react-router
Advanced tools
Comparing version 0.0.0-experimental-5509a3c42 to 0.0.0-experimental-58439e382
117
CHANGELOG.md
# `react-router` | ||
## 7.2.0 | ||
### Minor Changes | ||
- New type-safe `href` utility that guarantees links point to actual paths in your app ([#13012](https://github.com/remix-run/react-router/pull/13012)) | ||
```tsx | ||
import { href } from "react-router"; | ||
export default function Component() { | ||
const link = href("/blog/:slug", { slug: "my-first-post" }); | ||
return ( | ||
<main> | ||
<Link to={href("/products/:id", { id: "asdf" })} /> | ||
<NavLink to={href("/:lang?/about", { lang: "en" })} /> | ||
</main> | ||
); | ||
} | ||
``` | ||
### Patch Changes | ||
- Fix typegen for repeated params ([#13012](https://github.com/remix-run/react-router/pull/13012)) | ||
In React Router, path parameters are keyed by their name. | ||
So for a path pattern like `/a/:id/b/:id?/c/:id`, the last `:id` will set the value for `id` in `useParams` and the `params` prop. | ||
For example, `/a/1/b/2/c/3` will result in the value `{ id: 3 }` at runtime. | ||
Previously, generated types for params incorrectly modeled repeated params with an array. | ||
So `/a/1/b/2/c/3` generated a type like `{ id: [1,2,3] }`. | ||
To be consistent with runtime behavior, the generated types now correctly model the "last one wins" semantics of path parameters. | ||
So `/a/1/b/2/c/3` now generates a type like `{ id: 3 }`. | ||
- Don't apply Single Fetch revalidation de-optimization when in SPA mode since there is no server HTTP request ([#12948](https://github.com/remix-run/react-router/pull/12948)) | ||
- Properly handle revalidations to across a prerender/SPA boundary ([#13021](https://github.com/remix-run/react-router/pull/13021)) | ||
- In "hybrid" applications where some routes are pre-rendered and some are served from a SPA fallback, we need to avoid making `.data` requests if the path wasn't pre-rendered because the request will 404 | ||
- We don't know all the pre-rendered paths client-side, however: | ||
- All `loader` data in `ssr:false` mode is static because it's generated at build time | ||
- A route must use a `clientLoader` to do anything dynamic | ||
- Therefore, if a route only has a `loader` and not a `clientLoader`, we disable revalidation by default because there is no new data to retrieve | ||
- We short circuit and skip single fetch `.data` request logic if there are no server loaders with `shouldLoad=true` in our single fetch `dataStrategy` | ||
- This ensures that the route doesn't cause a `.data` request that would 404 after a submission | ||
- Error at build time in `ssr:false` + `prerender` apps for the edge case scenario of: ([#13021](https://github.com/remix-run/react-router/pull/13021)) | ||
- A parent route has only a `loader` (does not have a `clientLoader`) | ||
- The parent route is pre-rendered | ||
- The parent route has children routes which are not prerendered | ||
- This means that when the child paths are loaded via the SPA fallback, the parent won't have any `loaderData` because there is no server on which to run the `loader` | ||
- This can be resolved by either adding a parent `clientLoader` or pre-rendering the child paths | ||
- If you add a `clientLoader`, calling the `serverLoader()` on non-prerendered paths will throw a 404 | ||
- Add unstable support for splitting route modules in framework mode via `future.unstable_splitRouteModules` ([#11871](https://github.com/remix-run/react-router/pull/11871)) | ||
- Add `unstable_SerializesTo` brand type for library authors to register types serializable by React Router's streaming format (`turbo-stream`) ([`ab5b05b02`](https://github.com/remix-run/react-router/commit/ab5b05b02f99f062edb3c536c392197c88eb6c77)) | ||
- Align dev server behavior with static file server behavior when `ssr:false` is set ([#12948](https://github.com/remix-run/react-router/pull/12948)) | ||
- When no `prerender` config exists, only SSR down to the root `HydrateFallback` (SPA Mode) | ||
- When a `prerender` config exists but the current path is not prerendered, only SSR down to the root `HydrateFallback` (SPA Fallback) | ||
- Return a 404 on `.data` requests to non-pre-rendered paths | ||
- Improve prefetch performance of CSS side effects in framework mode ([#12889](https://github.com/remix-run/react-router/pull/12889)) | ||
- Disable Lazy Route Discovery for all `ssr:false` apps and not just "SPA Mode" because there is no runtime server to serve the search-param-configured `__manifest` requests ([#12894](https://github.com/remix-run/react-router/pull/12894)) | ||
- We previously only disabled this for "SPA Mode" which is `ssr:false` and no `prerender` config but we realized it should apply to all `ssr:false` apps, including those prerendering multiple pages | ||
- In those `prerender` scenarios we would prerender the `/__manifest` file assuming the static file server would serve it but that makes some unneccesary assumptions about the static file server behaviors | ||
- Properly handle interrupted manifest requests in lazy route discovery ([#12915](https://github.com/remix-run/react-router/pull/12915)) | ||
## 7.1.5 | ||
### Patch Changes | ||
- Fix regression introduced in `7.1.4` via [#12800](https://github.com/remix-run/react-router/pull/12800) that caused issues navigating to hash routes inside splat routes for applications using Lazy Route Discovery (`patchRoutesOnNavigation`) ([#12927](https://github.com/remix-run/react-router/pull/12927)) | ||
## 7.1.4 | ||
### Patch Changes | ||
- Internal reorg to clean up some duplicated route module types ([#12799](https://github.com/remix-run/react-router/pull/12799)) | ||
- Properly handle status codes that cannot have a body in single fetch responses (204, etc.) ([#12760](https://github.com/remix-run/react-router/pull/12760)) | ||
- Stop erroring on resource routes that return raw strings/objects and instead serialize them as `text/plain` or `application/json` responses ([#12848](https://github.com/remix-run/react-router/pull/12848)) | ||
- This only applies when accessed as a resource route without the `.data` extension | ||
- When accessed from a Single Fetch `.data` request, they will still be encoded via `turbo-stream` | ||
- Optimize Lazy Route Discovery path discovery to favor a single `querySelectorAll` call at the `body` level instead of many calls at the sub-tree level ([#12731](https://github.com/remix-run/react-router/pull/12731)) | ||
- Properly bubble headers as `errorHeaders` when throwing a `data()` result ([#12846](https://github.com/remix-run/react-router/pull/12846)) | ||
- Avoid duplication of `Set-Cookie` headers could be duplicated if also returned from `headers` | ||
- Optimize route matching by skipping redundant `matchRoutes` calls when possible ([#12800](https://github.com/remix-run/react-router/pull/12800)) | ||
## 7.1.3 | ||
_No changes_ | ||
## 7.1.2 | ||
### Patch Changes | ||
- Fix issue with fetcher data cleanup in the data layer on fetcher unmount ([#12681](https://github.com/remix-run/react-router/pull/12681)) | ||
- Do not rely on `symbol` for filtering out `redirect` responses from loader data ([#12694](https://github.com/remix-run/react-router/pull/12694)) | ||
Previously, some projects were getting type checking errors like: | ||
```ts | ||
error TS4058: Return type of exported function has or is using name 'redirectSymbol' from external module "node_modules/..." but cannot be named. | ||
``` | ||
Now that `symbol`s are not used for the `redirect` response type, these errors should no longer be present. | ||
## 7.1.1 | ||
_No changes_ | ||
## 7.1.0 | ||
@@ -26,2 +141,4 @@ | ||
_No changes_ | ||
## 7.0.0 | ||
@@ -28,0 +145,0 @@ |
import * as React from 'react'; | ||
import { R as RouterProviderProps$1 } from './fog-of-war-CcF9dOvO.js'; | ||
import './route-data-JFOfNyPS.js'; | ||
import { R as RouterProviderProps$1 } from './fog-of-war-CqN-DVCB.js'; | ||
import './route-data-CW3SE6AN.js'; | ||
@@ -9,3 +9,3 @@ type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">; | ||
/** | ||
* @category Router Components | ||
* @category Component Routers | ||
*/ | ||
@@ -12,0 +12,0 @@ declare function HydratedRouter(): React.JSX.Element; |
@@ -1,5 +0,5 @@ | ||
import { R as RouteModules, a as Router, D as DataStrategyFunction, A as ActionFunction, L as LoaderFunction, C as ClientActionFunction, b as ClientLoaderFunction, c as LinksFunction, M as MetaFunction, d as RouteManifest, e as LoaderFunctionArgs, f as ActionFunctionArgs, T as To, g as RelativeRoutingType, h as Location, i as Action, P as ParamParseKey, j as Path, k as PathPattern, l as PathMatch, N as NavigateOptions, m as Params, n as RouteObject, o as Navigation, p as RevalidationState, U as UIMatch, S as SerializeFrom, B as BlockerFunction, q as Blocker, r as StaticHandlerContext, s as StaticHandler, F as FutureConfig$1, t as CreateStaticHandlerOptions$1, I as InitialEntry, H as HydrationState, u as IndexRouteObject, v as NonIndexRouteObject, w as RouterState } from './route-data-JFOfNyPS.js'; | ||
export { ap as ClientActionFunctionArgs, aq as ClientLoaderFunctionArgs, aj as DataRouteMatch, ak as DataRouteObject, Q as DataStrategyFunctionArgs, V as DataStrategyMatch, W as DataStrategyResult, Y as ErrorResponse, y as Fetcher, Z as FormEncType, _ as FormMethod, G as GetScrollPositionFunction, x as GetScrollRestorationKeyFunction, $ as HTMLFormMethod, au as HtmlLinkDescriptor, a9 as IDLE_BLOCKER, a8 as IDLE_FETCHER, a7 as IDLE_NAVIGATION, a0 as LazyRouteFunction, av as LinkDescriptor, ar as MetaArgs, as as MetaDescriptor, z as NavigationStates, al as Navigator, at as PageLinkDescriptor, am as PatchRoutesOnNavigationFunction, an as PatchRoutesOnNavigationFunctionArgs, a1 as PathParam, a2 as RedirectFunction, ao as RouteMatch, O as RouterFetchOptions, E as RouterInit, K as RouterNavigateOptions, J as RouterSubscriber, a3 as ShouldRevalidateFunction, a4 as ShouldRevalidateFunctionArgs, aA as UNSAFE_DataRouterContext, aB as UNSAFE_DataRouterStateContext, X as UNSAFE_DataWithResponseInit, az as UNSAFE_ErrorResponseImpl, aC as UNSAFE_FetchersContext, aD as UNSAFE_LocationContext, aE as UNSAFE_NavigationContext, aF as UNSAFE_RouteContext, aG as UNSAFE_ViewTransitionContext, aw as UNSAFE_createBrowserHistory, ay as UNSAFE_createRouter, ax as UNSAFE_invariant, a5 as createPath, aa as data, ab as generatePath, ac as isRouteErrorResponse, ad as matchPath, ae as matchRoutes, a6 as parsePath, af as redirect, ag as redirectDocument, ah as replace, ai as resolvePath } from './route-data-JFOfNyPS.js'; | ||
import { A as AssetsManifest, a as Route, F as FutureConfig, E as EntryContext } from './fog-of-war-CcF9dOvO.js'; | ||
export { f as Await, b as AwaitProps, J as BrowserRouter, B as BrowserRouterProps, v as FetcherFormProps, z as FetcherSubmitFunction, a4 as FetcherSubmitOptions, C as FetcherWithComponents, V as Form, w as FormProps, K as HashRouter, H as HashRouterProps, q as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, Q as Link, s as LinkProps, ab as Links, g as MemoryRouter, M as MemoryRouterProps, aa as Meta, U as NavLink, t as NavLinkProps, u as NavLinkRenderProps, h as Navigate, N as NavigateProps, i as Outlet, O as OutletProps, a5 as ParamKeyValuePair, P as PathRouteProps, ad as PrefetchPageLinks, j as Route, c as RouteProps, k as Router, d as RouterProps, l as RouterProvider, R as RouterProviderProps, m as Routes, e as RoutesProps, ac as Scripts, ae as ScriptsProps, W as ScrollRestoration, S as ScrollRestorationProps, x as SetURLSearchParams, y as SubmitFunction, a6 as SubmitOptions, a8 as SubmitTarget, ag as UNSAFE_FrameworkContext, aj as UNSAFE_createClientRoutes, ak as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, ah as UNSAFE_getPatchRoutesOnNavigationFunction, af as UNSAFE_mapRouteProperties, al as UNSAFE_shouldHydrateRouteLoader, ai as UNSAFE_useFogOFWarDiscovery, am as UNSAFE_useScrollRestoration, a7 as URLSearchParamsInit, D as createBrowserRouter, G as createHashRouter, n as createMemoryRouter, o as createRoutesFromChildren, p as createRoutesFromElements, a9 as createSearchParams, r as renderMatches, T as unstable_HistoryRouter, a2 as unstable_usePrompt, a1 as useBeforeUnload, $ as useFetcher, a0 as useFetchers, _ as useFormAction, X as useLinkClickHandler, Y as useSearchParams, Z as useSubmit, a3 as useViewTransitionState } from './fog-of-war-CcF9dOvO.js'; | ||
import { R as RouteModules, a as Router, D as DataStrategyFunction, b as RouteManifest, S as ServerRouteModule, L as LoaderFunctionArgs, A as ActionFunctionArgs, T as To, c as RelativeRoutingType, d as Location, e as Action, P as ParamParseKey, f as Path, g as PathPattern, h as PathMatch, N as NavigateOptions, i as Params$1, j as RouteObject, k as Navigation, l as RevalidationState, U as UIMatch, m as SerializeFrom, B as BlockerFunction, n as Blocker, o as StaticHandlerContext, p as StaticHandler, F as FutureConfig$1, C as CreateStaticHandlerOptions$1, I as InitialEntry, H as HydrationState, q as IndexRouteObject, r as LoaderFunction, s as ActionFunction, M as MetaFunction, t as LinksFunction, u as NonIndexRouteObject, E as Equal, v as RouterState } from './route-data-CW3SE6AN.js'; | ||
export { ap as ClientActionFunction, aq as ClientActionFunctionArgs, ar as ClientLoaderFunction, as as ClientLoaderFunctionArgs, aj as DataRouteMatch, ak as DataRouteObject, Q as DataStrategyFunctionArgs, V as DataStrategyMatch, W as DataStrategyResult, Y as ErrorResponse, x as Fetcher, Z as FormEncType, _ as FormMethod, G as GetScrollPositionFunction, w as GetScrollRestorationKeyFunction, $ as HTMLFormMethod, at as HeadersArgs, au as HeadersFunction, ay as HtmlLinkDescriptor, a9 as IDLE_BLOCKER, a8 as IDLE_FETCHER, a7 as IDLE_NAVIGATION, a0 as LazyRouteFunction, az as LinkDescriptor, av as MetaArgs, aw as MetaDescriptor, y as NavigationStates, al as Navigator, ax as PageLinkDescriptor, am as PatchRoutesOnNavigationFunction, an as PatchRoutesOnNavigationFunctionArgs, a1 as PathParam, a2 as RedirectFunction, ao as RouteMatch, O as RouterFetchOptions, z as RouterInit, K as RouterNavigateOptions, J as RouterSubscriber, a3 as ShouldRevalidateFunction, a4 as ShouldRevalidateFunctionArgs, aF as UNSAFE_DataRouterContext, aG as UNSAFE_DataRouterStateContext, X as UNSAFE_DataWithResponseInit, aE as UNSAFE_ErrorResponseImpl, aH as UNSAFE_FetchersContext, aI as UNSAFE_LocationContext, aJ as UNSAFE_NavigationContext, aK as UNSAFE_RouteContext, aL as UNSAFE_ViewTransitionContext, aB as UNSAFE_createBrowserHistory, aD as UNSAFE_createRouter, aC as UNSAFE_invariant, a5 as createPath, aa as data, ab as generatePath, ac as isRouteErrorResponse, ad as matchPath, ae as matchRoutes, a6 as parsePath, af as redirect, ag as redirectDocument, ah as replace, ai as resolvePath, aA as unstable_SerializesTo } from './route-data-CW3SE6AN.js'; | ||
import { A as AssetsManifest, a as Route, F as FutureConfig, E as EntryContext, C as CriticalCss } from './fog-of-war-CqN-DVCB.js'; | ||
export { f as Await, b as AwaitProps, K as BrowserRouter, B as BrowserRouterProps, v as FetcherFormProps, z as FetcherSubmitFunction, a5 as FetcherSubmitOptions, D as FetcherWithComponents, W as Form, w as FormProps, Q as HashRouter, H as HashRouterProps, q as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, T as Link, s as LinkProps, ac as Links, g as MemoryRouter, M as MemoryRouterProps, ab as Meta, V as NavLink, t as NavLinkProps, u as NavLinkRenderProps, h as Navigate, N as NavigateProps, i as Outlet, O as OutletProps, a6 as ParamKeyValuePair, P as PathRouteProps, ae as PrefetchPageLinks, j as Route, c as RouteProps, k as Router, d as RouterProps, l as RouterProvider, R as RouterProviderProps, m as Routes, e as RoutesProps, ad as Scripts, af as ScriptsProps, X as ScrollRestoration, S as ScrollRestorationProps, x as SetURLSearchParams, y as SubmitFunction, a7 as SubmitOptions, a9 as SubmitTarget, ah as UNSAFE_FrameworkContext, ak as UNSAFE_createClientRoutes, al as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, ai as UNSAFE_getPatchRoutesOnNavigationFunction, ag as UNSAFE_mapRouteProperties, am as UNSAFE_shouldHydrateRouteLoader, aj as UNSAFE_useFogOFWarDiscovery, an as UNSAFE_useScrollRestoration, a8 as URLSearchParamsInit, G as createBrowserRouter, J as createHashRouter, n as createMemoryRouter, o as createRoutesFromChildren, p as createRoutesFromElements, aa as createSearchParams, r as renderMatches, U as unstable_HistoryRouter, a3 as unstable_usePrompt, a2 as useBeforeUnload, a0 as useFetcher, a1 as useFetchers, $ as useFormAction, Y as useLinkClickHandler, Z as useSearchParams, _ as useSubmit, a4 as useViewTransitionState } from './fog-of-war-CqN-DVCB.js'; | ||
import * as React from 'react'; | ||
@@ -12,3 +12,3 @@ import { ReactElement } from 'react'; | ||
declare const SingleFetchRedirectSymbol: unique symbol; | ||
declare function getSingleFetchDataStrategy(manifest: AssetsManifest, routeModules: RouteModules, getRouter: () => Router): DataStrategyFunction; | ||
declare function getSingleFetchDataStrategy(manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, basename: string | undefined, getRouter: () => Router): DataStrategyFunction; | ||
declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{ | ||
@@ -28,38 +28,2 @@ done: Promise<undefined>; | ||
type HeadersArgs = { | ||
loaderHeaders: Headers; | ||
parentHeaders: Headers; | ||
actionHeaders: Headers; | ||
errorHeaders: Headers | undefined; | ||
}; | ||
/** | ||
* A function that returns HTTP headers to be used for a route. These headers | ||
* will be merged with (and take precedence over) headers from parent routes. | ||
*/ | ||
interface HeadersFunction { | ||
(args: HeadersArgs): Headers | HeadersInit; | ||
} | ||
/** | ||
* An arbitrary object that is associated with a route. | ||
*/ | ||
type RouteHandle = unknown; | ||
interface EntryRouteModule { | ||
clientAction?: ClientActionFunction; | ||
clientLoader?: ClientLoaderFunction; | ||
ErrorBoundary?: any; | ||
HydrateFallback?: any; | ||
Layout?: any; | ||
default: any; | ||
handle?: RouteHandle; | ||
links?: LinksFunction; | ||
meta?: MetaFunction; | ||
} | ||
interface ServerRouteModule extends EntryRouteModule { | ||
action?: ActionFunction; | ||
headers?: HeadersFunction | { | ||
[name: string]: string; | ||
}; | ||
loader?: LoaderFunction; | ||
} | ||
type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>; | ||
@@ -71,2 +35,3 @@ interface ServerRoute extends Route { | ||
type OptionalCriticalCss = CriticalCss | undefined; | ||
/** | ||
@@ -85,3 +50,11 @@ * The output of the compiler for the server build. | ||
future: FutureConfig; | ||
ssr: boolean; | ||
getCriticalCss?: (args: { | ||
pathname: string; | ||
}) => OptionalCriticalCss | Promise<OptionalCriticalCss>; | ||
/** | ||
* @deprecated This is now done via a custom header during prerendering | ||
*/ | ||
isSpaMode: boolean; | ||
prerender: string[]; | ||
} | ||
@@ -232,3 +205,3 @@ interface HandleDocumentRequestFunction { | ||
ParamsOrKey | ||
] extends [string] ? Params<ParamsOrKey> : Partial<ParamsOrKey>>; | ||
] extends [string] ? Params$1<ParamsOrKey> : Partial<ParamsOrKey>>; | ||
/** | ||
@@ -485,3 +458,3 @@ Resolves the pathname of the given `to` value against the current location. Similar to {@link useHref}, but returns a {@link Path} instead of a string. | ||
* | ||
* @category Router Components | ||
* @category Component Routers | ||
*/ | ||
@@ -499,3 +472,3 @@ declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): React.JSX.Element; | ||
* | ||
* @category Router Components | ||
* @category Component Routers | ||
*/ | ||
@@ -509,3 +482,3 @@ declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): React.JSX.Element; | ||
/** | ||
* @category Routers | ||
* @category Data Routers | ||
*/ | ||
@@ -819,3 +792,3 @@ declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: { | ||
type DevServerHooks = { | ||
getCriticalCss?: (build: ServerBuild, pathname: string) => Promise<string | undefined>; | ||
getCriticalCss?: (pathname: string) => Promise<string | undefined>; | ||
processRequestError?: (error: unknown) => void; | ||
@@ -825,2 +798,33 @@ }; | ||
/** | ||
* Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation. | ||
* React Router should handle this for you via type generation. | ||
* | ||
* For more on declaration merging and module augmentation, see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation . | ||
*/ | ||
interface Register { | ||
} | ||
type AnyParams = Record<string, Record<string, string | undefined>>; | ||
type Params = Register extends { | ||
params: infer RegisteredParams extends AnyParams; | ||
} ? RegisteredParams : AnyParams; | ||
type Args = { | ||
[K in keyof Params]: ToArgs<Params[K]>; | ||
}; | ||
type ToArgs<T> = Equal<T, {}> extends true ? [] : Partial<T> extends T ? [T] | [] : [ | ||
T | ||
]; | ||
/** | ||
Returns a resolved URL path for the specified route. | ||
```tsx | ||
const h = href("/:lang?/about", { lang: "en" }) | ||
// -> `/en/about` | ||
<Link to={href("/products/:id", { id: "abc123" })} /> | ||
``` | ||
*/ | ||
declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string; | ||
declare function deserializeErrors(errors: RouterState["errors"]): RouterState["errors"]; | ||
@@ -849,2 +853,2 @@ | ||
export { ActionFunction, ActionFunctionArgs, AppLoadContext$1 as AppLoadContext, Blocker, BlockerFunction, ClientActionFunction, ClientLoaderFunction, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, Router as DataRouter, DataStrategyFunction, EntryContext, type FlashSessionData, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, type HeadersArgs, type HeadersFunction, HydrationState, IndexRouteObject, InitialEntry, type IsCookieFunction, type IsSessionFunction, LinksFunction, LoaderFunction, LoaderFunctionArgs, Location, MetaFunction, type NavigateFunction, NavigateOptions, Navigation, Action as NavigationType, NonIndexRouteObject, ParamParseKey, Params, Path, PathMatch, PathPattern, RelativeRoutingType, type RequestHandler, RevalidationState, RouteObject, RouterState, type RoutesTestStubProps, type ServerBuild, type ServerEntryModule, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, StaticHandler, StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, To, UIMatch, AssetsManifest as UNSAFE_AssetsManifest, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, deserializeErrors as UNSAFE_deserializeErrors, getSingleFetchDataStrategy as UNSAFE_getSingleFetchDataStrategy, createCookie, createCookieSessionStorage, createMemorySessionStorage, createRequestHandler, createRoutesStub, createSession, createSessionStorage, createStaticHandler, createStaticRouter, isCookie, isSession, setDevServerHooks as unstable_setDevServerHooks, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes }; | ||
export { ActionFunction, ActionFunctionArgs, AppLoadContext$1 as AppLoadContext, Blocker, BlockerFunction, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, Router as DataRouter, DataStrategyFunction, EntryContext, type FlashSessionData, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HydrationState, IndexRouteObject, InitialEntry, type IsCookieFunction, type IsSessionFunction, LinksFunction, LoaderFunction, LoaderFunctionArgs, Location, MetaFunction, type NavigateFunction, NavigateOptions, Navigation, Action as NavigationType, NonIndexRouteObject, ParamParseKey, Params$1 as Params, Path, PathMatch, PathPattern, type Register, RelativeRoutingType, type RequestHandler, RevalidationState, RouteObject, RouterState, type RoutesTestStubProps, type ServerBuild, type ServerEntryModule, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, StaticHandler, StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, To, UIMatch, AssetsManifest as UNSAFE_AssetsManifest, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, deserializeErrors as UNSAFE_deserializeErrors, getSingleFetchDataStrategy as UNSAFE_getSingleFetchDataStrategy, createCookie, createCookieSessionStorage, createMemorySessionStorage, createRequestHandler, createRoutesStub, createSession, createSessionStorage, createStaticHandler, createStaticRouter, href, isCookie, isSession, setDevServerHooks as unstable_setDevServerHooks, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes }; |
@@ -1,2 +0,2 @@ | ||
import { av as LinkDescriptor, as as MetaDescriptor, aJ as ServerDataFrom, aK as ClientDataFrom, aL as Func, aM as Equal, aN as Pretty } from '../../route-data-JFOfNyPS.js'; | ||
import { az as LinkDescriptor, aw as MetaDescriptor, aO as ServerDataFrom, aP as ClientDataFrom, aQ as Func, E as Equal, aR as Pretty } from '../../route-data-CW3SE6AN.js'; | ||
import { A as AppLoadContext } from '../../data-CQbyyGzl.js'; | ||
@@ -39,6 +39,11 @@ import 'react'; | ||
type CreateMetaArgs<T extends RouteInfo> = { | ||
/** This is the current router `Location` object. This is useful for generating tags for routes at specific paths or query parameters. */ | ||
location: Location; | ||
/** {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. */ | ||
params: T["params"]; | ||
/** The return value for this route's server loader function */ | ||
data: T["loaderData"]; | ||
/** Thrown errors that trigger error boundaries will be passed to the meta function. This is useful for generating metadata for error pages. */ | ||
error?: unknown; | ||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */ | ||
matches: MetaMatches<[...T["parents"], T]>; | ||
@@ -74,6 +79,47 @@ }; | ||
type ClientDataFunctionArgs<T extends RouteInfo> = { | ||
/** | ||
* A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the URL, the method, the "content-type" header, and the request body from the request. | ||
* | ||
* @note Because client data functions are called before a network request is made, the Request object does not include the headers which the browser automatically adds. React Router infers the "content-type" header from the enc-type of the form that performed the submission. | ||
**/ | ||
request: Request; | ||
/** | ||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. | ||
* @example | ||
* // app/routes.ts | ||
* route("teams/:teamId", "./team.tsx"), | ||
* | ||
* // app/team.tsx | ||
* export function clientLoader({ | ||
* params, | ||
* }: Route.ClientLoaderArgs) { | ||
* params.teamId; | ||
* // ^ string | ||
* } | ||
**/ | ||
params: T["params"]; | ||
}; | ||
type ServerDataFunctionArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & { | ||
type ServerDataFunctionArgs<T extends RouteInfo> = { | ||
/** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the url, method, headers (such as cookies), and request body from the request. */ | ||
request: Request; | ||
/** | ||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. | ||
* @example | ||
* // app/routes.ts | ||
* route("teams/:teamId", "./team.tsx"), | ||
* | ||
* // app/team.tsx | ||
* export function loader({ | ||
* params, | ||
* }: Route.LoaderArgs) { | ||
* params.teamId; | ||
* // ^ string | ||
* } | ||
**/ | ||
params: T["params"]; | ||
/** | ||
* This is the context passed in to your server adapter's getLoadContext() function. | ||
* It's a way to bridge the gap between the adapter's request/response API with your React Router app. | ||
* It is only applicable if you are using a custom server adapter. | ||
*/ | ||
context: AppLoadContext; | ||
@@ -83,2 +129,3 @@ }; | ||
type CreateClientLoaderArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & { | ||
/** This is an asynchronous function to get the data from the server loader for this route. On client-side navigations, this will make a {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server loader. If you opt-into running your clientLoader on hydration, then this function will return the data that was already loaded on the server (via Promise.resolve). */ | ||
serverLoader: () => Promise<ServerDataFrom<T["module"]["loader"]>>; | ||
@@ -88,2 +135,3 @@ }; | ||
type CreateClientActionArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & { | ||
/** This is an asynchronous function that makes the {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server action for this route. */ | ||
serverAction: () => Promise<ServerDataFrom<T["module"]["action"]>>; | ||
@@ -93,2 +141,4 @@ }; | ||
params: T["params"]; | ||
loaderData?: T["loaderData"]; | ||
actionData?: T["actionData"]; | ||
}; | ||
@@ -102,8 +152,39 @@ type Match<T extends RouteInfo> = Pretty<Pick<T, "id" | "params"> & { | ||
type CreateComponentProps<T extends RouteInfo> = { | ||
/** | ||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. | ||
* @example | ||
* // app/routes.ts | ||
* route("teams/:teamId", "./team.tsx"), | ||
* | ||
* // app/team.tsx | ||
* export default function Component({ | ||
* params, | ||
* }: Route.ComponentProps) { | ||
* params.teamId; | ||
* // ^ string | ||
* } | ||
**/ | ||
params: T["params"]; | ||
/** The data returned from the `loader` or `clientLoader` */ | ||
loaderData: T["loaderData"]; | ||
/** The data returned from the `action` or `clientAction` following an action submission. */ | ||
actionData?: T["actionData"]; | ||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */ | ||
matches: Matches<[...T["parents"], T]>; | ||
}; | ||
type CreateErrorBoundaryProps<T extends RouteInfo> = { | ||
/** | ||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. | ||
* @example | ||
* // app/routes.ts | ||
* route("teams/:teamId", "./team.tsx"), | ||
* | ||
* // app/team.tsx | ||
* export function ErrorBoundary({ | ||
* params, | ||
* }: Route.ErrorBoundaryProps) { | ||
* params.teamId; | ||
* // ^ string | ||
* } | ||
**/ | ||
params: T["params"]; | ||
@@ -110,0 +191,0 @@ error: unknown; |
/** | ||
* react-router v0.0.0-experimental-5509a3c42 | ||
* react-router v0.0.0-experimental-58439e382 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
import * as React from 'react'; | ||
import { R as RouterProviderProps$1 } from './fog-of-war-CcF9dOvO.js'; | ||
import './route-data-JFOfNyPS.js'; | ||
import { R as RouterProviderProps$1 } from './fog-of-war-CqN-DVCB.js'; | ||
import './route-data-CW3SE6AN.js'; | ||
@@ -9,3 +9,3 @@ type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">; | ||
/** | ||
* @category Router Components | ||
* @category Component Routers | ||
*/ | ||
@@ -12,0 +12,0 @@ declare function HydratedRouter(): React.JSX.Element; |
@@ -1,5 +0,5 @@ | ||
import { R as RouteModules, a as Router, D as DataStrategyFunction, A as ActionFunction, L as LoaderFunction, C as ClientActionFunction, b as ClientLoaderFunction, c as LinksFunction, M as MetaFunction, d as RouteManifest, e as LoaderFunctionArgs, f as ActionFunctionArgs, T as To, g as RelativeRoutingType, h as Location, i as Action, P as ParamParseKey, j as Path, k as PathPattern, l as PathMatch, N as NavigateOptions, m as Params, n as RouteObject, o as Navigation, p as RevalidationState, U as UIMatch, S as SerializeFrom, B as BlockerFunction, q as Blocker, r as StaticHandlerContext, s as StaticHandler, F as FutureConfig$1, t as CreateStaticHandlerOptions$1, I as InitialEntry, H as HydrationState, u as IndexRouteObject, v as NonIndexRouteObject, w as RouterState } from './route-data-JFOfNyPS.js'; | ||
export { ap as ClientActionFunctionArgs, aq as ClientLoaderFunctionArgs, aj as DataRouteMatch, ak as DataRouteObject, Q as DataStrategyFunctionArgs, V as DataStrategyMatch, W as DataStrategyResult, Y as ErrorResponse, y as Fetcher, Z as FormEncType, _ as FormMethod, G as GetScrollPositionFunction, x as GetScrollRestorationKeyFunction, $ as HTMLFormMethod, au as HtmlLinkDescriptor, a9 as IDLE_BLOCKER, a8 as IDLE_FETCHER, a7 as IDLE_NAVIGATION, a0 as LazyRouteFunction, av as LinkDescriptor, ar as MetaArgs, as as MetaDescriptor, z as NavigationStates, al as Navigator, at as PageLinkDescriptor, am as PatchRoutesOnNavigationFunction, an as PatchRoutesOnNavigationFunctionArgs, a1 as PathParam, a2 as RedirectFunction, ao as RouteMatch, O as RouterFetchOptions, E as RouterInit, K as RouterNavigateOptions, J as RouterSubscriber, a3 as ShouldRevalidateFunction, a4 as ShouldRevalidateFunctionArgs, aA as UNSAFE_DataRouterContext, aB as UNSAFE_DataRouterStateContext, X as UNSAFE_DataWithResponseInit, az as UNSAFE_ErrorResponseImpl, aC as UNSAFE_FetchersContext, aD as UNSAFE_LocationContext, aE as UNSAFE_NavigationContext, aF as UNSAFE_RouteContext, aG as UNSAFE_ViewTransitionContext, aw as UNSAFE_createBrowserHistory, ay as UNSAFE_createRouter, ax as UNSAFE_invariant, a5 as createPath, aa as data, ab as generatePath, ac as isRouteErrorResponse, ad as matchPath, ae as matchRoutes, a6 as parsePath, af as redirect, ag as redirectDocument, ah as replace, ai as resolvePath } from './route-data-JFOfNyPS.js'; | ||
import { A as AssetsManifest, a as Route, F as FutureConfig, E as EntryContext } from './fog-of-war-CcF9dOvO.js'; | ||
export { f as Await, b as AwaitProps, J as BrowserRouter, B as BrowserRouterProps, v as FetcherFormProps, z as FetcherSubmitFunction, a4 as FetcherSubmitOptions, C as FetcherWithComponents, V as Form, w as FormProps, K as HashRouter, H as HashRouterProps, q as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, Q as Link, s as LinkProps, ab as Links, g as MemoryRouter, M as MemoryRouterProps, aa as Meta, U as NavLink, t as NavLinkProps, u as NavLinkRenderProps, h as Navigate, N as NavigateProps, i as Outlet, O as OutletProps, a5 as ParamKeyValuePair, P as PathRouteProps, ad as PrefetchPageLinks, j as Route, c as RouteProps, k as Router, d as RouterProps, l as RouterProvider, R as RouterProviderProps, m as Routes, e as RoutesProps, ac as Scripts, ae as ScriptsProps, W as ScrollRestoration, S as ScrollRestorationProps, x as SetURLSearchParams, y as SubmitFunction, a6 as SubmitOptions, a8 as SubmitTarget, ag as UNSAFE_FrameworkContext, aj as UNSAFE_createClientRoutes, ak as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, ah as UNSAFE_getPatchRoutesOnNavigationFunction, af as UNSAFE_mapRouteProperties, al as UNSAFE_shouldHydrateRouteLoader, ai as UNSAFE_useFogOFWarDiscovery, am as UNSAFE_useScrollRestoration, a7 as URLSearchParamsInit, D as createBrowserRouter, G as createHashRouter, n as createMemoryRouter, o as createRoutesFromChildren, p as createRoutesFromElements, a9 as createSearchParams, r as renderMatches, T as unstable_HistoryRouter, a2 as unstable_usePrompt, a1 as useBeforeUnload, $ as useFetcher, a0 as useFetchers, _ as useFormAction, X as useLinkClickHandler, Y as useSearchParams, Z as useSubmit, a3 as useViewTransitionState } from './fog-of-war-CcF9dOvO.js'; | ||
import { R as RouteModules, a as Router, D as DataStrategyFunction, b as RouteManifest, S as ServerRouteModule, L as LoaderFunctionArgs, A as ActionFunctionArgs, T as To, c as RelativeRoutingType, d as Location, e as Action, P as ParamParseKey, f as Path, g as PathPattern, h as PathMatch, N as NavigateOptions, i as Params$1, j as RouteObject, k as Navigation, l as RevalidationState, U as UIMatch, m as SerializeFrom, B as BlockerFunction, n as Blocker, o as StaticHandlerContext, p as StaticHandler, F as FutureConfig$1, C as CreateStaticHandlerOptions$1, I as InitialEntry, H as HydrationState, q as IndexRouteObject, r as LoaderFunction, s as ActionFunction, M as MetaFunction, t as LinksFunction, u as NonIndexRouteObject, E as Equal, v as RouterState } from './route-data-CW3SE6AN.js'; | ||
export { ap as ClientActionFunction, aq as ClientActionFunctionArgs, ar as ClientLoaderFunction, as as ClientLoaderFunctionArgs, aj as DataRouteMatch, ak as DataRouteObject, Q as DataStrategyFunctionArgs, V as DataStrategyMatch, W as DataStrategyResult, Y as ErrorResponse, x as Fetcher, Z as FormEncType, _ as FormMethod, G as GetScrollPositionFunction, w as GetScrollRestorationKeyFunction, $ as HTMLFormMethod, at as HeadersArgs, au as HeadersFunction, ay as HtmlLinkDescriptor, a9 as IDLE_BLOCKER, a8 as IDLE_FETCHER, a7 as IDLE_NAVIGATION, a0 as LazyRouteFunction, az as LinkDescriptor, av as MetaArgs, aw as MetaDescriptor, y as NavigationStates, al as Navigator, ax as PageLinkDescriptor, am as PatchRoutesOnNavigationFunction, an as PatchRoutesOnNavigationFunctionArgs, a1 as PathParam, a2 as RedirectFunction, ao as RouteMatch, O as RouterFetchOptions, z as RouterInit, K as RouterNavigateOptions, J as RouterSubscriber, a3 as ShouldRevalidateFunction, a4 as ShouldRevalidateFunctionArgs, aF as UNSAFE_DataRouterContext, aG as UNSAFE_DataRouterStateContext, X as UNSAFE_DataWithResponseInit, aE as UNSAFE_ErrorResponseImpl, aH as UNSAFE_FetchersContext, aI as UNSAFE_LocationContext, aJ as UNSAFE_NavigationContext, aK as UNSAFE_RouteContext, aL as UNSAFE_ViewTransitionContext, aB as UNSAFE_createBrowserHistory, aD as UNSAFE_createRouter, aC as UNSAFE_invariant, a5 as createPath, aa as data, ab as generatePath, ac as isRouteErrorResponse, ad as matchPath, ae as matchRoutes, a6 as parsePath, af as redirect, ag as redirectDocument, ah as replace, ai as resolvePath, aA as unstable_SerializesTo } from './route-data-CW3SE6AN.js'; | ||
import { A as AssetsManifest, a as Route, F as FutureConfig, E as EntryContext, C as CriticalCss } from './fog-of-war-CqN-DVCB.js'; | ||
export { f as Await, b as AwaitProps, K as BrowserRouter, B as BrowserRouterProps, v as FetcherFormProps, z as FetcherSubmitFunction, a5 as FetcherSubmitOptions, D as FetcherWithComponents, W as Form, w as FormProps, Q as HashRouter, H as HashRouterProps, q as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, T as Link, s as LinkProps, ac as Links, g as MemoryRouter, M as MemoryRouterProps, ab as Meta, V as NavLink, t as NavLinkProps, u as NavLinkRenderProps, h as Navigate, N as NavigateProps, i as Outlet, O as OutletProps, a6 as ParamKeyValuePair, P as PathRouteProps, ae as PrefetchPageLinks, j as Route, c as RouteProps, k as Router, d as RouterProps, l as RouterProvider, R as RouterProviderProps, m as Routes, e as RoutesProps, ad as Scripts, af as ScriptsProps, X as ScrollRestoration, S as ScrollRestorationProps, x as SetURLSearchParams, y as SubmitFunction, a7 as SubmitOptions, a9 as SubmitTarget, ah as UNSAFE_FrameworkContext, ak as UNSAFE_createClientRoutes, al as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, ai as UNSAFE_getPatchRoutesOnNavigationFunction, ag as UNSAFE_mapRouteProperties, am as UNSAFE_shouldHydrateRouteLoader, aj as UNSAFE_useFogOFWarDiscovery, an as UNSAFE_useScrollRestoration, a8 as URLSearchParamsInit, G as createBrowserRouter, J as createHashRouter, n as createMemoryRouter, o as createRoutesFromChildren, p as createRoutesFromElements, aa as createSearchParams, r as renderMatches, U as unstable_HistoryRouter, a3 as unstable_usePrompt, a2 as useBeforeUnload, a0 as useFetcher, a1 as useFetchers, $ as useFormAction, Y as useLinkClickHandler, Z as useSearchParams, _ as useSubmit, a4 as useViewTransitionState } from './fog-of-war-CqN-DVCB.js'; | ||
import * as React from 'react'; | ||
@@ -12,3 +12,3 @@ import { ReactElement } from 'react'; | ||
declare const SingleFetchRedirectSymbol: unique symbol; | ||
declare function getSingleFetchDataStrategy(manifest: AssetsManifest, routeModules: RouteModules, getRouter: () => Router): DataStrategyFunction; | ||
declare function getSingleFetchDataStrategy(manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, basename: string | undefined, getRouter: () => Router): DataStrategyFunction; | ||
declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{ | ||
@@ -28,38 +28,2 @@ done: Promise<undefined>; | ||
type HeadersArgs = { | ||
loaderHeaders: Headers; | ||
parentHeaders: Headers; | ||
actionHeaders: Headers; | ||
errorHeaders: Headers | undefined; | ||
}; | ||
/** | ||
* A function that returns HTTP headers to be used for a route. These headers | ||
* will be merged with (and take precedence over) headers from parent routes. | ||
*/ | ||
interface HeadersFunction { | ||
(args: HeadersArgs): Headers | HeadersInit; | ||
} | ||
/** | ||
* An arbitrary object that is associated with a route. | ||
*/ | ||
type RouteHandle = unknown; | ||
interface EntryRouteModule { | ||
clientAction?: ClientActionFunction; | ||
clientLoader?: ClientLoaderFunction; | ||
ErrorBoundary?: any; | ||
HydrateFallback?: any; | ||
Layout?: any; | ||
default: any; | ||
handle?: RouteHandle; | ||
links?: LinksFunction; | ||
meta?: MetaFunction; | ||
} | ||
interface ServerRouteModule extends EntryRouteModule { | ||
action?: ActionFunction; | ||
headers?: HeadersFunction | { | ||
[name: string]: string; | ||
}; | ||
loader?: LoaderFunction; | ||
} | ||
type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>; | ||
@@ -71,2 +35,3 @@ interface ServerRoute extends Route { | ||
type OptionalCriticalCss = CriticalCss | undefined; | ||
/** | ||
@@ -85,3 +50,11 @@ * The output of the compiler for the server build. | ||
future: FutureConfig; | ||
ssr: boolean; | ||
getCriticalCss?: (args: { | ||
pathname: string; | ||
}) => OptionalCriticalCss | Promise<OptionalCriticalCss>; | ||
/** | ||
* @deprecated This is now done via a custom header during prerendering | ||
*/ | ||
isSpaMode: boolean; | ||
prerender: string[]; | ||
} | ||
@@ -232,3 +205,3 @@ interface HandleDocumentRequestFunction { | ||
ParamsOrKey | ||
] extends [string] ? Params<ParamsOrKey> : Partial<ParamsOrKey>>; | ||
] extends [string] ? Params$1<ParamsOrKey> : Partial<ParamsOrKey>>; | ||
/** | ||
@@ -485,3 +458,3 @@ Resolves the pathname of the given `to` value against the current location. Similar to {@link useHref}, but returns a {@link Path} instead of a string. | ||
* | ||
* @category Router Components | ||
* @category Component Routers | ||
*/ | ||
@@ -499,3 +472,3 @@ declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): React.JSX.Element; | ||
* | ||
* @category Router Components | ||
* @category Component Routers | ||
*/ | ||
@@ -509,3 +482,3 @@ declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): React.JSX.Element; | ||
/** | ||
* @category Routers | ||
* @category Data Routers | ||
*/ | ||
@@ -819,3 +792,3 @@ declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: { | ||
type DevServerHooks = { | ||
getCriticalCss?: (build: ServerBuild, pathname: string) => Promise<string | undefined>; | ||
getCriticalCss?: (pathname: string) => Promise<string | undefined>; | ||
processRequestError?: (error: unknown) => void; | ||
@@ -825,2 +798,33 @@ }; | ||
/** | ||
* Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation. | ||
* React Router should handle this for you via type generation. | ||
* | ||
* For more on declaration merging and module augmentation, see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation . | ||
*/ | ||
interface Register { | ||
} | ||
type AnyParams = Record<string, Record<string, string | undefined>>; | ||
type Params = Register extends { | ||
params: infer RegisteredParams extends AnyParams; | ||
} ? RegisteredParams : AnyParams; | ||
type Args = { | ||
[K in keyof Params]: ToArgs<Params[K]>; | ||
}; | ||
type ToArgs<T> = Equal<T, {}> extends true ? [] : Partial<T> extends T ? [T] | [] : [ | ||
T | ||
]; | ||
/** | ||
Returns a resolved URL path for the specified route. | ||
```tsx | ||
const h = href("/:lang?/about", { lang: "en" }) | ||
// -> `/en/about` | ||
<Link to={href("/products/:id", { id: "abc123" })} /> | ||
``` | ||
*/ | ||
declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string; | ||
declare function deserializeErrors(errors: RouterState["errors"]): RouterState["errors"]; | ||
@@ -849,2 +853,2 @@ | ||
export { ActionFunction, ActionFunctionArgs, AppLoadContext$1 as AppLoadContext, Blocker, BlockerFunction, ClientActionFunction, ClientLoaderFunction, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, Router as DataRouter, DataStrategyFunction, EntryContext, type FlashSessionData, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, type HeadersArgs, type HeadersFunction, HydrationState, IndexRouteObject, InitialEntry, type IsCookieFunction, type IsSessionFunction, LinksFunction, LoaderFunction, LoaderFunctionArgs, Location, MetaFunction, type NavigateFunction, NavigateOptions, Navigation, Action as NavigationType, NonIndexRouteObject, ParamParseKey, Params, Path, PathMatch, PathPattern, RelativeRoutingType, type RequestHandler, RevalidationState, RouteObject, RouterState, type RoutesTestStubProps, type ServerBuild, type ServerEntryModule, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, StaticHandler, StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, To, UIMatch, AssetsManifest as UNSAFE_AssetsManifest, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, deserializeErrors as UNSAFE_deserializeErrors, getSingleFetchDataStrategy as UNSAFE_getSingleFetchDataStrategy, createCookie, createCookieSessionStorage, createMemorySessionStorage, createRequestHandler, createRoutesStub, createSession, createSessionStorage, createStaticHandler, createStaticRouter, isCookie, isSession, setDevServerHooks as unstable_setDevServerHooks, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes }; | ||
export { ActionFunction, ActionFunctionArgs, AppLoadContext$1 as AppLoadContext, Blocker, BlockerFunction, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, Router as DataRouter, DataStrategyFunction, EntryContext, type FlashSessionData, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HydrationState, IndexRouteObject, InitialEntry, type IsCookieFunction, type IsSessionFunction, LinksFunction, LoaderFunction, LoaderFunctionArgs, Location, MetaFunction, type NavigateFunction, NavigateOptions, Navigation, Action as NavigationType, NonIndexRouteObject, ParamParseKey, Params$1 as Params, Path, PathMatch, PathPattern, type Register, RelativeRoutingType, type RequestHandler, RevalidationState, RouteObject, RouterState, type RoutesTestStubProps, type ServerBuild, type ServerEntryModule, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, StaticHandler, StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, To, UIMatch, AssetsManifest as UNSAFE_AssetsManifest, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, deserializeErrors as UNSAFE_deserializeErrors, getSingleFetchDataStrategy as UNSAFE_getSingleFetchDataStrategy, createCookie, createCookieSessionStorage, createMemorySessionStorage, createRequestHandler, createRoutesStub, createSession, createSessionStorage, createStaticHandler, createStaticRouter, href, isCookie, isSession, setDevServerHooks as unstable_setDevServerHooks, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes }; |
@@ -1,2 +0,2 @@ | ||
import { av as LinkDescriptor, as as MetaDescriptor, aJ as ServerDataFrom, aK as ClientDataFrom, aL as Func, aM as Equal, aN as Pretty } from '../../route-data-JFOfNyPS.js'; | ||
import { az as LinkDescriptor, aw as MetaDescriptor, aO as ServerDataFrom, aP as ClientDataFrom, aQ as Func, E as Equal, aR as Pretty } from '../../route-data-CW3SE6AN.js'; | ||
import { A as AppLoadContext } from '../../data-CQbyyGzl.js'; | ||
@@ -39,6 +39,11 @@ import 'react'; | ||
type CreateMetaArgs<T extends RouteInfo> = { | ||
/** This is the current router `Location` object. This is useful for generating tags for routes at specific paths or query parameters. */ | ||
location: Location; | ||
/** {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. */ | ||
params: T["params"]; | ||
/** The return value for this route's server loader function */ | ||
data: T["loaderData"]; | ||
/** Thrown errors that trigger error boundaries will be passed to the meta function. This is useful for generating metadata for error pages. */ | ||
error?: unknown; | ||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */ | ||
matches: MetaMatches<[...T["parents"], T]>; | ||
@@ -74,6 +79,47 @@ }; | ||
type ClientDataFunctionArgs<T extends RouteInfo> = { | ||
/** | ||
* A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the URL, the method, the "content-type" header, and the request body from the request. | ||
* | ||
* @note Because client data functions are called before a network request is made, the Request object does not include the headers which the browser automatically adds. React Router infers the "content-type" header from the enc-type of the form that performed the submission. | ||
**/ | ||
request: Request; | ||
/** | ||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. | ||
* @example | ||
* // app/routes.ts | ||
* route("teams/:teamId", "./team.tsx"), | ||
* | ||
* // app/team.tsx | ||
* export function clientLoader({ | ||
* params, | ||
* }: Route.ClientLoaderArgs) { | ||
* params.teamId; | ||
* // ^ string | ||
* } | ||
**/ | ||
params: T["params"]; | ||
}; | ||
type ServerDataFunctionArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & { | ||
type ServerDataFunctionArgs<T extends RouteInfo> = { | ||
/** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the url, method, headers (such as cookies), and request body from the request. */ | ||
request: Request; | ||
/** | ||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. | ||
* @example | ||
* // app/routes.ts | ||
* route("teams/:teamId", "./team.tsx"), | ||
* | ||
* // app/team.tsx | ||
* export function loader({ | ||
* params, | ||
* }: Route.LoaderArgs) { | ||
* params.teamId; | ||
* // ^ string | ||
* } | ||
**/ | ||
params: T["params"]; | ||
/** | ||
* This is the context passed in to your server adapter's getLoadContext() function. | ||
* It's a way to bridge the gap between the adapter's request/response API with your React Router app. | ||
* It is only applicable if you are using a custom server adapter. | ||
*/ | ||
context: AppLoadContext; | ||
@@ -83,2 +129,3 @@ }; | ||
type CreateClientLoaderArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & { | ||
/** This is an asynchronous function to get the data from the server loader for this route. On client-side navigations, this will make a {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server loader. If you opt-into running your clientLoader on hydration, then this function will return the data that was already loaded on the server (via Promise.resolve). */ | ||
serverLoader: () => Promise<ServerDataFrom<T["module"]["loader"]>>; | ||
@@ -88,2 +135,3 @@ }; | ||
type CreateClientActionArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & { | ||
/** This is an asynchronous function that makes the {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server action for this route. */ | ||
serverAction: () => Promise<ServerDataFrom<T["module"]["action"]>>; | ||
@@ -93,2 +141,4 @@ }; | ||
params: T["params"]; | ||
loaderData?: T["loaderData"]; | ||
actionData?: T["actionData"]; | ||
}; | ||
@@ -102,8 +152,39 @@ type Match<T extends RouteInfo> = Pretty<Pick<T, "id" | "params"> & { | ||
type CreateComponentProps<T extends RouteInfo> = { | ||
/** | ||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. | ||
* @example | ||
* // app/routes.ts | ||
* route("teams/:teamId", "./team.tsx"), | ||
* | ||
* // app/team.tsx | ||
* export default function Component({ | ||
* params, | ||
* }: Route.ComponentProps) { | ||
* params.teamId; | ||
* // ^ string | ||
* } | ||
**/ | ||
params: T["params"]; | ||
/** The data returned from the `loader` or `clientLoader` */ | ||
loaderData: T["loaderData"]; | ||
/** The data returned from the `action` or `clientAction` following an action submission. */ | ||
actionData?: T["actionData"]; | ||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */ | ||
matches: Matches<[...T["parents"], T]>; | ||
}; | ||
type CreateErrorBoundaryProps<T extends RouteInfo> = { | ||
/** | ||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. | ||
* @example | ||
* // app/routes.ts | ||
* route("teams/:teamId", "./team.tsx"), | ||
* | ||
* // app/team.tsx | ||
* export function ErrorBoundary({ | ||
* params, | ||
* }: Route.ErrorBoundaryProps) { | ||
* params.teamId; | ||
* // ^ string | ||
* } | ||
**/ | ||
params: T["params"]; | ||
@@ -110,0 +191,0 @@ error: unknown; |
/** | ||
* react-router v0.0.0-experimental-5509a3c42 | ||
* react-router v0.0.0-experimental-58439e382 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
{ | ||
"name": "react-router", | ||
"version": "0.0.0-experimental-5509a3c42", | ||
"version": "0.0.0-experimental-58439e382", | ||
"description": "Declarative routing for React", | ||
@@ -113,4 +113,5 @@ "keywords": [ | ||
"scripts": { | ||
"build": "wireit" | ||
"build": "wireit", | ||
"typecheck": "tsc" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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.
Found 1 instance in 1 package
2378532
60088
12