New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-router

Package Overview
Dependencies
Maintainers
3
Versions
712
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-router - npm Package Compare versions

Comparing version 6.4.0-pre.9 to 6.4.0-pre.10

38

CHANGELOG.md
# react-router
## 6.4.0-pre.10
### Patch Changes
- feat: Deferred API Updates (#9070)
- Removes `<Suspense>` from inside `<Deferred>`, requires users to render their own suspense boundaries
- Updates `Deferred` to use a true error boundary to catch render errors as well as data errors
- Support array and single promise usages
- `return deferred([ await critical(), lazy() ])`
- `return deferred(lazy())`
- Remove `Deferrable`/`ResolvedDeferrable` in favor of raw `Promise`'s and `Awaited`
- Remove generics from `useDeferredData` until `useLoaderData` generic is decided in 6.5
- Updated dependencies
- @remix-run/router@0.2.0-pre.5
## 6.4.0-pre.9

@@ -18,3 +35,3 @@

critical: await getCriticalData(),
lazy1: getLazyData(),
lazy: getLazyData(),
});

@@ -30,8 +47,7 @@ };

<p>Critical Data: {data.critical}</p>
<Deferred
value={data.lazy}
fallback={<p>Loading...</p>}
errorElement={<RenderDeferredError />}>
<RenderDeferredData />
</Deferred>
<Suspense fallback={<p>Loading...</p>}>
<Deferred value={data.lazy} errorElement={<RenderDeferredError />}>
<RenderDeferredData />
</Deferred>
</Suspense>
</>

@@ -63,5 +79,7 @@ );

<p>Critical Data: {data.critical}</p>
<Deferred value={data.lazy} fallback={<p>Loading...</p>}>
{(data) => <p>{data}</p>}
</Deferred>
<Suspense fallback={<p>Loading...</p>}>
<Deferred value={data.lazy} errorElement={<RenderDeferredError />}>
{(data) => <p>{data}</p>}
</Deferred>
</Suspense>
</>

@@ -68,0 +86,0 @@ );

import type { ActionFunction, ActionFunctionArgs, DataRouteMatch, Fetcher, JsonFunction, LoaderFunction, LoaderFunctionArgs, Location, Navigation, Params, ParamParseKey, Path, PathMatch, PathPattern, RedirectFunction, RouteMatch, RouteObject, ShouldRevalidateFunction, To } from "@remix-run/router";
import { Action as NavigationType, createPath, deferred, generatePath, isDeferredError, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from "@remix-run/router";
import type { DataMemoryRouterProps, DeferredProps, MemoryRouterProps, NavigateProps, OutletProps, RouteProps, PathRouteProps, LayoutRouteProps, IndexRouteProps, RouterProps, RoutesProps } from "./lib/components";
import { createRoutesFromChildren, renderMatches, DataMemoryRouter, Deferred, MemoryRouter, Navigate, Outlet, Route, Router, Routes, useRenderDataRouter } from "./lib/components";
import { createRoutesFromChildren, renderMatches, DataMemoryRouter, DataRouter, DataRouterProvider, Deferred, MemoryRouter, Navigate, Outlet, Route, Router, Routes } from "./lib/components";
import type { Navigator, NavigateOptions } from "./lib/context";
import { DataRouterContext, DataRouterStateContext, LocationContext, NavigationContext, RouteContext } from "./lib/context";
import type { Deferrable, NavigateFunction } from "./lib/hooks";
import { DataRouterContext, DataRouterStateContext, DataStaticRouterContext, LocationContext, NavigationContext, RouteContext } from "./lib/context";
import type { NavigateFunction } from "./lib/hooks";
import { useHref, useInRouterContext, useLocation, useMatch, useNavigationType, useNavigate, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useActionData, useDeferredData, useLoaderData, useMatches, useRouteLoaderData, useRouteError, useNavigation, useRevalidator } from "./lib/hooks";

@@ -12,5 +12,5 @@ declare type Hash = string;

declare type Search = string;
export type { ActionFunction, ActionFunctionArgs, DataMemoryRouterProps, DataRouteMatch, Deferrable, DeferredProps, Fetcher, Hash, IndexRouteProps, JsonFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathPattern, PathRouteProps, RedirectFunction, RouteMatch, RouteObject, RouteProps, RouterProps, RoutesProps, Search, ShouldRevalidateFunction, To, };
export type { ActionFunction, ActionFunctionArgs, DataMemoryRouterProps, DataRouteMatch, DeferredProps, Fetcher, Hash, IndexRouteProps, JsonFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathPattern, PathRouteProps, RedirectFunction, RouteMatch, RouteObject, RouteProps, RouterProps, RoutesProps, Search, ShouldRevalidateFunction, To, };
export { DataMemoryRouter, Deferred, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, Routes, createPath, createRoutesFromChildren, deferred, isDeferredError, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, renderMatches, resolvePath, useActionData, useDeferredData, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, };
/** @internal */
export { NavigationContext as UNSAFE_NavigationContext, LocationContext as UNSAFE_LocationContext, RouteContext as UNSAFE_RouteContext, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, useRenderDataRouter, };
export { DataRouter as UNSAFE_DataRouter, DataRouterProvider as UNSAFE_DataRouterProvider, NavigationContext as UNSAFE_NavigationContext, LocationContext as UNSAFE_LocationContext, RouteContext as UNSAFE_RouteContext, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, DataStaticRouterContext as UNSAFE_DataStaticRouterContext, };
/**
* React Router v6.4.0-pre.9
* React Router v6.4.0-pre.10
*

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

*/
import { invariant, resolveTo, joinPaths, matchPath, warning, parsePath, matchRoutes, isDeferredError, isRouteErrorResponse, createMemoryHistory, Action, stripBasename, createMemoryRouter } from '@remix-run/router';
import { invariant, resolveTo, joinPaths, matchPath, warning, parsePath, matchRoutes, isRouteErrorResponse, createMemoryRouter, createMemoryHistory, Action, stripBasename, isDeferredError } from '@remix-run/router';
export { Action as NavigationType, createPath, deferred, generatePath, isDeferredError, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from '@remix-run/router';

@@ -196,2 +196,8 @@ import * as React from 'react';

// Contexts for data routers
const DataStaticRouterContext = /*#__PURE__*/React.createContext(null);
if (process.env.NODE_ENV !== "production") {
DataStaticRouterContext.displayName = "DataStaticRouterContext";
}
const DataRouterContext = /*#__PURE__*/React.createContext(null);

@@ -550,3 +556,4 @@

let error = useRouteError();
let message = isRouteErrorResponse(error) ? error.status + " " + error.statusText : (error == null ? void 0 : error.message) || JSON.stringify(error);
let message = isRouteErrorResponse(error) ? error.status + " " + error.statusText : error instanceof Error ? error.message : JSON.stringify(error);
let stack = error instanceof Error ? error.stack : null;
let lightgrey = "rgba(200,200,200, 0.5)";

@@ -565,5 +572,5 @@ let preStyles = {

}
}, message), error != null && error.stack ? /*#__PURE__*/React.createElement("pre", {
}, message), stack ? /*#__PURE__*/React.createElement("pre", {
style: preStyles
}, error == null ? void 0 : error.stack) : null, /*#__PURE__*/React.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), /*#__PURE__*/React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own\xA0", /*#__PURE__*/React.createElement("code", {
}, stack) : null, /*#__PURE__*/React.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), /*#__PURE__*/React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own\xA0", /*#__PURE__*/React.createElement("code", {
style: codeStyles

