react-router
Advanced tools
Comparing version 7.0.0-pre.1 to 7.0.0-pre.2
# `react-router` | ||
## 7.0.0-pre.2 | ||
### Major Changes | ||
- Migrate Remix type generics to React Router ([#12180](https://github.com/remix-run/react-router/pull/12180)) | ||
- These generics are provided for Remix v2 migration purposes | ||
- These generics and the APIs they exist on should be considered informally deprecated in favor of the new `Route.*` types | ||
- Anyone migrating from React Router v6 should probably not leverage these new generics and should migrate straight to the `Route.*` types | ||
- For React Router v6 users, these generics are new and should not impact your app, with one exception | ||
- `useFetcher` previously had an optional generic (used primarily by Remix v2) that expected the data type | ||
- This has been updated in v7 to expect the type of the function that generates the data (i.e., `typeof loader`/`typeof action`) | ||
- Therefore, you should update your usages: | ||
- ❌ `useFetcher<LoaderData>()` | ||
- ✅ `useFetcher<typeof loader>()` | ||
- - Consolidate types previously duplicated across `@remix-run/router`, `@remix-run/server-runtime`, and `@remix-run/react` now that they all live in `react-router` ([#12177](https://github.com/remix-run/react-router/pull/12177)) | ||
- Examples: `LoaderFunction`, `LoaderFunctionArgs`, `ActionFunction`, `ActionFunctionArgs`, `DataFunctionArgs`, `RouteManifest`, `LinksFunction`, `Route`, `EntryRoute` | ||
- The `RouteManifest` type used by the "remix" code is now slightly stricter because it is using the former `@remix-run/router` `RouteManifest` | ||
- `Record<string, Route> -> Record<string, Route | undefined>` | ||
- Removed `AppData` type in favor of inlining `unknown` in the few locations it was used | ||
- Removed `ServerRuntimeMeta*` types in favor of the `Meta*` types they were duplicated from | ||
- Drop support for Node 18, update minimum Node vestion to 20 ([#12171](https://github.com/remix-run/react-router/pull/12171)) | ||
- Remove `installGlobals()` as this should no longer be necessary | ||
- Update `cookie` dependency to `^1.0.1` - please see the [release notes](https://github.com/jshttp/cookie/releases) for any breaking changes ([#12172](https://github.com/remix-run/react-router/pull/12172)) | ||
### Patch Changes | ||
- Replace `substr` with `substring` ([#12080](https://github.com/remix-run/react-router/pull/12080)) | ||
- Remove the deprecated `json` utility ([#12146](https://github.com/remix-run/react-router/pull/12146)) | ||
- You can use [`Response.json`](https://developer.mozilla.org/en-US/docs/Web/API/Response/json_static) if you still need to construct JSON responses in your app | ||
- Updated dependencies: | ||
- `react-router@7.0.0-pre.2` | ||
## 7.0.0-pre.1 | ||
@@ -4,0 +42,0 @@ |
@@ -6,3 +6,3 @@ export type { InitialEntry, Location, Path, To } from "./lib/router/history"; | ||
export { IDLE_NAVIGATION, IDLE_FETCHER, IDLE_BLOCKER, } from "./lib/router/router"; | ||
export { data, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, redirect, redirectDocument, replace, resolvePath, } from "./lib/router/utils"; | ||
export { data, generatePath, isRouteErrorResponse, matchPath, matchRoutes, redirect, redirectDocument, replace, resolvePath, } from "./lib/router/utils"; | ||
export type { DataRouteMatch, DataRouteObject, IndexRouteObject, NavigateOptions, Navigator, NonIndexRouteObject, PatchRoutesOnNavigationFunction, PatchRoutesOnNavigationFunctionArgs, RouteMatch, RouteObject, } from "./lib/context"; | ||
@@ -40,4 +40,3 @@ export type { AwaitProps, IndexRouteProps, LayoutRouteProps, MemoryRouterProps, NavigateProps, OutletProps, PathRouteProps, RouteProps, RouterProps, RouterProviderProps, RoutesProps, } from "./lib/components"; | ||
export type { PageLinkDescriptor, HtmlLinkDescriptor, LinkDescriptor, } from "./lib/router/links"; | ||
export type { TypedResponse, JsonFunction, } from "./lib/server-runtime/responses"; | ||
export type { DataFunctionArgs, HeadersArgs, HeadersFunction, } from "./lib/server-runtime/routeModules"; | ||
export type { HeadersArgs, HeadersFunction, } from "./lib/server-runtime/routeModules"; | ||
export type { RequestHandler } from "./lib/server-runtime/server"; | ||
@@ -44,0 +43,0 @@ export type { Session, SessionData, SessionIdStorageStrategy, SessionStorage, FlashSessionData, } from "./lib/server-runtime/sessions"; |
@@ -5,3 +5,3 @@ import * as React from "react"; | ||
import type { FutureConfig, HydrationState, RelativeRoutingType, Router as DataRouter } from "./router/router"; | ||
import type { DataStrategyFunction, LazyRouteFunction, TrackedPromise } from "./router/utils"; | ||
import type { DataStrategyFunction, LazyRouteFunction } from "./router/utils"; | ||
import type { IndexRouteObject, Navigator, NonIndexRouteObject, PatchRoutesOnNavigationFunction, RouteMatch, RouteObject } from "./context"; | ||
@@ -213,4 +213,4 @@ /** | ||
export declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null; | ||
export interface AwaitResolveRenderFunction { | ||
(data: Awaited<any>): React.ReactNode; | ||
export interface AwaitResolveRenderFunction<Resolve = any> { | ||
(data: Awaited<Resolve>): React.ReactNode; | ||
} | ||
@@ -220,3 +220,3 @@ /** | ||
*/ | ||
export interface AwaitProps { | ||
export interface AwaitProps<Resolve> { | ||
/** | ||
@@ -318,3 +318,3 @@ When using a function, the resolved value is provided as the parameter. | ||
*/ | ||
resolve: TrackedPromise | any; | ||
resolve: Resolve; | ||
} | ||
@@ -362,3 +362,3 @@ /** | ||
*/ | ||
export declare function Await({ children, errorElement, resolve }: AwaitProps): React.JSX.Element; | ||
export declare function Await<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element; | ||
/** | ||
@@ -365,0 +365,0 @@ * Creates a route config from a React "children" object, which is usually |
@@ -9,2 +9,3 @@ import * as React from "react"; | ||
import type { RouteObject, NavigateOptions, PatchRoutesOnNavigationFunction } from "../context"; | ||
import type { SerializeFrom } from "../types"; | ||
interface DOMRouterOpts { | ||
@@ -838,3 +839,3 @@ basename?: string; | ||
*/ | ||
export declare function useFetcher<TData = any>({ key, }?: { | ||
export declare function useFetcher<T = any>({ key, }?: { | ||
/** | ||
@@ -858,3 +859,3 @@ By default, `useFetcher` generate a unique fetcher scoped to that component. If you want to identify a fetcher with your own key such that you can access it from elsewhere in your app, you can do that with the `key` option: | ||
key?: string; | ||
}): FetcherWithComponents<TData>; | ||
}): FetcherWithComponents<SerializeFrom<T>>; | ||
/** | ||
@@ -861,0 +862,0 @@ Returns an array of all in-flight fetchers. This is useful for components throughout the app that didn't create the fetchers but want to use their submissions to participate in optimistic UI. |
@@ -5,3 +5,2 @@ import type { FocusEventHandler, MouseEventHandler, TouchEventHandler } from "react"; | ||
import type { PageLinkDescriptor } from "../../router/links"; | ||
export type SerializeFrom<D> = D extends () => {} ? Awaited<ReturnType<D>> : D; | ||
export declare const FrameworkContext: React.Context<FrameworkContextObject | undefined>; | ||
@@ -8,0 +7,0 @@ export declare function useFrameworkContext(): FrameworkContextObject; |
import "../global"; | ||
/** | ||
* Data for a route that was returned from a `loader()`. | ||
*/ | ||
export type AppData = unknown; | ||
export declare function isResponse(value: any): value is Response; | ||
export declare function createRequestInit(request: Request): Promise<RequestInit>; |
import type { StaticHandlerContext } from "../../router/router"; | ||
import type { RouteManifest, EntryRoute } from "./routes"; | ||
import type { EntryRoute } from "./routes"; | ||
import type { RouteModules } from "./routeModules"; | ||
import type { RouteManifest } from "../../router/utils"; | ||
type SerializedError = { | ||
@@ -5,0 +6,0 @@ message: string; |
import type { ComponentType, ReactElement } from "react"; | ||
import type { Location } from "../../router/history"; | ||
import type { ActionFunction as RRActionFunction, ActionFunctionArgs as RRActionFunctionArgs, LoaderFunction as RRLoaderFunction, LoaderFunctionArgs as RRLoaderFunctionArgs, Params, ShouldRevalidateFunction, LoaderFunctionArgs } from "../../router/utils"; | ||
import type { SerializeFrom } from "./components"; | ||
import type { AppData } from "./data"; | ||
import type { ActionFunction, ActionFunctionArgs, LoaderFunction, LoaderFunctionArgs, Params, ShouldRevalidateFunction } from "../../router/utils"; | ||
import type { EntryRoute } from "./routes"; | ||
import type { DataRouteMatch } from "../../context"; | ||
import type { LinkDescriptor } from "../../router/links"; | ||
import type { SerializeFrom } from "../../types"; | ||
export interface RouteModules { | ||
@@ -27,8 +26,8 @@ [routeId: string]: RouteModule | undefined; | ||
*/ | ||
export type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType<RRActionFunction>; | ||
export type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType<ActionFunction>; | ||
/** | ||
* Arguments passed to a route `clientAction` function | ||
*/ | ||
export type ClientActionFunctionArgs = RRActionFunctionArgs<undefined> & { | ||
serverAction: <T = AppData>() => Promise<SerializeFrom<T>>; | ||
export type ClientActionFunctionArgs = ActionFunctionArgs<undefined> & { | ||
serverAction: <T = unknown>() => Promise<SerializeFrom<T>>; | ||
}; | ||
@@ -38,3 +37,3 @@ /** | ||
*/ | ||
export type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType<RRLoaderFunction>) & { | ||
export type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType<LoaderFunction>) & { | ||
hydrate?: boolean; | ||
@@ -45,4 +44,4 @@ }; | ||
*/ | ||
export type ClientLoaderFunctionArgs = RRLoaderFunctionArgs<undefined> & { | ||
serverLoader: <T = AppData>() => Promise<SerializeFrom<T>>; | ||
export type ClientLoaderFunctionArgs = LoaderFunctionArgs<undefined> & { | ||
serverLoader: <T = unknown>() => Promise<SerializeFrom<T>>; | ||
}; | ||
@@ -75,13 +74,6 @@ /** | ||
} | ||
type LoaderFunction = (args: LoaderFunctionArgs & { | ||
context: unknown; | ||
response?: { | ||
status: number | undefined; | ||
headers: Headers; | ||
}; | ||
}) => ReturnType<RRLoaderFunction>; | ||
export interface MetaMatch<RouteId extends string = string, Loader extends LoaderFunction | unknown = unknown> { | ||
export interface MetaMatch<RouteId extends string = string, Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown> { | ||
id: RouteId; | ||
pathname: DataRouteMatch["pathname"]; | ||
data: Loader extends LoaderFunction ? SerializeFrom<Loader> : unknown; | ||
data: Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown; | ||
handle?: RouteHandle; | ||
@@ -92,7 +84,7 @@ params: DataRouteMatch["params"]; | ||
} | ||
export type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | unknown> = Record<string, unknown>> = Array<{ | ||
export type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> = Array<{ | ||
[K in keyof MatchLoaders]: MetaMatch<Exclude<K, number | symbol>, MatchLoaders[K]>; | ||
}[keyof MatchLoaders]>; | ||
export interface MetaArgs<Loader extends LoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | unknown> = Record<string, unknown>> { | ||
data: (Loader extends LoaderFunction ? SerializeFrom<Loader> : AppData) | undefined; | ||
export interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> { | ||
data: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined; | ||
params: Params; | ||
@@ -103,3 +95,53 @@ location: Location; | ||
} | ||
export interface MetaFunction<Loader extends LoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | unknown> = Record<string, unknown>> { | ||
/** | ||
* A function that returns an array of data objects to use for rendering | ||
* metadata HTML tags in a route. These tags are not rendered on descendant | ||
* routes in the route hierarchy. In other words, they will only be rendered on | ||
* the route in which they are exported. | ||
* | ||
* @param Loader - The type of the current route's loader function | ||
* @param MatchLoaders - Mapping from a parent route's filepath to its loader | ||
* function type | ||
* | ||
* Note that parent route filepaths are relative to the `app/` directory. | ||
* | ||
* For example, if this meta function is for `/sales/customers/$customerId`: | ||
* | ||
* ```ts | ||
* // app/root.tsx | ||
* const loader = () => ({ hello: "world" }) | ||
* export type Loader = typeof loader | ||
* | ||
* // app/routes/sales.tsx | ||
* const loader = () => ({ salesCount: 1074 }) | ||
* export type Loader = typeof loader | ||
* | ||
* // app/routes/sales/customers.tsx | ||
* const loader = () => ({ customerCount: 74 }) | ||
* export type Loader = typeof loader | ||
* | ||
* // app/routes/sales/customers/$customersId.tsx | ||
* import type { Loader as RootLoader } from "../../../root" | ||
* import type { Loader as SalesLoader } from "../../sales" | ||
* import type { Loader as CustomersLoader } from "../../sales/customers" | ||
* | ||
* const loader = () => ({ name: "Customer name" }) | ||
* | ||
* const meta: MetaFunction<typeof loader, { | ||
* "root": RootLoader, | ||
* "routes/sales": SalesLoader, | ||
* "routes/sales/customers": CustomersLoader, | ||
* }> = ({ data, matches }) => { | ||
* const { name } = data | ||
* // ^? string | ||
* const { customerCount } = matches.find((match) => match.id === "routes/sales/customers").data | ||
* // ^? number | ||
* const { salesCount } = matches.find((match) => match.id === "routes/sales").data | ||
* // ^? number | ||
* const { hello } = matches.find((match) => match.id === "root").data | ||
* // ^? "world" | ||
* } | ||
* ``` | ||
*/ | ||
export interface MetaFunction<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> { | ||
(args: MetaArgs<Loader, MatchLoaders>): MetaDescriptor[] | undefined; | ||
@@ -106,0 +148,0 @@ } |
import type { HydrationState } from "../../router/router"; | ||
import type { RouteManifest } from "../../router/utils"; | ||
import type { RouteModule, RouteModules } from "./routeModules"; | ||
import type { FutureConfig } from "./entry"; | ||
import type { DataRouteObject } from "../../context"; | ||
export interface RouteManifest<Route> { | ||
[routeId: string]: Route; | ||
} | ||
interface Route { | ||
export interface Route { | ||
index?: boolean; | ||
@@ -32,2 +30,1 @@ caseSensitive?: boolean; | ||
export declare function shouldHydrateRouteLoader(route: EntryRoute, routeModule: RouteModule, isSpaMode: boolean): boolean; | ||
export {}; |
@@ -7,2 +7,3 @@ import * as React from "react"; | ||
import type { ParamParseKey, Params, PathMatch, PathPattern, UIMatch } from "./router/utils"; | ||
import type { SerializeFrom } from "./types"; | ||
/** | ||
@@ -293,3 +294,3 @@ Resolves a URL against the current location. | ||
*/ | ||
export declare function useLoaderData(): unknown; | ||
export declare function useLoaderData<T = any>(): SerializeFrom<T>; | ||
/** | ||
@@ -322,3 +323,3 @@ Returns the loader data for a given route by route ID. | ||
*/ | ||
export declare function useRouteLoaderData(routeId: string): unknown; | ||
export declare function useRouteLoaderData<T = any>(routeId: string): SerializeFrom<T> | undefined; | ||
/** | ||
@@ -349,3 +350,3 @@ Returns the action data from the most recent POST navigation form submission or `undefined` if there hasn't been one. | ||
*/ | ||
export declare function useActionData(): unknown; | ||
export declare function useActionData<T = any>(): SerializeFrom<T> | undefined; | ||
/** | ||
@@ -352,0 +353,0 @@ Accesses the error thrown during an {@link ActionFunction | action}, {@link LoaderFunction | loader}, or component render to be used in a route module Error Boundary. |
@@ -519,2 +519,3 @@ import type { History, Location, Path, To } from "./history"; | ||
}) => boolean; | ||
export declare const redirectStatusCodes: Set<number>; | ||
export declare const IDLE_NAVIGATION: NavigationStates["Idle"]; | ||
@@ -541,2 +542,5 @@ export declare const IDLE_FETCHER: FetcherStates["Idle"]; | ||
export declare function isDataWithResponseInit(value: any): value is DataWithResponseInit<unknown>; | ||
export declare function isResponse(value: any): value is Response; | ||
export declare function isRedirectStatusCode(statusCode: number): boolean; | ||
export declare function isRedirectResponse(result: any): result is Response; | ||
export {}; |
@@ -1,2 +0,1 @@ | ||
import type { JsonFunction } from "../server-runtime/responses"; | ||
import type { Location, Path, To } from "./history"; | ||
@@ -255,3 +254,3 @@ /** | ||
export type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject; | ||
export type RouteManifest = Record<string, AgnosticDataRouteObject | undefined>; | ||
export type RouteManifest<R = AgnosticDataRouteObject> = Record<string, R | undefined>; | ||
type _PathParam<Path extends string> = Path extends `${infer L}/${infer R}` ? _PathParam<L> | _PathParam<R> : Path extends `:${infer Param}` ? Param extends `${infer Optional}?` ? Optional : Param : never; | ||
@@ -428,9 +427,2 @@ /** | ||
export declare const normalizeHash: (hash: string) => string; | ||
/** | ||
* This is a shortcut for creating `application/json` responses. Converts `data` | ||
* to JSON and sets the `Content-Type` header. | ||
* | ||
* @category Utils | ||
*/ | ||
export declare const json: JsonFunction; | ||
export declare class DataWithResponseInit<D> { | ||
@@ -437,0 +429,0 @@ type: string; |
@@ -1,2 +0,2 @@ | ||
import type { ActionFunctionArgs, LoaderFunctionArgs } from "./routeModules"; | ||
import type { ActionFunctionArgs, LoaderFunctionArgs } from "../router/utils"; | ||
import type { AssetsManifest, EntryContext, FutureConfig } from "../dom/ssr/entry"; | ||
@@ -3,0 +3,0 @@ import type { ServerRouteManifest } from "./routes"; |
@@ -1,3 +0,3 @@ | ||
import type { CookieParseOptions, CookieSerializeOptions } from "cookie"; | ||
export type { CookieParseOptions, CookieSerializeOptions }; | ||
import type { ParseOptions, SerializeOptions } from "cookie"; | ||
export type { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions, }; | ||
export interface CookieSignatureOptions { | ||
@@ -14,3 +14,3 @@ /** | ||
} | ||
export type CookieOptions = CookieParseOptions & CookieSerializeOptions & CookieSignatureOptions; | ||
export type CookieOptions = ParseOptions & SerializeOptions & CookieSignatureOptions; | ||
/** | ||
@@ -46,3 +46,3 @@ * A HTTP cookie. | ||
*/ | ||
parse(cookieHeader: string | null, options?: CookieParseOptions): Promise<any>; | ||
parse(cookieHeader: string | null, options?: ParseOptions): Promise<any>; | ||
/** | ||
@@ -52,3 +52,3 @@ * Serializes the given value to a string and returns the `Set-Cookie` | ||
*/ | ||
serialize(value: any, options?: CookieSerializeOptions): Promise<string>; | ||
serialize(value: any, options?: SerializeOptions): Promise<string>; | ||
} | ||
@@ -55,0 +55,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import type { ActionFunction, ActionFunctionArgs, LoaderFunction, LoaderFunctionArgs } from "./routeModules"; | ||
import type { LoaderFunction, ActionFunction, LoaderFunctionArgs, ActionFunctionArgs } from "../router/utils"; | ||
/** | ||
@@ -11,6 +11,2 @@ * An object of unknown type for route loaders and actions provided by the | ||
} | ||
/** | ||
* Data for a route that was returned from a `loader()`. | ||
*/ | ||
export type AppData = unknown; | ||
export declare function callRouteHandler(handler: LoaderFunction | ActionFunction, args: LoaderFunctionArgs | ActionFunctionArgs): Promise<{} | Response | null>; |
@@ -1,61 +0,6 @@ | ||
import type { Location } from "../router/history"; | ||
import type { ActionFunction as RRActionFunction, ActionFunctionArgs as RRActionFunctionArgs, AgnosticRouteMatch, LoaderFunction as RRLoaderFunction, LoaderFunctionArgs as RRLoaderFunctionArgs, Params } from "../router/utils"; | ||
import type { AppData, AppLoadContext } from "./data"; | ||
import type { SerializeFrom } from "../dom/ssr/components"; | ||
import type { LinkDescriptor } from "../router/links"; | ||
import type { ActionFunction, LoaderFunction } from "../router/utils"; | ||
import type { ClientActionFunction, ClientLoaderFunction, LinksFunction, MetaFunction } from "../dom/ssr/routeModules"; | ||
export interface RouteModules<RouteModule> { | ||
[routeId: string]: RouteModule | undefined; | ||
} | ||
/** | ||
* @deprecated Use `LoaderFunctionArgs`/`ActionFunctionArgs` instead | ||
*/ | ||
export type DataFunctionArgs = RRActionFunctionArgs<AppLoadContext> & RRLoaderFunctionArgs<AppLoadContext> & { | ||
context: AppLoadContext; | ||
}; | ||
/** | ||
* A function that handles data mutations for a route on the server | ||
*/ | ||
export type ActionFunction = (args: ActionFunctionArgs) => ReturnType<RRActionFunction>; | ||
/** | ||
* Arguments passed to a route `action` function | ||
*/ | ||
export type ActionFunctionArgs = RRActionFunctionArgs<AppLoadContext> & { | ||
context: AppLoadContext; | ||
}; | ||
/** | ||
* A function that handles data mutations for a route on the client | ||
* @private Public API is exported from @react-router/react | ||
*/ | ||
type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType<RRActionFunction>; | ||
/** | ||
* Arguments passed to a route `clientAction` function | ||
* @private Public API is exported from @react-router/react | ||
*/ | ||
export type ClientActionFunctionArgs = RRActionFunctionArgs<undefined> & { | ||
serverAction: <T = AppData>() => Promise<SerializeFrom<T>>; | ||
}; | ||
/** | ||
* A function that loads data for a route on the server | ||
*/ | ||
export type LoaderFunction = (args: LoaderFunctionArgs) => ReturnType<RRLoaderFunction>; | ||
/** | ||
* Arguments passed to a route `loader` function | ||
*/ | ||
export type LoaderFunctionArgs = RRLoaderFunctionArgs<AppLoadContext> & { | ||
context: AppLoadContext; | ||
}; | ||
/** | ||
* A function that loads data for a route on the client | ||
* @private Public API is exported from @react-router/react | ||
*/ | ||
type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType<RRLoaderFunction>) & { | ||
hydrate?: boolean; | ||
}; | ||
/** | ||
* Arguments passed to a route `clientLoader` function | ||
* @private Public API is exported from @react-router/react | ||
*/ | ||
export type ClientLoaderFunctionArgs = RRLoaderFunctionArgs<undefined> & { | ||
serverLoader: <T = AppData>() => Promise<SerializeFrom<T>>; | ||
}; | ||
export type HeadersArgs = { | ||
@@ -75,118 +20,2 @@ loaderHeaders: Headers; | ||
/** | ||
* A function that defines `<link>` tags to be inserted into the `<head>` of | ||
* the document on route transitions. | ||
*/ | ||
export interface LinksFunction { | ||
(): LinkDescriptor[]; | ||
} | ||
/** | ||
* A function that returns an array of data objects to use for rendering | ||
* metadata HTML tags in a route. These tags are not rendered on descendant | ||
* routes in the route hierarchy. In other words, they will only be rendered on | ||
* the route in which they are exported. | ||
* | ||
* @param Loader - The type of the current route's loader function | ||
* @param MatchLoaders - Mapping from a parent route's filepath to its loader | ||
* function type | ||
* | ||
* Note that parent route filepaths are relative to the `app/` directory. | ||
* | ||
* For example, if this meta function is for `/sales/customers/$customerId`: | ||
* | ||
* ```ts | ||
* // app/root.tsx | ||
* const loader = () => { | ||
* return json({ hello: "world" } as const) | ||
* } | ||
* export type Loader = typeof loader | ||
* | ||
* // app/routes/sales.tsx | ||
* const loader = () => { | ||
* return json({ salesCount: 1074 }) | ||
* } | ||
* export type Loader = typeof loader | ||
* | ||
* // app/routes/sales/customers.tsx | ||
* const loader = () => { | ||
* return json({ customerCount: 74 }) | ||
* } | ||
* export type Loader = typeof loader | ||
* | ||
* // app/routes/sales/customers/$customersId.tsx | ||
* import type { Loader as RootLoader } from "../../../root" | ||
* import type { Loader as SalesLoader } from "../../sales" | ||
* import type { Loader as CustomersLoader } from "../../sales/customers" | ||
* | ||
* const loader = () => { | ||
* return json({ name: "Customer name" }) | ||
* } | ||
* | ||
* const meta: MetaFunction<typeof loader, { | ||
* "root": RootLoader, | ||
* "routes/sales": SalesLoader, | ||
* "routes/sales/customers": CustomersLoader, | ||
* }> = ({ data, matches }) => { | ||
* const { name } = data | ||
* // ^? string | ||
* const { customerCount } = matches.find((match) => match.id === "routes/sales/customers").data | ||
* // ^? number | ||
* const { salesCount } = matches.find((match) => match.id === "routes/sales").data | ||
* // ^? number | ||
* const { hello } = matches.find((match) => match.id === "root").data | ||
* // ^? "world" | ||
* } | ||
* ``` | ||
*/ | ||
export interface ServerRuntimeMetaFunction<Loader extends LoaderFunction | unknown = unknown, ParentsLoaders extends Record<string, LoaderFunction | unknown> = Record<string, unknown>> { | ||
(args: ServerRuntimeMetaArgs<Loader, ParentsLoaders>): ServerRuntimeMetaDescriptor[]; | ||
} | ||
interface ServerRuntimeMetaMatch<RouteId extends string = string, Loader extends LoaderFunction | unknown = unknown> { | ||
id: RouteId; | ||
pathname: AgnosticRouteMatch["pathname"]; | ||
data: Loader extends LoaderFunction ? SerializeFrom<Loader> : unknown; | ||
handle?: RouteHandle; | ||
params: AgnosticRouteMatch["params"]; | ||
meta: ServerRuntimeMetaDescriptor[]; | ||
error?: unknown; | ||
} | ||
type ServerRuntimeMetaMatches<MatchLoaders extends Record<string, LoaderFunction | unknown> = Record<string, unknown>> = Array<{ | ||
[K in keyof MatchLoaders]: ServerRuntimeMetaMatch<Exclude<K, number | symbol>, MatchLoaders[K]>; | ||
}[keyof MatchLoaders]>; | ||
export interface ServerRuntimeMetaArgs<Loader extends LoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | unknown> = Record<string, unknown>> { | ||
data: (Loader extends LoaderFunction ? SerializeFrom<Loader> : AppData) | undefined; | ||
params: Params; | ||
location: Location; | ||
matches: ServerRuntimeMetaMatches<MatchLoaders>; | ||
error?: unknown; | ||
} | ||
export type ServerRuntimeMetaDescriptor = { | ||
charSet: "utf-8"; | ||
} | { | ||
title: string; | ||
} | { | ||
name: string; | ||
content: string; | ||
} | { | ||
property: string; | ||
content: string; | ||
} | { | ||
httpEquiv: string; | ||
content: string; | ||
} | { | ||
"script:ld+json": LdJsonObject; | ||
} | { | ||
tagName: "meta" | "link"; | ||
[name: string]: string; | ||
} | { | ||
[name: string]: unknown; | ||
}; | ||
type LdJsonObject = { | ||
[Key in string]: LdJsonValue; | ||
} & { | ||
[Key in string]?: LdJsonValue | undefined; | ||
}; | ||
type LdJsonArray = LdJsonValue[] | readonly LdJsonValue[]; | ||
type LdJsonPrimitive = string | number | boolean | null; | ||
type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray; | ||
/** | ||
* An arbitrary object that is associated with a route. | ||
@@ -204,3 +33,3 @@ */ | ||
links?: LinksFunction; | ||
meta?: ServerRuntimeMetaFunction; | ||
meta?: MetaFunction; | ||
} | ||
@@ -214,2 +43,1 @@ export interface ServerRouteModule extends EntryRouteModule { | ||
} | ||
export {}; |
@@ -1,26 +0,6 @@ | ||
import type { AgnosticDataRouteObject } from "../router/utils"; | ||
import type { AgnosticDataRouteObject, RouteManifest } from "../router/utils"; | ||
import type { FutureConfig } from "../dom/ssr/entry"; | ||
import type { Route } from "../dom/ssr/routes"; | ||
import type { ServerRouteModule } from "./routeModules"; | ||
export interface RouteManifest<Route> { | ||
[routeId: string]: Route; | ||
} | ||
export type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>; | ||
export interface Route { | ||
index?: boolean; | ||
caseSensitive?: boolean; | ||
id: string; | ||
parentId?: string; | ||
path?: string; | ||
} | ||
export interface EntryRoute extends Route { | ||
hasAction: boolean; | ||
hasLoader: boolean; | ||
hasClientAction: boolean; | ||
hasClientLoader: boolean; | ||
hasErrorBoundary: boolean; | ||
imports?: string[]; | ||
css?: string[]; | ||
module: string; | ||
parentId?: string; | ||
} | ||
export interface ServerRoute extends Route { | ||
@@ -27,0 +7,0 @@ children: ServerRoute[]; |
@@ -1,2 +0,2 @@ | ||
import type { CookieParseOptions, CookieSerializeOptions } from "cookie"; | ||
import type { ParseOptions, SerializeOptions } from "cookie"; | ||
import type { Cookie, CookieOptions } from "./cookies"; | ||
@@ -86,3 +86,3 @@ /** | ||
*/ | ||
getSession: (cookieHeader?: string | null, options?: CookieParseOptions) => Promise<Session<Data, FlashData>>; | ||
getSession: (cookieHeader?: string | null, options?: ParseOptions) => Promise<Session<Data, FlashData>>; | ||
/** | ||
@@ -92,3 +92,3 @@ * Stores all data in the Session and returns the Set-Cookie header to be | ||
*/ | ||
commitSession: (session: Session<Data, FlashData>, options?: CookieSerializeOptions) => Promise<string>; | ||
commitSession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>; | ||
/** | ||
@@ -98,3 +98,3 @@ * Deletes all data associated with the Session and returns the Set-Cookie | ||
*/ | ||
destroySession: (session: Session<Data, FlashData>, options?: CookieSerializeOptions) => Promise<string>; | ||
destroySession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>; | ||
} | ||
@@ -101,0 +101,0 @@ /** |
@@ -0,5 +1,4 @@ | ||
import type { ClientLoaderFunctionArgs, ClientActionFunctionArgs } from "./dom/ssr/routeModules"; | ||
import type { DataWithResponseInit } from "./router/utils"; | ||
import type { AppLoadContext } from "./server-runtime/data"; | ||
import type { Jsonify } from "./server-runtime/jsonify"; | ||
import type { TypedResponse } from "./server-runtime/responses"; | ||
import type { Serializable } from "./server-runtime/single-fetch"; | ||
@@ -22,4 +21,4 @@ export type Expect<T extends true> = T; | ||
type DataFrom<T> = IsAny<T> extends true ? undefined : T extends Fn ? VoidToUndefined<Awaited<ReturnType<T>>> : undefined; | ||
type ClientData<T> = T extends TypedResponse<infer U> ? Jsonify<U> : T extends DataWithResponseInit<infer U> ? U : T; | ||
type ServerData<T> = T extends TypedResponse<infer U> ? Jsonify<U> : T extends DataWithResponseInit<infer U> ? Serialize<U> : Serialize<T>; | ||
type ClientData<T> = T extends DataWithResponseInit<infer U> ? U : T; | ||
type ServerData<T> = T extends DataWithResponseInit<infer U> ? Serialize<U> : Serialize<T>; | ||
type ServerDataFrom<T> = ServerData<DataFrom<T>>; | ||
@@ -47,16 +46,24 @@ type ClientDataFrom<T> = ClientData<DataFrom<T>>; | ||
] extends [true, true] ? ServerActionData | ClientActionData : IsDefined<ClientActionData> extends true ? ClientActionData : IsDefined<ServerActionData> extends true ? ServerActionData : undefined>; | ||
type DataFunctionArgs<Params> = { | ||
type ClientDataFunctionArgs<Params> = { | ||
request: Request; | ||
params: Params; | ||
context?: AppLoadContext; | ||
}; | ||
type ServerDataFunctionArgs<Params> = ClientDataFunctionArgs<Params> & { | ||
context: AppLoadContext; | ||
}; | ||
type Serialize<T> = T extends Serializable ? T : T extends (...args: any[]) => unknown ? undefined : T extends Promise<infer U> ? Promise<Serialize<U>> : T extends Map<infer K, infer V> ? Map<Serialize<K>, Serialize<V>> : T extends Set<infer U> ? Set<Serialize<U>> : T extends [] ? [] : T extends readonly [infer F, ...infer R] ? [Serialize<F>, ...Serialize<R>] : T extends Array<infer U> ? Array<Serialize<U>> : T extends readonly unknown[] ? readonly Serialize<T[number]>[] : T extends Record<any, any> ? { | ||
[K in keyof T]: Serialize<T[K]>; | ||
} : undefined; | ||
export type CreateServerLoaderArgs<Params> = DataFunctionArgs<Params>; | ||
export type CreateClientLoaderArgs<Params, T extends RouteModule> = DataFunctionArgs<Params> & { | ||
/** | ||
* @deprecated Generics on data APIs such as `useLoaderData`, `useActionData`, | ||
* `meta`, etc. are deprecated in favor of the `Route.*` types generated via | ||
* `react-router typegen` | ||
*/ | ||
export type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [ClientLoaderFunctionArgs | ClientActionFunctionArgs] ? ClientData<DataFrom<T>> : ServerData<DataFrom<T>> : T; | ||
export type CreateServerLoaderArgs<Params> = ServerDataFunctionArgs<Params>; | ||
export type CreateClientLoaderArgs<Params, T extends RouteModule> = ClientDataFunctionArgs<Params> & { | ||
serverLoader: () => Promise<ServerDataFrom<T["loader"]>>; | ||
}; | ||
export type CreateServerActionArgs<Params> = DataFunctionArgs<Params>; | ||
export type CreateClientActionArgs<Params, T extends RouteModule> = DataFunctionArgs<Params> & { | ||
export type CreateServerActionArgs<Params> = ServerDataFunctionArgs<Params>; | ||
export type CreateClientActionArgs<Params, T extends RouteModule> = ClientDataFunctionArgs<Params> & { | ||
serverAction: () => Promise<ServerDataFrom<T["action"]>>; | ||
@@ -63,0 +70,0 @@ }; |
/** | ||
* React Router v7.0.0-pre.1 | ||
* React Router v7.0.0-pre.2 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* React Router v7.0.0-pre.1 | ||
* React Router v7.0.0-pre.2 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* React Router v7.0.0-pre.1 | ||
* React Router v7.0.0-pre.2 | ||
* | ||
@@ -84,3 +84,3 @@ * Copyright (c) Remix Software Inc. | ||
// * or doesn't have a server loader and we have no data to render | ||
if (route && UNSAFE_shouldHydrateRouteLoader(manifestRoute, route, ssrInfo.context.isSpaMode) && (route.HydrateFallback || !manifestRoute.hasLoader)) { | ||
if (route && manifestRoute && UNSAFE_shouldHydrateRouteLoader(manifestRoute, route, ssrInfo.context.isSpaMode) && (route.HydrateFallback || !manifestRoute.hasLoader)) { | ||
delete hydrationData.loaderData[routeId]; | ||
@@ -87,0 +87,0 @@ } else if (manifestRoute && !manifestRoute.hasLoader) { |
/** | ||
* React Router v7.0.0-pre.1 | ||
* React Router v7.0.0-pre.2 | ||
* | ||
@@ -11,3 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
*/ | ||
import*as e from"react";import*as t from"react-dom";import{UNSAFE_invariant as o,UNSAFE_useFogOFWarDiscovery as r,UNSAFE_FrameworkContext as a,UNSAFE_RemixErrorBoundary as i,UNSAFE_decodeViaTurboStream as n,UNSAFE_createClientRoutes as s,matchRoutes as u,UNSAFE_shouldHydrateRouteLoader as c,UNSAFE_deserializeErrors as d,UNSAFE_createRouter as l,UNSAFE_createBrowserHistory as m,UNSAFE_mapRouteProperties as f,UNSAFE_getSingleFetchDataStrategy as w,UNSAFE_getPatchRoutesOnNavigationFunction as x,UNSAFE_createClientRoutesWithHMRRevalidationOptOut as M,RouterProvider as R}from"react-router";let p=null,g=null;function _(){if(!p&&window.__reactRouterContext&&window.__reactRouterManifest&&window.__reactRouterRouteModules&&(p={context:window.__reactRouterContext,manifest:window.__reactRouterManifest,routeModules:window.__reactRouterRouteModules,stateDecodingPromise:void 0,router:void 0,routerInitialized:!1}),!p)throw new Error("You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`");let e=p;if(!p.stateDecodingPromise){let t=p.context.stream;t||o(!1),p.context.stream=void 0,p.stateDecodingPromise=n(t,window).then((t=>{p.context.state=t.value,e.stateDecodingPromise.value=!0})).catch((t=>{e.stateDecodingPromise.error=t}))}if(p.stateDecodingPromise.error)throw p.stateDecodingPromise.error;if(!p.stateDecodingPromise.value)throw p.stateDecodingPromise;let t,r=s(p.manifest.routes,p.routeModules,p.context.state,p.context.isSpaMode);if(!p.context.isSpaMode){t={...p.context.state,loaderData:{...p.context.state.loaderData}};let e=u(r,window.location,window.__reactRouterContext?.basename);if(e)for(let o of e){let e=o.route.id,r=p.routeModules[e],a=p.manifest.routes[e];r&&c(a,r,p.context.isSpaMode)&&(r.HydrateFallback||!a.hasLoader)?delete t.loaderData[e]:a&&!a.hasLoader&&(t.loaderData[e]=null)}t&&t.errors&&(t.errors=d(t.errors))}let a=l({routes:r,history:m(),basename:p.context.basename,hydrationData:t,mapRouteProperties:f,dataStrategy:w(p.manifest,p.routeModules,(()=>a)),patchRoutesOnNavigation:x(p.manifest,p.routeModules,p.context.isSpaMode,p.context.basename)});return p.router=a,a.state.initialized&&(p.routerInitialized=!0,a.initialize()),a.createRoutesForHMR=M,window.__reactRouterDataRouter=a,a}function D(){g||(g=_());let[t,n]=e.useState(void 0),[s,u]=e.useState(g.state.location);return e.useLayoutEffect((()=>{p&&p.router&&!p.routerInitialized&&(p.routerInitialized=!0,p.router.initialize())}),[]),e.useLayoutEffect((()=>{if(p&&p.router)return p.router.subscribe((e=>{e.location!==s&&u(e.location)}))}),[s]),p||o(!1),r(g,p.manifest,p.routeModules,p.context.isSpaMode),e.createElement(e.Fragment,null,e.createElement(a.Provider,{value:{manifest:p.manifest,routeModules:p.routeModules,future:p.context.future,criticalCss:t,isSpaMode:p.context.isSpaMode}},e.createElement(i,{location:s},e.createElement(S,{router:g}))),e.createElement(e.Fragment,null))}function S(o){return e.createElement(R,Object.assign({flushSync:t.flushSync},o))}export{D as HydratedRouter,S as RouterProvider}; | ||
import*as e from"react";import*as t from"react-dom";import{UNSAFE_invariant as o,UNSAFE_useFogOFWarDiscovery as r,UNSAFE_FrameworkContext as a,UNSAFE_RemixErrorBoundary as i,UNSAFE_decodeViaTurboStream as n,UNSAFE_createClientRoutes as s,matchRoutes as u,UNSAFE_shouldHydrateRouteLoader as c,UNSAFE_deserializeErrors as d,UNSAFE_createRouter as l,UNSAFE_createBrowserHistory as m,UNSAFE_mapRouteProperties as f,UNSAFE_getSingleFetchDataStrategy as w,UNSAFE_getPatchRoutesOnNavigationFunction as x,UNSAFE_createClientRoutesWithHMRRevalidationOptOut as M,RouterProvider as R}from"react-router";let p=null,g=null;function _(){if(!p&&window.__reactRouterContext&&window.__reactRouterManifest&&window.__reactRouterRouteModules&&(p={context:window.__reactRouterContext,manifest:window.__reactRouterManifest,routeModules:window.__reactRouterRouteModules,stateDecodingPromise:void 0,router:void 0,routerInitialized:!1}),!p)throw new Error("You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`");let e=p;if(!p.stateDecodingPromise){let t=p.context.stream;t||o(!1),p.context.stream=void 0,p.stateDecodingPromise=n(t,window).then((t=>{p.context.state=t.value,e.stateDecodingPromise.value=!0})).catch((t=>{e.stateDecodingPromise.error=t}))}if(p.stateDecodingPromise.error)throw p.stateDecodingPromise.error;if(!p.stateDecodingPromise.value)throw p.stateDecodingPromise;let t,r=s(p.manifest.routes,p.routeModules,p.context.state,p.context.isSpaMode);if(!p.context.isSpaMode){t={...p.context.state,loaderData:{...p.context.state.loaderData}};let e=u(r,window.location,window.__reactRouterContext?.basename);if(e)for(let o of e){let e=o.route.id,r=p.routeModules[e],a=p.manifest.routes[e];r&&a&&c(a,r,p.context.isSpaMode)&&(r.HydrateFallback||!a.hasLoader)?delete t.loaderData[e]:a&&!a.hasLoader&&(t.loaderData[e]=null)}t&&t.errors&&(t.errors=d(t.errors))}let a=l({routes:r,history:m(),basename:p.context.basename,hydrationData:t,mapRouteProperties:f,dataStrategy:w(p.manifest,p.routeModules,(()=>a)),patchRoutesOnNavigation:x(p.manifest,p.routeModules,p.context.isSpaMode,p.context.basename)});return p.router=a,a.state.initialized&&(p.routerInitialized=!0,a.initialize()),a.createRoutesForHMR=M,window.__reactRouterDataRouter=a,a}function D(){g||(g=_());let[t,n]=e.useState(void 0),[s,u]=e.useState(g.state.location);return e.useLayoutEffect((()=>{p&&p.router&&!p.routerInitialized&&(p.routerInitialized=!0,p.router.initialize())}),[]),e.useLayoutEffect((()=>{if(p&&p.router)return p.router.subscribe((e=>{e.location!==s&&u(e.location)}))}),[s]),p||o(!1),r(g,p.manifest,p.routeModules,p.context.isSpaMode),e.createElement(e.Fragment,null,e.createElement(a.Provider,{value:{manifest:p.manifest,routeModules:p.routeModules,future:p.context.future,criticalCss:t,isSpaMode:p.context.isSpaMode}},e.createElement(i,{location:s},e.createElement(S,{router:g}))),e.createElement(e.Fragment,null))}function S(o){return e.createElement(R,Object.assign({flushSync:t.flushSync},o))}export{D as HydratedRouter,S as RouterProvider}; | ||
//# sourceMappingURL=react-router-dom.production.min.js.map |
/** | ||
* React Router v7.0.0-pre.1 | ||
* React Router v7.0.0-pre.2 | ||
* | ||
@@ -120,3 +120,3 @@ * Copyright (c) Remix Software Inc. | ||
// * or doesn't have a server loader and we have no data to render | ||
if (route && reactRouter.UNSAFE_shouldHydrateRouteLoader(manifestRoute, route, ssrInfo.context.isSpaMode) && (route.HydrateFallback || !manifestRoute.hasLoader)) { | ||
if (route && manifestRoute && reactRouter.UNSAFE_shouldHydrateRouteLoader(manifestRoute, route, ssrInfo.context.isSpaMode) && (route.HydrateFallback || !manifestRoute.hasLoader)) { | ||
delete hydrationData.loaderData[routeId]; | ||
@@ -123,0 +123,0 @@ } else if (manifestRoute && !manifestRoute.hasLoader) { |
/** | ||
* React Router v7.0.0-pre.1 | ||
* React Router v7.0.0-pre.2 | ||
* | ||
@@ -11,3 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom"),require("react-router")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","react-router"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactRouterDomExport={},e.React,e.ReactDOM,e.ReactRouter)}(this,(function(e,t,r,o){"use strict";function a(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var i=a(t),n=a(r);function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},u.apply(this,arguments)}let s=null,c=null;function d(){if(!s&&window.__reactRouterContext&&window.__reactRouterManifest&&window.__reactRouterRouteModules&&(s={context:window.__reactRouterContext,manifest:window.__reactRouterManifest,routeModules:window.__reactRouterRouteModules,stateDecodingPromise:void 0,router:void 0,routerInitialized:!1}),!s)throw new Error("You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`");let e=s;if(!s.stateDecodingPromise){let t=s.context.stream;t||o.UNSAFE_invariant(!1),s.context.stream=void 0,s.stateDecodingPromise=o.UNSAFE_decodeViaTurboStream(t,window).then((t=>{s.context.state=t.value,e.stateDecodingPromise.value=!0})).catch((t=>{e.stateDecodingPromise.error=t}))}if(s.stateDecodingPromise.error)throw s.stateDecodingPromise.error;if(!s.stateDecodingPromise.value)throw s.stateDecodingPromise;let t,r=o.UNSAFE_createClientRoutes(s.manifest.routes,s.routeModules,s.context.state,s.context.isSpaMode);if(!s.context.isSpaMode){var a;t=u({},s.context.state,{loaderData:u({},s.context.state.loaderData)});let e=o.matchRoutes(r,window.location,null==(a=window.__reactRouterContext)?void 0:a.basename);if(e)for(let r of e){let e=r.route.id,a=s.routeModules[e],i=s.manifest.routes[e];a&&o.UNSAFE_shouldHydrateRouteLoader(i,a,s.context.isSpaMode)&&(a.HydrateFallback||!i.hasLoader)?delete t.loaderData[e]:i&&!i.hasLoader&&(t.loaderData[e]=null)}t&&t.errors&&(t.errors=o.UNSAFE_deserializeErrors(t.errors))}let i=o.UNSAFE_createRouter({routes:r,history:o.UNSAFE_createBrowserHistory(),basename:s.context.basename,hydrationData:t,mapRouteProperties:o.UNSAFE_mapRouteProperties,dataStrategy:o.UNSAFE_getSingleFetchDataStrategy(s.manifest,s.routeModules,(()=>i)),patchRoutesOnNavigation:o.UNSAFE_getPatchRoutesOnNavigationFunction(s.manifest,s.routeModules,s.context.isSpaMode,s.context.basename)});return s.router=i,i.state.initialized&&(s.routerInitialized=!0,i.initialize()),i.createRoutesForHMR=o.UNSAFE_createClientRoutesWithHMRRevalidationOptOut,window.__reactRouterDataRouter=i,i}function l(e){return i.createElement(o.RouterProvider,u({flushSync:n.flushSync},e))}e.HydratedRouter=function(){c||(c=d());let[e,t]=i.useState(void 0),[r,a]=i.useState(c.state.location);return i.useLayoutEffect((()=>{s&&s.router&&!s.routerInitialized&&(s.routerInitialized=!0,s.router.initialize())}),[]),i.useLayoutEffect((()=>{if(s&&s.router)return s.router.subscribe((e=>{e.location!==r&&a(e.location)}))}),[r]),s||o.UNSAFE_invariant(!1),o.UNSAFE_useFogOFWarDiscovery(c,s.manifest,s.routeModules,s.context.isSpaMode),i.createElement(i.Fragment,null,i.createElement(o.UNSAFE_FrameworkContext.Provider,{value:{manifest:s.manifest,routeModules:s.routeModules,future:s.context.future,criticalCss:e,isSpaMode:s.context.isSpaMode}},i.createElement(o.UNSAFE_RemixErrorBoundary,{location:r},i.createElement(l,{router:c}))),i.createElement(i.Fragment,null))},e.RouterProvider=l,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom"),require("react-router")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","react-router"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactRouterDomExport={},e.React,e.ReactDOM,e.ReactRouter)}(this,(function(e,t,r,o){"use strict";function a(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var i=a(t),n=a(r);function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},u.apply(this,arguments)}let s=null,c=null;function d(){if(!s&&window.__reactRouterContext&&window.__reactRouterManifest&&window.__reactRouterRouteModules&&(s={context:window.__reactRouterContext,manifest:window.__reactRouterManifest,routeModules:window.__reactRouterRouteModules,stateDecodingPromise:void 0,router:void 0,routerInitialized:!1}),!s)throw new Error("You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`");let e=s;if(!s.stateDecodingPromise){let t=s.context.stream;t||o.UNSAFE_invariant(!1),s.context.stream=void 0,s.stateDecodingPromise=o.UNSAFE_decodeViaTurboStream(t,window).then((t=>{s.context.state=t.value,e.stateDecodingPromise.value=!0})).catch((t=>{e.stateDecodingPromise.error=t}))}if(s.stateDecodingPromise.error)throw s.stateDecodingPromise.error;if(!s.stateDecodingPromise.value)throw s.stateDecodingPromise;let t,r=o.UNSAFE_createClientRoutes(s.manifest.routes,s.routeModules,s.context.state,s.context.isSpaMode);if(!s.context.isSpaMode){var a;t=u({},s.context.state,{loaderData:u({},s.context.state.loaderData)});let e=o.matchRoutes(r,window.location,null==(a=window.__reactRouterContext)?void 0:a.basename);if(e)for(let r of e){let e=r.route.id,a=s.routeModules[e],i=s.manifest.routes[e];a&&i&&o.UNSAFE_shouldHydrateRouteLoader(i,a,s.context.isSpaMode)&&(a.HydrateFallback||!i.hasLoader)?delete t.loaderData[e]:i&&!i.hasLoader&&(t.loaderData[e]=null)}t&&t.errors&&(t.errors=o.UNSAFE_deserializeErrors(t.errors))}let i=o.UNSAFE_createRouter({routes:r,history:o.UNSAFE_createBrowserHistory(),basename:s.context.basename,hydrationData:t,mapRouteProperties:o.UNSAFE_mapRouteProperties,dataStrategy:o.UNSAFE_getSingleFetchDataStrategy(s.manifest,s.routeModules,(()=>i)),patchRoutesOnNavigation:o.UNSAFE_getPatchRoutesOnNavigationFunction(s.manifest,s.routeModules,s.context.isSpaMode,s.context.basename)});return s.router=i,i.state.initialized&&(s.routerInitialized=!0,i.initialize()),i.createRoutesForHMR=o.UNSAFE_createClientRoutesWithHMRRevalidationOptOut,window.__reactRouterDataRouter=i,i}function l(e){return i.createElement(o.RouterProvider,u({flushSync:n.flushSync},e))}e.HydratedRouter=function(){c||(c=d());let[e,t]=i.useState(void 0),[r,a]=i.useState(c.state.location);return i.useLayoutEffect((()=>{s&&s.router&&!s.routerInitialized&&(s.routerInitialized=!0,s.router.initialize())}),[]),i.useLayoutEffect((()=>{if(s&&s.router)return s.router.subscribe((e=>{e.location!==r&&a(e.location)}))}),[r]),s||o.UNSAFE_invariant(!1),o.UNSAFE_useFogOFWarDiscovery(c,s.manifest,s.routeModules,s.context.isSpaMode),i.createElement(i.Fragment,null,i.createElement(o.UNSAFE_FrameworkContext.Provider,{value:{manifest:s.manifest,routeModules:s.routeModules,future:s.context.future,criticalCss:e,isSpaMode:s.context.isSpaMode}},i.createElement(o.UNSAFE_RemixErrorBoundary,{location:r},i.createElement(l,{router:c}))),i.createElement(i.Fragment,null))},e.RouterProvider=l,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=react-router-dom.production.min.js.map |
{ | ||
"name": "react-router", | ||
"version": "7.0.0-pre.1", | ||
"version": "7.0.0-pre.2", | ||
"description": "Declarative routing for React", | ||
@@ -44,7 +44,7 @@ "keywords": [ | ||
"@web3-storage/multipart-parser": "^1.0.0", | ||
"cookie": "^0.6.0", | ||
"cookie": "^1.0.1", | ||
"set-cookie-parser": "^2.6.0", | ||
"source-map": "^0.7.3", | ||
"turbo-stream": "2.4.0", | ||
"react-router": "7.0.0-pre.1" | ||
"react-router": "7.0.0-pre.2" | ||
}, | ||
@@ -72,4 +72,4 @@ "devDependencies": { | ||
"engines": { | ||
"node": ">=18.0.0" | ||
"node": ">=20.0.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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 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 too big to display
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6533305
41963
81
94
+ Addedcookie@1.0.1(transitive)
- Removedcookie@0.6.0(transitive)
Updatedcookie@^1.0.1
Updatedreact-router@7.0.0-pre.2