react-router 8.3.0 → 8.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -2
- package/dist/development/dom-export.js +1 -1
- package/dist/development/index-react-server-client.js +1 -1
- package/dist/development/index-react-server.d.ts +50 -48
- package/dist/development/index-react-server.js +96 -43
- package/dist/development/index.d.ts +2 -2
- package/dist/development/index.js +3 -3
- package/dist/development/lib/actions.js +10 -5
- package/dist/development/lib/components.js +50 -10
- package/dist/development/lib/context.d.ts +14 -5
- package/dist/development/lib/context.js +11 -3
- package/dist/development/lib/dom/dom.js +2 -2
- package/dist/development/lib/dom/lib.js +33 -36
- package/dist/development/lib/dom/server.d.ts +6 -1
- package/dist/development/lib/dom/server.js +40 -14
- package/dist/development/lib/dom/ssr/components.js +16 -24
- package/dist/development/lib/dom/ssr/data.js +1 -1
- package/dist/development/lib/dom/ssr/entry.d.ts +4 -0
- package/dist/development/lib/dom/ssr/errorBoundaries.js +1 -1
- package/dist/development/lib/dom/ssr/fallback.js +1 -1
- package/dist/development/lib/dom/ssr/fog-of-war.js +34 -12
- package/dist/development/lib/dom/ssr/hydration.d.ts +3 -1
- package/dist/development/lib/dom/ssr/hydration.js +6 -4
- package/dist/development/lib/dom/ssr/invariant.js +1 -1
- package/dist/development/lib/dom/ssr/links.js +1 -1
- package/dist/development/lib/dom/ssr/markup.js +5 -2
- package/dist/development/lib/dom/ssr/routeModules.js +1 -1
- package/dist/development/lib/dom/ssr/routes-test-stub.js +1 -1
- package/dist/development/lib/dom/ssr/routes.js +1 -1
- package/dist/development/lib/dom/ssr/server.js +2 -2
- package/dist/development/lib/dom/ssr/single-fetch.js +13 -22
- package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/development/lib/dom-export/hydrated-router.js +2 -1
- package/dist/development/lib/errors.js +1 -1
- package/dist/development/lib/hooks.js +54 -46
- package/dist/development/lib/href.js +1 -1
- package/dist/development/lib/router/history.js +2 -2
- package/dist/development/lib/router/instrumentation.js +1 -1
- package/dist/development/lib/router/matcher-route-pattern.d.ts +2 -0
- package/dist/development/lib/router/matcher-route-pattern.js +216 -0
- package/dist/development/lib/router/matcher-route-pattern.preload.d.ts +20 -0
- package/dist/development/lib/router/matcher-route-pattern.preload.js +36 -0
- package/dist/development/lib/router/matcher.d.ts +2 -0
- package/dist/development/lib/router/matcher.js +29 -0
- package/dist/development/lib/router/navigation.js +45 -0
- package/dist/development/lib/router/router.d.ts +21 -7
- package/dist/development/lib/router/router.js +111 -82
- package/dist/development/lib/router/url.js +1 -1
- package/dist/development/lib/router/utils.d.ts +6 -1
- package/dist/development/lib/router/utils.js +15 -9
- package/dist/development/lib/rsc/browser.js +5 -1
- package/dist/development/lib/rsc/errorBoundaries.js +1 -1
- package/dist/development/lib/rsc/html-stream/browser.js +1 -1
- package/dist/development/lib/rsc/html-stream/server.js +3 -5
- package/dist/development/lib/rsc/route-modules.js +1 -1
- package/dist/development/lib/rsc/server.rsc.d.ts +7 -0
- package/dist/development/lib/rsc/server.ssr.js +26 -22
- package/dist/development/lib/server-runtime/cookies.js +2 -2
- package/dist/development/lib/server-runtime/crypto.js +2 -2
- package/dist/development/lib/server-runtime/data.js +1 -1
- package/dist/development/lib/server-runtime/dev.js +2 -2
- package/dist/development/lib/server-runtime/entry.js +1 -1
- package/dist/development/lib/server-runtime/errors.js +1 -1
- package/dist/development/lib/server-runtime/headers.js +1 -1
- package/dist/development/lib/server-runtime/invariant.js +1 -1
- package/dist/development/lib/server-runtime/mode.js +1 -1
- package/dist/development/lib/server-runtime/routeMatching.js +3 -4
- package/dist/development/lib/server-runtime/routes.js +1 -1
- package/dist/development/lib/server-runtime/server.js +8 -7
- package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions.js +1 -1
- package/dist/development/lib/server-runtime/single-fetch.js +2 -2
- package/dist/development/lib/server-runtime/urls.js +1 -1
- package/dist/development/lib/server-runtime/warnings.js +1 -1
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/route-pattern.d.ts +3 -0
- package/dist/development/route-pattern.js +12 -0
- package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +4 -4
- package/dist/development/vendor/turbo-stream-v2/unflatten.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
- package/dist/production/dom-export.js +1 -1
- package/dist/production/index-react-server-client.js +1 -1
- package/dist/production/index-react-server.d.ts +50 -48
- package/dist/production/index-react-server.js +96 -43
- package/dist/production/index.d.ts +2 -2
- package/dist/production/index.js +3 -3
- package/dist/production/lib/actions.js +10 -5
- package/dist/production/lib/components.js +50 -10
- package/dist/production/lib/context.d.ts +14 -5
- package/dist/production/lib/context.js +11 -3
- package/dist/production/lib/dom/dom.js +2 -2
- package/dist/production/lib/dom/lib.js +33 -36
- package/dist/production/lib/dom/server.d.ts +6 -1
- package/dist/production/lib/dom/server.js +40 -14
- package/dist/production/lib/dom/ssr/components.js +16 -24
- package/dist/production/lib/dom/ssr/data.js +1 -1
- package/dist/production/lib/dom/ssr/entry.d.ts +4 -0
- package/dist/production/lib/dom/ssr/errorBoundaries.js +1 -1
- package/dist/production/lib/dom/ssr/fallback.js +1 -1
- package/dist/production/lib/dom/ssr/fog-of-war.js +34 -12
- package/dist/production/lib/dom/ssr/hydration.d.ts +3 -1
- package/dist/production/lib/dom/ssr/hydration.js +6 -4
- package/dist/production/lib/dom/ssr/invariant.js +1 -1
- package/dist/production/lib/dom/ssr/links.js +1 -1
- package/dist/production/lib/dom/ssr/markup.js +5 -2
- package/dist/production/lib/dom/ssr/routeModules.js +1 -1
- package/dist/production/lib/dom/ssr/routes-test-stub.js +1 -1
- package/dist/production/lib/dom/ssr/routes.js +1 -1
- package/dist/production/lib/dom/ssr/server.js +2 -2
- package/dist/production/lib/dom/ssr/single-fetch.js +13 -22
- package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/production/lib/dom-export/hydrated-router.js +2 -1
- package/dist/production/lib/errors.js +1 -1
- package/dist/production/lib/hooks.js +54 -46
- package/dist/production/lib/href.js +1 -1
- package/dist/production/lib/router/history.js +2 -2
- package/dist/production/lib/router/instrumentation.js +1 -1
- package/dist/production/lib/router/matcher-route-pattern.d.ts +2 -0
- package/dist/production/lib/router/matcher-route-pattern.js +216 -0
- package/dist/production/lib/router/matcher-route-pattern.preload.d.ts +20 -0
- package/dist/production/lib/router/matcher-route-pattern.preload.js +36 -0
- package/dist/production/lib/router/matcher.d.ts +2 -0
- package/dist/production/lib/router/matcher.js +29 -0
- package/dist/production/lib/router/navigation.js +45 -0
- package/dist/production/lib/router/router.d.ts +21 -7
- package/dist/production/lib/router/router.js +111 -82
- package/dist/production/lib/router/url.js +1 -1
- package/dist/production/lib/router/utils.d.ts +6 -1
- package/dist/production/lib/router/utils.js +15 -9
- package/dist/production/lib/rsc/browser.js +5 -1
- package/dist/production/lib/rsc/errorBoundaries.js +1 -1
- package/dist/production/lib/rsc/html-stream/browser.js +1 -1
- package/dist/production/lib/rsc/html-stream/server.js +3 -5
- package/dist/production/lib/rsc/route-modules.js +1 -1
- package/dist/production/lib/rsc/server.rsc.d.ts +7 -0
- package/dist/production/lib/rsc/server.ssr.js +26 -22
- package/dist/production/lib/server-runtime/cookies.js +2 -2
- package/dist/production/lib/server-runtime/crypto.js +2 -2
- package/dist/production/lib/server-runtime/data.js +1 -1
- package/dist/production/lib/server-runtime/dev.js +2 -2
- package/dist/production/lib/server-runtime/entry.js +1 -1
- package/dist/production/lib/server-runtime/errors.js +1 -1
- package/dist/production/lib/server-runtime/headers.js +1 -1
- package/dist/production/lib/server-runtime/invariant.js +1 -1
- package/dist/production/lib/server-runtime/mode.js +1 -1
- package/dist/production/lib/server-runtime/routeMatching.js +3 -4
- package/dist/production/lib/server-runtime/routes.js +1 -1
- package/dist/production/lib/server-runtime/server.js +8 -7
- package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions.js +1 -1
- package/dist/production/lib/server-runtime/single-fetch.js +2 -2
- package/dist/production/lib/server-runtime/urls.js +1 -1
- package/dist/production/lib/server-runtime/warnings.js +1 -1
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/route-pattern.d.ts +3 -0
- package/dist/production/route-pattern.js +12 -0
- package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +4 -4
- package/dist/production/vendor/turbo-stream-v2/unflatten.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
- package/docs/how-to/fetchers.md +6 -1
- package/docs/how-to/middleware.md +3 -1
- package/docs/how-to/optimize-revalidation.md +178 -5
- package/docs/how-to/react-server-components.md +26 -3
- package/docs/how-to/resource-routes.md +3 -0
- package/docs/start/data/actions.md +2 -1
- package/docs/start/data/route-object.md +21 -6
- package/docs/start/framework/actions.md +4 -2
- package/docs/start/framework/route-module.md +32 -5
- package/docs/upgrading/future.md +68 -0
- package/package.json +11 -1
|
@@ -4,7 +4,7 @@ import { ActionFunction, ActionFunctionArgs, BaseRouteObject, DataRouteMatch, Da
|
|
|
4
4
|
import { Blocker, BlockerFunction, Fetcher, GetScrollPositionFunction, GetScrollRestorationKeyFunction, HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, Navigation, NavigationStates, RelativeRoutingType, RevalidationState, Router, RouterFetchOptions, RouterInit, RouterNavigateOptions, RouterState, RouterSubscriber, StaticHandler, StaticHandlerContext, createRouter, createStaticHandler } from "./lib/router/router.js";
|
|
5
5
|
import { HtmlLinkDescriptor, LinkDescriptor, PageLinkDescriptor } from "./lib/router/links.js";
|
|
6
6
|
import { Await, AwaitProps, ClientOnErrorFunction, IndexRouteProps, LayoutRouteProps, MemoryRouter, MemoryRouterOpts, MemoryRouterProps, Navigate, NavigateProps, Outlet, OutletProps, PathRouteProps, Route, RouteProps, Router as Router$1, RouterProps, RouterProvider, RouterProviderProps, Routes, RoutesProps, WithComponentProps, WithErrorBoundaryProps, WithHydrateFallbackProps, createMemoryRouter, createRoutesFromChildren, createRoutesFromElements, hydrationRouteProperties, renderMatches, withComponentProps, withErrorBoundaryProps, withHydrateFallbackProps } from "./lib/components.js";
|
|
7
|
-
import { AwaitContextProvider, DataRouterContext, DataRouterStateContext, FetchersContext, LocationContext, NavigateOptions, NavigationContext, Navigator, RouteContext, ViewTransitionContext } from "./lib/context.js";
|
|
7
|
+
import { AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, LocationContext, NavigateOptions, NavigationContext, Navigator, RouteContext, ViewTransitionContext } from "./lib/context.js";
|
|
8
8
|
import { Register } from "./lib/types/register.js";
|
|
9
9
|
import { NavigateFunction, unstable_RouterState, unstable_RouterStateActiveVariant, unstable_RouterStatePendingVariant, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRoute, useRouteError, useRouteLoaderData, useRouterState, useRoutes } from "./lib/hooks.js";
|
|
10
10
|
import { FetcherSubmitOptions, ParamKeyValuePair, SubmitOptions, SubmitTarget, URLSearchParamsInit, createSearchParams } from "./lib/dom/dom.js";
|
|
@@ -41,4 +41,4 @@ import { ClientInstrumentation, InstrumentRequestHandlerFunction, InstrumentRout
|
|
|
41
41
|
declare const unstable_getRequest: typeof getRequest;
|
|
42
42
|
declare const unstable_matchRSCServerRequest: typeof matchRSCServerRequest;
|
|
43
43
|
//#endregion
|
|
44
|
-
export { type ActionFunction, type ActionFunctionArgs, Await, type AwaitProps, type BaseRouteObject, type Blocker, type BlockerFunction, BrowserRouter, type BrowserRouterProps, type ClientActionFunction, type ClientActionFunctionArgs, type ClientInstrumentation, type ClientLoaderFunction, type ClientLoaderFunctionArgs, type ClientOnErrorFunction, type Cookie, type CookieOptions, type CookieParseOptions, type CookieSerializeOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, type DataRouteMatch, type DataRouteObject, type Router as DataRouter, type DataStrategyFunction, type DataStrategyFunctionArgs, type DataStrategyMatch, type DataStrategyResult, type DiscoverBehavior, type EntryContext, type ErrorResponse, type Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, type FormEncType, type FormMethod, type FormProps, type Future, type GetScrollPositionFunction, type GetScrollRestorationKeyFunction, type HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HeadersArgs, type HeadersFunction, type HistoryRouterProps, type HtmlLinkDescriptor, type HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, type IndexRouteObject, type IndexRouteProps, type InitialEntry, type InstrumentRequestHandlerFunction, type InstrumentRouteFunction, type InstrumentRouterFunction, type InstrumentationClientRouterResult, type InstrumentationHandlerResult, type InstrumentationServerHandlerResult, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, type LazyRouteFunction, Link, type LinkDescriptor, type LinkProps, Links, type LinksFunction, type LinksProps, type LoaderFunction, type LoaderFunctionArgs, type Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, type MetaArgs, type MetaDescriptor, type MetaFunction, type MiddlewareFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, type NavigateOptions, type NavigateProps, type Navigation, type NavigationStates, Action as NavigationType, type Navigator, type NonIndexRouteObject, Outlet, type OutletProps, type PageLinkDescriptor, type ParamKeyValuePair, type ParamParseKey, type Params, type PatchRoutesOnNavigationFunction, type PatchRoutesOnNavigationFunctionArgs, type Path, type PathMatch, type PathParam, type PathPattern, type PathRouteProps, type PrefetchBehavior, PrefetchPageLinks, type RedirectFunction, type Register, type RelativeRoutingType, type RequestHandler, type RevalidationState, Route, type RouteMatch, type RouteObject, type RouteProps, Router$1 as Router, type RouterContext, RouterContextProvider, type RouterFetchOptions, type RouterInit, type RouterNavigateOptions, type RouterProps, RouterProvider, type RouterProviderProps, type RouterState, type RouterSubscriber, Routes, type RoutesProps, type RoutesTestStubProps, Scripts, type ScriptsProps, ScrollRestoration, type ScrollRestorationProps, type ServerBuild, type ServerEntryModule, type ServerInstrumentation, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, type SetURLSearchParams, type ShouldRevalidateFunction, type ShouldRevalidateFunctionArgs, type StaticHandler, type StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, type To, type UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, type DataWithResponseInit as UNSAFE_DataWithResponseInit, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, type RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, type URLSearchParamsInit, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, type BrowserCreateFromReadableStreamFunction as unstable_BrowserCreateFromReadableStreamFunction, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type EncodeReplyFunction as unstable_EncodeReplyFunction, HistoryRouter as unstable_HistoryRouter, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCHydratedRouterProps as unstable_RSCHydratedRouterProps, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, RSCStaticRouter as unstable_RSCStaticRouter, type RSCStaticRouterProps as unstable_RSCStaticRouterProps, type unstable_RouterState, type unstable_RouterStateActiveVariant, type unstable_RouterStatePendingVariant, type SSRCreateFromReadableStreamFunction as unstable_SSRCreateFromReadableStreamFunction, type unstable_SerializesTo, unstable_getRequest, unstable_matchRSCServerRequest, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };
|
|
44
|
+
export { type ActionFunction, type ActionFunctionArgs, Await, type AwaitProps, type BaseRouteObject, type Blocker, type BlockerFunction, BrowserRouter, type BrowserRouterProps, type ClientActionFunction, type ClientActionFunctionArgs, type ClientInstrumentation, type ClientLoaderFunction, type ClientLoaderFunctionArgs, type ClientOnErrorFunction, type Cookie, type CookieOptions, type CookieParseOptions, type CookieSerializeOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, type DataRouteMatch, type DataRouteObject, type Router as DataRouter, type DataStrategyFunction, type DataStrategyFunctionArgs, type DataStrategyMatch, type DataStrategyResult, type DiscoverBehavior, type EntryContext, type ErrorResponse, type Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, type FormEncType, type FormMethod, type FormProps, type Future, type GetScrollPositionFunction, type GetScrollRestorationKeyFunction, type HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HeadersArgs, type HeadersFunction, type HistoryRouterProps, type HtmlLinkDescriptor, type HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, type IndexRouteObject, type IndexRouteProps, type InitialEntry, type InstrumentRequestHandlerFunction, type InstrumentRouteFunction, type InstrumentRouterFunction, type InstrumentationClientRouterResult, type InstrumentationHandlerResult, type InstrumentationServerHandlerResult, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, type LazyRouteFunction, Link, type LinkDescriptor, type LinkProps, Links, type LinksFunction, type LinksProps, type LoaderFunction, type LoaderFunctionArgs, type Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, type MetaArgs, type MetaDescriptor, type MetaFunction, type MiddlewareFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, type NavigateOptions, type NavigateProps, type Navigation, type NavigationStates, Action as NavigationType, type Navigator, type NonIndexRouteObject, Outlet, type OutletProps, type PageLinkDescriptor, type ParamKeyValuePair, type ParamParseKey, type Params, type PatchRoutesOnNavigationFunction, type PatchRoutesOnNavigationFunctionArgs, type Path, type PathMatch, type PathParam, type PathPattern, type PathRouteProps, type PrefetchBehavior, PrefetchPageLinks, type RedirectFunction, type Register, type RelativeRoutingType, type RequestHandler, type RevalidationState, Route, type RouteMatch, type RouteObject, type RouteProps, Router$1 as Router, type RouterContext, RouterContextProvider, type RouterFetchOptions, type RouterInit, type RouterNavigateOptions, type RouterProps, RouterProvider, type RouterProviderProps, type RouterState, type RouterSubscriber, Routes, type RoutesProps, type RoutesTestStubProps, Scripts, type ScriptsProps, ScrollRestoration, type ScrollRestorationProps, type ServerBuild, type ServerEntryModule, type ServerInstrumentation, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, type SetURLSearchParams, type ShouldRevalidateFunction, type ShouldRevalidateFunctionArgs, type StaticHandler, type StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, type To, type UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterDataContext as UNSAFE_DataRouterDataContext, DataRouterNavigationContext as UNSAFE_DataRouterNavigationContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, type DataWithResponseInit as UNSAFE_DataWithResponseInit, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, type RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, type URLSearchParamsInit, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, type BrowserCreateFromReadableStreamFunction as unstable_BrowserCreateFromReadableStreamFunction, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type EncodeReplyFunction as unstable_EncodeReplyFunction, HistoryRouter as unstable_HistoryRouter, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCHydratedRouterProps as unstable_RSCHydratedRouterProps, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, RSCStaticRouter as unstable_RSCStaticRouter, type RSCStaticRouterProps as unstable_RSCStaticRouterProps, type unstable_RouterState, type unstable_RouterStateActiveVariant, type unstable_RouterStatePendingVariant, type SSRCreateFromReadableStreamFunction as unstable_SSRCreateFromReadableStreamFunction, type unstable_SerializesTo, unstable_getRequest, unstable_matchRSCServerRequest, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };
|
package/dist/production/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.4.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import { Action, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, invariant, parsePath } from "./lib/router/history.js";
|
|
13
13
|
import { ErrorResponseImpl, RouterContextProvider, createContext, data, defaultMapRouteProperties, generatePath, isRouteErrorResponse, matchPath, matchRoutes, redirect, redirectDocument, replace, resolvePath } from "./lib/router/utils.js";
|
|
14
14
|
import { IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, createRouter, createStaticHandler } from "./lib/router/router.js";
|
|
15
|
-
import { AwaitContextProvider, DataRouterContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RouteContext, ViewTransitionContext } from "./lib/context.js";
|
|
15
|
+
import { AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RouteContext, ViewTransitionContext } from "./lib/context.js";
|
|
16
16
|
import { useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRoute, useRouteError, useRouteLoaderData, useRouterState, useRoutes } from "./lib/hooks.js";
|
|
17
17
|
import { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, WithComponentProps, WithErrorBoundaryProps, WithHydrateFallbackProps, createMemoryRouter, createRoutesFromChildren, createRoutesFromElements, hydrationRouteProperties, renderMatches, withComponentProps, withErrorBoundaryProps, withHydrateFallbackProps } from "./lib/components.js";
|
|
18
18
|
import { createSearchParams } from "./lib/dom/dom.js";
|
|
@@ -42,4 +42,4 @@ import { getHydrationData } from "./lib/dom/ssr/hydration.js";
|
|
|
42
42
|
* @mergeModuleWith react-router
|
|
43
43
|
*/
|
|
44
44
|
//#endregion
|
|
45
|
-
export { Await, BrowserRouter, Form, HashRouter, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Action as NavigationType, Outlet, PrefetchPageLinks, Route, Router, RouterContextProvider, RouterProvider, Routes, Scripts, ScrollRestoration, ServerRouter, StaticRouter, StaticRouterProvider, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, HistoryRouter as unstable_HistoryRouter, RSCStaticRouter as unstable_RSCStaticRouter, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };
|
|
45
|
+
export { Await, BrowserRouter, Form, HashRouter, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Action as NavigationType, Outlet, PrefetchPageLinks, Route, Router, RouterContextProvider, RouterProvider, Routes, Scripts, ScrollRestoration, ServerRouter, StaticRouter, StaticRouterProvider, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterDataContext as UNSAFE_DataRouterDataContext, DataRouterNavigationContext as UNSAFE_DataRouterNavigationContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, HistoryRouter as unstable_HistoryRouter, RSCStaticRouter as unstable_RSCStaticRouter, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.4.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -12,14 +12,19 @@
|
|
|
12
12
|
function throwIfPotentialCSRFAttack(request, allowedActionOrigins) {
|
|
13
13
|
let originHeader = request.headers.get("origin");
|
|
14
14
|
let originDomain = null;
|
|
15
|
+
let originUrl = null;
|
|
15
16
|
try {
|
|
16
|
-
|
|
17
|
+
if (typeof originHeader === "string" && originHeader !== "null") {
|
|
18
|
+
originUrl = new URL(originHeader);
|
|
19
|
+
originDomain = originUrl.host;
|
|
20
|
+
} else originDomain = originHeader;
|
|
17
21
|
} catch {
|
|
18
22
|
throw new Error(`\`origin\` header is not a valid URL. Aborting the action.`);
|
|
19
23
|
}
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
let requestUrl = new URL(request.url);
|
|
25
|
+
let originMatchesRequest = originUrl ? originUrl.origin === requestUrl.origin : originDomain === requestUrl.host;
|
|
26
|
+
if (originDomain && !originMatchesRequest) {
|
|
27
|
+
if (!isAllowedOrigin(originDomain, allowedActionOrigins)) throw new Error("The `request.url` origin does not match `origin` header from a forwarded action request. Aborting the action.");
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
function matchWildcardDomain(domain, pattern) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.4.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import { createMemoryHistory, invariant, parsePath, warning } from "./router/history.js";
|
|
11
|
+
import { createMemoryHistory, createPath, invariant, parsePath, warning } from "./router/history.js";
|
|
12
12
|
import { defaultMapRouteProperties, getResolveToMatches, getRoutePattern, resolveTo, stripBasename } from "./router/utils.js";
|
|
13
|
+
import { getNavigatorCurrentUrl, validateNavigationTarget } from "./router/navigation.js";
|
|
13
14
|
import { createRouter } from "./router/router.js";
|
|
14
|
-
import { AwaitContext, DataRouterContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RouteContext, ViewTransitionContext, useIsRSCRouterContext } from "./context.js";
|
|
15
|
+
import { AwaitContext, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RouteContext, ViewTransitionContext, useIsRSCRouterContext } from "./context.js";
|
|
15
16
|
import { _renderMatches, useActionData, useAsyncValue, useInRouterContext, useLoaderData, useLocation, useMatches, useNavigate, useOutlet, useParams, useRouteError, useRoutes, useRoutesImpl } from "./hooks.js";
|
|
16
17
|
import { warnOnce } from "./server-runtime/warnings.js";
|
|
17
18
|
import * as React$1 from "react";
|
|
@@ -256,6 +257,7 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
|
|
|
256
257
|
let navigator = React$1.useMemo(() => {
|
|
257
258
|
return {
|
|
258
259
|
createHref: router.createHref,
|
|
260
|
+
createURL: router.createURL,
|
|
259
261
|
encodeLocation: router.encodeLocation,
|
|
260
262
|
go: (n) => router.navigate(n),
|
|
261
263
|
push: (to, state, opts) => router.navigate(to, {
|
|
@@ -282,7 +284,43 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
|
|
|
282
284
|
basename,
|
|
283
285
|
onError
|
|
284
286
|
]);
|
|
285
|
-
|
|
287
|
+
let dataRouterState = React$1.useMemo(() => ({
|
|
288
|
+
historyAction: state.historyAction,
|
|
289
|
+
location: state.location,
|
|
290
|
+
matches: state.matches,
|
|
291
|
+
initialized: state.initialized,
|
|
292
|
+
renderFallback: state.renderFallback,
|
|
293
|
+
restoreScrollPosition: state.restoreScrollPosition,
|
|
294
|
+
preventScrollReset: state.preventScrollReset,
|
|
295
|
+
blockers: state.blockers
|
|
296
|
+
}), [
|
|
297
|
+
state.historyAction,
|
|
298
|
+
state.location,
|
|
299
|
+
state.matches,
|
|
300
|
+
state.initialized,
|
|
301
|
+
state.renderFallback,
|
|
302
|
+
state.restoreScrollPosition,
|
|
303
|
+
state.preventScrollReset,
|
|
304
|
+
state.blockers
|
|
305
|
+
]);
|
|
306
|
+
let dataRouterNavigation = React$1.useMemo(() => ({
|
|
307
|
+
navigation: state.navigation,
|
|
308
|
+
revalidation: state.revalidation
|
|
309
|
+
}), [state.navigation, state.revalidation]);
|
|
310
|
+
let dataRouterData = React$1.useMemo(() => ({
|
|
311
|
+
loaderData: state.loaderData,
|
|
312
|
+
actionData: state.actionData,
|
|
313
|
+
errors: state.errors
|
|
314
|
+
}), [
|
|
315
|
+
state.loaderData,
|
|
316
|
+
state.actionData,
|
|
317
|
+
state.errors
|
|
318
|
+
]);
|
|
319
|
+
let fetchersContext = React$1.useMemo(() => ({
|
|
320
|
+
fetchers: state.fetchers,
|
|
321
|
+
fetcherData: fetcherData.current
|
|
322
|
+
}), [state.fetchers]);
|
|
323
|
+
return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, /* @__PURE__ */ React$1.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React$1.createElement(DataRouterStateContext.Provider, { value: dataRouterState }, /* @__PURE__ */ React$1.createElement(DataRouterNavigationContext.Provider, { value: dataRouterNavigation }, /* @__PURE__ */ React$1.createElement(DataRouterDataContext.Provider, { value: dataRouterData }, /* @__PURE__ */ React$1.createElement(FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React$1.createElement(ViewTransitionContext.Provider, { value: vtContext }, /* @__PURE__ */ React$1.createElement(Router, {
|
|
286
324
|
basename,
|
|
287
325
|
location: state.location,
|
|
288
326
|
navigationType: state.historyAction,
|
|
@@ -291,11 +329,10 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
|
|
|
291
329
|
}, /* @__PURE__ */ React$1.createElement(MemoizedDataRoutes, {
|
|
292
330
|
routes: router.routes,
|
|
293
331
|
manifest: router.manifest,
|
|
294
|
-
future: router.future,
|
|
295
332
|
state,
|
|
296
333
|
isStatic: false,
|
|
297
334
|
onError
|
|
298
|
-
})))))), null);
|
|
335
|
+
})))))))), null);
|
|
299
336
|
}
|
|
300
337
|
function getOptimisticRouterState(currentState, newState) {
|
|
301
338
|
return {
|
|
@@ -307,13 +344,15 @@ function getOptimisticRouterState(currentState, newState) {
|
|
|
307
344
|
};
|
|
308
345
|
}
|
|
309
346
|
const MemoizedDataRoutes = React$1.memo(DataRoutes);
|
|
310
|
-
function DataRoutes({ routes, manifest,
|
|
347
|
+
function DataRoutes({ routes, manifest, state, isStatic, onError }) {
|
|
348
|
+
let dataRouterContext = React$1.useContext(DataRouterContext);
|
|
349
|
+
invariant(dataRouterContext, "You must render this element inside a <DataRouterContext.Provider> element");
|
|
311
350
|
return useRoutesImpl(routes, void 0, {
|
|
351
|
+
router: dataRouterContext.router,
|
|
312
352
|
manifest,
|
|
313
353
|
state,
|
|
314
354
|
isStatic,
|
|
315
|
-
onError
|
|
316
|
-
future
|
|
355
|
+
onError
|
|
317
356
|
});
|
|
318
357
|
}
|
|
319
358
|
/**
|
|
@@ -379,12 +418,13 @@ function MemoryRouter({ basename, children, initialEntries, initialIndex, useTra
|
|
|
379
418
|
*/
|
|
380
419
|
function Navigate({ to, replace, state, relative }) {
|
|
381
420
|
invariant(useInRouterContext(), `<Navigate> may be used only in the context of a <Router> component.`);
|
|
382
|
-
let { static: isStatic } = React$1.useContext(NavigationContext);
|
|
421
|
+
let { static: isStatic, navigator } = React$1.useContext(NavigationContext);
|
|
383
422
|
warning(!isStatic, "<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");
|
|
384
423
|
let { matches } = React$1.useContext(RouteContext);
|
|
385
424
|
let { pathname: locationPathname } = useLocation();
|
|
386
425
|
let navigate = useNavigate();
|
|
387
426
|
let path = resolveTo(to, getResolveToMatches(matches), locationPathname, relative === "path");
|
|
427
|
+
validateNavigationTarget(typeof to === "string" ? to : createPath(to), navigator.createHref(path), getNavigatorCurrentUrl(navigator), "reject");
|
|
388
428
|
let jsonPath = JSON.stringify(path);
|
|
389
429
|
React$1.useEffect(() => {
|
|
390
430
|
navigate(JSON.parse(jsonPath), {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { Action, History, Location, To } from "./router/history.js";
|
|
3
3
|
import { RouteMatch, TrackedPromise } from "./router/utils.js";
|
|
4
|
-
import { RelativeRoutingType, Router,
|
|
4
|
+
import { RelativeRoutingType, Router, StaticHandlerContext } from "./router/router.js";
|
|
5
5
|
import { ClientOnErrorFunction } from "./components.js";
|
|
6
6
|
import * as React$1 from "react";
|
|
7
7
|
|
|
@@ -12,7 +12,12 @@ interface DataRouterContextObject extends Omit<NavigationContextObject, "future"
|
|
|
12
12
|
onError?: ClientOnErrorFunction;
|
|
13
13
|
}
|
|
14
14
|
declare const DataRouterContext: React$1.Context<DataRouterContextObject | null>;
|
|
15
|
-
|
|
15
|
+
type DataRouterDataContextObject = Pick<Router["state"], "loaderData" | "actionData" | "errors">;
|
|
16
|
+
type DataRouterNavigationContextObject = Pick<Router["state"], "navigation" | "revalidation">;
|
|
17
|
+
type DataRouterStateContextObject = Omit<Router["state"], keyof DataRouterDataContextObject | keyof DataRouterNavigationContextObject | "fetchers">;
|
|
18
|
+
declare const DataRouterStateContext: React$1.Context<DataRouterStateContextObject | null>;
|
|
19
|
+
declare const DataRouterDataContext: React$1.Context<DataRouterDataContextObject | null>;
|
|
20
|
+
declare const DataRouterNavigationContext: React$1.Context<DataRouterNavigationContextObject | null>;
|
|
16
21
|
type ViewTransitionContextObject = {
|
|
17
22
|
isTransitioning: false;
|
|
18
23
|
} | {
|
|
@@ -22,8 +27,11 @@ type ViewTransitionContextObject = {
|
|
|
22
27
|
nextLocation: Location;
|
|
23
28
|
};
|
|
24
29
|
declare const ViewTransitionContext: React$1.Context<ViewTransitionContextObject>;
|
|
25
|
-
type FetchersContextObject =
|
|
26
|
-
|
|
30
|
+
type FetchersContextObject = {
|
|
31
|
+
fetchers: Router["state"]["fetchers"];
|
|
32
|
+
fetcherData: Map<string, any>;
|
|
33
|
+
};
|
|
34
|
+
declare const FetchersContext: React$1.Context<FetchersContextObject | null>;
|
|
27
35
|
declare const AwaitContext: React$1.Context<TrackedPromise | null>;
|
|
28
36
|
declare const AwaitContextProvider: (props: React$1.ComponentProps<typeof AwaitContext.Provider>) => React$1.FunctionComponentElement<React$1.ProviderProps<TrackedPromise | null>>;
|
|
29
37
|
interface NavigateOptions {
|
|
@@ -55,6 +63,7 @@ interface NavigateOptions {
|
|
|
55
63
|
*/
|
|
56
64
|
interface Navigator {
|
|
57
65
|
createHref: History["createHref"];
|
|
66
|
+
createURL?: History["createURL"];
|
|
58
67
|
encodeLocation?: History["encodeLocation"];
|
|
59
68
|
go: History["go"];
|
|
60
69
|
push(to: To, state?: any, opts?: NavigateOptions): void;
|
|
@@ -80,4 +89,4 @@ interface RouteContextObject {
|
|
|
80
89
|
}
|
|
81
90
|
declare const RouteContext: React$1.Context<RouteContextObject>;
|
|
82
91
|
//#endregion
|
|
83
|
-
export { AwaitContextProvider, DataRouterContext, DataRouterStateContext, FetchersContext, LocationContext, NavigateOptions, NavigationContext, Navigator, RouteContext, ViewTransitionContext };
|
|
92
|
+
export { AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, LocationContext, NavigateOptions, NavigationContext, Navigator, RouteContext, ViewTransitionContext };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.4.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -14,13 +14,17 @@ const DataRouterContext = React$1.createContext(null);
|
|
|
14
14
|
DataRouterContext.displayName = "DataRouter";
|
|
15
15
|
const DataRouterStateContext = React$1.createContext(null);
|
|
16
16
|
DataRouterStateContext.displayName = "DataRouterState";
|
|
17
|
+
const DataRouterDataContext = React$1.createContext(null);
|
|
18
|
+
DataRouterDataContext.displayName = "DataRouterData";
|
|
19
|
+
const DataRouterNavigationContext = React$1.createContext(null);
|
|
20
|
+
DataRouterNavigationContext.displayName = "DataRouterNavigation";
|
|
17
21
|
const RSCRouterContext = React$1.createContext(false);
|
|
18
22
|
function useIsRSCRouterContext() {
|
|
19
23
|
return React$1.useContext(RSCRouterContext);
|
|
20
24
|
}
|
|
21
25
|
const ViewTransitionContext = React$1.createContext({ isTransitioning: false });
|
|
22
26
|
ViewTransitionContext.displayName = "ViewTransition";
|
|
23
|
-
const FetchersContext = React$1.createContext(
|
|
27
|
+
const FetchersContext = React$1.createContext(null);
|
|
24
28
|
FetchersContext.displayName = "Fetchers";
|
|
25
29
|
const AwaitContext = React$1.createContext(null);
|
|
26
30
|
AwaitContext.displayName = "Await";
|
|
@@ -35,7 +39,11 @@ const RouteContext = React$1.createContext({
|
|
|
35
39
|
isDataRoute: false
|
|
36
40
|
});
|
|
37
41
|
RouteContext.displayName = "Route";
|
|
42
|
+
const IsDataRouteContext = React$1.createContext(false);
|
|
43
|
+
IsDataRouteContext.displayName = "IsDataRoute";
|
|
44
|
+
const RouteIdContext = React$1.createContext(void 0);
|
|
45
|
+
RouteIdContext.displayName = "RouteId";
|
|
38
46
|
const RouteErrorContext = React$1.createContext(null);
|
|
39
47
|
RouteErrorContext.displayName = "RouteError";
|
|
40
48
|
//#endregion
|
|
41
|
-
export { AwaitContext, AwaitContextProvider, DataRouterContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RSCRouterContext, RouteContext, RouteErrorContext, ViewTransitionContext, useIsRSCRouterContext };
|
|
49
|
+
export { AwaitContext, AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, IsDataRouteContext, LocationContext, NavigationContext, RSCRouterContext, RouteContext, RouteErrorContext, RouteIdContext, ViewTransitionContext, useIsRSCRouterContext };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.4.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -75,7 +75,7 @@ function isFormDataSubmitterSupported() {
|
|
|
75
75
|
if (_formDataSupportsSubmitter === null) try {
|
|
76
76
|
new FormData(document.createElement("form"), 0);
|
|
77
77
|
_formDataSupportsSubmitter = false;
|
|
78
|
-
} catch
|
|
78
|
+
} catch {
|
|
79
79
|
_formDataSupportsSubmitter = true;
|
|
80
80
|
}
|
|
81
81
|
return _formDataSupportsSubmitter;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.4.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -12,8 +12,8 @@ import { ABSOLUTE_URL_REGEX } from "../router/url.js";
|
|
|
12
12
|
import { createBrowserHistory, createHashHistory, createPath, invariant, warning } from "../router/history.js";
|
|
13
13
|
import { ErrorResponseImpl, SUPPORTED_ERROR_TYPES, defaultMapRouteProperties, joinPaths, matchPath, parseToInfo, resolveTo, stripBasename } from "../router/utils.js";
|
|
14
14
|
import { IDLE_FETCHER, createRouter } from "../router/router.js";
|
|
15
|
-
import {
|
|
16
|
-
import { useBlocker, useHref, useLocation, useMatches, useNavigate, useNavigation, useResolvedPath
|
|
15
|
+
import { DataRouterNavigationContext, NavigationContext, RouteContext, ViewTransitionContext } from "../context.js";
|
|
16
|
+
import { useBlocker, useCurrentRouteId, useDataRouterContext, useDataRouterFetchers, useDataRouterState, useHref, useLocation, useMatches, useNavigate, useNavigation, useResolvedPath } from "../hooks.js";
|
|
17
17
|
import { Router, hydrationRouteProperties } from "../components.js";
|
|
18
18
|
import { createSearchParams, getFormSubmissionInfo, getSearchParamsForLocation, shouldProcessLinkClick } from "./dom.js";
|
|
19
19
|
import { escapeHtml } from "./ssr/markup.js";
|
|
@@ -22,8 +22,8 @@ import * as React$1 from "react";
|
|
|
22
22
|
//#region lib/dom/lib.tsx
|
|
23
23
|
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
24
24
|
try {
|
|
25
|
-
if (isBrowser) window.__reactRouterVersion = "8
|
|
26
|
-
} catch
|
|
25
|
+
if (isBrowser) window.__reactRouterVersion = "8";
|
|
26
|
+
} catch {}
|
|
27
27
|
/**
|
|
28
28
|
* Create a new {@link DataRouter| data router} that manages the application
|
|
29
29
|
* path via [`history.pushState`](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState)
|
|
@@ -123,7 +123,7 @@ function deserializeErrors(errors) {
|
|
|
123
123
|
let error = new ErrorConstructor(val.message);
|
|
124
124
|
error.stack = "";
|
|
125
125
|
serialized[key] = error;
|
|
126
|
-
} catch
|
|
126
|
+
} catch {}
|
|
127
127
|
}
|
|
128
128
|
if (serialized[key] == null) {
|
|
129
129
|
let error = new Error(val.message);
|
|
@@ -372,12 +372,12 @@ Link.displayName = "Link";
|
|
|
372
372
|
const NavLink = React$1.forwardRef(function NavLinkWithRef({ "aria-current": ariaCurrentProp = "page", caseSensitive = false, className: classNameProp = "", end = false, style: styleProp, to, viewTransition, children, ...rest }, ref) {
|
|
373
373
|
let path = useResolvedPath(to, { relative: rest.relative });
|
|
374
374
|
let location = useLocation();
|
|
375
|
-
let
|
|
375
|
+
let routerNavigation = React$1.useContext(DataRouterNavigationContext);
|
|
376
376
|
let { navigator, basename } = React$1.useContext(NavigationContext);
|
|
377
|
-
let isTransitioning =
|
|
377
|
+
let isTransitioning = routerNavigation != null && useViewTransitionState(path) && viewTransition === true;
|
|
378
378
|
let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
|
|
379
379
|
let locationPathname = location.pathname;
|
|
380
|
-
let nextLocationPathname =
|
|
380
|
+
let nextLocationPathname = routerNavigation?.navigation.location ? routerNavigation.navigation.location.pathname : null;
|
|
381
381
|
if (!caseSensitive) {
|
|
382
382
|
locationPathname = locationPathname.toLowerCase();
|
|
383
383
|
nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
|
|
@@ -573,19 +573,6 @@ function ScrollRestoration({ getKey, storageKey, ...props }) {
|
|
|
573
573
|
});
|
|
574
574
|
}
|
|
575
575
|
ScrollRestoration.displayName = "ScrollRestoration";
|
|
576
|
-
function getDataRouterConsoleError(hookName) {
|
|
577
|
-
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
|
|
578
|
-
}
|
|
579
|
-
function useDataRouterContext(hookName) {
|
|
580
|
-
let ctx = React$1.useContext(DataRouterContext);
|
|
581
|
-
invariant(ctx, getDataRouterConsoleError(hookName));
|
|
582
|
-
return ctx;
|
|
583
|
-
}
|
|
584
|
-
function useDataRouterState(hookName) {
|
|
585
|
-
let state = React$1.useContext(DataRouterStateContext);
|
|
586
|
-
invariant(state, getDataRouterConsoleError(hookName));
|
|
587
|
-
return state;
|
|
588
|
-
}
|
|
589
576
|
/**
|
|
590
577
|
* Handles the click behavior for router {@link Link | `<Link>`} components.This
|
|
591
578
|
* is useful if you need to create custom {@link Link | `<Link>`} components with
|
|
@@ -788,7 +775,7 @@ let getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
|
|
|
788
775
|
function useSubmit() {
|
|
789
776
|
let { router } = useDataRouterContext("useSubmit");
|
|
790
777
|
let { basename } = React$1.useContext(NavigationContext);
|
|
791
|
-
let currentRouteId =
|
|
778
|
+
let currentRouteId = useCurrentRouteId("useSubmit");
|
|
792
779
|
let routerFetch = router.fetch;
|
|
793
780
|
let routerNavigate = router.navigate;
|
|
794
781
|
return React$1.useCallback(async (target, options = {}) => {
|
|
@@ -796,6 +783,7 @@ function useSubmit() {
|
|
|
796
783
|
if (options.navigate === false) await routerFetch(options.fetcherKey || getUniqueFetcherId(), currentRouteId, options.action || action, {
|
|
797
784
|
defaultShouldRevalidate: options.defaultShouldRevalidate,
|
|
798
785
|
preventScrollReset: options.preventScrollReset,
|
|
786
|
+
relative: options.relative,
|
|
799
787
|
formData,
|
|
800
788
|
body,
|
|
801
789
|
formMethod: options.method || method,
|
|
@@ -805,6 +793,7 @@ function useSubmit() {
|
|
|
805
793
|
else await routerNavigate(options.action || action, {
|
|
806
794
|
defaultShouldRevalidate: options.defaultShouldRevalidate,
|
|
807
795
|
preventScrollReset: options.preventScrollReset,
|
|
796
|
+
relative: options.relative,
|
|
808
797
|
formData,
|
|
809
798
|
body,
|
|
810
799
|
formMethod: options.method || method,
|
|
@@ -945,13 +934,8 @@ function useFormAction(action, { relative } = {}) {
|
|
|
945
934
|
*/
|
|
946
935
|
function useFetcher({ key } = {}) {
|
|
947
936
|
let { router } = useDataRouterContext("useFetcher");
|
|
948
|
-
let
|
|
949
|
-
let
|
|
950
|
-
let route = React$1.useContext(RouteContext);
|
|
951
|
-
let routeId = route.matches[route.matches.length - 1]?.route.id;
|
|
952
|
-
invariant(fetcherData, `useFetcher must be used inside a FetchersContext`);
|
|
953
|
-
invariant(route, `useFetcher must be used inside a RouteContext`);
|
|
954
|
-
invariant(routeId != null, `useFetcher can only be used on routes that contain a unique "id"`);
|
|
937
|
+
let fetchersContext = useDataRouterFetchers("useFetcher");
|
|
938
|
+
let routeId = useCurrentRouteId("useFetcher");
|
|
955
939
|
let defaultKey = React$1.useId();
|
|
956
940
|
let [fetcherKey, setFetcherKey] = React$1.useState(key || defaultKey);
|
|
957
941
|
if (key && key !== fetcherKey) setFetcherKey(key);
|
|
@@ -993,8 +977,8 @@ function useFetcher({ key } = {}) {
|
|
|
993
977
|
FetcherForm.displayName = "fetcher.Form";
|
|
994
978
|
return FetcherForm;
|
|
995
979
|
}, [fetcherKey]);
|
|
996
|
-
let fetcher =
|
|
997
|
-
let data = fetcherData.get(fetcherKey);
|
|
980
|
+
let fetcher = fetchersContext.fetchers.get(fetcherKey) || IDLE_FETCHER;
|
|
981
|
+
let data = fetchersContext.fetcherData.get(fetcherKey);
|
|
998
982
|
return React$1.useMemo(() => ({
|
|
999
983
|
Form: FetcherForm,
|
|
1000
984
|
submit,
|
|
@@ -1034,11 +1018,11 @@ function useFetcher({ key } = {}) {
|
|
|
1034
1018
|
* property.
|
|
1035
1019
|
*/
|
|
1036
1020
|
function useFetchers() {
|
|
1037
|
-
let
|
|
1038
|
-
return React$1.useMemo(() => Array.from(
|
|
1021
|
+
let { fetchers } = useDataRouterFetchers("useFetchers");
|
|
1022
|
+
return React$1.useMemo(() => Array.from(fetchers.entries()).map(([key, fetcher]) => ({
|
|
1039
1023
|
...fetcher,
|
|
1040
1024
|
key
|
|
1041
|
-
})), [
|
|
1025
|
+
})), [fetchers]);
|
|
1042
1026
|
}
|
|
1043
1027
|
const SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
|
|
1044
1028
|
let savedScrollPositions = {};
|
|
@@ -1087,6 +1071,9 @@ function useScrollRestoration({ getKey, storageKey } = {}) {
|
|
|
1087
1071
|
window.history.scrollRestoration = "auto";
|
|
1088
1072
|
};
|
|
1089
1073
|
}, []);
|
|
1074
|
+
usePageShow(React$1.useCallback((event) => {
|
|
1075
|
+
if (event.persisted) window.history.scrollRestoration = "manual";
|
|
1076
|
+
}, []));
|
|
1090
1077
|
usePageHide(React$1.useCallback(() => {
|
|
1091
1078
|
if (navigation.state === "idle") {
|
|
1092
1079
|
let key = getScrollRestorationKey(location, matches, basename, getKey);
|
|
@@ -1111,7 +1098,7 @@ function useScrollRestoration({ getKey, storageKey } = {}) {
|
|
|
1111
1098
|
try {
|
|
1112
1099
|
let sessionPositions = sessionStorage.getItem(storageKey || SCROLL_RESTORATION_STORAGE_KEY);
|
|
1113
1100
|
if (sessionPositions) savedScrollPositions = JSON.parse(sessionPositions);
|
|
1114
|
-
} catch
|
|
1101
|
+
} catch {}
|
|
1115
1102
|
}, [storageKey]);
|
|
1116
1103
|
React$1.useLayoutEffect(() => {
|
|
1117
1104
|
let disableScrollRestoration = router?.enableScrollRestoration(savedScrollPositions, () => window.scrollY, getKey ? (location, matches) => getScrollRestorationKey(location, matches, basename, getKey) : void 0);
|
|
@@ -1179,6 +1166,16 @@ function usePageHide(callback, options) {
|
|
|
1179
1166
|
};
|
|
1180
1167
|
}, [callback, capture]);
|
|
1181
1168
|
}
|
|
1169
|
+
function usePageShow(callback, options) {
|
|
1170
|
+
let { capture } = options || {};
|
|
1171
|
+
React$1.useEffect(() => {
|
|
1172
|
+
let opts = capture != null ? { capture } : void 0;
|
|
1173
|
+
window.addEventListener("pageshow", callback, opts);
|
|
1174
|
+
return () => {
|
|
1175
|
+
window.removeEventListener("pageshow", callback, opts);
|
|
1176
|
+
};
|
|
1177
|
+
}, [callback, capture]);
|
|
1178
|
+
}
|
|
1182
1179
|
/**
|
|
1183
1180
|
* Wrapper around {@link useBlocker} to show a [`window.confirm`](https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm)
|
|
1184
1181
|
* prompt to users instead of building a custom UI with {@link useBlocker}.
|
|
@@ -127,10 +127,15 @@ declare function StaticRouterProvider({
|
|
|
127
127
|
* `query`
|
|
128
128
|
* @param opts Options
|
|
129
129
|
* @param opts.future Future flags for the static {@link DataRouter}
|
|
130
|
-
* @param opts.branches
|
|
130
|
+
* @param opts.branches Deprecated optional pre-computed route branches. This option
|
|
131
|
+
* is no longer used because branch caching is done automatically inside the static router.
|
|
131
132
|
* @returns A static {@link DataRouter} that can be used to render the provided routes
|
|
132
133
|
*/
|
|
133
134
|
declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
|
|
135
|
+
/**
|
|
136
|
+
* @deprecated This option is no longer used because branch caching is done
|
|
137
|
+
* automatically inside the static router.
|
|
138
|
+
*/
|
|
134
139
|
branches?: RouteBranch<DataRouteObject>[];
|
|
135
140
|
future?: Partial<FutureConfig>;
|
|
136
141
|
}): Router;
|