@@ -628,2 +635,21 @@ }, "errorElement"), " props on\xA0", /*#__PURE__*/React.createElement("code", {

}
function RenderedRoute(_ref) {
let {
routeContext,
match,
children
} = _ref;
let dataStaticRouterContext = React.useContext(DataStaticRouterContext); // Track how deep we got in our render pass to emulate SSR componentDidCatch
// in a DataStaticRouter
if (dataStaticRouterContext && match.route.errorElement) {
dataStaticRouterContext._deepestRenderedBoundaryId = match.route.id;
}
return /*#__PURE__*/React.createElement(RouteContext.Provider, {
value: routeContext
}, children);
}
function _renderMatches(matches, parentMatches, dataRouterState) {

@@ -659,9 +685,9 @@ if (parentMatches === void 0) {

let getChildren = () => /*#__PURE__*/React.createElement(RouteContext.Provider, {
children: error ? errorElement : match.route.element !== undefined ? match.route.element : outlet,
value: {
let getChildren = () => /*#__PURE__*/React.createElement(RenderedRoute, {
match: match,
routeContext: {
outlet,
matches: parentMatches.concat(renderedMatches.slice(0, index + 1))
}
}); // Only wrap in an error boundary within data router usages when we have an
}, error ? errorElement : match.route.element !== undefined ? match.route.element : outlet); // Only wrap in an error boundary within data router usages when we have an
// errorElement on this route. Otherwise let it bubble up to an ancestor

@@ -693,3 +719,3 @@ // errorElement

let state = React.useContext(DataRouterStateContext);
!state ? process.env.NODE_ENV !== "production" ? invariant(false, hookName + " must be used within a DataRouter") : invariant(false) : void 0;
!state ? process.env.NODE_ENV !== "production" ? invariant(false, hookName + " must be used within a DataRouterStateContext") : invariant(false) : void 0;
return state;

@@ -713,7 +739,7 @@ }

function useRevalidator() {
let router = React.useContext(DataRouterContext);
!router ? process.env.NODE_ENV !== "production" ? invariant(false, "useRevalidator must be used within a DataRouter") : invariant(false) : void 0;
let dataRouterContext = React.useContext(DataRouterContext);
!dataRouterContext ? process.env.NODE_ENV !== "production" ? invariant(false, "useRevalidator must be used within a DataRouterContext") : invariant(false) : void 0;
let state = useDataRouterState(DataRouterHook.UseRevalidator);
return {
revalidate: router.revalidate,
revalidate: dataRouterContext.router.revalidate,
state: state.revalidation

@@ -791,3 +817,3 @@ };

if (deferredValue && isDeferredError(deferredValue)) {
if (deferredValue && deferredValue instanceof Error) {
return deferredValue;

@@ -807,6 +833,6 @@ } // If this was a render error, we put it in a RouteError context inside

}
/**
* Returns the happy-path data from the nearest ancestor <Deferred /> value
*/
function useDeferredData() {

@@ -831,6 +857,7 @@ let value = React.useContext(DeferredContext);

/**
* @private
* A higher-order component that, given a Remix Router instance. setups the
* Context's required for data routing
*/
function useRenderDataRouter(_ref) {
function DataRouterProvider(_ref) {
let {

@@ -840,13 +867,9 @@ basename,

fallbackElement,
routes,
createRouter
router
} = _ref;
if (!routerSingleton) {
routerSingleton = createRouter(routes || createRoutesFromChildren(children)).initialize();
}
let router = routerSingleton; // Sync router state to our component state to force re-renders
let state = useSyncExternalStore(router.subscribe, () => router.state);
// Sync router state to our component state to force re-renders
let state = useSyncExternalStore(router.subscribe, () => router.state, // 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
() => router.state);
let navigator = React.useMemo(() => {

@@ -867,2 +890,8 @@ return {

}, [router]);
let dataRouterContext = {
router,
navigator,
static: false,
basename: basename || "/"
};

@@ -874,14 +903,27 @@ if (!state.initialized) {

return /*#__PURE__*/React.createElement(DataRouterContext.Provider, {
value: router
value: dataRouterContext
}, /*#__PURE__*/React.createElement(DataRouterStateContext.Provider, {
value: state
}, /*#__PURE__*/React.createElement(Router, {
value: state,
children: children
}));
}
/**
* A data-aware wrapper for `<Router>` that leverages the Context's provided by
* `<DataRouterProvider>`
*/
function DataRouter() {
let dataRouterContext = React.useContext(DataRouterContext);
!dataRouterContext ? process.env.NODE_ENV !== "production" ? invariant(false, "<DataRouter> may only be rendered within a DataRouterContext") : invariant(false) : void 0;
let {
router,
navigator,
basename
} = dataRouterContext;
return /*#__PURE__*/React.createElement(Router, {
basename: basename,
location: state.location,
navigationType: state.historyAction,
location: router.state.location,
navigationType: router.state.historyAction,
navigator: navigator
}, /*#__PURE__*/React.createElement(DataRoutes, {
routes: routes,
children: children
}))));
}, /*#__PURE__*/React.createElement(Routes, null));
}

@@ -898,15 +940,19 @@ function DataMemoryRouter(_ref2) {

} = _ref2;
return useRenderDataRouter({
basename,
children,
fallbackElement,
routes,
createRouter: routes => createMemoryRouter({
if (!routerSingleton) {
routerSingleton = createMemoryRouter({
basename,
hydrationData,
initialEntries,
initialIndex,
routes,
hydrationData
})
});
routes: routes || createRoutesFromChildren(children)
}).initialize();
}
let router = routerSingleton;
return /*#__PURE__*/React.createElement(DataRouterProvider, {
router: router,
basename: basename,
fallbackElement: fallbackElement
}, /*#__PURE__*/React.createElement(DataRouter, null));
}

@@ -1080,18 +1126,8 @@

} = _ref6;
return useRoutes(createRoutesFromChildren(children), location);
}
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.
/**
* @private
* Used as an extension to <Routes> and accepts a manual `routes` array to be
* instead of using JSX children. Extracted to it's own component to avoid
* conditional usage of `useRoutes` if we have to render a `fallbackElement`
*/
function DataRoutes(_ref7) {
let {
children,
location,
routes
} = _ref7;
return useRoutes(routes || createRoutesFromChildren(children), location);
let routes = dataRouterContext && !children ? dataRouterContext.router.routes : createRoutesFromChildren(children);
return useRoutes(routes, location);
}

@@ -1103,58 +1139,84 @@

*/
function Deferred(_ref8) {
function Deferred(_ref7) {
let {
children,
value,
fallback,
errorElement
} = _ref8;
return /*#__PURE__*/React.createElement(DeferredContext.Provider, {
value: value
}, /*#__PURE__*/React.createElement(React.Suspense, {
fallback: fallback
}, /*#__PURE__*/React.createElement(DeferredWrapper, {
} = _ref7;
return /*#__PURE__*/React.createElement(DeferredErrorBoundary, {
value: value,
errorElement: errorElement
}, typeof children === "function" ? /*#__PURE__*/React.createElement(ResolveDeferred, {
children: children
}) : children)));
}, /*#__PURE__*/React.createElement(ResolveDeferred, null, children));
}
/**
* @private
* Internal wrapper to handle re-throwing the promise to trigger the Suspense
* fallback, or rendering the children/errorElement once the promise resolves
* or rejects
*/
function DeferredWrapper(_ref9) {
let {
children,
errorElement
} = _ref9;
let value = React.useContext(DeferredContext);
class DeferredErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = {
error: null
};
}
if (value instanceof Promise) {
// throw to the suspense boundary
throw value;
static getDerivedStateFromError(error) {
return {
error
};
}
if (isDeferredError(value)) {
if (errorElement) {
return /*#__PURE__*/React.createElement(React.Fragment, null, errorElement);
} else {
// Throw to the nearest route-level error boundary
componentDidCatch(error, errorInfo) {
console.error("<Deferred> caught the following error during render", error, errorInfo);
}
render() {
let {
children,
errorElement,
value
} = this.props; // Handle render errors from this.state, or data errors from context
let error = this.state.error || (isDeferredError(value) ? value : null);
if (error) {
if (errorElement) {
// We have our own errorElement, provide our error and render it
return /*#__PURE__*/React.createElement(DeferredContext.Provider, {
value: error,
children: errorElement
});
} // Throw to the nearest ancestor route-level error boundary
throw error;
}
if (value instanceof Promise) {
// Throw to the suspense boundary
throw value;
}
} // We've resolved successfully, provide the value and render the children
return /*#__PURE__*/React.createElement(DeferredContext.Provider, {
value: value,
children: children
});
}
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
}
/**
* @private
* Indirection to leverage useDeferredData for a render-prop API on <Deferred>
*/
function ResolveDeferred(_ref10) {
function ResolveDeferred(_ref8) {
let {
children
} = _ref10;
return children(useDeferredData());
} = _ref8;
let data = useDeferredData();
if (typeof children === "function") {
return children(data);
}
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
} ///////////////////////////////////////////////////////////////////////////////

@@ -1172,2 +1234,3 @@ // UTILS

function createRoutesFromChildren(children, parentPath) {

@@ -1223,3 +1286,3 @@ if (parentPath === void 0) {

export { DataMemoryRouter, Deferred, MemoryRouter, Navigate, Outlet, Route, Router, Routes, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, createRoutesFromChildren, renderMatches, useActionData, useDeferredData, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useRenderDataRouter, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
export { DataMemoryRouter, Deferred, MemoryRouter, Navigate, Outlet, Route, Router, Routes, DataRouter as UNSAFE_DataRouter, DataRouterContext as UNSAFE_DataRouterContext, DataRouterProvider as UNSAFE_DataRouterProvider, DataRouterStateContext as UNSAFE_DataRouterStateContext, DataStaticRouterContext as UNSAFE_DataStaticRouterContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, createRoutesFromChildren, renderMatches, useActionData, useDeferredData, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
//# sourceMappingURL=index.js.map
import * as React from "react";
import type { HydrationState, InitialEntry, Location, RouteMatch, RouteObject, Router as DataRouter, To } from "@remix-run/router";
import type { HydrationState, InitialEntry, Location, RouteMatch, RouteObject, Router as RemixRouter, To } from "@remix-run/router";
import { Action as NavigationType } from "@remix-run/router";
import { Navigator } from "./context";
import type { ResolvedDeferrable } from "./hooks";
import type { Navigator } from "./context";
/**

@@ -12,11 +11,16 @@ * Unit-testing-only function to reset the router between tests

/**
* @private
* A higher-order component that, given a Remix Router instance. setups the
* Context's required for data routing
*/
export declare function useRenderDataRouter({ basename, children, fallbackElement, routes, createRouter, }: {
export declare function DataRouterProvider({ basename, children, fallbackElement, router, }: {
basename?: string;
children?: React.ReactNode;
fallbackElement?: React.ReactNode;
routes?: RouteObject[];
createRouter: (routes: RouteObject[]) => DataRouter;
router: RemixRouter;
}): React.ReactElement;
/**
* A data-aware wrapper for `<Router>` that leverages the Context's provided by
* `<DataRouterProvider>`
*/
export declare function DataRouter(): JSX.Element;
export interface DataMemoryRouterProps {

@@ -133,8 +137,8 @@ basename?: string;

export declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
export interface DeferredResolveRenderFunction<Data> {
(data: ResolvedDeferrable<Data>): JSX.Element;
export interface DeferredResolveRenderFunction {
(data: Awaited<any>): JSX.Element;
}
export interface DeferredProps<Data> extends Omit<React.SuspenseProps, "children"> {
children: React.ReactNode | DeferredResolveRenderFunction<Data>;
value: Data;
export interface DeferredProps {
children: React.ReactNode | DeferredResolveRenderFunction;
value: any;
errorElement?: React.ReactNode;

@@ -146,11 +150,4 @@ }

*/
export declare function Deferred<Data = any>({ children, value, fallback, errorElement, }: DeferredProps<Data>): JSX.Element;
export interface ResolveDeferredProps<Data> {
children: DeferredResolveRenderFunction<Data>;
}
export declare function Deferred({ children, value, errorElement }: DeferredProps): JSX.Element;
/**
* @private
*/
export declare function ResolveDeferred<Data>({ children, }: ResolveDeferredProps<Data>): JSX.Element;
/**
* Creates a route config from a React "children" object, which is usually

@@ -157,0 +154,0 @@ * either a `<Route>` element or an array of them. Used internally by

import * as React from "react";
import type { History, Location, RouteMatch, Router, To } from "@remix-run/router";
import type { History, Location, RouteMatch, Router, StaticHandlerContext, To } from "@remix-run/router";
import { Action as NavigationType } from "@remix-run/router";
export declare const DataRouterContext: React.Context<Router | null>;
export declare const DataStaticRouterContext: React.Context<StaticHandlerContext | null>;
export interface DataRouterContextObject extends NavigationContextObject {
router: Router;
}
export declare const DataRouterContext: React.Context<DataRouterContextObject | null>;
export declare const DataRouterStateContext: React.Context<import("@remix-run/router").RouterState | null>;

@@ -38,3 +42,3 @@ export declare const DeferredContext: React.Context<any>;

export declare const LocationContext: React.Context<LocationContextObject>;
interface RouteContextObject {
export interface RouteContextObject {
outlet: React.ReactElement | null;

@@ -44,7 +48,3 @@ matches: RouteMatch[];

export declare const RouteContext: React.Context<RouteContextObject>;
interface RouteContextObject {
outlet: React.ReactElement | null;
matches: RouteMatch[];
}
export declare const RouteErrorContext: React.Context<any>;
export {};
import * as React from "react";
import { Location, ParamParseKey, Params, Path, PathMatch, PathPattern, RouteMatch, RouteObject, Router as DataRouter, To } from "@remix-run/router";
import { Location, ParamParseKey, Params, Path, PathMatch, PathPattern, RouteMatch, RouteObject, Router as RemixRouter, To } from "@remix-run/router";
import { Action as NavigationType } from "@remix-run/router";

@@ -116,3 +116,3 @@ import { NavigateOptions } from "./context";

}
export declare function _renderMatches(matches: RouteMatch[] | null, parentMatches?: RouteMatch[], dataRouterState?: DataRouter["state"]): React.ReactElement | null;
export declare function _renderMatches(matches: RouteMatch[] | null, parentMatches?: RouteMatch[], dataRouterState?: RemixRouter["state"]): React.ReactElement | null;
/**

@@ -139,4 +139,4 @@ * Returns the current navigation, defaulting to an "idle" navigation when

params: Params<string>;
data: any;
handle: any;
data: unknown;
handle: unknown;
}[];

@@ -146,11 +146,11 @@ /**

*/
export declare function useLoaderData(): any;
export declare function useLoaderData(): unknown;
/**
* Returns the loaderData for the given routeId
*/
export declare function useRouteLoaderData(routeId: string): any | undefined;
export declare function useRouteLoaderData(routeId: string): unknown;
/**
* Returns the action data for the nearest ancestor Route action
*/
export declare function useActionData(): any;
export declare function useActionData(): unknown;
/**

@@ -161,9 +161,7 @@ * Returns the nearest ancestor Route error, which could be a loader/action

*/
export declare function useRouteError(): any;
export declare type Deferrable<T> = never | T | Promise<T>;
export declare type ResolvedDeferrable<T> = T extends null | undefined ? T : T extends Deferrable<infer T2> ? T2 extends Promise<infer T3> ? T3 : T2 : T;
export declare function useRouteError(): unknown;
/**
* Returns the happy-path data from the nearest ancestor <Deferred /> value
*/
export declare function useDeferredData<Data>(): ResolvedDeferrable<Data>;
export declare function useDeferredData(): unknown;
export {};
/**
* React Router v6.4.0-pre.9
* React Router v6.4.0-pre.10
*

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

/**
* React Router v6.4.0-pre.9
* React Router v6.4.0-pre.10
*

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

*/
import { invariant, resolveTo, joinPaths, matchPath, warning, parsePath, matchRoutes, isDeferredError, isRouteErrorResponse, createMemoryRouter, createMemoryHistory, stripBasename, Action } from '@remix-run/router';
import { invariant, resolveTo, joinPaths, matchPath, warning, parsePath, matchRoutes, isRouteErrorResponse, createMemoryRouter, createMemoryHistory, stripBasename, Action, isDeferredError } from '@remix-run/router';
export { Action as NavigationType, createPath, deferred, generatePath, isDeferredError, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from '@remix-run/router';

@@ -195,2 +195,8 @@ import * as React from 'react';

const DataStaticRouterContext = /*#__PURE__*/React.createContext(null);
{
DataStaticRouterContext.displayName = "DataStaticRouterContext";
}
const DataRouterContext = /*#__PURE__*/React.createContext(null);

@@ -540,3 +546,4 @@

let error = useRouteError();
let message = isRouteErrorResponse(error) ? `${error.status} ${error.statusText}` : error?.message || JSON.stringify(error);
let message = isRouteErrorResponse(error) ? `${error.status} ${error.statusText}` : error instanceof Error ? error.message : JSON.stringify(error);
let stack = error instanceof Error ? error.stack : null;
let lightgrey = "rgba(200,200,200, 0.5)";

@@ -555,5 +562,5 @@ let preStyles = {

}
}, message), error?.stack ? /*#__PURE__*/React.createElement("pre", {
}, message), stack ? /*#__PURE__*/React.createElement("pre", {
style: preStyles
}, error?.stack) : null, /*#__PURE__*/React.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), /*#__PURE__*/React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own\u00A0", /*#__PURE__*/React.createElement("code", {
}, stack) : null, /*#__PURE__*/React.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), /*#__PURE__*/React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own\u00A0", /*#__PURE__*/React.createElement("code", {
style: codeStyles

@@ -618,2 +625,20 @@ }, "errorElement"), " props on\u00A0", /*#__PURE__*/React.createElement("code", {

}
function RenderedRoute({
routeContext,
match,
children
}) {
let dataStaticRouterContext = React.useContext(DataStaticRouterContext); // Track how deep we got in our render pass to emulate SSR componentDidCatch
// in a DataStaticRouter
if (dataStaticRouterContext && match.route.errorElement) {
dataStaticRouterContext._deepestRenderedBoundaryId = match.route.id;
}
return /*#__PURE__*/React.createElement(RouteContext.Provider, {
value: routeContext
}, children);
}
function _renderMatches(matches, parentMatches = [], dataRouterState) {

@@ -645,9 +670,9 @@ if (matches == null) {

let getChildren = () => /*#__PURE__*/React.createElement(RouteContext.Provider, {
children: error ? errorElement : match.route.element !== undefined ? match.route.element : outlet,
value: {
let getChildren = () => /*#__PURE__*/React.createElement(RenderedRoute, {
match: match,
routeContext: {
outlet,
matches: parentMatches.concat(renderedMatches.slice(0, index + 1))
}
}); // Only wrap in an error boundary within data router usages when we have an
}, error ? errorElement : match.route.element !== undefined ? match.route.element : outlet); // Only wrap in an error boundary within data router usages when we have an
// errorElement on this route. Otherwise let it bubble up to an ancestor

@@ -679,3 +704,3 @@ // errorElement

let state = React.useContext(DataRouterStateContext);
!state ? invariant(false, `${hookName} must be used within a DataRouter`) : void 0;
!state ? invariant(false, `${hookName} must be used within a DataRouterStateContext`) : void 0;
return state;

@@ -699,7 +724,7 @@ }

function useRevalidator() {
let router = React.useContext(DataRouterContext);
!router ? invariant(false, `useRevalidator must be used within a DataRouter`) : void 0;
let dataRouterContext = React.useContext(DataRouterContext);
!dataRouterContext ? invariant(false, `useRevalidator must be used within a DataRouterContext`) : void 0;
let state = useDataRouterState(DataRouterHook.UseRevalidator);
return {
revalidate: router.revalidate,
revalidate: dataRouterContext.router.revalidate,
state: state.revalidation

@@ -775,3 +800,3 @@ };

if (deferredValue && isDeferredError(deferredValue)) {
if (deferredValue && deferredValue instanceof Error) {
return deferredValue;

@@ -814,19 +839,17 @@ } // If this was a render error, we put it in a RouteError context inside

/**
* @private
* A higher-order component that, given a Remix Router instance. setups the
* Context's required for data routing
*/
function useRenderDataRouter({
function DataRouterProvider({
basename,
children,
fallbackElement,
routes,
createRouter
router
}) {
if (!routerSingleton) {
routerSingleton = createRouter(routes || createRoutesFromChildren(children)).initialize();
}
let router = routerSingleton; // Sync router state to our component state to force re-renders
let state = useSyncExternalStore(router.subscribe, () => router.state);
// Sync router state to our component state to force re-renders
let state = useSyncExternalStore(router.subscribe, () => router.state, // 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
() => router.state);
let navigator = React.useMemo(() => {

@@ -847,2 +870,8 @@ return {

}, [router]);
let dataRouterContext = {
router,
navigator,
static: false,
basename: basename || "/"
};

@@ -854,14 +883,27 @@ if (!state.initialized) {

return /*#__PURE__*/React.createElement(DataRouterContext.Provider, {
value: router
value: dataRouterContext
}, /*#__PURE__*/React.createElement(DataRouterStateContext.Provider, {
value: state
}, /*#__PURE__*/React.createElement(Router, {
value: state,
children: children
}));
}
/**
* A data-aware wrapper for `<Router>` that leverages the Context's provided by
* `<DataRouterProvider>`
*/
function DataRouter() {
let dataRouterContext = React.useContext(DataRouterContext);
!dataRouterContext ? invariant(false, "<DataRouter> may only be rendered within a DataRouterContext") : void 0;
let {
router,
navigator,
basename
} = dataRouterContext;
return /*#__PURE__*/React.createElement(Router, {
basename: basename,
location: state.location,
navigationType: state.historyAction,
location: router.state.location,
navigationType: router.state.historyAction,
navigator: navigator
}, /*#__PURE__*/React.createElement(DataRoutes, {
routes: routes,
children: children
}))));
}, /*#__PURE__*/React.createElement(Routes, null));
}

@@ -877,15 +919,18 @@ function DataMemoryRouter({

}) {
return useRenderDataRouter({
basename,
children,
fallbackElement,
routes,
createRouter: routes => createMemoryRouter({
if (!routerSingleton) {
routerSingleton = createMemoryRouter({
basename,
hydrationData,
initialEntries,
initialIndex,
routes,
hydrationData
})
});
routes: routes || createRoutesFromChildren(children)
}).initialize();
}
let router = routerSingleton;
return /*#__PURE__*/React.createElement(DataRouterProvider, {
router: router,
basename: basename,
fallbackElement: fallbackElement
}, /*#__PURE__*/React.createElement(DataRouter, null));
}

@@ -1055,17 +1100,8 @@ /**

}) {
return useRoutes(createRoutesFromChildren(children), location);
}
/**
* @private
* Used as an extension to <Routes> and accepts a manual `routes` array to be
* instead of using JSX children. Extracted to it's own component to avoid
* conditional usage of `useRoutes` if we have to render a `fallbackElement`
*/
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.
function DataRoutes({
children,
location,
routes
}) {
return useRoutes(routes || createRoutesFromChildren(children), location);
let routes = dataRouterContext && !children ? dataRouterContext.router.routes : createRoutesFromChildren(children);
return useRoutes(routes, location);
}

@@ -1077,50 +1113,69 @@ /**

function Deferred({
children,
value,
fallback,
errorElement
}) {
return /*#__PURE__*/React.createElement(DeferredContext.Provider, {
value: value
}, /*#__PURE__*/React.createElement(React.Suspense, {
fallback: fallback
}, /*#__PURE__*/React.createElement(DeferredWrapper, {
return /*#__PURE__*/React.createElement(DeferredErrorBoundary, {
value: value,
errorElement: errorElement
}, typeof children === "function" ? /*#__PURE__*/React.createElement(ResolveDeferred, {
children: children
}) : children)));
}, /*#__PURE__*/React.createElement(ResolveDeferred, null, children));
}
/**
* @private
* Internal wrapper to handle re-throwing the promise to trigger the Suspense
* fallback, or rendering the children/errorElement once the promise resolves
* or rejects
*/
function DeferredWrapper({
children,
errorElement
}) {
let value = React.useContext(DeferredContext);
class DeferredErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = {
error: null
};
}
if (value instanceof Promise) {
// throw to the suspense boundary
throw value;
static getDerivedStateFromError(error) {
return {
error
};
}
if (isDeferredError(value)) {
if (errorElement) {
return /*#__PURE__*/React.createElement(React.Fragment, null, errorElement);
} else {
// Throw to the nearest route-level error boundary
componentDidCatch(error, errorInfo) {
console.error("<Deferred> caught the following error during render", error, errorInfo);
}
render() {
let {
children,
errorElement,
value
} = this.props; // Handle render errors from this.state, or data errors from context
let error = this.state.error || (isDeferredError(value) ? value : null);
if (error) {
if (errorElement) {
// We have our own errorElement, provide our error and render it
return /*#__PURE__*/React.createElement(DeferredContext.Provider, {
value: error,
children: errorElement
});
} // Throw to the nearest ancestor route-level error boundary
throw error;
}
if (value instanceof Promise) {
// Throw to the suspense boundary
throw value;
}
} // We've resolved successfully, provide the value and render the children
return /*#__PURE__*/React.createElement(DeferredContext.Provider, {
value: value,
children: children
});
}
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
}
/**
* @private
* Indirection to leverage useDeferredData for a render-prop API on <Deferred>
*/

@@ -1132,3 +1187,9 @@

}) {
return children(useDeferredData());
let data = useDeferredData();
if (typeof children === "function") {
return children(data);
}
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
} ///////////////////////////////////////////////////////////////////////////////

@@ -1146,2 +1207,3 @@ // UTILS

function createRoutesFromChildren(children, parentPath = []) {

@@ -1193,3 +1255,3 @@ let routes = [];

export { DataMemoryRouter, Deferred, MemoryRouter, Navigate, Outlet, Route, Router, Routes, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, createRoutesFromChildren, renderMatches, useActionData, useDeferredData, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useRenderDataRouter, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
export { DataMemoryRouter, Deferred, MemoryRouter, Navigate, Outlet, Route, Router, Routes, DataRouter as UNSAFE_DataRouter, DataRouterContext as UNSAFE_DataRouterContext, DataRouterProvider as UNSAFE_DataRouterProvider, DataRouterStateContext as UNSAFE_DataRouterStateContext, DataStaticRouterContext as UNSAFE_DataStaticRouterContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, createRoutesFromChildren, renderMatches, useActionData, useDeferredData, 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 v6.4.0-pre.9
* React Router v6.4.0-pre.10
*

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

*/
import{invariant as e,resolveTo as t,joinPaths as n,matchPath as r,parsePath as a,matchRoutes as o,isDeferredError as l,isRouteErrorResponse as i,createMemoryRouter as u,createMemoryHistory as s,stripBasename as c,Action as m}from"@remix-run/router";export{Action as NavigationType,createPath,deferred,generatePath,isDeferredError,isRouteErrorResponse,json,matchPath,matchRoutes,parsePath,redirect,resolvePath}from"@remix-run/router";import*as h from"react";const p="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},{useState:d,useEffect:f,useLayoutEffect:v,useDebugValue:E}=h;function g(e){const t=e.getSnapshot,n=e.value;try{const e=t();return!p(n,e)}catch(r){return!0}}const x=!!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement)?function(e,t,n){return t()}:function(e,t,n){const r=t(),[{inst:a},o]=d({inst:{value:r,getSnapshot:t}});return v((()=>{a.value=r,a.getSnapshot=t,g(a)&&o({inst:a})}),[e,r,t]),f((()=>{g(a)&&o({inst:a});return e((()=>{g(a)&&o({inst:a})}))}),[e]),E(r),r},C="useSyncExternalStore"in h?h.useSyncExternalStore:x,y=h.createContext(null),b=h.createContext(null),S=h.createContext(null),R=h.createContext(null),D=h.createContext(null),U=h.createContext({outlet:null,matches:[]}),P=h.createContext(null);function N(t){w()||e(!1);let{basename:r,navigator:a}=h.useContext(R),{hash:o,pathname:l,search:i}=I(t),u=l;return"/"!==r&&(u="/"===l?r:n([r,l])),a.createHref({pathname:u,search:i,hash:o})}function w(){return null!=h.useContext(D)}function k(){return w()||e(!1),h.useContext(D).location}function F(){return h.useContext(D).navigationType}function A(t){w()||e(!1);let{pathname:n}=k();return h.useMemo((()=>r(t,n)),[n,t])}function M(e){return e.filter(((t,n)=>0===n||!t.route.index&&t.pathnameBase!==e[n-1].pathnameBase))}function O(){w()||e(!1);let{basename:r,navigator:a}=h.useContext(R),{matches:o}=h.useContext(U),{pathname:l}=k(),i=JSON.stringify(M(o).map((e=>e.pathnameBase))),u=h.useRef(!1);return h.useEffect((()=>{u.current=!0})),h.useCallback(((e,o={})=>{if(!u.current)return;if("number"==typeof e)return void a.go(e);let s=t(e,JSON.parse(i),l);"/"!==r&&(s.pathname="/"===s.pathname?r:n([r,s.pathname])),(o.replace?a.replace:a.push)(s,o.state,o)}),[r,a,i,l])}const L=h.createContext(null);function B(){return h.useContext(L)}function T(e){let t=h.useContext(U).outlet;return t?h.createElement(L.Provider,{value:e},t):t}function j(){let{matches:e}=h.useContext(U),t=e[e.length-1];return t?t.params:{}}function I(e){let{matches:n}=h.useContext(U),{pathname:r}=k(),a=JSON.stringify(M(n).map((e=>e.pathnameBase)));return h.useMemo((()=>t(e,JSON.parse(a),r)),[e,a,r])}function J(t,r){w()||e(!1);let l=h.useContext(b),{matches:i}=h.useContext(U),u=i[i.length-1],s=u?u.params:{};!u||u.pathname;let c=u?u.pathnameBase:"/";u&&u.route;let m,p=k();if(r){let t="string"==typeof r?a(r):r;"/"===c||t.pathname?.startsWith(c)||e(!1),m=t}else m=p;let d=m.pathname||"/",f="/"===c?d:d.slice(c.length)||"/",v=o(t,{pathname:f});return z(v&&v.map((e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:n([c,e.pathname]),pathnameBase:"/"===e.pathnameBase?c:n([c,e.pathnameBase])}))),i,l||void 0)}function _(){let e=Q(),t=i(e)?`${e.status} ${e.statusText}`:e?.message||JSON.stringify(e),n="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:n},a={padding:"2px 4px",backgroundColor:n};return h.createElement(h.Fragment,null,h.createElement("h2",null,"Unhandled Thrown Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},t),e?.stack?h.createElement("pre",{style:r},e?.stack):null,h.createElement("p",null,"💿 Hey developer 👋"),h.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",h.createElement("code",{style:a},"errorElement")," props on ",h.createElement("code",{style:a},"<Route>")))}class H extends h.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?h.createElement(P.Provider,{value:this.state.error,children:this.props.component}):this.props.children}}function z(t,n=[],r){if(null==t){if(!r?.errors)return null;t=r.matches}let a=t,o=r?.errors;if(null!=o){let t=a.findIndex((e=>e.route.id&&o?.[e.route.id]));t>=0||e(!1),a=a.slice(0,Math.min(a.length,t+1))}return a.reduceRight(((e,t,l)=>{let i=t.route.id?o?.[t.route.id]:null,u=r?t.route.errorElement||h.createElement(_,null):null,s=()=>h.createElement(U.Provider,{children:i?u:void 0!==t.route.element?t.route.element:e,value:{outlet:e,matches:n.concat(a.slice(0,l+1))}});return r&&(t.route.errorElement||0===l)?h.createElement(H,{location:r.location,component:u,error:i,children:s()}):s()}),null)}var V;function $(t){let n=h.useContext(b);return n||e(!1),n}function W(){return $(V.UseNavigation).navigation}function X(){let t=h.useContext(y);t||e(!1);let n=$(V.UseRevalidator);return{revalidate:t.revalidate,state:n.revalidation}}function Y(){let{matches:e,loaderData:t}=$(V.UseMatches);return h.useMemo((()=>e.map((e=>{let{pathname:n,params:r}=e;return{id:e.route.id,pathname:n,params:r,data:t[e.route.id],handle:e.route.handle}}))),[e,t])}function q(){let t=$(V.UseLoaderData),n=h.useContext(U);n||e(!1);let r=n.matches[n.matches.length-1];return r.route.id||e(!1),t.loaderData[r.route.id]}function G(e){return $(V.UseRouteLoaderData).loaderData[e]}function K(){let t=$(V.UseActionData);return h.useContext(U)||e(!1),Object.values(t?.actionData||{})[0]}function Q(){let t=h.useContext(P),n=$(V.UseRouteError),r=h.useContext(U),a=r.matches[r.matches.length-1],o=h.useContext(S);return o&&l(o)?o:t||(r||e(!1),a.route.id||e(!1),n.errors?.[a.route.id])}function Z(){return h.useContext(S)}let ee;function te({basename:e,children:t,fallbackElement:n,routes:r,createRouter:a}){ee||(ee=a(r||pe(t)).initialize());let o=ee,l=C(o.subscribe,(()=>o.state)),i=h.useMemo((()=>({createHref:o.createHref,go:e=>o.navigate(e),push:(e,t,n)=>o.navigate(e,{state:t,resetScroll:n?.resetScroll}),replace:(e,t,n)=>o.navigate(e,{replace:!0,state:t,resetScroll:n?.resetScroll})})),[o]);return l.initialized?h.createElement(y.Provider,{value:o},h.createElement(b.Provider,{value:l},h.createElement(ie,{basename:e,location:l.location,navigationType:l.historyAction,navigator:i},h.createElement(se,{routes:r,children:t})))):h.createElement(h.Fragment,null,n)}function ne({basename:e,children:t,initialEntries:n,initialIndex:r,hydrationData:a,fallbackElement:o,routes:l}){return te({basename:e,children:t,fallbackElement:o,routes:l,createRouter:t=>u({basename:e,initialEntries:n,initialIndex:r,routes:t,hydrationData:a})})}function re({basename:e,children:t,initialEntries:n,initialIndex:r}){let a=h.useRef();null==a.current&&(a.current=s({initialEntries:n,initialIndex:r,v5Compat:!0}));let o=a.current,[l,i]=h.useState({action:o.action,location:o.location});return h.useLayoutEffect((()=>o.listen(i)),[o]),h.createElement(ie,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o})}function ae({to:t,replace:n,state:r}){w()||e(!1);let a=O();return h.useEffect((()=>{a(t,{replace:n,state:r})})),null}function oe(e){return T(e.context)}function le(t){e(!1)}function ie({basename:t="/",children:n=null,location:r,navigationType:o=m.Pop,navigator:l,static:i=!1}){w()&&e(!1);let u=t.replace(/^\/*/,"/"),s=h.useMemo((()=>({basename:u,navigator:l,static:i})),[u,l,i]);"string"==typeof r&&(r=a(r));let{pathname:p="/",search:d="",hash:f="",state:v=null,key:E="default"}=r,g=h.useMemo((()=>{let e=c(p,u);return null==e?null:{pathname:e,search:d,hash:f,state:v,key:E}}),[u,p,d,f,v,E]);return null==g?null:h.createElement(R.Provider,{value:s},h.createElement(D.Provider,{children:n,value:{location:g,navigationType:o}}))}function ue({children:e,location:t}){return J(pe(e),t)}function se({children:e,location:t,routes:n}){return J(n||pe(e),t)}function ce({children:e,value:t,fallback:n,errorElement:r}){return h.createElement(S.Provider,{value:t},h.createElement(h.Suspense,{fallback:n},h.createElement(me,{errorElement:r},"function"==typeof e?h.createElement(he,{children:e}):e)))}function me({children:e,errorElement:t}){let n=h.useContext(S);if(n instanceof Promise)throw n;if(l(n)){if(t)return h.createElement(h.Fragment,null,t);throw n}return h.createElement(h.Fragment,null,e)}function he({children:e}){return e(Z())}function pe(t,n=[]){let r=[];return h.Children.forEach(t,((t,a)=>{if(!h.isValidElement(t))return;if(t.type===h.Fragment)return void r.push.apply(r,pe(t.props.children,n));t.type!==le&&e(!1);let o=[...n,a],l={id:t.props.id||o.join("-"),caseSensitive:t.props.caseSensitive,element:t.props.element,index:t.props.index,path:t.props.path,loader:t.props.loader,action:t.props.action,errorElement:t.props.errorElement,shouldRevalidate:t.props.shouldRevalidate,handle:t.props.handle};t.props.children&&(l.children=pe(t.props.children,o)),r.push(l)})),r}function de(e){return z(e)}!function(e){e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator"}(V||(V={}));export{ne as DataMemoryRouter,ce as Deferred,re as MemoryRouter,ae as Navigate,oe as Outlet,le as Route,ie as Router,ue as Routes,y as UNSAFE_DataRouterContext,b as UNSAFE_DataRouterStateContext,D as UNSAFE_LocationContext,R as UNSAFE_NavigationContext,U as UNSAFE_RouteContext,pe as createRoutesFromChildren,de as renderMatches,K as useActionData,Z as useDeferredData,N as useHref,w as useInRouterContext,q as useLoaderData,k as useLocation,A as useMatch,Y as useMatches,O as useNavigate,W as useNavigation,F as useNavigationType,T as useOutlet,B as useOutletContext,j as useParams,te as useRenderDataRouter,I as useResolvedPath,X as useRevalidator,Q as useRouteError,G as useRouteLoaderData,J as useRoutes};
import{invariant as e,resolveTo as t,joinPaths as r,matchPath as n,parsePath as a,matchRoutes as o,isRouteErrorResponse as l,createMemoryRouter as i,createMemoryHistory as u,stripBasename as s,Action as c,isDeferredError as m}from"@remix-run/router";export{Action as NavigationType,createPath,deferred,generatePath,isDeferredError,isRouteErrorResponse,json,matchPath,matchRoutes,parsePath,redirect,resolvePath}from"@remix-run/router";import*as h from"react";const d="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},{useState:p,useEffect:f,useLayoutEffect:E,useDebugValue:v}=h;function g(e){const t=e.getSnapshot,r=e.value;try{const e=t();return!d(r,e)}catch(n){return!0}}const x=!!("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:a},o]=p({inst:{value:n,getSnapshot:t}});return E((()=>{a.value=n,a.getSnapshot=t,g(a)&&o({inst:a})}),[e,n,t]),f((()=>{g(a)&&o({inst:a});return e((()=>{g(a)&&o({inst:a})}))}),[e]),v(n),n},C="useSyncExternalStore"in h?h.useSyncExternalStore:x,y=h.createContext(null),S=h.createContext(null),b=h.createContext(null),D=h.createContext(null),R=h.createContext(null),U=h.createContext(null),N=h.createContext({outlet:null,matches:[]}),P=h.createContext(null);function w(t){F()||e(!1);let{basename:n,navigator:a}=h.useContext(R),{hash:o,pathname:l,search:i}=I(t),u=l;return"/"!==n&&(u="/"===l?n:r([n,l])),a.createHref({pathname:u,search:i,hash:o})}function F(){return null!=h.useContext(U)}function A(){return F()||e(!1),h.useContext(U).location}function M(){return h.useContext(U).navigationType}function O(t){F()||e(!1);let{pathname:r}=A();return h.useMemo((()=>n(t,r)),[r,t])}function k(e){return e.filter(((t,r)=>0===r||!t.route.index&&t.pathnameBase!==e[r-1].pathnameBase))}function B(){F()||e(!1);let{basename:n,navigator:a}=h.useContext(R),{matches:o}=h.useContext(N),{pathname:l}=A(),i=JSON.stringify(k(o).map((e=>e.pathnameBase))),u=h.useRef(!1);return h.useEffect((()=>{u.current=!0})),h.useCallback(((e,o={})=>{if(!u.current)return;if("number"==typeof e)return void a.go(e);let s=t(e,JSON.parse(i),l);"/"!==n&&(s.pathname="/"===s.pathname?n:r([n,s.pathname])),(o.replace?a.replace:a.push)(s,o.state,o)}),[n,a,i,l])}const L=h.createContext(null);function _(){return h.useContext(L)}function T(e){let t=h.useContext(N).outlet;return t?h.createElement(L.Provider,{value:e},t):t}function j(){let{matches:e}=h.useContext(N),t=e[e.length-1];return t?t.params:{}}function I(e){let{matches:r}=h.useContext(N),{pathname:n}=A(),a=JSON.stringify(k(r).map((e=>e.pathnameBase)));return h.useMemo((()=>t(e,JSON.parse(a),n)),[e,a,n])}function J(t,n){F()||e(!1);let l=h.useContext(b),{matches:i}=h.useContext(N),u=i[i.length-1],s=u?u.params:{};!u||u.pathname;let c=u?u.pathnameBase:"/";u&&u.route;let m,d=A();if(n){let t="string"==typeof n?a(n):n;"/"===c||t.pathname?.startsWith(c)||e(!1),m=t}else m=d;let p=m.pathname||"/",f="/"===c?p:p.slice(c.length)||"/",E=o(t,{pathname:f});return $(E&&E.map((e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:r([c,e.pathname]),pathnameBase:"/"===e.pathnameBase?c:r([c,e.pathnameBase])}))),i,l||void 0)}function H(){let e=ee(),t=l(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:n},o={padding:"2px 4px",backgroundColor:n};return h.createElement(h.Fragment,null,h.createElement("h2",null,"Unhandled Thrown Error!"),h.createElement("h3",{style:{fontStyle:"italic"}},t),r?h.createElement("pre",{style:a},r):null,h.createElement("p",null,"💿 Hey developer 👋"),h.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",h.createElement("code",{style:o},"errorElement")," props on ",h.createElement("code",{style:o},"<Route>")))}class z extends h.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?h.createElement(P.Provider,{value:this.state.error,children:this.props.component}):this.props.children}}function V({routeContext:e,match:t,children:r}){let n=h.useContext(y);return n&&t.route.errorElement&&(n._deepestRenderedBoundaryId=t.route.id),h.createElement(N.Provider,{value:e},r)}function $(t,r=[],n){if(null==t){if(!n?.errors)return null;t=n.matches}let a=t,o=n?.errors;if(null!=o){let t=a.findIndex((e=>e.route.id&&o?.[e.route.id]));t>=0||e(!1),a=a.slice(0,Math.min(a.length,t+1))}return a.reduceRight(((e,t,l)=>{let i=t.route.id?o?.[t.route.id]:null,u=n?t.route.errorElement||h.createElement(H,null):null,s=()=>h.createElement(V,{match:t,routeContext:{outlet:e,matches:r.concat(a.slice(0,l+1))}},i?u:void 0!==t.route.element?t.route.element:e);return n&&(t.route.errorElement||0===l)?h.createElement(z,{location:n.location,component:u,error:i,children:s()}):s()}),null)}var W;function X(t){let r=h.useContext(b);return r||e(!1),r}function Y(){return X(W.UseNavigation).navigation}function q(){let t=h.useContext(S);t||e(!1);let r=X(W.UseRevalidator);return{revalidate:t.router.revalidate,state:r.revalidation}}function G(){let{matches:e,loaderData:t}=X(W.UseMatches);return h.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 K(){let t=X(W.UseLoaderData),r=h.useContext(N);r||e(!1);let n=r.matches[r.matches.length-1];return n.route.id||e(!1),t.loaderData[n.route.id]}function Q(e){return X(W.UseRouteLoaderData).loaderData[e]}function Z(){let t=X(W.UseActionData);return h.useContext(N)||e(!1),Object.values(t?.actionData||{})[0]}function ee(){let t=h.useContext(P),r=X(W.UseRouteError),n=h.useContext(N),a=n.matches[n.matches.length-1],o=h.useContext(D);return o&&o instanceof Error?o:t||(n||e(!1),a.route.id||e(!1),r.errors?.[a.route.id])}function te(){return h.useContext(D)}let re;function ne({basename:e,children:t,fallbackElement:r,router:n}){let a=C(n.subscribe,(()=>n.state),(()=>n.state)),o=h.useMemo((()=>({createHref:n.createHref,go:e=>n.navigate(e),push:(e,t,r)=>n.navigate(e,{state:t,resetScroll:r?.resetScroll}),replace:(e,t,r)=>n.navigate(e,{replace:!0,state:t,resetScroll:r?.resetScroll})})),[n]),l={router:n,navigator:o,static:!1,basename:e||"/"};return a.initialized?h.createElement(S.Provider,{value:l},h.createElement(b.Provider,{value:a,children:t})):h.createElement(h.Fragment,null,r)}function ae(){let t=h.useContext(S);t||e(!1);let{router:r,navigator:n,basename:a}=t;return h.createElement(ce,{basename:a,location:r.state.location,navigationType:r.state.historyAction,navigator:n},h.createElement(me,null))}function oe({basename:e,children:t,initialEntries:r,initialIndex:n,hydrationData:a,fallbackElement:o,routes:l}){re||(re=i({basename:e,hydrationData:a,initialEntries:r,initialIndex:n,routes:l||fe(t)}).initialize());let u=re;return h.createElement(ne,{router:u,basename:e,fallbackElement:o},h.createElement(ae,null))}function le({basename:e,children:t,initialEntries:r,initialIndex:n}){let a=h.useRef();null==a.current&&(a.current=u({initialEntries:r,initialIndex:n,v5Compat:!0}));let o=a.current,[l,i]=h.useState({action:o.action,location:o.location});return h.useLayoutEffect((()=>o.listen(i)),[o]),h.createElement(ce,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o})}function ie({to:t,replace:r,state:n}){F()||e(!1);let a=B();return h.useEffect((()=>{a(t,{replace:r,state:n})})),null}function ue(e){return T(e.context)}function se(t){e(!1)}function ce({basename:t="/",children:r=null,location:n,navigationType:o=c.Pop,navigator:l,static:i=!1}){F()&&e(!1);let u=t.replace(/^\/*/,"/"),m=h.useMemo((()=>({basename:u,navigator:l,static:i})),[u,l,i]);"string"==typeof n&&(n=a(n));let{pathname:d="/",search:p="",hash:f="",state:E=null,key:v="default"}=n,g=h.useMemo((()=>{let e=s(d,u);return null==e?null:{pathname:e,search:p,hash:f,state:E,key:v}}),[u,d,p,f,E,v]);return null==g?null:h.createElement(R.Provider,{value:m},h.createElement(U.Provider,{children:r,value:{location:g,navigationType:o}}))}function me({children:e,location:t}){let r=h.useContext(S);return J(r&&!e?r.router.routes:fe(e),t)}function he({children:e,value:t,errorElement:r}){return h.createElement(de,{value:t,errorElement:r},h.createElement(pe,null,e))}!function(e){e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator"}(W||(W={}));class de extends h.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error("<Deferred> caught the following error during render",e,t)}render(){let{children:e,errorElement:t,value:r}=this.props,n=this.state.error||(m(r)?r:null);if(n){if(t)return h.createElement(D.Provider,{value:n,children:t});throw n}if(r instanceof Promise)throw r;return h.createElement(D.Provider,{value:r,children:e})}}function pe({children:e}){let t=te();return"function"==typeof e?e(t):h.createElement(h.Fragment,null,e)}function fe(t,r=[]){let n=[];return h.Children.forEach(t,((t,a)=>{if(!h.isValidElement(t))return;if(t.type===h.Fragment)return void n.push.apply(n,fe(t.props.children,r));t.type!==se&&e(!1);let o=[...r,a],l={id:t.props.id||o.join("-"),caseSensitive:t.props.caseSensitive,element:t.props.element,index:t.props.index,path:t.props.path,loader:t.props.loader,action:t.props.action,errorElement:t.props.errorElement,shouldRevalidate:t.props.shouldRevalidate,handle:t.props.handle};t.props.children&&(l.children=fe(t.props.children,o)),n.push(l)})),n}function Ee(e){return $(e)}export{oe as DataMemoryRouter,he as Deferred,le as MemoryRouter,ie as Navigate,ue as Outlet,se as Route,ce as Router,me as Routes,ae as UNSAFE_DataRouter,S as UNSAFE_DataRouterContext,ne as UNSAFE_DataRouterProvider,b as UNSAFE_DataRouterStateContext,y as UNSAFE_DataStaticRouterContext,U as UNSAFE_LocationContext,R as UNSAFE_NavigationContext,N as UNSAFE_RouteContext,fe as createRoutesFromChildren,Ee as renderMatches,Z as useActionData,te as useDeferredData,w as useHref,F as useInRouterContext,K as useLoaderData,A as useLocation,O as useMatch,G as useMatches,B as useNavigate,Y as useNavigation,M as useNavigationType,T as useOutlet,_ as useOutletContext,j as useParams,I as useResolvedPath,q as useRevalidator,ee as useRouteError,Q as useRouteLoaderData,J as useRoutes};
//# sourceMappingURL=react-router.production.min.js.map
/**
* React Router v6.4.0-pre.9
* React Router v6.4.0-pre.10
*

@@ -217,2 +217,8 @@ * Copyright (c) Remix Software Inc.

// Contexts for data routers
const DataStaticRouterContext = /*#__PURE__*/React__namespace.createContext(null);
{
DataStaticRouterContext.displayName = "DataStaticRouterContext";
}
const DataRouterContext = /*#__PURE__*/React__namespace.createContext(null);

@@ -571,3 +577,4 @@

let error = useRouteError();
let message = router.isRouteErrorResponse(error) ? error.status + " " + error.statusText : (error == null ? void 0 : error.message) || JSON.stringify(error);
let message = router.isRouteErrorResponse(error) ? error.status + " " + error.statusText : error instanceof Error ? error.message : JSON.stringify(error);
let stack = error instanceof Error ? error.stack : null;
let lightgrey = "rgba(200,200,200, 0.5)";

@@ -586,5 +593,5 @@ let preStyles = {

}
}, message), error != null && error.stack ? /*#__PURE__*/React__namespace.createElement("pre", {
}, message), stack ? /*#__PURE__*/React__namespace.createElement("pre", {
style: preStyles
}, error == null ? void 0 : error.stack) : null, /*#__PURE__*/React__namespace.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), /*#__PURE__*/React__namespace.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own\xA0", /*#__PURE__*/React__namespace.createElement("code", {
}, stack) : null, /*#__PURE__*/React__namespace.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), /*#__PURE__*/React__namespace.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own\xA0", /*#__PURE__*/React__namespace.createElement("code", {
style: codeStyles

@@ -649,2 +656,21 @@ }, "errorElement"), " props on\xA0", /*#__PURE__*/React__namespace.createElement("code", {

}
function RenderedRoute(_ref) {
let {
routeContext,
match,
children
} = _ref;
let dataStaticRouterContext = React__namespace.useContext(DataStaticRouterContext); // Track how deep we got in our render pass to emulate SSR componentDidCatch
// in a DataStaticRouter
if (dataStaticRouterContext && match.route.errorElement) {
dataStaticRouterContext._deepestRenderedBoundaryId = match.route.id;
}
return /*#__PURE__*/React__namespace.createElement(RouteContext.Provider, {
value: routeContext
}, children);
}
function _renderMatches(matches, parentMatches, dataRouterState) {

@@ -680,9 +706,9 @@ if (parentMatches === void 0) {

let getChildren = () => /*#__PURE__*/React__namespace.createElement(RouteContext.Provider, {
children: error ? errorElement : match.route.element !== undefined ? match.route.element : outlet,
value: {
let getChildren = () => /*#__PURE__*/React__namespace.createElement(RenderedRoute, {
match: match,
routeContext: {
outlet,
matches: parentMatches.concat(renderedMatches.slice(0, index + 1))
}
}); // Only wrap in an error boundary within data router usages when we have an
}, error ? errorElement : match.route.element !== undefined ? match.route.element : outlet); // Only wrap in an error boundary within data router usages when we have an
// errorElement on this route. Otherwise let it bubble up to an ancestor

@@ -714,3 +740,3 @@ // errorElement

let state = React__namespace.useContext(DataRouterStateContext);
!state ? router.invariant(false, hookName + " must be used within a DataRouter") : void 0;
!state ? router.invariant(false, hookName + " must be used within a DataRouterStateContext") : void 0;
return state;

@@ -734,7 +760,7 @@ }

function useRevalidator() {
let router$1 = React__namespace.useContext(DataRouterContext);
!router$1 ? router.invariant(false, "useRevalidator must be used within a DataRouter") : void 0;
let dataRouterContext = React__namespace.useContext(DataRouterContext);
!dataRouterContext ? router.invariant(false, "useRevalidator must be used within a DataRouterContext") : void 0;
let state = useDataRouterState(DataRouterHook.UseRevalidator);
return {
revalidate: router$1.revalidate,
revalidate: dataRouterContext.router.revalidate,
state: state.revalidation

@@ -812,3 +838,3 @@ };

if (deferredValue && router.isDeferredError(deferredValue)) {
if (deferredValue && deferredValue instanceof Error) {
return deferredValue;

@@ -828,6 +854,6 @@ } // If this was a render error, we put it in a RouteError context inside

}
/**
* Returns the happy-path data from the nearest ancestor <Deferred /> value
*/
function useDeferredData() {

@@ -852,6 +878,7 @@ let value = React__namespace.useContext(DeferredContext);

/**
* @private
* A higher-order component that, given a Remix Router instance. setups the
* Context's required for data routing
*/
function useRenderDataRouter(_ref) {
function DataRouterProvider(_ref) {
let {

@@ -861,13 +888,9 @@ basename,

fallbackElement,
routes,
createRouter
router
} = _ref;
if (!routerSingleton) {
routerSingleton = createRouter(routes || createRoutesFromChildren(children)).initialize();
}
let router = routerSingleton; // Sync router state to our component state to force re-renders
let state = useSyncExternalStore(router.subscribe, () => router.state);
// Sync router state to our component state to force re-renders
let state = useSyncExternalStore(router.subscribe, () => router.state, // 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
() => router.state);
let navigator = React__namespace.useMemo(() => {

@@ -888,2 +911,8 @@ return {

}, [router]);
let dataRouterContext = {
router,
navigator,
static: false,
basename: basename || "/"
};

@@ -895,14 +924,27 @@ if (!state.initialized) {

return /*#__PURE__*/React__namespace.createElement(DataRouterContext.Provider, {
value: router
value: dataRouterContext
}, /*#__PURE__*/React__namespace.createElement(DataRouterStateContext.Provider, {
value: state
}, /*#__PURE__*/React__namespace.createElement(Router, {
value: state,
children: children
}));
}
/**
* A data-aware wrapper for `<Router>` that leverages the Context's provided by
* `<DataRouterProvider>`
*/
function DataRouter() {
let dataRouterContext = React__namespace.useContext(DataRouterContext);
!dataRouterContext ? router.invariant(false, "<DataRouter> may only be rendered within a DataRouterContext") : void 0;
let {
router: router$1,
navigator,
basename
} = dataRouterContext;
return /*#__PURE__*/React__namespace.createElement(Router, {
basename: basename,
location: state.location,
navigationType: state.historyAction,
location: router$1.state.location,
navigationType: router$1.state.historyAction,
navigator: navigator
}, /*#__PURE__*/React__namespace.createElement(DataRoutes, {
routes: routes,
children: children
}))));
}, /*#__PURE__*/React__namespace.createElement(Routes, null));
}

@@ -919,15 +961,19 @@ function DataMemoryRouter(_ref2) {

} = _ref2;
return useRenderDataRouter({
basename,
children,
fallbackElement,
routes,
createRouter: routes => router.createMemoryRouter({
if (!routerSingleton) {
routerSingleton = router.createMemoryRouter({
basename,
hydrationData,
initialEntries,
initialIndex,
routes,
hydrationData
})
});
routes: routes || createRoutesFromChildren(children)
}).initialize();
}
let router$1 = routerSingleton;
return /*#__PURE__*/React__namespace.createElement(DataRouterProvider, {
router: router$1,
basename: basename,
fallbackElement: fallbackElement
}, /*#__PURE__*/React__namespace.createElement(DataRouter, null));
}

@@ -1101,18 +1147,8 @@

} = _ref6;
return useRoutes(createRoutesFromChildren(children), location);
}
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.
/**
* @private
* Used as an extension to <Routes> and accepts a manual `routes` array to be
* instead of using JSX children. Extracted to it's own component to avoid
* conditional usage of `useRoutes` if we have to render a `fallbackElement`
*/
function DataRoutes(_ref7) {
let {
children,
location,
routes
} = _ref7;
return useRoutes(routes || createRoutesFromChildren(children), location);
let routes = dataRouterContext && !children ? dataRouterContext.router.routes : createRoutesFromChildren(children);
return useRoutes(routes, location);
}

@@ -1124,58 +1160,84 @@

*/
function Deferred(_ref8) {
function Deferred(_ref7) {
let {
children,
value,
fallback,
errorElement
} = _ref8;
return /*#__PURE__*/React__namespace.createElement(DeferredContext.Provider, {
value: value
}, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
fallback: fallback
}, /*#__PURE__*/React__namespace.createElement(DeferredWrapper, {
} = _ref7;
return /*#__PURE__*/React__namespace.createElement(DeferredErrorBoundary, {
value: value,
errorElement: errorElement
}, typeof children === "function" ? /*#__PURE__*/React__namespace.createElement(ResolveDeferred, {
children: children
}) : children)));
}, /*#__PURE__*/React__namespace.createElement(ResolveDeferred, null, children));
}
/**
* @private
* Internal wrapper to handle re-throwing the promise to trigger the Suspense
* fallback, or rendering the children/errorElement once the promise resolves
* or rejects
*/
function DeferredWrapper(_ref9) {
let {
children,
errorElement
} = _ref9;
let value = React__namespace.useContext(DeferredContext);
class DeferredErrorBoundary extends React__namespace.Component {
constructor(props) {
super(props);
this.state = {
error: null
};
}
if (value instanceof Promise) {
// throw to the suspense boundary
throw value;
static getDerivedStateFromError(error) {
return {
error
};
}
if (router.isDeferredError(value)) {
if (errorElement) {
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, errorElement);
} else {
// Throw to the nearest route-level error boundary
componentDidCatch(error, errorInfo) {
console.error("<Deferred> caught the following error during render", error, errorInfo);
}
render() {
let {
children,
errorElement,
value
} = this.props; // Handle render errors from this.state, or data errors from context
let error = this.state.error || (router.isDeferredError(value) ? value : null);
if (error) {
if (errorElement) {
// We have our own errorElement, provide our error and render it
return /*#__PURE__*/React__namespace.createElement(DeferredContext.Provider, {
value: error,
children: errorElement
});
} // Throw to the nearest ancestor route-level error boundary
throw error;
}
if (value instanceof Promise) {
// Throw to the suspense boundary
throw value;
}
} // We've resolved successfully, provide the value and render the children
return /*#__PURE__*/React__namespace.createElement(DeferredContext.Provider, {
value: value,
children: children
});
}
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, children);
}
/**
* @private
* Indirection to leverage useDeferredData for a render-prop API on <Deferred>
*/
function ResolveDeferred(_ref10) {
function ResolveDeferred(_ref8) {
let {
children
} = _ref10;
return children(useDeferredData());
} = _ref8;
let data = useDeferredData();
if (typeof children === "function") {
return children(data);
}
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, children);
} ///////////////////////////////////////////////////////////////////////////////

@@ -1193,2 +1255,3 @@ // UTILS

function createRoutesFromChildren(children, parentPath) {

@@ -1300,4 +1363,7 @@ if (parentPath === void 0) {

exports.Routes = Routes;
exports.UNSAFE_DataRouter = DataRouter;
exports.UNSAFE_DataRouterContext = DataRouterContext;
exports.UNSAFE_DataRouterProvider = DataRouterProvider;
exports.UNSAFE_DataRouterStateContext = DataRouterStateContext;
exports.UNSAFE_DataStaticRouterContext = DataStaticRouterContext;
exports.UNSAFE_LocationContext = LocationContext;

@@ -1322,3 +1388,2 @@ exports.UNSAFE_NavigationContext = NavigationContext;

exports.useParams = useParams;
exports.useRenderDataRouter = useRenderDataRouter;
exports.useResolvedPath = useResolvedPath;

@@ -1325,0 +1390,0 @@ exports.useRevalidator = useRevalidator;

/**
* React Router v6.4.0-pre.9
* React Router v6.4.0-pre.10
*

@@ -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.Router,e.React)}(this,(function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var a=r(n);const o="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}=a;function c(e){const t=e.getSnapshot,n=e.value;try{const e=t();return!o(n,e)}catch(e){return!0}}const d=!!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement)?function(e,t,n){return t()}:function(e,t,n){const r=t(),[{inst:a},o]=i({inst:{value:r,getSnapshot:t}});return l((()=>{a.value=r,a.getSnapshot=t,c(a)&&o({inst:a})}),[e,r,t]),u((()=>{c(a)&&o({inst:a});return e((()=>{c(a)&&o({inst:a})}))}),[e]),s(r),r},m="useSyncExternalStore"in a?(e=>e.useSyncExternalStore)(a):d,h=a.createContext(null),p=a.createContext(null),f=a.createContext(null),v=a.createContext(null),g=a.createContext(null),E=a.createContext({outlet:null,matches:[]}),b=a.createContext(null);function y(){return null!=a.useContext(g)}function x(){return y()||t.invariant(!1),a.useContext(g).location}function R(e){return e.filter(((t,n)=>0===n||!t.route.index&&t.pathnameBase!==e[n-1].pathnameBase))}function P(){y()||t.invariant(!1);let{basename:e,navigator:n}=a.useContext(v),{matches:r}=a.useContext(E),{pathname:o}=x(),i=JSON.stringify(R(r).map((e=>e.pathnameBase))),u=a.useRef(!1);return a.useEffect((()=>{u.current=!0})),a.useCallback((function(r,a){if(void 0===a&&(a={}),!u.current)return;if("number"==typeof r)return void n.go(r);let l=t.resolveTo(r,JSON.parse(i),o);"/"!==e&&(l.pathname="/"===l.pathname?e:t.joinPaths([e,l.pathname])),(a.replace?n.replace:n.push)(l,a.state,a)}),[e,n,i,o])}const C=a.createContext(null);function D(e){let t=a.useContext(E).outlet;return t?a.createElement(C.Provider,{value:e},t):t}function O(e){let{matches:n}=a.useContext(E),{pathname:r}=x(),o=JSON.stringify(R(n).map((e=>e.pathnameBase)));return a.useMemo((()=>t.resolveTo(e,JSON.parse(o),r)),[e,o,r])}function j(e,n){y()||t.invariant(!1);let r=a.useContext(p),{matches:o}=a.useContext(E),i=o[o.length-1],u=i?i.params:{};!i||i.pathname;let l=i?i.pathnameBase:"/";i&&i.route;let s,c=x();if(n){var d;let e="string"==typeof n?t.parsePath(n):n;"/"===l||(null==(d=e.pathname)?void 0:d.startsWith(l))||t.invariant(!1),s=e}else s=c;let m=s.pathname||"/",h="/"===l?m:m.slice(l.length)||"/",f=t.matchRoutes(e,{pathname:h});return M(f&&f.map((e=>Object.assign({},e,{params:Object.assign({},u,e.params),pathname:t.joinPaths([l,e.pathname]),pathnameBase:"/"===e.pathnameBase?l:t.joinPaths([l,e.pathnameBase])}))),o,r||void 0)}function S(){let e=k(),n=t.isRouteErrorResponse(e)?e.status+" "+e.statusText:(null==e?void 0:e.message)||JSON.stringify(e),r="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:r},i={padding:"2px 4px",backgroundColor:r};return a.createElement(a.Fragment,null,a.createElement("h2",null,"Unhandled Thrown Error!"),a.createElement("h3",{style:{fontStyle:"italic"}},n),null!=e&&e.stack?a.createElement("pre",{style:o},null==e?void 0:e.stack):null,a.createElement("p",null,"💿 Hey developer 👋"),a.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",a.createElement("code",{style:i},"errorElement")," props on ",a.createElement("code",{style:i},"<Route>")))}class U extends a.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?a.createElement(b.Provider,{value:this.state.error,children:this.props.component}):this.props.children}}function M(e,n,r){if(void 0===n&&(n=[]),null==e){if(null==r||!r.errors)return null;e=r.matches}let o=e,i=null==r?void 0:r.errors;if(null!=i){let e=o.findIndex((e=>e.route.id&&(null==i?void 0:i[e.route.id])));e>=0||t.invariant(!1),o=o.slice(0,Math.min(o.length,e+1))}return o.reduceRight(((e,t,u)=>{let l=t.route.id?null==i?void 0:i[t.route.id]:null,s=r?t.route.errorElement||a.createElement(S,null):null,c=()=>a.createElement(E.Provider,{children:l?s:void 0!==t.route.element?t.route.element:e,value:{outlet:e,matches:n.concat(o.slice(0,u+1))}});return r&&(t.route.errorElement||0===u)?a.createElement(U,{location:r.location,component:s,error:l,children:c()}):c()}),null)}var N;function w(e){let n=a.useContext(p);return n||t.invariant(!1),n}function k(){var e;let n=a.useContext(b),r=w(N.UseRouteError),o=a.useContext(E),i=o.matches[o.matches.length-1],u=a.useContext(f);return u&&t.isDeferredError(u)?u:n||(o||t.invariant(!1),i.route.id||t.invariant(!1),null==(e=r.errors)?void 0:e[i.route.id])}function F(){return a.useContext(f)}let T;function A(e){let{basename:t,children:n,fallbackElement:r,routes:o,createRouter:i}=e;T||(T=i(o||J(n)).initialize());let u=T,l=m(u.subscribe,(()=>u.state)),s=a.useMemo((()=>({createHref:u.createHref,go:e=>u.navigate(e),push:(e,t,n)=>u.navigate(e,{state:t,resetScroll:null==n?void 0:n.resetScroll}),replace:(e,t,n)=>u.navigate(e,{replace:!0,state:t,resetScroll:null==n?void 0:n.resetScroll})})),[u]);return l.initialized?a.createElement(h.Provider,{value:u},a.createElement(p.Provider,{value:l},a.createElement(B,{basename:t,location:l.location,navigationType:l.historyAction,navigator:s},a.createElement(_,{routes:o,children:n})))):a.createElement(a.Fragment,null,r)}function L(e){t.invariant(!1)}function B(e){let{basename:n="/",children:r=null,location:o,navigationType:i=t.Action.Pop,navigator:u,static:l=!1}=e;y()&&t.invariant(!1);let s=n.replace(/^\/*/,"/"),c=a.useMemo((()=>({basename:s,navigator:u,static:l})),[s,u,l]);"string"==typeof o&&(o=t.parsePath(o));let{pathname:d="/",search:m="",hash:h="",state:p=null,key:f="default"}=o,E=a.useMemo((()=>{let e=t.stripBasename(d,s);return null==e?null:{pathname:e,search:m,hash:h,state:p,key:f}}),[s,d,m,h,p,f]);return null==E?null:a.createElement(v.Provider,{value:c},a.createElement(g.Provider,{children:r,value:{location:E,navigationType:i}}))}function _(e){let{children:t,location:n,routes:r}=e;return j(r||J(t),n)}function H(e){let{children:n,errorElement:r}=e,o=a.useContext(f);if(o instanceof Promise)throw o;if(t.isDeferredError(o)){if(r)return a.createElement(a.Fragment,null,r);throw o}return a.createElement(a.Fragment,null,n)}function I(e){let{children:t}=e;return t(F())}function J(e,n){void 0===n&&(n=[]);let r=[];return a.Children.forEach(e,((e,o)=>{if(!a.isValidElement(e))return;if(e.type===a.Fragment)return void r.push.apply(r,J(e.props.children,n));e.type!==L&&t.invariant(!1);let i=[...n,o],u={id:e.props.id||i.join("-"),caseSensitive:e.props.caseSensitive,element:e.props.element,index:e.props.index,path:e.props.path,loader:e.props.loader,action:e.props.action,errorElement:e.props.errorElement,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle};e.props.children&&(u.children=J(e.props.children,i)),r.push(u)})),r}!function(e){e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator"}(N||(N={})),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,"deferred",{enumerable:!0,get:function(){return t.deferred}}),Object.defineProperty(e,"generatePath",{enumerable:!0,get:function(){return t.generatePath}}),Object.defineProperty(e,"isDeferredError",{enumerable:!0,get:function(){return t.isDeferredError}}),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.DataMemoryRouter=function(e){let{basename:n,children:r,initialEntries:a,initialIndex:o,hydrationData:i,fallbackElement:u,routes:l}=e;return A({basename:n,children:r,fallbackElement:u,routes:l,createRouter:e=>t.createMemoryRouter({basename:n,initialEntries:a,initialIndex:o,routes:e,hydrationData:i})})},e.Deferred=function(e){let{children:t,value:n,fallback:r,errorElement:o}=e;return a.createElement(f.Provider,{value:n},a.createElement(a.Suspense,{fallback:r},a.createElement(H,{errorElement:o},"function"==typeof t?a.createElement(I,{children:t}):t)))},e.MemoryRouter=function(e){let{basename:n,children:r,initialEntries:o,initialIndex:i}=e,u=a.useRef();null==u.current&&(u.current=t.createMemoryHistory({initialEntries:o,initialIndex:i,v5Compat:!0}));let l=u.current,[s,c]=a.useState({action:l.action,location:l.location});return a.useLayoutEffect((()=>l.listen(c)),[l]),a.createElement(B,{basename:n,children:r,location:s.location,navigationType:s.action,navigator:l})},e.Navigate=function(e){let{to:n,replace:r,state:o}=e;y()||t.invariant(!1);let i=P();return a.useEffect((()=>{i(n,{replace:r,state:o})})),null},e.Outlet=function(e){return D(e.context)},e.Route=L,e.Router=B,e.Routes=function(e){let{children:t,location:n}=e;return j(J(t),n)},e.UNSAFE_DataRouterContext=h,e.UNSAFE_DataRouterStateContext=p,e.UNSAFE_LocationContext=g,e.UNSAFE_NavigationContext=v,e.UNSAFE_RouteContext=E,e.createRoutesFromChildren=J,e.renderMatches=function(e){return M(e)},e.useActionData=function(){let e=w(N.UseActionData);return a.useContext(E)||t.invariant(!1),Object.values((null==e?void 0:e.actionData)||{})[0]},e.useDeferredData=F,e.useHref=function(e){y()||t.invariant(!1);let{basename:n,navigator:r}=a.useContext(v),{hash:o,pathname:i,search:u}=O(e),l=i;return"/"!==n&&(l="/"===i?n:t.joinPaths([n,i])),r.createHref({pathname:l,search:u,hash:o})},e.useInRouterContext=y,e.useLoaderData=function(){let e=w(N.UseLoaderData),n=a.useContext(E);n||t.invariant(!1);let r=n.matches[n.matches.length-1];return r.route.id||t.invariant(!1),e.loaderData[r.route.id]},e.useLocation=x,e.useMatch=function(e){y()||t.invariant(!1);let{pathname:n}=x();return a.useMemo((()=>t.matchPath(e,n)),[n,e])},e.useMatches=function(){let{matches:e,loaderData:t}=w(N.UseMatches);return a.useMemo((()=>e.map((e=>{let{pathname:n,params:r}=e;return{id:e.route.id,pathname:n,params:r,data:t[e.route.id],handle:e.route.handle}}))),[e,t])},e.useNavigate=P,e.useNavigation=function(){return w(N.UseNavigation).navigation},e.useNavigationType=function(){return a.useContext(g).navigationType},e.useOutlet=D,e.useOutletContext=function(){return a.useContext(C)},e.useParams=function(){let{matches:e}=a.useContext(E),t=e[e.length-1];return t?t.params:{}},e.useRenderDataRouter=A,e.useResolvedPath=O,e.useRevalidator=function(){let e=a.useContext(h);e||t.invariant(!1);let n=w(N.UseRevalidator);return{revalidate:e.revalidate,state:n.revalidation}},e.useRouteError=k,e.useRouteLoaderData=function(e){return w(N.UseRouteLoaderData).loaderData[e]},e.useRoutes=j,Object.defineProperty(e,"__esModule",{value:!0})}));
!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.Router,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 a=n(r);const o="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}=a;function c(e){const t=e.getSnapshot,r=e.value;try{const e=t();return!o(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:a},o]=i({inst:{value:n,getSnapshot:t}});return l((()=>{a.value=n,a.getSnapshot=t,c(a)&&o({inst:a})}),[e,n,t]),u((()=>{c(a)&&o({inst:a});return e((()=>{c(a)&&o({inst:a})}))}),[e]),s(n),n},m="useSyncExternalStore"in a?(e=>e.useSyncExternalStore)(a):d,h=a.createContext(null),p=a.createContext(null),f=a.createContext(null),v=a.createContext(null),g=a.createContext(null),E=a.createContext(null),b=a.createContext({outlet:null,matches:[]}),y=a.createContext(null);function x(){return null!=a.useContext(E)}function C(){return x()||t.invariant(!1),a.useContext(E).location}function R(e){return e.filter(((t,r)=>0===r||!t.route.index&&t.pathnameBase!==e[r-1].pathnameBase))}function P(){x()||t.invariant(!1);let{basename:e,navigator:r}=a.useContext(g),{matches:n}=a.useContext(b),{pathname:o}=C(),i=JSON.stringify(R(n).map((e=>e.pathnameBase))),u=a.useRef(!1);return a.useEffect((()=>{u.current=!0})),a.useCallback((function(n,a){if(void 0===a&&(a={}),!u.current)return;if("number"==typeof n)return void r.go(n);let l=t.resolveTo(n,JSON.parse(i),o);"/"!==e&&(l.pathname="/"===l.pathname?e:t.joinPaths([e,l.pathname])),(a.replace?r.replace:r.push)(l,a.state,a)}),[e,r,i,o])}const D=a.createContext(null);function S(e){let t=a.useContext(b).outlet;return t?a.createElement(D.Provider,{value:e},t):t}function O(e){let{matches:r}=a.useContext(b),{pathname:n}=C(),o=JSON.stringify(R(r).map((e=>e.pathnameBase)));return a.useMemo((()=>t.resolveTo(e,JSON.parse(o),n)),[e,o,n])}function j(e,r){x()||t.invariant(!1);let n=a.useContext(f),{matches:o}=a.useContext(b),i=o[o.length-1],u=i?i.params:{};!i||i.pathname;let l=i?i.pathnameBase:"/";i&&i.route;let s,c=C();if(r){var d;let e="string"==typeof r?t.parsePath(r):r;"/"===l||(null==(d=e.pathname)?void 0:d.startsWith(l))||t.invariant(!1),s=e}else s=c;let m=s.pathname||"/",h="/"===l?m:m.slice(l.length)||"/",p=t.matchRoutes(e,{pathname:h});return w(p&&p.map((e=>Object.assign({},e,{params:Object.assign({},u,e.params),pathname:t.joinPaths([l,e.pathname]),pathnameBase:"/"===e.pathnameBase?l:t.joinPaths([l,e.pathnameBase])}))),o,n||void 0)}function U(){let e=T(),r=t.isRouteErrorResponse(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,o="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o};return a.createElement(a.Fragment,null,a.createElement("h2",null,"Unhandled Thrown Error!"),a.createElement("h3",{style:{fontStyle:"italic"}},r),n?a.createElement("pre",{style:i},n):null,a.createElement("p",null,"💿 Hey developer 👋"),a.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",a.createElement("code",{style:u},"errorElement")," props on ",a.createElement("code",{style:u},"<Route>")))}class N extends a.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?a.createElement(y.Provider,{value:this.state.error,children:this.props.component}):this.props.children}}function M(e){let{routeContext:t,match:r,children:n}=e,o=a.useContext(h);return o&&r.route.errorElement&&(o._deepestRenderedBoundaryId=r.route.id),a.createElement(b.Provider,{value:t},n)}function w(e,r,n){if(void 0===r&&(r=[]),null==e){if(null==n||!n.errors)return null;e=n.matches}let o=e,i=null==n?void 0:n.errors;if(null!=i){let e=o.findIndex((e=>e.route.id&&(null==i?void 0:i[e.route.id])));e>=0||t.invariant(!1),o=o.slice(0,Math.min(o.length,e+1))}return o.reduceRight(((e,t,u)=>{let l=t.route.id?null==i?void 0:i[t.route.id]:null,s=n?t.route.errorElement||a.createElement(U,null):null,c=()=>a.createElement(M,{match:t,routeContext:{outlet:e,matches:r.concat(o.slice(0,u+1))}},l?s:void 0!==t.route.element?t.route.element:e);return n&&(t.route.errorElement||0===u)?a.createElement(N,{location:n.location,component:s,error:l,children:c()}):c()}),null)}var F;function A(e){let r=a.useContext(f);return r||t.invariant(!1),r}function T(){var e;let r=a.useContext(y),n=A(F.UseRouteError),o=a.useContext(b),i=o.matches[o.matches.length-1],u=a.useContext(v);return u&&u instanceof Error?u:r||(o||t.invariant(!1),i.route.id||t.invariant(!1),null==(e=n.errors)?void 0:e[i.route.id])}function _(){return a.useContext(v)}let L;function k(e){let{basename:t,children:r,fallbackElement:n,router:o}=e,i=m(o.subscribe,(()=>o.state),(()=>o.state)),u=a.useMemo((()=>({createHref:o.createHref,go:e=>o.navigate(e),push:(e,t,r)=>o.navigate(e,{state:t,resetScroll:null==r?void 0:r.resetScroll}),replace:(e,t,r)=>o.navigate(e,{replace:!0,state:t,resetScroll:null==r?void 0:r.resetScroll})})),[o]),l={router:o,navigator:u,static:!1,basename:t||"/"};return i.initialized?a.createElement(p.Provider,{value:l},a.createElement(f.Provider,{value:i,children:r})):a.createElement(a.Fragment,null,n)}function B(){let e=a.useContext(p);e||t.invariant(!1);let{router:r,navigator:n,basename:o}=e;return a.createElement(H,{basename:o,location:r.state.location,navigationType:r.state.historyAction,navigator:n},a.createElement(J,null))}function I(e){t.invariant(!1)}function H(e){let{basename:r="/",children:n=null,location:o,navigationType:i=t.Action.Pop,navigator:u,static:l=!1}=e;x()&&t.invariant(!1);let s=r.replace(/^\/*/,"/"),c=a.useMemo((()=>({basename:s,navigator:u,static:l})),[s,u,l]);"string"==typeof o&&(o=t.parsePath(o));let{pathname:d="/",search:m="",hash:h="",state:p=null,key:f="default"}=o,v=a.useMemo((()=>{let e=t.stripBasename(d,s);return null==e?null:{pathname:e,search:m,hash:h,state:p,key:f}}),[s,d,m,h,p,f]);return null==v?null:a.createElement(g.Provider,{value:c},a.createElement(E.Provider,{children:n,value:{location:v,navigationType:i}}))}function J(e){let{children:t,location:r}=e,n=a.useContext(p);return j(n&&!t?n.router.routes:V(t),r)}!function(e){e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator"}(F||(F={}));class z extends a.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error("<Deferred> caught the following error during render",e,t)}render(){let{children:e,errorElement:r,value:n}=this.props,o=this.state.error||(t.isDeferredError(n)?n:null);if(o){if(r)return a.createElement(v.Provider,{value:o,children:r});throw o}if(n instanceof Promise)throw n;return a.createElement(v.Provider,{value:n,children:e})}}function q(e){let{children:t}=e,r=_();return"function"==typeof t?t(r):a.createElement(a.Fragment,null,t)}function V(e,r){void 0===r&&(r=[]);let n=[];return a.Children.forEach(e,((e,o)=>{if(!a.isValidElement(e))return;if(e.type===a.Fragment)return void n.push.apply(n,V(e.props.children,r));e.type!==I&&t.invariant(!1);let i=[...r,o],u={id:e.props.id||i.join("-"),caseSensitive:e.props.caseSensitive,element:e.props.element,index:e.props.index,path:e.props.path,loader:e.props.loader,action:e.props.action,errorElement:e.props.errorElement,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle};e.props.children&&(u.children=V(e.props.children,i)),n.push(u)})),n}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,"deferred",{enumerable:!0,get:function(){return t.deferred}}),Object.defineProperty(e,"generatePath",{enumerable:!0,get:function(){return t.generatePath}}),Object.defineProperty(e,"isDeferredError",{enumerable:!0,get:function(){return t.isDeferredError}}),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.DataMemoryRouter=function(e){let{basename:r,children:n,initialEntries:o,initialIndex:i,hydrationData:u,fallbackElement:l,routes:s}=e;L||(L=t.createMemoryRouter({basename:r,hydrationData:u,initialEntries:o,initialIndex:i,routes:s||V(n)}).initialize());let c=L;return a.createElement(k,{router:c,basename:r,fallbackElement:l},a.createElement(B,null))},e.Deferred=function(e){let{children:t,value:r,errorElement:n}=e;return a.createElement(z,{value:r,errorElement:n},a.createElement(q,null,t))},e.MemoryRouter=function(e){let{basename:r,children:n,initialEntries:o,initialIndex:i}=e,u=a.useRef();null==u.current&&(u.current=t.createMemoryHistory({initialEntries:o,initialIndex:i,v5Compat:!0}));let l=u.current,[s,c]=a.useState({action:l.action,location:l.location});return a.useLayoutEffect((()=>l.listen(c)),[l]),a.createElement(H,{basename:r,children:n,location:s.location,navigationType:s.action,navigator:l})},e.Navigate=function(e){let{to:r,replace:n,state:o}=e;x()||t.invariant(!1);let i=P();return a.useEffect((()=>{i(r,{replace:n,state:o})})),null},e.Outlet=function(e){return S(e.context)},e.Route=I,e.Router=H,e.Routes=J,e.UNSAFE_DataRouter=B,e.UNSAFE_DataRouterContext=p,e.UNSAFE_DataRouterProvider=k,e.UNSAFE_DataRouterStateContext=f,e.UNSAFE_DataStaticRouterContext=h,e.UNSAFE_LocationContext=E,e.UNSAFE_NavigationContext=g,e.UNSAFE_RouteContext=b,e.createRoutesFromChildren=V,e.renderMatches=function(e){return w(e)},e.useActionData=function(){let e=A(F.UseActionData);return a.useContext(b)||t.invariant(!1),Object.values((null==e?void 0:e.actionData)||{})[0]},e.useDeferredData=_,e.useHref=function(e){x()||t.invariant(!1);let{basename:r,navigator:n}=a.useContext(g),{hash:o,pathname:i,search:u}=O(e),l=i;return"/"!==r&&(l="/"===i?r:t.joinPaths([r,i])),n.createHref({pathname:l,search:u,hash:o})},e.useInRouterContext=x,e.useLoaderData=function(){let e=A(F.UseLoaderData),r=a.useContext(b);r||t.invariant(!1);let n=r.matches[r.matches.length-1];return n.route.id||t.invariant(!1),e.loaderData[n.route.id]},e.useLocation=C,e.useMatch=function(e){x()||t.invariant(!1);let{pathname:r}=C();return a.useMemo((()=>t.matchPath(e,r)),[r,e])},e.useMatches=function(){let{matches:e,loaderData:t}=A(F.UseMatches);return a.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=P,e.useNavigation=function(){return A(F.UseNavigation).navigation},e.useNavigationType=function(){return a.useContext(E).navigationType},e.useOutlet=S,e.useOutletContext=function(){return a.useContext(D)},e.useParams=function(){let{matches:e}=a.useContext(b),t=e[e.length-1];return t?t.params:{}},e.useResolvedPath=O,e.useRevalidator=function(){let e=a.useContext(p);e||t.invariant(!1);let r=A(F.UseRevalidator);return{revalidate:e.router.revalidate,state:r.revalidation}},e.useRouteError=T,e.useRouteLoaderData=function(e){return A(F.UseRouteLoaderData).loaderData[e]},e.useRoutes=j,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=react-router.production.min.js.map
{
"name": "react-router",
"version": "6.4.0-pre.9",
"version": "6.4.0-pre.10",
"description": "Declarative routing for React",

@@ -26,3 +26,3 @@ "keywords": [

"dependencies": {
"@remix-run/router": "0.2.0-pre.4"
"@remix-run/router": "0.2.0-pre.5"
},

@@ -29,0 +29,0 @@ "devDependencies": {

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc