react-router
Advanced tools
| /** | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
| * Copyright (c) Remix Software Inc. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE.md file in the root directory of this source tree. | ||
| * | ||
| * @license MIT | ||
| */ | ||
| //#region lib/router/url.ts | ||
| const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i; | ||
| const PROTOCOL_RELATIVE_URL_REGEX = /^[\\/]{2}/; | ||
| function normalizeProtocolRelativeUrl(url, protocol) { | ||
| return protocol + url.replace(/\\/g, "/"); | ||
| } | ||
| //#endregion | ||
| export { ABSOLUTE_URL_REGEX, PROTOCOL_RELATIVE_URL_REGEX, normalizeProtocolRelativeUrl }; |
| /** | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
| * Copyright (c) Remix Software Inc. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE.md file in the root directory of this source tree. | ||
| * | ||
| * @license MIT | ||
| */ | ||
| //#region lib/router/url.ts | ||
| const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i; | ||
| const PROTOCOL_RELATIVE_URL_REGEX = /^[\\/]{2}/; | ||
| function normalizeProtocolRelativeUrl(url, protocol) { | ||
| return protocol + url.replace(/\\/g, "/"); | ||
| } | ||
| //#endregion | ||
| export { ABSOLUTE_URL_REGEX, PROTOCOL_RELATIVE_URL_REGEX, normalizeProtocolRelativeUrl }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -29,3 +29,2 @@ | ||
| import { RSCDefaultRootErrorBoundary } from "./lib/rsc/errorBoundaries.js"; | ||
| import { deserializeErrors } from "./lib/dom/ssr/errors.js"; | ||
| import { RemixErrorBoundary } from "./lib/dom/ssr/errorBoundaries.js"; | ||
@@ -47,2 +46,2 @@ import { getPatchRoutesOnNavigationFunction, useFogOFWarDiscovery } from "./lib/dom/ssr/fog-of-war.js"; | ||
| //#endregion | ||
| export { type ActionFunction, type ActionFunctionArgs, type AppLoadContext, 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 InstrumentationHandlerResult, 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, deserializeErrors as UNSAFE_deserializeErrors, 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 }; | ||
| export { type ActionFunction, type ActionFunctionArgs, type AppLoadContext, 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 InstrumentationHandlerResult, 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 }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -38,3 +38,2 @@ * Copyright (c) Remix Software Inc. | ||
| import { RSCStaticRouter, routeRSCServerRequest } from "./lib/rsc/server.ssr.js"; | ||
| import { deserializeErrors } from "./lib/dom/ssr/errors.js"; | ||
| import { getHydrationData } from "./lib/dom/ssr/hydration.js"; | ||
@@ -47,2 +46,2 @@ //#region index.ts | ||
| //#endregion | ||
| 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, deserializeErrors as UNSAFE_deserializeErrors, 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 }; | ||
| 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 }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -12,4 +12,4 @@ * Copyright (c) Remix Software Inc. | ||
| //#region lib/actions.ts | ||
| function throwIfPotentialCSRFAttack(headers, allowedActionOrigins) { | ||
| let originHeader = headers.get("origin"); | ||
| function throwIfPotentialCSRFAttack(request, allowedActionOrigins) { | ||
| let originHeader = request.headers.get("origin"); | ||
| let originDomain = null; | ||
@@ -21,6 +21,5 @@ try { | ||
| } | ||
| let host = parseHostHeader(headers); | ||
| if (originDomain && (!host || originDomain !== host.value)) { | ||
| if (!isAllowedOrigin(originDomain, allowedActionOrigins)) if (host) throw new Error(`${host.type} header does not match \`origin\` header from a forwarded action request. Aborting the action.`); | ||
| else throw new Error("`x-forwarded-host` or `host` headers are not provided. One of these is needed to compare the `origin` header from a forwarded action request. Aborting the action."); | ||
| let host = new URL(request.url).host; | ||
| if (originDomain && originDomain !== host) { | ||
| if (!isAllowedOrigin(originDomain, allowedActionOrigins)) throw new Error("The `request.url` host does not match `origin` header from a forwarded action request. Aborting the action."); | ||
| } | ||
@@ -52,14 +51,3 @@ } | ||
| } | ||
| function parseHostHeader(headers) { | ||
| let forwardedHostValue = headers.get("x-forwarded-host")?.split(",")[0]?.trim(); | ||
| let hostHeader = headers.get("host"); | ||
| return forwardedHostValue ? { | ||
| type: "x-forwarded-host", | ||
| value: forwardedHostValue | ||
| } : hostHeader ? { | ||
| type: "host", | ||
| value: hostHeader | ||
| } : void 0; | ||
| } | ||
| //#endregion | ||
| export { throwIfPotentialCSRFAttack }; |
@@ -132,2 +132,6 @@ | ||
| * | ||
| * Data Routers should not be held in React state. You should create your router | ||
| * once outside of the React tree and pass it to {@link RouterProvider | `<RouterProvider>`}. | ||
| * You can use `patchRoutesOnNavigation` to add additional routes programmatically. | ||
| * | ||
| * @public | ||
@@ -167,3 +171,5 @@ * @category Data Routers | ||
| /** | ||
| * The {@link DataRouter} instance to use for navigation and data fetching. | ||
| * The {@link DataRouter} instance to use for navigation and data fetching. The | ||
| * router prop should be a single router instance created outside of the React | ||
| * tree. Avoid creating new routers during React renders/re-renders. | ||
| */ | ||
@@ -192,3 +198,3 @@ router: Router$1; | ||
| * ```tsx | ||
| * <RouterProvider onError=(error, info) => { | ||
| * <RouterProvider onError={(error, info) => { | ||
| * let { location, params, pattern, errorInfo } = info; | ||
@@ -223,3 +229,5 @@ * console.error(error, location, errorInfo); | ||
| * Render the UI for the given {@link DataRouter}. This component should | ||
| * typically be at the top of an app's element tree. | ||
| * typically be at the top of an app's element tree. The router prop should | ||
| * be a single router instance created outside of the React tree. Avoid | ||
| * creating new routers during React renders/re-renders. | ||
| * | ||
@@ -226,0 +234,0 @@ * ```tsx |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -26,2 +26,6 @@ * Copyright (c) Remix Software Inc. | ||
| * | ||
| * Data Routers should not be held in React state. You should create your router | ||
| * once outside of the React tree and pass it to {@link RouterProvider | `<RouterProvider>`}. | ||
| * You can use `patchRoutesOnNavigation` to add additional routes programmatically. | ||
| * | ||
| * @public | ||
@@ -85,3 +89,5 @@ * @category Data Routers | ||
| * Render the UI for the given {@link DataRouter}. This component should | ||
| * typically be at the top of an app's element tree. | ||
| * typically be at the top of an app's element tree. The router prop should | ||
| * be a single router instance created outside of the React tree. Avoid | ||
| * creating new routers during React renders/re-renders. | ||
| * | ||
@@ -88,0 +94,0 @@ * ```tsx |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -83,3 +83,3 @@ | ||
| * ```tsx | ||
| * <HydratedRouter onError=(error, info) => { | ||
| * <HydratedRouter onError={(error, info) => { | ||
| * let { location, params, pattern, errorInfo } = info; | ||
@@ -86,0 +86,0 @@ * console.error(error, location, errorInfo); |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -14,3 +14,3 @@ * Copyright (c) Remix Software Inc. | ||
| import * as React$1 from "react"; | ||
| import { UNSAFE_FrameworkContext, UNSAFE_RemixErrorBoundary, UNSAFE_createBrowserHistory, UNSAFE_createClientRoutes, UNSAFE_createClientRoutesWithHMRRevalidationOptOut, UNSAFE_createRouter, UNSAFE_decodeViaTurboStream, UNSAFE_defaultMapRouteProperties, UNSAFE_deserializeErrors, UNSAFE_getHydrationData, UNSAFE_getPatchRoutesOnNavigationFunction, UNSAFE_getTurboStreamSingleFetchDataStrategy, UNSAFE_hydrationRouteProperties, UNSAFE_invariant, UNSAFE_useFogOFWarDiscovery } from "react-router"; | ||
| import { UNSAFE_FrameworkContext, UNSAFE_RemixErrorBoundary, UNSAFE_createBrowserHistory, UNSAFE_createClientRoutes, UNSAFE_createClientRoutesWithHMRRevalidationOptOut, UNSAFE_createRouter, UNSAFE_decodeViaTurboStream, UNSAFE_defaultMapRouteProperties, UNSAFE_getHydrationData, UNSAFE_getPatchRoutesOnNavigationFunction, UNSAFE_getTurboStreamSingleFetchDataStrategy, UNSAFE_hydrationRouteProperties, UNSAFE_invariant, UNSAFE_useFogOFWarDiscovery } from "react-router"; | ||
| //#region lib/dom-export/hydrated-router.tsx | ||
@@ -61,17 +61,14 @@ let ssrInfo = null; | ||
| if (ssrInfo.manifest.routes.root?.hasLoader && loaderData && "root" in loaderData) hydrationData = { loaderData: { root: loaderData.root } }; | ||
| } else { | ||
| hydrationData = UNSAFE_getHydrationData({ | ||
| state: ssrInfo.context.state, | ||
| routes, | ||
| getRouteInfo: (routeId) => ({ | ||
| clientLoader: ssrInfo.routeModules[routeId]?.clientLoader, | ||
| hasLoader: ssrInfo.manifest.routes[routeId]?.hasLoader === true, | ||
| hasHydrateFallback: ssrInfo.routeModules[routeId]?.HydrateFallback != null | ||
| }), | ||
| location: window.location, | ||
| basename: window.__reactRouterContext?.basename, | ||
| isSpaMode: ssrInfo.context.isSpaMode | ||
| }); | ||
| if (hydrationData && hydrationData.errors) hydrationData.errors = UNSAFE_deserializeErrors(hydrationData.errors); | ||
| } | ||
| } else hydrationData = UNSAFE_getHydrationData({ | ||
| state: ssrInfo.context.state, | ||
| routes, | ||
| getRouteInfo: (routeId) => ({ | ||
| clientLoader: ssrInfo.routeModules[routeId]?.clientLoader, | ||
| hasLoader: ssrInfo.manifest.routes[routeId]?.hasLoader === true, | ||
| hasHydrateFallback: ssrInfo.routeModules[routeId]?.HydrateFallback != null | ||
| }), | ||
| location: window.location, | ||
| basename: window.__reactRouterContext?.basename, | ||
| isSpaMode: ssrInfo.context.isSpaMode | ||
| }); | ||
| if (window.history.state && window.history.state.masked) window.history.replaceState({ | ||
@@ -78,0 +75,0 @@ ...window.history.state, |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,4 +11,5 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { ABSOLUTE_URL_REGEX } from "../router/url.js"; | ||
| import { createBrowserHistory, createHashHistory, createPath, invariant, warning } from "../router/history.js"; | ||
| import { ErrorResponseImpl, defaultMapRouteProperties, joinPaths, matchPath, parseToInfo, resolveTo, stripBasename } from "../router/utils.js"; | ||
| import { ErrorResponseImpl, SUPPORTED_ERROR_TYPES, defaultMapRouteProperties, joinPaths, matchPath, parseToInfo, resolveTo, stripBasename } from "../router/utils.js"; | ||
| import { IDLE_FETCHER, createRouter } from "../router/router.js"; | ||
@@ -25,3 +26,3 @@ import { DataRouterContext, DataRouterStateContext, FetchersContext, NavigationContext, RouteContext, ViewTransitionContext } from "../context.js"; | ||
| try { | ||
| if (isBrowser) window.__reactRouterVersion = "8.0.0-pre.0"; | ||
| if (isBrowser) window.__reactRouterVersion = "8.0.0-pre.1"; | ||
| } catch (e) {} | ||
@@ -33,2 +34,6 @@ /** | ||
| * | ||
| * Data Routers should not be held in React state. You should create your router | ||
| * once outside of the React tree and pass it to {@link RouterProvider | `<RouterProvider>`}. | ||
| * You can use `patchRoutesOnNavigation` to add additional routes programmatically. | ||
| * | ||
| * @public | ||
@@ -69,2 +74,6 @@ * @category Data Routers | ||
| * | ||
| * Data Routers should not be held in React state. You should create your router | ||
| * once outside of the React tree and pass it to {@link RouterProvider | `<RouterProvider>`}. | ||
| * You can use `patchRoutesOnNavigation` to add additional routes programmatically. | ||
| * | ||
| * @public | ||
@@ -115,3 +124,3 @@ * @category Data Routers | ||
| else if (val && val.__type === "Error") { | ||
| if (val.__subType) { | ||
| if (typeof val.__subType === "string" && SUPPORTED_ERROR_TYPES.includes(val.__subType)) { | ||
| let ErrorConstructor = window[val.__subType]; | ||
@@ -252,3 +261,2 @@ if (typeof ErrorConstructor === "function") try { | ||
| HistoryRouter.displayName = "unstable_HistoryRouter"; | ||
| const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i; | ||
| /** | ||
@@ -518,3 +526,6 @@ * A progressively enhanced [`<a href>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) | ||
| * | ||
| * This component renders an inline `<script>` to prevent scroll flashing. The `nonce` prop will be passed down to the script tag to allow CSP nonce usage. | ||
| * This component renders an inline `<script>` to prevent scroll flashing. The | ||
| * `nonce` prop will be passed down to the script tag to allow CSP nonce usage. | ||
| * If not provided in Framework Mode, it will default to any | ||
| * {@link ServerRouter | `<ServerRouter nonce>`} prop. | ||
| * | ||
@@ -564,2 +575,3 @@ * ```tsx | ||
| }).toString(); | ||
| if (props.nonce == null && remixContext?.nonce) props.nonce = remixContext.nonce; | ||
| return /* @__PURE__ */ React$1.createElement("script", { | ||
@@ -566,0 +578,0 @@ ...props, |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,2 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { ABSOLUTE_URL_REGEX } from "../router/url.js"; | ||
| import { createPath, invariant, parsePath } from "../router/history.js"; | ||
@@ -300,4 +301,3 @@ import { convertRoutesToDataRoutes, isRouteErrorResponse } from "../router/utils.js"; | ||
| } | ||
| const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i; | ||
| //#endregion | ||
| export { StaticRouter, StaticRouterProvider, createStaticRouter }; |
@@ -34,3 +34,4 @@ | ||
| * attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) | ||
| * element | ||
| * element. If not provided in Framework Mode, it will default to any | ||
| * {@link ServerRouter | `<ServerRouter nonce>`} prop. | ||
| */ | ||
@@ -158,3 +159,4 @@ nonce?: string | undefined; | ||
| * attribute to render on the [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) | ||
| * element | ||
| * element. If not provided in Framework Mode, it will default to any | ||
| * {@link ServerRouter | `<ServerRouter nonce>`} prop. | ||
| */ | ||
@@ -161,0 +163,0 @@ nonce?: string | undefined; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -144,3 +144,3 @@ * Copyright (c) Remix Software Inc. | ||
| function Links({ nonce, crossOrigin }) { | ||
| let { isSpaMode, manifest, routeModules, criticalCss } = useFrameworkContext(); | ||
| let { isSpaMode, manifest, routeModules, criticalCss, nonce: contextNonce } = useFrameworkContext(); | ||
| let { errors, matches: routerMatches } = useDataRouterStateContext(); | ||
@@ -153,2 +153,3 @@ let matches = getActiveMatches(routerMatches, errors, isSpaMode); | ||
| ]); | ||
| if (nonce == null && contextNonce) nonce = contextNonce; | ||
| return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, typeof criticalCss === "string" ? /* @__PURE__ */ React$1.createElement("style", { | ||
@@ -205,2 +206,3 @@ [CRITICAL_CSS_DATA_ATTRIBUTE]: "", | ||
| let rsc = useIsRSCRouterContext(); | ||
| let { nonce: contextNonce } = useFrameworkContext(); | ||
| let { router } = useDataRouterContext(); | ||
@@ -213,2 +215,6 @@ let matches = React$1.useMemo(() => matchRoutes(router.routes, page, router.basename), [ | ||
| if (!matches) return null; | ||
| if (linkProps.nonce == null && contextNonce) linkProps = { | ||
| ...linkProps, | ||
| nonce: contextNonce | ||
| }; | ||
| if (rsc) return /* @__PURE__ */ React$1.createElement(RSCPrefetchPageLinksImpl, { | ||
@@ -480,3 +486,3 @@ page, | ||
| function Scripts(scriptProps) { | ||
| let { manifest, serverHandoffString, isSpaMode, renderMeta, routeDiscovery, ssr } = useFrameworkContext(); | ||
| let { manifest, serverHandoffString, isSpaMode, renderMeta, routeDiscovery, ssr, nonce: contextNonce } = useFrameworkContext(); | ||
| let { router, static: isStatic, staticContext } = useDataRouterContext(); | ||
@@ -486,2 +492,6 @@ let { matches: routerMatches } = useDataRouterStateContext(); | ||
| let enableFogOfWar = isFogOfWarEnabled(routeDiscovery, ssr); | ||
| if (scriptProps.nonce == null && contextNonce) scriptProps = { | ||
| ...scriptProps, | ||
| nonce: contextNonce | ||
| }; | ||
| if (renderMeta) renderMeta.didRenderScripts = true; | ||
@@ -488,0 +498,0 @@ let matches = getActiveMatches(routerMatches, null, isSpaMode); |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -22,2 +22,3 @@ | ||
| routeDiscovery: ServerBuild["routeDiscovery"]; | ||
| nonce?: string; | ||
| serializeError?(error: Error): SerializedError; | ||
@@ -24,0 +25,0 @@ renderMeta?: { |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -48,8 +48,12 @@ * Copyright (c) Remix Software Inc. | ||
| function RemixRootDefaultErrorBoundary({ error, isOutsideRemixApp }) { | ||
| let { nonce } = useFrameworkContext(); | ||
| console.error(error); | ||
| let heyDeveloper = /* @__PURE__ */ React$1.createElement("script", { dangerouslySetInnerHTML: { __html: ` | ||
| let heyDeveloper = /* @__PURE__ */ React$1.createElement("script", { | ||
| nonce, | ||
| dangerouslySetInnerHTML: { __html: ` | ||
| console.log( | ||
| "💿 Hey developer 👋. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information." | ||
| ); | ||
| ` } }); | ||
| ` } | ||
| }); | ||
| if (isRouteErrorResponse(error)) return /* @__PURE__ */ React$1.createElement(BoundaryShell, { title: "Unhandled Thrown Response!" }, /* @__PURE__ */ React$1.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText), heyDeveloper); | ||
@@ -56,0 +60,0 @@ let errorInstance; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -12,9 +12,13 @@ * Copyright (c) Remix Software Inc. | ||
| import { BoundaryShell } from "./errorBoundaries.js"; | ||
| import { useFrameworkContext } from "./components.js"; | ||
| import * as React$1 from "react"; | ||
| //#region lib/dom/ssr/fallback.tsx | ||
| function RemixRootDefaultHydrateFallback() { | ||
| let { nonce } = useFrameworkContext(); | ||
| return /* @__PURE__ */ React$1.createElement(BoundaryShell, { | ||
| title: "Loading...", | ||
| renderScripts: true | ||
| }, /* @__PURE__ */ React$1.createElement("script", { dangerouslySetInnerHTML: { __html: ` | ||
| }, /* @__PURE__ */ React$1.createElement("script", { | ||
| nonce, | ||
| dangerouslySetInnerHTML: { __html: ` | ||
| console.log( | ||
@@ -26,5 +30,6 @@ "💿 Hey developer 👋. You can provide a way better UX than this " + | ||
| ); | ||
| ` } })); | ||
| ` } | ||
| })); | ||
| } | ||
| //#endregion | ||
| export { RemixRootDefaultHydrateFallback }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -20,2 +20,11 @@ * Copyright (c) Remix Software Inc. | ||
| const URL_LIMIT = 7680; | ||
| function getPathsWithAncestors(paths) { | ||
| let result = /* @__PURE__ */ new Set(); | ||
| paths.forEach((path) => { | ||
| if (!path.startsWith("/")) path = `/${path}`; | ||
| for (let i = 1; i < path.length; i++) if (path[i] === "/") result.add(path.slice(0, i)); | ||
| result.add(path); | ||
| }); | ||
| return Array.from(result); | ||
| } | ||
| function isFogOfWarEnabled(routeDiscovery, ssr) { | ||
@@ -106,2 +115,3 @@ return routeDiscovery.mode === "lazy" && ssr === true; | ||
| async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal) { | ||
| paths = getPathsWithAncestors(paths); | ||
| const searchParams = new URLSearchParams(); | ||
@@ -172,2 +182,2 @@ searchParams.set("paths", paths.sort().join(",")); | ||
| //#endregion | ||
| export { URL_LIMIT, getManifestPath, getPartialManifest, getPatchRoutesOnNavigationFunction, isFogOfWarEnabled, useFogOFWarDiscovery }; | ||
| export { URL_LIMIT, getManifestPath, getPartialManifest, getPatchRoutesOnNavigationFunction, getPathsWithAncestors, isFogOfWarEnabled, useFogOFWarDiscovery }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -21,3 +21,6 @@ | ||
| * An optional `nonce` for [Content Security Policy (CSP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP) | ||
| * compliance, used to allow inline scripts to run safely. | ||
| * compliance. This is applied to inline scripts rendered by React Router and | ||
| * used as the default for nonce-aware components such as {@link Links | `<Links>`}, | ||
| * {@link Scripts | `<Scripts>`}, and {@link ScrollRestoration | `<ScrollRestoration>`} | ||
| * when they do not provide their own `nonce`. | ||
| */ | ||
@@ -24,0 +27,0 @@ nonce?: string; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -53,2 +53,3 @@ * Copyright (c) Remix Software Inc. | ||
| routeDiscovery: context.routeDiscovery, | ||
| nonce, | ||
| serializeError: context.serializeError, | ||
@@ -55,0 +56,0 @@ renderMeta: context.renderMeta |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,7 +11,6 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { ErrorResponseImpl, data, isRouteErrorResponse, redirect } from "../../router/utils.js"; | ||
| import { ErrorResponseImpl, SUPPORTED_ERROR_TYPES, data, isRouteErrorResponse, redirect } from "../../router/utils.js"; | ||
| import { isDataWithResponseInit, isResponse } from "../../router/router.js"; | ||
| import invariant from "./invariant.js"; | ||
| import { escapeHtml } from "./markup.js"; | ||
| import { SUPPORTED_ERROR_TYPES } from "../../../vendor/turbo-stream-v2/utils.js"; | ||
| import { decode } from "../../../vendor/turbo-stream-v2/turbo-stream.js"; | ||
@@ -18,0 +17,0 @@ import { createRequestInit } from "./data.js"; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -13,3 +13,3 @@ * Copyright (c) Remix Software Inc. | ||
| import { convertRouteMatchToUiMatch, decodePath, getResolveToMatches, getRoutePattern, isBrowser, isRouteErrorResponse, joinPaths, matchPath, matchRoutes, parseToInfo, resolveTo, stripBasename } from "./router/utils.js"; | ||
| import { IDLE_BLOCKER } from "./router/router.js"; | ||
| import { IDLE_BLOCKER, hasInvalidProtocol } from "./router/router.js"; | ||
| import { AwaitContext, DataRouterContext, DataRouterStateContext, LocationContext, NavigationContext, RSCRouterContext, RouteContext, RouteErrorContext } from "./context.js"; | ||
@@ -694,3 +694,5 @@ import { decodeRedirectErrorDigest, decodeRouteErrorResponseDigest } from "./errors.js"; | ||
| let parsed = parseToInfo(redirect.location, basename); | ||
| if (isBrowser && !errorRedirectHandledMap.get(error)) if (parsed.isExternal || redirect.reloadDocument) window.location.href = parsed.absoluteURL || parsed.to; | ||
| let target = parsed.absoluteURL || parsed.to; | ||
| if (hasInvalidProtocol(target)) throw new Error("Invalid redirect location"); | ||
| if (isBrowser && !errorRedirectHandledMap.get(error)) if (parsed.isExternal || redirect.reloadDocument) window.location.href = target; | ||
| else { | ||
@@ -703,3 +705,3 @@ const redirectPromise = Promise.resolve().then(() => window.__reactRouterDataRouter.navigate(parsed.to, { replace: redirect.replace })); | ||
| httpEquiv: "refresh", | ||
| content: `0;url=${parsed.absoluteURL || parsed.to}` | ||
| content: `0;url=${target}` | ||
| }); | ||
@@ -706,0 +708,0 @@ } |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,2 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { PROTOCOL_RELATIVE_URL_REGEX } from "./url.js"; | ||
| //#region lib/router/history.ts | ||
@@ -368,3 +369,3 @@ /** | ||
| href = href.replace(/ $/, "%20"); | ||
| if (!isAbsolute && href.startsWith("//")) href = base + href; | ||
| if (!isAbsolute && PROTOCOL_RELATIVE_URL_REGEX.test(href)) href = base + href; | ||
| return new URL(href, base); | ||
@@ -371,0 +372,0 @@ } |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -103,4 +103,5 @@ | ||
| * attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) | ||
| * element | ||
| */ | ||
| * element. If not provided in Framework Mode, it will default to any | ||
| * {@link ServerRouter | `<ServerRouter nonce>`} prop. | ||
| */ | ||
| nonce?: string | undefined; | ||
@@ -107,0 +108,0 @@ /** |
@@ -671,2 +671,4 @@ | ||
| route: RouteObjectType; | ||
| matcher?: RegExp; | ||
| compiledParams?: CompiledPathParam[]; | ||
| } | ||
@@ -756,2 +758,6 @@ /** | ||
| declare function matchPath<Path extends string>(pattern: PathPattern<Path> | Path, pathname: string): PathMatch<ParamParseKey<Path>> | null; | ||
| type CompiledPathParam = { | ||
| paramName: string; | ||
| isOptional?: boolean; | ||
| }; | ||
| /** | ||
@@ -758,0 +764,0 @@ * Returns a resolved {@link Path} object relative to the given pathname. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,2 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { ABSOLUTE_URL_REGEX, PROTOCOL_RELATIVE_URL_REGEX, normalizeProtocolRelativeUrl } from "./url.js"; | ||
| import { invariant, parsePath, warning } from "./history.js"; | ||
@@ -293,3 +294,10 @@ import * as React$1 from "react"; | ||
| score: computeScore(path, route.index), | ||
| routesMeta | ||
| routesMeta: routesMeta.map((meta, i) => { | ||
| let [matcher, params] = compilePath(meta.relativePath, meta.caseSensitive, i === routesMeta.length - 1); | ||
| return { | ||
| ...meta, | ||
| matcher, | ||
| compiledParams: params | ||
| }; | ||
| }) | ||
| }); | ||
@@ -345,7 +353,8 @@ }; | ||
| let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/"; | ||
| let match = matchPath({ | ||
| let pattern = { | ||
| path: meta.relativePath, | ||
| caseSensitive: meta.caseSensitive, | ||
| end | ||
| }, remainingPathname); | ||
| }; | ||
| let match = meta.matcher && meta.compiledParams ? matchPathImpl(pattern, remainingPathname, meta.matcher, meta.compiledParams) : matchPath(pattern, remainingPathname); | ||
| let route = meta.route; | ||
@@ -424,2 +433,5 @@ if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) match = matchPath({ | ||
| let [matcher, compiledParams] = compilePath(pattern.path, pattern.caseSensitive, pattern.end); | ||
| return matchPathImpl(pattern, pathname, matcher, compiledParams); | ||
| } | ||
| function matchPathImpl(pattern, pathname, matcher, compiledParams) { | ||
| let match = pathname.match(matcher); | ||
@@ -487,3 +499,2 @@ if (!match) return null; | ||
| } | ||
| const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i; | ||
| const isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX.test(url); | ||
@@ -564,3 +575,3 @@ /** | ||
| } | ||
| const removeDoubleSlashes = (path) => path.replace(/\/\/+/g, "/"); | ||
| const removeDoubleSlashes = (path) => path.replace(/[\\/]{2,}/g, "/"); | ||
| const joinPaths = (paths) => removeDoubleSlashes(paths.join("/")); | ||
@@ -718,2 +729,10 @@ const removeTrailingSlash = (path) => path.replace(/\/+$/, ""); | ||
| }; | ||
| const SUPPORTED_ERROR_TYPES = [ | ||
| "EvalError", | ||
| "RangeError", | ||
| "ReferenceError", | ||
| "SyntaxError", | ||
| "TypeError", | ||
| "URIError" | ||
| ]; | ||
| var ErrorResponseImpl = class { | ||
@@ -784,3 +803,3 @@ status; | ||
| let currentUrl = new URL(window.location.href); | ||
| let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to); | ||
| let targetUrl = PROTOCOL_RELATIVE_URL_REGEX.test(to) ? new URL(normalizeProtocolRelativeUrl(to, currentUrl.protocol)) : new URL(to); | ||
| let path = stripBasename(targetUrl.pathname, basename); | ||
@@ -799,2 +818,2 @@ if (targetUrl.origin === currentUrl.origin && path != null) to = path + targetUrl.search + targetUrl.hash; | ||
| //#endregion | ||
| export { ErrorResponseImpl, RouterContextProvider, compilePath, convertRouteMatchToUiMatch, convertRoutesToDataRoutes, createContext, data, decodePath, defaultMapRouteProperties, flattenAndRankRoutes, generatePath, getPathContributingMatches, getResolveToMatches, getRoutePattern, isAbsoluteUrl, isBrowser, isRouteErrorResponse, isUnsupportedLazyRouteFunctionKey, isUnsupportedLazyRouteObjectKey, joinPaths, matchPath, matchRoutes, matchRoutesImpl, parseToInfo, prependBasename, redirect, redirectDocument, removeDoubleSlashes, replace, resolvePath, resolveTo, stripBasename }; | ||
| export { ErrorResponseImpl, RouterContextProvider, SUPPORTED_ERROR_TYPES, compilePath, convertRouteMatchToUiMatch, convertRoutesToDataRoutes, createContext, data, decodePath, defaultMapRouteProperties, flattenAndRankRoutes, generatePath, getPathContributingMatches, getResolveToMatches, getRoutePattern, isAbsoluteUrl, isBrowser, isRouteErrorResponse, isUnsupportedLazyRouteFunctionKey, isUnsupportedLazyRouteObjectKey, joinPaths, matchPath, matchRoutes, matchRoutesImpl, parseToInfo, prependBasename, redirect, redirectDocument, removeDoubleSlashes, removeTrailingSlash, replace, resolvePath, resolveTo, stripBasename }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,5 +11,6 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { PROTOCOL_RELATIVE_URL_REGEX } from "../router/url.js"; | ||
| import { createBrowserHistory, invariant } from "../router/history.js"; | ||
| import { ErrorResponseImpl, createContext } from "../router/utils.js"; | ||
| import { createRouter, invalidProtocols, isMutationMethod } from "../router/router.js"; | ||
| import { ErrorResponseImpl, createContext, resolvePath } from "../router/utils.js"; | ||
| import { createRouter, hasInvalidProtocol, isMutationMethod } from "../router/router.js"; | ||
| import { RSCRouterContext } from "../context.js"; | ||
@@ -20,3 +21,3 @@ import { RouterProvider } from "../components.js"; | ||
| import { noActionDefinedError, shouldHydrateRouteLoader } from "../dom/ssr/routes.js"; | ||
| import "../dom/ssr/fog-of-war.js"; | ||
| import { getPathsWithAncestors } from "../dom/ssr/fog-of-war.js"; | ||
| import { FrameworkContext, setIsHydrated } from "../dom/ssr/components.js"; | ||
@@ -85,9 +86,10 @@ import { RSCRouterGlobalErrorBoundary } from "./errorBoundaries.js"; | ||
| if (payload.type === "redirect") { | ||
| if (payload.reload || isExternalLocation(payload.location)) { | ||
| if (hasInvalidProtocol(payload.location)) throw new Error("Invalid redirect location"); | ||
| window.location.href = payload.location; | ||
| let location = normalizeRedirectLocation(payload.location); | ||
| if (payload.reload || isExternalLocation(location)) { | ||
| if (hasInvalidProtocol(location)) throw new Error("Invalid redirect location"); | ||
| window.location.href = location; | ||
| return; | ||
| } | ||
| React$1.startTransition(() => { | ||
| globalVar.__reactRouterDataRouter.navigate(payload.location, { replace: payload.replace }); | ||
| globalVar.__reactRouterDataRouter.navigate(location, { replace: payload.replace }); | ||
| }); | ||
@@ -100,9 +102,10 @@ return; | ||
| if (rerender.type === "redirect") { | ||
| if (rerender.reload || isExternalLocation(rerender.location)) { | ||
| if (hasInvalidProtocol(rerender.location)) throw new Error("Invalid redirect location"); | ||
| window.location.href = rerender.location; | ||
| let location = normalizeRedirectLocation(rerender.location); | ||
| if (rerender.reload || isExternalLocation(location)) { | ||
| if (hasInvalidProtocol(location)) throw new Error("Invalid redirect location"); | ||
| window.location.href = location; | ||
| return; | ||
| } | ||
| React$1.startTransition(() => { | ||
| globalVar.__reactRouterDataRouter.navigate(rerender.location, { replace: rerender.replace }); | ||
| globalVar.__reactRouterDataRouter.navigate(location, { replace: rerender.replace }); | ||
| }); | ||
@@ -540,2 +543,3 @@ return; | ||
| async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fetchImplementation, signal) { | ||
| paths = getPathsWithAncestors(paths); | ||
| let url = getManifestUrl(paths); | ||
@@ -576,8 +580,8 @@ if (url == null) return; | ||
| } | ||
| function hasInvalidProtocol(location) { | ||
| try { | ||
| return invalidProtocols.includes(new URL(location).protocol); | ||
| } catch { | ||
| return false; | ||
| function normalizeRedirectLocation(location) { | ||
| if (PROTOCOL_RELATIVE_URL_REGEX.test(location)) { | ||
| let path = resolvePath(location); | ||
| return path.pathname + path.search + path.hash; | ||
| } | ||
| return location; | ||
| } | ||
@@ -584,0 +588,0 @@ function cloneRoutes(routes) { |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -12,2 +12,3 @@ * Copyright (c) Remix Software Inc. | ||
| import { isRouteErrorResponse } from "../router/utils.js"; | ||
| import { hasInvalidProtocol } from "../router/router.js"; | ||
| import { RSCRouterContext } from "../context.js"; | ||
@@ -126,2 +127,3 @@ import { decodeRedirectErrorDigest, decodeRouteErrorResponseDigest } from "../errors.js"; | ||
| if (serverResponse.status === 202 && payload.type === "redirect") { | ||
| if (hasInvalidProtocol(payload.location)) throw new Error("Invalid redirect location"); | ||
| const headers = new Headers(serverResponse.headers); | ||
@@ -164,2 +166,3 @@ headers.delete("Content-Encoding"); | ||
| if (renderRedirect) { | ||
| if (hasInvalidProtocol(renderRedirect.location)) throw new Error("Invalid redirect location"); | ||
| headers.set("Location", renderRedirect.location); | ||
@@ -172,3 +175,6 @@ return new Response(html, { | ||
| const redirectTransform = new TransformStream({ flush(controller) { | ||
| if (renderRedirect) controller.enqueue(new TextEncoder().encode(`<meta http-equiv="refresh" content="0;url=${escapeHtml(renderRedirect.location)}"/>`)); | ||
| if (renderRedirect) { | ||
| if (hasInvalidProtocol(renderRedirect.location)) return; | ||
| controller.enqueue(new TextEncoder().encode(`<meta http-equiv="refresh" content="0;url=${escapeHtml(renderRedirect.location)}"/>`)); | ||
| } | ||
| } }); | ||
@@ -189,6 +195,9 @@ if (!hydrate) return new Response(html.pipeThrough(redirectTransform), { | ||
| if (error instanceof Response) return error; | ||
| if (renderRedirect) return new Response(`Redirect: ${renderRedirect.location}`, { | ||
| status: renderRedirect.status, | ||
| headers: { Location: renderRedirect.location } | ||
| }); | ||
| if (renderRedirect) { | ||
| if (hasInvalidProtocol(renderRedirect.location)) throw new Error("Invalid redirect location"); | ||
| return new Response(`Redirect: ${renderRedirect.location}`, { | ||
| status: renderRedirect.status, | ||
| headers: { Location: renderRedirect.location } | ||
| }); | ||
| } | ||
| try { | ||
@@ -238,2 +247,3 @@ let normalizedError = renderError ?? error; | ||
| if (retryRedirect) { | ||
| if (hasInvalidProtocol(retryRedirect.location)) throw new Error("Invalid redirect location"); | ||
| headers.set("Location", retryRedirect.location); | ||
@@ -246,3 +256,6 @@ return new Response(html, { | ||
| const retryRedirectTransform = new TransformStream({ flush(controller) { | ||
| if (retryRedirect) controller.enqueue(new TextEncoder().encode(`<meta http-equiv="refresh" content="0;url=${escapeHtml(retryRedirect.location)}"/>`)); | ||
| if (retryRedirect) { | ||
| if (hasInvalidProtocol(retryRedirect.location)) return; | ||
| controller.enqueue(new TextEncoder().encode(`<meta http-equiv="refresh" content="0;url=${escapeHtml(retryRedirect.location)}"/>`)); | ||
| } | ||
| } }); | ||
@@ -305,6 +318,9 @@ if (!hydrate) return new Response(html.pipeThrough(retryRedirectTransform), { | ||
| const payload = React$1.use(decoded); | ||
| if (payload.type === "redirect") throw new Response(null, { | ||
| status: payload.status, | ||
| headers: { Location: payload.location } | ||
| }); | ||
| if (payload.type === "redirect") { | ||
| if (hasInvalidProtocol(payload.location)) throw new Error("Invalid redirect location"); | ||
| throw new Response(null, { | ||
| status: payload.status, | ||
| headers: { Location: payload.location } | ||
| }); | ||
| } | ||
| if (payload.type !== "render") return null; | ||
@@ -311,0 +327,0 @@ let patchedLoaderData = { ...payload.loaderData }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,3 +11,2 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { isRouteErrorResponse } from "../router/utils.js"; | ||
| import "./mode.js"; | ||
@@ -76,22 +75,3 @@ //#region lib/server-runtime/errors.ts | ||
| } | ||
| function serializeErrors(errors, serverMode) { | ||
| if (!errors) return null; | ||
| let entries = Object.entries(errors); | ||
| let serialized = {}; | ||
| for (let [key, val] of entries) if (isRouteErrorResponse(val)) serialized[key] = { | ||
| ...val, | ||
| __type: "RouteErrorResponse" | ||
| }; | ||
| else if (val instanceof Error) { | ||
| let sanitized = sanitizeError(val, serverMode); | ||
| serialized[key] = { | ||
| message: sanitized.message, | ||
| stack: sanitized.stack, | ||
| __type: "Error", | ||
| ...sanitized.name !== "Error" ? { __subType: sanitized.name } : {} | ||
| }; | ||
| } else serialized[key] = val; | ||
| return serialized; | ||
| } | ||
| //#endregion | ||
| export { sanitizeError, sanitizeErrors, serializeError, serializeErrors }; | ||
| export { sanitizeError, sanitizeErrors, serializeError }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,3 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { ErrorResponseImpl, RouterContextProvider, defaultMapRouteProperties, isRouteErrorResponse, stripBasename } from "../router/utils.js"; | ||
| import { ErrorResponseImpl, RouterContextProvider, defaultMapRouteProperties, isRouteErrorResponse, removeTrailingSlash, stripBasename } from "../router/utils.js"; | ||
| import { instrumentHandler } from "../router/instrumentation.js"; | ||
@@ -18,3 +18,3 @@ import { createStaticHandler, getStaticContextFromError, isMutationMethod, isRedirectResponse, isResponse } from "../router/router.js"; | ||
| import { isServerMode } from "./mode.js"; | ||
| import { sanitizeErrors, serializeError, serializeErrors } from "./errors.js"; | ||
| import { sanitizeErrors, serializeError } from "./errors.js"; | ||
| import { matchServerRoutes } from "./routeMatching.js"; | ||
@@ -59,3 +59,3 @@ import { getBuildTimeHeader, getDevServerHooks } from "./dev.js"; | ||
| let requestUrl = new URL(request.url); | ||
| let normalizedPathname = getNormalizedPath(request, build.basename).pathname; | ||
| let normalizedPathname = getNormalizedPath(request).pathname; | ||
| let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes"; | ||
@@ -80,3 +80,3 @@ if (!build.ssr) { | ||
| if (build.prerender.length === 0) isSpaMode = true; | ||
| else if (!build.prerender.includes(decodedPath) && !build.prerender.includes(decodedPath + "/")) if (requestUrl.pathname.endsWith(".data")) { | ||
| else if (!build.prerender.some((p) => removeTrailingSlash(p) === removeTrailingSlash(decodedPath))) if (requestUrl.pathname.endsWith(".data")) { | ||
| errorHandler(new ErrorResponseImpl(404, "Not Found", `Refusing to SSR the path \`${decodedPath}\` because \`ssr:false\` is set and the path is not included in the \`prerender\` config, so in production the path will be a 404.`), { | ||
@@ -162,2 +162,6 @@ context: loadContext, | ||
| async function handleManifestRequest(build, dataRoutes, branches, url) { | ||
| if (url.toString().length > 7680) return new Response(null, { | ||
| statusText: "Bad Request", | ||
| status: 400 | ||
| }); | ||
| if (build.assets.version !== url.searchParams.get("version")) return new Response(null, { | ||
@@ -167,18 +171,8 @@ status: 204, | ||
| }); | ||
| if (url.toString().length > 7680) return new Response(null, { | ||
| statusText: "Bad Request", | ||
| status: 400 | ||
| }); | ||
| let patches = {}; | ||
| if (url.searchParams.has("paths")) { | ||
| let paths = /* @__PURE__ */ new Set(); | ||
| (url.searchParams.get("paths") || "").split(",").filter(Boolean).forEach((path) => { | ||
| let pathParam = url.searchParams.get("paths") || ""; | ||
| let paths = new Set(pathParam.split(",").filter(Boolean)); | ||
| for (let path of paths) { | ||
| if (!path.startsWith("/")) path = `/${path}`; | ||
| let segments = path.split("/").slice(1); | ||
| segments.forEach((_, i) => { | ||
| let partialPath = segments.slice(0, i + 1).join("/"); | ||
| paths.add(`/${partialPath}`); | ||
| }); | ||
| }); | ||
| for (let path of paths) { | ||
| let matches = matchServerRoutes(build.routes, dataRoutes, branches, path, build.basename); | ||
@@ -201,3 +195,3 @@ if (matches) for (let match of matches) { | ||
| if (isMutationMethod(request.method)) try { | ||
| throwIfPotentialCSRFAttack(request.headers, Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []); | ||
| throwIfPotentialCSRFAttack(request, Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []); | ||
| } catch (e) { | ||
@@ -219,3 +213,3 @@ handleError(e); | ||
| }, | ||
| normalizePath: (r) => getNormalizedPath(r, build.basename) | ||
| normalizePath: (r) => getNormalizedPath(r) | ||
| }); | ||
@@ -243,3 +237,3 @@ if (!isResponse(result)) result = await renderHtml(result, isSpaMode); | ||
| actionData: context.actionData, | ||
| errors: serializeErrors(context.errors, serverMode) | ||
| errors: context.errors | ||
| }; | ||
@@ -286,3 +280,3 @@ let baseServerHandoff = { | ||
| actionData: context.actionData, | ||
| errors: serializeErrors(context.errors, serverMode) | ||
| errors: context.errors | ||
| }; | ||
@@ -317,3 +311,3 @@ entryContext = { | ||
| }, | ||
| normalizePath: (r) => getNormalizedPath(r, build.basename) | ||
| normalizePath: (r) => getNormalizedPath(r) | ||
| })); | ||
@@ -320,0 +314,0 @@ } catch (error) { |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -25,3 +25,3 @@ * Copyright (c) Remix Software Inc. | ||
| try { | ||
| throwIfPotentialCSRFAttack(request.headers, Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []); | ||
| throwIfPotentialCSRFAttack(request, Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []); | ||
| } catch (e) { | ||
@@ -41,3 +41,3 @@ return handleQueryError(/* @__PURE__ */ new Error("Bad Request"), 400); | ||
| }, | ||
| normalizePath: (r) => getNormalizedPath(r, build.basename) | ||
| normalizePath: (r) => getNormalizedPath(r) | ||
| })); | ||
@@ -95,3 +95,3 @@ } catch (error) { | ||
| }, | ||
| normalizePath: (r) => getNormalizedPath(r, build.basename) | ||
| normalizePath: (r) => getNormalizedPath(r) | ||
| })); | ||
@@ -98,0 +98,0 @@ } catch (error) { |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,6 +11,4 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { stripBasename } from "../router/utils.js"; | ||
| //#region lib/server-runtime/urls.ts | ||
| function getNormalizedPath(request, basename) { | ||
| basename = basename || "/"; | ||
| function getNormalizedPath(request) { | ||
| let url = new URL(request.url); | ||
@@ -20,3 +18,2 @@ let pathname = url.pathname; | ||
| else pathname = pathname.replace(/\.data$/, ""); | ||
| if (stripBasename(pathname, basename) !== "/" && pathname.endsWith("/")) pathname = pathname.slice(0, -1); | ||
| let searchParams = new URLSearchParams(url.search); | ||
@@ -23,0 +20,0 @@ searchParams.delete("_routes"); |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,2 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import "../../lib/router/utils.js"; | ||
| import { Deferred, createLineSplittingTransform } from "./utils.js"; | ||
@@ -13,0 +14,0 @@ import { flatten } from "./flatten.js"; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,3 +11,4 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { Deferred, SUPPORTED_ERROR_TYPES } from "./utils.js"; | ||
| import { SUPPORTED_ERROR_TYPES } from "../../lib/router/utils.js"; | ||
| import { Deferred } from "./utils.js"; | ||
| //#region vendor/turbo-stream-v2/unflatten.ts | ||
@@ -14,0 +15,0 @@ const globalObj = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : void 0; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -12,10 +12,2 @@ * Copyright (c) Remix Software Inc. | ||
| //#region vendor/turbo-stream-v2/utils.ts | ||
| const SUPPORTED_ERROR_TYPES = [ | ||
| "EvalError", | ||
| "RangeError", | ||
| "ReferenceError", | ||
| "SyntaxError", | ||
| "TypeError", | ||
| "URIError" | ||
| ]; | ||
| var Deferred = class { | ||
@@ -48,2 +40,2 @@ promise; | ||
| //#endregion | ||
| export { Deferred, SUPPORTED_ERROR_TYPES, createLineSplittingTransform }; | ||
| export { Deferred, createLineSplittingTransform }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -29,3 +29,2 @@ | ||
| import { RSCDefaultRootErrorBoundary } from "./lib/rsc/errorBoundaries.js"; | ||
| import { deserializeErrors } from "./lib/dom/ssr/errors.js"; | ||
| import { RemixErrorBoundary } from "./lib/dom/ssr/errorBoundaries.js"; | ||
@@ -47,2 +46,2 @@ import { getPatchRoutesOnNavigationFunction, useFogOFWarDiscovery } from "./lib/dom/ssr/fog-of-war.js"; | ||
| //#endregion | ||
| export { type ActionFunction, type ActionFunctionArgs, type AppLoadContext, 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 InstrumentationHandlerResult, 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, deserializeErrors as UNSAFE_deserializeErrors, 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 }; | ||
| export { type ActionFunction, type ActionFunctionArgs, type AppLoadContext, 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 InstrumentationHandlerResult, 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 }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -38,3 +38,2 @@ * Copyright (c) Remix Software Inc. | ||
| import { RSCStaticRouter, routeRSCServerRequest } from "./lib/rsc/server.ssr.js"; | ||
| import { deserializeErrors } from "./lib/dom/ssr/errors.js"; | ||
| import { getHydrationData } from "./lib/dom/ssr/hydration.js"; | ||
@@ -47,2 +46,2 @@ //#region index.ts | ||
| //#endregion | ||
| 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, deserializeErrors as UNSAFE_deserializeErrors, 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 }; | ||
| 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 }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -12,4 +12,4 @@ * Copyright (c) Remix Software Inc. | ||
| //#region lib/actions.ts | ||
| function throwIfPotentialCSRFAttack(headers, allowedActionOrigins) { | ||
| let originHeader = headers.get("origin"); | ||
| function throwIfPotentialCSRFAttack(request, allowedActionOrigins) { | ||
| let originHeader = request.headers.get("origin"); | ||
| let originDomain = null; | ||
@@ -21,6 +21,5 @@ try { | ||
| } | ||
| let host = parseHostHeader(headers); | ||
| if (originDomain && (!host || originDomain !== host.value)) { | ||
| if (!isAllowedOrigin(originDomain, allowedActionOrigins)) if (host) throw new Error(`${host.type} header does not match \`origin\` header from a forwarded action request. Aborting the action.`); | ||
| else throw new Error("`x-forwarded-host` or `host` headers are not provided. One of these is needed to compare the `origin` header from a forwarded action request. Aborting the action."); | ||
| let host = new URL(request.url).host; | ||
| if (originDomain && originDomain !== host) { | ||
| if (!isAllowedOrigin(originDomain, allowedActionOrigins)) throw new Error("The `request.url` host does not match `origin` header from a forwarded action request. Aborting the action."); | ||
| } | ||
@@ -52,14 +51,3 @@ } | ||
| } | ||
| function parseHostHeader(headers) { | ||
| let forwardedHostValue = headers.get("x-forwarded-host")?.split(",")[0]?.trim(); | ||
| let hostHeader = headers.get("host"); | ||
| return forwardedHostValue ? { | ||
| type: "x-forwarded-host", | ||
| value: forwardedHostValue | ||
| } : hostHeader ? { | ||
| type: "host", | ||
| value: hostHeader | ||
| } : void 0; | ||
| } | ||
| //#endregion | ||
| export { throwIfPotentialCSRFAttack }; |
@@ -132,2 +132,6 @@ | ||
| * | ||
| * Data Routers should not be held in React state. You should create your router | ||
| * once outside of the React tree and pass it to {@link RouterProvider | `<RouterProvider>`}. | ||
| * You can use `patchRoutesOnNavigation` to add additional routes programmatically. | ||
| * | ||
| * @public | ||
@@ -167,3 +171,5 @@ * @category Data Routers | ||
| /** | ||
| * The {@link DataRouter} instance to use for navigation and data fetching. | ||
| * The {@link DataRouter} instance to use for navigation and data fetching. The | ||
| * router prop should be a single router instance created outside of the React | ||
| * tree. Avoid creating new routers during React renders/re-renders. | ||
| */ | ||
@@ -192,3 +198,3 @@ router: Router$1; | ||
| * ```tsx | ||
| * <RouterProvider onError=(error, info) => { | ||
| * <RouterProvider onError={(error, info) => { | ||
| * let { location, params, pattern, errorInfo } = info; | ||
@@ -223,3 +229,5 @@ * console.error(error, location, errorInfo); | ||
| * Render the UI for the given {@link DataRouter}. This component should | ||
| * typically be at the top of an app's element tree. | ||
| * typically be at the top of an app's element tree. The router prop should | ||
| * be a single router instance created outside of the React tree. Avoid | ||
| * creating new routers during React renders/re-renders. | ||
| * | ||
@@ -226,0 +234,0 @@ * ```tsx |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -26,2 +26,6 @@ * Copyright (c) Remix Software Inc. | ||
| * | ||
| * Data Routers should not be held in React state. You should create your router | ||
| * once outside of the React tree and pass it to {@link RouterProvider | `<RouterProvider>`}. | ||
| * You can use `patchRoutesOnNavigation` to add additional routes programmatically. | ||
| * | ||
| * @public | ||
@@ -85,3 +89,5 @@ * @category Data Routers | ||
| * Render the UI for the given {@link DataRouter}. This component should | ||
| * typically be at the top of an app's element tree. | ||
| * typically be at the top of an app's element tree. The router prop should | ||
| * be a single router instance created outside of the React tree. Avoid | ||
| * creating new routers during React renders/re-renders. | ||
| * | ||
@@ -88,0 +94,0 @@ * ```tsx |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -83,3 +83,3 @@ | ||
| * ```tsx | ||
| * <HydratedRouter onError=(error, info) => { | ||
| * <HydratedRouter onError={(error, info) => { | ||
| * let { location, params, pattern, errorInfo } = info; | ||
@@ -86,0 +86,0 @@ * console.error(error, location, errorInfo); |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -14,3 +14,3 @@ * Copyright (c) Remix Software Inc. | ||
| import * as React$1 from "react"; | ||
| import { UNSAFE_FrameworkContext, UNSAFE_RemixErrorBoundary, UNSAFE_createBrowserHistory, UNSAFE_createClientRoutes, UNSAFE_createClientRoutesWithHMRRevalidationOptOut, UNSAFE_createRouter, UNSAFE_decodeViaTurboStream, UNSAFE_defaultMapRouteProperties, UNSAFE_deserializeErrors, UNSAFE_getHydrationData, UNSAFE_getPatchRoutesOnNavigationFunction, UNSAFE_getTurboStreamSingleFetchDataStrategy, UNSAFE_hydrationRouteProperties, UNSAFE_invariant, UNSAFE_useFogOFWarDiscovery } from "react-router"; | ||
| import { UNSAFE_FrameworkContext, UNSAFE_RemixErrorBoundary, UNSAFE_createBrowserHistory, UNSAFE_createClientRoutes, UNSAFE_createClientRoutesWithHMRRevalidationOptOut, UNSAFE_createRouter, UNSAFE_decodeViaTurboStream, UNSAFE_defaultMapRouteProperties, UNSAFE_getHydrationData, UNSAFE_getPatchRoutesOnNavigationFunction, UNSAFE_getTurboStreamSingleFetchDataStrategy, UNSAFE_hydrationRouteProperties, UNSAFE_invariant, UNSAFE_useFogOFWarDiscovery } from "react-router"; | ||
| //#region lib/dom-export/hydrated-router.tsx | ||
@@ -61,17 +61,14 @@ let ssrInfo = null; | ||
| if (ssrInfo.manifest.routes.root?.hasLoader && loaderData && "root" in loaderData) hydrationData = { loaderData: { root: loaderData.root } }; | ||
| } else { | ||
| hydrationData = UNSAFE_getHydrationData({ | ||
| state: ssrInfo.context.state, | ||
| routes, | ||
| getRouteInfo: (routeId) => ({ | ||
| clientLoader: ssrInfo.routeModules[routeId]?.clientLoader, | ||
| hasLoader: ssrInfo.manifest.routes[routeId]?.hasLoader === true, | ||
| hasHydrateFallback: ssrInfo.routeModules[routeId]?.HydrateFallback != null | ||
| }), | ||
| location: window.location, | ||
| basename: window.__reactRouterContext?.basename, | ||
| isSpaMode: ssrInfo.context.isSpaMode | ||
| }); | ||
| if (hydrationData && hydrationData.errors) hydrationData.errors = UNSAFE_deserializeErrors(hydrationData.errors); | ||
| } | ||
| } else hydrationData = UNSAFE_getHydrationData({ | ||
| state: ssrInfo.context.state, | ||
| routes, | ||
| getRouteInfo: (routeId) => ({ | ||
| clientLoader: ssrInfo.routeModules[routeId]?.clientLoader, | ||
| hasLoader: ssrInfo.manifest.routes[routeId]?.hasLoader === true, | ||
| hasHydrateFallback: ssrInfo.routeModules[routeId]?.HydrateFallback != null | ||
| }), | ||
| location: window.location, | ||
| basename: window.__reactRouterContext?.basename, | ||
| isSpaMode: ssrInfo.context.isSpaMode | ||
| }); | ||
| if (window.history.state && window.history.state.masked) window.history.replaceState({ | ||
@@ -78,0 +75,0 @@ ...window.history.state, |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,4 +11,5 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { ABSOLUTE_URL_REGEX } from "../router/url.js"; | ||
| import { createBrowserHistory, createHashHistory, createPath, invariant, warning } from "../router/history.js"; | ||
| import { ErrorResponseImpl, defaultMapRouteProperties, joinPaths, matchPath, parseToInfo, resolveTo, stripBasename } from "../router/utils.js"; | ||
| import { ErrorResponseImpl, SUPPORTED_ERROR_TYPES, defaultMapRouteProperties, joinPaths, matchPath, parseToInfo, resolveTo, stripBasename } from "../router/utils.js"; | ||
| import { IDLE_FETCHER, createRouter } from "../router/router.js"; | ||
@@ -25,3 +26,3 @@ import { DataRouterContext, DataRouterStateContext, FetchersContext, NavigationContext, RouteContext, ViewTransitionContext } from "../context.js"; | ||
| try { | ||
| if (isBrowser) window.__reactRouterVersion = "8.0.0-pre.0"; | ||
| if (isBrowser) window.__reactRouterVersion = "8.0.0-pre.1"; | ||
| } catch (e) {} | ||
@@ -33,2 +34,6 @@ /** | ||
| * | ||
| * Data Routers should not be held in React state. You should create your router | ||
| * once outside of the React tree and pass it to {@link RouterProvider | `<RouterProvider>`}. | ||
| * You can use `patchRoutesOnNavigation` to add additional routes programmatically. | ||
| * | ||
| * @public | ||
@@ -69,2 +74,6 @@ * @category Data Routers | ||
| * | ||
| * Data Routers should not be held in React state. You should create your router | ||
| * once outside of the React tree and pass it to {@link RouterProvider | `<RouterProvider>`}. | ||
| * You can use `patchRoutesOnNavigation` to add additional routes programmatically. | ||
| * | ||
| * @public | ||
@@ -115,3 +124,3 @@ * @category Data Routers | ||
| else if (val && val.__type === "Error") { | ||
| if (val.__subType) { | ||
| if (typeof val.__subType === "string" && SUPPORTED_ERROR_TYPES.includes(val.__subType)) { | ||
| let ErrorConstructor = window[val.__subType]; | ||
@@ -252,3 +261,2 @@ if (typeof ErrorConstructor === "function") try { | ||
| HistoryRouter.displayName = "unstable_HistoryRouter"; | ||
| const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i; | ||
| /** | ||
@@ -518,3 +526,6 @@ * A progressively enhanced [`<a href>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) | ||
| * | ||
| * This component renders an inline `<script>` to prevent scroll flashing. The `nonce` prop will be passed down to the script tag to allow CSP nonce usage. | ||
| * This component renders an inline `<script>` to prevent scroll flashing. The | ||
| * `nonce` prop will be passed down to the script tag to allow CSP nonce usage. | ||
| * If not provided in Framework Mode, it will default to any | ||
| * {@link ServerRouter | `<ServerRouter nonce>`} prop. | ||
| * | ||
@@ -564,2 +575,3 @@ * ```tsx | ||
| }).toString(); | ||
| if (props.nonce == null && remixContext?.nonce) props.nonce = remixContext.nonce; | ||
| return /* @__PURE__ */ React$1.createElement("script", { | ||
@@ -566,0 +578,0 @@ ...props, |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,2 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { ABSOLUTE_URL_REGEX } from "../router/url.js"; | ||
| import { createPath, invariant, parsePath } from "../router/history.js"; | ||
@@ -300,4 +301,3 @@ import { convertRoutesToDataRoutes, isRouteErrorResponse } from "../router/utils.js"; | ||
| } | ||
| const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i; | ||
| //#endregion | ||
| export { StaticRouter, StaticRouterProvider, createStaticRouter }; |
@@ -34,3 +34,4 @@ | ||
| * attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) | ||
| * element | ||
| * element. If not provided in Framework Mode, it will default to any | ||
| * {@link ServerRouter | `<ServerRouter nonce>`} prop. | ||
| */ | ||
@@ -158,3 +159,4 @@ nonce?: string | undefined; | ||
| * attribute to render on the [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) | ||
| * element | ||
| * element. If not provided in Framework Mode, it will default to any | ||
| * {@link ServerRouter | `<ServerRouter nonce>`} prop. | ||
| */ | ||
@@ -161,0 +163,0 @@ nonce?: string | undefined; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -144,3 +144,3 @@ * Copyright (c) Remix Software Inc. | ||
| function Links({ nonce, crossOrigin }) { | ||
| let { isSpaMode, manifest, routeModules, criticalCss } = useFrameworkContext(); | ||
| let { isSpaMode, manifest, routeModules, criticalCss, nonce: contextNonce } = useFrameworkContext(); | ||
| let { errors, matches: routerMatches } = useDataRouterStateContext(); | ||
@@ -153,2 +153,3 @@ let matches = getActiveMatches(routerMatches, errors, isSpaMode); | ||
| ]); | ||
| if (nonce == null && contextNonce) nonce = contextNonce; | ||
| return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, typeof criticalCss === "string" ? /* @__PURE__ */ React$1.createElement("style", { | ||
@@ -205,2 +206,3 @@ [CRITICAL_CSS_DATA_ATTRIBUTE]: "", | ||
| let rsc = useIsRSCRouterContext(); | ||
| let { nonce: contextNonce } = useFrameworkContext(); | ||
| let { router } = useDataRouterContext(); | ||
@@ -213,2 +215,6 @@ let matches = React$1.useMemo(() => matchRoutes(router.routes, page, router.basename), [ | ||
| if (!matches) return null; | ||
| if (linkProps.nonce == null && contextNonce) linkProps = { | ||
| ...linkProps, | ||
| nonce: contextNonce | ||
| }; | ||
| if (rsc) return /* @__PURE__ */ React$1.createElement(RSCPrefetchPageLinksImpl, { | ||
@@ -480,3 +486,3 @@ page, | ||
| function Scripts(scriptProps) { | ||
| let { manifest, serverHandoffString, isSpaMode, renderMeta, routeDiscovery, ssr } = useFrameworkContext(); | ||
| let { manifest, serverHandoffString, isSpaMode, renderMeta, routeDiscovery, ssr, nonce: contextNonce } = useFrameworkContext(); | ||
| let { router, static: isStatic, staticContext } = useDataRouterContext(); | ||
@@ -486,2 +492,6 @@ let { matches: routerMatches } = useDataRouterStateContext(); | ||
| let enableFogOfWar = isFogOfWarEnabled(routeDiscovery, ssr); | ||
| if (scriptProps.nonce == null && contextNonce) scriptProps = { | ||
| ...scriptProps, | ||
| nonce: contextNonce | ||
| }; | ||
| if (renderMeta) renderMeta.didRenderScripts = true; | ||
@@ -488,0 +498,0 @@ let matches = getActiveMatches(routerMatches, null, isSpaMode); |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -22,2 +22,3 @@ | ||
| routeDiscovery: ServerBuild["routeDiscovery"]; | ||
| nonce?: string; | ||
| serializeError?(error: Error): SerializedError; | ||
@@ -24,0 +25,0 @@ renderMeta?: { |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -48,8 +48,12 @@ * Copyright (c) Remix Software Inc. | ||
| function RemixRootDefaultErrorBoundary({ error, isOutsideRemixApp }) { | ||
| let { nonce } = useFrameworkContext(); | ||
| console.error(error); | ||
| let heyDeveloper = /* @__PURE__ */ React$1.createElement("script", { dangerouslySetInnerHTML: { __html: ` | ||
| let heyDeveloper = /* @__PURE__ */ React$1.createElement("script", { | ||
| nonce, | ||
| dangerouslySetInnerHTML: { __html: ` | ||
| console.log( | ||
| "💿 Hey developer 👋. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information." | ||
| ); | ||
| ` } }); | ||
| ` } | ||
| }); | ||
| if (isRouteErrorResponse(error)) return /* @__PURE__ */ React$1.createElement(BoundaryShell, { title: "Unhandled Thrown Response!" }, /* @__PURE__ */ React$1.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText), null); | ||
@@ -56,0 +60,0 @@ let errorInstance; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -12,5 +12,7 @@ * Copyright (c) Remix Software Inc. | ||
| import { BoundaryShell } from "./errorBoundaries.js"; | ||
| import { useFrameworkContext } from "./components.js"; | ||
| import * as React$1 from "react"; | ||
| //#region lib/dom/ssr/fallback.tsx | ||
| function RemixRootDefaultHydrateFallback() { | ||
| let { nonce } = useFrameworkContext(); | ||
| return /* @__PURE__ */ React$1.createElement(BoundaryShell, { | ||
@@ -17,0 +19,0 @@ title: "Loading...", |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -20,2 +20,11 @@ * Copyright (c) Remix Software Inc. | ||
| const URL_LIMIT = 7680; | ||
| function getPathsWithAncestors(paths) { | ||
| let result = /* @__PURE__ */ new Set(); | ||
| paths.forEach((path) => { | ||
| if (!path.startsWith("/")) path = `/${path}`; | ||
| for (let i = 1; i < path.length; i++) if (path[i] === "/") result.add(path.slice(0, i)); | ||
| result.add(path); | ||
| }); | ||
| return Array.from(result); | ||
| } | ||
| function isFogOfWarEnabled(routeDiscovery, ssr) { | ||
@@ -106,2 +115,3 @@ return routeDiscovery.mode === "lazy" && ssr === true; | ||
| async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal) { | ||
| paths = getPathsWithAncestors(paths); | ||
| const searchParams = new URLSearchParams(); | ||
@@ -172,2 +182,2 @@ searchParams.set("paths", paths.sort().join(",")); | ||
| //#endregion | ||
| export { URL_LIMIT, getManifestPath, getPartialManifest, getPatchRoutesOnNavigationFunction, isFogOfWarEnabled, useFogOFWarDiscovery }; | ||
| export { URL_LIMIT, getManifestPath, getPartialManifest, getPatchRoutesOnNavigationFunction, getPathsWithAncestors, isFogOfWarEnabled, useFogOFWarDiscovery }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -21,3 +21,6 @@ | ||
| * An optional `nonce` for [Content Security Policy (CSP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP) | ||
| * compliance, used to allow inline scripts to run safely. | ||
| * compliance. This is applied to inline scripts rendered by React Router and | ||
| * used as the default for nonce-aware components such as {@link Links | `<Links>`}, | ||
| * {@link Scripts | `<Scripts>`}, and {@link ScrollRestoration | `<ScrollRestoration>`} | ||
| * when they do not provide their own `nonce`. | ||
| */ | ||
@@ -24,0 +27,0 @@ nonce?: string; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -53,2 +53,3 @@ * Copyright (c) Remix Software Inc. | ||
| routeDiscovery: context.routeDiscovery, | ||
| nonce, | ||
| serializeError: context.serializeError, | ||
@@ -55,0 +56,0 @@ renderMeta: context.renderMeta |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,7 +11,6 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { ErrorResponseImpl, data, isRouteErrorResponse, redirect } from "../../router/utils.js"; | ||
| import { ErrorResponseImpl, SUPPORTED_ERROR_TYPES, data, isRouteErrorResponse, redirect } from "../../router/utils.js"; | ||
| import { isDataWithResponseInit, isResponse } from "../../router/router.js"; | ||
| import invariant from "./invariant.js"; | ||
| import { escapeHtml } from "./markup.js"; | ||
| import { SUPPORTED_ERROR_TYPES } from "../../../vendor/turbo-stream-v2/utils.js"; | ||
| import { decode } from "../../../vendor/turbo-stream-v2/turbo-stream.js"; | ||
@@ -18,0 +17,0 @@ import { createRequestInit } from "./data.js"; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -13,3 +13,3 @@ * Copyright (c) Remix Software Inc. | ||
| import { convertRouteMatchToUiMatch, decodePath, getResolveToMatches, getRoutePattern, isBrowser, isRouteErrorResponse, joinPaths, matchPath, matchRoutes, parseToInfo, resolveTo, stripBasename } from "./router/utils.js"; | ||
| import { IDLE_BLOCKER } from "./router/router.js"; | ||
| import { IDLE_BLOCKER, hasInvalidProtocol } from "./router/router.js"; | ||
| import { AwaitContext, DataRouterContext, DataRouterStateContext, LocationContext, NavigationContext, RSCRouterContext, RouteContext, RouteErrorContext } from "./context.js"; | ||
@@ -679,3 +679,5 @@ import { decodeRedirectErrorDigest, decodeRouteErrorResponseDigest } from "./errors.js"; | ||
| let parsed = parseToInfo(redirect.location, basename); | ||
| if (isBrowser && !errorRedirectHandledMap.get(error)) if (parsed.isExternal || redirect.reloadDocument) window.location.href = parsed.absoluteURL || parsed.to; | ||
| let target = parsed.absoluteURL || parsed.to; | ||
| if (hasInvalidProtocol(target)) throw new Error("Invalid redirect location"); | ||
| if (isBrowser && !errorRedirectHandledMap.get(error)) if (parsed.isExternal || redirect.reloadDocument) window.location.href = target; | ||
| else { | ||
@@ -688,3 +690,3 @@ const redirectPromise = Promise.resolve().then(() => window.__reactRouterDataRouter.navigate(parsed.to, { replace: redirect.replace })); | ||
| httpEquiv: "refresh", | ||
| content: `0;url=${parsed.absoluteURL || parsed.to}` | ||
| content: `0;url=${target}` | ||
| }); | ||
@@ -691,0 +693,0 @@ } |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,2 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { PROTOCOL_RELATIVE_URL_REGEX } from "./url.js"; | ||
| //#region lib/router/history.ts | ||
@@ -368,3 +369,3 @@ /** | ||
| href = href.replace(/ $/, "%20"); | ||
| if (!isAbsolute && href.startsWith("//")) href = base + href; | ||
| if (!isAbsolute && PROTOCOL_RELATIVE_URL_REGEX.test(href)) href = base + href; | ||
| return new URL(href, base); | ||
@@ -371,0 +372,0 @@ } |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -103,4 +103,5 @@ | ||
| * attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link) | ||
| * element | ||
| */ | ||
| * element. If not provided in Framework Mode, it will default to any | ||
| * {@link ServerRouter | `<ServerRouter nonce>`} prop. | ||
| */ | ||
| nonce?: string | undefined; | ||
@@ -107,0 +108,0 @@ /** |
@@ -671,2 +671,4 @@ | ||
| route: RouteObjectType; | ||
| matcher?: RegExp; | ||
| compiledParams?: CompiledPathParam[]; | ||
| } | ||
@@ -756,2 +758,6 @@ /** | ||
| declare function matchPath<Path extends string>(pattern: PathPattern<Path> | Path, pathname: string): PathMatch<ParamParseKey<Path>> | null; | ||
| type CompiledPathParam = { | ||
| paramName: string; | ||
| isOptional?: boolean; | ||
| }; | ||
| /** | ||
@@ -758,0 +764,0 @@ * Returns a resolved {@link Path} object relative to the given pathname. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,2 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { ABSOLUTE_URL_REGEX, PROTOCOL_RELATIVE_URL_REGEX, normalizeProtocolRelativeUrl } from "./url.js"; | ||
| import { invariant, parsePath, warning } from "./history.js"; | ||
@@ -284,3 +285,10 @@ import * as React$1 from "react"; | ||
| score: computeScore(path, route.index), | ||
| routesMeta | ||
| routesMeta: routesMeta.map((meta, i) => { | ||
| let [matcher, params] = compilePath(meta.relativePath, meta.caseSensitive, i === routesMeta.length - 1); | ||
| return { | ||
| ...meta, | ||
| matcher, | ||
| compiledParams: params | ||
| }; | ||
| }) | ||
| }); | ||
@@ -336,7 +344,8 @@ }; | ||
| let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/"; | ||
| let match = matchPath({ | ||
| let pattern = { | ||
| path: meta.relativePath, | ||
| caseSensitive: meta.caseSensitive, | ||
| end | ||
| }, remainingPathname); | ||
| }; | ||
| let match = meta.matcher && meta.compiledParams ? matchPathImpl(pattern, remainingPathname, meta.matcher, meta.compiledParams) : matchPath(pattern, remainingPathname); | ||
| let route = meta.route; | ||
@@ -415,2 +424,5 @@ if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) match = matchPath({ | ||
| let [matcher, compiledParams] = compilePath(pattern.path, pattern.caseSensitive, pattern.end); | ||
| return matchPathImpl(pattern, pathname, matcher, compiledParams); | ||
| } | ||
| function matchPathImpl(pattern, pathname, matcher, compiledParams) { | ||
| let match = pathname.match(matcher); | ||
@@ -478,3 +490,2 @@ if (!match) return null; | ||
| } | ||
| const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i; | ||
| const isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX.test(url); | ||
@@ -555,3 +566,3 @@ /** | ||
| } | ||
| const removeDoubleSlashes = (path) => path.replace(/\/\/+/g, "/"); | ||
| const removeDoubleSlashes = (path) => path.replace(/[\\/]{2,}/g, "/"); | ||
| const joinPaths = (paths) => removeDoubleSlashes(paths.join("/")); | ||
@@ -709,2 +720,10 @@ const removeTrailingSlash = (path) => path.replace(/\/+$/, ""); | ||
| }; | ||
| const SUPPORTED_ERROR_TYPES = [ | ||
| "EvalError", | ||
| "RangeError", | ||
| "ReferenceError", | ||
| "SyntaxError", | ||
| "TypeError", | ||
| "URIError" | ||
| ]; | ||
| var ErrorResponseImpl = class { | ||
@@ -775,3 +794,3 @@ status; | ||
| let currentUrl = new URL(window.location.href); | ||
| let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to); | ||
| let targetUrl = PROTOCOL_RELATIVE_URL_REGEX.test(to) ? new URL(normalizeProtocolRelativeUrl(to, currentUrl.protocol)) : new URL(to); | ||
| let path = stripBasename(targetUrl.pathname, basename); | ||
@@ -790,2 +809,2 @@ if (targetUrl.origin === currentUrl.origin && path != null) to = path + targetUrl.search + targetUrl.hash; | ||
| //#endregion | ||
| export { ErrorResponseImpl, RouterContextProvider, compilePath, convertRouteMatchToUiMatch, convertRoutesToDataRoutes, createContext, data, decodePath, defaultMapRouteProperties, flattenAndRankRoutes, generatePath, getPathContributingMatches, getResolveToMatches, getRoutePattern, isAbsoluteUrl, isBrowser, isRouteErrorResponse, isUnsupportedLazyRouteFunctionKey, isUnsupportedLazyRouteObjectKey, joinPaths, matchPath, matchRoutes, matchRoutesImpl, parseToInfo, prependBasename, redirect, redirectDocument, removeDoubleSlashes, replace, resolvePath, resolveTo, stripBasename }; | ||
| export { ErrorResponseImpl, RouterContextProvider, SUPPORTED_ERROR_TYPES, compilePath, convertRouteMatchToUiMatch, convertRoutesToDataRoutes, createContext, data, decodePath, defaultMapRouteProperties, flattenAndRankRoutes, generatePath, getPathContributingMatches, getResolveToMatches, getRoutePattern, isAbsoluteUrl, isBrowser, isRouteErrorResponse, isUnsupportedLazyRouteFunctionKey, isUnsupportedLazyRouteObjectKey, joinPaths, matchPath, matchRoutes, matchRoutesImpl, parseToInfo, prependBasename, redirect, redirectDocument, removeDoubleSlashes, removeTrailingSlash, replace, resolvePath, resolveTo, stripBasename }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,5 +11,6 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { PROTOCOL_RELATIVE_URL_REGEX } from "../router/url.js"; | ||
| import { createBrowserHistory, invariant } from "../router/history.js"; | ||
| import { ErrorResponseImpl, createContext } from "../router/utils.js"; | ||
| import { createRouter, invalidProtocols, isMutationMethod } from "../router/router.js"; | ||
| import { ErrorResponseImpl, createContext, resolvePath } from "../router/utils.js"; | ||
| import { createRouter, hasInvalidProtocol, isMutationMethod } from "../router/router.js"; | ||
| import { RSCRouterContext } from "../context.js"; | ||
@@ -20,3 +21,3 @@ import { RouterProvider } from "../components.js"; | ||
| import { noActionDefinedError, shouldHydrateRouteLoader } from "../dom/ssr/routes.js"; | ||
| import "../dom/ssr/fog-of-war.js"; | ||
| import { getPathsWithAncestors } from "../dom/ssr/fog-of-war.js"; | ||
| import { FrameworkContext, setIsHydrated } from "../dom/ssr/components.js"; | ||
@@ -85,9 +86,10 @@ import { RSCRouterGlobalErrorBoundary } from "./errorBoundaries.js"; | ||
| if (payload.type === "redirect") { | ||
| if (payload.reload || isExternalLocation(payload.location)) { | ||
| if (hasInvalidProtocol(payload.location)) throw new Error("Invalid redirect location"); | ||
| window.location.href = payload.location; | ||
| let location = normalizeRedirectLocation(payload.location); | ||
| if (payload.reload || isExternalLocation(location)) { | ||
| if (hasInvalidProtocol(location)) throw new Error("Invalid redirect location"); | ||
| window.location.href = location; | ||
| return; | ||
| } | ||
| React$1.startTransition(() => { | ||
| globalVar.__reactRouterDataRouter.navigate(payload.location, { replace: payload.replace }); | ||
| globalVar.__reactRouterDataRouter.navigate(location, { replace: payload.replace }); | ||
| }); | ||
@@ -100,9 +102,10 @@ return; | ||
| if (rerender.type === "redirect") { | ||
| if (rerender.reload || isExternalLocation(rerender.location)) { | ||
| if (hasInvalidProtocol(rerender.location)) throw new Error("Invalid redirect location"); | ||
| window.location.href = rerender.location; | ||
| let location = normalizeRedirectLocation(rerender.location); | ||
| if (rerender.reload || isExternalLocation(location)) { | ||
| if (hasInvalidProtocol(location)) throw new Error("Invalid redirect location"); | ||
| window.location.href = location; | ||
| return; | ||
| } | ||
| React$1.startTransition(() => { | ||
| globalVar.__reactRouterDataRouter.navigate(rerender.location, { replace: rerender.replace }); | ||
| globalVar.__reactRouterDataRouter.navigate(location, { replace: rerender.replace }); | ||
| }); | ||
@@ -540,2 +543,3 @@ return; | ||
| async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fetchImplementation, signal) { | ||
| paths = getPathsWithAncestors(paths); | ||
| let url = getManifestUrl(paths); | ||
@@ -576,8 +580,8 @@ if (url == null) return; | ||
| } | ||
| function hasInvalidProtocol(location) { | ||
| try { | ||
| return invalidProtocols.includes(new URL(location).protocol); | ||
| } catch { | ||
| return false; | ||
| function normalizeRedirectLocation(location) { | ||
| if (PROTOCOL_RELATIVE_URL_REGEX.test(location)) { | ||
| let path = resolvePath(location); | ||
| return path.pathname + path.search + path.hash; | ||
| } | ||
| return location; | ||
| } | ||
@@ -584,0 +588,0 @@ function cloneRoutes(routes) { |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -12,2 +12,3 @@ * Copyright (c) Remix Software Inc. | ||
| import { isRouteErrorResponse } from "../router/utils.js"; | ||
| import { hasInvalidProtocol } from "../router/router.js"; | ||
| import { RSCRouterContext } from "../context.js"; | ||
@@ -126,2 +127,3 @@ import { decodeRedirectErrorDigest, decodeRouteErrorResponseDigest } from "../errors.js"; | ||
| if (serverResponse.status === 202 && payload.type === "redirect") { | ||
| if (hasInvalidProtocol(payload.location)) throw new Error("Invalid redirect location"); | ||
| const headers = new Headers(serverResponse.headers); | ||
@@ -164,2 +166,3 @@ headers.delete("Content-Encoding"); | ||
| if (renderRedirect) { | ||
| if (hasInvalidProtocol(renderRedirect.location)) throw new Error("Invalid redirect location"); | ||
| headers.set("Location", renderRedirect.location); | ||
@@ -172,3 +175,6 @@ return new Response(html, { | ||
| const redirectTransform = new TransformStream({ flush(controller) { | ||
| if (renderRedirect) controller.enqueue(new TextEncoder().encode(`<meta http-equiv="refresh" content="0;url=${escapeHtml(renderRedirect.location)}"/>`)); | ||
| if (renderRedirect) { | ||
| if (hasInvalidProtocol(renderRedirect.location)) return; | ||
| controller.enqueue(new TextEncoder().encode(`<meta http-equiv="refresh" content="0;url=${escapeHtml(renderRedirect.location)}"/>`)); | ||
| } | ||
| } }); | ||
@@ -189,6 +195,9 @@ if (!hydrate) return new Response(html.pipeThrough(redirectTransform), { | ||
| if (error instanceof Response) return error; | ||
| if (renderRedirect) return new Response(`Redirect: ${renderRedirect.location}`, { | ||
| status: renderRedirect.status, | ||
| headers: { Location: renderRedirect.location } | ||
| }); | ||
| if (renderRedirect) { | ||
| if (hasInvalidProtocol(renderRedirect.location)) throw new Error("Invalid redirect location"); | ||
| return new Response(`Redirect: ${renderRedirect.location}`, { | ||
| status: renderRedirect.status, | ||
| headers: { Location: renderRedirect.location } | ||
| }); | ||
| } | ||
| try { | ||
@@ -238,2 +247,3 @@ let normalizedError = renderError ?? error; | ||
| if (retryRedirect) { | ||
| if (hasInvalidProtocol(retryRedirect.location)) throw new Error("Invalid redirect location"); | ||
| headers.set("Location", retryRedirect.location); | ||
@@ -246,3 +256,6 @@ return new Response(html, { | ||
| const retryRedirectTransform = new TransformStream({ flush(controller) { | ||
| if (retryRedirect) controller.enqueue(new TextEncoder().encode(`<meta http-equiv="refresh" content="0;url=${escapeHtml(retryRedirect.location)}"/>`)); | ||
| if (retryRedirect) { | ||
| if (hasInvalidProtocol(retryRedirect.location)) return; | ||
| controller.enqueue(new TextEncoder().encode(`<meta http-equiv="refresh" content="0;url=${escapeHtml(retryRedirect.location)}"/>`)); | ||
| } | ||
| } }); | ||
@@ -305,6 +318,9 @@ if (!hydrate) return new Response(html.pipeThrough(retryRedirectTransform), { | ||
| const payload = React$1.use(decoded); | ||
| if (payload.type === "redirect") throw new Response(null, { | ||
| status: payload.status, | ||
| headers: { Location: payload.location } | ||
| }); | ||
| if (payload.type === "redirect") { | ||
| if (hasInvalidProtocol(payload.location)) throw new Error("Invalid redirect location"); | ||
| throw new Response(null, { | ||
| status: payload.status, | ||
| headers: { Location: payload.location } | ||
| }); | ||
| } | ||
| if (payload.type !== "render") return null; | ||
@@ -311,0 +327,0 @@ let patchedLoaderData = { ...payload.loaderData }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,3 +11,2 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { isRouteErrorResponse } from "../router/utils.js"; | ||
| import "./mode.js"; | ||
@@ -76,22 +75,3 @@ //#region lib/server-runtime/errors.ts | ||
| } | ||
| function serializeErrors(errors, serverMode) { | ||
| if (!errors) return null; | ||
| let entries = Object.entries(errors); | ||
| let serialized = {}; | ||
| for (let [key, val] of entries) if (isRouteErrorResponse(val)) serialized[key] = { | ||
| ...val, | ||
| __type: "RouteErrorResponse" | ||
| }; | ||
| else if (val instanceof Error) { | ||
| let sanitized = sanitizeError(val, serverMode); | ||
| serialized[key] = { | ||
| message: sanitized.message, | ||
| stack: sanitized.stack, | ||
| __type: "Error", | ||
| ...sanitized.name !== "Error" ? { __subType: sanitized.name } : {} | ||
| }; | ||
| } else serialized[key] = val; | ||
| return serialized; | ||
| } | ||
| //#endregion | ||
| export { sanitizeError, sanitizeErrors, serializeError, serializeErrors }; | ||
| export { sanitizeError, sanitizeErrors, serializeError }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,3 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { ErrorResponseImpl, RouterContextProvider, defaultMapRouteProperties, isRouteErrorResponse, stripBasename } from "../router/utils.js"; | ||
| import { ErrorResponseImpl, RouterContextProvider, defaultMapRouteProperties, isRouteErrorResponse, removeTrailingSlash, stripBasename } from "../router/utils.js"; | ||
| import { instrumentHandler } from "../router/instrumentation.js"; | ||
@@ -18,3 +18,3 @@ import { createStaticHandler, getStaticContextFromError, isMutationMethod, isRedirectResponse, isResponse } from "../router/router.js"; | ||
| import { isServerMode } from "./mode.js"; | ||
| import { sanitizeErrors, serializeError, serializeErrors } from "./errors.js"; | ||
| import { sanitizeErrors, serializeError } from "./errors.js"; | ||
| import { matchServerRoutes } from "./routeMatching.js"; | ||
@@ -59,3 +59,3 @@ import { getBuildTimeHeader, getDevServerHooks } from "./dev.js"; | ||
| let requestUrl = new URL(request.url); | ||
| let normalizedPathname = getNormalizedPath(request, build.basename).pathname; | ||
| let normalizedPathname = getNormalizedPath(request).pathname; | ||
| let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes"; | ||
@@ -80,3 +80,3 @@ if (!build.ssr) { | ||
| if (build.prerender.length === 0) isSpaMode = true; | ||
| else if (!build.prerender.includes(decodedPath) && !build.prerender.includes(decodedPath + "/")) if (requestUrl.pathname.endsWith(".data")) { | ||
| else if (!build.prerender.some((p) => removeTrailingSlash(p) === removeTrailingSlash(decodedPath))) if (requestUrl.pathname.endsWith(".data")) { | ||
| errorHandler(new ErrorResponseImpl(404, "Not Found", `Refusing to SSR the path \`${decodedPath}\` because \`ssr:false\` is set and the path is not included in the \`prerender\` config, so in production the path will be a 404.`), { | ||
@@ -162,2 +162,6 @@ context: loadContext, | ||
| async function handleManifestRequest(build, dataRoutes, branches, url) { | ||
| if (url.toString().length > 7680) return new Response(null, { | ||
| statusText: "Bad Request", | ||
| status: 400 | ||
| }); | ||
| if (build.assets.version !== url.searchParams.get("version")) return new Response(null, { | ||
@@ -167,18 +171,8 @@ status: 204, | ||
| }); | ||
| if (url.toString().length > 7680) return new Response(null, { | ||
| statusText: "Bad Request", | ||
| status: 400 | ||
| }); | ||
| let patches = {}; | ||
| if (url.searchParams.has("paths")) { | ||
| let paths = /* @__PURE__ */ new Set(); | ||
| (url.searchParams.get("paths") || "").split(",").filter(Boolean).forEach((path) => { | ||
| let pathParam = url.searchParams.get("paths") || ""; | ||
| let paths = new Set(pathParam.split(",").filter(Boolean)); | ||
| for (let path of paths) { | ||
| if (!path.startsWith("/")) path = `/${path}`; | ||
| let segments = path.split("/").slice(1); | ||
| segments.forEach((_, i) => { | ||
| let partialPath = segments.slice(0, i + 1).join("/"); | ||
| paths.add(`/${partialPath}`); | ||
| }); | ||
| }); | ||
| for (let path of paths) { | ||
| let matches = matchServerRoutes(build.routes, dataRoutes, branches, path, build.basename); | ||
@@ -201,3 +195,3 @@ if (matches) for (let match of matches) { | ||
| if (isMutationMethod(request.method)) try { | ||
| throwIfPotentialCSRFAttack(request.headers, Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []); | ||
| throwIfPotentialCSRFAttack(request, Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []); | ||
| } catch (e) { | ||
@@ -219,3 +213,3 @@ handleError(e); | ||
| }, | ||
| normalizePath: (r) => getNormalizedPath(r, build.basename) | ||
| normalizePath: (r) => getNormalizedPath(r) | ||
| }); | ||
@@ -243,3 +237,3 @@ if (!isResponse(result)) result = await renderHtml(result, isSpaMode); | ||
| actionData: context.actionData, | ||
| errors: serializeErrors(context.errors, serverMode) | ||
| errors: context.errors | ||
| }; | ||
@@ -286,3 +280,3 @@ let baseServerHandoff = { | ||
| actionData: context.actionData, | ||
| errors: serializeErrors(context.errors, serverMode) | ||
| errors: context.errors | ||
| }; | ||
@@ -317,3 +311,3 @@ entryContext = { | ||
| }, | ||
| normalizePath: (r) => getNormalizedPath(r, build.basename) | ||
| normalizePath: (r) => getNormalizedPath(r) | ||
| })); | ||
@@ -320,0 +314,0 @@ } catch (error) { |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -25,3 +25,3 @@ * Copyright (c) Remix Software Inc. | ||
| try { | ||
| throwIfPotentialCSRFAttack(request.headers, Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []); | ||
| throwIfPotentialCSRFAttack(request, Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []); | ||
| } catch (e) { | ||
@@ -41,3 +41,3 @@ return handleQueryError(/* @__PURE__ */ new Error("Bad Request"), 400); | ||
| }, | ||
| normalizePath: (r) => getNormalizedPath(r, build.basename) | ||
| normalizePath: (r) => getNormalizedPath(r) | ||
| })); | ||
@@ -95,3 +95,3 @@ } catch (error) { | ||
| }, | ||
| normalizePath: (r) => getNormalizedPath(r, build.basename) | ||
| normalizePath: (r) => getNormalizedPath(r) | ||
| })); | ||
@@ -98,0 +98,0 @@ } catch (error) { |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,6 +11,4 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { stripBasename } from "../router/utils.js"; | ||
| //#region lib/server-runtime/urls.ts | ||
| function getNormalizedPath(request, basename) { | ||
| basename = basename || "/"; | ||
| function getNormalizedPath(request) { | ||
| let url = new URL(request.url); | ||
@@ -20,3 +18,2 @@ let pathname = url.pathname; | ||
| else pathname = pathname.replace(/\.data$/, ""); | ||
| if (stripBasename(pathname, basename) !== "/" && pathname.endsWith("/")) pathname = pathname.slice(0, -1); | ||
| let searchParams = new URLSearchParams(url.search); | ||
@@ -23,0 +20,0 @@ searchParams.delete("_routes"); |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,2 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import "../../lib/router/utils.js"; | ||
| import { Deferred, createLineSplittingTransform } from "./utils.js"; | ||
@@ -13,0 +14,0 @@ import { flatten } from "./flatten.js"; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -11,3 +11,4 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { Deferred, SUPPORTED_ERROR_TYPES } from "./utils.js"; | ||
| import { SUPPORTED_ERROR_TYPES } from "../../lib/router/utils.js"; | ||
| import { Deferred } from "./utils.js"; | ||
| //#region vendor/turbo-stream-v2/unflatten.ts | ||
@@ -14,0 +15,0 @@ const globalObj = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : void 0; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * react-router v8.0.0-pre.1 | ||
| * | ||
@@ -12,10 +12,2 @@ * Copyright (c) Remix Software Inc. | ||
| //#region vendor/turbo-stream-v2/utils.ts | ||
| const SUPPORTED_ERROR_TYPES = [ | ||
| "EvalError", | ||
| "RangeError", | ||
| "ReferenceError", | ||
| "SyntaxError", | ||
| "TypeError", | ||
| "URIError" | ||
| ]; | ||
| var Deferred = class { | ||
@@ -48,2 +40,2 @@ promise; | ||
| //#endregion | ||
| export { Deferred, SUPPORTED_ERROR_TYPES, createLineSplittingTransform }; | ||
| export { Deferred, createLineSplittingTransform }; |
@@ -77,2 +77,2 @@ --- | ||
| [route-module]: ../../start/framework/route-module | ||
| [route-module]: ../start/framework/route-module |
@@ -83,5 +83,5 @@ --- | ||
| [loader]: ../api/data-routers/loader | ||
| [loader]: ../start/data/route-object#loader | ||
| [form_element]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form | ||
| [form_component]: ../api/components/Form | ||
| [action]: ../api/data-routers/action | ||
| [action]: ../start/data/route-object#action |
@@ -53,3 +53,3 @@ --- | ||
| For a deeper dive into some of the design decisions, check out our [type inference decision doc](https://github.com/remix-run/react-router/blob/dev/decisions/0012-type-inference.md). | ||
| For a deeper dive into some of the design decisions, check out our [type inference decision doc](https://github.com/remix-run/react-router/blob/main/decisions/0012-type-inference.md). | ||
@@ -56,0 +56,0 @@ [route-module-type-safety]: ../how-to/route-module-type-safety |
@@ -161,7 +161,7 @@ --- | ||
| Now that we have stabilized the new `match.shouldCallHandler()`/`match.shouldRevalidateArgs` fields, it's recommended to move away from the now-deprecated `match.shouldLoad` API. The prior boolean approach did not allow for custom `dataStrategy`functions to alter the default revalidation behavior, so the new function-based APIs were created to allow that. | ||
| Now that we have stabilized the new `match.shouldCallHandler()`/`match.shouldRevalidateArgs` fields, it's recommended to move away from the now-deprecated `match.shouldLoad` API. The prior boolean approach did not allow for custom `dataStrategy` functions to alter the default revalidation behavior, so the new function-based APIs were created to allow that. | ||
| The major difference between these two APIs is that when using `shouldLoad`, calling `resolve()` would _only_ call the handler if `shouldLoad` was `true`. You could safely call it for all matches even if only a subset needed to have their handlers executed. | ||
| With `shouldCallHandler`, you are in charge of which handlers should be called so calling resolve will automatically call the handler. You should only call resolve on a the set of matches you wish to run handlers for. | ||
| With `shouldCallHandler`, you are in charge of which handlers should be called so calling resolve will automatically call the handler. You should only call resolve on the set of matches you wish to run handlers for. | ||
@@ -188,5 +188,5 @@ Here's an example change from the prior API to the new API. Note that we pre-filter the `matchesToLoad` before calling `resolve()`: | ||
| Let's define a middleware on each route via [`handle`](../../start/data/route-object#handle) | ||
| Let's define a middleware on each route via [`handle`](../start/data/route-object#handle) | ||
| and call middleware sequentially first, then call all | ||
| [`loader`](../../start/data/route-object#loader)s in parallel - providing | ||
| [`loader`](../start/data/route-object#loader)s in parallel - providing | ||
| any data made available via the middleware: | ||
@@ -263,3 +263,3 @@ | ||
| It's also possible you don't even want to define a [`loader`](../../start/daoute-object#loader) | ||
| It's also possible you don't even want to define a [`loader`](../start/data/route-object#loader) | ||
| implementation at the route level. Maybe you want to just determine the | ||
@@ -266,0 +266,0 @@ routes and issue a single GraphQL request for all of your data. You can do |
@@ -107,3 +107,7 @@ --- | ||
| ```tsx | ||
| import { type ClientOnErrorFunction } from "react-router"; | ||
| import { | ||
| createBrowserRouter, | ||
| type ClientOnErrorFunction, | ||
| } from "react-router"; | ||
| import { RouterProvider } from "react-router/dom"; | ||
@@ -120,4 +124,8 @@ const onError: ClientOnErrorFunction = ( | ||
| const router = createBrowserRouter(routes); | ||
| function App() { | ||
| return <RouterProvider onError={onError} />; | ||
| return ( | ||
| <RouterProvider router={router} onError={onError} /> | ||
| ); | ||
| } | ||
@@ -124,0 +132,0 @@ ``` |
@@ -113,3 +113,4 @@ --- | ||
| parentHeaders.append( | ||
| "Permissions-Policy: geolocation=()", | ||
| "Permissions-Policy", | ||
| "geolocation=()", | ||
| ); | ||
@@ -116,0 +117,0 @@ return parentHeaders; |
@@ -16,11 +16,13 @@ --- | ||
| If you are implementing a [Content-Security-Policy (CSP)][csp] in your application, specifically one using the `unsafe-inline` directive, you will need to specify a [`nonce`][nonce] attribute on the inline `<script>` elements rendered in your HTML. This must be specified on any API that generates inline scripts, including: | ||
| If you are implementing a [Content-Security-Policy (CSP)][csp] in your application, specifically one using the `unsafe-inline` directive, you will need to specify a [`nonce`][nonce] attribute on the inline `<script>` elements rendered in your HTML. | ||
| - [`<Scripts nonce>`][scripts] (`root.tsx`) | ||
| - [`<ScrollRestoration nonce>`][scrollrestoration] (`root.tsx`) | ||
| - [`<ServerRouter nonce>`][serverrouter] (`entry.server.tsx`) | ||
| - [`renderToPipeableStream(..., { nonce })`][renderToPipeableStream] (`entry.server.tsx`) | ||
| - [`renderToReadableStream(..., { nonce })`][renderToReadableStream] (`entry.server.tsx`) | ||
| Add a nonce to these two spots in [`entry.server.tsx`][entryserver]: | ||
| - The [`<ServerRouter nonce>`][serverrouter] prop | ||
| - This will be proxied along through React Context and used for other Framework Mode components that output `nonce`-aware elements, including [`<Scripts>`][scripts], [`<ScrollRestoration>`][scrollrestoration] | ||
| - If those components specify their own `nonce` prop, it will override the `ServerRouter` value | ||
| - The `nonce` options of [`renderToPipeableStream`][renderToPipeableStream]/[`renderToReadableStream`][renderToReadableStream] | ||
| [csp]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP | ||
| [entryserver]: ../api/framework-conventions/entry.server.tsx | ||
| [nonce]: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce | ||
@@ -31,2 +33,2 @@ [renderToPipeableStream]: https://react.dev/reference/react-dom/server/renderToPipeableStream | ||
| [scrollrestoration]: ../api/components/ScrollRestoration | ||
| [serverrouter]: ../api/components/ServerRouter | ||
| [serverrouter]: ../api/framework-routers/ServerRouter |
@@ -50,4 +50,8 @@ --- | ||
| <docs-info>Data Routers should not be held in React state. You should create your router | ||
| once outside of the React tree and pass it to `<RouterProvider>`. You can use | ||
| `patchRoutesOnNavigation` to add additional routes programmatically.</docs-info> | ||
| --- | ||
| Next: [Routing](./routing) |
@@ -243,2 +243,21 @@ --- | ||
| ## `handle` | ||
| Route handle allows apps to add anything to a route match in `useMatches` to create abstractions (like breadcrumbs, etc.). | ||
| ```tsx | ||
| createBrowserRouter([ | ||
| { | ||
| path: "/app", | ||
| handle: { | ||
| breadcrumb: "App", | ||
| }, | ||
| }, | ||
| ]); | ||
| ``` | ||
| See also: | ||
| - [`useMatches`][use-matches] | ||
| --- | ||
@@ -250,1 +269,2 @@ | ||
| [middleware]: ../../how-to/middleware | ||
| [use-matches]: ../../api/hooks/useMatches |
@@ -175,2 +175,1 @@ --- | ||
| [fetchers]: ../../how-to/fetchers | ||
| [data]: ../../api/react-router/data |
@@ -145,3 +145,3 @@ --- | ||
| const serverData = await serverLoader(); | ||
| return { ...serverData, ...res.json() }; | ||
| return { ...serverData, ...(await res.json()) }; | ||
| } | ||
@@ -148,0 +148,0 @@ |
@@ -97,1 +97,5 @@ --- | ||
| EdgeOne Pages maintains their own template for React Router. Checkout the [EdgeOne Pages Guide](https://pages.edgeone.ai/document/framework-react-router) for more information. | ||
| ### DeployHQ | ||
| DeployHQ maintains their own guide for deploying React Router v7 to your own server. Checkout the [DeployHQ Guide](https://www.deployhq.com/guides/deploy-react-router-from-github) for more information. |
@@ -40,4 +40,3 @@ --- | ||
| [manual_usage]: ../how-to/manual-usage | ||
| [default-template]: https://github.com/remix-run/react-router-templates/tree/main/default | ||
| [react-router-templates]: https://github.com/remix-run/react-router-templates |
@@ -144,2 +144,4 @@ --- | ||
| <docs-info>We added a flag to opt-out of `React.startTransition` in v7 so you can use that to upgrade to v7 without adopting React transition-enabled navigations if needed. See the [transition docs][transitions] for more information.</docs-info> | ||
| ### v7_fetcherPersist | ||
@@ -381,1 +383,2 @@ | ||
| [data-util]: https://api.reactrouter.com/v7/functions/react-router.data.html | ||
| [transitions]: ../explanation/react-transitions |
+2
-2
| { | ||
| "name": "react-router", | ||
| "type": "module", | ||
| "version": "8.0.0-pre.0", | ||
| "version": "8.0.0-pre.1", | ||
| "description": "Declarative routing for React", | ||
@@ -113,3 +113,3 @@ "keywords": [ | ||
| "engines": { | ||
| "node": ">=22.12.0" | ||
| "node": ">=22.22.0" | ||
| }, | ||
@@ -116,0 +116,0 @@ "scripts": { |
| import { RouterState } from "../../router/router.js"; | ||
| //#region lib/dom/ssr/errors.d.ts | ||
| declare function deserializeErrors(errors: RouterState["errors"]): RouterState["errors"]; | ||
| //#endregion | ||
| export { deserializeErrors }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * | ||
| * Copyright (c) Remix Software Inc. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE.md file in the root directory of this source tree. | ||
| * | ||
| * @license MIT | ||
| */ | ||
| import { ErrorResponseImpl } from "../../router/utils.js"; | ||
| //#region lib/dom/ssr/errors.ts | ||
| function deserializeErrors(errors) { | ||
| if (!errors) return null; | ||
| let entries = Object.entries(errors); | ||
| let serialized = {}; | ||
| for (let [key, val] of entries) if (val && val.__type === "RouteErrorResponse") serialized[key] = new ErrorResponseImpl(val.status, val.statusText, val.data, val.internal === true); | ||
| else if (val && val.__type === "Error") { | ||
| if (val.__subType) { | ||
| let ErrorConstructor = window[val.__subType]; | ||
| if (typeof ErrorConstructor === "function") try { | ||
| let error = new ErrorConstructor(val.message); | ||
| error.stack = val.stack; | ||
| serialized[key] = error; | ||
| } catch (e) {} | ||
| } | ||
| if (serialized[key] == null) { | ||
| let error = new Error(val.message); | ||
| error.stack = val.stack; | ||
| serialized[key] = error; | ||
| } | ||
| } else serialized[key] = val; | ||
| return serialized; | ||
| } | ||
| //#endregion | ||
| export { deserializeErrors }; |
| import { RouterState } from "../../router/router.js"; | ||
| //#region lib/dom/ssr/errors.d.ts | ||
| declare function deserializeErrors(errors: RouterState["errors"]): RouterState["errors"]; | ||
| //#endregion | ||
| export { deserializeErrors }; |
| /** | ||
| * react-router v8.0.0-pre.0 | ||
| * | ||
| * Copyright (c) Remix Software Inc. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE.md file in the root directory of this source tree. | ||
| * | ||
| * @license MIT | ||
| */ | ||
| import { ErrorResponseImpl } from "../../router/utils.js"; | ||
| //#region lib/dom/ssr/errors.ts | ||
| function deserializeErrors(errors) { | ||
| if (!errors) return null; | ||
| let entries = Object.entries(errors); | ||
| let serialized = {}; | ||
| for (let [key, val] of entries) if (val && val.__type === "RouteErrorResponse") serialized[key] = new ErrorResponseImpl(val.status, val.statusText, val.data, val.internal === true); | ||
| else if (val && val.__type === "Error") { | ||
| if (val.__subType) { | ||
| let ErrorConstructor = window[val.__subType]; | ||
| if (typeof ErrorConstructor === "function") try { | ||
| let error = new ErrorConstructor(val.message); | ||
| error.stack = val.stack; | ||
| serialized[key] = error; | ||
| } catch (e) {} | ||
| } | ||
| if (serialized[key] == null) { | ||
| let error = new Error(val.message); | ||
| error.stack = val.stack; | ||
| serialized[key] = error; | ||
| } | ||
| } else serialized[key] = val; | ||
| return serialized; | ||
| } | ||
| //#endregion | ||
| export { deserializeErrors }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
2717135
0.38%56810
0.22%56
-1.75%321
-0.62%