Socket
Socket
Sign inDemoInstall

react-router

Package Overview
Dependencies
4
Maintainers
3
Versions
382
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.0-experimental-0f2dd78c to 0.0.0-experimental-0f302655

416

CHANGELOG.md
# `react-router`
## 6.22.3
### Patch Changes
- Updated dependencies:
- `@remix-run/router@1.15.3`
## 6.22.2
### Patch Changes
- Updated dependencies:
- `@remix-run/router@1.15.2`
## 6.22.1
### Patch Changes
- Fix encoding/decoding issues with pre-encoded dynamic parameter values ([#11199](https://github.com/remix-run/react-router/pull/11199))
- Updated dependencies:
- `@remix-run/router@1.15.1`
## 6.22.0
### Patch Changes
- Updated dependencies:
- `@remix-run/router@1.15.0`
## 6.21.3
### Patch Changes
- Remove leftover `unstable_` prefix from `Blocker`/`BlockerFunction` types ([#11187](https://github.com/remix-run/react-router/pull/11187))
## 6.21.2
### Patch Changes
- Updated dependencies:
- `@remix-run/router@1.14.2`
## 6.21.1
### Patch Changes
- Fix bug with `route.lazy` not working correctly on initial SPA load when `v7_partialHydration` is specified ([#11121](https://github.com/remix-run/react-router/pull/11121))
- Updated dependencies:
- `@remix-run/router@1.14.1`
## 6.21.0
### Minor Changes
- Add a new `future.v7_relativeSplatPath` flag to implement a breaking bug fix to relative routing when inside a splat route. ([#11087](https://github.com/remix-run/react-router/pull/11087))
This fix was originally added in [#10983](https://github.com/remix-run/react-router/issues/10983) and was later reverted in [#11078](https://github.com/remix-run/react-router/pull/11078) because it was determined that a large number of existing applications were relying on the buggy behavior (see [#11052](https://github.com/remix-run/react-router/issues/11052))
**The Bug**
The buggy behavior is that without this flag, the default behavior when resolving relative paths is to _ignore_ any splat (`*`) portion of the current route path.
**The Background**
This decision was originally made thinking that it would make the concept of nested different sections of your apps in `<Routes>` easier if relative routing would _replace_ the current splat:
```jsx
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />} />
<Route path="dashboard/*" element={<Dashboard />} />
</Routes>
</BrowserRouter>
```
Any paths like `/dashboard`, `/dashboard/team`, `/dashboard/projects` will match the `Dashboard` route. The dashboard component itself can then render nested `<Routes>`:
```jsx
function Dashboard() {
return (
<div>
<h2>Dashboard</h2>
<nav>
<Link to="/">Dashboard Home</Link>
<Link to="team">Team</Link>
<Link to="projects">Projects</Link>
</nav>
<Routes>
<Route path="/" element={<DashboardHome />} />
<Route path="team" element={<DashboardTeam />} />
<Route path="projects" element={<DashboardProjects />} />
</Routes>
</div>
);
}
```
Now, all links and route paths are relative to the router above them. This makes code splitting and compartmentalizing your app really easy. You could render the `Dashboard` as its own independent app, or embed it into your large app without making any changes to it.
**The Problem**
The problem is that this concept of ignoring part of a path breaks a lot of other assumptions in React Router - namely that `"."` always means the current location pathname for that route. When we ignore the splat portion, we start getting invalid paths when using `"."`:
```jsx
// If we are on URL /dashboard/team, and we want to link to /dashboard/team:
function DashboardTeam() {
// ❌ This is broken and results in <a href="/dashboard">
return <Link to=".">A broken link to the Current URL</Link>;
// ✅ This is fixed but super unintuitive since we're already at /dashboard/team!
return <Link to="./team">A broken link to the Current URL</Link>;
}
```
We've also introduced an issue that we can no longer move our `DashboardTeam` component around our route hierarchy easily - since it behaves differently if we're underneath a non-splat route, such as `/dashboard/:widget`. Now, our `"."` links will, properly point to ourself _inclusive of the dynamic param value_ so behavior will break from it's corresponding usage in a `/dashboard/*` route.
Even worse, consider a nested splat route configuration:
```jsx
<BrowserRouter>
<Routes>
<Route path="dashboard">
<Route path="*" element={<Dashboard />} />
</Route>
</Routes>
</BrowserRouter>
```
Now, a `<Link to=".">` and a `<Link to="..">` inside the `Dashboard` component go to the same place! That is definitely not correct!
Another common issue arose in Data Routers (and Remix) where any `<Form>` should post to it's own route `action` if you the user doesn't specify a form action:
```jsx
let router = createBrowserRouter({
path: "/dashboard",
children: [
{
path: "*",
action: dashboardAction,
Component() {
// ❌ This form is broken! It throws a 405 error when it submits because
// it tries to submit to /dashboard (without the splat value) and the parent
// `/dashboard` route doesn't have an action
return <Form method="post">...</Form>;
},
},
],
});
```
This is just a compounded issue from the above because the default location for a `Form` to submit to is itself (`"."`) - and if we ignore the splat portion, that now resolves to the parent route.
**The Solution**
If you are leveraging this behavior, it's recommended to enable the future flag, move your splat to it's own route, and leverage `../` for any links to "sibling" pages:
```jsx
<BrowserRouter>
<Routes>
<Route path="dashboard">
<Route index path="*" element={<Dashboard />} />
</Route>
</Routes>
</BrowserRouter>
function Dashboard() {
return (
<div>
<h2>Dashboard</h2>
<nav>
<Link to="..">Dashboard Home</Link>
<Link to="../team">Team</Link>
<Link to="../projects">Projects</Link>
</nav>
<Routes>
<Route path="/" element={<DashboardHome />} />
<Route path="team" element={<DashboardTeam />} />
<Route path="projects" element={<DashboardProjects />} />
</Router>
</div>
);
}
```
This way, `.` means "the full current pathname for my route" in all cases (including static, dynamic, and splat routes) and `..` always means "my parents pathname".
### Patch Changes
- Properly handle falsy error values in ErrorBoundary's ([#11071](https://github.com/remix-run/react-router/pull/11071))
- Updated dependencies:
- `@remix-run/router@1.14.0`
## 6.20.1
### Patch Changes
- Revert the `useResolvedPath` fix for splat routes due to a large number of applications that were relying on the buggy behavior (see <https://github.com/remix-run/react-router/issues/11052#issuecomment-1836589329>). We plan to re-introduce this fix behind a future flag in the next minor version. ([#11078](https://github.com/remix-run/react-router/pull/11078))
- Updated dependencies:
- `@remix-run/router@1.13.1`
## 6.20.0
### Minor Changes
- Export the `PathParam` type from the public API ([#10719](https://github.com/remix-run/react-router/pull/10719))
### Patch Changes
- Fix bug with `resolveTo` in splat routes ([#11045](https://github.com/remix-run/react-router/pull/11045))
- This is a follow up to [#10983](https://github.com/remix-run/react-router/pull/10983) to handle the few other code paths using `getPathContributingMatches`
- This removes the `UNSAFE_getPathContributingMatches` export from `@remix-run/router` since we no longer need this in the `react-router`/`react-router-dom` layers
- Updated dependencies:
- `@remix-run/router@1.13.0`
## 6.19.0
### Minor Changes
- Add `unstable_flushSync` option to `useNavigate`/`useSumbit`/`fetcher.load`/`fetcher.submit` to opt-out of `React.startTransition` and into `ReactDOM.flushSync` for state updates ([#11005](https://github.com/remix-run/react-router/pull/11005))
- Remove the `unstable_` prefix from the [`useBlocker`](https://reactrouter.com/en/main/hooks/use-blocker) hook as it's been in use for enough time that we are confident in the API. We do not plan to remove the prefix from `unstable_usePrompt` due to differences in how browsers handle `window.confirm` that prevent React Router from guaranteeing consistent/correct behavior. ([#10991](https://github.com/remix-run/react-router/pull/10991))
### Patch Changes
- Fix `useActionData` so it returns proper contextual action data and not _any_ action data in the tree ([#11023](https://github.com/remix-run/react-router/pull/11023))
- Fix bug in `useResolvedPath` that would cause `useResolvedPath(".")` in a splat route to lose the splat portion of the URL path. ([#10983](https://github.com/remix-run/react-router/pull/10983))
- ⚠️ This fixes a quite long-standing bug specifically for `"."` paths inside a splat route which incorrectly dropped the splat portion of the URL. If you are relative routing via `"."` inside a splat route in your application you should double check that your logic is not relying on this buggy behavior and update accordingly.
- Updated dependencies:
- `@remix-run/router@1.12.0`
## 6.18.0
### Patch Changes
- Fix the `future` prop on `BrowserRouter`, `HashRouter` and `MemoryRouter` so that it accepts a `Partial<FutureConfig>` instead of requiring all flags to be included. ([#10962](https://github.com/remix-run/react-router/pull/10962))
- Updated dependencies:
- `@remix-run/router@1.11.0`
## 6.17.0
### Patch Changes
- Fix `RouterProvider` `future` prop type to be a `Partial<FutureConfig>` so that not all flags must be specified ([#10900](https://github.com/remix-run/react-router/pull/10900))
- Updated dependencies:
- `@remix-run/router@1.10.0`
## 6.16.0
### Minor Changes
- In order to move towards stricter TypeScript support in the future, we're aiming to replace current usages of `any` with `unknown` on exposed typings for user-provided data. To do this in Remix v2 without introducing breaking changes in React Router v6, we have added generics to a number of shared types. These continue to default to `any` in React Router and are overridden with `unknown` in Remix. In React Router v7 we plan to move these to `unknown` as a breaking change. ([#10843](https://github.com/remix-run/react-router/pull/10843))
- `Location` now accepts a generic for the `location.state` value
- `ActionFunctionArgs`/`ActionFunction`/`LoaderFunctionArgs`/`LoaderFunction` now accept a generic for the `context` parameter (only used in SSR usages via `createStaticHandler`)
- The return type of `useMatches` (now exported as `UIMatch`) accepts generics for `match.data` and `match.handle` - both of which were already set to `unknown`
- Move the `@private` class export `ErrorResponse` to an `UNSAFE_ErrorResponseImpl` export since it is an implementation detail and there should be no construction of `ErrorResponse` instances in userland. This frees us up to export a `type ErrorResponse` which correlates to an instance of the class via `InstanceType`. Userland code should only ever be using `ErrorResponse` as a type and should be type-narrowing via `isRouteErrorResponse`. ([#10811](https://github.com/remix-run/react-router/pull/10811))
- Export `ShouldRevalidateFunctionArgs` interface ([#10797](https://github.com/remix-run/react-router/pull/10797))
- Removed private/internal APIs only required for the Remix v1 backwards compatibility layer and no longer needed in Remix v2 (`_isFetchActionRedirect`, `_hasFetcherDoneAnything`) ([#10715](https://github.com/remix-run/react-router/pull/10715))
### Patch Changes
- Updated dependencies:
- `@remix-run/router@1.9.0`
## 6.15.0
### Minor Changes
- Add's a new `redirectDocument()` function which allows users to specify that a redirect from a `loader`/`action` should trigger a document reload (via `window.location`) instead of attempting to navigate to the redirected location via React Router ([#10705](https://github.com/remix-run/react-router/pull/10705))
### Patch Changes
- Ensure `useRevalidator` is referentially stable across re-renders if revalidations are not actively occurring ([#10707](https://github.com/remix-run/react-router/pull/10707))
- Updated dependencies:
- `@remix-run/router@1.8.0`
## 6.14.2
### Patch Changes
- Updated dependencies:
- `@remix-run/router@1.7.2`
## 6.14.1
### Patch Changes
- Fix loop in `unstable_useBlocker` when used with an unstable blocker function ([#10652](https://github.com/remix-run/react-router/pull/10652))
- Fix issues with reused blockers on subsequent navigations ([#10656](https://github.com/remix-run/react-router/pull/10656))
- Updated dependencies:
- `@remix-run/router@1.7.1`
## 6.14.0
### Patch Changes
- Strip `basename` from locations provided to `unstable_useBlocker` functions to match `useLocation` ([#10573](https://github.com/remix-run/react-router/pull/10573))
- Fix `generatePath` when passed a numeric `0` value parameter ([#10612](https://github.com/remix-run/react-router/pull/10612))
- Fix `unstable_useBlocker` key issues in `StrictMode` ([#10573](https://github.com/remix-run/react-router/pull/10573))
- Fix `tsc --skipLibCheck:false` issues on React 17 ([#10622](https://github.com/remix-run/react-router/pull/10622))
- Upgrade `typescript` to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581))
- Updated dependencies:
- `@remix-run/router@1.7.0`
## 6.13.0
### Minor Changes
- Move [`React.startTransition`](https://react.dev/reference/react/startTransition) usage behind a [future flag](https://reactrouter.com/en/main/guides/api-development-strategy) to avoid issues with existing incompatible `Suspense` usages. We recommend folks adopting this flag to be better compatible with React concurrent mode, but if you run into issues you can continue without the use of `startTransition` until v7. Issues usually boils down to creating net-new promises during the render cycle, so if you run into issues you should either lift your promise creation out of the render cycle or put it behind a `useMemo`. ([#10596](https://github.com/remix-run/react-router/pull/10596))
Existing behavior will no longer include `React.startTransition`:
```jsx
<BrowserRouter>
<Routes>{/*...*/}</Routes>
</BrowserRouter>
<RouterProvider router={router} />
```
If you wish to enable `React.startTransition`, pass the future flag to your component:
```jsx
<BrowserRouter future={{ v7_startTransition: true }}>
<Routes>{/*...*/}</Routes>
</BrowserRouter>
<RouterProvider router={router} future={{ v7_startTransition: true }}/>
```
### Patch Changes
- Work around webpack/terser `React.startTransition` minification bug in production mode ([#10588](https://github.com/remix-run/react-router/pull/10588))
## 6.12.1
> \[!WARNING]
> Please use version `6.13.0` or later instead of `6.12.1`. This version suffers from a `webpack`/`terser` minification issue resulting in invalid minified code in your resulting production bundles which can cause issues in your application. See [#10579](https://github.com/remix-run/react-router/issues/10579) for more details.
### Patch Changes
- Adjust feature detection of `React.startTransition` to fix webpack + react 17 compilation error ([#10569](https://github.com/remix-run/react-router/pull/10569))
## 6.12.0
### Minor Changes
- Wrap internal router state updates with `React.startTransition` if it exists ([#10438](https://github.com/remix-run/react-router/pull/10438))
### Patch Changes
- Updated dependencies:
- `@remix-run/router@1.6.3`
## 6.11.2
### Patch Changes
- Fix `basename` duplication in descendant `<Routes>` inside a `<RouterProvider>` ([#10492](https://github.com/remix-run/react-router/pull/10492))
- Updated dependencies:
- `@remix-run/router@1.6.2`
## 6.11.1
### Patch Changes
- Fix usage of `Component` API within descendant `<Routes>` ([#10434](https://github.com/remix-run/react-router/pull/10434))
- Fix bug when calling `useNavigate` from `<Routes>` inside a `<RouterProvider>` ([#10432](https://github.com/remix-run/react-router/pull/10432))
- Fix usage of `<Navigate>` in strict mode when using a data router ([#10435](https://github.com/remix-run/react-router/pull/10435))
- Updated dependencies:
- `@remix-run/router@1.6.1`
## 6.11.0
### Patch Changes
- Log loader/action errors to the console in dev for easier stack trace evaluation ([#10286](https://github.com/remix-run/react-router/pull/10286))
- Fix bug preventing rendering of descendant `<Routes>` when `RouterProvider` errors existed ([#10374](https://github.com/remix-run/react-router/pull/10374))
- Fix inadvertent re-renders when using `Component` instead of `element` on a route definition ([#10287](https://github.com/remix-run/react-router/pull/10287))
- Fix detection of `useNavigate` in the render cycle by setting the `activeRef` in a layout effect, allowing the `navigate` function to be passed to child components and called in a `useEffect` there. ([#10394](https://github.com/remix-run/react-router/pull/10394))
- Switched from `useSyncExternalStore` to `useState` for internal `@remix-run/router` router state syncing in `<RouterProvider>`. We found some [subtle bugs](https://codesandbox.io/s/use-sync-external-store-loop-9g7b81) where router state updates got propagated _before_ other normal `useState` updates, which could lead to footguns in `useEffect` calls. ([#10377](https://github.com/remix-run/react-router/pull/10377), [#10409](https://github.com/remix-run/react-router/pull/10409))
- Allow `useRevalidator()` to resolve a loader-driven error boundary scenario ([#10369](https://github.com/remix-run/react-router/pull/10369))
- Avoid unnecessary unsubscribe/resubscribes on router state changes ([#10409](https://github.com/remix-run/react-router/pull/10409))
- When using a `RouterProvider`, `useNavigate`/`useSubmit`/`fetcher.submit` are now stable across location changes, since we can handle relative routing via the `@remix-run/router` instance and get rid of our dependence on `useLocation()`. When using `BrowserRouter`, these hooks remain unstable across location changes because they still rely on `useLocation()`. ([#10336](https://github.com/remix-run/react-router/pull/10336))
- Updated dependencies:
- `@remix-run/router@1.6.0`
## 6.10.0
### Minor Changes
- Added support for [**Future Flags**](https://reactrouter.com/en/main/guides/api-development-strategy) in React Router. The first flag being introduced is `future.v7_normalizeFormMethod` which will normalize the exposed `useNavigation()/useFetcher()` `formMethod` fields as uppercase HTTP methods to align with the `fetch()` behavior. ([#10207](https://github.com/remix-run/react-router/pull/10207))
- When `future.v7_normalizeFormMethod === false` (default v6 behavior),
- `useNavigation().formMethod` is lowercase
- `useFetcher().formMethod` is lowercase
- When `future.v7_normalizeFormMethod === true`:
- `useNavigation().formMethod` is uppercase
- `useFetcher().formMethod` is uppercase
### Patch Changes
- Fix route ID generation when using Fragments in `createRoutesFromElements` ([#10193](https://github.com/remix-run/react-router/pull/10193))
- Updated dependencies:
- `@remix-run/router@1.5.0`
## 6.9.0

@@ -108,4 +514,4 @@

- Fix `generatePath` incorrectly applying parameters in some cases ([`bc6fefa1`](https://github.com/remix-run/react-router/commit/bc6fefa19019ce9f5250c8b5af9b8c5d3390e9d1))
- Improve memoization for context providers to avoid unnecessary re-renders ([`bc6fefa1`](https://github.com/remix-run/react-router/commit/bc6fefa19019ce9f5250c8b5af9b8c5d3390e9d1))
- Fix `generatePath` incorrectly applying parameters in some cases ([#10078](https://github.com/remix-run/react-router/pull/10078))
- Improve memoization for context providers to avoid unnecessary re-renders ([#9983](https://github.com/remix-run/react-router/pull/9983))

@@ -266,3 +672,3 @@ ## 6.8.2

Whoa this is a big one! `6.4.0` brings all the data loading and mutation APIs over from Remix. Here's a quick high level overview, but it's recommended you go check out the [docs][rr-docs], especially the [feature overview][rr-feature-overview] and the [tutorial][rr-tutorial].
Whoa this is a big one! `6.4.0` brings all the data loading and mutation APIs over from Remix. Here's a quick high level overview, but it's recommended you go check out the [docs](https://reactrouter.com), especially the [feature overview](https://reactrouter.com/start/overview) and the [tutorial](https://reactrouter.com/start/tutorial).

@@ -285,5 +691,1 @@ **New APIs**

- `@remix-run/router@1.0.0`
[rr-docs]: https://reactrouter.com
[rr-feature-overview]: https://reactrouter.com/start/overview
[rr-tutorial]: https://reactrouter.com/start/tutorial

31

dist/index.d.ts

@@ -1,23 +0,26 @@

import type { ActionFunction, ActionFunctionArgs, Blocker, BlockerFunction, Fetcher, HydrationState, JsonFunction, LoaderFunction, LoaderFunctionArgs, Location, Navigation, Params, ParamParseKey, Path, PathMatch, PathPattern, RedirectFunction, Router as RemixRouter, ShouldRevalidateFunction, To, InitialEntry, LazyRouteFunction, FutureConfig } from "@remix-run/router";
import { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from "@remix-run/router";
import type { AwaitProps, MemoryRouterProps, NavigateProps, OutletProps, RouteProps, PathRouteProps, LayoutRouteProps, IndexRouteProps, RouterProps, RoutesProps, RouterProviderProps } from "./lib/components";
import { createRoutesFromChildren, renderMatches, Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes } from "./lib/components";
import type { DataRouteMatch, DataRouteObject, IndexRouteObject, Navigator, NavigateOptions, NonIndexRouteObject, RouteMatch, RouteObject, RelativeRoutingType } from "./lib/context";
import type { ActionFunction, ActionFunctionArgs, Blocker, BlockerFunction, unstable_DataStrategyFunction, unstable_DataStrategyFunctionArgs, unstable_DataStrategyMatch, ErrorResponse, Fetcher, HydrationState, InitialEntry, JsonFunction, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, Location, Navigation, ParamParseKey, Params, Path, PathMatch, PathParam, PathPattern, RedirectFunction, RelativeRoutingType, Router as RemixRouter, FutureConfig as RouterFutureConfig, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, To, UIMatch, unstable_HandlerResult } from "@remix-run/router";
import { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, resolvePath } from "@remix-run/router";
import type { AwaitProps, FutureConfig, IndexRouteProps, LayoutRouteProps, MemoryRouterProps, NavigateProps, OutletProps, PathRouteProps, RouteProps, RouterProps, RouterProviderProps, RoutesProps } from "./lib/components";
import { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, createRoutesFromChildren, renderMatches } from "./lib/components";
import type { DataRouteMatch, DataRouteObject, IndexRouteObject, NavigateOptions, Navigator, NonIndexRouteObject, RouteMatch, RouteObject } from "./lib/context";
import { DataRouterContext, DataRouterStateContext, LocationContext, NavigationContext, RouteContext } from "./lib/context";
import type { NavigateFunction } from "./lib/hooks";
import { useBlocker, useHref, useInRouterContext, useLocation, useMatch, useNavigationType, useNavigate, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useActionData, useAsyncError, useAsyncValue, useLoaderData, useMatches, useNavigation, useRevalidator, useRouteError, useRouteLoaderData } from "./lib/hooks";
declare type Hash = string;
declare type Pathname = string;
declare type Search = string;
export type { ActionFunction, ActionFunctionArgs, AwaitProps, Blocker as unstable_Blocker, BlockerFunction as unstable_BlockerFunction, DataRouteMatch, DataRouteObject, Fetcher, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LazyRouteFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathPattern, PathRouteProps, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, To, };
export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, createPath, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, defer, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, renderMatches, resolvePath, useActionData, useAsyncError, useAsyncValue, useBlocker as unstable_useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, };
declare function detectErrorBoundary(route: RouteObject): boolean;
import { useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteId, useRouteLoaderData, useRoutes, useRoutesImpl } from "./lib/hooks";
type Hash = string;
type Pathname = string;
type Search = string;
export type { ActionFunction, ActionFunctionArgs, AwaitProps, DataRouteMatch, DataRouteObject, unstable_DataStrategyFunction, unstable_DataStrategyFunctionArgs, unstable_DataStrategyMatch, ErrorResponse, Fetcher, FutureConfig, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LayoutRouteProps, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, ParamParseKey, Params, Path, PathMatch, PathParam, PathPattern, PathRouteProps, Pathname, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, To, UIMatch, Blocker, BlockerFunction, unstable_HandlerResult, };
export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, createPath, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, resolvePath, useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, };
declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
hasErrorBoundary: boolean;
};
export declare function createMemoryRouter(routes: RouteObject[], opts?: {
basename?: string;
future?: FutureConfig;
future?: Partial<Omit<RouterFutureConfig, "v7_prependBasename">>;
hydrationData?: HydrationState;
initialEntries?: InitialEntry[];
initialIndex?: number;
unstable_dataStrategy?: unstable_DataStrategyFunction;
}): RemixRouter;
/** @internal */
export { NavigationContext as UNSAFE_NavigationContext, LocationContext as UNSAFE_LocationContext, RouteContext as UNSAFE_RouteContext, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, detectErrorBoundary as UNSAFE_detectErrorBoundary, };
export { 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, };
/**
* React Router v0.0.0-experimental-0f2dd78c
* React Router v0.0.0-experimental-0f302655
*

@@ -11,198 +11,32 @@ * Copyright (c) Remix Software Inc.

*/
import { UNSAFE_invariant, joinPaths, matchPath, UNSAFE_getPathContributingMatches, UNSAFE_warning, resolveTo, parsePath, matchRoutes, Action, isRouteErrorResponse, createMemoryHistory, stripBasename, AbortedDeferredError, createRouter } from '@remix-run/router';
export { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from '@remix-run/router';
import * as React from 'react';
import { UNSAFE_invariant, joinPaths, matchPath, UNSAFE_getResolveToMatches, UNSAFE_warning, resolveTo, parsePath, matchRoutes, Action, UNSAFE_convertRouteMatchToUiMatch, stripBasename, IDLE_BLOCKER, isRouteErrorResponse, createMemoryHistory, AbortedDeferredError, createRouter } from '@remix-run/router';
export { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, resolvePath } from '@remix-run/router';
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
function isPolyfill(x, y) {
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
;
}
const is = typeof Object.is === "function" ? Object.is : isPolyfill; // Intentionally not using named imports because Rollup uses dynamic
// dispatch for CommonJS interop named imports.
const {
useState,
useEffect,
useLayoutEffect,
useDebugValue
} = React;
let didWarnOld18Alpha = false;
let didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
// because of a very particular set of implementation details and assumptions
// -- change any one of them and it will break. The most important assumption
// is that updates are always synchronous, because concurrent rendering is
// only available in versions of React that also have a built-in
// useSyncExternalStore API. And we only use this shim when the built-in API
// does not exist.
//
// Do not assume that the clever hacks used by this hook also work in general.
// The point of this shim is to replace the need for hacks by other libraries.
function useSyncExternalStore$2(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
// React do not expose a way to check if we're hydrating. So users of the shim
// will need to track that themselves and return the correct value
// from `getSnapshot`.
getServerSnapshot) {
if (process.env.NODE_ENV !== "production") {
if (!didWarnOld18Alpha) {
if ("startTransition" in React) {
didWarnOld18Alpha = true;
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.");
function _extends() {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
} // Read the current snapshot from the store on every render. Again, this
// breaks the rules of React, and only works here because of specific
// implementation details, most importantly that updates are
// always synchronous.
const value = getSnapshot();
if (process.env.NODE_ENV !== "production") {
if (!didWarnUncachedGetSnapshot) {
const cachedValue = getSnapshot();
if (!is(value, cachedValue)) {
console.error("The result of getSnapshot should be cached to avoid an infinite loop");
didWarnUncachedGetSnapshot = true;
}
}
} // Because updates are synchronous, we don't queue them. Instead we force a
// re-render whenever the subscribed state changes by updating an some
// arbitrary useState hook. Then, during render, we call getSnapshot to read
// the current value.
//
// Because we don't actually use the state returned by the useState hook, we
// can save a bit of memory by storing other stuff in that slot.
//
// To implement the early bailout, we need to track some things on a mutable
// object. Usually, we would put that in a useRef hook, but we can stash it in
// our useState hook instead.
//
// To force a re-render, we call forceUpdate({inst}). That works because the
// new object always fails an equality check.
const [{
inst
}, forceUpdate] = useState({
inst: {
value,
getSnapshot
}
}); // Track the latest getSnapshot function with a ref. This needs to be updated
// in the layout phase so we can access it during the tearing check that
// happens on subscribe.
useLayoutEffect(() => {
inst.value = value;
inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
// commit phase if there was an interleaved mutation. In concurrent mode
// this can happen all the time, but even in synchronous mode, an earlier
// effect may have mutated the store.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceUpdate({
inst
});
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [subscribe, value, getSnapshot]);
useEffect(() => {
// Check for changes right before subscribing. Subsequent changes will be
// detected in the subscription handler.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceUpdate({
inst
});
}
const handleStoreChange = () => {
// TODO: Because there is no cross-renderer API for batching updates, it's
// up to the consumer of this library to wrap their subscription event
// with unstable_batchedUpdates. Should we try to detect when this isn't
// the case and print a warning in development?
// The store changed. Check if the snapshot changed since the last time we
// read from the store.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceUpdate({
inst
});
}
}; // Subscribe to the store and return a clean-up function.
return subscribe(handleStoreChange); // eslint-disable-next-line react-hooks/exhaustive-deps
}, [subscribe]);
useDebugValue(value);
return value;
return target;
};
return _extends.apply(this, arguments);
}
function checkIfSnapshotChanged(inst) {
const latestGetSnapshot = inst.getSnapshot;
const prevValue = inst.value;
try {
const nextValue = latestGetSnapshot();
return !is(prevValue, nextValue);
} catch (error) {
return true;
}
}
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
// Note: The shim does not use getServerSnapshot, because pre-18 versions of
// React do not expose a way to check if we're hydrating. So users of the shim
// will need to track that themselves and return the correct value
// from `getSnapshot`.
return getSnapshot();
}
/**
* Inlined into the react-router repo since use-sync-external-store does not
* provide a UMD-compatible package, so we need this to be able to distribute
* UMD react-router bundles
*/
const canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
const isServerEnvironment = !canUseDOM;
const shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore$2;
const useSyncExternalStore = "useSyncExternalStore" in React ? (module => module.useSyncExternalStore)(React) : shim;
// Create react-specific types from the agnostic types in @remix-run/router to
// export from react-router
const DataRouterContext = /*#__PURE__*/React.createContext(null);
if (process.env.NODE_ENV !== "production") {
DataRouterContext.displayName = "DataRouter";
}
const DataRouterStateContext = /*#__PURE__*/React.createContext(null);
if (process.env.NODE_ENV !== "production") {
DataRouterStateContext.displayName = "DataRouterState";
}
const AwaitContext = /*#__PURE__*/React.createContext(null);
if (process.env.NODE_ENV !== "production") {

@@ -212,25 +46,29 @@ AwaitContext.displayName = "Await";

/**
* A Navigator is a "location changer"; it's how you get to different locations.
*
* Every history instance conforms to the Navigator interface, but the
* distinction is useful primarily when it comes to the low-level `<Router>` API
* where both the location and a navigator must be provided separately in order
* to avoid "tearing" that may occur in a suspense-enabled app if the action
* and/or location were to be read directly from the history instance.
*/
const NavigationContext = /*#__PURE__*/React.createContext(null);
if (process.env.NODE_ENV !== "production") {
NavigationContext.displayName = "Navigation";
}
const LocationContext = /*#__PURE__*/React.createContext(null);
if (process.env.NODE_ENV !== "production") {
LocationContext.displayName = "Location";
}
const RouteContext = /*#__PURE__*/React.createContext({
outlet: null,
matches: []
matches: [],
isDataRoute: false
});
if (process.env.NODE_ENV !== "production") {
RouteContext.displayName = "Route";
}
const RouteErrorContext = /*#__PURE__*/React.createContext(null);
if (process.env.NODE_ENV !== "production") {

@@ -240,19 +78,2 @@ RouteErrorContext.displayName = "RouteError";

function _extends() {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
/**

@@ -264,3 +85,2 @@ * Returns the full href for the given "to" value. This is useful for building

*/
function useHref(to, _temp) {

@@ -284,11 +104,11 @@ let {

});
let joinedPathname = pathname; // If we're operating within a basename, prepend it to the pathname prior
let joinedPathname = pathname;
// If we're operating within a basename, prepend it to the pathname prior
// to creating the href. If this is a root navigation, then just use the raw
// basename which allows the basename to have full control over the presence
// of a trailing slash on root links
if (basename !== "/") {
joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
}
return navigator.createHref({

@@ -300,11 +120,12 @@ pathname: joinedPathname,

}
/**
* Returns true if this component is a descendant of a <Router>.
* Returns true if this component is a descendant of a `<Router>`.
*
* @see https://reactrouter.com/hooks/use-in-router-context
*/
function useInRouterContext() {
return React.useContext(LocationContext) != null;
}
/**

@@ -320,3 +141,2 @@ * Returns the current location object, which represents the current URL in web

*/
function useLocation() {

@@ -328,2 +148,3 @@ !useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the

}
/**

@@ -335,14 +156,13 @@ * Returns the current navigation action which describes how the router came to

*/
function useNavigationType() {
return React.useContext(LocationContext).navigationType;
}
/**
* Returns a PathMatch object if the given pattern matches the current URL.
* This is useful for components that need to know "active" state, e.g.
* <NavLink>.
* `<NavLink>`.
*
* @see https://reactrouter.com/hooks/use-match
*/
function useMatch(pattern) {

@@ -357,2 +177,3 @@ !useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the

}
/**

@@ -362,4 +183,17 @@ * The interface for the navigate() function returned from useNavigate().

const navigateEffectWarning = "You should call navigate() in a React.useEffect(), not when " + "your component is first rendered.";
// Mute warnings for calls to useNavigate in SSR environments
function useIsomorphicLayoutEffect(cb) {
let isStatic = React.useContext(NavigationContext).static;
if (!isStatic) {
// We should be able to get rid of this once react 18.3 is released
// See: https://github.com/facebook/react/pull/26395
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useLayoutEffect(cb);
}
}
/**
* Returns an imperative method for changing the location. Used by <Link>s, but
* Returns an imperative method for changing the location. Used by `<Link>`s, but
* may also be used by other elements to change the location.

@@ -370,7 +204,17 @@ *

function useNavigate() {
let {
isDataRoute
} = React.useContext(RouteContext);
// Conditional usage is OK here because the usage of a data router is static
// eslint-disable-next-line react-hooks/rules-of-hooks
return isDataRoute ? useNavigateStable() : useNavigateUnstable();
}
function useNavigateUnstable() {
!useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
// router loaded. We can help them understand how to avoid that.
"useNavigate() may be used only in the context of a <Router> component.") : UNSAFE_invariant(false) : void 0;
let dataRouterContext = React.useContext(DataRouterContext);
let {
basename,
future,
navigator

@@ -384,5 +228,5 @@ } = React.useContext(NavigationContext);

} = useLocation();
let routePathnamesJson = JSON.stringify(UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase));
let routePathnamesJson = JSON.stringify(UNSAFE_getResolveToMatches(matches, future.v7_relativeSplatPath));
let activeRef = React.useRef(false);
React.useEffect(() => {
useIsomorphicLayoutEffect(() => {
activeRef.current = true;

@@ -394,6 +238,7 @@ });

}
process.env.NODE_ENV !== "production" ? UNSAFE_warning(activeRef.current, navigateEffectWarning) : void 0;
process.env.NODE_ENV !== "production" ? UNSAFE_warning(activeRef.current, "You should call navigate() in a React.useEffect(), not when " + "your component is first rendered.") : void 0;
// Short circuit here since if this happens on first render the navigate
// is useless because we haven't wired up our history listener yet
if (!activeRef.current) return;
if (typeof to === "number") {

@@ -403,17 +248,19 @@ navigator.go(to);

}
let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path");
let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path"); // If we're operating within a basename, prepend it to the pathname prior
// to handing off to history. If this is a root navigation, then we
// navigate to the raw basename which allows the basename to have full
// control over the presence of a trailing slash on root links
if (basename !== "/") {
// If we're operating within a basename, prepend it to the pathname prior
// to handing off to history (but only if we're not in a data router,
// otherwise it'll prepend the basename inside of the router).
// If this is a root navigation, then we navigate to the raw basename
// which allows the basename to have full control over the presence of a
// trailing slash on root links
if (dataRouterContext == null && basename !== "/") {
path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
}
(!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
}, [basename, navigator, routePathnamesJson, locationPathname]);
}, [basename, navigator, routePathnamesJson, locationPathname, dataRouterContext]);
return navigate;
}
const OutletContext = /*#__PURE__*/React.createContext(null);
/**

@@ -424,16 +271,14 @@ * Returns the context (if provided) for the child route at this level of the route

*/
function useOutletContext() {
return React.useContext(OutletContext);
}
/**
* Returns the element for the child route at this level of the route
* hierarchy. Used internally by <Outlet> to render child routes.
* hierarchy. Used internally by `<Outlet>` to render child routes.
*
* @see https://reactrouter.com/hooks/use-outlet
*/
function useOutlet(context) {
let outlet = React.useContext(RouteContext).outlet;
if (outlet) {

@@ -444,5 +289,5 @@ return /*#__PURE__*/React.createElement(OutletContext.Provider, {

}
return outlet;
}
/**

@@ -454,3 +299,2 @@ * Returns an object of key/value pairs of the dynamic params from the current

*/
function useParams() {

@@ -463,2 +307,3 @@ let {

}
/**

@@ -469,3 +314,2 @@ * Resolves the pathname of the given `to` value against the current location.

*/
function useResolvedPath(to, _temp2) {

@@ -476,2 +320,5 @@ let {

let {
future
} = React.useContext(NavigationContext);
let {
matches

@@ -482,9 +329,10 @@ } = React.useContext(RouteContext);

} = useLocation();
let routePathnamesJson = JSON.stringify(UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase));
let routePathnamesJson = JSON.stringify(UNSAFE_getResolveToMatches(matches, future.v7_relativeSplatPath));
return React.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);
}
/**
* Returns the element of the route that matched the current location, prepared
* with the correct context to render the remainder of the route tree. Route
* elements in the tree must render an <Outlet> to render their child route's
* elements in the tree must render an `<Outlet>` to render their child route's
* element.

@@ -494,4 +342,8 @@ *

*/
function useRoutes(routes, locationArg) {
return useRoutesImpl(routes, locationArg);
}
function useRoutes(routes, locationArg) {
// Internal implementation with accept optional param for RouterProvider usage
function useRoutesImpl(routes, locationArg, dataRouterState, future) {
!useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the

@@ -503,3 +355,2 @@ // router loaded. We can help them understand how to avoid that.

} = React.useContext(NavigationContext);
let dataRouterStateContext = React.useContext(DataRouterStateContext);
let {

@@ -513,3 +364,2 @@ matches: parentMatches

let parentRoute = routeMatch && routeMatch.route;
if (process.env.NODE_ENV !== "production") {

@@ -539,9 +389,6 @@ // You won't get a warning about 2 different <Routes> under a <Route>

}
let locationFromContext = useLocation();
let location;
if (locationArg) {
var _parsedLocationArg$pa;
let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;

@@ -553,25 +400,43 @@ !(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;

}
let pathname = location.pathname || "/";
let remainingPathname = parentPathnameBase === "/" ? pathname : pathname.slice(parentPathnameBase.length) || "/";
let remainingPathname = pathname;
if (parentPathnameBase !== "/") {
// Determine the remaining pathname by removing the # of URL segments the
// parentPathnameBase has, instead of removing based on character count.
// This is because we can't guarantee that incoming/outgoing encodings/
// decodings will match exactly.
// We decode paths before matching on a per-segment basis with
// decodeURIComponent(), but we re-encode pathnames via `new URL()` so they
// match what `window.location.pathname` would reflect. Those don't 100%
// align when it comes to encoded URI characters such as % and &.
//
// So we may end up with:
// pathname: "/descendant/a%25b/match"
// parentPathnameBase: "/descendant/a%b"
//
// And the direct substring removal approach won't work :/
let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
let segments = pathname.replace(/^\//, "").split("/");
remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
}
let matches = matchRoutes(routes, {
pathname: remainingPathname
});
if (process.env.NODE_ENV !== "production") {
process.env.NODE_ENV !== "production" ? UNSAFE_warning(parentRoute || matches != null, "No routes matched location \"" + location.pathname + location.search + location.hash + "\" ") : void 0;
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;
process.env.NODE_ENV !== "production" ? UNSAFE_warning(matches == null || matches[matches.length - 1].route.element !== undefined || matches[matches.length - 1].route.Component !== undefined || matches[matches.length - 1].route.lazy !== 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;
}
let renderedMatches = _renderMatches(matches && matches.map(match => Object.assign({}, match, {
params: Object.assign({}, parentParams, match.params),
pathname: joinPaths([parentPathnameBase, // Re-encode pathnames that were decoded inside matchRoutes
pathname: joinPaths([parentPathnameBase,
// Re-encode pathnames that were decoded inside matchRoutes
navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname]),
pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([parentPathnameBase, // Re-encode pathnames that were decoded inside matchRoutes
pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([parentPathnameBase,
// Re-encode pathnames that were decoded inside matchRoutes
navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase])
})), parentMatches, dataRouterStateContext || undefined); // When a user passes in a `locationArg`, the associated routes need to
})), parentMatches, dataRouterState, future);
// When a user passes in a `locationArg`, the associated routes need to
// be wrapped in a new `LocationContext.Provider` in order for `useLocation`
// to use the scoped location instead of the global location.
if (locationArg && renderedMatches) {

@@ -591,6 +456,4 @@ return /*#__PURE__*/React.createElement(LocationContext.Provider, {

}
return renderedMatches;
}
function DefaultErrorComponent() {

@@ -610,11 +473,10 @@ let error = useRouteError();

let devInfo = null;
if (process.env.NODE_ENV !== "production") {
devInfo = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), /*#__PURE__*/React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own\xA0", /*#__PURE__*/React.createElement("code", {
console.error("Error handled by React Router default ErrorBoundary:", error);
devInfo = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), /*#__PURE__*/React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /*#__PURE__*/React.createElement("code", {
style: codeStyles
}, "ErrorBoundary"), " prop on\xA0", /*#__PURE__*/React.createElement("code", {
}, "ErrorBoundary"), " or", " ", /*#__PURE__*/React.createElement("code", {
style: codeStyles
}, "<Route>")));
}, "errorElement"), " prop on your route."));
}
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("h2", null, "Unexpected Application Error!"), /*#__PURE__*/React.createElement("h3", {

@@ -628,3 +490,3 @@ style: {

}
const defaultErrorElement = /*#__PURE__*/React.createElement(DefaultErrorComponent, null);
class RenderErrorBoundary extends React.Component {

@@ -635,6 +497,6 @@ constructor(props) {

location: props.location,
revalidation: props.revalidation,
error: props.error
};
}
static getDerivedStateFromError(error) {

@@ -645,3 +507,2 @@ return {

}
static getDerivedStateFromProps(props, state) {

@@ -656,25 +517,25 @@ // When we get into an error state, the user will likely click "back" to the

// comes in and the user recovers from the error.
if (state.location !== props.location) {
if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
return {
error: props.error,
location: props.location
location: props.location,
revalidation: props.revalidation
};
} // If we're not changing locations, preserve the location but still surface
}
// If we're not changing locations, preserve the location but still surface
// any new errors that may come through. We retain the existing error, we do
// this because the error provided from the app state may be cleared without
// the location changing.
return {
error: props.error || state.error,
location: state.location
error: props.error !== undefined ? props.error : state.error,
location: state.location,
revalidation: props.revalidation || state.revalidation
};
}
componentDidCatch(error, errorInfo) {
console.error("React Router caught the following error during render", error, errorInfo);
}
render() {
return this.state.error ? /*#__PURE__*/React.createElement(RouteContext.Provider, {
return this.state.error !== undefined ? /*#__PURE__*/React.createElement(RouteContext.Provider, {
value: this.props.routeContext

@@ -686,5 +547,3 @@ }, /*#__PURE__*/React.createElement(RouteErrorContext.Provider, {

}
}
function RenderedRoute(_ref) {

@@ -696,9 +555,9 @@ let {

} = _ref;
let dataRouterContext = React.useContext(DataRouterContext); // Track how deep we got in our render pass to emulate SSR componentDidCatch
let dataRouterContext = React.useContext(DataRouterContext);
// Track how deep we got in our render pass to emulate SSR componentDidCatch
// in a DataStaticRouter
if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
}
return /*#__PURE__*/React.createElement(RouteContext.Provider, {

@@ -708,10 +567,16 @@ value: routeContext

}
function _renderMatches(matches, parentMatches, dataRouterState) {
function _renderMatches(matches, parentMatches, dataRouterState, future) {
var _dataRouterState2;
if (parentMatches === void 0) {
parentMatches = [];
}
if (dataRouterState === void 0) {
dataRouterState = null;
}
if (future === void 0) {
future = null;
}
if (matches == null) {
if (dataRouterState != null && dataRouterState.errors) {
var _dataRouterState;
if ((_dataRouterState = dataRouterState) != null && _dataRouterState.errors) {
// Don't bail if we have data router errors so we can render them in the

@@ -724,41 +589,84 @@ // boundary. Use the pre-matched (or shimmed) matches

}
let renderedMatches = matches;
let renderedMatches = matches; // If we have data errors, trim matches to the highest error boundary
let errors = dataRouterState == null ? void 0 : dataRouterState.errors;
// If we have data errors, trim matches to the highest error boundary
let errors = (_dataRouterState2 = dataRouterState) == null ? void 0 : _dataRouterState2.errors;
if (errors != null) {
let errorIndex = renderedMatches.findIndex(m => m.route.id && (errors == null ? void 0 : errors[m.route.id]));
!(errorIndex >= 0) ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "Could not find a matching route for the current errors: " + errors) : UNSAFE_invariant(false) : void 0;
let errorIndex = renderedMatches.findIndex(m => m.route.id && (errors == null ? void 0 : errors[m.route.id]) !== undefined);
!(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;
renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
}
// If we're in a partial hydration mode, detect if we need to render down to
// a given HydrateFallback while we load the rest of the hydration data
let renderFallback = false;
let fallbackIndex = -1;
if (dataRouterState && future && future.v7_partialHydration) {
for (let i = 0; i < renderedMatches.length; i++) {
let match = renderedMatches[i];
// Track the deepest fallback up until the first route without data
if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
fallbackIndex = i;
}
if (match.route.id) {
let {
loaderData,
errors
} = dataRouterState;
let needsToRunLoader = match.route.loader && loaderData[match.route.id] === undefined && (!errors || errors[match.route.id] === undefined);
if (match.route.lazy || needsToRunLoader) {
// We found the first route that's not ready to render (waiting on
// lazy, or has a loader that hasn't run yet). Flag that we need to
// render a fallback and render up until the appropriate fallback
renderFallback = true;
if (fallbackIndex >= 0) {
renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
} else {
renderedMatches = [renderedMatches[0]];
}
break;
}
}
}
}
return renderedMatches.reduceRight((outlet, match, index) => {
let error = match.route.id ? errors == null ? void 0 : errors[match.route.id] : null; // Only data routers handle errors
// Only data routers handle errors/fallbacks
let error;
let shouldRenderHydrateFallback = false;
let errorElement = null;
let hydrateFallbackElement = null;
if (dataRouterState) {
if (match.route.ErrorBoundary) {
errorElement = /*#__PURE__*/React.createElement(match.route.ErrorBoundary, null);
} else if (match.route.errorElement) {
errorElement = match.route.errorElement;
} else {
errorElement = /*#__PURE__*/React.createElement(DefaultErrorComponent, null);
error = errors && match.route.id ? errors[match.route.id] : undefined;
errorElement = match.route.errorElement || defaultErrorElement;
if (renderFallback) {
if (fallbackIndex < 0 && index === 0) {
warningOnce("route-fallback", false, "No `HydrateFallback` element provided to render during initial hydration");
shouldRenderHydrateFallback = true;
hydrateFallbackElement = null;
} else if (fallbackIndex === index) {
shouldRenderHydrateFallback = true;
hydrateFallbackElement = match.route.hydrateFallbackElement || null;
}
}
}
let matches = parentMatches.concat(renderedMatches.slice(0, index + 1));
let getChildren = () => {
let children = outlet;
let children;
if (error) {
children = errorElement;
} else if (shouldRenderHydrateFallback) {
children = hydrateFallbackElement;
} else if (match.route.Component) {
// Note: This is a de-optimized path since React won't re-use the
// ReactElement since it's identity changes with each new
// React.createElement call. We keep this so folks can use
// `<Route Component={...}>` in `<Routes>` but generally `Component`
// usage is only advised in `RouterProvider` when we can convert it to
// `element` ahead of time.
children = /*#__PURE__*/React.createElement(match.route.Component, null);
} else if (match.route.element) {
children = match.route.element;
} else {
children = outlet;
}
return /*#__PURE__*/React.createElement(RenderedRoute, {

@@ -768,13 +676,14 @@ match: match,

outlet,
matches
matches,
isDataRoute: dataRouterState != null
},
children: children
});
}; // Only wrap in an error boundary within data router usages when we have an
};
// Only wrap in an error boundary within data router usages when we have an
// ErrorBoundary/errorElement on this route. Otherwise let it bubble up to
// an ancestor ErrorBoundary/errorElement
return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /*#__PURE__*/React.createElement(RenderErrorBoundary, {
location: dataRouterState.location,
revalidation: dataRouterState.revalidation,
component: errorElement,

@@ -785,3 +694,4 @@ error: error,

outlet: null,
matches
matches,
isDataRoute: true
}

@@ -791,12 +701,9 @@ }) : getChildren();

}
var DataRouterHook;
(function (DataRouterHook) {
var DataRouterHook = /*#__PURE__*/function (DataRouterHook) {
DataRouterHook["UseBlocker"] = "useBlocker";
DataRouterHook["UseRevalidator"] = "useRevalidator";
})(DataRouterHook || (DataRouterHook = {}));
var DataRouterStateHook;
(function (DataRouterStateHook) {
DataRouterHook["UseNavigateStable"] = "useNavigate";
return DataRouterHook;
}(DataRouterHook || {});
var DataRouterStateHook = /*#__PURE__*/function (DataRouterStateHook) {
DataRouterStateHook["UseBlocker"] = "useBlocker";

@@ -810,8 +717,9 @@ DataRouterStateHook["UseLoaderData"] = "useLoaderData";

DataRouterStateHook["UseRevalidator"] = "useRevalidator";
})(DataRouterStateHook || (DataRouterStateHook = {}));
DataRouterStateHook["UseNavigateStable"] = "useNavigate";
DataRouterStateHook["UseRouteId"] = "useRouteId";
return DataRouterStateHook;
}(DataRouterStateHook || {});
function getDataRouterConsoleError(hookName) {
return hookName + " must be used within a data router. See https://reactrouter.com/routers/picking-a-router.";
}
function useDataRouterContext(hookName) {

@@ -822,3 +730,2 @@ let ctx = React.useContext(DataRouterContext);

}
function useDataRouterState(hookName) {

@@ -829,3 +736,2 @@ let state = React.useContext(DataRouterStateContext);

}
function useRouteContext(hookName) {

@@ -837,2 +743,3 @@ let route = React.useContext(RouteContext);

// Internal version with hookName-aware debugging
function useCurrentRouteId(hookName) {

@@ -844,8 +751,14 @@ let route = useRouteContext(hookName);

}
/**
* Returns the ID for the nearest contextual route
*/
function useRouteId() {
return useCurrentRouteId(DataRouterStateHook.UseRouteId);
}
/**
* Returns the current navigation, defaulting to an "idle" navigation when
* no navigation is in progress
*/
function useNavigation() {

@@ -855,2 +768,3 @@ let state = useDataRouterState(DataRouterStateHook.UseNavigation);

}
/**

@@ -860,11 +774,11 @@ * Returns a revalidate function for manually triggering revalidation, as well

*/
function useRevalidator() {
let dataRouterContext = useDataRouterContext(DataRouterHook.UseRevalidator);
let state = useDataRouterState(DataRouterStateHook.UseRevalidator);
return {
return React.useMemo(() => ({
revalidate: dataRouterContext.router.revalidate,
state: state.revalidation
};
}), [dataRouterContext.router.revalidate, state.revalidation]);
}
/**

@@ -874,3 +788,2 @@ * Returns the active route matches, useful for accessing loaderData for

*/
function useMatches() {

@@ -881,27 +794,11 @@ let {

} = useDataRouterState(DataRouterStateHook.UseMatches);
return React.useMemo(() => matches.map(match => {
let {
pathname,
params
} = match; // Note: This structure matches that created by createUseMatchesMatch
// in the @remix-run/router , so if you change this please also change
// that :) Eventually we'll DRY this up
return React.useMemo(() => matches.map(m => UNSAFE_convertRouteMatchToUiMatch(m, loaderData)), [matches, loaderData]);
}
return {
id: match.route.id,
pathname,
params,
data: loaderData[match.route.id],
handle: match.route.handle
};
}), [matches, loaderData]);
}
/**
* Returns the loader data for the nearest ancestor Route loader
*/
function useLoaderData() {
let state = useDataRouterState(DataRouterStateHook.UseLoaderData);
let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData);
if (state.errors && state.errors[routeId] != null) {

@@ -911,9 +808,8 @@ console.error("You cannot `useLoaderData` in an errorElement (routeId: " + routeId + ")");

}
return state.loaderData[routeId];
}
/**
* Returns the loaderData for the given routeId
*/
function useRouteLoaderData(routeId) {

@@ -923,12 +819,12 @@ let state = useDataRouterState(DataRouterStateHook.UseRouteLoaderData);

}
/**
* Returns the action data for the nearest ancestor Route action
*/
function useActionData() {
let state = useDataRouterState(DataRouterStateHook.UseActionData);
let route = React.useContext(RouteContext);
!route ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "useActionData must be used inside a RouteContext") : UNSAFE_invariant(false) : void 0;
return Object.values((state == null ? void 0 : state.actionData) || {})[0];
let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData);
return state.actionData ? state.actionData[routeId] : undefined;
}
/**

@@ -939,22 +835,21 @@ * Returns the nearest ancestor Route error, which could be a loader/action

*/
function useRouteError() {
var _state$errors;
let error = React.useContext(RouteErrorContext);
let state = useDataRouterState(DataRouterStateHook.UseRouteError);
let routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError); // If this was a render error, we put it in a RouteError context inside
let routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError);
// If this was a render error, we put it in a RouteError context inside
// of RenderErrorBoundary
if (error) {
if (error !== undefined) {
return error;
} // Otherwise look for errors from our data router state
}
// Otherwise look for errors from our data router state
return (_state$errors = state.errors) == null ? void 0 : _state$errors[routeId];
}
/**
* Returns the happy-path data from the nearest ancestor <Await /> value
* Returns the happy-path data from the nearest ancestor `<Await />` value
*/
function useAsyncValue() {

@@ -964,6 +859,6 @@ let value = React.useContext(AwaitContext);

}
/**
* Returns the error from the nearest ancestor <Await /> value
* Returns the error from the nearest ancestor `<Await />` value
*/
function useAsyncError() {

@@ -974,2 +869,3 @@ let value = React.useContext(AwaitContext);

let blockerId = 0;
/**

@@ -981,21 +877,92 @@ * Allow the application to block navigations within the SPA and present the

*/
function useBlocker(shouldBlock) {
let {
router
router,
basename
} = useDataRouterContext(DataRouterHook.UseBlocker);
let state = useDataRouterState(DataRouterStateHook.UseBlocker);
let [blockerKey] = React.useState(() => String(++blockerId));
let blockerFunction = React.useCallback(args => {
return typeof shouldBlock === "function" ? !!shouldBlock(args) : !!shouldBlock;
}, [shouldBlock]);
let blocker = router.getBlocker(blockerKey, blockerFunction); // Cleanup on unmount
let [blockerKey, setBlockerKey] = React.useState("");
let blockerFunction = React.useCallback(arg => {
if (typeof shouldBlock !== "function") {
return !!shouldBlock;
}
if (basename === "/") {
return shouldBlock(arg);
}
React.useEffect(() => () => router.deleteBlocker(blockerKey), [router, blockerKey]); // Prefer the blocker from state since DataRouterContext is memoized so this
// ensures we update on blocker state updates
// If they provided us a function and we've got an active basename, strip
// it from the locations we expose to the user to match the behavior of
// useLocation
let {
currentLocation,
nextLocation,
historyAction
} = arg;
return shouldBlock({
currentLocation: _extends({}, currentLocation, {
pathname: stripBasename(currentLocation.pathname, basename) || currentLocation.pathname
}),
nextLocation: _extends({}, nextLocation, {
pathname: stripBasename(nextLocation.pathname, basename) || nextLocation.pathname
}),
historyAction
});
}, [basename, shouldBlock]);
return state.blockers.get(blockerKey) || blocker;
// This effect is in charge of blocker key assignment and deletion (which is
// tightly coupled to the key)
React.useEffect(() => {
let key = String(++blockerId);
setBlockerKey(key);
return () => router.deleteBlocker(key);
}, [router]);
// This effect handles assigning the blockerFunction. This is to handle
// unstable blocker function identities, and happens only after the prior
// effect so we don't get an orphaned blockerFunction in the router with a
// key of "". Until then we just have the IDLE_BLOCKER.
React.useEffect(() => {
if (blockerKey !== "") {
router.getBlocker(blockerKey, blockerFunction);
}
}, [router, blockerKey, blockerFunction]);
// Prefer the blocker from `state` not `router.state` since DataRouterContext
// is memoized so this ensures we update on blocker state updates
return blockerKey && state.blockers.has(blockerKey) ? state.blockers.get(blockerKey) : IDLE_BLOCKER;
}
/**
* Stable version of useNavigate that is used when we are in the context of
* a RouterProvider.
*/
function useNavigateStable() {
let {
router
} = useDataRouterContext(DataRouterHook.UseNavigateStable);
let id = useCurrentRouteId(DataRouterStateHook.UseNavigateStable);
let activeRef = React.useRef(false);
useIsomorphicLayoutEffect(() => {
activeRef.current = true;
});
let navigate = React.useCallback(function (to, options) {
if (options === void 0) {
options = {};
}
process.env.NODE_ENV !== "production" ? UNSAFE_warning(activeRef.current, navigateEffectWarning) : void 0;
// Short circuit here since if this happens on first render the navigate
// is useless because we haven't wired up our router subscriber yet
if (!activeRef.current) return;
if (typeof to === "number") {
router.navigate(to);
} else {
router.navigate(to, _extends({
fromRouteId: id
}, options));
}
}, [router, id]);
return navigate;
}
const alreadyWarned = {};
function warningOnce(key, cond, message) {

@@ -1009,2 +976,26 @@ if (!cond && !alreadyWarned[key]) {

/**
Webpack + React 17 fails to compile on any of the following because webpack
complains that `startTransition` doesn't exist in `React`:
* import { startTransition } from "react"
* import * as React from from "react";
"startTransition" in React ? React.startTransition(() => setState()) : setState()
* import * as React from from "react";
"startTransition" in React ? React["startTransition"](() => setState()) : setState()
Moving it to a constant such as the following solves the Webpack/React 17 issue:
* import * as React from from "react";
const START_TRANSITION = "startTransition";
START_TRANSITION in React ? React[START_TRANSITION](() => setState()) : setState()
However, that introduces webpack/terser minification issues in production builds
in React 18 where minification/obfuscation ends up removing the call of
React.startTransition entirely from the first half of the ternary. Grabbing
this exported reference once up front resolves that issue.
See https://github.com/remix-run/react-router/issues/10579
*/
const START_TRANSITION = "startTransition";
const startTransitionImpl = React[START_TRANSITION];
/**
* Given a Remix Router instance, render the appropriate UI

@@ -1015,10 +1006,25 @@ */

fallbackElement,
router
router,
future
} = _ref;
let getState = React.useCallback(() => router.state, [router]); // Sync router state to our component state to force re-renders
let [state, setStateImpl] = React.useState(router.state);
let {
v7_startTransition
} = future || {};
let setState = React.useCallback(newState => {
if (v7_startTransition && startTransitionImpl) {
startTransitionImpl(() => setStateImpl(newState));
} else {
setStateImpl(newState);
}
}, [setStateImpl, v7_startTransition]);
let state = useSyncExternalStore(router.subscribe, getState, // We have to provide this so React@18 doesn't complain during hydration,
// but we pass our serialized hydration data into the router so state here
// is already synced with what the server saw
getState);
// Need to use a layout effect here so we are subscribed early enough to
// pick up on any render-driven redirects/navigations (useEffect/<Navigate>)
React.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
React.useEffect(() => {
process.env.NODE_ENV !== "production" ? UNSAFE_warning(fallbackElement == null || !router.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using " + "`v7_partialHydration`, use a `HydrateFallback` component instead") : void 0;
// Only log this once on initial mount
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
let navigator = React.useMemo(() => {

@@ -1046,3 +1052,5 @@ return {

basename
}), [router, navigator, basename]); // The fragment and {null} here are important! We need them to keep React 18's
}), [router, navigator, basename]);
// The fragment and {null} here are important! We need them to keep React 18's
// useId happy when we are server-rendering since we may have a <script> here

@@ -1053,3 +1061,2 @@ // containing the hydrated server-side staticContext (from StaticRouterProvider).

// we don't need the <script> tag
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DataRouterContext.Provider, {

@@ -1060,15 +1067,29 @@ value: dataRouterContext

}, /*#__PURE__*/React.createElement(Router, {
basename: router.basename,
location: router.state.location,
navigationType: router.state.historyAction,
navigator: navigator
}, router.state.initialized ? /*#__PURE__*/React.createElement(Routes, null) : fallbackElement))), null);
basename: basename,
location: state.location,
navigationType: state.historyAction,
navigator: navigator,
future: {
v7_relativeSplatPath: router.future.v7_relativeSplatPath
}
}, state.initialized || router.future.v7_partialHydration ? /*#__PURE__*/React.createElement(DataRoutes, {
routes: router.routes,
future: router.future,
state: state
}) : fallbackElement))), null);
}
function DataRoutes(_ref2) {
let {
routes,
future,
state
} = _ref2;
return useRoutesImpl(routes, undefined, state, future);
}
/**
* A <Router> that stores all entries in memory.
* A `<Router>` that stores all entries in memory.
*
* @see https://reactrouter.com/router-components/memory-router
*/
function MemoryRouter(_ref2) {
function MemoryRouter(_ref3) {
let {

@@ -1078,6 +1099,6 @@ basename,

initialEntries,
initialIndex
} = _ref2;
initialIndex,
future
} = _ref3;
let historyRef = React.useRef();
if (historyRef.current == null) {

@@ -1090,9 +1111,14 @@ historyRef.current = createMemoryHistory({

}
let history = historyRef.current;
let [state, setState] = React.useState({
let [state, setStateImpl] = React.useState({
action: history.action,
location: history.location
});
React.useLayoutEffect(() => history.listen(setState), [history]);
let {
v7_startTransition
} = future || {};
let setState = React.useCallback(newState => {
v7_startTransition && startTransitionImpl ? startTransitionImpl(() => setStateImpl(newState)) : setStateImpl(newState);
}, [setStateImpl, v7_startTransition]);
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
return /*#__PURE__*/React.createElement(Router, {

@@ -1103,6 +1129,6 @@ basename: basename,

navigationType: state.action,
navigator: history
navigator: history,
future: future
});
}
/**

@@ -1117,3 +1143,3 @@ * Changes the current location.

*/
function Navigate(_ref3) {
function Navigate(_ref4) {
let {

@@ -1124,26 +1150,30 @@ to,

relative
} = _ref3;
} = _ref4;
!useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of
// the router loaded. We can help them understand how to avoid that.
"<Navigate> may be used only in the context of a <Router> component.") : UNSAFE_invariant(false) : void 0;
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;
let dataRouterState = React.useContext(DataRouterStateContext);
let {
future,
static: isStatic
} = React.useContext(NavigationContext);
process.env.NODE_ENV !== "production" ? UNSAFE_warning(!isStatic, "<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;
let {
matches
} = React.useContext(RouteContext);
let {
pathname: locationPathname
} = useLocation();
let navigate = useNavigate();
React.useEffect(() => {
// Avoid kicking off multiple navigations if we're in the middle of a
// data-router navigation, since components get re-rendered when we enter
// a submitting/loading state
if (dataRouterState && dataRouterState.navigation.state !== "idle") {
return;
}
navigate(to, {
replace,
state,
relative
});
});
// Resolve the path outside of the effect so that when effects run twice in
// StrictMode they navigate to the same place
let path = resolveTo(to, UNSAFE_getResolveToMatches(matches, future.v7_relativeSplatPath), locationPathname, relative === "path");
let jsonPath = JSON.stringify(path);
React.useEffect(() => navigate(JSON.parse(jsonPath), {
replace,
state,
relative
}), [navigate, jsonPath, relative, replace, state]);
return null;
}
/**

@@ -1157,3 +1187,2 @@ * Renders the child route's element, if there is one.

}
/**

@@ -1167,13 +1196,12 @@ * Declares an element that should be rendered at a certain URL path.

}
/**
* Provides location context for the rest of the app.
*
* Note: You usually won't render a <Router> directly. Instead, you'll render a
* router that is more specific to your environment such as a <BrowserRouter>
* in web browsers or a <StaticRouter> for server rendering.
* Note: You usually won't render a `<Router>` directly. Instead, you'll render a
* router that is more specific to your environment such as a `<BrowserRouter>`
* in web browsers or a `<StaticRouter>` for server rendering.
*
* @see https://reactrouter.com/router-components/router
*/
function Router(_ref4) {
function Router(_ref5) {
let {

@@ -1185,7 +1213,9 @@ basename: basenameProp = "/",

navigator,
static: staticProp = false
} = _ref4;
!!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; // Preserve trailing slashes on basename, so we can let the user control
static: staticProp = false,
future
} = _ref5;
!!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;
// Preserve trailing slashes on basename, so we can let the user control
// the enforcement of trailing slashes throughout the app
let basename = basenameProp.replace(/^\/*/, "/");

@@ -1195,9 +1225,10 @@ let navigationContext = React.useMemo(() => ({

navigator,
static: staticProp
}), [basename, navigator, staticProp]);
static: staticProp,
future: _extends({
v7_relativeSplatPath: false
}, future)
}), [basename, future, navigator, staticProp]);
if (typeof locationProp === "string") {
locationProp = parsePath(locationProp);
}
let {

@@ -1212,7 +1243,5 @@ pathname = "/",

let trailingPathname = stripBasename(pathname, basename);
if (trailingPathname == null) {
return null;
}
return {

@@ -1230,7 +1259,5 @@ location: {

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;
if (locationContext == null) {
return null;
}
return /*#__PURE__*/React.createElement(NavigationContext.Provider, {

@@ -1243,5 +1270,4 @@ value: navigationContext

}
/**
* A container for a nested tree of <Route> elements that renders the branch
* A container for a nested tree of `<Route>` elements that renders the branch
* that best matches the current location.

@@ -1251,15 +1277,9 @@ *

*/
function Routes(_ref5) {
function Routes(_ref6) {
let {
children,
location
} = _ref5;
let dataRouterContext = React.useContext(DataRouterContext); // When in a DataRouterContext _without_ children, we use the router routes
// directly. If we have children, then we're in a descendant tree and we
// need to use child routes.
let routes = dataRouterContext && !children ? dataRouterContext.router.routes : createRoutesFromChildren(children);
return useRoutes(routes, location);
} = _ref6;
return useRoutes(createRoutesFromChildren(children), location);
}
/**

@@ -1269,3 +1289,3 @@ * Component to use for rendering lazily loaded data from returning defer()

*/
function Await(_ref6) {
function Await(_ref7) {
let {

@@ -1275,3 +1295,3 @@ children,

resolve
} = _ref6;
} = _ref7;
return /*#__PURE__*/React.createElement(AwaitErrorBoundary, {

@@ -1282,12 +1302,9 @@ resolve: resolve,

}
var AwaitRenderStatus;
(function (AwaitRenderStatus) {
var AwaitRenderStatus = /*#__PURE__*/function (AwaitRenderStatus) {
AwaitRenderStatus[AwaitRenderStatus["pending"] = 0] = "pending";
AwaitRenderStatus[AwaitRenderStatus["success"] = 1] = "success";
AwaitRenderStatus[AwaitRenderStatus["error"] = 2] = "error";
})(AwaitRenderStatus || (AwaitRenderStatus = {}));
return AwaitRenderStatus;
}(AwaitRenderStatus || {});
const neverSettledPromise = new Promise(() => {});
class AwaitErrorBoundary extends React.Component {

@@ -1300,3 +1317,2 @@ constructor(props) {

}
static getDerivedStateFromError(error) {

@@ -1307,7 +1323,5 @@ return {

}
componentDidCatch(error, errorInfo) {
console.error("<Await> caught the following error during render", error, errorInfo);
}
render() {

@@ -1321,3 +1335,2 @@ let {

let status = AwaitRenderStatus.pending;
if (!(resolve instanceof Promise)) {

@@ -1338,3 +1351,2 @@ // Didn't get a promise - provide as a resolved promise

promise = Promise.reject().catch(() => {}); // Avoid unhandled rejection warnings
Object.defineProperty(promise, "_tracked", {

@@ -1362,3 +1374,2 @@ get: () => true

}
if (status === AwaitRenderStatus.error && promise._error instanceof AbortedDeferredError) {

@@ -1368,3 +1379,2 @@ // Freeze the UI by throwing a never resolved promise

}
if (status === AwaitRenderStatus.error && !errorElement) {

@@ -1374,3 +1384,2 @@ // No errorElement, throw to the nearest route-level error boundary

}
if (status === AwaitRenderStatus.error) {

@@ -1383,3 +1392,2 @@ // Render via our errorElement

}
if (status === AwaitRenderStatus.success) {

@@ -1391,23 +1399,23 @@ // Render children with resolved value

});
} // Throw to the suspense boundary
}
// Throw to the suspense boundary
throw promise;
}
}
}
/**
* @private
* Indirection to leverage useAsyncValue for a render-prop API on <Await>
* Indirection to leverage useAsyncValue for a render-prop API on `<Await>`
*/
function ResolveAwait(_ref7) {
function ResolveAwait(_ref8) {
let {
children
} = _ref7;
} = _ref8;
let data = useAsyncValue();
let toRender = typeof children === "function" ? children(data) : children;
return /*#__PURE__*/React.createElement(React.Fragment, null, toRender);
} ///////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////
// UTILS

@@ -1423,4 +1431,2 @@ ///////////////////////////////////////////////////////////////////////////////

*/
function createRoutesFromChildren(children, parentPath) {

@@ -1430,3 +1436,2 @@ if (parentPath === void 0) {

}
let routes = [];

@@ -1439,5 +1444,3 @@ React.Children.forEach(children, (element, index) => {

}
let treePath = [...parentPath, index];
if (element.type === React.Fragment) {

@@ -1448,3 +1451,2 @@ // Transparently support React.Fragment and its children.

}
!(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;

@@ -1468,7 +1470,5 @@ !(!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;

};
if (element.props.children) {
route.children = createRoutesFromChildren(element.props.children, treePath);
}
routes.push(route);

@@ -1478,6 +1478,6 @@ });

}
/**
* Renders the result of `matchRoutes()` into a React element.
*/
function renderMatches(matches) {

@@ -1487,22 +1487,49 @@ return _renderMatches(matches);

function detectErrorBoundary(route) {
if (process.env.NODE_ENV !== "production") {
if (route.Component && route.element) {
process.env.NODE_ENV !== "production" ? UNSAFE_warning(false, "You should not include both `Component` and `element` on your route - " + "`element` will be ignored.") : void 0;
function mapRouteProperties(route) {
let updates = {
// Note: this check also occurs in createRoutesFromChildren so update
// there if you change this -- please and thank you!
hasErrorBoundary: route.ErrorBoundary != null || route.errorElement != null
};
if (route.Component) {
if (process.env.NODE_ENV !== "production") {
if (route.element) {
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;
}
}
if (route.ErrorBoundary && route.errorElement) {
process.env.NODE_ENV !== "production" ? UNSAFE_warning(false, "You should not include both `ErrorBoundary` and `errorElement` on your route - " + "`errorElement` will be ignored.") : void 0;
Object.assign(updates, {
element: /*#__PURE__*/React.createElement(route.Component),
Component: undefined
});
}
if (route.HydrateFallback) {
if (process.env.NODE_ENV !== "production") {
if (route.hydrateFallbackElement) {
process.env.NODE_ENV !== "production" ? UNSAFE_warning(false, "You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - " + "`HydrateFallback` will be used.") : void 0;
}
}
} // Note: this check also occurs in createRoutesFromChildren so update
// there if you change this
return Boolean(route.ErrorBoundary) || Boolean(route.errorElement);
Object.assign(updates, {
hydrateFallbackElement: /*#__PURE__*/React.createElement(route.HydrateFallback),
HydrateFallback: undefined
});
}
if (route.ErrorBoundary) {
if (process.env.NODE_ENV !== "production") {
if (route.errorElement) {
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;
}
}
Object.assign(updates, {
errorElement: /*#__PURE__*/React.createElement(route.ErrorBoundary),
ErrorBoundary: undefined
});
}
return updates;
}
function createMemoryRouter(routes, opts) {
return createRouter({
basename: opts == null ? void 0 : opts.basename,
future: opts == null ? void 0 : opts.future,
future: _extends({}, opts == null ? void 0 : opts.future, {
v7_prependBasename: true
}),
history: createMemoryHistory({

@@ -1514,7 +1541,8 @@ initialEntries: opts == null ? void 0 : opts.initialEntries,

routes,
detectErrorBoundary
mapRouteProperties,
unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy
}).initialize();
} ///////////////////////////////////////////////////////////////////////////////
}
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, detectErrorBoundary as UNSAFE_detectErrorBoundary, 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 };
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, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
//# sourceMappingURL=index.js.map

@@ -0,8 +1,13 @@

import type { InitialEntry, LazyRouteFunction, Location, RelativeRoutingType, Router as RemixRouter, To, TrackedPromise } from "@remix-run/router";
import { Action as NavigationType } from "@remix-run/router";
import * as React from "react";
import type { TrackedPromise, InitialEntry, Location, Router as RemixRouter, To, LazyRouteFunction } from "@remix-run/router";
import { Action as NavigationType } from "@remix-run/router";
import type { IndexRouteObject, RouteMatch, RouteObject, Navigator, NonIndexRouteObject, RelativeRoutingType } from "./context";
import type { IndexRouteObject, Navigator, NonIndexRouteObject, RouteMatch, RouteObject } from "./context";
export interface FutureConfig {
v7_relativeSplatPath: boolean;
v7_startTransition: boolean;
}
export interface RouterProviderProps {
fallbackElement?: React.ReactNode;
router: RemixRouter;
future?: Partial<Pick<FutureConfig, "v7_startTransition">>;
}

@@ -12,3 +17,3 @@ /**

*/
export declare function RouterProvider({ fallbackElement, router, }: RouterProviderProps): React.ReactElement;
export declare function RouterProvider({ fallbackElement, router, future, }: RouterProviderProps): React.ReactElement;
export interface MemoryRouterProps {

@@ -19,9 +24,10 @@ basename?: string;

initialIndex?: number;
future?: Partial<FutureConfig>;
}
/**
* A <Router> that stores all entries in memory.
* A `<Router>` that stores all entries in memory.
*
* @see https://reactrouter.com/router-components/memory-router
*/
export declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
export declare function MemoryRouter({ basename, children, initialEntries, initialIndex, future, }: MemoryRouterProps): React.ReactElement;
export interface NavigateProps {

@@ -65,4 +71,6 @@ to: To;

element?: React.ReactNode | null;
hydrateFallbackElement?: React.ReactNode | null;
errorElement?: React.ReactNode | null;
Component?: React.ComponentType | null;
HydrateFallback?: React.ComponentType | null;
ErrorBoundary?: React.ComponentType | null;

@@ -85,7 +93,9 @@ }

element?: React.ReactNode | null;
hydrateFallbackElement?: React.ReactNode | null;
errorElement?: React.ReactNode | null;
Component?: React.ComponentType | null;
HydrateFallback?: React.ComponentType | null;
ErrorBoundary?: React.ComponentType | null;
}
export declare type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
export type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
/**

@@ -104,2 +114,3 @@ * Declares an element that should be rendered at a certain URL path.

static?: boolean;
future?: Partial<Pick<FutureConfig, "v7_relativeSplatPath">>;
}

@@ -109,9 +120,9 @@ /**

*
* Note: You usually won't render a <Router> directly. Instead, you'll render a
* router that is more specific to your environment such as a <BrowserRouter>
* in web browsers or a <StaticRouter> for server rendering.
* Note: You usually won't render a `<Router>` directly. Instead, you'll render a
* router that is more specific to your environment such as a `<BrowserRouter>`
* in web browsers or a `<StaticRouter>` for server rendering.
*
* @see https://reactrouter.com/router-components/router
*/
export declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
export declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, future, }: RouterProps): React.ReactElement | null;
export interface RoutesProps {

@@ -122,3 +133,3 @@ children?: React.ReactNode;

/**
* A container for a nested tree of <Route> elements that renders the branch
* A container for a nested tree of `<Route>` elements that renders the branch
* that best matches the current location.

@@ -141,3 +152,3 @@ *

*/
export declare function Await({ children, errorElement, resolve }: AwaitProps): JSX.Element;
export declare function Await({ children, errorElement, resolve }: AwaitProps): React.JSX.Element;
/**

@@ -144,0 +155,0 @@ * Creates a route config from a React "children" object, which is usually

import * as React from "react";
import type { AgnosticRouteMatch, AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, History, Location, Router, StaticHandlerContext, To, TrackedPromise, LazyRouteFunction } from "@remix-run/router";
import type { Action as NavigationType } from "@remix-run/router";
import type { AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticRouteMatch, History, LazyRouteFunction, Location, Action as NavigationType, RelativeRoutingType, Router, StaticHandlerContext, To, TrackedPromise } from "@remix-run/router";
export interface IndexRouteObject {

@@ -16,6 +15,8 @@ caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];

element?: React.ReactNode | null;
hydrateFallbackElement?: React.ReactNode | null;
errorElement?: React.ReactNode | null;
Component?: React.ComponentType | null;
HydrateFallback?: React.ComponentType | null;
ErrorBoundary?: React.ComponentType | null;
lazy?: LazyRouteFunction<IndexRouteObject>;
lazy?: LazyRouteFunction<RouteObject>;
}

@@ -34,9 +35,11 @@ export interface NonIndexRouteObject {

element?: React.ReactNode | null;
hydrateFallbackElement?: React.ReactNode | null;
errorElement?: React.ReactNode | null;
Component?: React.ComponentType | null;
HydrateFallback?: React.ComponentType | null;
ErrorBoundary?: React.ComponentType | null;
lazy?: LazyRouteFunction<NonIndexRouteObject>;
lazy?: LazyRouteFunction<RouteObject>;
}
export declare type RouteObject = IndexRouteObject | NonIndexRouteObject;
export declare type DataRouteObject = RouteObject & {
export type RouteObject = IndexRouteObject | NonIndexRouteObject;
export type DataRouteObject = RouteObject & {
children?: DataRouteObject[];

@@ -49,3 +52,3 @@ id: string;

}
export interface DataRouterContextObject extends NavigationContextObject {
export interface DataRouterContextObject extends Omit<NavigationContextObject, "future"> {
router: Router;

@@ -57,3 +60,2 @@ staticContext?: StaticHandlerContext;

export declare const AwaitContext: React.Context<TrackedPromise | null>;
export declare type RelativeRoutingType = "route" | "path";
export interface NavigateOptions {

@@ -64,2 +66,4 @@ replace?: boolean;

relative?: RelativeRoutingType;
unstable_flushSync?: boolean;
unstable_viewTransition?: boolean;
}

@@ -70,3 +74,3 @@ /**

* Every history instance conforms to the Navigator interface, but the
* distinction is useful primarily when it comes to the low-level <Router> API
* distinction is useful primarily when it comes to the low-level `<Router>` API
* where both the location and a navigator must be provided separately in order

@@ -87,2 +91,5 @@ * to avoid "tearing" that may occur in a suspense-enabled app if the action

static: boolean;
future: {
v7_relativeSplatPath: boolean;
};
}

@@ -98,2 +105,3 @@ export declare const NavigationContext: React.Context<NavigationContextObject>;

matches: RouteMatch[];
isDataRoute: boolean;
}

@@ -100,0 +108,0 @@ export declare const RouteContext: React.Context<RouteContextObject>;

import * as React from "react";
import type { Blocker, BlockerFunction, Location, ParamParseKey, Params, Path, PathMatch, PathPattern, Router as RemixRouter, To } from "@remix-run/router";
import type { Blocker, BlockerFunction, Location, ParamParseKey, Params, Path, PathMatch, PathPattern, RelativeRoutingType, Router as RemixRouter, RevalidationState, To, UIMatch } from "@remix-run/router";
import { Action as NavigationType } from "@remix-run/router";
import type { NavigateOptions, RouteContextObject, RouteMatch, RouteObject, RelativeRoutingType } from "./context";
import type { NavigateOptions, RouteContextObject, RouteMatch, RouteObject } from "./context";
/**

@@ -15,3 +15,3 @@ * Returns the full href for the given "to" value. This is useful for building

/**
* Returns true if this component is a descendant of a <Router>.
* Returns true if this component is a descendant of a `<Router>`.
*

@@ -42,3 +42,3 @@ * @see https://reactrouter.com/hooks/use-in-router-context

* This is useful for components that need to know "active" state, e.g.
* <NavLink>.
* `<NavLink>`.
*

@@ -56,3 +56,3 @@ * @see https://reactrouter.com/hooks/use-match

/**
* Returns an imperative method for changing the location. Used by <Link>s, but
* Returns an imperative method for changing the location. Used by `<Link>`s, but
* may also be used by other elements to change the location.

@@ -71,3 +71,3 @@ *

* Returns the element for the child route at this level of the route
* hierarchy. Used internally by <Outlet> to render child routes.
* hierarchy. Used internally by `<Outlet>` to render child routes.
*

@@ -97,3 +97,3 @@ * @see https://reactrouter.com/hooks/use-outlet

* with the correct context to render the remainder of the route tree. Route
* elements in the tree must render an <Outlet> to render their child route's
* elements in the tree must render an `<Outlet>` to render their child route's
* element.

@@ -104,4 +104,6 @@ *

export declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
declare type RenderErrorBoundaryProps = React.PropsWithChildren<{
export declare function useRoutesImpl(routes: RouteObject[], locationArg?: Partial<Location> | string, dataRouterState?: RemixRouter["state"], future?: RemixRouter["future"]): React.ReactElement | null;
type RenderErrorBoundaryProps = React.PropsWithChildren<{
location: Location;
revalidation: RevalidationState;
error: any;

@@ -111,4 +113,5 @@ component: React.ReactNode;

}>;
declare type RenderErrorBoundaryState = {
type RenderErrorBoundaryState = {
location: Location;
revalidation: RevalidationState;
error: any;

@@ -123,9 +126,14 @@ };

error: any;
location: Location;
location: Location<any>;
revalidation: RevalidationState;
};
componentDidCatch(error: any, errorInfo: any): void;
render(): string | number | boolean | React.ReactFragment | JSX.Element | null | undefined;
render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
}
export declare function _renderMatches(matches: RouteMatch[] | null, parentMatches?: RouteMatch[], dataRouterState?: RemixRouter["state"]): React.ReactElement | null;
export declare function _renderMatches(matches: RouteMatch[] | null, parentMatches?: RouteMatch[], dataRouterState?: RemixRouter["state"] | null, future?: RemixRouter["future"] | null): React.ReactElement | null;
/**
* Returns the ID for the nearest contextual route
*/
export declare function useRouteId(): string;
/**
* Returns the current navigation, defaulting to an "idle" navigation when

@@ -141,3 +149,3 @@ * no navigation is in progress

revalidate: () => void;
state: import("@remix-run/router").RevalidationState;
state: RevalidationState;
};

@@ -148,9 +156,3 @@ /**

*/
export declare function useMatches(): {
id: string;
pathname: string;
params: Params<string>;
data: unknown;
handle: unknown;
}[];
export declare function useMatches(): UIMatch[];
/**

@@ -175,7 +177,7 @@ * Returns the loader data for the nearest ancestor Route loader

/**
* Returns the happy-path data from the nearest ancestor <Await /> value
* Returns the happy-path data from the nearest ancestor `<Await />` value
*/
export declare function useAsyncValue(): unknown;
/**
* Returns the error from the nearest ancestor <Await /> value
* Returns the error from the nearest ancestor `<Await />` value
*/

@@ -182,0 +184,0 @@ export declare function useAsyncError(): unknown;

/**
* React Router v0.0.0-experimental-0f2dd78c
* React Router v0.0.0-experimental-0f302655
*

@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc.

/**
* React Router v0.0.0-experimental-0f2dd78c
* React Router v0.0.0-experimental-0f302655
*

@@ -11,225 +11,35 @@ * Copyright (c) Remix Software Inc.

*/
import { UNSAFE_invariant, joinPaths, matchPath, UNSAFE_getPathContributingMatches, UNSAFE_warning, resolveTo, parsePath, matchRoutes, Action, isRouteErrorResponse, createMemoryHistory, stripBasename, AbortedDeferredError, createRouter } from '@remix-run/router';
export { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from '@remix-run/router';
import * as React from 'react';
import { UNSAFE_invariant, joinPaths, matchPath, UNSAFE_getResolveToMatches, UNSAFE_warning, resolveTo, parsePath, matchRoutes, Action, UNSAFE_convertRouteMatchToUiMatch, stripBasename, IDLE_BLOCKER, isRouteErrorResponse, createMemoryHistory, AbortedDeferredError, createRouter } from '@remix-run/router';
export { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, resolvePath } from '@remix-run/router';
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
function isPolyfill(x, y) {
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
;
}
const is = typeof Object.is === "function" ? Object.is : isPolyfill; // Intentionally not using named imports because Rollup uses dynamic
// dispatch for CommonJS interop named imports.
const {
useState,
useEffect,
useLayoutEffect,
useDebugValue
} = React;
let didWarnOld18Alpha = false;
let didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
// because of a very particular set of implementation details and assumptions
// -- change any one of them and it will break. The most important assumption
// is that updates are always synchronous, because concurrent rendering is
// only available in versions of React that also have a built-in
// useSyncExternalStore API. And we only use this shim when the built-in API
// does not exist.
//
// Do not assume that the clever hacks used by this hook also work in general.
// The point of this shim is to replace the need for hacks by other libraries.
function useSyncExternalStore$2(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
// React do not expose a way to check if we're hydrating. So users of the shim
// will need to track that themselves and return the correct value
// from `getSnapshot`.
getServerSnapshot) {
{
if (!didWarnOld18Alpha) {
if ("startTransition" in React) {
didWarnOld18Alpha = true;
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.");
}
}
} // Read the current snapshot from the store on every render. Again, this
// breaks the rules of React, and only works here because of specific
// implementation details, most importantly that updates are
// always synchronous.
const value = getSnapshot();
{
if (!didWarnUncachedGetSnapshot) {
const cachedValue = getSnapshot();
if (!is(value, cachedValue)) {
console.error("The result of getSnapshot should be cached to avoid an infinite loop");
didWarnUncachedGetSnapshot = true;
}
}
} // Because updates are synchronous, we don't queue them. Instead we force a
// re-render whenever the subscribed state changes by updating an some
// arbitrary useState hook. Then, during render, we call getSnapshot to read
// the current value.
//
// Because we don't actually use the state returned by the useState hook, we
// can save a bit of memory by storing other stuff in that slot.
//
// To implement the early bailout, we need to track some things on a mutable
// object. Usually, we would put that in a useRef hook, but we can stash it in
// our useState hook instead.
//
// To force a re-render, we call forceUpdate({inst}). That works because the
// new object always fails an equality check.
const [{
inst
}, forceUpdate] = useState({
inst: {
value,
getSnapshot
}
}); // Track the latest getSnapshot function with a ref. This needs to be updated
// in the layout phase so we can access it during the tearing check that
// happens on subscribe.
useLayoutEffect(() => {
inst.value = value;
inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
// commit phase if there was an interleaved mutation. In concurrent mode
// this can happen all the time, but even in synchronous mode, an earlier
// effect may have mutated the store.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceUpdate({
inst
});
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [subscribe, value, getSnapshot]);
useEffect(() => {
// Check for changes right before subscribing. Subsequent changes will be
// detected in the subscription handler.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceUpdate({
inst
});
}
const handleStoreChange = () => {
// TODO: Because there is no cross-renderer API for batching updates, it's
// up to the consumer of this library to wrap their subscription event
// with unstable_batchedUpdates. Should we try to detect when this isn't
// the case and print a warning in development?
// The store changed. Check if the snapshot changed since the last time we
// read from the store.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceUpdate({
inst
});
}
}; // Subscribe to the store and return a clean-up function.
return subscribe(handleStoreChange); // eslint-disable-next-line react-hooks/exhaustive-deps
}, [subscribe]);
useDebugValue(value);
return value;
}
function checkIfSnapshotChanged(inst) {
const latestGetSnapshot = inst.getSnapshot;
const prevValue = inst.value;
try {
const nextValue = latestGetSnapshot();
return !is(prevValue, nextValue);
} catch (error) {
return true;
}
}
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
// Note: The shim does not use getServerSnapshot, because pre-18 versions of
// React do not expose a way to check if we're hydrating. So users of the shim
// will need to track that themselves and return the correct value
// from `getSnapshot`.
return getSnapshot();
}
/**
* Inlined into the react-router repo since use-sync-external-store does not
* provide a UMD-compatible package, so we need this to be able to distribute
* UMD react-router bundles
*/
const canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
const isServerEnvironment = !canUseDOM;
const shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore$2;
const useSyncExternalStore = "useSyncExternalStore" in React ? (module => module.useSyncExternalStore)(React) : shim;
const DataRouterContext = /*#__PURE__*/React.createContext(null);
{
DataRouterContext.displayName = "DataRouter";
}
const DataRouterStateContext = /*#__PURE__*/React.createContext(null);
{
DataRouterStateContext.displayName = "DataRouterState";
}
const AwaitContext = /*#__PURE__*/React.createContext(null);
{
AwaitContext.displayName = "Await";
}
const NavigationContext = /*#__PURE__*/React.createContext(null);
{
NavigationContext.displayName = "Navigation";
}
const LocationContext = /*#__PURE__*/React.createContext(null);
{
LocationContext.displayName = "Location";
}
const RouteContext = /*#__PURE__*/React.createContext({
outlet: null,
matches: []
matches: [],
isDataRoute: false
});
{
RouteContext.displayName = "Route";
}
const RouteErrorContext = /*#__PURE__*/React.createContext(null);
{

@@ -245,7 +55,7 @@ RouteErrorContext.displayName = "RouteError";

*/
function useHref(to, {
relative
} = {}) {
!useInRouterContext() ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
!useInRouterContext() ? UNSAFE_invariant(false,
// TODO: This error is probably because they somehow have 2 versions of the
// router loaded. We can help them understand how to avoid that.

@@ -264,11 +74,10 @@ `useHref() may be used only in the context of a <Router> component.`) : void 0;

});
let joinedPathname = pathname; // If we're operating within a basename, prepend it to the pathname prior
let joinedPathname = pathname;
// If we're operating within a basename, prepend it to the pathname prior
// to creating the href. If this is a root navigation, then just use the raw
// basename which allows the basename to have full control over the presence
// of a trailing slash on root links
if (basename !== "/") {
joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
}
return navigator.createHref({

@@ -281,7 +90,6 @@ pathname: joinedPathname,

/**
* Returns true if this component is a descendant of a <Router>.
* Returns true if this component is a descendant of a `<Router>`.
*
* @see https://reactrouter.com/hooks/use-in-router-context
*/
function useInRouterContext() {

@@ -300,5 +108,5 @@ return React.useContext(LocationContext) != null;

*/
function useLocation() {
!useInRouterContext() ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
!useInRouterContext() ? UNSAFE_invariant(false,
// TODO: This error is probably because they somehow have 2 versions of the
// router loaded. We can help them understand how to avoid that.

@@ -314,3 +122,2 @@ `useLocation() may be used only in the context of a <Router> component.`) : void 0;

*/
function useNavigationType() {

@@ -322,9 +129,9 @@ return React.useContext(LocationContext).navigationType;

* This is useful for components that need to know "active" state, e.g.
* <NavLink>.
* `<NavLink>`.
*
* @see https://reactrouter.com/hooks/use-match
*/
function useMatch(pattern) {
!useInRouterContext() ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
!useInRouterContext() ? UNSAFE_invariant(false,
// TODO: This error is probably because they somehow have 2 versions of the
// router loaded. We can help them understand how to avoid that.

@@ -337,4 +144,15 @@ `useMatch() may be used only in the context of a <Router> component.`) : void 0;

}
const navigateEffectWarning = `You should call navigate() in a React.useEffect(), not when ` + `your component is first rendered.`;
// Mute warnings for calls to useNavigate in SSR environments
function useIsomorphicLayoutEffect(cb) {
let isStatic = React.useContext(NavigationContext).static;
if (!isStatic) {
// We should be able to get rid of this once react 18.3 is released
// See: https://github.com/facebook/react/pull/26395
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useLayoutEffect(cb);
}
}
/**
* Returns an imperative method for changing the location. Used by <Link>s, but
* Returns an imperative method for changing the location. Used by `<Link>`s, but
* may also be used by other elements to change the location.

@@ -344,9 +162,19 @@ *

*/
function useNavigate() {
!useInRouterContext() ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
let {
isDataRoute
} = React.useContext(RouteContext);
// Conditional usage is OK here because the usage of a data router is static
// eslint-disable-next-line react-hooks/rules-of-hooks
return isDataRoute ? useNavigateStable() : useNavigateUnstable();
}
function useNavigateUnstable() {
!useInRouterContext() ? UNSAFE_invariant(false,
// TODO: This error is probably because they somehow have 2 versions of the
// router loaded. We can help them understand how to avoid that.
`useNavigate() may be used only in the context of a <Router> component.`) : void 0;
let dataRouterContext = React.useContext(DataRouterContext);
let {
basename,
future,
navigator

@@ -360,11 +188,12 @@ } = React.useContext(NavigationContext);

} = useLocation();
let routePathnamesJson = JSON.stringify(UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase));
let routePathnamesJson = JSON.stringify(UNSAFE_getResolveToMatches(matches, future.v7_relativeSplatPath));
let activeRef = React.useRef(false);
React.useEffect(() => {
useIsomorphicLayoutEffect(() => {
activeRef.current = true;
});
let navigate = React.useCallback((to, options = {}) => {
UNSAFE_warning(activeRef.current, `You should call navigate() in a React.useEffect(), not when ` + `your component is first rendered.`) ;
UNSAFE_warning(activeRef.current, navigateEffectWarning) ;
// Short circuit here since if this happens on first render the navigate
// is useless because we haven't wired up our history listener yet
if (!activeRef.current) return;
if (typeof to === "number") {

@@ -374,14 +203,14 @@ navigator.go(to);

}
let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path"); // If we're operating within a basename, prepend it to the pathname prior
// to handing off to history. If this is a root navigation, then we
// navigate to the raw basename which allows the basename to have full
// control over the presence of a trailing slash on root links
if (basename !== "/") {
let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path");
// If we're operating within a basename, prepend it to the pathname prior
// to handing off to history (but only if we're not in a data router,
// otherwise it'll prepend the basename inside of the router).
// If this is a root navigation, then we navigate to the raw basename
// which allows the basename to have full control over the presence of a
// trailing slash on root links
if (dataRouterContext == null && basename !== "/") {
path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
}
(!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
}, [basename, navigator, routePathnamesJson, locationPathname]);
}, [basename, navigator, routePathnamesJson, locationPathname, dataRouterContext]);
return navigate;

@@ -395,3 +224,2 @@ }

*/
function useOutletContext() {

@@ -402,10 +230,8 @@ return React.useContext(OutletContext);

* Returns the element for the child route at this level of the route
* hierarchy. Used internally by <Outlet> to render child routes.
* hierarchy. Used internally by `<Outlet>` to render child routes.
*
* @see https://reactrouter.com/hooks/use-outlet
*/
function useOutlet(context) {
let outlet = React.useContext(RouteContext).outlet;
if (outlet) {

@@ -416,3 +242,2 @@ return /*#__PURE__*/React.createElement(OutletContext.Provider, {

}
return outlet;

@@ -426,3 +251,2 @@ }

*/
function useParams() {

@@ -440,3 +264,2 @@ let {

*/
function useResolvedPath(to, {

@@ -446,2 +269,5 @@ relative

let {
future
} = React.useContext(NavigationContext);
let {
matches

@@ -452,3 +278,3 @@ } = React.useContext(RouteContext);

} = useLocation();
let routePathnamesJson = JSON.stringify(UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase));
let routePathnamesJson = JSON.stringify(UNSAFE_getResolveToMatches(matches, future.v7_relativeSplatPath));
return React.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);

@@ -459,3 +285,3 @@ }

* with the correct context to render the remainder of the route tree. Route
* elements in the tree must render an <Outlet> to render their child route's
* elements in the tree must render an `<Outlet>` to render their child route's
* element.

@@ -465,5 +291,9 @@ *

*/
function useRoutes(routes, locationArg) {
!useInRouterContext() ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
return useRoutesImpl(routes, locationArg);
}
// Internal implementation with accept optional param for RouterProvider usage
function useRoutesImpl(routes, locationArg, dataRouterState, future) {
!useInRouterContext() ? UNSAFE_invariant(false,
// TODO: This error is probably because they somehow have 2 versions of the
// router loaded. We can help them understand how to avoid that.

@@ -474,3 +304,2 @@ `useRoutes() may be used only in the context of a <Router> component.`) : void 0;

} = React.useContext(NavigationContext);
let dataRouterStateContext = React.useContext(DataRouterStateContext);
let {

@@ -484,3 +313,2 @@ matches: parentMatches

let parentRoute = routeMatch && routeMatch.route;
{

@@ -510,6 +338,4 @@ // You won't get a warning about 2 different <Routes> under a <Route>

}
let locationFromContext = useLocation();
let location;
if (locationArg) {

@@ -522,25 +348,42 @@ let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;

}
let pathname = location.pathname || "/";
let remainingPathname = parentPathnameBase === "/" ? pathname : pathname.slice(parentPathnameBase.length) || "/";
let remainingPathname = pathname;
if (parentPathnameBase !== "/") {
// Determine the remaining pathname by removing the # of URL segments the
// parentPathnameBase has, instead of removing based on character count.
// This is because we can't guarantee that incoming/outgoing encodings/
// decodings will match exactly.
// We decode paths before matching on a per-segment basis with
// decodeURIComponent(), but we re-encode pathnames via `new URL()` so they
// match what `window.location.pathname` would reflect. Those don't 100%
// align when it comes to encoded URI characters such as % and &.
//
// So we may end up with:
// pathname: "/descendant/a%25b/match"
// parentPathnameBase: "/descendant/a%b"
//
// And the direct substring removal approach won't work :/
let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
let segments = pathname.replace(/^\//, "").split("/");
remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
}
let matches = matchRoutes(routes, {
pathname: remainingPathname
});
{
UNSAFE_warning(parentRoute || matches != null, `No routes matched location "${location.pathname}${location.search}${location.hash}" `) ;
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.`) ;
UNSAFE_warning(matches == null || matches[matches.length - 1].route.element !== undefined || matches[matches.length - 1].route.Component !== undefined || matches[matches.length - 1].route.lazy !== 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.`) ;
}
let renderedMatches = _renderMatches(matches && matches.map(match => Object.assign({}, match, {
params: Object.assign({}, parentParams, match.params),
pathname: joinPaths([parentPathnameBase, // Re-encode pathnames that were decoded inside matchRoutes
pathname: joinPaths([parentPathnameBase,
// Re-encode pathnames that were decoded inside matchRoutes
navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname]),
pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([parentPathnameBase, // Re-encode pathnames that were decoded inside matchRoutes
pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([parentPathnameBase,
// Re-encode pathnames that were decoded inside matchRoutes
navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase])
})), parentMatches, dataRouterStateContext || undefined); // When a user passes in a `locationArg`, the associated routes need to
})), parentMatches, dataRouterState, future);
// When a user passes in a `locationArg`, the associated routes need to
// be wrapped in a new `LocationContext.Provider` in order for `useLocation`
// to use the scoped location instead of the global location.
if (locationArg && renderedMatches) {

@@ -561,6 +404,4 @@ return /*#__PURE__*/React.createElement(LocationContext.Provider, {

}
return renderedMatches;
}
function DefaultErrorComponent() {

@@ -580,11 +421,10 @@ let error = useRouteError();

let devInfo = null;
{
devInfo = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), /*#__PURE__*/React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own\u00A0", /*#__PURE__*/React.createElement("code", {
console.error("Error handled by React Router default ErrorBoundary:", error);
devInfo = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), /*#__PURE__*/React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /*#__PURE__*/React.createElement("code", {
style: codeStyles
}, "ErrorBoundary"), " prop on\u00A0", /*#__PURE__*/React.createElement("code", {
}, "ErrorBoundary"), " or", " ", /*#__PURE__*/React.createElement("code", {
style: codeStyles
}, "<Route>")));
}, "errorElement"), " prop on your route."));
}
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("h2", null, "Unexpected Application Error!"), /*#__PURE__*/React.createElement("h3", {

@@ -598,3 +438,3 @@ style: {

}
const defaultErrorElement = /*#__PURE__*/React.createElement(DefaultErrorComponent, null);
class RenderErrorBoundary extends React.Component {

@@ -605,6 +445,6 @@ constructor(props) {

location: props.location,
revalidation: props.revalidation,
error: props.error
};
}
static getDerivedStateFromError(error) {

@@ -615,3 +455,2 @@ return {

}
static getDerivedStateFromProps(props, state) {

@@ -626,25 +465,24 @@ // When we get into an error state, the user will likely click "back" to the

// comes in and the user recovers from the error.
if (state.location !== props.location) {
if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
return {
error: props.error,
location: props.location
location: props.location,
revalidation: props.revalidation
};
} // If we're not changing locations, preserve the location but still surface
}
// If we're not changing locations, preserve the location but still surface
// any new errors that may come through. We retain the existing error, we do
// this because the error provided from the app state may be cleared without
// the location changing.
return {
error: props.error || state.error,
location: state.location
error: props.error !== undefined ? props.error : state.error,
location: state.location,
revalidation: props.revalidation || state.revalidation
};
}
componentDidCatch(error, errorInfo) {
console.error("React Router caught the following error during render", error, errorInfo);
}
render() {
return this.state.error ? /*#__PURE__*/React.createElement(RouteContext.Provider, {
return this.state.error !== undefined ? /*#__PURE__*/React.createElement(RouteContext.Provider, {
value: this.props.routeContext

@@ -656,5 +494,3 @@ }, /*#__PURE__*/React.createElement(RouteErrorContext.Provider, {

}
}
function RenderedRoute({

@@ -665,9 +501,8 @@ routeContext,

}) {
let dataRouterContext = React.useContext(DataRouterContext); // Track how deep we got in our render pass to emulate SSR componentDidCatch
let dataRouterContext = React.useContext(DataRouterContext);
// Track how deep we got in our render pass to emulate SSR componentDidCatch
// in a DataStaticRouter
if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
}
return /*#__PURE__*/React.createElement(RouteContext.Provider, {

@@ -677,4 +512,3 @@ value: routeContext

}
function _renderMatches(matches, parentMatches = [], dataRouterState) {
function _renderMatches(matches, parentMatches = [], dataRouterState = null, future = null) {
if (matches == null) {

@@ -689,41 +523,82 @@ if (dataRouterState?.errors) {

}
let renderedMatches = matches; // If we have data errors, trim matches to the highest error boundary
let renderedMatches = matches;
// If we have data errors, trim matches to the highest error boundary
let errors = dataRouterState?.errors;
if (errors != null) {
let errorIndex = renderedMatches.findIndex(m => m.route.id && errors?.[m.route.id]);
!(errorIndex >= 0) ? UNSAFE_invariant(false, `Could not find a matching route for the current errors: ${errors}`) : void 0;
let errorIndex = renderedMatches.findIndex(m => m.route.id && errors?.[m.route.id] !== undefined);
!(errorIndex >= 0) ? UNSAFE_invariant(false, `Could not find a matching route for errors on route IDs: ${Object.keys(errors).join(",")}`) : void 0;
renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
}
// If we're in a partial hydration mode, detect if we need to render down to
// a given HydrateFallback while we load the rest of the hydration data
let renderFallback = false;
let fallbackIndex = -1;
if (dataRouterState && future && future.v7_partialHydration) {
for (let i = 0; i < renderedMatches.length; i++) {
let match = renderedMatches[i];
// Track the deepest fallback up until the first route without data
if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
fallbackIndex = i;
}
if (match.route.id) {
let {
loaderData,
errors: _errors
} = dataRouterState;
let needsToRunLoader = match.route.loader && loaderData[match.route.id] === undefined && (!_errors || _errors[match.route.id] === undefined);
if (match.route.lazy || needsToRunLoader) {
// We found the first route that's not ready to render (waiting on
// lazy, or has a loader that hasn't run yet). Flag that we need to
// render a fallback and render up until the appropriate fallback
renderFallback = true;
if (fallbackIndex >= 0) {
renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
} else {
renderedMatches = [renderedMatches[0]];
}
break;
}
}
}
}
return renderedMatches.reduceRight((outlet, match, index) => {
let error = match.route.id ? errors?.[match.route.id] : null; // Only data routers handle errors
// Only data routers handle errors/fallbacks
let error;
let shouldRenderHydrateFallback = false;
let errorElement = null;
let hydrateFallbackElement = null;
if (dataRouterState) {
if (match.route.ErrorBoundary) {
errorElement = /*#__PURE__*/React.createElement(match.route.ErrorBoundary, null);
} else if (match.route.errorElement) {
errorElement = match.route.errorElement;
} else {
errorElement = /*#__PURE__*/React.createElement(DefaultErrorComponent, null);
error = errors && match.route.id ? errors[match.route.id] : undefined;
errorElement = match.route.errorElement || defaultErrorElement;
if (renderFallback) {
if (fallbackIndex < 0 && index === 0) {
warningOnce("route-fallback", false, "No `HydrateFallback` element provided to render during initial hydration");
shouldRenderHydrateFallback = true;
hydrateFallbackElement = null;
} else if (fallbackIndex === index) {
shouldRenderHydrateFallback = true;
hydrateFallbackElement = match.route.hydrateFallbackElement || null;
}
}
}
let matches = parentMatches.concat(renderedMatches.slice(0, index + 1));
let getChildren = () => {
let children = outlet;
let children;
if (error) {
children = errorElement;
} else if (shouldRenderHydrateFallback) {
children = hydrateFallbackElement;
} else if (match.route.Component) {
// Note: This is a de-optimized path since React won't re-use the
// ReactElement since it's identity changes with each new
// React.createElement call. We keep this so folks can use
// `<Route Component={...}>` in `<Routes>` but generally `Component`
// usage is only advised in `RouterProvider` when we can convert it to
// `element` ahead of time.
children = /*#__PURE__*/React.createElement(match.route.Component, null);
} else if (match.route.element) {
children = match.route.element;
} else {
children = outlet;
}
return /*#__PURE__*/React.createElement(RenderedRoute, {

@@ -733,13 +608,14 @@ match: match,

outlet,
matches
matches,
isDataRoute: dataRouterState != null
},
children: children
});
}; // Only wrap in an error boundary within data router usages when we have an
};
// Only wrap in an error boundary within data router usages when we have an
// ErrorBoundary/errorElement on this route. Otherwise let it bubble up to
// an ancestor ErrorBoundary/errorElement
return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /*#__PURE__*/React.createElement(RenderErrorBoundary, {
location: dataRouterState.location,
revalidation: dataRouterState.revalidation,
component: errorElement,

@@ -750,3 +626,4 @@ error: error,

outlet: null,
matches
matches,
isDataRoute: true
}

@@ -757,10 +634,8 @@ }) : getChildren();

var DataRouterHook;
(function (DataRouterHook) {
DataRouterHook["UseBlocker"] = "useBlocker";
DataRouterHook["UseRevalidator"] = "useRevalidator";
DataRouterHook["UseNavigateStable"] = "useNavigate";
})(DataRouterHook || (DataRouterHook = {}));
var DataRouterStateHook;
(function (DataRouterStateHook) {

@@ -775,8 +650,8 @@ DataRouterStateHook["UseBlocker"] = "useBlocker";

DataRouterStateHook["UseRevalidator"] = "useRevalidator";
DataRouterStateHook["UseNavigateStable"] = "useNavigate";
DataRouterStateHook["UseRouteId"] = "useRouteId";
})(DataRouterStateHook || (DataRouterStateHook = {}));
function getDataRouterConsoleError(hookName) {
return `${hookName} must be used within a data router. See https://reactrouter.com/routers/picking-a-router.`;
}
function useDataRouterContext(hookName) {

@@ -787,3 +662,2 @@ let ctx = React.useContext(DataRouterContext);

}
function useDataRouterState(hookName) {

@@ -794,3 +668,2 @@ let state = React.useContext(DataRouterStateContext);

}
function useRouteContext(hookName) {

@@ -801,3 +674,3 @@ let route = React.useContext(RouteContext);

}
// Internal version with hookName-aware debugging
function useCurrentRouteId(hookName) {

@@ -810,7 +683,11 @@ let route = useRouteContext(hookName);

/**
* Returns the ID for the nearest contextual route
*/
function useRouteId() {
return useCurrentRouteId(DataRouterStateHook.UseRouteId);
}
/**
* Returns the current navigation, defaulting to an "idle" navigation when
* no navigation is in progress
*/
function useNavigation() {

@@ -824,10 +701,9 @@ let state = useDataRouterState(DataRouterStateHook.UseNavigation);

*/
function useRevalidator() {
let dataRouterContext = useDataRouterContext(DataRouterHook.UseRevalidator);
let state = useDataRouterState(DataRouterStateHook.UseRevalidator);
return {
return React.useMemo(() => ({
revalidate: dataRouterContext.router.revalidate,
state: state.revalidation
};
}), [dataRouterContext.router.revalidate, state.revalidation]);
}

@@ -838,3 +714,2 @@ /**

*/
function useMatches() {

@@ -845,18 +720,3 @@ let {

} = useDataRouterState(DataRouterStateHook.UseMatches);
return React.useMemo(() => matches.map(match => {
let {
pathname,
params
} = match; // Note: This structure matches that created by createUseMatchesMatch
// in the @remix-run/router , so if you change this please also change
// that :) Eventually we'll DRY this up
return {
id: match.route.id,
pathname,
params,
data: loaderData[match.route.id],
handle: match.route.handle
};
}), [matches, loaderData]);
return React.useMemo(() => matches.map(m => UNSAFE_convertRouteMatchToUiMatch(m, loaderData)), [matches, loaderData]);
}

@@ -866,7 +726,5 @@ /**

*/
function useLoaderData() {
let state = useDataRouterState(DataRouterStateHook.UseLoaderData);
let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData);
if (state.errors && state.errors[routeId] != null) {

@@ -876,3 +734,2 @@ console.error(`You cannot \`useLoaderData\` in an errorElement (routeId: ${routeId})`);

}
return state.loaderData[routeId];

@@ -883,3 +740,2 @@ }

*/
function useRouteLoaderData(routeId) {

@@ -892,8 +748,6 @@ let state = useDataRouterState(DataRouterStateHook.UseRouteLoaderData);

*/
function useActionData() {
let state = useDataRouterState(DataRouterStateHook.UseActionData);
let route = React.useContext(RouteContext);
!route ? UNSAFE_invariant(false, `useActionData must be used inside a RouteContext`) : void 0;
return Object.values(state?.actionData || {})[0];
let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData);
return state.actionData ? state.actionData[routeId] : undefined;
}

@@ -905,20 +759,17 @@ /**

*/
function useRouteError() {
let error = React.useContext(RouteErrorContext);
let state = useDataRouterState(DataRouterStateHook.UseRouteError);
let routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError); // If this was a render error, we put it in a RouteError context inside
let routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError);
// If this was a render error, we put it in a RouteError context inside
// of RenderErrorBoundary
if (error) {
if (error !== undefined) {
return error;
} // Otherwise look for errors from our data router state
}
// Otherwise look for errors from our data router state
return state.errors?.[routeId];
}
/**
* Returns the happy-path data from the nearest ancestor <Await /> value
* Returns the happy-path data from the nearest ancestor `<Await />` value
*/
function useAsyncValue() {

@@ -929,5 +780,4 @@ let value = React.useContext(AwaitContext);

/**
* Returns the error from the nearest ancestor <Await /> value
* Returns the error from the nearest ancestor `<Await />` value
*/
function useAsyncError() {

@@ -944,21 +794,86 @@ let value = React.useContext(AwaitContext);

*/
function useBlocker(shouldBlock) {
let {
router
router,
basename
} = useDataRouterContext(DataRouterHook.UseBlocker);
let state = useDataRouterState(DataRouterStateHook.UseBlocker);
let [blockerKey] = React.useState(() => String(++blockerId));
let blockerFunction = React.useCallback(args => {
return typeof shouldBlock === "function" ? !!shouldBlock(args) : !!shouldBlock;
}, [shouldBlock]);
let blocker = router.getBlocker(blockerKey, blockerFunction); // Cleanup on unmount
React.useEffect(() => () => router.deleteBlocker(blockerKey), [router, blockerKey]); // Prefer the blocker from state since DataRouterContext is memoized so this
// ensures we update on blocker state updates
return state.blockers.get(blockerKey) || blocker;
let [blockerKey, setBlockerKey] = React.useState("");
let blockerFunction = React.useCallback(arg => {
if (typeof shouldBlock !== "function") {
return !!shouldBlock;
}
if (basename === "/") {
return shouldBlock(arg);
}
// If they provided us a function and we've got an active basename, strip
// it from the locations we expose to the user to match the behavior of
// useLocation
let {
currentLocation,
nextLocation,
historyAction
} = arg;
return shouldBlock({
currentLocation: {
...currentLocation,
pathname: stripBasename(currentLocation.pathname, basename) || currentLocation.pathname
},
nextLocation: {
...nextLocation,
pathname: stripBasename(nextLocation.pathname, basename) || nextLocation.pathname
},
historyAction
});
}, [basename, shouldBlock]);
// This effect is in charge of blocker key assignment and deletion (which is
// tightly coupled to the key)
React.useEffect(() => {
let key = String(++blockerId);
setBlockerKey(key);
return () => router.deleteBlocker(key);
}, [router]);
// This effect handles assigning the blockerFunction. This is to handle
// unstable blocker function identities, and happens only after the prior
// effect so we don't get an orphaned blockerFunction in the router with a
// key of "". Until then we just have the IDLE_BLOCKER.
React.useEffect(() => {
if (blockerKey !== "") {
router.getBlocker(blockerKey, blockerFunction);
}
}, [router, blockerKey, blockerFunction]);
// Prefer the blocker from `state` not `router.state` since DataRouterContext
// is memoized so this ensures we update on blocker state updates
return blockerKey && state.blockers.has(blockerKey) ? state.blockers.get(blockerKey) : IDLE_BLOCKER;
}
/**
* Stable version of useNavigate that is used when we are in the context of
* a RouterProvider.
*/
function useNavigateStable() {
let {
router
} = useDataRouterContext(DataRouterHook.UseNavigateStable);
let id = useCurrentRouteId(DataRouterStateHook.UseNavigateStable);
let activeRef = React.useRef(false);
useIsomorphicLayoutEffect(() => {
activeRef.current = true;
});
let navigate = React.useCallback((to, options = {}) => {
UNSAFE_warning(activeRef.current, navigateEffectWarning) ;
// Short circuit here since if this happens on first render the navigate
// is useless because we haven't wired up our router subscriber yet
if (!activeRef.current) return;
if (typeof to === "number") {
router.navigate(to);
} else {
router.navigate(to, {
fromRouteId: id,
...options
});
}
}, [router, id]);
return navigate;
}
const alreadyWarned = {};
function warningOnce(key, cond, message) {

@@ -972,15 +887,51 @@ if (!cond && !alreadyWarned[key]) {

/**
Webpack + React 17 fails to compile on any of the following because webpack
complains that `startTransition` doesn't exist in `React`:
* import { startTransition } from "react"
* import * as React from from "react";
"startTransition" in React ? React.startTransition(() => setState()) : setState()
* import * as React from from "react";
"startTransition" in React ? React["startTransition"](() => setState()) : setState()
Moving it to a constant such as the following solves the Webpack/React 17 issue:
* import * as React from from "react";
const START_TRANSITION = "startTransition";
START_TRANSITION in React ? React[START_TRANSITION](() => setState()) : setState()
However, that introduces webpack/terser minification issues in production builds
in React 18 where minification/obfuscation ends up removing the call of
React.startTransition entirely from the first half of the ternary. Grabbing
this exported reference once up front resolves that issue.
See https://github.com/remix-run/react-router/issues/10579
*/
const START_TRANSITION = "startTransition";
const startTransitionImpl = React[START_TRANSITION];
/**
* Given a Remix Router instance, render the appropriate UI
*/
function RouterProvider({
fallbackElement,
router
router,
future
}) {
let getState = React.useCallback(() => router.state, [router]); // Sync router state to our component state to force re-renders
let state = useSyncExternalStore(router.subscribe, getState, // We have to provide this so React@18 doesn't complain during hydration,
// but we pass our serialized hydration data into the router so state here
// is already synced with what the server saw
getState);
let [state, setStateImpl] = React.useState(router.state);
let {
v7_startTransition
} = future || {};
let setState = React.useCallback(newState => {
if (v7_startTransition && startTransitionImpl) {
startTransitionImpl(() => setStateImpl(newState));
} else {
setStateImpl(newState);
}
}, [setStateImpl, v7_startTransition]);
// Need to use a layout effect here so we are subscribed early enough to
// pick up on any render-driven redirects/navigations (useEffect/<Navigate>)
React.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
React.useEffect(() => {
UNSAFE_warning(fallbackElement == null || !router.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using " + "`v7_partialHydration`, use a `HydrateFallback` component instead") ;
// Only log this once on initial mount
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
let navigator = React.useMemo(() => {

@@ -1008,3 +959,4 @@ return {

basename
}), [router, navigator, basename]); // The fragment and {null} here are important! We need them to keep React 18's
}), [router, navigator, basename]);
// The fragment and {null} here are important! We need them to keep React 18's
// useId happy when we are server-rendering since we may have a <script> here

@@ -1015,3 +967,2 @@ // containing the hydrated server-side staticContext (from StaticRouterProvider).

// we don't need the <script> tag
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DataRouterContext.Provider, {

@@ -1022,14 +973,27 @@ value: dataRouterContext

}, /*#__PURE__*/React.createElement(Router, {
basename: router.basename,
location: router.state.location,
navigationType: router.state.historyAction,
navigator: navigator
}, router.state.initialized ? /*#__PURE__*/React.createElement(Routes, null) : fallbackElement))), null);
basename: basename,
location: state.location,
navigationType: state.historyAction,
navigator: navigator,
future: {
v7_relativeSplatPath: router.future.v7_relativeSplatPath
}
}, state.initialized || router.future.v7_partialHydration ? /*#__PURE__*/React.createElement(DataRoutes, {
routes: router.routes,
future: router.future,
state: state
}) : fallbackElement))), null);
}
function DataRoutes({
routes,
future,
state
}) {
return useRoutesImpl(routes, undefined, state, future);
}
/**
* A <Router> that stores all entries in memory.
* A `<Router>` that stores all entries in memory.
*
* @see https://reactrouter.com/router-components/memory-router
*/
function MemoryRouter({

@@ -1039,6 +1003,6 @@ basename,

initialEntries,
initialIndex
initialIndex,
future
}) {
let historyRef = React.useRef();
if (historyRef.current == null) {

@@ -1051,9 +1015,14 @@ historyRef.current = createMemoryHistory({

}
let history = historyRef.current;
let [state, setState] = React.useState({
let [state, setStateImpl] = React.useState({
action: history.action,
location: history.location
});
React.useLayoutEffect(() => history.listen(setState), [history]);
let {
v7_startTransition
} = future || {};
let setState = React.useCallback(newState => {
v7_startTransition && startTransitionImpl ? startTransitionImpl(() => setStateImpl(newState)) : setStateImpl(newState);
}, [setStateImpl, v7_startTransition]);
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
return /*#__PURE__*/React.createElement(Router, {

@@ -1064,3 +1033,4 @@ basename: basename,

navigationType: state.action,
navigator: history
navigator: history,
future: future
});

@@ -1077,3 +1047,2 @@ }

*/
function Navigate({

@@ -1085,22 +1054,27 @@ to,

}) {
!useInRouterContext() ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of
!useInRouterContext() ? UNSAFE_invariant(false,
// TODO: This error is probably because they somehow have 2 versions of
// the router loaded. We can help them understand how to avoid that.
`<Navigate> may be used only in the context of a <Router> component.`) : void 0;
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.`) ;
let dataRouterState = React.useContext(DataRouterStateContext);
let {
future,
static: isStatic
} = React.useContext(NavigationContext);
UNSAFE_warning(!isStatic, `<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.`) ;
let {
matches
} = React.useContext(RouteContext);
let {
pathname: locationPathname
} = useLocation();
let navigate = useNavigate();
React.useEffect(() => {
// Avoid kicking off multiple navigations if we're in the middle of a
// data-router navigation, since components get re-rendered when we enter
// a submitting/loading state
if (dataRouterState && dataRouterState.navigation.state !== "idle") {
return;
}
navigate(to, {
replace,
state,
relative
});
});
// Resolve the path outside of the effect so that when effects run twice in
// StrictMode they navigate to the same place
let path = resolveTo(to, UNSAFE_getResolveToMatches(matches, future.v7_relativeSplatPath), locationPathname, relative === "path");
let jsonPath = JSON.stringify(path);
React.useEffect(() => navigate(JSON.parse(jsonPath), {
replace,
state,
relative
}), [navigate, jsonPath, relative, replace, state]);
return null;

@@ -1113,3 +1087,2 @@ }

*/
function Outlet(props) {

@@ -1123,3 +1096,2 @@ return useOutlet(props.context);

*/
function Route(_props) {

@@ -1131,9 +1103,8 @@ 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>.`) ;

*
* Note: You usually won't render a <Router> directly. Instead, you'll render a
* router that is more specific to your environment such as a <BrowserRouter>
* in web browsers or a <StaticRouter> for server rendering.
* Note: You usually won't render a `<Router>` directly. Instead, you'll render a
* router that is more specific to your environment such as a `<BrowserRouter>`
* in web browsers or a `<StaticRouter>` for server rendering.
*
* @see https://reactrouter.com/router-components/router
*/
function Router({

@@ -1145,7 +1116,8 @@ basename: basenameProp = "/",

navigator,
static: staticProp = false
static: staticProp = false,
future
}) {
!!useInRouterContext() ? UNSAFE_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
!!useInRouterContext() ? UNSAFE_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
// the enforcement of trailing slashes throughout the app
let basename = basenameProp.replace(/^\/*/, "/");

@@ -1155,9 +1127,11 @@ let navigationContext = React.useMemo(() => ({

navigator,
static: staticProp
}), [basename, navigator, staticProp]);
static: staticProp,
future: {
v7_relativeSplatPath: false,
...future
}
}), [basename, future, navigator, staticProp]);
if (typeof locationProp === "string") {
locationProp = parsePath(locationProp);
}
let {

@@ -1172,7 +1146,5 @@ pathname = "/",

let trailingPathname = stripBasename(pathname, basename);
if (trailingPathname == null) {
return null;
}
return {

@@ -1190,7 +1162,5 @@ location: {

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.`) ;
if (locationContext == null) {
return null;
}
return /*#__PURE__*/React.createElement(NavigationContext.Provider, {

@@ -1204,3 +1174,3 @@ value: navigationContext

/**
* A container for a nested tree of <Route> elements that renders the branch
* A container for a nested tree of `<Route>` elements that renders the branch
* that best matches the current location.

@@ -1210,3 +1180,2 @@ *

*/
function Routes({

@@ -1216,8 +1185,3 @@ children,

}) {
let dataRouterContext = React.useContext(DataRouterContext); // When in a DataRouterContext _without_ children, we use the router routes
// directly. If we have children, then we're in a descendant tree and we
// need to use child routes.
let routes = dataRouterContext && !children ? dataRouterContext.router.routes : createRoutesFromChildren(children);
return useRoutes(routes, location);
return useRoutes(createRoutesFromChildren(children), location);
}

@@ -1228,3 +1192,2 @@ /**

*/
function Await({

@@ -1241,3 +1204,2 @@ children,

var AwaitRenderStatus;
(function (AwaitRenderStatus) {

@@ -1248,5 +1210,3 @@ AwaitRenderStatus[AwaitRenderStatus["pending"] = 0] = "pending";

})(AwaitRenderStatus || (AwaitRenderStatus = {}));
const neverSettledPromise = new Promise(() => {});
class AwaitErrorBoundary extends React.Component {

@@ -1259,3 +1219,2 @@ constructor(props) {

}
static getDerivedStateFromError(error) {

@@ -1266,7 +1225,5 @@ return {

}
componentDidCatch(error, errorInfo) {
console.error("<Await> caught the following error during render", error, errorInfo);
}
render() {

@@ -1280,3 +1237,2 @@ let {

let status = AwaitRenderStatus.pending;
if (!(resolve instanceof Promise)) {

@@ -1297,3 +1253,2 @@ // Didn't get a promise - provide as a resolved promise

promise = Promise.reject().catch(() => {}); // Avoid unhandled rejection warnings
Object.defineProperty(promise, "_tracked", {

@@ -1321,3 +1276,2 @@ get: () => true

}
if (status === AwaitRenderStatus.error && promise._error instanceof AbortedDeferredError) {

@@ -1327,3 +1281,2 @@ // Freeze the UI by throwing a never resolved promise

}
if (status === AwaitRenderStatus.error && !errorElement) {

@@ -1333,3 +1286,2 @@ // No errorElement, throw to the nearest route-level error boundary

}
if (status === AwaitRenderStatus.error) {

@@ -1342,3 +1294,2 @@ // Render via our errorElement

}
if (status === AwaitRenderStatus.success) {

@@ -1350,15 +1301,11 @@ // Render children with resolved value

});
} // Throw to the suspense boundary
}
// Throw to the suspense boundary
throw promise;
}
}
/**
* @private
* Indirection to leverage useAsyncValue for a render-prop API on <Await>
* Indirection to leverage useAsyncValue for a render-prop API on `<Await>`
*/
function ResolveAwait({

@@ -1370,6 +1317,6 @@ children

return /*#__PURE__*/React.createElement(React.Fragment, null, toRender);
} ///////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////
// UTILS
///////////////////////////////////////////////////////////////////////////////
/**

@@ -1382,4 +1329,2 @@ * Creates a route config from a React "children" object, which is usually

*/
function createRoutesFromChildren(children, parentPath = []) {

@@ -1393,5 +1338,3 @@ let routes = [];

}
let treePath = [...parentPath, index];
if (element.type === React.Fragment) {

@@ -1402,3 +1345,2 @@ // Transparently support React.Fragment and its children.

}
!(element.type === Route) ? 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>`) : void 0;

@@ -1422,7 +1364,5 @@ !(!element.props.index || !element.props.children) ? UNSAFE_invariant(false, "An index route cannot have child routes.") : void 0;

};
if (element.props.children) {
route.children = createRoutesFromChildren(element.props.children, treePath);
}
routes.push(route);

@@ -1435,3 +1375,2 @@ });

*/
function renderMatches(matches) {

@@ -1441,22 +1380,50 @@ return _renderMatches(matches);

function detectErrorBoundary(route) {
{
if (route.Component && route.element) {
UNSAFE_warning(false, "You should not include both `Component` and `element` on your route - " + "`element` will be ignored.") ;
function mapRouteProperties(route) {
let updates = {
// Note: this check also occurs in createRoutesFromChildren so update
// there if you change this -- please and thank you!
hasErrorBoundary: route.ErrorBoundary != null || route.errorElement != null
};
if (route.Component) {
{
if (route.element) {
UNSAFE_warning(false, "You should not include both `Component` and `element` on your route - " + "`Component` will be used.") ;
}
}
if (route.ErrorBoundary && route.errorElement) {
UNSAFE_warning(false, "You should not include both `ErrorBoundary` and `errorElement` on your route - " + "`errorElement` will be ignored.") ;
Object.assign(updates, {
element: /*#__PURE__*/React.createElement(route.Component),
Component: undefined
});
}
if (route.HydrateFallback) {
{
if (route.hydrateFallbackElement) {
UNSAFE_warning(false, "You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - " + "`HydrateFallback` will be used.") ;
}
}
} // Note: this check also occurs in createRoutesFromChildren so update
// there if you change this
return Boolean(route.ErrorBoundary) || Boolean(route.errorElement);
Object.assign(updates, {
hydrateFallbackElement: /*#__PURE__*/React.createElement(route.HydrateFallback),
HydrateFallback: undefined
});
}
if (route.ErrorBoundary) {
{
if (route.errorElement) {
UNSAFE_warning(false, "You should not include both `ErrorBoundary` and `errorElement` on your route - " + "`ErrorBoundary` will be used.") ;
}
}
Object.assign(updates, {
errorElement: /*#__PURE__*/React.createElement(route.ErrorBoundary),
ErrorBoundary: undefined
});
}
return updates;
}
function createMemoryRouter(routes, opts) {
return createRouter({
basename: opts?.basename,
future: opts?.future,
future: {
...opts?.future,
v7_prependBasename: true
},
history: createMemoryHistory({

@@ -1468,7 +1435,8 @@ initialEntries: opts?.initialEntries,

routes,
detectErrorBoundary
mapRouteProperties,
unstable_dataStrategy: opts?.unstable_dataStrategy
}).initialize();
} ///////////////////////////////////////////////////////////////////////////////
}
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, detectErrorBoundary as UNSAFE_detectErrorBoundary, 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 };
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, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
//# sourceMappingURL=react-router.development.js.map
/**
* React Router v0.0.0-experimental-0f2dd78c
* React Router v0.0.0-experimental-0f302655
*

@@ -11,3 +11,3 @@ * Copyright (c) Remix Software Inc.

*/
import{UNSAFE_invariant as e,joinPaths as t,matchPath as r,UNSAFE_getPathContributingMatches as n,resolveTo as o,parsePath as a,matchRoutes as l,Action as i,isRouteErrorResponse as u,createMemoryHistory as s,stripBasename as c,AbortedDeferredError as d,createRouter as p}from"@remix-run/router";export{AbortedDeferredError,Action as NavigationType,createPath,defer,generatePath,isRouteErrorResponse,json,matchPath,matchRoutes,parsePath,redirect,resolvePath}from"@remix-run/router";import*as m from"react";const h="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},{useState:f,useEffect:v,useLayoutEffect:E,useDebugValue:g}=m;function x(e){const t=e.getSnapshot,r=e.value;try{const e=t();return!h(r,e)}catch(n){return!0}}const y=!!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement)?function(e,t,r){return t()}:function(e,t,r){const n=t(),[{inst:o},a]=f({inst:{value:n,getSnapshot:t}});return E((()=>{o.value=n,o.getSnapshot=t,x(o)&&a({inst:o})}),[e,n,t]),v((()=>{x(o)&&a({inst:o});return e((()=>{x(o)&&a({inst:o})}))}),[e]),g(n),n},C="useSyncExternalStore"in m?m.useSyncExternalStore:y,b=m.createContext(null),S=m.createContext(null),R=m.createContext(null),B=m.createContext(null),P=m.createContext(null),U=m.createContext({outlet:null,matches:[]}),D=m.createContext(null);function k(r,{relative:n}={}){_()||e(!1);let{basename:o,navigator:a}=m.useContext(B),{hash:l,pathname:i,search:u}=T(r,{relative:n}),s=i;return"/"!==o&&(s="/"===i?o:t([o,i])),a.createHref({pathname:s,search:u,hash:l})}function _(){return null!=m.useContext(P)}function L(){return _()||e(!1),m.useContext(P).location}function O(){return m.useContext(P).navigationType}function N(t){_()||e(!1);let{pathname:n}=L();return m.useMemo((()=>r(t,n)),[n,t])}function j(){_()||e(!1);let{basename:r,navigator:a}=m.useContext(B),{matches:l}=m.useContext(U),{pathname:i}=L(),u=JSON.stringify(n(l).map((e=>e.pathnameBase))),s=m.useRef(!1);return m.useEffect((()=>{s.current=!0})),m.useCallback(((e,n={})=>{if(!s.current)return;if("number"==typeof e)return void a.go(e);let l=o(e,JSON.parse(u),i,"path"===n.relative);"/"!==r&&(l.pathname="/"===l.pathname?r:t([r,l.pathname])),(n.replace?a.replace:a.push)(l,n.state,n)}),[r,a,u,i])}const A=m.createContext(null);function F(){return m.useContext(A)}function w(e){let t=m.useContext(U).outlet;return t?m.createElement(A.Provider,{value:e},t):t}function M(){let{matches:e}=m.useContext(U),t=e[e.length-1];return t?t.params:{}}function T(e,{relative:t}={}){let{matches:r}=m.useContext(U),{pathname:a}=L(),l=JSON.stringify(n(r).map((e=>e.pathnameBase)));return m.useMemo((()=>o(e,JSON.parse(l),a,"path"===t)),[e,l,a,t])}function I(r,n){_()||e(!1);let{navigator:o}=m.useContext(B),u=m.useContext(S),{matches:s}=m.useContext(U),c=s[s.length-1],d=c?c.params:{};!c||c.pathname;let p=c?c.pathnameBase:"/";c&&c.route;let h,f=L();if(n){let t="string"==typeof n?a(n):n;"/"===p||t.pathname?.startsWith(p)||e(!1),h=t}else h=f;let v=h.pathname||"/",E="/"===p?v:v.slice(p.length)||"/",g=l(r,{pathname:E}),x=$(g&&g.map((e=>Object.assign({},e,{params:Object.assign({},d,e.params),pathname:t([p,o.encodeLocation?o.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?p:t([p,o.encodeLocation?o.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])}))),s,u||void 0);return n&&x?m.createElement(P.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...h},navigationType:i.Pop}},x):x}function J(){let e=re(),t=u(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,n={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},t),r?m.createElement("pre",{style:n},r):null,null)}class z extends m.Component{constructor(e){super(e),this.state={location:e.location,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location?{error:e.error,location:e.location}:{error:e.error||t.error,location:t.location}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return this.state.error?m.createElement(U.Provider,{value:this.props.routeContext},m.createElement(D.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function H({routeContext:e,match:t,children:r}){let n=m.useContext(b);return n&&n.static&&n.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=t.route.id),m.createElement(U.Provider,{value:e},r)}function $(t,r=[],n){if(null==t){if(!n?.errors)return null;t=n.matches}let o=t,a=n?.errors;if(null!=a){let t=o.findIndex((e=>e.route.id&&a?.[e.route.id]));t>=0||e(!1),o=o.slice(0,Math.min(o.length,t+1))}return o.reduceRight(((e,t,l)=>{let i=t.route.id?a?.[t.route.id]:null,u=null;n&&(u=t.route.ErrorBoundary?m.createElement(t.route.ErrorBoundary,null):t.route.errorElement?t.route.errorElement:m.createElement(J,null));let s=r.concat(o.slice(0,l+1)),c=()=>{let r=e;return i?r=u:t.route.Component?r=m.createElement(t.route.Component,null):t.route.element&&(r=t.route.element),m.createElement(H,{match:t,routeContext:{outlet:e,matches:s},children:r})};return n&&(t.route.ErrorBoundary||t.route.errorElement||0===l)?m.createElement(z,{location:n.location,component:u,error:i,children:c(),routeContext:{outlet:null,matches:s}}):c()}),null)}var V,W;function Y(t){let r=m.useContext(b);return r||e(!1),r}function q(t){let r=m.useContext(S);return r||e(!1),r}function G(t){let r=function(t){let r=m.useContext(U);return r||e(!1),r}(),n=r.matches[r.matches.length-1];return n.route.id||e(!1),n.route.id}function K(){return q(W.UseNavigation).navigation}function Q(){let e=Y(V.UseRevalidator),t=q(W.UseRevalidator);return{revalidate:e.router.revalidate,state:t.revalidation}}function X(){let{matches:e,loaderData:t}=q(W.UseMatches);return m.useMemo((()=>e.map((e=>{let{pathname:r,params:n}=e;return{id:e.route.id,pathname:r,params:n,data:t[e.route.id],handle:e.route.handle}}))),[e,t])}function Z(){let e=q(W.UseLoaderData),t=G(W.UseLoaderData);if(!e.errors||null==e.errors[t])return e.loaderData[t];console.error(`You cannot \`useLoaderData\` in an errorElement (routeId: ${t})`)}function ee(e){return q(W.UseRouteLoaderData).loaderData[e]}function te(){let t=q(W.UseActionData);return m.useContext(U)||e(!1),Object.values(t?.actionData||{})[0]}function re(){let e=m.useContext(D),t=q(W.UseRouteError),r=G(W.UseRouteError);return e||t.errors?.[r]}function ne(){return m.useContext(R)?._data}function oe(){return m.useContext(R)?._error}!function(e){e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator"}(V||(V={})),function(e){e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator"}(W||(W={}));let ae=0;function le(e){let{router:t}=Y(V.UseBlocker),r=q(W.UseBlocker),[n]=m.useState((()=>String(++ae))),o=m.useCallback((t=>"function"==typeof e?!!e(t):!!e),[e]),a=t.getBlocker(n,o);return m.useEffect((()=>()=>t.deleteBlocker(n)),[t,n]),r.blockers.get(n)||a}function ie({fallbackElement:e,router:t}){let r=m.useCallback((()=>t.state),[t]),n=C(t.subscribe,r,r),o=m.useMemo((()=>({createHref:t.createHref,encodeLocation:t.encodeLocation,go:e=>t.navigate(e),push:(e,r,n)=>t.navigate(e,{state:r,preventScrollReset:n?.preventScrollReset}),replace:(e,r,n)=>t.navigate(e,{replace:!0,state:r,preventScrollReset:n?.preventScrollReset})})),[t]),a=t.basename||"/",l=m.useMemo((()=>({router:t,navigator:o,static:!1,basename:a})),[t,o,a]);return m.createElement(m.Fragment,null,m.createElement(b.Provider,{value:l},m.createElement(S.Provider,{value:n},m.createElement(pe,{basename:t.basename,location:t.state.location,navigationType:t.state.historyAction,navigator:o},t.state.initialized?m.createElement(me,null):e))),null)}function ue({basename:e,children:t,initialEntries:r,initialIndex:n}){let o=m.useRef();null==o.current&&(o.current=s({initialEntries:r,initialIndex:n,v5Compat:!0}));let a=o.current,[l,i]=m.useState({action:a.action,location:a.location});return m.useLayoutEffect((()=>a.listen(i)),[a]),m.createElement(pe,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:a})}function se({to:t,replace:r,state:n,relative:o}){_()||e(!1);let a=m.useContext(S),l=j();return m.useEffect((()=>{a&&"idle"!==a.navigation.state||l(t,{replace:r,state:n,relative:o})})),null}function ce(e){return w(e.context)}function de(t){e(!1)}function pe({basename:t="/",children:r=null,location:n,navigationType:o=i.Pop,navigator:l,static:u=!1}){_()&&e(!1);let s=t.replace(/^\/*/,"/"),d=m.useMemo((()=>({basename:s,navigator:l,static:u})),[s,l,u]);"string"==typeof n&&(n=a(n));let{pathname:p="/",search:h="",hash:f="",state:v=null,key:E="default"}=n,g=m.useMemo((()=>{let e=c(p,s);return null==e?null:{location:{pathname:e,search:h,hash:f,state:v,key:E},navigationType:o}}),[s,p,h,f,v,E,o]);return null==g?null:m.createElement(B.Provider,{value:d},m.createElement(P.Provider,{children:r,value:g}))}function me({children:e,location:t}){let r=m.useContext(b);return I(r&&!e?r.router.routes:xe(e),t)}function he({children:e,errorElement:t,resolve:r}){return m.createElement(Ee,{resolve:r,errorElement:t},m.createElement(ge,null,e))}var fe;!function(e){e[e.pending=0]="pending",e[e.success=1]="success",e[e.error=2]="error"}(fe||(fe={}));const ve=new Promise((()=>{}));class Ee extends m.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error("<Await> caught the following error during render",e,t)}render(){let{children:e,errorElement:t,resolve:r}=this.props,n=null,o=fe.pending;if(r instanceof Promise)if(this.state.error){o=fe.error;let e=this.state.error;n=Promise.reject().catch((()=>{})),Object.defineProperty(n,"_tracked",{get:()=>!0}),Object.defineProperty(n,"_error",{get:()=>e})}else r._tracked?(n=r,o=void 0!==n._error?fe.error:void 0!==n._data?fe.success:fe.pending):(o=fe.pending,Object.defineProperty(r,"_tracked",{get:()=>!0}),n=r.then((e=>Object.defineProperty(r,"_data",{get:()=>e})),(e=>Object.defineProperty(r,"_error",{get:()=>e}))));else o=fe.success,n=Promise.resolve(),Object.defineProperty(n,"_tracked",{get:()=>!0}),Object.defineProperty(n,"_data",{get:()=>r});if(o===fe.error&&n._error instanceof d)throw ve;if(o===fe.error&&!t)throw n._error;if(o===fe.error)return m.createElement(R.Provider,{value:n,children:t});if(o===fe.success)return m.createElement(R.Provider,{value:n,children:e});throw n}}function ge({children:e}){let t=ne(),r="function"==typeof e?e(t):e;return m.createElement(m.Fragment,null,r)}function xe(t,r=[]){let n=[];return m.Children.forEach(t,((t,o)=>{if(!m.isValidElement(t))return;let a=[...r,o];if(t.type===m.Fragment)return void n.push.apply(n,xe(t.props.children,a));t.type!==de&&e(!1),t.props.index&&t.props.children&&e(!1);let l={id:t.props.id||a.join("-"),caseSensitive:t.props.caseSensitive,element:t.props.element,Component:t.props.Component,index:t.props.index,path:t.props.path,loader:t.props.loader,action:t.props.action,errorElement:t.props.errorElement,ErrorBoundary:t.props.ErrorBoundary,hasErrorBoundary:null!=t.props.ErrorBoundary||null!=t.props.errorElement,shouldRevalidate:t.props.shouldRevalidate,handle:t.props.handle,lazy:t.props.lazy};t.props.children&&(l.children=xe(t.props.children,a)),n.push(l)})),n}function ye(e){return $(e)}function Ce(e){return Boolean(e.ErrorBoundary)||Boolean(e.errorElement)}function be(e,t){return p({basename:t?.basename,future:t?.future,history:s({initialEntries:t?.initialEntries,initialIndex:t?.initialIndex}),hydrationData:t?.hydrationData,routes:e,detectErrorBoundary:Ce}).initialize()}export{he as Await,ue as MemoryRouter,se as Navigate,ce as Outlet,de as Route,pe as Router,ie as RouterProvider,me as Routes,b as UNSAFE_DataRouterContext,S as UNSAFE_DataRouterStateContext,P as UNSAFE_LocationContext,B as UNSAFE_NavigationContext,U as UNSAFE_RouteContext,Ce as UNSAFE_detectErrorBoundary,be as createMemoryRouter,xe as createRoutesFromChildren,xe as createRoutesFromElements,ye as renderMatches,le as unstable_useBlocker,te as useActionData,oe as useAsyncError,ne as useAsyncValue,k as useHref,_ as useInRouterContext,Z as useLoaderData,L as useLocation,N as useMatch,X as useMatches,j as useNavigate,K as useNavigation,O as useNavigationType,w as useOutlet,F as useOutletContext,M as useParams,T as useResolvedPath,Q as useRevalidator,re as useRouteError,ee as useRouteLoaderData,I as useRoutes};
import*as e from"react";import{UNSAFE_invariant as t,joinPaths as r,matchPath as n,UNSAFE_getResolveToMatches as a,resolveTo as o,parsePath as l,matchRoutes as i,Action as u,UNSAFE_convertRouteMatchToUiMatch as s,stripBasename as c,IDLE_BLOCKER as d,isRouteErrorResponse as p,createMemoryHistory as m,AbortedDeferredError as h,createRouter as f}from"@remix-run/router";export{AbortedDeferredError,Action as NavigationType,createPath,defer,generatePath,isRouteErrorResponse,json,matchPath,matchRoutes,parsePath,redirect,redirectDocument,resolvePath}from"@remix-run/router";const v=e.createContext(null),E=e.createContext(null),g=e.createContext(null),y=e.createContext(null),x=e.createContext(null),C=e.createContext({outlet:null,matches:[],isDataRoute:!1}),b=e.createContext(null);function R(n,{relative:a}={}){S()||t(!1);let{basename:o,navigator:l}=e.useContext(y),{hash:i,pathname:u,search:s}=O(n,{relative:a}),c=u;return"/"!==o&&(c="/"===u?o:r([o,u])),l.createHref({pathname:c,search:s,hash:i})}function S(){return null!=e.useContext(x)}function P(){return S()||t(!1),e.useContext(x).location}function U(){return e.useContext(x).navigationType}function _(r){S()||t(!1);let{pathname:a}=P();return e.useMemo((()=>n(r,a)),[a,r])}function k(t){e.useContext(y).static||e.useLayoutEffect(t)}function D(){let{isDataRoute:n}=e.useContext(C);return n?function(){let{router:t}=$(J.UseNavigateStable),r=W(z.UseNavigateStable),n=e.useRef(!1);return k((()=>{n.current=!0})),e.useCallback(((e,a={})=>{n.current&&("number"==typeof e?t.navigate(e):t.navigate(e,{fromRouteId:r,...a}))}),[t,r])}():function(){S()||t(!1);let n=e.useContext(v),{basename:l,future:i,navigator:u}=e.useContext(y),{matches:s}=e.useContext(C),{pathname:c}=P(),d=JSON.stringify(a(s,i.v7_relativeSplatPath)),p=e.useRef(!1);return k((()=>{p.current=!0})),e.useCallback(((e,t={})=>{if(!p.current)return;if("number"==typeof e)return void u.go(e);let a=o(e,JSON.parse(d),c,"path"===t.relative);null==n&&"/"!==l&&(a.pathname="/"===a.pathname?l:r([l,a.pathname])),(t.replace?u.replace:u.push)(a,t.state,t)}),[l,u,d,c,n])}()}const B=e.createContext(null);function N(){return e.useContext(B)}function F(t){let r=e.useContext(C).outlet;return r?e.createElement(B.Provider,{value:t},r):r}function L(){let{matches:t}=e.useContext(C),r=t[t.length-1];return r?r.params:{}}function O(t,{relative:r}={}){let{future:n}=e.useContext(y),{matches:l}=e.useContext(C),{pathname:i}=P(),u=JSON.stringify(a(l,n.v7_relativeSplatPath));return e.useMemo((()=>o(t,JSON.parse(u),i,"path"===r)),[t,u,i,r])}function A(e,t){return j(e,t)}function j(n,a,o,s){S()||t(!1);let{navigator:c}=e.useContext(y),{matches:d}=e.useContext(C),p=d[d.length-1],m=p?p.params:{};!p||p.pathname;let h=p?p.pathnameBase:"/";p&&p.route;let f,v=P();if(a){let e="string"==typeof a?l(a):a;"/"===h||e.pathname?.startsWith(h)||t(!1),f=e}else f=v;let E=f.pathname||"/",g=E;if("/"!==h){let e=h.replace(/^\//,"").split("/");g="/"+E.replace(/^\//,"").split("/").slice(e.length).join("/")}let b=i(n,{pathname:g}),R=w(b&&b.map((e=>Object.assign({},e,{params:Object.assign({},m,e.params),pathname:r([h,c.encodeLocation?c.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?h:r([h,c.encodeLocation?c.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])}))),d,o,s);return a&&R?e.createElement(x.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...f},navigationType:u.Pop}},R):R}function I(){let t=ee(),r=p(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return e.createElement(e.Fragment,null,e.createElement("h2",null,"Unexpected Application Error!"),e.createElement("h3",{style:{fontStyle:"italic"}},r),n?e.createElement("pre",{style:a},n):null,null)}const M=e.createElement(I,null);class T extends e.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||"idle"!==t.revalidation&&"idle"===e.revalidation?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:void 0!==e.error?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return void 0!==this.state.error?e.createElement(C.Provider,{value:this.props.routeContext},e.createElement(b.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function H({routeContext:t,match:r,children:n}){let a=e.useContext(v);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),e.createElement(C.Provider,{value:t},n)}function w(r,n=[],a=null,o=null){if(null==r){if(!a?.errors)return null;r=a.matches}let l=r,i=a?.errors;if(null!=i){let e=l.findIndex((e=>e.route.id&&void 0!==i?.[e.route.id]));e>=0||t(!1),l=l.slice(0,Math.min(l.length,e+1))}let u=!1,s=-1;if(a&&o&&o.v7_partialHydration)for(let e=0;e<l.length;e++){let t=l[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:r}=a,n=t.route.loader&&void 0===e[t.route.id]&&(!r||void 0===r[t.route.id]);if(t.route.lazy||n){u=!0,l=s>=0?l.slice(0,s+1):[l[0]];break}}}return l.reduceRight(((t,r,o)=>{let c,d=!1,p=null,m=null;var h;a&&(c=i&&r.route.id?i[r.route.id]:void 0,p=r.route.errorElement||M,u&&(s<0&&0===o?(h="route-fallback",!1||oe[h]||(oe[h]=!0),d=!0,m=null):s===o&&(d=!0,m=r.route.hydrateFallbackElement||null)));let f=n.concat(l.slice(0,o+1)),v=()=>{let n;return n=c?p:d?m:r.route.Component?e.createElement(r.route.Component,null):r.route.element?r.route.element:t,e.createElement(H,{match:r,routeContext:{outlet:t,matches:f,isDataRoute:null!=a},children:n})};return a&&(r.route.ErrorBoundary||r.route.errorElement||0===o)?e.createElement(T,{location:a.location,revalidation:a.revalidation,component:p,error:c,children:v(),routeContext:{outlet:null,matches:f,isDataRoute:!0}}):v()}),null)}var J=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(J||{}),z=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(z||{});function $(r){let n=e.useContext(v);return n||t(!1),n}function V(r){let n=e.useContext(E);return n||t(!1),n}function W(r){let n=function(r){let n=e.useContext(C);return n||t(!1),n}(),a=n.matches[n.matches.length-1];return a.route.id||t(!1),a.route.id}function Y(){return W(z.UseRouteId)}function q(){return V(z.UseNavigation).navigation}function G(){let t=$(J.UseRevalidator),r=V(z.UseRevalidator);return e.useMemo((()=>({revalidate:t.router.revalidate,state:r.revalidation})),[t.router.revalidate,r.revalidation])}function K(){let{matches:t,loaderData:r}=V(z.UseMatches);return e.useMemo((()=>t.map((e=>s(e,r)))),[t,r])}function Q(){let e=V(z.UseLoaderData),t=W(z.UseLoaderData);if(!e.errors||null==e.errors[t])return e.loaderData[t];console.error(`You cannot \`useLoaderData\` in an errorElement (routeId: ${t})`)}function X(e){return V(z.UseRouteLoaderData).loaderData[e]}function Z(){let e=V(z.UseActionData),t=W(z.UseLoaderData);return e.actionData?e.actionData[t]:void 0}function ee(){let t=e.useContext(b),r=V(z.UseRouteError),n=W(z.UseRouteError);return void 0!==t?t:r.errors?.[n]}function te(){return e.useContext(g)?._data}function re(){return e.useContext(g)?._error}let ne=0;function ae(t){let{router:r,basename:n}=$(J.UseBlocker),a=V(z.UseBlocker),[o,l]=e.useState(""),i=e.useCallback((e=>{if("function"!=typeof t)return!!t;if("/"===n)return t(e);let{currentLocation:r,nextLocation:a,historyAction:o}=e;return t({currentLocation:{...r,pathname:c(r.pathname,n)||r.pathname},nextLocation:{...a,pathname:c(a.pathname,n)||a.pathname},historyAction:o})}),[n,t]);return e.useEffect((()=>{let e=String(++ne);return l(e),()=>r.deleteBlocker(e)}),[r]),e.useEffect((()=>{""!==o&&r.getBlocker(o,i)}),[r,o,i]),o&&a.blockers.has(o)?a.blockers.get(o):d}const oe={};const le=e.startTransition;function ie({fallbackElement:t,router:r,future:n}){let[a,o]=e.useState(r.state),{v7_startTransition:l}=n||{},i=e.useCallback((e=>{l&&le?le((()=>o(e))):o(e)}),[o,l]);e.useLayoutEffect((()=>r.subscribe(i)),[r,i]),e.useEffect((()=>{}),[]);let u=e.useMemo((()=>({createHref:r.createHref,encodeLocation:r.encodeLocation,go:e=>r.navigate(e),push:(e,t,n)=>r.navigate(e,{state:t,preventScrollReset:n?.preventScrollReset}),replace:(e,t,n)=>r.navigate(e,{replace:!0,state:t,preventScrollReset:n?.preventScrollReset})})),[r]),s=r.basename||"/",c=e.useMemo((()=>({router:r,navigator:u,static:!1,basename:s})),[r,u,s]);return e.createElement(e.Fragment,null,e.createElement(v.Provider,{value:c},e.createElement(E.Provider,{value:a},e.createElement(me,{basename:s,location:a.location,navigationType:a.historyAction,navigator:u,future:{v7_relativeSplatPath:r.future.v7_relativeSplatPath}},a.initialized||r.future.v7_partialHydration?e.createElement(ue,{routes:r.routes,future:r.future,state:a}):t))),null)}function ue({routes:e,future:t,state:r}){return j(e,void 0,r,t)}function se({basename:t,children:r,initialEntries:n,initialIndex:a,future:o}){let l=e.useRef();null==l.current&&(l.current=m({initialEntries:n,initialIndex:a,v5Compat:!0}));let i=l.current,[u,s]=e.useState({action:i.action,location:i.location}),{v7_startTransition:c}=o||{},d=e.useCallback((e=>{c&&le?le((()=>s(e))):s(e)}),[s,c]);return e.useLayoutEffect((()=>i.listen(d)),[i,d]),e.createElement(me,{basename:t,children:r,location:u.location,navigationType:u.action,navigator:i,future:o})}function ce({to:r,replace:n,state:l,relative:i}){S()||t(!1);let{future:u,static:s}=e.useContext(y),{matches:c}=e.useContext(C),{pathname:d}=P(),p=D(),m=o(r,a(c,u.v7_relativeSplatPath),d,"path"===i),h=JSON.stringify(m);return e.useEffect((()=>p(JSON.parse(h),{replace:n,state:l,relative:i})),[p,h,i,n,l]),null}function de(e){return F(e.context)}function pe(e){t(!1)}function me({basename:r="/",children:n=null,location:a,navigationType:o=u.Pop,navigator:i,static:s=!1,future:d}){S()&&t(!1);let p=r.replace(/^\/*/,"/"),m=e.useMemo((()=>({basename:p,navigator:i,static:s,future:{v7_relativeSplatPath:!1,...d}})),[p,d,i,s]);"string"==typeof a&&(a=l(a));let{pathname:h="/",search:f="",hash:v="",state:E=null,key:g="default"}=a,C=e.useMemo((()=>{let e=c(h,p);return null==e?null:{location:{pathname:e,search:f,hash:v,state:E,key:g},navigationType:o}}),[p,h,f,v,E,g,o]);return null==C?null:e.createElement(y.Provider,{value:m},e.createElement(x.Provider,{children:n,value:C}))}function he({children:e,location:t}){return A(xe(e),t)}function fe({children:t,errorElement:r,resolve:n}){return e.createElement(ge,{resolve:n,errorElement:r},e.createElement(ye,null,t))}var ve=function(e){return e[e.pending=0]="pending",e[e.success=1]="success",e[e.error=2]="error",e}(ve||{});const Ee=new Promise((()=>{}));class ge extends e.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error("<Await> caught the following error during render",e,t)}render(){let{children:t,errorElement:r,resolve:n}=this.props,a=null,o=ve.pending;if(n instanceof Promise)if(this.state.error){o=ve.error;let e=this.state.error;a=Promise.reject().catch((()=>{})),Object.defineProperty(a,"_tracked",{get:()=>!0}),Object.defineProperty(a,"_error",{get:()=>e})}else n._tracked?(a=n,o=void 0!==a._error?ve.error:void 0!==a._data?ve.success:ve.pending):(o=ve.pending,Object.defineProperty(n,"_tracked",{get:()=>!0}),a=n.then((e=>Object.defineProperty(n,"_data",{get:()=>e})),(e=>Object.defineProperty(n,"_error",{get:()=>e}))));else o=ve.success,a=Promise.resolve(),Object.defineProperty(a,"_tracked",{get:()=>!0}),Object.defineProperty(a,"_data",{get:()=>n});if(o===ve.error&&a._error instanceof h)throw Ee;if(o===ve.error&&!r)throw a._error;if(o===ve.error)return e.createElement(g.Provider,{value:a,children:r});if(o===ve.success)return e.createElement(g.Provider,{value:a,children:t});throw a}}function ye({children:t}){let r=te(),n="function"==typeof t?t(r):t;return e.createElement(e.Fragment,null,n)}function xe(r,n=[]){let a=[];return e.Children.forEach(r,((r,o)=>{if(!e.isValidElement(r))return;let l=[...n,o];if(r.type===e.Fragment)return void a.push.apply(a,xe(r.props.children,l));r.type!==pe&&t(!1),r.props.index&&r.props.children&&t(!1);let i={id:r.props.id||l.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:null!=r.props.ErrorBoundary||null!=r.props.errorElement,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(i.children=xe(r.props.children,l)),a.push(i)})),a}function Ce(e){return w(e)}function be(t){let r={hasErrorBoundary:null!=t.ErrorBoundary||null!=t.errorElement};return t.Component&&Object.assign(r,{element:e.createElement(t.Component),Component:void 0}),t.HydrateFallback&&Object.assign(r,{hydrateFallbackElement:e.createElement(t.HydrateFallback),HydrateFallback:void 0}),t.ErrorBoundary&&Object.assign(r,{errorElement:e.createElement(t.ErrorBoundary),ErrorBoundary:void 0}),r}function Re(e,t){return f({basename:t?.basename,future:{...t?.future,v7_prependBasename:!0},history:m({initialEntries:t?.initialEntries,initialIndex:t?.initialIndex}),hydrationData:t?.hydrationData,routes:e,mapRouteProperties:be,unstable_dataStrategy:t?.unstable_dataStrategy}).initialize()}export{fe as Await,se as MemoryRouter,ce as Navigate,de as Outlet,pe as Route,me as Router,ie as RouterProvider,he as Routes,v as UNSAFE_DataRouterContext,E as UNSAFE_DataRouterStateContext,x as UNSAFE_LocationContext,y as UNSAFE_NavigationContext,C as UNSAFE_RouteContext,be as UNSAFE_mapRouteProperties,Y as UNSAFE_useRouteId,j as UNSAFE_useRoutesImpl,Re as createMemoryRouter,xe as createRoutesFromChildren,xe as createRoutesFromElements,Ce as renderMatches,Z as useActionData,re as useAsyncError,te as useAsyncValue,ae as useBlocker,R as useHref,S as useInRouterContext,Q as useLoaderData,P as useLocation,_ as useMatch,K as useMatches,D as useNavigate,q as useNavigation,U as useNavigationType,F as useOutlet,N as useOutletContext,L as useParams,O as useResolvedPath,G as useRevalidator,ee as useRouteError,X as useRouteLoaderData,A as useRoutes};
//# sourceMappingURL=react-router.production.min.js.map
/**
* React Router v0.0.0-experimental-0f2dd78c
* React Router v0.0.0-experimental-0f302655
*

@@ -12,6 +12,6 @@ * Copyright (c) Remix Software Inc.

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@remix-run/router'), require('react')) :
typeof define === 'function' && define.amd ? define(['exports', '@remix-run/router', 'react'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactRouter = {}, global.RemixRouter, global.React));
})(this, (function (exports, router, React) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@remix-run/router')) :
typeof define === 'function' && define.amd ? define(['exports', 'react', '@remix-run/router'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactRouter = {}, global.React, global.RemixRouter));
})(this, (function (exports, React, router) { 'use strict';

@@ -38,194 +38,28 @@ function _interopNamespace(e) {

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
function isPolyfill(x, y) {
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
;
}
const is = typeof Object.is === "function" ? Object.is : isPolyfill; // Intentionally not using named imports because Rollup uses dynamic
// dispatch for CommonJS interop named imports.
const {
useState,
useEffect,
useLayoutEffect,
useDebugValue
} = React__namespace;
let didWarnOld18Alpha = false;
let didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
// because of a very particular set of implementation details and assumptions
// -- change any one of them and it will break. The most important assumption
// is that updates are always synchronous, because concurrent rendering is
// only available in versions of React that also have a built-in
// useSyncExternalStore API. And we only use this shim when the built-in API
// does not exist.
//
// Do not assume that the clever hacks used by this hook also work in general.
// The point of this shim is to replace the need for hacks by other libraries.
function useSyncExternalStore$2(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
// React do not expose a way to check if we're hydrating. So users of the shim
// will need to track that themselves and return the correct value
// from `getSnapshot`.
getServerSnapshot) {
{
if (!didWarnOld18Alpha) {
if ("startTransition" in React__namespace) {
didWarnOld18Alpha = true;
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.");
function _extends() {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
} // Read the current snapshot from the store on every render. Again, this
// breaks the rules of React, and only works here because of specific
// implementation details, most importantly that updates are
// always synchronous.
const value = getSnapshot();
{
if (!didWarnUncachedGetSnapshot) {
const cachedValue = getSnapshot();
if (!is(value, cachedValue)) {
console.error("The result of getSnapshot should be cached to avoid an infinite loop");
didWarnUncachedGetSnapshot = true;
}
}
} // Because updates are synchronous, we don't queue them. Instead we force a
// re-render whenever the subscribed state changes by updating an some
// arbitrary useState hook. Then, during render, we call getSnapshot to read
// the current value.
//
// Because we don't actually use the state returned by the useState hook, we
// can save a bit of memory by storing other stuff in that slot.
//
// To implement the early bailout, we need to track some things on a mutable
// object. Usually, we would put that in a useRef hook, but we can stash it in
// our useState hook instead.
//
// To force a re-render, we call forceUpdate({inst}). That works because the
// new object always fails an equality check.
const [{
inst
}, forceUpdate] = useState({
inst: {
value,
getSnapshot
}
}); // Track the latest getSnapshot function with a ref. This needs to be updated
// in the layout phase so we can access it during the tearing check that
// happens on subscribe.
useLayoutEffect(() => {
inst.value = value;
inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
// commit phase if there was an interleaved mutation. In concurrent mode
// this can happen all the time, but even in synchronous mode, an earlier
// effect may have mutated the store.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceUpdate({
inst
});
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [subscribe, value, getSnapshot]);
useEffect(() => {
// Check for changes right before subscribing. Subsequent changes will be
// detected in the subscription handler.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceUpdate({
inst
});
}
const handleStoreChange = () => {
// TODO: Because there is no cross-renderer API for batching updates, it's
// up to the consumer of this library to wrap their subscription event
// with unstable_batchedUpdates. Should we try to detect when this isn't
// the case and print a warning in development?
// The store changed. Check if the snapshot changed since the last time we
// read from the store.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceUpdate({
inst
});
}
}; // Subscribe to the store and return a clean-up function.
return subscribe(handleStoreChange); // eslint-disable-next-line react-hooks/exhaustive-deps
}, [subscribe]);
useDebugValue(value);
return value;
return target;
};
return _extends.apply(this, arguments);
}
function checkIfSnapshotChanged(inst) {
const latestGetSnapshot = inst.getSnapshot;
const prevValue = inst.value;
try {
const nextValue = latestGetSnapshot();
return !is(prevValue, nextValue);
} catch (error) {
return true;
}
}
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
// Note: The shim does not use getServerSnapshot, because pre-18 versions of
// React do not expose a way to check if we're hydrating. So users of the shim
// will need to track that themselves and return the correct value
// from `getSnapshot`.
return getSnapshot();
}
/**
* Inlined into the react-router repo since use-sync-external-store does not
* provide a UMD-compatible package, so we need this to be able to distribute
* UMD react-router bundles
*/
const canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
const isServerEnvironment = !canUseDOM;
const shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore$2;
const useSyncExternalStore = "useSyncExternalStore" in React__namespace ? (module => module.useSyncExternalStore)(React__namespace) : shim;
// Create react-specific types from the agnostic types in @remix-run/router to
// export from react-router
const DataRouterContext = /*#__PURE__*/React__namespace.createContext(null);
{
DataRouterContext.displayName = "DataRouter";
}
const DataRouterStateContext = /*#__PURE__*/React__namespace.createContext(null);
{
DataRouterStateContext.displayName = "DataRouterState";
}
const AwaitContext = /*#__PURE__*/React__namespace.createContext(null);
{

@@ -235,25 +69,29 @@ AwaitContext.displayName = "Await";

/**
* A Navigator is a "location changer"; it's how you get to different locations.
*
* Every history instance conforms to the Navigator interface, but the
* distinction is useful primarily when it comes to the low-level `<Router>` API
* where both the location and a navigator must be provided separately in order
* to avoid "tearing" that may occur in a suspense-enabled app if the action
* and/or location were to be read directly from the history instance.
*/
const NavigationContext = /*#__PURE__*/React__namespace.createContext(null);
{
NavigationContext.displayName = "Navigation";
}
const LocationContext = /*#__PURE__*/React__namespace.createContext(null);
{
LocationContext.displayName = "Location";
}
const RouteContext = /*#__PURE__*/React__namespace.createContext({
outlet: null,
matches: []
matches: [],
isDataRoute: false
});
{
RouteContext.displayName = "Route";
}
const RouteErrorContext = /*#__PURE__*/React__namespace.createContext(null);
{

@@ -263,19 +101,2 @@ RouteErrorContext.displayName = "RouteError";

function _extends() {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
/**

@@ -287,3 +108,2 @@ * Returns the full href for the given "to" value. This is useful for building

*/
function useHref(to, _temp) {

@@ -307,11 +127,11 @@ let {

});
let joinedPathname = pathname; // If we're operating within a basename, prepend it to the pathname prior
let joinedPathname = pathname;
// If we're operating within a basename, prepend it to the pathname prior
// to creating the href. If this is a root navigation, then just use the raw
// basename which allows the basename to have full control over the presence
// of a trailing slash on root links
if (basename !== "/") {
joinedPathname = pathname === "/" ? basename : router.joinPaths([basename, pathname]);
}
return navigator.createHref({

@@ -323,11 +143,12 @@ pathname: joinedPathname,

}
/**
* Returns true if this component is a descendant of a <Router>.
* Returns true if this component is a descendant of a `<Router>`.
*
* @see https://reactrouter.com/hooks/use-in-router-context
*/
function useInRouterContext() {
return React__namespace.useContext(LocationContext) != null;
}
/**

@@ -343,3 +164,2 @@ * Returns the current location object, which represents the current URL in web

*/
function useLocation() {

@@ -351,2 +171,3 @@ !useInRouterContext() ? router.UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the

}
/**

@@ -358,14 +179,13 @@ * Returns the current navigation action which describes how the router came to

*/
function useNavigationType() {
return React__namespace.useContext(LocationContext).navigationType;
}
/**
* Returns a PathMatch object if the given pattern matches the current URL.
* This is useful for components that need to know "active" state, e.g.
* <NavLink>.
* `<NavLink>`.
*
* @see https://reactrouter.com/hooks/use-match
*/
function useMatch(pattern) {

@@ -380,2 +200,3 @@ !useInRouterContext() ? router.UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the

}
/**

@@ -385,4 +206,17 @@ * The interface for the navigate() function returned from useNavigate().

const navigateEffectWarning = "You should call navigate() in a React.useEffect(), not when " + "your component is first rendered.";
// Mute warnings for calls to useNavigate in SSR environments
function useIsomorphicLayoutEffect(cb) {
let isStatic = React__namespace.useContext(NavigationContext).static;
if (!isStatic) {
// We should be able to get rid of this once react 18.3 is released
// See: https://github.com/facebook/react/pull/26395
// eslint-disable-next-line react-hooks/rules-of-hooks
React__namespace.useLayoutEffect(cb);
}
}
/**
* Returns an imperative method for changing the location. Used by <Link>s, but
* Returns an imperative method for changing the location. Used by `<Link>`s, but
* may also be used by other elements to change the location.

@@ -393,7 +227,17 @@ *

function useNavigate() {
let {
isDataRoute
} = React__namespace.useContext(RouteContext);
// Conditional usage is OK here because the usage of a data router is static
// eslint-disable-next-line react-hooks/rules-of-hooks
return isDataRoute ? useNavigateStable() : useNavigateUnstable();
}
function useNavigateUnstable() {
!useInRouterContext() ? router.UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
// router loaded. We can help them understand how to avoid that.
"useNavigate() may be used only in the context of a <Router> component.") : void 0;
let dataRouterContext = React__namespace.useContext(DataRouterContext);
let {
basename,
future,
navigator

@@ -407,5 +251,5 @@ } = React__namespace.useContext(NavigationContext);

} = useLocation();
let routePathnamesJson = JSON.stringify(router.UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase));
let routePathnamesJson = JSON.stringify(router.UNSAFE_getResolveToMatches(matches, future.v7_relativeSplatPath));
let activeRef = React__namespace.useRef(false);
React__namespace.useEffect(() => {
useIsomorphicLayoutEffect(() => {
activeRef.current = true;

@@ -417,6 +261,7 @@ });

}
router.UNSAFE_warning(activeRef.current, navigateEffectWarning) ;
router.UNSAFE_warning(activeRef.current, "You should call navigate() in a React.useEffect(), not when " + "your component is first rendered.") ;
// Short circuit here since if this happens on first render the navigate
// is useless because we haven't wired up our history listener yet
if (!activeRef.current) return;
if (typeof to === "number") {

@@ -426,17 +271,19 @@ navigator.go(to);

}
let path = router.resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path");
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
// to handing off to history. If this is a root navigation, then we
// navigate to the raw basename which allows the basename to have full
// control over the presence of a trailing slash on root links
if (basename !== "/") {
// If we're operating within a basename, prepend it to the pathname prior
// to handing off to history (but only if we're not in a data router,
// otherwise it'll prepend the basename inside of the router).
// If this is a root navigation, then we navigate to the raw basename
// which allows the basename to have full control over the presence of a
// trailing slash on root links
if (dataRouterContext == null && basename !== "/") {
path.pathname = path.pathname === "/" ? basename : router.joinPaths([basename, path.pathname]);
}
(!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
}, [basename, navigator, routePathnamesJson, locationPathname]);
}, [basename, navigator, routePathnamesJson, locationPathname, dataRouterContext]);
return navigate;
}
const OutletContext = /*#__PURE__*/React__namespace.createContext(null);
/**

@@ -447,16 +294,14 @@ * Returns the context (if provided) for the child route at this level of the route

*/
function useOutletContext() {
return React__namespace.useContext(OutletContext);
}
/**
* Returns the element for the child route at this level of the route
* hierarchy. Used internally by <Outlet> to render child routes.
* hierarchy. Used internally by `<Outlet>` to render child routes.
*
* @see https://reactrouter.com/hooks/use-outlet
*/
function useOutlet(context) {
let outlet = React__namespace.useContext(RouteContext).outlet;
if (outlet) {

@@ -467,5 +312,5 @@ return /*#__PURE__*/React__namespace.createElement(OutletContext.Provider, {

}
return outlet;
}
/**

@@ -477,3 +322,2 @@ * Returns an object of key/value pairs of the dynamic params from the current

*/
function useParams() {

@@ -486,2 +330,3 @@ let {

}
/**

@@ -492,3 +337,2 @@ * Resolves the pathname of the given `to` value against the current location.

*/
function useResolvedPath(to, _temp2) {

@@ -499,2 +343,5 @@ let {

let {
future
} = React__namespace.useContext(NavigationContext);
let {
matches

@@ -505,9 +352,10 @@ } = React__namespace.useContext(RouteContext);

} = useLocation();
let routePathnamesJson = JSON.stringify(router.UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase));
let routePathnamesJson = JSON.stringify(router.UNSAFE_getResolveToMatches(matches, future.v7_relativeSplatPath));
return React__namespace.useMemo(() => router.resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);
}
/**
* Returns the element of the route that matched the current location, prepared
* with the correct context to render the remainder of the route tree. Route
* elements in the tree must render an <Outlet> to render their child route's
* elements in the tree must render an `<Outlet>` to render their child route's
* element.

@@ -517,4 +365,8 @@ *

*/
function useRoutes(routes, locationArg) {
return useRoutesImpl(routes, locationArg);
}
function useRoutes(routes, locationArg) {
// Internal implementation with accept optional param for RouterProvider usage
function useRoutesImpl(routes, locationArg, dataRouterState, future) {
!useInRouterContext() ? router.UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the

@@ -526,3 +378,2 @@ // router loaded. We can help them understand how to avoid that.

} = React__namespace.useContext(NavigationContext);
let dataRouterStateContext = React__namespace.useContext(DataRouterStateContext);
let {

@@ -536,3 +387,2 @@ matches: parentMatches

let parentRoute = routeMatch && routeMatch.route;
{

@@ -562,9 +412,6 @@ // You won't get a warning about 2 different <Routes> under a <Route>

}
let locationFromContext = useLocation();
let location;
if (locationArg) {
var _parsedLocationArg$pa;
let parsedLocationArg = typeof locationArg === "string" ? router.parsePath(locationArg) : locationArg;

@@ -576,25 +423,43 @@ !(parentPathnameBase === "/" || ((_parsedLocationArg$pa = parsedLocationArg.pathname) == null ? void 0 : _parsedLocationArg$pa.startsWith(parentPathnameBase))) ? router.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.")) : void 0;

}
let pathname = location.pathname || "/";
let remainingPathname = parentPathnameBase === "/" ? pathname : pathname.slice(parentPathnameBase.length) || "/";
let remainingPathname = pathname;
if (parentPathnameBase !== "/") {
// Determine the remaining pathname by removing the # of URL segments the
// parentPathnameBase has, instead of removing based on character count.
// This is because we can't guarantee that incoming/outgoing encodings/
// decodings will match exactly.
// We decode paths before matching on a per-segment basis with
// decodeURIComponent(), but we re-encode pathnames via `new URL()` so they
// match what `window.location.pathname` would reflect. Those don't 100%
// align when it comes to encoded URI characters such as % and &.
//
// So we may end up with:
// pathname: "/descendant/a%25b/match"
// parentPathnameBase: "/descendant/a%b"
//
// And the direct substring removal approach won't work :/
let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
let segments = pathname.replace(/^\//, "").split("/");
remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
}
let matches = router.matchRoutes(routes, {
pathname: remainingPathname
});
{
router.UNSAFE_warning(parentRoute || matches != null, "No routes matched location \"" + location.pathname + location.search + location.hash + "\" ") ;
router.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.") ;
router.UNSAFE_warning(matches == null || matches[matches.length - 1].route.element !== undefined || matches[matches.length - 1].route.Component !== undefined || matches[matches.length - 1].route.lazy !== 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.") ;
}
let renderedMatches = _renderMatches(matches && matches.map(match => Object.assign({}, match, {
params: Object.assign({}, parentParams, match.params),
pathname: router.joinPaths([parentPathnameBase, // Re-encode pathnames that were decoded inside matchRoutes
pathname: router.joinPaths([parentPathnameBase,
// Re-encode pathnames that were decoded inside matchRoutes
navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname]),
pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : router.joinPaths([parentPathnameBase, // Re-encode pathnames that were decoded inside matchRoutes
pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : router.joinPaths([parentPathnameBase,
// Re-encode pathnames that were decoded inside matchRoutes
navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase])
})), parentMatches, dataRouterStateContext || undefined); // When a user passes in a `locationArg`, the associated routes need to
})), parentMatches, dataRouterState, future);
// When a user passes in a `locationArg`, the associated routes need to
// be wrapped in a new `LocationContext.Provider` in order for `useLocation`
// to use the scoped location instead of the global location.
if (locationArg && renderedMatches) {

@@ -614,6 +479,4 @@ return /*#__PURE__*/React__namespace.createElement(LocationContext.Provider, {

}
return renderedMatches;
}
function DefaultErrorComponent() {

@@ -633,11 +496,10 @@ let error = useRouteError();

let devInfo = null;
{
devInfo = /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, 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", {
console.error("Error handled by React Router default ErrorBoundary:", error);
devInfo = /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, 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 ", /*#__PURE__*/React__namespace.createElement("code", {
style: codeStyles
}, "ErrorBoundary"), " prop on\xA0", /*#__PURE__*/React__namespace.createElement("code", {
}, "ErrorBoundary"), " or", " ", /*#__PURE__*/React__namespace.createElement("code", {
style: codeStyles
}, "<Route>")));
}, "errorElement"), " prop on your route."));
}
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement("h2", null, "Unexpected Application Error!"), /*#__PURE__*/React__namespace.createElement("h3", {

@@ -651,3 +513,3 @@ style: {

}
const defaultErrorElement = /*#__PURE__*/React__namespace.createElement(DefaultErrorComponent, null);
class RenderErrorBoundary extends React__namespace.Component {

@@ -658,6 +520,6 @@ constructor(props) {

location: props.location,
revalidation: props.revalidation,
error: props.error
};
}
static getDerivedStateFromError(error) {

@@ -668,3 +530,2 @@ return {

}
static getDerivedStateFromProps(props, state) {

@@ -679,25 +540,25 @@ // When we get into an error state, the user will likely click "back" to the

// comes in and the user recovers from the error.
if (state.location !== props.location) {
if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
return {
error: props.error,
location: props.location
location: props.location,
revalidation: props.revalidation
};
} // If we're not changing locations, preserve the location but still surface
}
// If we're not changing locations, preserve the location but still surface
// any new errors that may come through. We retain the existing error, we do
// this because the error provided from the app state may be cleared without
// the location changing.
return {
error: props.error || state.error,
location: state.location
error: props.error !== undefined ? props.error : state.error,
location: state.location,
revalidation: props.revalidation || state.revalidation
};
}
componentDidCatch(error, errorInfo) {
console.error("React Router caught the following error during render", error, errorInfo);
}
render() {
return this.state.error ? /*#__PURE__*/React__namespace.createElement(RouteContext.Provider, {
return this.state.error !== undefined ? /*#__PURE__*/React__namespace.createElement(RouteContext.Provider, {
value: this.props.routeContext

@@ -709,5 +570,3 @@ }, /*#__PURE__*/React__namespace.createElement(RouteErrorContext.Provider, {

}
}
function RenderedRoute(_ref) {

@@ -719,9 +578,9 @@ let {

} = _ref;
let dataRouterContext = React__namespace.useContext(DataRouterContext); // Track how deep we got in our render pass to emulate SSR componentDidCatch
let dataRouterContext = React__namespace.useContext(DataRouterContext);
// Track how deep we got in our render pass to emulate SSR componentDidCatch
// in a DataStaticRouter
if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
}
return /*#__PURE__*/React__namespace.createElement(RouteContext.Provider, {

@@ -731,10 +590,16 @@ value: routeContext

}
function _renderMatches(matches, parentMatches, dataRouterState) {
function _renderMatches(matches, parentMatches, dataRouterState, future) {
var _dataRouterState2;
if (parentMatches === void 0) {
parentMatches = [];
}
if (dataRouterState === void 0) {
dataRouterState = null;
}
if (future === void 0) {
future = null;
}
if (matches == null) {
if (dataRouterState != null && dataRouterState.errors) {
var _dataRouterState;
if ((_dataRouterState = dataRouterState) != null && _dataRouterState.errors) {
// Don't bail if we have data router errors so we can render them in the

@@ -747,41 +612,84 @@ // boundary. Use the pre-matched (or shimmed) matches

}
let renderedMatches = matches;
let renderedMatches = matches; // If we have data errors, trim matches to the highest error boundary
let errors = dataRouterState == null ? void 0 : dataRouterState.errors;
// If we have data errors, trim matches to the highest error boundary
let errors = (_dataRouterState2 = dataRouterState) == null ? void 0 : _dataRouterState2.errors;
if (errors != null) {
let errorIndex = renderedMatches.findIndex(m => m.route.id && (errors == null ? void 0 : errors[m.route.id]));
!(errorIndex >= 0) ? router.UNSAFE_invariant(false, "Could not find a matching route for the current errors: " + errors) : void 0;
let errorIndex = renderedMatches.findIndex(m => m.route.id && (errors == null ? void 0 : errors[m.route.id]) !== undefined);
!(errorIndex >= 0) ? router.UNSAFE_invariant(false, "Could not find a matching route for errors on route IDs: " + Object.keys(errors).join(",")) : void 0;
renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
}
// If we're in a partial hydration mode, detect if we need to render down to
// a given HydrateFallback while we load the rest of the hydration data
let renderFallback = false;
let fallbackIndex = -1;
if (dataRouterState && future && future.v7_partialHydration) {
for (let i = 0; i < renderedMatches.length; i++) {
let match = renderedMatches[i];
// Track the deepest fallback up until the first route without data
if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
fallbackIndex = i;
}
if (match.route.id) {
let {
loaderData,
errors
} = dataRouterState;
let needsToRunLoader = match.route.loader && loaderData[match.route.id] === undefined && (!errors || errors[match.route.id] === undefined);
if (match.route.lazy || needsToRunLoader) {
// We found the first route that's not ready to render (waiting on
// lazy, or has a loader that hasn't run yet). Flag that we need to
// render a fallback and render up until the appropriate fallback
renderFallback = true;
if (fallbackIndex >= 0) {
renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
} else {
renderedMatches = [renderedMatches[0]];
}
break;
}
}
}
}
return renderedMatches.reduceRight((outlet, match, index) => {
let error = match.route.id ? errors == null ? void 0 : errors[match.route.id] : null; // Only data routers handle errors
// Only data routers handle errors/fallbacks
let error;
let shouldRenderHydrateFallback = false;
let errorElement = null;
let hydrateFallbackElement = null;
if (dataRouterState) {
if (match.route.ErrorBoundary) {
errorElement = /*#__PURE__*/React__namespace.createElement(match.route.ErrorBoundary, null);
} else if (match.route.errorElement) {
errorElement = match.route.errorElement;
} else {
errorElement = /*#__PURE__*/React__namespace.createElement(DefaultErrorComponent, null);
error = errors && match.route.id ? errors[match.route.id] : undefined;
errorElement = match.route.errorElement || defaultErrorElement;
if (renderFallback) {
if (fallbackIndex < 0 && index === 0) {
warningOnce("route-fallback", false, "No `HydrateFallback` element provided to render during initial hydration");
shouldRenderHydrateFallback = true;
hydrateFallbackElement = null;
} else if (fallbackIndex === index) {
shouldRenderHydrateFallback = true;
hydrateFallbackElement = match.route.hydrateFallbackElement || null;
}
}
}
let matches = parentMatches.concat(renderedMatches.slice(0, index + 1));
let getChildren = () => {
let children = outlet;
let children;
if (error) {
children = errorElement;
} else if (shouldRenderHydrateFallback) {
children = hydrateFallbackElement;
} else if (match.route.Component) {
// Note: This is a de-optimized path since React won't re-use the
// ReactElement since it's identity changes with each new
// React.createElement call. We keep this so folks can use
// `<Route Component={...}>` in `<Routes>` but generally `Component`
// usage is only advised in `RouterProvider` when we can convert it to
// `element` ahead of time.
children = /*#__PURE__*/React__namespace.createElement(match.route.Component, null);
} else if (match.route.element) {
children = match.route.element;
} else {
children = outlet;
}
return /*#__PURE__*/React__namespace.createElement(RenderedRoute, {

@@ -791,13 +699,14 @@ match: match,

outlet,
matches
matches,
isDataRoute: dataRouterState != null
},
children: children
});
}; // Only wrap in an error boundary within data router usages when we have an
};
// Only wrap in an error boundary within data router usages when we have an
// ErrorBoundary/errorElement on this route. Otherwise let it bubble up to
// an ancestor ErrorBoundary/errorElement
return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /*#__PURE__*/React__namespace.createElement(RenderErrorBoundary, {
location: dataRouterState.location,
revalidation: dataRouterState.revalidation,
component: errorElement,

@@ -808,3 +717,4 @@ error: error,

outlet: null,
matches
matches,
isDataRoute: true
}

@@ -814,12 +724,9 @@ }) : getChildren();

}
var DataRouterHook;
(function (DataRouterHook) {
var DataRouterHook = /*#__PURE__*/function (DataRouterHook) {
DataRouterHook["UseBlocker"] = "useBlocker";
DataRouterHook["UseRevalidator"] = "useRevalidator";
})(DataRouterHook || (DataRouterHook = {}));
var DataRouterStateHook;
(function (DataRouterStateHook) {
DataRouterHook["UseNavigateStable"] = "useNavigate";
return DataRouterHook;
}(DataRouterHook || {});
var DataRouterStateHook = /*#__PURE__*/function (DataRouterStateHook) {
DataRouterStateHook["UseBlocker"] = "useBlocker";

@@ -833,8 +740,9 @@ DataRouterStateHook["UseLoaderData"] = "useLoaderData";

DataRouterStateHook["UseRevalidator"] = "useRevalidator";
})(DataRouterStateHook || (DataRouterStateHook = {}));
DataRouterStateHook["UseNavigateStable"] = "useNavigate";
DataRouterStateHook["UseRouteId"] = "useRouteId";
return DataRouterStateHook;
}(DataRouterStateHook || {});
function getDataRouterConsoleError(hookName) {
return hookName + " must be used within a data router. See https://reactrouter.com/routers/picking-a-router.";
}
function useDataRouterContext(hookName) {

@@ -845,3 +753,2 @@ let ctx = React__namespace.useContext(DataRouterContext);

}
function useDataRouterState(hookName) {

@@ -852,3 +759,2 @@ let state = React__namespace.useContext(DataRouterStateContext);

}
function useRouteContext(hookName) {

@@ -860,2 +766,3 @@ let route = React__namespace.useContext(RouteContext);

// Internal version with hookName-aware debugging
function useCurrentRouteId(hookName) {

@@ -867,8 +774,14 @@ let route = useRouteContext(hookName);

}
/**
* Returns the ID for the nearest contextual route
*/
function useRouteId() {
return useCurrentRouteId(DataRouterStateHook.UseRouteId);
}
/**
* Returns the current navigation, defaulting to an "idle" navigation when
* no navigation is in progress
*/
function useNavigation() {

@@ -878,2 +791,3 @@ let state = useDataRouterState(DataRouterStateHook.UseNavigation);

}
/**

@@ -883,11 +797,11 @@ * Returns a revalidate function for manually triggering revalidation, as well

*/
function useRevalidator() {
let dataRouterContext = useDataRouterContext(DataRouterHook.UseRevalidator);
let state = useDataRouterState(DataRouterStateHook.UseRevalidator);
return {
return React__namespace.useMemo(() => ({
revalidate: dataRouterContext.router.revalidate,
state: state.revalidation
};
}), [dataRouterContext.router.revalidate, state.revalidation]);
}
/**

@@ -897,3 +811,2 @@ * Returns the active route matches, useful for accessing loaderData for

*/
function useMatches() {

@@ -904,27 +817,11 @@ let {

} = useDataRouterState(DataRouterStateHook.UseMatches);
return React__namespace.useMemo(() => matches.map(match => {
let {
pathname,
params
} = match; // Note: This structure matches that created by createUseMatchesMatch
// in the @remix-run/router , so if you change this please also change
// that :) Eventually we'll DRY this up
return React__namespace.useMemo(() => matches.map(m => router.UNSAFE_convertRouteMatchToUiMatch(m, loaderData)), [matches, loaderData]);
}
return {
id: match.route.id,
pathname,
params,
data: loaderData[match.route.id],
handle: match.route.handle
};
}), [matches, loaderData]);
}
/**
* Returns the loader data for the nearest ancestor Route loader
*/
function useLoaderData() {
let state = useDataRouterState(DataRouterStateHook.UseLoaderData);
let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData);
if (state.errors && state.errors[routeId] != null) {

@@ -934,9 +831,8 @@ console.error("You cannot `useLoaderData` in an errorElement (routeId: " + routeId + ")");

}
return state.loaderData[routeId];
}
/**
* Returns the loaderData for the given routeId
*/
function useRouteLoaderData(routeId) {

@@ -946,12 +842,12 @@ let state = useDataRouterState(DataRouterStateHook.UseRouteLoaderData);

}
/**
* Returns the action data for the nearest ancestor Route action
*/
function useActionData() {
let state = useDataRouterState(DataRouterStateHook.UseActionData);
let route = React__namespace.useContext(RouteContext);
!route ? router.UNSAFE_invariant(false, "useActionData must be used inside a RouteContext") : void 0;
return Object.values((state == null ? void 0 : state.actionData) || {})[0];
let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData);
return state.actionData ? state.actionData[routeId] : undefined;
}
/**

@@ -962,22 +858,21 @@ * Returns the nearest ancestor Route error, which could be a loader/action

*/
function useRouteError() {
var _state$errors;
let error = React__namespace.useContext(RouteErrorContext);
let state = useDataRouterState(DataRouterStateHook.UseRouteError);
let routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError); // If this was a render error, we put it in a RouteError context inside
let routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError);
// If this was a render error, we put it in a RouteError context inside
// of RenderErrorBoundary
if (error) {
if (error !== undefined) {
return error;
} // Otherwise look for errors from our data router state
}
// Otherwise look for errors from our data router state
return (_state$errors = state.errors) == null ? void 0 : _state$errors[routeId];
}
/**
* Returns the happy-path data from the nearest ancestor <Await /> value
* Returns the happy-path data from the nearest ancestor `<Await />` value
*/
function useAsyncValue() {

@@ -987,6 +882,6 @@ let value = React__namespace.useContext(AwaitContext);

}
/**
* Returns the error from the nearest ancestor <Await /> value
* Returns the error from the nearest ancestor `<Await />` value
*/
function useAsyncError() {

@@ -997,2 +892,3 @@ let value = React__namespace.useContext(AwaitContext);

let blockerId = 0;
/**

@@ -1004,21 +900,92 @@ * Allow the application to block navigations within the SPA and present the

*/
function useBlocker(shouldBlock) {
let {
router
router: router$1,
basename
} = useDataRouterContext(DataRouterHook.UseBlocker);
let state = useDataRouterState(DataRouterStateHook.UseBlocker);
let [blockerKey] = React__namespace.useState(() => String(++blockerId));
let blockerFunction = React__namespace.useCallback(args => {
return typeof shouldBlock === "function" ? !!shouldBlock(args) : !!shouldBlock;
}, [shouldBlock]);
let blocker = router.getBlocker(blockerKey, blockerFunction); // Cleanup on unmount
let [blockerKey, setBlockerKey] = React__namespace.useState("");
let blockerFunction = React__namespace.useCallback(arg => {
if (typeof shouldBlock !== "function") {
return !!shouldBlock;
}
if (basename === "/") {
return shouldBlock(arg);
}
React__namespace.useEffect(() => () => router.deleteBlocker(blockerKey), [router, blockerKey]); // Prefer the blocker from state since DataRouterContext is memoized so this
// ensures we update on blocker state updates
// If they provided us a function and we've got an active basename, strip
// it from the locations we expose to the user to match the behavior of
// useLocation
let {
currentLocation,
nextLocation,
historyAction
} = arg;
return shouldBlock({
currentLocation: _extends({}, currentLocation, {
pathname: router.stripBasename(currentLocation.pathname, basename) || currentLocation.pathname
}),
nextLocation: _extends({}, nextLocation, {
pathname: router.stripBasename(nextLocation.pathname, basename) || nextLocation.pathname
}),
historyAction
});
}, [basename, shouldBlock]);
return state.blockers.get(blockerKey) || blocker;
// This effect is in charge of blocker key assignment and deletion (which is
// tightly coupled to the key)
React__namespace.useEffect(() => {
let key = String(++blockerId);
setBlockerKey(key);
return () => router$1.deleteBlocker(key);
}, [router$1]);
// This effect handles assigning the blockerFunction. This is to handle
// unstable blocker function identities, and happens only after the prior
// effect so we don't get an orphaned blockerFunction in the router with a
// key of "". Until then we just have the IDLE_BLOCKER.
React__namespace.useEffect(() => {
if (blockerKey !== "") {
router$1.getBlocker(blockerKey, blockerFunction);
}
}, [router$1, blockerKey, blockerFunction]);
// Prefer the blocker from `state` not `router.state` since DataRouterContext
// is memoized so this ensures we update on blocker state updates
return blockerKey && state.blockers.has(blockerKey) ? state.blockers.get(blockerKey) : router.IDLE_BLOCKER;
}
/**
* Stable version of useNavigate that is used when we are in the context of
* a RouterProvider.
*/
function useNavigateStable() {
let {
router: router$1
} = useDataRouterContext(DataRouterHook.UseNavigateStable);
let id = useCurrentRouteId(DataRouterStateHook.UseNavigateStable);
let activeRef = React__namespace.useRef(false);
useIsomorphicLayoutEffect(() => {
activeRef.current = true;
});
let navigate = React__namespace.useCallback(function (to, options) {
if (options === void 0) {
options = {};
}
router.UNSAFE_warning(activeRef.current, navigateEffectWarning) ;
// Short circuit here since if this happens on first render the navigate
// is useless because we haven't wired up our router subscriber yet
if (!activeRef.current) return;
if (typeof to === "number") {
router$1.navigate(to);
} else {
router$1.navigate(to, _extends({
fromRouteId: id
}, options));
}
}, [router$1, id]);
return navigate;
}
const alreadyWarned = {};
function warningOnce(key, cond, message) {

@@ -1032,2 +999,26 @@ if (!cond && !alreadyWarned[key]) {

/**
Webpack + React 17 fails to compile on any of the following because webpack
complains that `startTransition` doesn't exist in `React`:
* import { startTransition } from "react"
* import * as React from from "react";
"startTransition" in React ? React.startTransition(() => setState()) : setState()
* import * as React from from "react";
"startTransition" in React ? React["startTransition"](() => setState()) : setState()
Moving it to a constant such as the following solves the Webpack/React 17 issue:
* import * as React from from "react";
const START_TRANSITION = "startTransition";
START_TRANSITION in React ? React[START_TRANSITION](() => setState()) : setState()
However, that introduces webpack/terser minification issues in production builds
in React 18 where minification/obfuscation ends up removing the call of
React.startTransition entirely from the first half of the ternary. Grabbing
this exported reference once up front resolves that issue.
See https://github.com/remix-run/react-router/issues/10579
*/
const START_TRANSITION = "startTransition";
const startTransitionImpl = React__namespace[START_TRANSITION];
/**
* Given a Remix Router instance, render the appropriate UI

@@ -1038,20 +1029,35 @@ */

fallbackElement,
router
router: router$1,
future
} = _ref;
let getState = React__namespace.useCallback(() => router.state, [router]); // Sync router state to our component state to force re-renders
let [state, setStateImpl] = React__namespace.useState(router$1.state);
let {
v7_startTransition
} = future || {};
let setState = React__namespace.useCallback(newState => {
if (v7_startTransition && startTransitionImpl) {
startTransitionImpl(() => setStateImpl(newState));
} else {
setStateImpl(newState);
}
}, [setStateImpl, v7_startTransition]);
let state = useSyncExternalStore(router.subscribe, getState, // We have to provide this so React@18 doesn't complain during hydration,
// but we pass our serialized hydration data into the router so state here
// is already synced with what the server saw
getState);
// Need to use a layout effect here so we are subscribed early enough to
// pick up on any render-driven redirects/navigations (useEffect/<Navigate>)
React__namespace.useLayoutEffect(() => router$1.subscribe(setState), [router$1, setState]);
React__namespace.useEffect(() => {
router.UNSAFE_warning(fallbackElement == null || !router$1.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using " + "`v7_partialHydration`, use a `HydrateFallback` component instead") ;
// Only log this once on initial mount
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
let navigator = React__namespace.useMemo(() => {
return {
createHref: router.createHref,
encodeLocation: router.encodeLocation,
go: n => router.navigate(n),
push: (to, state, opts) => router.navigate(to, {
createHref: router$1.createHref,
encodeLocation: router$1.encodeLocation,
go: n => router$1.navigate(n),
push: (to, state, opts) => router$1.navigate(to, {
state,
preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
}),
replace: (to, state, opts) => router.navigate(to, {
replace: (to, state, opts) => router$1.navigate(to, {
replace: true,

@@ -1062,10 +1068,12 @@ state,

};
}, [router]);
let basename = router.basename || "/";
}, [router$1]);
let basename = router$1.basename || "/";
let dataRouterContext = React__namespace.useMemo(() => ({
router,
router: router$1,
navigator,
static: false,
basename
}), [router, navigator, basename]); // The fragment and {null} here are important! We need them to keep React 18's
}), [router$1, navigator, basename]);
// The fragment and {null} here are important! We need them to keep React 18's
// useId happy when we are server-rendering since we may have a <script> here

@@ -1076,3 +1084,2 @@ // containing the hydrated server-side staticContext (from StaticRouterProvider).

// we don't need the <script> tag
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(DataRouterContext.Provider, {

@@ -1083,15 +1090,29 @@ value: dataRouterContext

}, /*#__PURE__*/React__namespace.createElement(Router, {
basename: router.basename,
location: router.state.location,
navigationType: router.state.historyAction,
navigator: navigator
}, router.state.initialized ? /*#__PURE__*/React__namespace.createElement(Routes, null) : fallbackElement))), null);
basename: basename,
location: state.location,
navigationType: state.historyAction,
navigator: navigator,
future: {
v7_relativeSplatPath: router$1.future.v7_relativeSplatPath
}
}, state.initialized || router$1.future.v7_partialHydration ? /*#__PURE__*/React__namespace.createElement(DataRoutes, {
routes: router$1.routes,
future: router$1.future,
state: state
}) : fallbackElement))), null);
}
function DataRoutes(_ref2) {
let {
routes,
future,
state
} = _ref2;
return useRoutesImpl(routes, undefined, state, future);
}
/**
* A <Router> that stores all entries in memory.
* A `<Router>` that stores all entries in memory.
*
* @see https://reactrouter.com/router-components/memory-router
*/
function MemoryRouter(_ref2) {
function MemoryRouter(_ref3) {
let {

@@ -1101,6 +1122,6 @@ basename,

initialEntries,
initialIndex
} = _ref2;
initialIndex,
future
} = _ref3;
let historyRef = React__namespace.useRef();
if (historyRef.current == null) {

@@ -1113,9 +1134,14 @@ historyRef.current = router.createMemoryHistory({

}
let history = historyRef.current;
let [state, setState] = React__namespace.useState({
let [state, setStateImpl] = React__namespace.useState({
action: history.action,
location: history.location
});
React__namespace.useLayoutEffect(() => history.listen(setState), [history]);
let {
v7_startTransition
} = future || {};
let setState = React__namespace.useCallback(newState => {
v7_startTransition && startTransitionImpl ? startTransitionImpl(() => setStateImpl(newState)) : setStateImpl(newState);
}, [setStateImpl, v7_startTransition]);
React__namespace.useLayoutEffect(() => history.listen(setState), [history, setState]);
return /*#__PURE__*/React__namespace.createElement(Router, {

@@ -1126,6 +1152,6 @@ basename: basename,

navigationType: state.action,
navigator: history
navigator: history,
future: future
});
}
/**

@@ -1140,3 +1166,3 @@ * Changes the current location.

*/
function Navigate(_ref3) {
function Navigate(_ref4) {
let {

@@ -1147,26 +1173,30 @@ to,

relative
} = _ref3;
} = _ref4;
!useInRouterContext() ? router.UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of
// the router loaded. We can help them understand how to avoid that.
"<Navigate> may be used only in the context of a <Router> component.") : void 0;
router.UNSAFE_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.") ;
let dataRouterState = React__namespace.useContext(DataRouterStateContext);
let {
future,
static: isStatic
} = React__namespace.useContext(NavigationContext);
router.UNSAFE_warning(!isStatic, "<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.") ;
let {
matches
} = React__namespace.useContext(RouteContext);
let {
pathname: locationPathname
} = useLocation();
let navigate = useNavigate();
React__namespace.useEffect(() => {
// Avoid kicking off multiple navigations if we're in the middle of a
// data-router navigation, since components get re-rendered when we enter
// a submitting/loading state
if (dataRouterState && dataRouterState.navigation.state !== "idle") {
return;
}
navigate(to, {
replace,
state,
relative
});
});
// Resolve the path outside of the effect so that when effects run twice in
// StrictMode they navigate to the same place
let path = router.resolveTo(to, router.UNSAFE_getResolveToMatches(matches, future.v7_relativeSplatPath), locationPathname, relative === "path");
let jsonPath = JSON.stringify(path);
React__namespace.useEffect(() => navigate(JSON.parse(jsonPath), {
replace,
state,
relative
}), [navigate, jsonPath, relative, replace, state]);
return null;
}
/**

@@ -1180,3 +1210,2 @@ * Renders the child route's element, if there is one.

}
/**

@@ -1190,13 +1219,12 @@ * Declares an element that should be rendered at a certain URL path.

}
/**
* Provides location context for the rest of the app.
*
* Note: You usually won't render a <Router> directly. Instead, you'll render a
* router that is more specific to your environment such as a <BrowserRouter>
* in web browsers or a <StaticRouter> for server rendering.
* Note: You usually won't render a `<Router>` directly. Instead, you'll render a
* router that is more specific to your environment such as a `<BrowserRouter>`
* in web browsers or a `<StaticRouter>` for server rendering.
*
* @see https://reactrouter.com/router-components/router
*/
function Router(_ref4) {
function Router(_ref5) {
let {

@@ -1208,7 +1236,9 @@ basename: basenameProp = "/",

navigator,
static: staticProp = false
} = _ref4;
!!useInRouterContext() ? router.UNSAFE_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
static: staticProp = false,
future
} = _ref5;
!!useInRouterContext() ? router.UNSAFE_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
// the enforcement of trailing slashes throughout the app
let basename = basenameProp.replace(/^\/*/, "/");

@@ -1218,9 +1248,10 @@ let navigationContext = React__namespace.useMemo(() => ({

navigator,
static: staticProp
}), [basename, navigator, staticProp]);
static: staticProp,
future: _extends({
v7_relativeSplatPath: false
}, future)
}), [basename, future, navigator, staticProp]);
if (typeof locationProp === "string") {
locationProp = router.parsePath(locationProp);
}
let {

@@ -1235,7 +1266,5 @@ pathname = "/",

let trailingPathname = router.stripBasename(pathname, basename);
if (trailingPathname == null) {
return null;
}
return {

@@ -1253,7 +1282,5 @@ location: {

router.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.") ;
if (locationContext == null) {
return null;
}
return /*#__PURE__*/React__namespace.createElement(NavigationContext.Provider, {

@@ -1266,5 +1293,4 @@ value: navigationContext

}
/**
* A container for a nested tree of <Route> elements that renders the branch
* A container for a nested tree of `<Route>` elements that renders the branch
* that best matches the current location.

@@ -1274,15 +1300,9 @@ *

*/
function Routes(_ref5) {
function Routes(_ref6) {
let {
children,
location
} = _ref5;
let dataRouterContext = React__namespace.useContext(DataRouterContext); // When in a DataRouterContext _without_ children, we use the router routes
// directly. If we have children, then we're in a descendant tree and we
// need to use child routes.
let routes = dataRouterContext && !children ? dataRouterContext.router.routes : createRoutesFromChildren(children);
return useRoutes(routes, location);
} = _ref6;
return useRoutes(createRoutesFromChildren(children), location);
}
/**

@@ -1292,3 +1312,3 @@ * Component to use for rendering lazily loaded data from returning defer()

*/
function Await(_ref6) {
function Await(_ref7) {
let {

@@ -1298,3 +1318,3 @@ children,

resolve
} = _ref6;
} = _ref7;
return /*#__PURE__*/React__namespace.createElement(AwaitErrorBoundary, {

@@ -1305,12 +1325,9 @@ resolve: resolve,

}
var AwaitRenderStatus;
(function (AwaitRenderStatus) {
var AwaitRenderStatus = /*#__PURE__*/function (AwaitRenderStatus) {
AwaitRenderStatus[AwaitRenderStatus["pending"] = 0] = "pending";
AwaitRenderStatus[AwaitRenderStatus["success"] = 1] = "success";
AwaitRenderStatus[AwaitRenderStatus["error"] = 2] = "error";
})(AwaitRenderStatus || (AwaitRenderStatus = {}));
return AwaitRenderStatus;
}(AwaitRenderStatus || {});
const neverSettledPromise = new Promise(() => {});
class AwaitErrorBoundary extends React__namespace.Component {

@@ -1323,3 +1340,2 @@ constructor(props) {

}
static getDerivedStateFromError(error) {

@@ -1330,7 +1346,5 @@ return {

}
componentDidCatch(error, errorInfo) {
console.error("<Await> caught the following error during render", error, errorInfo);
}
render() {

@@ -1344,3 +1358,2 @@ let {

let status = AwaitRenderStatus.pending;
if (!(resolve instanceof Promise)) {

@@ -1361,3 +1374,2 @@ // Didn't get a promise - provide as a resolved promise

promise = Promise.reject().catch(() => {}); // Avoid unhandled rejection warnings
Object.defineProperty(promise, "_tracked", {

@@ -1385,3 +1397,2 @@ get: () => true

}
if (status === AwaitRenderStatus.error && promise._error instanceof router.AbortedDeferredError) {

@@ -1391,3 +1402,2 @@ // Freeze the UI by throwing a never resolved promise

}
if (status === AwaitRenderStatus.error && !errorElement) {

@@ -1397,3 +1407,2 @@ // No errorElement, throw to the nearest route-level error boundary

}
if (status === AwaitRenderStatus.error) {

@@ -1406,3 +1415,2 @@ // Render via our errorElement

}
if (status === AwaitRenderStatus.success) {

@@ -1414,23 +1422,23 @@ // Render children with resolved value

});
} // Throw to the suspense boundary
}
// Throw to the suspense boundary
throw promise;
}
}
}
/**
* @private
* Indirection to leverage useAsyncValue for a render-prop API on <Await>
* Indirection to leverage useAsyncValue for a render-prop API on `<Await>`
*/
function ResolveAwait(_ref7) {
function ResolveAwait(_ref8) {
let {
children
} = _ref7;
} = _ref8;
let data = useAsyncValue();
let toRender = typeof children === "function" ? children(data) : children;
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, toRender);
} ///////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////
// UTILS

@@ -1446,4 +1454,2 @@ ///////////////////////////////////////////////////////////////////////////////

*/
function createRoutesFromChildren(children, parentPath) {

@@ -1453,3 +1459,2 @@ if (parentPath === void 0) {

}
let routes = [];

@@ -1462,5 +1467,3 @@ React__namespace.Children.forEach(children, (element, index) => {

}
let treePath = [...parentPath, index];
if (element.type === React__namespace.Fragment) {

@@ -1471,3 +1474,2 @@ // Transparently support React.Fragment and its children.

}
!(element.type === Route) ? router.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>") : void 0;

@@ -1491,7 +1493,5 @@ !(!element.props.index || !element.props.children) ? router.UNSAFE_invariant(false, "An index route cannot have child routes.") : void 0;

};
if (element.props.children) {
route.children = createRoutesFromChildren(element.props.children, treePath);
}
routes.push(route);

@@ -1501,6 +1501,6 @@ });

}
/**
* Renders the result of `matchRoutes()` into a React element.
*/
function renderMatches(matches) {

@@ -1510,22 +1510,49 @@ return _renderMatches(matches);

function detectErrorBoundary(route) {
{
if (route.Component && route.element) {
router.UNSAFE_warning(false, "You should not include both `Component` and `element` on your route - " + "`element` will be ignored.") ;
function mapRouteProperties(route) {
let updates = {
// Note: this check also occurs in createRoutesFromChildren so update
// there if you change this -- please and thank you!
hasErrorBoundary: route.ErrorBoundary != null || route.errorElement != null
};
if (route.Component) {
{
if (route.element) {
router.UNSAFE_warning(false, "You should not include both `Component` and `element` on your route - " + "`Component` will be used.") ;
}
}
if (route.ErrorBoundary && route.errorElement) {
router.UNSAFE_warning(false, "You should not include both `ErrorBoundary` and `errorElement` on your route - " + "`errorElement` will be ignored.") ;
Object.assign(updates, {
element: /*#__PURE__*/React__namespace.createElement(route.Component),
Component: undefined
});
}
if (route.HydrateFallback) {
{
if (route.hydrateFallbackElement) {
router.UNSAFE_warning(false, "You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - " + "`HydrateFallback` will be used.") ;
}
}
} // Note: this check also occurs in createRoutesFromChildren so update
// there if you change this
return Boolean(route.ErrorBoundary) || Boolean(route.errorElement);
Object.assign(updates, {
hydrateFallbackElement: /*#__PURE__*/React__namespace.createElement(route.HydrateFallback),
HydrateFallback: undefined
});
}
if (route.ErrorBoundary) {
{
if (route.errorElement) {
router.UNSAFE_warning(false, "You should not include both `ErrorBoundary` and `errorElement` on your route - " + "`ErrorBoundary` will be used.") ;
}
}
Object.assign(updates, {
errorElement: /*#__PURE__*/React__namespace.createElement(route.ErrorBoundary),
ErrorBoundary: undefined
});
}
return updates;
}
function createMemoryRouter(routes, opts) {
return router.createRouter({
basename: opts == null ? void 0 : opts.basename,
future: opts == null ? void 0 : opts.future,
future: _extends({}, opts == null ? void 0 : opts.future, {
v7_prependBasename: true
}),
history: router.createMemoryHistory({

@@ -1537,5 +1564,6 @@ initialEntries: opts == null ? void 0 : opts.initialEntries,

routes,
detectErrorBoundary
mapRouteProperties,
unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy
}).initialize();
} ///////////////////////////////////////////////////////////////////////////////
}

@@ -1586,2 +1614,6 @@ Object.defineProperty(exports, 'AbortedDeferredError', {

});
Object.defineProperty(exports, 'redirectDocument', {
enumerable: true,
get: function () { return router.redirectDocument; }
});
Object.defineProperty(exports, 'resolvePath', {

@@ -1604,3 +1636,5 @@ enumerable: true,

exports.UNSAFE_RouteContext = RouteContext;
exports.UNSAFE_detectErrorBoundary = detectErrorBoundary;
exports.UNSAFE_mapRouteProperties = mapRouteProperties;
exports.UNSAFE_useRouteId = useRouteId;
exports.UNSAFE_useRoutesImpl = useRoutesImpl;
exports.createMemoryRouter = createMemoryRouter;

@@ -1610,6 +1644,6 @@ exports.createRoutesFromChildren = createRoutesFromChildren;

exports.renderMatches = renderMatches;
exports.unstable_useBlocker = useBlocker;
exports.useActionData = useActionData;
exports.useAsyncError = useAsyncError;
exports.useAsyncValue = useAsyncValue;
exports.useBlocker = useBlocker;
exports.useHref = useHref;

@@ -1616,0 +1650,0 @@ exports.useInRouterContext = useInRouterContext;

/**
* React Router v0.0.0-experimental-0f2dd78c
* React Router v0.0.0-experimental-0f302655
*

@@ -11,3 +11,3 @@ * Copyright (c) Remix Software Inc.

*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@remix-run/router"),require("react")):"function"==typeof define&&define.amd?define(["exports","@remix-run/router","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactRouter={},e.RemixRouter,e.React)}(this,(function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var o=n(r);const a="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},{useState:i,useEffect:u,useLayoutEffect:l,useDebugValue:s}=o;function c(e){const t=e.getSnapshot,r=e.value;try{const e=t();return!a(r,e)}catch(e){return!0}}const d=!!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement)?function(e,t,r){return t()}:function(e,t,r){const n=t(),[{inst:o},a]=i({inst:{value:n,getSnapshot:t}});return l((()=>{o.value=n,o.getSnapshot=t,c(o)&&a({inst:o})}),[e,n,t]),u((()=>{c(o)&&a({inst:o});return e((()=>{c(o)&&a({inst:o})}))}),[e]),s(n),n},p="useSyncExternalStore"in o?(e=>e.useSyncExternalStore)(o):d,m=o.createContext(null),h=o.createContext(null),f=o.createContext(null),v=o.createContext(null),E=o.createContext(null),g=o.createContext({outlet:null,matches:[]}),y=o.createContext(null);function b(){return b=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},b.apply(this,arguments)}function x(){return null!=o.useContext(E)}function P(){return x()||t.UNSAFE_invariant(!1),o.useContext(E).location}function C(){x()||t.UNSAFE_invariant(!1);let{basename:e,navigator:r}=o.useContext(v),{matches:n}=o.useContext(g),{pathname:a}=P(),i=JSON.stringify(t.UNSAFE_getPathContributingMatches(n).map((e=>e.pathnameBase))),u=o.useRef(!1);return o.useEffect((()=>{u.current=!0})),o.useCallback((function(n,o){if(void 0===o&&(o={}),!u.current)return;if("number"==typeof n)return void r.go(n);let l=t.resolveTo(n,JSON.parse(i),a,"path"===o.relative);"/"!==e&&(l.pathname="/"===l.pathname?e:t.joinPaths([e,l.pathname])),(o.replace?r.replace:r.push)(l,o.state,o)}),[e,r,i,a])}const R=o.createContext(null);function S(e){let t=o.useContext(g).outlet;return t?o.createElement(R.Provider,{value:e},t):t}function U(e,r){let{relative:n}=void 0===r?{}:r,{matches:a}=o.useContext(g),{pathname:i}=P(),u=JSON.stringify(t.UNSAFE_getPathContributingMatches(a).map((e=>e.pathnameBase)));return o.useMemo((()=>t.resolveTo(e,JSON.parse(u),i,"path"===n)),[e,u,i,n])}function _(e,r){x()||t.UNSAFE_invariant(!1);let{navigator:n}=o.useContext(v),a=o.useContext(h),{matches:i}=o.useContext(g),u=i[i.length-1],l=u?u.params:{};!u||u.pathname;let s=u?u.pathnameBase:"/";u&&u.route;let c,d=P();if(r){var p;let e="string"==typeof r?t.parsePath(r):r;"/"===s||(null==(p=e.pathname)?void 0:p.startsWith(s))||t.UNSAFE_invariant(!1),c=e}else c=d;let m=c.pathname||"/",f="/"===s?m:m.slice(s.length)||"/",y=t.matchRoutes(e,{pathname:f}),C=N(y&&y.map((e=>Object.assign({},e,{params:Object.assign({},l,e.params),pathname:t.joinPaths([s,n.encodeLocation?n.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?s:t.joinPaths([s,n.encodeLocation?n.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])}))),i,a||void 0);return r&&C?o.createElement(E.Provider,{value:{location:b({pathname:"/",search:"",hash:"",state:null,key:"default"},c),navigationType:t.Action.Pop}},C):C}function O(){let e=L(),r=t.isRouteErrorResponse(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return o.createElement(o.Fragment,null,o.createElement("h2",null,"Unexpected Application Error!"),o.createElement("h3",{style:{fontStyle:"italic"}},r),n?o.createElement("pre",{style:a},n):null,null)}class j extends o.Component{constructor(e){super(e),this.state={location:e.location,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location?{error:e.error,location:e.location}:{error:e.error||t.error,location:t.location}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return this.state.error?o.createElement(g.Provider,{value:this.props.routeContext},o.createElement(y.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function A(e){let{routeContext:t,match:r,children:n}=e,a=o.useContext(m);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),o.createElement(g.Provider,{value:t},n)}function N(e,r,n){if(void 0===r&&(r=[]),null==e){if(null==n||!n.errors)return null;e=n.matches}let a=e,i=null==n?void 0:n.errors;if(null!=i){let e=a.findIndex((e=>e.route.id&&(null==i?void 0:i[e.route.id])));e>=0||t.UNSAFE_invariant(!1),a=a.slice(0,Math.min(a.length,e+1))}return a.reduceRight(((e,t,u)=>{let l=t.route.id?null==i?void 0:i[t.route.id]:null,s=null;n&&(s=t.route.ErrorBoundary?o.createElement(t.route.ErrorBoundary,null):t.route.errorElement?t.route.errorElement:o.createElement(O,null));let c=r.concat(a.slice(0,u+1)),d=()=>{let r=e;return l?r=s:t.route.Component?r=o.createElement(t.route.Component,null):t.route.element&&(r=t.route.element),o.createElement(A,{match:t,routeContext:{outlet:e,matches:c},children:r})};return n&&(t.route.ErrorBoundary||t.route.errorElement||0===u)?o.createElement(j,{location:n.location,component:s,error:l,children:d(),routeContext:{outlet:null,matches:c}}):d()}),null)}var F,D;function B(e){let r=o.useContext(m);return r||t.UNSAFE_invariant(!1),r}function k(e){let r=o.useContext(h);return r||t.UNSAFE_invariant(!1),r}function M(e){let r=function(e){let r=o.useContext(g);return r||t.UNSAFE_invariant(!1),r}(),n=r.matches[r.matches.length-1];return n.route.id||t.UNSAFE_invariant(!1),n.route.id}function L(){var e;let t=o.useContext(y),r=k(D.UseRouteError),n=M(D.UseRouteError);return t||(null==(e=r.errors)?void 0:e[n])}function w(){let e=o.useContext(f);return null==e?void 0:e._data}!function(e){e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator"}(F||(F={})),function(e){e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator"}(D||(D={}));let T=0;function I(e){t.UNSAFE_invariant(!1)}function H(e){let{basename:r="/",children:n=null,location:a,navigationType:i=t.Action.Pop,navigator:u,static:l=!1}=e;x()&&t.UNSAFE_invariant(!1);let s=r.replace(/^\/*/,"/"),c=o.useMemo((()=>({basename:s,navigator:u,static:l})),[s,u,l]);"string"==typeof a&&(a=t.parsePath(a));let{pathname:d="/",search:p="",hash:m="",state:h=null,key:f="default"}=a,g=o.useMemo((()=>{let e=t.stripBasename(d,s);return null==e?null:{location:{pathname:e,search:p,hash:m,state:h,key:f},navigationType:i}}),[s,d,p,m,h,f,i]);return null==g?null:o.createElement(v.Provider,{value:c},o.createElement(E.Provider,{children:n,value:g}))}function z(e){let{children:t,location:r}=e,n=o.useContext(m);return _(n&&!t?n.router.routes:Y(t),r)}var J;!function(e){e[e.pending=0]="pending",e[e.success=1]="success",e[e.error=2]="error"}(J||(J={}));const V=new Promise((()=>{}));class q extends o.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error("<Await> caught the following error during render",e,t)}render(){let{children:e,errorElement:r,resolve:n}=this.props,a=null,i=J.pending;if(n instanceof Promise)if(this.state.error){i=J.error;let e=this.state.error;a=Promise.reject().catch((()=>{})),Object.defineProperty(a,"_tracked",{get:()=>!0}),Object.defineProperty(a,"_error",{get:()=>e})}else n._tracked?(a=n,i=void 0!==a._error?J.error:void 0!==a._data?J.success:J.pending):(i=J.pending,Object.defineProperty(n,"_tracked",{get:()=>!0}),a=n.then((e=>Object.defineProperty(n,"_data",{get:()=>e})),(e=>Object.defineProperty(n,"_error",{get:()=>e}))));else i=J.success,a=Promise.resolve(),Object.defineProperty(a,"_tracked",{get:()=>!0}),Object.defineProperty(a,"_data",{get:()=>n});if(i===J.error&&a._error instanceof t.AbortedDeferredError)throw V;if(i===J.error&&!r)throw a._error;if(i===J.error)return o.createElement(f.Provider,{value:a,children:r});if(i===J.success)return o.createElement(f.Provider,{value:a,children:e});throw a}}function W(e){let{children:t}=e,r=w(),n="function"==typeof t?t(r):t;return o.createElement(o.Fragment,null,n)}function Y(e,r){void 0===r&&(r=[]);let n=[];return o.Children.forEach(e,((e,a)=>{if(!o.isValidElement(e))return;let i=[...r,a];if(e.type===o.Fragment)return void n.push.apply(n,Y(e.props.children,i));e.type!==I&&t.UNSAFE_invariant(!1),e.props.index&&e.props.children&&t.UNSAFE_invariant(!1);let u={id:e.props.id||i.join("-"),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,loader:e.props.loader,action:e.props.action,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:null!=e.props.ErrorBoundary||null!=e.props.errorElement,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(u.children=Y(e.props.children,i)),n.push(u)})),n}function G(e){return Boolean(e.ErrorBoundary)||Boolean(e.errorElement)}Object.defineProperty(e,"AbortedDeferredError",{enumerable:!0,get:function(){return t.AbortedDeferredError}}),Object.defineProperty(e,"NavigationType",{enumerable:!0,get:function(){return t.Action}}),Object.defineProperty(e,"createPath",{enumerable:!0,get:function(){return t.createPath}}),Object.defineProperty(e,"defer",{enumerable:!0,get:function(){return t.defer}}),Object.defineProperty(e,"generatePath",{enumerable:!0,get:function(){return t.generatePath}}),Object.defineProperty(e,"isRouteErrorResponse",{enumerable:!0,get:function(){return t.isRouteErrorResponse}}),Object.defineProperty(e,"json",{enumerable:!0,get:function(){return t.json}}),Object.defineProperty(e,"matchPath",{enumerable:!0,get:function(){return t.matchPath}}),Object.defineProperty(e,"matchRoutes",{enumerable:!0,get:function(){return t.matchRoutes}}),Object.defineProperty(e,"parsePath",{enumerable:!0,get:function(){return t.parsePath}}),Object.defineProperty(e,"redirect",{enumerable:!0,get:function(){return t.redirect}}),Object.defineProperty(e,"resolvePath",{enumerable:!0,get:function(){return t.resolvePath}}),e.Await=function(e){let{children:t,errorElement:r,resolve:n}=e;return o.createElement(q,{resolve:n,errorElement:r},o.createElement(W,null,t))},e.MemoryRouter=function(e){let{basename:r,children:n,initialEntries:a,initialIndex:i}=e,u=o.useRef();null==u.current&&(u.current=t.createMemoryHistory({initialEntries:a,initialIndex:i,v5Compat:!0}));let l=u.current,[s,c]=o.useState({action:l.action,location:l.location});return o.useLayoutEffect((()=>l.listen(c)),[l]),o.createElement(H,{basename:r,children:n,location:s.location,navigationType:s.action,navigator:l})},e.Navigate=function(e){let{to:r,replace:n,state:a,relative:i}=e;x()||t.UNSAFE_invariant(!1);let u=o.useContext(h),l=C();return o.useEffect((()=>{u&&"idle"!==u.navigation.state||l(r,{replace:n,state:a,relative:i})})),null},e.Outlet=function(e){return S(e.context)},e.Route=I,e.Router=H,e.RouterProvider=function(e){let{fallbackElement:t,router:r}=e,n=o.useCallback((()=>r.state),[r]),a=p(r.subscribe,n,n),i=o.useMemo((()=>({createHref:r.createHref,encodeLocation:r.encodeLocation,go:e=>r.navigate(e),push:(e,t,n)=>r.navigate(e,{state:t,preventScrollReset:null==n?void 0:n.preventScrollReset}),replace:(e,t,n)=>r.navigate(e,{replace:!0,state:t,preventScrollReset:null==n?void 0:n.preventScrollReset})})),[r]),u=r.basename||"/",l=o.useMemo((()=>({router:r,navigator:i,static:!1,basename:u})),[r,i,u]);return o.createElement(o.Fragment,null,o.createElement(m.Provider,{value:l},o.createElement(h.Provider,{value:a},o.createElement(H,{basename:r.basename,location:r.state.location,navigationType:r.state.historyAction,navigator:i},r.state.initialized?o.createElement(z,null):t))),null)},e.Routes=z,e.UNSAFE_DataRouterContext=m,e.UNSAFE_DataRouterStateContext=h,e.UNSAFE_LocationContext=E,e.UNSAFE_NavigationContext=v,e.UNSAFE_RouteContext=g,e.UNSAFE_detectErrorBoundary=G,e.createMemoryRouter=function(e,r){return t.createRouter({basename:null==r?void 0:r.basename,future:null==r?void 0:r.future,history:t.createMemoryHistory({initialEntries:null==r?void 0:r.initialEntries,initialIndex:null==r?void 0:r.initialIndex}),hydrationData:null==r?void 0:r.hydrationData,routes:e,detectErrorBoundary:G}).initialize()},e.createRoutesFromChildren=Y,e.createRoutesFromElements=Y,e.renderMatches=function(e){return N(e)},e.unstable_useBlocker=function(e){let{router:t}=B(F.UseBlocker),r=k(D.UseBlocker),[n]=o.useState((()=>String(++T))),a=o.useCallback((t=>"function"==typeof e?!!e(t):!!e),[e]),i=t.getBlocker(n,a);return o.useEffect((()=>()=>t.deleteBlocker(n)),[t,n]),r.blockers.get(n)||i},e.useActionData=function(){let e=k(D.UseActionData);return o.useContext(g)||t.UNSAFE_invariant(!1),Object.values((null==e?void 0:e.actionData)||{})[0]},e.useAsyncError=function(){let e=o.useContext(f);return null==e?void 0:e._error},e.useAsyncValue=w,e.useHref=function(e,r){let{relative:n}=void 0===r?{}:r;x()||t.UNSAFE_invariant(!1);let{basename:a,navigator:i}=o.useContext(v),{hash:u,pathname:l,search:s}=U(e,{relative:n}),c=l;return"/"!==a&&(c="/"===l?a:t.joinPaths([a,l])),i.createHref({pathname:c,search:s,hash:u})},e.useInRouterContext=x,e.useLoaderData=function(){let e=k(D.UseLoaderData),t=M(D.UseLoaderData);if(!e.errors||null==e.errors[t])return e.loaderData[t];console.error("You cannot `useLoaderData` in an errorElement (routeId: "+t+")")},e.useLocation=P,e.useMatch=function(e){x()||t.UNSAFE_invariant(!1);let{pathname:r}=P();return o.useMemo((()=>t.matchPath(e,r)),[r,e])},e.useMatches=function(){let{matches:e,loaderData:t}=k(D.UseMatches);return o.useMemo((()=>e.map((e=>{let{pathname:r,params:n}=e;return{id:e.route.id,pathname:r,params:n,data:t[e.route.id],handle:e.route.handle}}))),[e,t])},e.useNavigate=C,e.useNavigation=function(){return k(D.UseNavigation).navigation},e.useNavigationType=function(){return o.useContext(E).navigationType},e.useOutlet=S,e.useOutletContext=function(){return o.useContext(R)},e.useParams=function(){let{matches:e}=o.useContext(g),t=e[e.length-1];return t?t.params:{}},e.useResolvedPath=U,e.useRevalidator=function(){let e=B(F.UseRevalidator),t=k(D.UseRevalidator);return{revalidate:e.router.revalidate,state:t.revalidation}},e.useRouteError=L,e.useRouteLoaderData=function(e){return k(D.UseRouteLoaderData).loaderData[e]},e.useRoutes=_,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@remix-run/router")):"function"==typeof define&&define.amd?define(["exports","react","@remix-run/router"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactRouter={},e.React,e.RemixRouter)}(this,(function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=n(t);function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},o.apply(this,arguments)}const i=a.createContext(null),u=a.createContext(null),l=a.createContext(null),s=a.createContext(null),c=a.createContext(null),d=a.createContext({outlet:null,matches:[],isDataRoute:!1}),p=a.createContext(null);function f(){return null!=a.useContext(c)}function v(){return f()||r.UNSAFE_invariant(!1),a.useContext(c).location}function m(e){a.useContext(s).static||a.useLayoutEffect(e)}function h(){let{isDataRoute:e}=a.useContext(d);return e?function(){let{router:e}=O(U.UseNavigateStable),t=j(N.UseNavigateStable),r=a.useRef(!1);return m((()=>{r.current=!0})),a.useCallback((function(n,a){void 0===a&&(a={}),r.current&&("number"==typeof n?e.navigate(n):e.navigate(n,o({fromRouteId:t},a)))}),[e,t])}():function(){f()||r.UNSAFE_invariant(!1);let e=a.useContext(i),{basename:t,future:n,navigator:o}=a.useContext(s),{matches:u}=a.useContext(d),{pathname:l}=v(),c=JSON.stringify(r.UNSAFE_getResolveToMatches(u,n.v7_relativeSplatPath)),p=a.useRef(!1);return m((()=>{p.current=!0})),a.useCallback((function(n,a){if(void 0===a&&(a={}),!p.current)return;if("number"==typeof n)return void o.go(n);let i=r.resolveTo(n,JSON.parse(c),l,"path"===a.relative);null==e&&"/"!==t&&(i.pathname="/"===i.pathname?t:r.joinPaths([t,i.pathname])),(a.replace?o.replace:o.push)(i,a.state,a)}),[t,o,c,l,e])}()}const E=a.createContext(null);function g(e){let t=a.useContext(d).outlet;return t?a.createElement(E.Provider,{value:e},t):t}function y(e,t){let{relative:n}=void 0===t?{}:t,{future:o}=a.useContext(s),{matches:i}=a.useContext(d),{pathname:u}=v(),l=JSON.stringify(r.UNSAFE_getResolveToMatches(i,o.v7_relativeSplatPath));return a.useMemo((()=>r.resolveTo(e,JSON.parse(l),u,"path"===n)),[e,l,u,n])}function b(e,t){return R(e,t)}function R(e,t,n,i){f()||r.UNSAFE_invariant(!1);let{navigator:u}=a.useContext(s),{matches:l}=a.useContext(d),p=l[l.length-1],m=p?p.params:{};!p||p.pathname;let h=p?p.pathnameBase:"/";p&&p.route;let E,g=v();if(t){var y;let e="string"==typeof t?r.parsePath(t):t;"/"===h||(null==(y=e.pathname)?void 0:y.startsWith(h))||r.UNSAFE_invariant(!1),E=e}else E=g;let b=E.pathname||"/",R=b;if("/"!==h){let e=h.replace(/^\//,"").split("/");R="/"+b.replace(/^\//,"").split("/").slice(e.length).join("/")}let P=r.matchRoutes(e,{pathname:R}),x=_(P&&P.map((e=>Object.assign({},e,{params:Object.assign({},m,e.params),pathname:r.joinPaths([h,u.encodeLocation?u.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?h:r.joinPaths([h,u.encodeLocation?u.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])}))),l,n,i);return t&&x?a.createElement(c.Provider,{value:{location:o({pathname:"/",search:"",hash:"",state:null,key:"default"},E),navigationType:r.Action.Pop}},x):x}function P(){let e=F(),t=r.isRouteErrorResponse(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,o={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return a.createElement(a.Fragment,null,a.createElement("h2",null,"Unexpected Application Error!"),a.createElement("h3",{style:{fontStyle:"italic"}},t),n?a.createElement("pre",{style:o},n):null,null)}const x=a.createElement(P,null);class C extends a.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||"idle"!==t.revalidation&&"idle"===e.revalidation?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:void 0!==e.error?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return void 0!==this.state.error?a.createElement(d.Provider,{value:this.props.routeContext},a.createElement(p.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function S(e){let{routeContext:t,match:r,children:n}=e,o=a.useContext(i);return o&&o.static&&o.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=r.route.id),a.createElement(d.Provider,{value:t},n)}function _(e,t,n,o){var i;if(void 0===t&&(t=[]),void 0===n&&(n=null),void 0===o&&(o=null),null==e){var u;if(null==(u=n)||!u.errors)return null;e=n.matches}let l=e,s=null==(i=n)?void 0:i.errors;if(null!=s){let e=l.findIndex((e=>e.route.id&&void 0!==(null==s?void 0:s[e.route.id])));e>=0||r.UNSAFE_invariant(!1),l=l.slice(0,Math.min(l.length,e+1))}let c=!1,d=-1;if(n&&o&&o.v7_partialHydration)for(let e=0;e<l.length;e++){let t=l[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(d=e),t.route.id){let{loaderData:e,errors:r}=n,a=t.route.loader&&void 0===e[t.route.id]&&(!r||void 0===r[t.route.id]);if(t.route.lazy||a){c=!0,l=d>=0?l.slice(0,d+1):[l[0]];break}}}return l.reduceRight(((e,r,o)=>{let i,u=!1,p=null,f=null;var v;n&&(i=s&&r.route.id?s[r.route.id]:void 0,p=r.route.errorElement||x,c&&(d<0&&0===o?(v="route-fallback",!1||B[v]||(B[v]=!0),u=!0,f=null):d===o&&(u=!0,f=r.route.hydrateFallbackElement||null)));let m=t.concat(l.slice(0,o+1)),h=()=>{let t;return t=i?p:u?f:r.route.Component?a.createElement(r.route.Component,null):r.route.element?r.route.element:e,a.createElement(S,{match:r,routeContext:{outlet:e,matches:m,isDataRoute:null!=n},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||0===o)?a.createElement(C,{location:n.location,revalidation:n.revalidation,component:p,error:i,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0}}):h()}),null)}var U=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(U||{}),N=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(N||{});function O(e){let t=a.useContext(i);return t||r.UNSAFE_invariant(!1),t}function A(e){let t=a.useContext(u);return t||r.UNSAFE_invariant(!1),t}function j(e){let t=function(e){let t=a.useContext(d);return t||r.UNSAFE_invariant(!1),t}(),n=t.matches[t.matches.length-1];return n.route.id||r.UNSAFE_invariant(!1),n.route.id}function F(){var e;let t=a.useContext(p),r=A(N.UseRouteError),n=j(N.UseRouteError);return void 0!==t?t:null==(e=r.errors)?void 0:e[n]}function D(){let e=a.useContext(l);return null==e?void 0:e._data}let k=0;const B={};const L=a.startTransition;function M(e){let{routes:t,future:r,state:n}=e;return R(t,void 0,n,r)}function T(e){r.UNSAFE_invariant(!1)}function I(e){let{basename:t="/",children:n=null,location:i,navigationType:u=r.Action.Pop,navigator:l,static:d=!1,future:p}=e;f()&&r.UNSAFE_invariant(!1);let v=t.replace(/^\/*/,"/"),m=a.useMemo((()=>({basename:v,navigator:l,static:d,future:o({v7_relativeSplatPath:!1},p)})),[v,p,l,d]);"string"==typeof i&&(i=r.parsePath(i));let{pathname:h="/",search:E="",hash:g="",state:y=null,key:b="default"}=i,R=a.useMemo((()=>{let e=r.stripBasename(h,v);return null==e?null:{location:{pathname:e,search:E,hash:g,state:y,key:b},navigationType:u}}),[v,h,E,g,y,b,u]);return null==R?null:a.createElement(s.Provider,{value:m},a.createElement(c.Provider,{children:n,value:R}))}var H=function(e){return e[e.pending=0]="pending",e[e.success=1]="success",e[e.error=2]="error",e}(H||{});const w=new Promise((()=>{}));class J extends a.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error("<Await> caught the following error during render",e,t)}render(){let{children:e,errorElement:t,resolve:n}=this.props,o=null,i=H.pending;if(n instanceof Promise)if(this.state.error){i=H.error;let e=this.state.error;o=Promise.reject().catch((()=>{})),Object.defineProperty(o,"_tracked",{get:()=>!0}),Object.defineProperty(o,"_error",{get:()=>e})}else n._tracked?(o=n,i=void 0!==o._error?H.error:void 0!==o._data?H.success:H.pending):(i=H.pending,Object.defineProperty(n,"_tracked",{get:()=>!0}),o=n.then((e=>Object.defineProperty(n,"_data",{get:()=>e})),(e=>Object.defineProperty(n,"_error",{get:()=>e}))));else i=H.success,o=Promise.resolve(),Object.defineProperty(o,"_tracked",{get:()=>!0}),Object.defineProperty(o,"_data",{get:()=>n});if(i===H.error&&o._error instanceof r.AbortedDeferredError)throw w;if(i===H.error&&!t)throw o._error;if(i===H.error)return a.createElement(l.Provider,{value:o,children:t});if(i===H.success)return a.createElement(l.Provider,{value:o,children:e});throw o}}function z(e){let{children:t}=e,r=D(),n="function"==typeof t?t(r):t;return a.createElement(a.Fragment,null,n)}function q(e,t){void 0===t&&(t=[]);let n=[];return a.Children.forEach(e,((e,o)=>{if(!a.isValidElement(e))return;let i=[...t,o];if(e.type===a.Fragment)return void n.push.apply(n,q(e.props.children,i));e.type!==T&&r.UNSAFE_invariant(!1),e.props.index&&e.props.children&&r.UNSAFE_invariant(!1);let u={id:e.props.id||i.join("-"),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,loader:e.props.loader,action:e.props.action,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:null!=e.props.ErrorBoundary||null!=e.props.errorElement,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(u.children=q(e.props.children,i)),n.push(u)})),n}function V(e){let t={hasErrorBoundary:null!=e.ErrorBoundary||null!=e.errorElement};return e.Component&&Object.assign(t,{element:a.createElement(e.Component),Component:void 0}),e.HydrateFallback&&Object.assign(t,{hydrateFallbackElement:a.createElement(e.HydrateFallback),HydrateFallback:void 0}),e.ErrorBoundary&&Object.assign(t,{errorElement:a.createElement(e.ErrorBoundary),ErrorBoundary:void 0}),t}Object.defineProperty(e,"AbortedDeferredError",{enumerable:!0,get:function(){return r.AbortedDeferredError}}),Object.defineProperty(e,"NavigationType",{enumerable:!0,get:function(){return r.Action}}),Object.defineProperty(e,"createPath",{enumerable:!0,get:function(){return r.createPath}}),Object.defineProperty(e,"defer",{enumerable:!0,get:function(){return r.defer}}),Object.defineProperty(e,"generatePath",{enumerable:!0,get:function(){return r.generatePath}}),Object.defineProperty(e,"isRouteErrorResponse",{enumerable:!0,get:function(){return r.isRouteErrorResponse}}),Object.defineProperty(e,"json",{enumerable:!0,get:function(){return r.json}}),Object.defineProperty(e,"matchPath",{enumerable:!0,get:function(){return r.matchPath}}),Object.defineProperty(e,"matchRoutes",{enumerable:!0,get:function(){return r.matchRoutes}}),Object.defineProperty(e,"parsePath",{enumerable:!0,get:function(){return r.parsePath}}),Object.defineProperty(e,"redirect",{enumerable:!0,get:function(){return r.redirect}}),Object.defineProperty(e,"redirectDocument",{enumerable:!0,get:function(){return r.redirectDocument}}),Object.defineProperty(e,"resolvePath",{enumerable:!0,get:function(){return r.resolvePath}}),e.Await=function(e){let{children:t,errorElement:r,resolve:n}=e;return a.createElement(J,{resolve:n,errorElement:r},a.createElement(z,null,t))},e.MemoryRouter=function(e){let{basename:t,children:n,initialEntries:o,initialIndex:i,future:u}=e,l=a.useRef();null==l.current&&(l.current=r.createMemoryHistory({initialEntries:o,initialIndex:i,v5Compat:!0}));let s=l.current,[c,d]=a.useState({action:s.action,location:s.location}),{v7_startTransition:p}=u||{},f=a.useCallback((e=>{p&&L?L((()=>d(e))):d(e)}),[d,p]);return a.useLayoutEffect((()=>s.listen(f)),[s,f]),a.createElement(I,{basename:t,children:n,location:c.location,navigationType:c.action,navigator:s,future:u})},e.Navigate=function(e){let{to:t,replace:n,state:o,relative:i}=e;f()||r.UNSAFE_invariant(!1);let{future:u,static:l}=a.useContext(s),{matches:c}=a.useContext(d),{pathname:p}=v(),m=h(),E=r.resolveTo(t,r.UNSAFE_getResolveToMatches(c,u.v7_relativeSplatPath),p,"path"===i),g=JSON.stringify(E);return a.useEffect((()=>m(JSON.parse(g),{replace:n,state:o,relative:i})),[m,g,i,n,o]),null},e.Outlet=function(e){return g(e.context)},e.Route=T,e.Router=I,e.RouterProvider=function(e){let{fallbackElement:t,router:r,future:n}=e,[o,l]=a.useState(r.state),{v7_startTransition:s}=n||{},c=a.useCallback((e=>{s&&L?L((()=>l(e))):l(e)}),[l,s]);a.useLayoutEffect((()=>r.subscribe(c)),[r,c]),a.useEffect((()=>{}),[]);let d=a.useMemo((()=>({createHref:r.createHref,encodeLocation:r.encodeLocation,go:e=>r.navigate(e),push:(e,t,n)=>r.navigate(e,{state:t,preventScrollReset:null==n?void 0:n.preventScrollReset}),replace:(e,t,n)=>r.navigate(e,{replace:!0,state:t,preventScrollReset:null==n?void 0:n.preventScrollReset})})),[r]),p=r.basename||"/",f=a.useMemo((()=>({router:r,navigator:d,static:!1,basename:p})),[r,d,p]);return a.createElement(a.Fragment,null,a.createElement(i.Provider,{value:f},a.createElement(u.Provider,{value:o},a.createElement(I,{basename:p,location:o.location,navigationType:o.historyAction,navigator:d,future:{v7_relativeSplatPath:r.future.v7_relativeSplatPath}},o.initialized||r.future.v7_partialHydration?a.createElement(M,{routes:r.routes,future:r.future,state:o}):t))),null)},e.Routes=function(e){let{children:t,location:r}=e;return b(q(t),r)},e.UNSAFE_DataRouterContext=i,e.UNSAFE_DataRouterStateContext=u,e.UNSAFE_LocationContext=c,e.UNSAFE_NavigationContext=s,e.UNSAFE_RouteContext=d,e.UNSAFE_mapRouteProperties=V,e.UNSAFE_useRouteId=function(){return j(N.UseRouteId)},e.UNSAFE_useRoutesImpl=R,e.createMemoryRouter=function(e,t){return r.createRouter({basename:null==t?void 0:t.basename,future:o({},null==t?void 0:t.future,{v7_prependBasename:!0}),history:r.createMemoryHistory({initialEntries:null==t?void 0:t.initialEntries,initialIndex:null==t?void 0:t.initialIndex}),hydrationData:null==t?void 0:t.hydrationData,routes:e,mapRouteProperties:V,unstable_dataStrategy:null==t?void 0:t.unstable_dataStrategy}).initialize()},e.createRoutesFromChildren=q,e.createRoutesFromElements=q,e.renderMatches=function(e){return _(e)},e.useActionData=function(){let e=A(N.UseActionData),t=j(N.UseLoaderData);return e.actionData?e.actionData[t]:void 0},e.useAsyncError=function(){let e=a.useContext(l);return null==e?void 0:e._error},e.useAsyncValue=D,e.useBlocker=function(e){let{router:t,basename:n}=O(U.UseBlocker),i=A(N.UseBlocker),[u,l]=a.useState(""),s=a.useCallback((t=>{if("function"!=typeof e)return!!e;if("/"===n)return e(t);let{currentLocation:a,nextLocation:i,historyAction:u}=t;return e({currentLocation:o({},a,{pathname:r.stripBasename(a.pathname,n)||a.pathname}),nextLocation:o({},i,{pathname:r.stripBasename(i.pathname,n)||i.pathname}),historyAction:u})}),[n,e]);return a.useEffect((()=>{let e=String(++k);return l(e),()=>t.deleteBlocker(e)}),[t]),a.useEffect((()=>{""!==u&&t.getBlocker(u,s)}),[t,u,s]),u&&i.blockers.has(u)?i.blockers.get(u):r.IDLE_BLOCKER},e.useHref=function(e,t){let{relative:n}=void 0===t?{}:t;f()||r.UNSAFE_invariant(!1);let{basename:o,navigator:i}=a.useContext(s),{hash:u,pathname:l,search:c}=y(e,{relative:n}),d=l;return"/"!==o&&(d="/"===l?o:r.joinPaths([o,l])),i.createHref({pathname:d,search:c,hash:u})},e.useInRouterContext=f,e.useLoaderData=function(){let e=A(N.UseLoaderData),t=j(N.UseLoaderData);if(!e.errors||null==e.errors[t])return e.loaderData[t];console.error("You cannot `useLoaderData` in an errorElement (routeId: "+t+")")},e.useLocation=v,e.useMatch=function(e){f()||r.UNSAFE_invariant(!1);let{pathname:t}=v();return a.useMemo((()=>r.matchPath(e,t)),[t,e])},e.useMatches=function(){let{matches:e,loaderData:t}=A(N.UseMatches);return a.useMemo((()=>e.map((e=>r.UNSAFE_convertRouteMatchToUiMatch(e,t)))),[e,t])},e.useNavigate=h,e.useNavigation=function(){return A(N.UseNavigation).navigation},e.useNavigationType=function(){return a.useContext(c).navigationType},e.useOutlet=g,e.useOutletContext=function(){return a.useContext(E)},e.useParams=function(){let{matches:e}=a.useContext(d),t=e[e.length-1];return t?t.params:{}},e.useResolvedPath=y,e.useRevalidator=function(){let e=O(U.UseRevalidator),t=A(N.UseRevalidator);return a.useMemo((()=>({revalidate:e.router.revalidate,state:t.revalidation})),[e.router.revalidate,t.revalidation])},e.useRouteError=F,e.useRouteLoaderData=function(e){return A(N.UseRouteLoaderData).loaderData[e]},e.useRoutes=b,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=react-router.production.min.js.map
MIT License
Copyright (c) React Training 2015-2019
Copyright (c) Remix Software 2020-2022
Copyright (c) React Training LLC 2015-2019
Copyright (c) Remix Software Inc. 2020-2021
Copyright (c) Shopify Inc. 2022-2023

@@ -6,0 +7,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"name": "react-router",
"version": "0.0.0-experimental-0f2dd78c",
"version": "0.0.0-experimental-0f302655",
"description": "Declarative routing for React",

@@ -26,6 +26,7 @@ "keywords": [

"dependencies": {
"@remix-run/router": "0.0.0-experimental-0f2dd78c"
"@remix-run/router": "0.0.0-experimental-0f302655"
},
"devDependencies": {
"react": "^18.2.0"
"react": "^18.2.0",
"react-router-dom": "0.0.0-experimental-0f302655"
},

@@ -42,4 +43,4 @@ "peerDependencies": {

"engines": {
"node": ">=14"
"node": ">=14.0.0"
}
}
}

@@ -5,5 +5,5 @@ # React Router

the core functionality for both
[`react-router-dom`](/packages/react-router-dom)
[`react-router-dom`](https://github.com/remix-run/react-router/tree/main/packages/react-router-dom)
and
[`react-router-native`](/packages/react-router-native).
[`react-router-native`](https://github.com/remix-run/react-router/tree/main/packages/react-router-native).

@@ -10,0 +10,0 @@ If you're using React Router, you should never `import` anything directly from

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc