react-router-dom
Advanced tools
Comparing version 0.0.0-experimental-63b6834e to 0.0.0-experimental-91f2bf54
# `react-router-dom` | ||
## 6.8.2 | ||
### Patch Changes | ||
- Treat same-origin absolute URLs in `<Link to>` as external if they are outside of the router `basename` ([#10135](https://github.com/remix-run/react-router/pull/10135)) | ||
- Fix `useBlocker` to return `IDLE_BLOCKER` during SSR ([#10046](https://github.com/remix-run/react-router/pull/10046)) | ||
- Fix SSR of absolute `<Link to>` urls ([#10112](https://github.com/remix-run/react-router/pull/10112)) | ||
- Properly escape HTML characters in `StaticRouterProvider` serialized hydration data ([#10068](https://github.com/remix-run/react-router/pull/10068)) | ||
- Updated dependencies: | ||
- `@remix-run/router@1.3.3` | ||
- `react-router@6.8.2` | ||
## 6.8.1 | ||
@@ -4,0 +16,0 @@ |
@@ -23,5 +23,2 @@ /** | ||
window?: Window; | ||
onInitialize?: (args: { | ||
router: RemixRouter; | ||
}) => void; | ||
}): RemixRouter; | ||
@@ -32,5 +29,2 @@ export declare function createHashRouter(routes: RouteObject[], opts?: { | ||
window?: Window; | ||
onInitialize?: (args: { | ||
router: RemixRouter; | ||
}) => void; | ||
}): RemixRouter; | ||
@@ -232,2 +226,3 @@ export interface BrowserRouterProps { | ||
}): void; | ||
export { useScrollRestoration as UNSAFE_useScrollRestoration }; | ||
/** | ||
@@ -257,2 +252,1 @@ * Setup a callback to be fired on the window's `beforeunload` event. This is | ||
export { usePrompt as unstable_usePrompt }; | ||
export { useScrollRestoration as UNSAFE_useScrollRestoration }; |
/** | ||
* React Router DOM v0.0.0-experimental-63b6834e | ||
* React Router DOM v0.0.0-experimental-91f2bf54 | ||
* | ||
@@ -12,5 +12,5 @@ * Copyright (c) Remix Software Inc. | ||
import * as React from 'react'; | ||
import { Router, useHref, useResolvedPath, useLocation, UNSAFE_DataRouterStateContext, UNSAFE_NavigationContext, useNavigate, createPath, UNSAFE_RouteContext, useMatches, useNavigation, unstable_useBlocker, UNSAFE_DataRouterContext } from 'react-router'; | ||
import { UNSAFE_detectErrorBoundary, Router, UNSAFE_NavigationContext, useHref, useResolvedPath, useLocation, UNSAFE_DataRouterStateContext, useNavigate, createPath, UNSAFE_RouteContext, useMatches, useNavigation, unstable_useBlocker, UNSAFE_DataRouterContext } from 'react-router'; | ||
export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, renderMatches, resolvePath, unstable_useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes } from 'react-router'; | ||
import { createRouter, createBrowserHistory, createHashHistory, ErrorResponse, invariant, joinPaths } from '@remix-run/router'; | ||
import { createRouter, createBrowserHistory, createHashHistory, ErrorResponse, stripBasename, UNSAFE_warning, UNSAFE_invariant, joinPaths } from '@remix-run/router'; | ||
@@ -205,4 +205,3 @@ function _extends() { | ||
routes, | ||
hasErrorBoundary: route => Boolean(route.errorElement), | ||
onInitialize: opts == null ? void 0 : opts.onInitialize | ||
detectErrorBoundary: UNSAFE_detectErrorBoundary | ||
}).initialize(); | ||
@@ -218,4 +217,3 @@ } | ||
routes, | ||
hasErrorBoundary: route => Boolean(route.errorElement), | ||
onInitialize: opts == null ? void 0 : opts.onInitialize | ||
detectErrorBoundary: UNSAFE_detectErrorBoundary | ||
}).initialize(); | ||
@@ -360,2 +358,3 @@ } | ||
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined"; | ||
const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i; | ||
/** | ||
@@ -378,16 +377,24 @@ * The public API for rendering a history-aware <a>. | ||
// Rendered into <a href> for absolute URLs | ||
let { | ||
basename | ||
} = React.useContext(UNSAFE_NavigationContext); // Rendered into <a href> for absolute URLs | ||
let absoluteHref; | ||
let isExternal = false; | ||
if (isBrowser && typeof to === "string" && /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(to)) { | ||
absoluteHref = to; | ||
let currentUrl = new URL(window.location.href); | ||
let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to); | ||
if (typeof to === "string" && ABSOLUTE_URL_REGEX.test(to)) { | ||
// Render the absolute href server- and client-side | ||
absoluteHref = to; // Only check for external origins client-side | ||
if (targetUrl.origin === currentUrl.origin) { | ||
// Strip the protocol/origin for same-origin absolute URLs | ||
to = targetUrl.pathname + targetUrl.search + targetUrl.hash; | ||
} else { | ||
isExternal = true; | ||
if (isBrowser) { | ||
let currentUrl = new URL(window.location.href); | ||
let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to); | ||
let path = stripBasename(targetUrl.pathname, basename); | ||
if (targetUrl.origin === currentUrl.origin && path != null) { | ||
// Strip the protocol/origin/basename for same-origin absolute URLs | ||
to = path + targetUrl.search + targetUrl.hash; | ||
} else { | ||
isExternal = true; | ||
} | ||
} | ||
@@ -614,3 +621,3 @@ } // Rendered into <a href> for relative URLs | ||
let ctx = React.useContext(UNSAFE_DataRouterContext); | ||
!ctx ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0; | ||
!ctx ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : UNSAFE_invariant(false) : void 0; | ||
return ctx; | ||
@@ -621,3 +628,3 @@ } | ||
let state = React.useContext(UNSAFE_DataRouterStateContext); | ||
!state ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0; | ||
!state ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : UNSAFE_invariant(false) : void 0; | ||
return state; | ||
@@ -666,3 +673,3 @@ } | ||
function useSearchParams(defaultInit) { | ||
process.env.NODE_ENV !== "production" ? warning(typeof URLSearchParams !== "undefined", "You cannot use the `useSearchParams` hook in a browser that does not " + "support the URLSearchParams API. If you need to support Internet " + "Explorer 11, we recommend you load a polyfill such as " + "https://github.com/ungap/url-search-params\n\n" + "If you're unsure how to load polyfills, we recommend you check out " + "https://polyfill.io/v3/ which provides some recommendations about how " + "to load polyfills only for users that need them, instead of for every " + "user.") : void 0; | ||
process.env.NODE_ENV !== "production" ? UNSAFE_warning(typeof URLSearchParams !== "undefined", "You cannot use the `useSearchParams` hook in a browser that does not " + "support the URLSearchParams API. If you need to support Internet " + "Explorer 11, we recommend you load a polyfill such as " + "https://github.com/ungap/url-search-params\n\n" + "If you're unsure how to load polyfills, we recommend you check out " + "https://polyfill.io/v3/ which provides some recommendations about how " + "to load polyfills only for users that need them, instead of for every " + "user.") : void 0; | ||
let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit)); | ||
@@ -722,3 +729,3 @@ let hasSetSearchParamsRef = React.useRef(false); | ||
if (fetcherKey) { | ||
!(routeId != null) ? process.env.NODE_ENV !== "production" ? invariant(false, "No routeId available for useFetcher()") : invariant(false) : void 0; | ||
!(routeId != null) ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "No routeId available for useFetcher()") : UNSAFE_invariant(false) : void 0; | ||
router.fetch(fetcherKey, routeId, href, opts); | ||
@@ -739,3 +746,3 @@ } else { | ||
let routeContext = React.useContext(UNSAFE_RouteContext); | ||
!routeContext ? process.env.NODE_ENV !== "production" ? invariant(false, "useFormAction must be used inside a RouteContext") : invariant(false) : void 0; | ||
!routeContext ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "useFormAction must be used inside a RouteContext") : UNSAFE_invariant(false) : void 0; | ||
let [match] = routeContext.matches.slice(-1); // Shallow clone path so we can modify it below, otherwise we modify the | ||
@@ -815,13 +822,13 @@ // object referenced by useMemo inside useResolvedPath | ||
let route = React.useContext(UNSAFE_RouteContext); | ||
!route ? process.env.NODE_ENV !== "production" ? invariant(false, "useFetcher must be used inside a RouteContext") : invariant(false) : void 0; | ||
!route ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "useFetcher must be used inside a RouteContext") : UNSAFE_invariant(false) : void 0; | ||
let routeId = (_route$matches = route.matches[route.matches.length - 1]) == null ? void 0 : _route$matches.route.id; | ||
!(routeId != null) ? process.env.NODE_ENV !== "production" ? invariant(false, "useFetcher can only be used on routes that contain a unique \"id\"") : invariant(false) : void 0; | ||
!(routeId != null) ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "useFetcher can only be used on routes that contain a unique \"id\"") : UNSAFE_invariant(false) : void 0; | ||
let [fetcherKey] = React.useState(() => String(++fetcherId)); | ||
let [Form] = React.useState(() => { | ||
!routeId ? process.env.NODE_ENV !== "production" ? invariant(false, "No routeId available for fetcher.Form()") : invariant(false) : void 0; | ||
!routeId ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "No routeId available for fetcher.Form()") : UNSAFE_invariant(false) : void 0; | ||
return createFetcherForm(fetcherKey, routeId); | ||
}); | ||
let [load] = React.useState(() => href => { | ||
!router ? process.env.NODE_ENV !== "production" ? invariant(false, "No router available for fetcher.load()") : invariant(false) : void 0; | ||
!routeId ? process.env.NODE_ENV !== "production" ? invariant(false, "No routeId available for fetcher.load()") : invariant(false) : void 0; | ||
!router ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "No router available for fetcher.load()") : UNSAFE_invariant(false) : void 0; | ||
!routeId ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "No routeId available for fetcher.load()") : UNSAFE_invariant(false) : void 0; | ||
router.fetch(fetcherKey, routeId, href); | ||
@@ -960,3 +967,2 @@ }); | ||
function useBeforeUnload(callback, options) { | ||
@@ -1032,23 +1038,5 @@ let { | ||
} | ||
//////////////////////////////////////////////////////////////////////////////// | ||
//#region Utils | ||
//////////////////////////////////////////////////////////////////////////////// | ||
//#endregion | ||
function warning(cond, message) { | ||
if (!cond) { | ||
// eslint-disable-next-line no-console | ||
if (typeof console !== "undefined") console.warn(message); | ||
try { | ||
// Welcome to debugging React Router! | ||
// | ||
// This error is thrown as a convenience so you can more easily | ||
// find the source for a warning that appears in the console by | ||
// enabling "pause on exceptions" in your JavaScript debugger. | ||
throw new Error(message); // eslint-disable-next-line no-empty | ||
} catch (e) {} | ||
} | ||
} //#endregion | ||
export { BrowserRouter, Form, HashRouter, Link, NavLink, ScrollRestoration, useScrollRestoration as UNSAFE_useScrollRestoration, createBrowserRouter, createHashRouter, createSearchParams, HistoryRouter as unstable_HistoryRouter, usePrompt as unstable_usePrompt, useBeforeUnload, useFetcher, useFetchers, useFormAction, useLinkClickHandler, useSearchParams, useSubmit }; | ||
//# sourceMappingURL=index.js.map |
/** | ||
* React Router DOM v0.0.0-experimental-63b6834e | ||
* React Router DOM v0.0.0-experimental-91f2bf54 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* React Router DOM v0.0.0-experimental-63b6834e | ||
* React Router DOM v0.0.0-experimental-91f2bf54 | ||
* | ||
@@ -12,5 +12,5 @@ * Copyright (c) Remix Software Inc. | ||
import * as React from 'react'; | ||
import { Router, useHref, useResolvedPath, useLocation, UNSAFE_DataRouterStateContext, UNSAFE_NavigationContext, useNavigate, createPath, UNSAFE_RouteContext, useMatches, useNavigation, unstable_useBlocker, UNSAFE_DataRouterContext } from 'react-router'; | ||
import { UNSAFE_detectErrorBoundary, Router, UNSAFE_NavigationContext, useHref, useResolvedPath, useLocation, UNSAFE_DataRouterStateContext, useNavigate, createPath, UNSAFE_RouteContext, useMatches, useNavigation, unstable_useBlocker, UNSAFE_DataRouterContext } from 'react-router'; | ||
export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, renderMatches, resolvePath, unstable_useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes } from 'react-router'; | ||
import { createRouter, createBrowserHistory, createHashHistory, ErrorResponse, invariant, joinPaths } from '@remix-run/router'; | ||
import { createRouter, createBrowserHistory, createHashHistory, ErrorResponse, stripBasename, UNSAFE_warning, UNSAFE_invariant, joinPaths } from '@remix-run/router'; | ||
@@ -171,4 +171,3 @@ const defaultMethod = "get"; | ||
routes, | ||
hasErrorBoundary: route => Boolean(route.errorElement), | ||
onInitialize: opts?.onInitialize | ||
detectErrorBoundary: UNSAFE_detectErrorBoundary | ||
}).initialize(); | ||
@@ -184,4 +183,3 @@ } | ||
routes, | ||
hasErrorBoundary: route => Boolean(route.errorElement), | ||
onInitialize: opts?.onInitialize | ||
detectErrorBoundary: UNSAFE_detectErrorBoundary | ||
}).initialize(); | ||
@@ -324,2 +322,3 @@ } | ||
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined"; | ||
const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i; | ||
/** | ||
@@ -340,16 +339,24 @@ * The public API for rendering a history-aware <a>. | ||
}, ref) { | ||
// Rendered into <a href> for absolute URLs | ||
let { | ||
basename | ||
} = React.useContext(UNSAFE_NavigationContext); // Rendered into <a href> for absolute URLs | ||
let absoluteHref; | ||
let isExternal = false; | ||
if (isBrowser && typeof to === "string" && /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(to)) { | ||
absoluteHref = to; | ||
let currentUrl = new URL(window.location.href); | ||
let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to); | ||
if (typeof to === "string" && ABSOLUTE_URL_REGEX.test(to)) { | ||
// Render the absolute href server- and client-side | ||
absoluteHref = to; // Only check for external origins client-side | ||
if (targetUrl.origin === currentUrl.origin) { | ||
// Strip the protocol/origin for same-origin absolute URLs | ||
to = targetUrl.pathname + targetUrl.search + targetUrl.hash; | ||
} else { | ||
isExternal = true; | ||
if (isBrowser) { | ||
let currentUrl = new URL(window.location.href); | ||
let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to); | ||
let path = stripBasename(targetUrl.pathname, basename); | ||
if (targetUrl.origin === currentUrl.origin && path != null) { | ||
// Strip the protocol/origin/basename for same-origin absolute URLs | ||
to = path + targetUrl.search + targetUrl.hash; | ||
} else { | ||
isExternal = true; | ||
} | ||
} | ||
@@ -570,3 +577,3 @@ } // Rendered into <a href> for relative URLs | ||
let ctx = React.useContext(UNSAFE_DataRouterContext); | ||
!ctx ? invariant(false, getDataRouterConsoleError(hookName)) : void 0; | ||
!ctx ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : void 0; | ||
return ctx; | ||
@@ -577,3 +584,3 @@ } | ||
let state = React.useContext(UNSAFE_DataRouterStateContext); | ||
!state ? invariant(false, getDataRouterConsoleError(hookName)) : void 0; | ||
!state ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : void 0; | ||
return state; | ||
@@ -621,3 +628,3 @@ } | ||
function useSearchParams(defaultInit) { | ||
warning(typeof URLSearchParams !== "undefined", `You cannot use the \`useSearchParams\` hook in a browser that does not ` + `support the URLSearchParams API. If you need to support Internet ` + `Explorer 11, we recommend you load a polyfill such as ` + `https://github.com/ungap/url-search-params\n\n` + `If you're unsure how to load polyfills, we recommend you check out ` + `https://polyfill.io/v3/ which provides some recommendations about how ` + `to load polyfills only for users that need them, instead of for every ` + `user.`) ; | ||
UNSAFE_warning(typeof URLSearchParams !== "undefined", `You cannot use the \`useSearchParams\` hook in a browser that does not ` + `support the URLSearchParams API. If you need to support Internet ` + `Explorer 11, we recommend you load a polyfill such as ` + `https://github.com/ungap/url-search-params\n\n` + `If you're unsure how to load polyfills, we recommend you check out ` + `https://polyfill.io/v3/ which provides some recommendations about how ` + `to load polyfills only for users that need them, instead of for every ` + `user.`) ; | ||
let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit)); | ||
@@ -673,3 +680,3 @@ let hasSetSearchParamsRef = React.useRef(false); | ||
if (fetcherKey) { | ||
!(routeId != null) ? invariant(false, "No routeId available for useFetcher()") : void 0; | ||
!(routeId != null) ? UNSAFE_invariant(false, "No routeId available for useFetcher()") : void 0; | ||
router.fetch(fetcherKey, routeId, href, opts); | ||
@@ -689,3 +696,3 @@ } else { | ||
let routeContext = React.useContext(UNSAFE_RouteContext); | ||
!routeContext ? invariant(false, "useFormAction must be used inside a RouteContext") : void 0; | ||
!routeContext ? UNSAFE_invariant(false, "useFormAction must be used inside a RouteContext") : void 0; | ||
let [match] = routeContext.matches.slice(-1); // Shallow clone path so we can modify it below, otherwise we modify the | ||
@@ -763,13 +770,13 @@ // object referenced by useMemo inside useResolvedPath | ||
let route = React.useContext(UNSAFE_RouteContext); | ||
!route ? invariant(false, `useFetcher must be used inside a RouteContext`) : void 0; | ||
!route ? UNSAFE_invariant(false, `useFetcher must be used inside a RouteContext`) : void 0; | ||
let routeId = route.matches[route.matches.length - 1]?.route.id; | ||
!(routeId != null) ? invariant(false, `useFetcher can only be used on routes that contain a unique "id"`) : void 0; | ||
!(routeId != null) ? UNSAFE_invariant(false, `useFetcher can only be used on routes that contain a unique "id"`) : void 0; | ||
let [fetcherKey] = React.useState(() => String(++fetcherId)); | ||
let [Form] = React.useState(() => { | ||
!routeId ? invariant(false, `No routeId available for fetcher.Form()`) : void 0; | ||
!routeId ? UNSAFE_invariant(false, `No routeId available for fetcher.Form()`) : void 0; | ||
return createFetcherForm(fetcherKey, routeId); | ||
}); | ||
let [load] = React.useState(() => href => { | ||
!router ? invariant(false, "No router available for fetcher.load()") : void 0; | ||
!routeId ? invariant(false, "No routeId available for fetcher.load()") : void 0; | ||
!router ? UNSAFE_invariant(false, "No router available for fetcher.load()") : void 0; | ||
!routeId ? UNSAFE_invariant(false, "No routeId available for fetcher.load()") : void 0; | ||
router.fetch(fetcherKey, routeId, href); | ||
@@ -908,3 +915,2 @@ }); | ||
function useBeforeUnload(callback, options) { | ||
@@ -979,23 +985,5 @@ let { | ||
} | ||
//////////////////////////////////////////////////////////////////////////////// | ||
//#region Utils | ||
//////////////////////////////////////////////////////////////////////////////// | ||
//#endregion | ||
function warning(cond, message) { | ||
if (!cond) { | ||
// eslint-disable-next-line no-console | ||
if (typeof console !== "undefined") console.warn(message); | ||
try { | ||
// Welcome to debugging React Router! | ||
// | ||
// This error is thrown as a convenience so you can more easily | ||
// find the source for a warning that appears in the console by | ||
// enabling "pause on exceptions" in your JavaScript debugger. | ||
throw new Error(message); // eslint-disable-next-line no-empty | ||
} catch (e) {} | ||
} | ||
} //#endregion | ||
export { BrowserRouter, Form, HashRouter, Link, NavLink, ScrollRestoration, useScrollRestoration as UNSAFE_useScrollRestoration, createBrowserRouter, createHashRouter, createSearchParams, HistoryRouter as unstable_HistoryRouter, usePrompt as unstable_usePrompt, useBeforeUnload, useFetcher, useFetchers, useFormAction, useLinkClickHandler, useSearchParams, useSubmit }; | ||
//# sourceMappingURL=react-router-dom.development.js.map |
/** | ||
* React Router DOM v0.0.0-experimental-63b6834e | ||
* React Router DOM v0.0.0-experimental-91f2bf54 | ||
* | ||
@@ -11,3 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
*/ | ||
import*as e from"react";import{Router as t,useHref as r,useResolvedPath as n,useLocation as o,UNSAFE_DataRouterStateContext as a,UNSAFE_NavigationContext as i,useNavigate as s,createPath as l,UNSAFE_RouteContext as u,useMatches as c,useNavigation as f,unstable_useBlocker as m,UNSAFE_DataRouterContext as d}from"react-router";export{AbortedDeferredError,Await,MemoryRouter,Navigate,NavigationType,Outlet,Route,Router,RouterProvider,Routes,UNSAFE_DataRouterContext,UNSAFE_DataRouterStateContext,UNSAFE_LocationContext,UNSAFE_NavigationContext,UNSAFE_RouteContext,createMemoryRouter,createPath,createRoutesFromChildren,createRoutesFromElements,defer,generatePath,isRouteErrorResponse,json,matchPath,matchRoutes,parsePath,redirect,renderMatches,resolvePath,unstable_useBlocker,useActionData,useAsyncError,useAsyncValue,useHref,useInRouterContext,useLoaderData,useLocation,useMatch,useMatches,useNavigate,useNavigation,useNavigationType,useOutlet,useOutletContext,useParams,useResolvedPath,useRevalidator,useRouteError,useRouteLoaderData,useRoutes}from"react-router";import{createRouter as h,createBrowserHistory as p,createHashHistory as w,ErrorResponse as g,invariant as y,joinPaths as v}from"@remix-run/router";const b="application/x-www-form-urlencoded";function R(e){return null!=e&&"string"==typeof e.tagName}function E(e=""){return new URLSearchParams("string"==typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce(((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map((e=>[r,e])):[[r,n]])}),[]))}function S(e,t,r){let n,o,a,i;if(R(s=e)&&"form"===s.tagName.toLowerCase()){let s=r.submissionTrigger;n=r.method||e.getAttribute("method")||"get",o=r.action||e.getAttribute("action")||t,a=r.encType||e.getAttribute("enctype")||b,i=new FormData(e),s&&s.name&&i.append(s.name,s.value)}else if(function(e){return R(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return R(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let s=e.form;if(null==s)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');n=r.method||e.getAttribute("formmethod")||s.getAttribute("method")||"get",o=r.action||e.getAttribute("formaction")||s.getAttribute("action")||t,a=r.encType||e.getAttribute("formenctype")||s.getAttribute("enctype")||b,i=new FormData(s),e.name&&i.append(e.name,e.value)}else{if(R(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');if(n=r.method||"get",o=r.action||t,a=r.encType||b,e instanceof FormData)i=e;else if(i=new FormData,e instanceof URLSearchParams)for(let[t,r]of e)i.append(t,r);else if(null!=e)for(let t of Object.keys(e))i.append(t,e[t])}var s;let{protocol:l,host:u}=window.location;return{url:new URL(o,`${l}//${u}`),method:n.toLowerCase(),encType:a,formData:i}}function C(e,t){return h({basename:t?.basename,history:p({window:t?.window}),hydrationData:t?.hydrationData||A(),routes:e,hasErrorBoundary:e=>Boolean(e.errorElement),onInitialize:t?.onInitialize}).initialize()}function L(e,t){return h({basename:t?.basename,history:w({window:t?.window}),hydrationData:t?.hydrationData||A(),routes:e,hasErrorBoundary:e=>Boolean(e.errorElement),onInitialize:t?.onInitialize}).initialize()}function A(){let e=window?.__staticRouterHydrationData;return e&&e.errors&&(e={...e,errors:x(e.errors)}),e}function x(e){if(!e)return null;let t=Object.entries(e),r={};for(let[n,o]of t)if(o&&"RouteErrorResponse"===o.__type)r[n]=new g(o.status,o.statusText,o.data,!0===o.internal);else if(o&&"Error"===o.__type){let e=new Error(o.message);e.stack="",r[n]=e}else r[n]=o;return r}function U({basename:r,children:n,window:o}){let a=e.useRef();null==a.current&&(a.current=p({window:o,v5Compat:!0}));let i=a.current,[s,l]=e.useState({action:i.action,location:i.location});return e.useLayoutEffect((()=>i.listen(l)),[i]),e.createElement(t,{basename:r,children:n,location:s.location,navigationType:s.action,navigator:i})}function D({basename:r,children:n,window:o}){let a=e.useRef();null==a.current&&(a.current=w({window:o,v5Compat:!0}));let i=a.current,[s,l]=e.useState({action:i.action,location:i.location});return e.useLayoutEffect((()=>i.listen(l)),[i]),e.createElement(t,{basename:r,children:n,location:s.location,navigationType:s.action,navigator:i})}function F({basename:r,children:n,history:o}){const[a,i]=e.useState({action:o.action,location:o.location});return e.useLayoutEffect((()=>o.listen(i)),[o]),e.createElement(t,{basename:r,children:n,location:a.location,navigationType:a.action,navigator:o})}const N="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,P=e.forwardRef((function({onClick:t,relative:n,reloadDocument:o,replace:a,state:i,target:s,to:l,preventScrollReset:u,...c},f){let m,d=!1;if(N&&"string"==typeof l&&/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(l)){m=l;let e=new URL(window.location.href),t=l.startsWith("//")?new URL(e.protocol+l):new URL(l);t.origin===e.origin?l=t.pathname+t.search+t.hash:d=!0}let h=r(l,{relative:n}),p=M(l,{replace:a,state:i,target:s,preventScrollReset:u,relative:n});return e.createElement("a",Object.assign({},c,{href:m||h,onClick:d||o?t:function(e){t&&t(e),e.defaultPrevented||p(e)},ref:f,target:s}))})),T=e.forwardRef((function({"aria-current":t="page",caseSensitive:r=!1,className:s="",end:l=!1,style:u,to:c,children:f,...m},d){let h=n(c,{relative:m.relative}),p=o(),w=e.useContext(a),{navigator:g}=e.useContext(i),y=g.encodeLocation?g.encodeLocation(h).pathname:h.pathname,v=p.pathname,b=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;r||(v=v.toLowerCase(),b=b?b.toLowerCase():null,y=y.toLowerCase());let R,E=v===y||!l&&v.startsWith(y)&&"/"===v.charAt(y.length),S=null!=b&&(b===y||!l&&b.startsWith(y)&&"/"===b.charAt(y.length)),C=E?t:void 0;R="function"==typeof s?s({isActive:E,isPending:S}):[s,E?"active":null,S?"pending":null].filter(Boolean).join(" ");let L="function"==typeof u?u({isActive:E,isPending:S}):u;return e.createElement(P,Object.assign({},m,{"aria-current":C,className:R,ref:d,style:L,to:c}),"function"==typeof f?f({isActive:E,isPending:S}):f)})),_=e.forwardRef(((t,r)=>e.createElement(k,Object.assign({},t,{ref:r})))),k=e.forwardRef((({reloadDocument:t,replace:r,method:n="get",action:o,onSubmit:a,fetcherKey:i,routeId:s,relative:l,preventScrollReset:u,...c},f)=>{let m=W(i,s),d="get"===n.toLowerCase()?"get":"post",h=Y(o,{relative:l});return e.createElement("form",Object.assign({ref:f,method:d,action:h,onSubmit:t?a:e=>{if(a&&a(e),e.defaultPrevented)return;e.preventDefault();let t=e.nativeEvent.submitter,o=t?.getAttribute("formmethod")||n;m(t||e.currentTarget,{method:o,replace:r,relative:l,preventScrollReset:u})}},c))}));function I({getKey:e,storageKey:t}){return G({getKey:e,storageKey:t}),null}var O,K;function j(t){let r=e.useContext(d);return r||y(!1),r}function z(t){let r=e.useContext(a);return r||y(!1),r}function M(t,{target:r,replace:a,state:i,preventScrollReset:u,relative:c}={}){let f=s(),m=o(),d=n(t,{relative:c});return e.useCallback((e=>{if(function(e,t){return!(0!==e.button||t&&"_self"!==t||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e))}(e,r)){e.preventDefault();let r=void 0!==a?a:l(m)===l(d);f(t,{replace:r,state:i,preventScrollReset:u,relative:c})}}),[m,f,d,a,i,r,t,u,c])}function B(t){let r=e.useRef(E(t)),n=e.useRef(!1),a=o(),i=e.useMemo((()=>function(e,t){let r=E(e);if(t)for(let n of t.keys())r.has(n)||t.getAll(n).forEach((e=>{r.append(n,e)}));return r}(a.search,n.current?null:r.current)),[a.search]),l=s(),u=e.useCallback(((e,t)=>{const r=E("function"==typeof e?e(i):e);n.current=!0,l("?"+r,t)}),[l,i]);return[i,u]}function H(){return W()}function W(t,r){let{router:n}=j(O.UseSubmitImpl),o=Y();return e.useCallback(((e,a={})=>{if("undefined"==typeof document)throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");let{method:i,encType:s,formData:l,url:u}=S(e,o,a),c=u.pathname+u.search,f={replace:a.replace,preventScrollReset:a.preventScrollReset,formData:l,formMethod:i,formEncType:s};t?(null==r&&y(!1),n.fetch(t,r,c,f)):n.navigate(c,f)}),[o,n,t,r])}function Y(t,{relative:r}={}){let{basename:a}=e.useContext(i),s=e.useContext(u);s||y(!1);let[c]=s.matches.slice(-1),f={...n(t||".",{relative:r})},m=o();if(null==t&&(f.search=m.search,f.hash=m.hash,c.route.index)){let e=new URLSearchParams(f.search);e.delete("index"),f.search=e.toString()?`?${e.toString()}`:""}return t&&"."!==t||!c.route.index||(f.search=f.search?f.search.replace(/^\?/,"?index&"):"?index"),"/"!==a&&(f.pathname="/"===f.pathname?a:v([a,f.pathname])),l(f)}!function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmitImpl="useSubmitImpl",e.UseFetcher="useFetcher"}(O||(O={})),function(e){e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(K||(K={}));let $=0;function J(){let{router:t}=j(O.UseFetcher),r=e.useContext(u);r||y(!1);let n=r.matches[r.matches.length-1]?.route.id;null==n&&y(!1);let[o]=e.useState((()=>String(++$))),[a]=e.useState((()=>(n||y(!1),function(t,r){return e.forwardRef(((n,o)=>e.createElement(k,Object.assign({},n,{ref:o,fetcherKey:t,routeId:r}))))}(o,n)))),[i]=e.useState((()=>e=>{t||y(!1),n||y(!1),t.fetch(o,n,e)})),s=W(o,n),l=t.getFetcher(o),c=e.useMemo((()=>({Form:a,submit:s,load:i,...l})),[l,a,s,i]);return e.useEffect((()=>()=>{t?t.deleteFetcher(o):console.warn("No fetcher available to clean up from useFetcher()")}),[t,o]),c}function V(){return[...z(K.UseFetchers).fetchers.values()]}let q={};function G({getKey:t,storageKey:r}={}){let{router:n}=j(O.UseScrollRestoration),{restoreScrollPosition:a,preventScrollReset:i}=z(K.UseScrollRestoration),s=o(),l=c(),u=f();e.useEffect((()=>(window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration="auto"})),[]),function(t,r){let{capture:n}=r||{};e.useEffect((()=>{let e=null!=n?{capture:n}:void 0;return window.addEventListener("pagehide",t,e),()=>{window.removeEventListener("pagehide",t,e)}}),[t,n])}(e.useCallback((()=>{if("idle"===u.state){let e=(t?t(s,l):null)||s.key;q[e]=window.scrollY}sessionStorage.setItem(r||"react-router-scroll-positions",JSON.stringify(q)),window.history.scrollRestoration="auto"}),[r,t,u.state,s,l])),"undefined"!=typeof document&&(e.useLayoutEffect((()=>{try{let e=sessionStorage.getItem(r||"react-router-scroll-positions");e&&(q=JSON.parse(e))}catch(e){}}),[r]),e.useLayoutEffect((()=>{let e=n?.enableScrollRestoration(q,(()=>window.scrollY),t);return()=>e&&e()}),[n,t]),e.useLayoutEffect((()=>{if(!1!==a)if("number"!=typeof a){if(s.hash){let e=document.getElementById(s.hash.slice(1));if(e)return void e.scrollIntoView()}!0!==i&&window.scrollTo(0,0)}else window.scrollTo(0,a)}),[s,a,i]))}function Q(t,r){let{capture:n}=r||{};e.useEffect((()=>{let e=null!=n?{capture:n}:void 0;return window.addEventListener("beforeunload",t,e),()=>{window.removeEventListener("beforeunload",t,e)}}),[t,n])}function X({when:t,message:r}){let n=m(t);e.useEffect((()=>{"blocked"!==n.state||t||n.reset()}),[n,t]),e.useEffect((()=>{if("blocked"===n.state){window.confirm(r)?setTimeout(n.proceed,0):n.reset()}}),[n,r])}export{U as BrowserRouter,_ as Form,D as HashRouter,P as Link,T as NavLink,I as ScrollRestoration,G as UNSAFE_useScrollRestoration,C as createBrowserRouter,L as createHashRouter,E as createSearchParams,F as unstable_HistoryRouter,X as unstable_usePrompt,Q as useBeforeUnload,J as useFetcher,V as useFetchers,Y as useFormAction,M as useLinkClickHandler,B as useSearchParams,H as useSubmit}; | ||
import*as e from"react";import{UNSAFE_detectErrorBoundary as t,Router as r,UNSAFE_NavigationContext as n,useHref as o,useResolvedPath as a,useLocation as i,UNSAFE_DataRouterStateContext as s,useNavigate as u,createPath as l,UNSAFE_RouteContext as c,useMatches as f,useNavigation as m,unstable_useBlocker as d,UNSAFE_DataRouterContext as h}from"react-router";export{AbortedDeferredError,Await,MemoryRouter,Navigate,NavigationType,Outlet,Route,Router,RouterProvider,Routes,UNSAFE_DataRouterContext,UNSAFE_DataRouterStateContext,UNSAFE_LocationContext,UNSAFE_NavigationContext,UNSAFE_RouteContext,createMemoryRouter,createPath,createRoutesFromChildren,createRoutesFromElements,defer,generatePath,isRouteErrorResponse,json,matchPath,matchRoutes,parsePath,redirect,renderMatches,resolvePath,unstable_useBlocker,useActionData,useAsyncError,useAsyncValue,useHref,useInRouterContext,useLoaderData,useLocation,useMatch,useMatches,useNavigate,useNavigation,useNavigationType,useOutlet,useOutletContext,useParams,useResolvedPath,useRevalidator,useRouteError,useRouteLoaderData,useRoutes}from"react-router";import{createRouter as p,createBrowserHistory as w,createHashHistory as g,ErrorResponse as y,stripBasename as v,UNSAFE_invariant as b,joinPaths as R}from"@remix-run/router";const E="application/x-www-form-urlencoded";function S(e){return null!=e&&"string"==typeof e.tagName}function C(e=""){return new URLSearchParams("string"==typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce(((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map((e=>[r,e])):[[r,n]])}),[]))}function L(e,t,r){let n,o,a,i;if(S(s=e)&&"form"===s.tagName.toLowerCase()){let s=r.submissionTrigger;n=r.method||e.getAttribute("method")||"get",o=r.action||e.getAttribute("action")||t,a=r.encType||e.getAttribute("enctype")||E,i=new FormData(e),s&&s.name&&i.append(s.name,s.value)}else if(function(e){return S(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return S(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let s=e.form;if(null==s)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');n=r.method||e.getAttribute("formmethod")||s.getAttribute("method")||"get",o=r.action||e.getAttribute("formaction")||s.getAttribute("action")||t,a=r.encType||e.getAttribute("formenctype")||s.getAttribute("enctype")||E,i=new FormData(s),e.name&&i.append(e.name,e.value)}else{if(S(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');if(n=r.method||"get",o=r.action||t,a=r.encType||E,e instanceof FormData)i=e;else if(i=new FormData,e instanceof URLSearchParams)for(let[t,r]of e)i.append(t,r);else if(null!=e)for(let t of Object.keys(e))i.append(t,e[t])}var s;let{protocol:u,host:l}=window.location;return{url:new URL(o,`${u}//${l}`),method:n.toLowerCase(),encType:a,formData:i}}function A(e,r){return p({basename:r?.basename,history:w({window:r?.window}),hydrationData:r?.hydrationData||U(),routes:e,detectErrorBoundary:t}).initialize()}function x(e,r){return p({basename:r?.basename,history:g({window:r?.window}),hydrationData:r?.hydrationData||U(),routes:e,detectErrorBoundary:t}).initialize()}function U(){let e=window?.__staticRouterHydrationData;return e&&e.errors&&(e={...e,errors:D(e.errors)}),e}function D(e){if(!e)return null;let t=Object.entries(e),r={};for(let[n,o]of t)if(o&&"RouteErrorResponse"===o.__type)r[n]=new y(o.status,o.statusText,o.data,!0===o.internal);else if(o&&"Error"===o.__type){let e=new Error(o.message);e.stack="",r[n]=e}else r[n]=o;return r}function F({basename:t,children:n,window:o}){let a=e.useRef();null==a.current&&(a.current=w({window:o,v5Compat:!0}));let i=a.current,[s,u]=e.useState({action:i.action,location:i.location});return e.useLayoutEffect((()=>i.listen(u)),[i]),e.createElement(r,{basename:t,children:n,location:s.location,navigationType:s.action,navigator:i})}function N({basename:t,children:n,window:o}){let a=e.useRef();null==a.current&&(a.current=g({window:o,v5Compat:!0}));let i=a.current,[s,u]=e.useState({action:i.action,location:i.location});return e.useLayoutEffect((()=>i.listen(u)),[i]),e.createElement(r,{basename:t,children:n,location:s.location,navigationType:s.action,navigator:i})}function P({basename:t,children:n,history:o}){const[a,i]=e.useState({action:o.action,location:o.location});return e.useLayoutEffect((()=>o.listen(i)),[o]),e.createElement(r,{basename:t,children:n,location:a.location,navigationType:a.action,navigator:o})}const T="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,_=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,k=e.forwardRef((function({onClick:t,relative:r,reloadDocument:a,replace:i,state:s,target:u,to:l,preventScrollReset:c,...f},m){let d,{basename:h}=e.useContext(n),p=!1;if("string"==typeof l&&_.test(l)&&(d=l,T)){let e=new URL(window.location.href),t=l.startsWith("//")?new URL(e.protocol+l):new URL(l),r=v(t.pathname,h);t.origin===e.origin&&null!=r?l=r+t.search+t.hash:p=!0}let w=o(l,{relative:r}),g=W(l,{replace:i,state:s,target:u,preventScrollReset:c,relative:r});return e.createElement("a",Object.assign({},f,{href:d||w,onClick:p||a?t:function(e){t&&t(e),e.defaultPrevented||g(e)},ref:m,target:u}))})),O=e.forwardRef((function({"aria-current":t="page",caseSensitive:r=!1,className:o="",end:u=!1,style:l,to:c,children:f,...m},d){let h=a(c,{relative:m.relative}),p=i(),w=e.useContext(s),{navigator:g}=e.useContext(n),y=g.encodeLocation?g.encodeLocation(h).pathname:h.pathname,v=p.pathname,b=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;r||(v=v.toLowerCase(),b=b?b.toLowerCase():null,y=y.toLowerCase());let R,E=v===y||!u&&v.startsWith(y)&&"/"===v.charAt(y.length),S=null!=b&&(b===y||!u&&b.startsWith(y)&&"/"===b.charAt(y.length)),C=E?t:void 0;R="function"==typeof o?o({isActive:E,isPending:S}):[o,E?"active":null,S?"pending":null].filter(Boolean).join(" ");let L="function"==typeof l?l({isActive:E,isPending:S}):l;return e.createElement(k,Object.assign({},m,{"aria-current":C,className:R,ref:d,style:L,to:c}),"function"==typeof f?f({isActive:E,isPending:S}):f)})),K=e.forwardRef(((t,r)=>e.createElement(j,Object.assign({},t,{ref:r})))),j=e.forwardRef((({reloadDocument:t,replace:r,method:n="get",action:o,onSubmit:a,fetcherKey:i,routeId:s,relative:u,preventScrollReset:l,...c},f)=>{let m=J(i,s),d="get"===n.toLowerCase()?"get":"post",h=V(o,{relative:u});return e.createElement("form",Object.assign({ref:f,method:d,action:h,onSubmit:t?a:e=>{if(a&&a(e),e.defaultPrevented)return;e.preventDefault();let t=e.nativeEvent.submitter,o=t?.getAttribute("formmethod")||n;m(t||e.currentTarget,{method:o,replace:r,relative:u,preventScrollReset:l})}},c))}));function I({getKey:e,storageKey:t}){return Z({getKey:e,storageKey:t}),null}var M,B;function z(t){let r=e.useContext(h);return r||b(!1),r}function H(t){let r=e.useContext(s);return r||b(!1),r}function W(t,{target:r,replace:n,state:o,preventScrollReset:s,relative:c}={}){let f=u(),m=i(),d=a(t,{relative:c});return e.useCallback((e=>{if(function(e,t){return!(0!==e.button||t&&"_self"!==t||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e))}(e,r)){e.preventDefault();let r=void 0!==n?n:l(m)===l(d);f(t,{replace:r,state:o,preventScrollReset:s,relative:c})}}),[m,f,d,n,o,r,t,s,c])}function Y(t){let r=e.useRef(C(t)),n=e.useRef(!1),o=i(),a=e.useMemo((()=>function(e,t){let r=C(e);if(t)for(let n of t.keys())r.has(n)||t.getAll(n).forEach((e=>{r.append(n,e)}));return r}(o.search,n.current?null:r.current)),[o.search]),s=u(),l=e.useCallback(((e,t)=>{const r=C("function"==typeof e?e(a):e);n.current=!0,s("?"+r,t)}),[s,a]);return[a,l]}function $(){return J()}function J(t,r){let{router:n}=z(M.UseSubmitImpl),o=V();return e.useCallback(((e,a={})=>{if("undefined"==typeof document)throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");let{method:i,encType:s,formData:u,url:l}=L(e,o,a),c=l.pathname+l.search,f={replace:a.replace,preventScrollReset:a.preventScrollReset,formData:u,formMethod:i,formEncType:s};t?(null==r&&b(!1),n.fetch(t,r,c,f)):n.navigate(c,f)}),[o,n,t,r])}function V(t,{relative:r}={}){let{basename:o}=e.useContext(n),s=e.useContext(c);s||b(!1);let[u]=s.matches.slice(-1),f={...a(t||".",{relative:r})},m=i();if(null==t&&(f.search=m.search,f.hash=m.hash,u.route.index)){let e=new URLSearchParams(f.search);e.delete("index"),f.search=e.toString()?`?${e.toString()}`:""}return t&&"."!==t||!u.route.index||(f.search=f.search?f.search.replace(/^\?/,"?index&"):"?index"),"/"!==o&&(f.pathname="/"===f.pathname?o:R([o,f.pathname])),l(f)}!function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmitImpl="useSubmitImpl",e.UseFetcher="useFetcher"}(M||(M={})),function(e){e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(B||(B={}));let q=0;function G(){let{router:t}=z(M.UseFetcher),r=e.useContext(c);r||b(!1);let n=r.matches[r.matches.length-1]?.route.id;null==n&&b(!1);let[o]=e.useState((()=>String(++q))),[a]=e.useState((()=>(n||b(!1),function(t,r){return e.forwardRef(((n,o)=>e.createElement(j,Object.assign({},n,{ref:o,fetcherKey:t,routeId:r}))))}(o,n)))),[i]=e.useState((()=>e=>{t||b(!1),n||b(!1),t.fetch(o,n,e)})),s=J(o,n),u=t.getFetcher(o),l=e.useMemo((()=>({Form:a,submit:s,load:i,...u})),[u,a,s,i]);return e.useEffect((()=>()=>{t?t.deleteFetcher(o):console.warn("No fetcher available to clean up from useFetcher()")}),[t,o]),l}function Q(){return[...H(B.UseFetchers).fetchers.values()]}let X={};function Z({getKey:t,storageKey:r}={}){let{router:n}=z(M.UseScrollRestoration),{restoreScrollPosition:o,preventScrollReset:a}=H(B.UseScrollRestoration),s=i(),u=f(),l=m();e.useEffect((()=>(window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration="auto"})),[]),function(t,r){let{capture:n}=r||{};e.useEffect((()=>{let e=null!=n?{capture:n}:void 0;return window.addEventListener("pagehide",t,e),()=>{window.removeEventListener("pagehide",t,e)}}),[t,n])}(e.useCallback((()=>{if("idle"===l.state){let e=(t?t(s,u):null)||s.key;X[e]=window.scrollY}sessionStorage.setItem(r||"react-router-scroll-positions",JSON.stringify(X)),window.history.scrollRestoration="auto"}),[r,t,l.state,s,u])),"undefined"!=typeof document&&(e.useLayoutEffect((()=>{try{let e=sessionStorage.getItem(r||"react-router-scroll-positions");e&&(X=JSON.parse(e))}catch(e){}}),[r]),e.useLayoutEffect((()=>{let e=n?.enableScrollRestoration(X,(()=>window.scrollY),t);return()=>e&&e()}),[n,t]),e.useLayoutEffect((()=>{if(!1!==o)if("number"!=typeof o){if(s.hash){let e=document.getElementById(s.hash.slice(1));if(e)return void e.scrollIntoView()}!0!==a&&window.scrollTo(0,0)}else window.scrollTo(0,o)}),[s,o,a]))}function ee(t,r){let{capture:n}=r||{};e.useEffect((()=>{let e=null!=n?{capture:n}:void 0;return window.addEventListener("beforeunload",t,e),()=>{window.removeEventListener("beforeunload",t,e)}}),[t,n])}function te({when:t,message:r}){let n=d(t);e.useEffect((()=>{"blocked"!==n.state||t||n.reset()}),[n,t]),e.useEffect((()=>{if("blocked"===n.state){window.confirm(r)?setTimeout(n.proceed,0):n.reset()}}),[n,r])}export{F as BrowserRouter,K as Form,N as HashRouter,k as Link,O as NavLink,I as ScrollRestoration,Z as UNSAFE_useScrollRestoration,A as createBrowserRouter,x as createHashRouter,C as createSearchParams,P as unstable_HistoryRouter,te as unstable_usePrompt,ee as useBeforeUnload,G as useFetcher,Q as useFetchers,V as useFormAction,W as useLinkClickHandler,Y as useSearchParams,$ as useSubmit}; | ||
//# sourceMappingURL=react-router-dom.production.min.js.map |
@@ -14,2 +14,3 @@ import * as React from "react"; | ||
export declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): JSX.Element; | ||
export { StaticHandlerContext }; | ||
export interface StaticRouterProviderProps { | ||
@@ -26,5 +27,4 @@ context: StaticHandlerContext; | ||
export declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): JSX.Element; | ||
declare type CreateStaticHandlerOptions = Omit<RouterCreateStaticHandlerOptions, "hasErrorBoundary">; | ||
declare type CreateStaticHandlerOptions = Omit<RouterCreateStaticHandlerOptions, "detectErrorBoundary">; | ||
export declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): import("@remix-run/router").StaticHandler; | ||
export declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext): RemixRouter; | ||
export {}; |
@@ -72,3 +72,3 @@ 'use strict'; | ||
}) { | ||
!(router$1 && context) ? process.env.NODE_ENV !== "production" ? router.invariant(false, "You must provide `router` and `context` to <StaticRouterProvider>") : router.invariant(false) : void 0; | ||
!(router$1 && context) ? process.env.NODE_ENV !== "production" ? router.UNSAFE_invariant(false, "You must provide `router` and `context` to <StaticRouterProvider>") : router.UNSAFE_invariant(false) : void 0; | ||
let dataRouterContext = { | ||
@@ -93,3 +93,3 @@ router: router$1, | ||
let json = JSON.stringify(JSON.stringify(data)); | ||
let json = htmlEscape(JSON.stringify(JSON.stringify(data))); | ||
hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json});`; | ||
@@ -170,7 +170,7 @@ } | ||
let hasErrorBoundary = route => Boolean(route.errorElement); | ||
let detectErrorBoundary = route => Boolean(route.errorElement); | ||
function createStaticHandler(routes, opts) { | ||
return router.createStaticHandler(routes, { ...opts, | ||
hasErrorBoundary | ||
detectErrorBoundary | ||
}); | ||
@@ -180,3 +180,3 @@ } | ||
let manifest = {}; | ||
let dataRoutes = router.UNSAFE_convertRoutesToDataRoutes(routes, hasErrorBoundary, undefined, manifest); // Because our context matches may be from a framework-agnostic set of | ||
let dataRoutes = router.UNSAFE_convertRoutesToDataRoutes(routes, detectErrorBoundary, undefined, manifest); // Because our context matches may be from a framework-agnostic set of | ||
// routes passed to createStaticHandler(), we update them here with our | ||
@@ -269,3 +269,8 @@ // newly created/enhanced data routes | ||
_internalFetchControllers: new Map(), | ||
_internalActiveDeferreds: new Map() | ||
_internalActiveDeferreds: new Map(), | ||
_internalSetRoutes() { | ||
throw msg("_internalSetRoutes"); | ||
} | ||
}; | ||
@@ -286,2 +291,17 @@ } | ||
}; | ||
} // This utility is based on https://github.com/zertosh/htmlescape | ||
// License: https://github.com/zertosh/htmlescape/blob/0527ca7156a524d256101bb310a9f970f63078ad/LICENSE | ||
const ESCAPE_LOOKUP = { | ||
"&": "\\u0026", | ||
">": "\\u003e", | ||
"<": "\\u003c", | ||
"\u2028": "\\u2028", | ||
"\u2029": "\\u2029" | ||
}; | ||
const ESCAPE_REGEX = /[&><\u2028\u2029]/g; | ||
function htmlEscape(str) { | ||
return str.replace(ESCAPE_REGEX, match => ESCAPE_LOOKUP[match]); | ||
} | ||
@@ -288,0 +308,0 @@ |
/** | ||
* React Router DOM v0.0.0-experimental-63b6834e | ||
* React Router DOM v0.0.0-experimental-91f2bf54 | ||
* | ||
@@ -226,4 +226,3 @@ * Copyright (c) Remix Software Inc. | ||
routes, | ||
hasErrorBoundary: route => Boolean(route.errorElement), | ||
onInitialize: opts == null ? void 0 : opts.onInitialize | ||
detectErrorBoundary: reactRouter.UNSAFE_detectErrorBoundary | ||
}).initialize(); | ||
@@ -239,4 +238,3 @@ } | ||
routes, | ||
hasErrorBoundary: route => Boolean(route.errorElement), | ||
onInitialize: opts == null ? void 0 : opts.onInitialize | ||
detectErrorBoundary: reactRouter.UNSAFE_detectErrorBoundary | ||
}).initialize(); | ||
@@ -384,2 +382,3 @@ } | ||
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined"; | ||
const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i; | ||
/** | ||
@@ -402,16 +401,24 @@ * The public API for rendering a history-aware <a>. | ||
// Rendered into <a href> for absolute URLs | ||
let { | ||
basename | ||
} = React__namespace.useContext(reactRouter.UNSAFE_NavigationContext); // Rendered into <a href> for absolute URLs | ||
let absoluteHref; | ||
let isExternal = false; | ||
if (isBrowser && typeof to === "string" && /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(to)) { | ||
absoluteHref = to; | ||
let currentUrl = new URL(window.location.href); | ||
let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to); | ||
if (typeof to === "string" && ABSOLUTE_URL_REGEX.test(to)) { | ||
// Render the absolute href server- and client-side | ||
absoluteHref = to; // Only check for external origins client-side | ||
if (targetUrl.origin === currentUrl.origin) { | ||
// Strip the protocol/origin for same-origin absolute URLs | ||
to = targetUrl.pathname + targetUrl.search + targetUrl.hash; | ||
} else { | ||
isExternal = true; | ||
if (isBrowser) { | ||
let currentUrl = new URL(window.location.href); | ||
let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to); | ||
let path = router.stripBasename(targetUrl.pathname, basename); | ||
if (targetUrl.origin === currentUrl.origin && path != null) { | ||
// Strip the protocol/origin/basename for same-origin absolute URLs | ||
to = path + targetUrl.search + targetUrl.hash; | ||
} else { | ||
isExternal = true; | ||
} | ||
} | ||
@@ -635,3 +642,3 @@ } // Rendered into <a href> for relative URLs | ||
let ctx = React__namespace.useContext(reactRouter.UNSAFE_DataRouterContext); | ||
!ctx ? router.invariant(false, getDataRouterConsoleError(hookName)) : void 0; | ||
!ctx ? router.UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : void 0; | ||
return ctx; | ||
@@ -642,3 +649,3 @@ } | ||
let state = React__namespace.useContext(reactRouter.UNSAFE_DataRouterStateContext); | ||
!state ? router.invariant(false, getDataRouterConsoleError(hookName)) : void 0; | ||
!state ? router.UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : void 0; | ||
return state; | ||
@@ -687,3 +694,3 @@ } | ||
function useSearchParams(defaultInit) { | ||
warning(typeof URLSearchParams !== "undefined", "You cannot use the `useSearchParams` hook in a browser that does not " + "support the URLSearchParams API. If you need to support Internet " + "Explorer 11, we recommend you load a polyfill such as " + "https://github.com/ungap/url-search-params\n\n" + "If you're unsure how to load polyfills, we recommend you check out " + "https://polyfill.io/v3/ which provides some recommendations about how " + "to load polyfills only for users that need them, instead of for every " + "user.") ; | ||
router.UNSAFE_warning(typeof URLSearchParams !== "undefined", "You cannot use the `useSearchParams` hook in a browser that does not " + "support the URLSearchParams API. If you need to support Internet " + "Explorer 11, we recommend you load a polyfill such as " + "https://github.com/ungap/url-search-params\n\n" + "If you're unsure how to load polyfills, we recommend you check out " + "https://polyfill.io/v3/ which provides some recommendations about how " + "to load polyfills only for users that need them, instead of for every " + "user.") ; | ||
let defaultSearchParamsRef = React__namespace.useRef(createSearchParams(defaultInit)); | ||
@@ -743,3 +750,3 @@ let hasSetSearchParamsRef = React__namespace.useRef(false); | ||
if (fetcherKey) { | ||
!(routeId != null) ? router.invariant(false, "No routeId available for useFetcher()") : void 0; | ||
!(routeId != null) ? router.UNSAFE_invariant(false, "No routeId available for useFetcher()") : void 0; | ||
router$1.fetch(fetcherKey, routeId, href, opts); | ||
@@ -760,3 +767,3 @@ } else { | ||
let routeContext = React__namespace.useContext(reactRouter.UNSAFE_RouteContext); | ||
!routeContext ? router.invariant(false, "useFormAction must be used inside a RouteContext") : void 0; | ||
!routeContext ? router.UNSAFE_invariant(false, "useFormAction must be used inside a RouteContext") : void 0; | ||
let [match] = routeContext.matches.slice(-1); // Shallow clone path so we can modify it below, otherwise we modify the | ||
@@ -836,13 +843,13 @@ // object referenced by useMemo inside useResolvedPath | ||
let route = React__namespace.useContext(reactRouter.UNSAFE_RouteContext); | ||
!route ? router.invariant(false, "useFetcher must be used inside a RouteContext") : void 0; | ||
!route ? router.UNSAFE_invariant(false, "useFetcher must be used inside a RouteContext") : void 0; | ||
let routeId = (_route$matches = route.matches[route.matches.length - 1]) == null ? void 0 : _route$matches.route.id; | ||
!(routeId != null) ? router.invariant(false, "useFetcher can only be used on routes that contain a unique \"id\"") : void 0; | ||
!(routeId != null) ? router.UNSAFE_invariant(false, "useFetcher can only be used on routes that contain a unique \"id\"") : void 0; | ||
let [fetcherKey] = React__namespace.useState(() => String(++fetcherId)); | ||
let [Form] = React__namespace.useState(() => { | ||
!routeId ? router.invariant(false, "No routeId available for fetcher.Form()") : void 0; | ||
!routeId ? router.UNSAFE_invariant(false, "No routeId available for fetcher.Form()") : void 0; | ||
return createFetcherForm(fetcherKey, routeId); | ||
}); | ||
let [load] = React__namespace.useState(() => href => { | ||
!router$1 ? router.invariant(false, "No router available for fetcher.load()") : void 0; | ||
!routeId ? router.invariant(false, "No routeId available for fetcher.load()") : void 0; | ||
!router$1 ? router.UNSAFE_invariant(false, "No router available for fetcher.load()") : void 0; | ||
!routeId ? router.UNSAFE_invariant(false, "No routeId available for fetcher.load()") : void 0; | ||
router$1.fetch(fetcherKey, routeId, href); | ||
@@ -981,3 +988,2 @@ }); | ||
function useBeforeUnload(callback, options) { | ||
@@ -1053,22 +1059,4 @@ let { | ||
} | ||
//////////////////////////////////////////////////////////////////////////////// | ||
//#region Utils | ||
//////////////////////////////////////////////////////////////////////////////// | ||
//#endregion | ||
function warning(cond, message) { | ||
if (!cond) { | ||
// eslint-disable-next-line no-console | ||
if (typeof console !== "undefined") console.warn(message); | ||
try { | ||
// Welcome to debugging React Router! | ||
// | ||
// This error is thrown as a convenience so you can more easily | ||
// find the source for a warning that appears in the console by | ||
// enabling "pause on exceptions" in your JavaScript debugger. | ||
throw new Error(message); // eslint-disable-next-line no-empty | ||
} catch (e) {} | ||
} | ||
} //#endregion | ||
Object.defineProperty(exports, 'AbortedDeferredError', { | ||
@@ -1075,0 +1063,0 @@ enumerable: true, |
/** | ||
* React Router DOM v0.0.0-experimental-63b6834e | ||
* React Router DOM v0.0.0-experimental-91f2bf54 | ||
* | ||
@@ -11,3 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-router"),require("@remix-run/router")):"function"==typeof define&&define.amd?define(["exports","react","react-router","@remix-run/router"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactRouterDOM={},e.React,e.ReactRouter,e.RemixRouter)}(this,(function(e,t,r,n){"use strict";function o(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=o(t);function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},u.apply(this,arguments)}function i(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}const c="get",l="application/x-www-form-urlencoded";function s(e){return null!=e&&"string"==typeof e.tagName}function f(e){return void 0===e&&(e=""),new URLSearchParams("string"==typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce(((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map((e=>[r,e])):[[r,n]])}),[]))}function d(e,t,r){let n,o,a,u;if(s(i=e)&&"form"===i.tagName.toLowerCase()){let i=r.submissionTrigger;n=r.method||e.getAttribute("method")||c,o=r.action||e.getAttribute("action")||t,a=r.encType||e.getAttribute("enctype")||l,u=new FormData(e),i&&i.name&&u.append(i.name,i.value)}else if(function(e){return s(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return s(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let i=e.form;if(null==i)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');n=r.method||e.getAttribute("formmethod")||i.getAttribute("method")||c,o=r.action||e.getAttribute("formaction")||i.getAttribute("action")||t,a=r.encType||e.getAttribute("formenctype")||i.getAttribute("enctype")||l,u=new FormData(i),e.name&&u.append(e.name,e.value)}else{if(s(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');if(n=r.method||c,o=r.action||t,a=r.encType||l,e instanceof FormData)u=e;else if(u=new FormData,e instanceof URLSearchParams)for(let[t,r]of e)u.append(t,r);else if(null!=e)for(let t of Object.keys(e))u.append(t,e[t])}var i;let{protocol:f,host:d}=window.location;return{url:new URL(o,f+"//"+d),method:n.toLowerCase(),encType:a,formData:u}}const m=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset"],b=["aria-current","caseSensitive","className","end","style","to","children"],p=["reloadDocument","replace","method","action","onSubmit","fetcherKey","routeId","relative","preventScrollReset"];function h(){var e;let t=null==(e=window)?void 0:e.__staticRouterHydrationData;return t&&t.errors&&(t=u({},t,{errors:y(t.errors)})),t}function y(e){if(!e)return null;let t=Object.entries(e),r={};for(let[e,o]of t)if(o&&"RouteErrorResponse"===o.__type)r[e]=new n.ErrorResponse(o.status,o.statusText,o.data,!0===o.internal);else if(o&&"Error"===o.__type){let t=new Error(o.message);t.stack="",r[e]=t}else r[e]=o;return r}const g="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,v=a.forwardRef((function(e,t){let n,{onClick:o,relative:c,reloadDocument:l,replace:s,state:f,target:d,to:b,preventScrollReset:p}=e,h=i(e,m),y=!1;if(g&&"string"==typeof b&&/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(b)){n=b;let e=new URL(window.location.href),t=b.startsWith("//")?new URL(e.protocol+b):new URL(b);t.origin===e.origin?b=t.pathname+t.search+t.hash:y=!0}let v=r.useHref(b,{relative:c}),R=C(b,{replace:s,state:f,target:d,preventScrollReset:p,relative:c});return a.createElement("a",u({},h,{href:n||v,onClick:y||l?o:function(e){o&&o(e),e.defaultPrevented||R(e)},ref:t,target:d}))})),R=a.forwardRef((function(e,t){let{"aria-current":n="page",caseSensitive:o=!1,className:c="",end:l=!1,style:s,to:f,children:d}=e,m=i(e,b),p=r.useResolvedPath(f,{relative:m.relative}),h=r.useLocation(),y=a.useContext(r.UNSAFE_DataRouterStateContext),{navigator:g}=a.useContext(r.UNSAFE_NavigationContext),R=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,w=h.pathname,P=y&&y.navigation&&y.navigation.location?y.navigation.location.pathname:null;o||(w=w.toLowerCase(),P=P?P.toLowerCase():null,R=R.toLowerCase());let O,S=w===R||!l&&w.startsWith(R)&&"/"===w.charAt(R.length),E=null!=P&&(P===R||!l&&P.startsWith(R)&&"/"===P.charAt(R.length)),j=S?n:void 0;O="function"==typeof c?c({isActive:S,isPending:E}):[c,S?"active":null,E?"pending":null].filter(Boolean).join(" ");let C="function"==typeof s?s({isActive:S,isPending:E}):s;return a.createElement(v,u({},m,{"aria-current":j,className:O,ref:t,style:C,to:f}),"function"==typeof d?d({isActive:S,isPending:E}):d)})),w=a.forwardRef(((e,t)=>a.createElement(P,u({},e,{ref:t})))),P=a.forwardRef(((e,t)=>{let{reloadDocument:r,replace:n,method:o=c,action:l,onSubmit:s,fetcherKey:f,routeId:d,relative:m,preventScrollReset:b}=e,h=i(e,p),y=A(f,d),g="get"===o.toLowerCase()?"get":"post",v=N(l,{relative:m});return a.createElement("form",u({ref:t,method:g,action:v,onSubmit:r?s:e=>{if(s&&s(e),e.defaultPrevented)return;e.preventDefault();let t=e.nativeEvent.submitter,r=(null==t?void 0:t.getAttribute("formmethod"))||o;y(t||e.currentTarget,{method:r,replace:n,relative:m,preventScrollReset:b})}},h))}));var O,S;function E(e){let t=a.useContext(r.UNSAFE_DataRouterContext);return t||n.invariant(!1),t}function j(e){let t=a.useContext(r.UNSAFE_DataRouterStateContext);return t||n.invariant(!1),t}function C(e,t){let{target:n,replace:o,state:u,preventScrollReset:i,relative:c}=void 0===t?{}:t,l=r.useNavigate(),s=r.useLocation(),f=r.useResolvedPath(e,{relative:c});return a.useCallback((t=>{if(function(e,t){return!(0!==e.button||t&&"_self"!==t||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e))}(t,n)){t.preventDefault();let n=void 0!==o?o:r.createPath(s)===r.createPath(f);l(e,{replace:n,state:u,preventScrollReset:i,relative:c})}}),[s,l,f,o,u,n,e,i,c])}function A(e,t){let{router:r}=E(O.UseSubmitImpl),o=N();return a.useCallback((function(a,u){if(void 0===u&&(u={}),"undefined"==typeof document)throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");let{method:i,encType:c,formData:l,url:s}=d(a,o,u),f=s.pathname+s.search,m={replace:u.replace,preventScrollReset:u.preventScrollReset,formData:l,formMethod:i,formEncType:c};e?(null==t&&n.invariant(!1),r.fetch(e,t,f,m)):r.navigate(f,m)}),[o,r,e,t])}function N(e,t){let{relative:o}=void 0===t?{}:t,{basename:i}=a.useContext(r.UNSAFE_NavigationContext),c=a.useContext(r.UNSAFE_RouteContext);c||n.invariant(!1);let[l]=c.matches.slice(-1),s=u({},r.useResolvedPath(e||".",{relative:o})),f=r.useLocation();if(null==e&&(s.search=f.search,s.hash=f.hash,l.route.index)){let e=new URLSearchParams(s.search);e.delete("index"),s.search=e.toString()?"?"+e.toString():""}return e&&"."!==e||!l.route.index||(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),"/"!==i&&(s.pathname="/"===s.pathname?i:n.joinPaths([i,s.pathname])),r.createPath(s)}!function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmitImpl="useSubmitImpl",e.UseFetcher="useFetcher"}(O||(O={})),function(e){e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(S||(S={}));let L=0;const x="react-router-scroll-positions";let F={};function U(e){let{getKey:t,storageKey:n}=void 0===e?{}:e,{router:o}=E(O.UseScrollRestoration),{restoreScrollPosition:u,preventScrollReset:i}=j(S.UseScrollRestoration),c=r.useLocation(),l=r.useMatches(),s=r.useNavigation();a.useEffect((()=>(window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration="auto"})),[]),function(e,t){let{capture:r}=t||{};a.useEffect((()=>{let t=null!=r?{capture:r}:void 0;return window.addEventListener("pagehide",e,t),()=>{window.removeEventListener("pagehide",e,t)}}),[e,r])}(a.useCallback((()=>{if("idle"===s.state){let e=(t?t(c,l):null)||c.key;F[e]=window.scrollY}sessionStorage.setItem(n||x,JSON.stringify(F)),window.history.scrollRestoration="auto"}),[n,t,s.state,c,l])),"undefined"!=typeof document&&(a.useLayoutEffect((()=>{try{let e=sessionStorage.getItem(n||x);e&&(F=JSON.parse(e))}catch(e){}}),[n]),a.useLayoutEffect((()=>{let e=null==o?void 0:o.enableScrollRestoration(F,(()=>window.scrollY),t);return()=>e&&e()}),[o,t]),a.useLayoutEffect((()=>{if(!1!==u)if("number"!=typeof u){if(c.hash){let e=document.getElementById(c.hash.slice(1));if(e)return void e.scrollIntoView()}!0!==i&&window.scrollTo(0,0)}else window.scrollTo(0,u)}),[c,u,i]))}Object.defineProperty(e,"AbortedDeferredError",{enumerable:!0,get:function(){return r.AbortedDeferredError}}),Object.defineProperty(e,"Await",{enumerable:!0,get:function(){return r.Await}}),Object.defineProperty(e,"MemoryRouter",{enumerable:!0,get:function(){return r.MemoryRouter}}),Object.defineProperty(e,"Navigate",{enumerable:!0,get:function(){return r.Navigate}}),Object.defineProperty(e,"NavigationType",{enumerable:!0,get:function(){return r.NavigationType}}),Object.defineProperty(e,"Outlet",{enumerable:!0,get:function(){return r.Outlet}}),Object.defineProperty(e,"Route",{enumerable:!0,get:function(){return r.Route}}),Object.defineProperty(e,"Router",{enumerable:!0,get:function(){return r.Router}}),Object.defineProperty(e,"RouterProvider",{enumerable:!0,get:function(){return r.RouterProvider}}),Object.defineProperty(e,"Routes",{enumerable:!0,get:function(){return r.Routes}}),Object.defineProperty(e,"UNSAFE_DataRouterContext",{enumerable:!0,get:function(){return r.UNSAFE_DataRouterContext}}),Object.defineProperty(e,"UNSAFE_DataRouterStateContext",{enumerable:!0,get:function(){return r.UNSAFE_DataRouterStateContext}}),Object.defineProperty(e,"UNSAFE_LocationContext",{enumerable:!0,get:function(){return r.UNSAFE_LocationContext}}),Object.defineProperty(e,"UNSAFE_NavigationContext",{enumerable:!0,get:function(){return r.UNSAFE_NavigationContext}}),Object.defineProperty(e,"UNSAFE_RouteContext",{enumerable:!0,get:function(){return r.UNSAFE_RouteContext}}),Object.defineProperty(e,"createMemoryRouter",{enumerable:!0,get:function(){return r.createMemoryRouter}}),Object.defineProperty(e,"createPath",{enumerable:!0,get:function(){return r.createPath}}),Object.defineProperty(e,"createRoutesFromChildren",{enumerable:!0,get:function(){return r.createRoutesFromChildren}}),Object.defineProperty(e,"createRoutesFromElements",{enumerable:!0,get:function(){return r.createRoutesFromElements}}),Object.defineProperty(e,"defer",{enumerable:!0,get:function(){return r.defer}}),Object.defineProperty(e,"generatePath",{enumerable:!0,get:function(){return r.generatePath}}),Object.defineProperty(e,"isRouteErrorResponse",{enumerable:!0,get:function(){return r.isRouteErrorResponse}}),Object.defineProperty(e,"json",{enumerable:!0,get:function(){return r.json}}),Object.defineProperty(e,"matchPath",{enumerable:!0,get:function(){return r.matchPath}}),Object.defineProperty(e,"matchRoutes",{enumerable:!0,get:function(){return r.matchRoutes}}),Object.defineProperty(e,"parsePath",{enumerable:!0,get:function(){return r.parsePath}}),Object.defineProperty(e,"redirect",{enumerable:!0,get:function(){return r.redirect}}),Object.defineProperty(e,"renderMatches",{enumerable:!0,get:function(){return r.renderMatches}}),Object.defineProperty(e,"resolvePath",{enumerable:!0,get:function(){return r.resolvePath}}),Object.defineProperty(e,"unstable_useBlocker",{enumerable:!0,get:function(){return r.unstable_useBlocker}}),Object.defineProperty(e,"useActionData",{enumerable:!0,get:function(){return r.useActionData}}),Object.defineProperty(e,"useAsyncError",{enumerable:!0,get:function(){return r.useAsyncError}}),Object.defineProperty(e,"useAsyncValue",{enumerable:!0,get:function(){return r.useAsyncValue}}),Object.defineProperty(e,"useHref",{enumerable:!0,get:function(){return r.useHref}}),Object.defineProperty(e,"useInRouterContext",{enumerable:!0,get:function(){return r.useInRouterContext}}),Object.defineProperty(e,"useLoaderData",{enumerable:!0,get:function(){return r.useLoaderData}}),Object.defineProperty(e,"useLocation",{enumerable:!0,get:function(){return r.useLocation}}),Object.defineProperty(e,"useMatch",{enumerable:!0,get:function(){return r.useMatch}}),Object.defineProperty(e,"useMatches",{enumerable:!0,get:function(){return r.useMatches}}),Object.defineProperty(e,"useNavigate",{enumerable:!0,get:function(){return r.useNavigate}}),Object.defineProperty(e,"useNavigation",{enumerable:!0,get:function(){return r.useNavigation}}),Object.defineProperty(e,"useNavigationType",{enumerable:!0,get:function(){return r.useNavigationType}}),Object.defineProperty(e,"useOutlet",{enumerable:!0,get:function(){return r.useOutlet}}),Object.defineProperty(e,"useOutletContext",{enumerable:!0,get:function(){return r.useOutletContext}}),Object.defineProperty(e,"useParams",{enumerable:!0,get:function(){return r.useParams}}),Object.defineProperty(e,"useResolvedPath",{enumerable:!0,get:function(){return r.useResolvedPath}}),Object.defineProperty(e,"useRevalidator",{enumerable:!0,get:function(){return r.useRevalidator}}),Object.defineProperty(e,"useRouteError",{enumerable:!0,get:function(){return r.useRouteError}}),Object.defineProperty(e,"useRouteLoaderData",{enumerable:!0,get:function(){return r.useRouteLoaderData}}),Object.defineProperty(e,"useRoutes",{enumerable:!0,get:function(){return r.useRoutes}}),e.BrowserRouter=function(e){let{basename:t,children:o,window:u}=e,i=a.useRef();null==i.current&&(i.current=n.createBrowserHistory({window:u,v5Compat:!0}));let c=i.current,[l,s]=a.useState({action:c.action,location:c.location});return a.useLayoutEffect((()=>c.listen(s)),[c]),a.createElement(r.Router,{basename:t,children:o,location:l.location,navigationType:l.action,navigator:c})},e.Form=w,e.HashRouter=function(e){let{basename:t,children:o,window:u}=e,i=a.useRef();null==i.current&&(i.current=n.createHashHistory({window:u,v5Compat:!0}));let c=i.current,[l,s]=a.useState({action:c.action,location:c.location});return a.useLayoutEffect((()=>c.listen(s)),[c]),a.createElement(r.Router,{basename:t,children:o,location:l.location,navigationType:l.action,navigator:c})},e.Link=v,e.NavLink=R,e.ScrollRestoration=function(e){let{getKey:t,storageKey:r}=e;return U({getKey:t,storageKey:r}),null},e.UNSAFE_useScrollRestoration=U,e.createBrowserRouter=function(e,t){return n.createRouter({basename:null==t?void 0:t.basename,history:n.createBrowserHistory({window:null==t?void 0:t.window}),hydrationData:(null==t?void 0:t.hydrationData)||h(),routes:e,hasErrorBoundary:e=>Boolean(e.errorElement),onInitialize:null==t?void 0:t.onInitialize}).initialize()},e.createHashRouter=function(e,t){return n.createRouter({basename:null==t?void 0:t.basename,history:n.createHashHistory({window:null==t?void 0:t.window}),hydrationData:(null==t?void 0:t.hydrationData)||h(),routes:e,hasErrorBoundary:e=>Boolean(e.errorElement),onInitialize:null==t?void 0:t.onInitialize}).initialize()},e.createSearchParams=f,e.unstable_HistoryRouter=function(e){let{basename:t,children:n,history:o}=e;const[u,i]=a.useState({action:o.action,location:o.location});return a.useLayoutEffect((()=>o.listen(i)),[o]),a.createElement(r.Router,{basename:t,children:n,location:u.location,navigationType:u.action,navigator:o})},e.unstable_usePrompt=function(e){let{when:t,message:n}=e,o=r.unstable_useBlocker(t);a.useEffect((()=>{"blocked"!==o.state||t||o.reset()}),[o,t]),a.useEffect((()=>{if("blocked"===o.state){window.confirm(n)?setTimeout(o.proceed,0):o.reset()}}),[o,n])},e.useBeforeUnload=function(e,t){let{capture:r}=t||{};a.useEffect((()=>{let t=null!=r?{capture:r}:void 0;return window.addEventListener("beforeunload",e,t),()=>{window.removeEventListener("beforeunload",e,t)}}),[e,r])},e.useFetcher=function(){var e;let{router:t}=E(O.UseFetcher),o=a.useContext(r.UNSAFE_RouteContext);o||n.invariant(!1);let i=null==(e=o.matches[o.matches.length-1])?void 0:e.route.id;null==i&&n.invariant(!1);let[c]=a.useState((()=>String(++L))),[l]=a.useState((()=>(i||n.invariant(!1),function(e,t){return a.forwardRef(((r,n)=>a.createElement(P,u({},r,{ref:n,fetcherKey:e,routeId:t}))))}(c,i)))),[s]=a.useState((()=>e=>{t||n.invariant(!1),i||n.invariant(!1),t.fetch(c,i,e)})),f=A(c,i),d=t.getFetcher(c),m=a.useMemo((()=>u({Form:l,submit:f,load:s},d)),[d,l,f,s]);return a.useEffect((()=>()=>{t?t.deleteFetcher(c):console.warn("No fetcher available to clean up from useFetcher()")}),[t,c]),m},e.useFetchers=function(){return[...j(S.UseFetchers).fetchers.values()]},e.useFormAction=N,e.useLinkClickHandler=C,e.useSearchParams=function(e){let t=a.useRef(f(e)),n=a.useRef(!1),o=r.useLocation(),u=a.useMemo((()=>function(e,t){let r=f(e);if(t)for(let e of t.keys())r.has(e)||t.getAll(e).forEach((t=>{r.append(e,t)}));return r}(o.search,n.current?null:t.current)),[o.search]),i=r.useNavigate(),c=a.useCallback(((e,t)=>{const r=f("function"==typeof e?e(u):e);n.current=!0,i("?"+r,t)}),[i,u]);return[u,c]},e.useSubmit=function(){return A()},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-router"),require("@remix-run/router")):"function"==typeof define&&define.amd?define(["exports","react","react-router","@remix-run/router"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactRouterDOM={},e.React,e.ReactRouter,e.RemixRouter)}(this,(function(e,t,r,n){"use strict";function o(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=o(t);function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},u.apply(this,arguments)}function i(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}const c="get",l="application/x-www-form-urlencoded";function s(e){return null!=e&&"string"==typeof e.tagName}function f(e){return void 0===e&&(e=""),new URLSearchParams("string"==typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce(((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map((e=>[r,e])):[[r,n]])}),[]))}function d(e,t,r){let n,o,a,u;if(s(i=e)&&"form"===i.tagName.toLowerCase()){let i=r.submissionTrigger;n=r.method||e.getAttribute("method")||c,o=r.action||e.getAttribute("action")||t,a=r.encType||e.getAttribute("enctype")||l,u=new FormData(e),i&&i.name&&u.append(i.name,i.value)}else if(function(e){return s(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return s(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let i=e.form;if(null==i)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');n=r.method||e.getAttribute("formmethod")||i.getAttribute("method")||c,o=r.action||e.getAttribute("formaction")||i.getAttribute("action")||t,a=r.encType||e.getAttribute("formenctype")||i.getAttribute("enctype")||l,u=new FormData(i),e.name&&u.append(e.name,e.value)}else{if(s(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');if(n=r.method||c,o=r.action||t,a=r.encType||l,e instanceof FormData)u=e;else if(u=new FormData,e instanceof URLSearchParams)for(let[t,r]of e)u.append(t,r);else if(null!=e)for(let t of Object.keys(e))u.append(t,e[t])}var i;let{protocol:f,host:d}=window.location;return{url:new URL(o,f+"//"+d),method:n.toLowerCase(),encType:a,formData:u}}const m=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset"],b=["aria-current","caseSensitive","className","end","style","to","children"],p=["reloadDocument","replace","method","action","onSubmit","fetcherKey","routeId","relative","preventScrollReset"];function h(){var e;let t=null==(e=window)?void 0:e.__staticRouterHydrationData;return t&&t.errors&&(t=u({},t,{errors:y(t.errors)})),t}function y(e){if(!e)return null;let t=Object.entries(e),r={};for(let[e,o]of t)if(o&&"RouteErrorResponse"===o.__type)r[e]=new n.ErrorResponse(o.status,o.statusText,o.data,!0===o.internal);else if(o&&"Error"===o.__type){let t=new Error(o.message);t.stack="",r[e]=t}else r[e]=o;return r}const g="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,v=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,R=a.forwardRef((function(e,t){let o,{onClick:c,relative:l,reloadDocument:s,replace:f,state:d,target:b,to:p,preventScrollReset:h}=e,y=i(e,m),{basename:R}=a.useContext(r.UNSAFE_NavigationContext),w=!1;if("string"==typeof p&&v.test(p)&&(o=p,g)){let e=new URL(window.location.href),t=p.startsWith("//")?new URL(e.protocol+p):new URL(p),r=n.stripBasename(t.pathname,R);t.origin===e.origin&&null!=r?p=r+t.search+t.hash:w=!0}let P=r.useHref(p,{relative:l}),S=N(p,{replace:f,state:d,target:b,preventScrollReset:h,relative:l});return a.createElement("a",u({},y,{href:o||P,onClick:w||s?c:function(e){c&&c(e),e.defaultPrevented||S(e)},ref:t,target:b}))})),w=a.forwardRef((function(e,t){let{"aria-current":n="page",caseSensitive:o=!1,className:c="",end:l=!1,style:s,to:f,children:d}=e,m=i(e,b),p=r.useResolvedPath(f,{relative:m.relative}),h=r.useLocation(),y=a.useContext(r.UNSAFE_DataRouterStateContext),{navigator:g}=a.useContext(r.UNSAFE_NavigationContext),v=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,w=h.pathname,P=y&&y.navigation&&y.navigation.location?y.navigation.location.pathname:null;o||(w=w.toLowerCase(),P=P?P.toLowerCase():null,v=v.toLowerCase());let S,E=w===v||!l&&w.startsWith(v)&&"/"===w.charAt(v.length),O=null!=P&&(P===v||!l&&P.startsWith(v)&&"/"===P.charAt(v.length)),j=E?n:void 0;S="function"==typeof c?c({isActive:E,isPending:O}):[c,E?"active":null,O?"pending":null].filter(Boolean).join(" ");let A="function"==typeof s?s({isActive:E,isPending:O}):s;return a.createElement(R,u({},m,{"aria-current":j,className:S,ref:t,style:A,to:f}),"function"==typeof d?d({isActive:E,isPending:O}):d)})),P=a.forwardRef(((e,t)=>a.createElement(S,u({},e,{ref:t})))),S=a.forwardRef(((e,t)=>{let{reloadDocument:r,replace:n,method:o=c,action:l,onSubmit:s,fetcherKey:f,routeId:d,relative:m,preventScrollReset:b}=e,h=i(e,p),y=C(f,d),g="get"===o.toLowerCase()?"get":"post",v=F(l,{relative:m});return a.createElement("form",u({ref:t,method:g,action:v,onSubmit:r?s:e=>{if(s&&s(e),e.defaultPrevented)return;e.preventDefault();let t=e.nativeEvent.submitter,r=(null==t?void 0:t.getAttribute("formmethod"))||o;y(t||e.currentTarget,{method:r,replace:n,relative:m,preventScrollReset:b})}},h))}));var E,O;function j(e){let t=a.useContext(r.UNSAFE_DataRouterContext);return t||n.UNSAFE_invariant(!1),t}function A(e){let t=a.useContext(r.UNSAFE_DataRouterStateContext);return t||n.UNSAFE_invariant(!1),t}function N(e,t){let{target:n,replace:o,state:u,preventScrollReset:i,relative:c}=void 0===t?{}:t,l=r.useNavigate(),s=r.useLocation(),f=r.useResolvedPath(e,{relative:c});return a.useCallback((t=>{if(function(e,t){return!(0!==e.button||t&&"_self"!==t||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e))}(t,n)){t.preventDefault();let n=void 0!==o?o:r.createPath(s)===r.createPath(f);l(e,{replace:n,state:u,preventScrollReset:i,relative:c})}}),[s,l,f,o,u,n,e,i,c])}function C(e,t){let{router:r}=j(E.UseSubmitImpl),o=F();return a.useCallback((function(a,u){if(void 0===u&&(u={}),"undefined"==typeof document)throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");let{method:i,encType:c,formData:l,url:s}=d(a,o,u),f=s.pathname+s.search,m={replace:u.replace,preventScrollReset:u.preventScrollReset,formData:l,formMethod:i,formEncType:c};e?(null==t&&n.UNSAFE_invariant(!1),r.fetch(e,t,f,m)):r.navigate(f,m)}),[o,r,e,t])}function F(e,t){let{relative:o}=void 0===t?{}:t,{basename:i}=a.useContext(r.UNSAFE_NavigationContext),c=a.useContext(r.UNSAFE_RouteContext);c||n.UNSAFE_invariant(!1);let[l]=c.matches.slice(-1),s=u({},r.useResolvedPath(e||".",{relative:o})),f=r.useLocation();if(null==e&&(s.search=f.search,s.hash=f.hash,l.route.index)){let e=new URLSearchParams(s.search);e.delete("index"),s.search=e.toString()?"?"+e.toString():""}return e&&"."!==e||!l.route.index||(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),"/"!==i&&(s.pathname="/"===s.pathname?i:n.joinPaths([i,s.pathname])),r.createPath(s)}!function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmitImpl="useSubmitImpl",e.UseFetcher="useFetcher"}(E||(E={})),function(e){e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(O||(O={}));let U=0;const _="react-router-scroll-positions";let x={};function L(e){let{getKey:t,storageKey:n}=void 0===e?{}:e,{router:o}=j(E.UseScrollRestoration),{restoreScrollPosition:u,preventScrollReset:i}=A(O.UseScrollRestoration),c=r.useLocation(),l=r.useMatches(),s=r.useNavigation();a.useEffect((()=>(window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration="auto"})),[]),function(e,t){let{capture:r}=t||{};a.useEffect((()=>{let t=null!=r?{capture:r}:void 0;return window.addEventListener("pagehide",e,t),()=>{window.removeEventListener("pagehide",e,t)}}),[e,r])}(a.useCallback((()=>{if("idle"===s.state){let e=(t?t(c,l):null)||c.key;x[e]=window.scrollY}sessionStorage.setItem(n||_,JSON.stringify(x)),window.history.scrollRestoration="auto"}),[n,t,s.state,c,l])),"undefined"!=typeof document&&(a.useLayoutEffect((()=>{try{let e=sessionStorage.getItem(n||_);e&&(x=JSON.parse(e))}catch(e){}}),[n]),a.useLayoutEffect((()=>{let e=null==o?void 0:o.enableScrollRestoration(x,(()=>window.scrollY),t);return()=>e&&e()}),[o,t]),a.useLayoutEffect((()=>{if(!1!==u)if("number"!=typeof u){if(c.hash){let e=document.getElementById(c.hash.slice(1));if(e)return void e.scrollIntoView()}!0!==i&&window.scrollTo(0,0)}else window.scrollTo(0,u)}),[c,u,i]))}Object.defineProperty(e,"AbortedDeferredError",{enumerable:!0,get:function(){return r.AbortedDeferredError}}),Object.defineProperty(e,"Await",{enumerable:!0,get:function(){return r.Await}}),Object.defineProperty(e,"MemoryRouter",{enumerable:!0,get:function(){return r.MemoryRouter}}),Object.defineProperty(e,"Navigate",{enumerable:!0,get:function(){return r.Navigate}}),Object.defineProperty(e,"NavigationType",{enumerable:!0,get:function(){return r.NavigationType}}),Object.defineProperty(e,"Outlet",{enumerable:!0,get:function(){return r.Outlet}}),Object.defineProperty(e,"Route",{enumerable:!0,get:function(){return r.Route}}),Object.defineProperty(e,"Router",{enumerable:!0,get:function(){return r.Router}}),Object.defineProperty(e,"RouterProvider",{enumerable:!0,get:function(){return r.RouterProvider}}),Object.defineProperty(e,"Routes",{enumerable:!0,get:function(){return r.Routes}}),Object.defineProperty(e,"UNSAFE_DataRouterContext",{enumerable:!0,get:function(){return r.UNSAFE_DataRouterContext}}),Object.defineProperty(e,"UNSAFE_DataRouterStateContext",{enumerable:!0,get:function(){return r.UNSAFE_DataRouterStateContext}}),Object.defineProperty(e,"UNSAFE_LocationContext",{enumerable:!0,get:function(){return r.UNSAFE_LocationContext}}),Object.defineProperty(e,"UNSAFE_NavigationContext",{enumerable:!0,get:function(){return r.UNSAFE_NavigationContext}}),Object.defineProperty(e,"UNSAFE_RouteContext",{enumerable:!0,get:function(){return r.UNSAFE_RouteContext}}),Object.defineProperty(e,"createMemoryRouter",{enumerable:!0,get:function(){return r.createMemoryRouter}}),Object.defineProperty(e,"createPath",{enumerable:!0,get:function(){return r.createPath}}),Object.defineProperty(e,"createRoutesFromChildren",{enumerable:!0,get:function(){return r.createRoutesFromChildren}}),Object.defineProperty(e,"createRoutesFromElements",{enumerable:!0,get:function(){return r.createRoutesFromElements}}),Object.defineProperty(e,"defer",{enumerable:!0,get:function(){return r.defer}}),Object.defineProperty(e,"generatePath",{enumerable:!0,get:function(){return r.generatePath}}),Object.defineProperty(e,"isRouteErrorResponse",{enumerable:!0,get:function(){return r.isRouteErrorResponse}}),Object.defineProperty(e,"json",{enumerable:!0,get:function(){return r.json}}),Object.defineProperty(e,"matchPath",{enumerable:!0,get:function(){return r.matchPath}}),Object.defineProperty(e,"matchRoutes",{enumerable:!0,get:function(){return r.matchRoutes}}),Object.defineProperty(e,"parsePath",{enumerable:!0,get:function(){return r.parsePath}}),Object.defineProperty(e,"redirect",{enumerable:!0,get:function(){return r.redirect}}),Object.defineProperty(e,"renderMatches",{enumerable:!0,get:function(){return r.renderMatches}}),Object.defineProperty(e,"resolvePath",{enumerable:!0,get:function(){return r.resolvePath}}),Object.defineProperty(e,"unstable_useBlocker",{enumerable:!0,get:function(){return r.unstable_useBlocker}}),Object.defineProperty(e,"useActionData",{enumerable:!0,get:function(){return r.useActionData}}),Object.defineProperty(e,"useAsyncError",{enumerable:!0,get:function(){return r.useAsyncError}}),Object.defineProperty(e,"useAsyncValue",{enumerable:!0,get:function(){return r.useAsyncValue}}),Object.defineProperty(e,"useHref",{enumerable:!0,get:function(){return r.useHref}}),Object.defineProperty(e,"useInRouterContext",{enumerable:!0,get:function(){return r.useInRouterContext}}),Object.defineProperty(e,"useLoaderData",{enumerable:!0,get:function(){return r.useLoaderData}}),Object.defineProperty(e,"useLocation",{enumerable:!0,get:function(){return r.useLocation}}),Object.defineProperty(e,"useMatch",{enumerable:!0,get:function(){return r.useMatch}}),Object.defineProperty(e,"useMatches",{enumerable:!0,get:function(){return r.useMatches}}),Object.defineProperty(e,"useNavigate",{enumerable:!0,get:function(){return r.useNavigate}}),Object.defineProperty(e,"useNavigation",{enumerable:!0,get:function(){return r.useNavigation}}),Object.defineProperty(e,"useNavigationType",{enumerable:!0,get:function(){return r.useNavigationType}}),Object.defineProperty(e,"useOutlet",{enumerable:!0,get:function(){return r.useOutlet}}),Object.defineProperty(e,"useOutletContext",{enumerable:!0,get:function(){return r.useOutletContext}}),Object.defineProperty(e,"useParams",{enumerable:!0,get:function(){return r.useParams}}),Object.defineProperty(e,"useResolvedPath",{enumerable:!0,get:function(){return r.useResolvedPath}}),Object.defineProperty(e,"useRevalidator",{enumerable:!0,get:function(){return r.useRevalidator}}),Object.defineProperty(e,"useRouteError",{enumerable:!0,get:function(){return r.useRouteError}}),Object.defineProperty(e,"useRouteLoaderData",{enumerable:!0,get:function(){return r.useRouteLoaderData}}),Object.defineProperty(e,"useRoutes",{enumerable:!0,get:function(){return r.useRoutes}}),e.BrowserRouter=function(e){let{basename:t,children:o,window:u}=e,i=a.useRef();null==i.current&&(i.current=n.createBrowserHistory({window:u,v5Compat:!0}));let c=i.current,[l,s]=a.useState({action:c.action,location:c.location});return a.useLayoutEffect((()=>c.listen(s)),[c]),a.createElement(r.Router,{basename:t,children:o,location:l.location,navigationType:l.action,navigator:c})},e.Form=P,e.HashRouter=function(e){let{basename:t,children:o,window:u}=e,i=a.useRef();null==i.current&&(i.current=n.createHashHistory({window:u,v5Compat:!0}));let c=i.current,[l,s]=a.useState({action:c.action,location:c.location});return a.useLayoutEffect((()=>c.listen(s)),[c]),a.createElement(r.Router,{basename:t,children:o,location:l.location,navigationType:l.action,navigator:c})},e.Link=R,e.NavLink=w,e.ScrollRestoration=function(e){let{getKey:t,storageKey:r}=e;return L({getKey:t,storageKey:r}),null},e.UNSAFE_useScrollRestoration=L,e.createBrowserRouter=function(e,t){return n.createRouter({basename:null==t?void 0:t.basename,history:n.createBrowserHistory({window:null==t?void 0:t.window}),hydrationData:(null==t?void 0:t.hydrationData)||h(),routes:e,detectErrorBoundary:r.UNSAFE_detectErrorBoundary}).initialize()},e.createHashRouter=function(e,t){return n.createRouter({basename:null==t?void 0:t.basename,history:n.createHashHistory({window:null==t?void 0:t.window}),hydrationData:(null==t?void 0:t.hydrationData)||h(),routes:e,detectErrorBoundary:r.UNSAFE_detectErrorBoundary}).initialize()},e.createSearchParams=f,e.unstable_HistoryRouter=function(e){let{basename:t,children:n,history:o}=e;const[u,i]=a.useState({action:o.action,location:o.location});return a.useLayoutEffect((()=>o.listen(i)),[o]),a.createElement(r.Router,{basename:t,children:n,location:u.location,navigationType:u.action,navigator:o})},e.unstable_usePrompt=function(e){let{when:t,message:n}=e,o=r.unstable_useBlocker(t);a.useEffect((()=>{"blocked"!==o.state||t||o.reset()}),[o,t]),a.useEffect((()=>{if("blocked"===o.state){window.confirm(n)?setTimeout(o.proceed,0):o.reset()}}),[o,n])},e.useBeforeUnload=function(e,t){let{capture:r}=t||{};a.useEffect((()=>{let t=null!=r?{capture:r}:void 0;return window.addEventListener("beforeunload",e,t),()=>{window.removeEventListener("beforeunload",e,t)}}),[e,r])},e.useFetcher=function(){var e;let{router:t}=j(E.UseFetcher),o=a.useContext(r.UNSAFE_RouteContext);o||n.UNSAFE_invariant(!1);let i=null==(e=o.matches[o.matches.length-1])?void 0:e.route.id;null==i&&n.UNSAFE_invariant(!1);let[c]=a.useState((()=>String(++U))),[l]=a.useState((()=>(i||n.UNSAFE_invariant(!1),function(e,t){return a.forwardRef(((r,n)=>a.createElement(S,u({},r,{ref:n,fetcherKey:e,routeId:t}))))}(c,i)))),[s]=a.useState((()=>e=>{t||n.UNSAFE_invariant(!1),i||n.UNSAFE_invariant(!1),t.fetch(c,i,e)})),f=C(c,i),d=t.getFetcher(c),m=a.useMemo((()=>u({Form:l,submit:f,load:s},d)),[d,l,f,s]);return a.useEffect((()=>()=>{t?t.deleteFetcher(c):console.warn("No fetcher available to clean up from useFetcher()")}),[t,c]),m},e.useFetchers=function(){return[...A(O.UseFetchers).fetchers.values()]},e.useFormAction=F,e.useLinkClickHandler=N,e.useSearchParams=function(e){let t=a.useRef(f(e)),n=a.useRef(!1),o=r.useLocation(),u=a.useMemo((()=>function(e,t){let r=f(e);if(t)for(let e of t.keys())r.has(e)||t.getAll(e).forEach((t=>{r.append(e,t)}));return r}(o.search,n.current?null:t.current)),[o.search]),i=r.useNavigate(),c=a.useCallback(((e,t)=>{const r=f("function"==typeof e?e(u):e);n.current=!0,i("?"+r,t)}),[i,u]);return[u,c]},e.useSubmit=function(){return C()},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=react-router-dom.production.min.js.map |
{ | ||
"name": "react-router-dom", | ||
"version": "0.0.0-experimental-63b6834e", | ||
"version": "0.0.0-experimental-91f2bf54", | ||
"description": "Declarative routing for React web applications", | ||
@@ -26,4 +26,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@remix-run/router": "0.0.0-experimental-63b6834e", | ||
"react-router": "0.0.0-experimental-63b6834e" | ||
"@remix-run/router": "0.0.0-experimental-91f2bf54", | ||
"react-router": "0.0.0-experimental-91f2bf54" | ||
}, | ||
@@ -30,0 +30,0 @@ "devDependencies": { |
@@ -14,2 +14,3 @@ import * as React from "react"; | ||
export declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): JSX.Element; | ||
export { StaticHandlerContext }; | ||
export interface StaticRouterProviderProps { | ||
@@ -26,5 +27,4 @@ context: StaticHandlerContext; | ||
export declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): JSX.Element; | ||
declare type CreateStaticHandlerOptions = Omit<RouterCreateStaticHandlerOptions, "hasErrorBoundary">; | ||
declare type CreateStaticHandlerOptions = Omit<RouterCreateStaticHandlerOptions, "detectErrorBoundary">; | ||
export declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): import("@remix-run/router").StaticHandler; | ||
export declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext): RemixRouter; | ||
export {}; |
@@ -72,3 +72,3 @@ 'use strict'; | ||
}) { | ||
!(router$1 && context) ? process.env.NODE_ENV !== "production" ? router.invariant(false, "You must provide `router` and `context` to <StaticRouterProvider>") : router.invariant(false) : void 0; | ||
!(router$1 && context) ? process.env.NODE_ENV !== "production" ? router.UNSAFE_invariant(false, "You must provide `router` and `context` to <StaticRouterProvider>") : router.UNSAFE_invariant(false) : void 0; | ||
let dataRouterContext = { | ||
@@ -93,3 +93,3 @@ router: router$1, | ||
let json = JSON.stringify(JSON.stringify(data)); | ||
let json = htmlEscape(JSON.stringify(JSON.stringify(data))); | ||
hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json});`; | ||
@@ -170,7 +170,7 @@ } | ||
let hasErrorBoundary = route => Boolean(route.errorElement); | ||
let detectErrorBoundary = route => Boolean(route.errorElement); | ||
function createStaticHandler(routes, opts) { | ||
return router.createStaticHandler(routes, { ...opts, | ||
hasErrorBoundary | ||
detectErrorBoundary | ||
}); | ||
@@ -180,3 +180,3 @@ } | ||
let manifest = {}; | ||
let dataRoutes = router.UNSAFE_convertRoutesToDataRoutes(routes, hasErrorBoundary, undefined, manifest); // Because our context matches may be from a framework-agnostic set of | ||
let dataRoutes = router.UNSAFE_convertRoutesToDataRoutes(routes, detectErrorBoundary, undefined, manifest); // Because our context matches may be from a framework-agnostic set of | ||
// routes passed to createStaticHandler(), we update them here with our | ||
@@ -269,3 +269,8 @@ // newly created/enhanced data routes | ||
_internalFetchControllers: new Map(), | ||
_internalActiveDeferreds: new Map() | ||
_internalActiveDeferreds: new Map(), | ||
_internalSetRoutes() { | ||
throw msg("_internalSetRoutes"); | ||
} | ||
}; | ||
@@ -286,2 +291,17 @@ } | ||
}; | ||
} // This utility is based on https://github.com/zertosh/htmlescape | ||
// License: https://github.com/zertosh/htmlescape/blob/0527ca7156a524d256101bb310a9f970f63078ad/LICENSE | ||
const ESCAPE_LOOKUP = { | ||
"&": "\\u0026", | ||
">": "\\u003e", | ||
"<": "\\u003c", | ||
"\u2028": "\\u2028", | ||
"\u2029": "\\u2029" | ||
}; | ||
const ESCAPE_REGEX = /[&><\u2028\u2029]/g; | ||
function htmlEscape(str) { | ||
return str.replace(ESCAPE_REGEX, match => ESCAPE_LOOKUP[match]); | ||
} | ||
@@ -288,0 +308,0 @@ |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4433
563651
+ Added@remix-run/router@0.0.0-experimental-91f2bf54(transitive)
+ Addedreact-router@0.0.0-experimental-91f2bf54(transitive)
- Removed@remix-run/router@0.0.0-experimental-63b6834e(transitive)
- Removedreact-router@0.0.0-experimental-63b6834e(transitive)