import type { ComponentType, ReactElement } from "react"; import type { ActionFunction as RRActionFunction, ActionFunctionArgs as RRActionFunctionArgs, LoaderFunction as RRLoaderFunction, LoaderFunctionArgs as RRLoaderFunctionArgs, DataRouteMatch, Params, Location, ShouldRevalidateFunction } from "react-router-dom"; import type { LoaderFunction, SerializeFrom } from "@remix-run/server-runtime"; import type { AppData } from "./data"; import type { LinkDescriptor } from "./links"; import type { EntryRoute } from "./routes"; export interface RouteModules { [routeId: string]: RouteModule | undefined; } export interface RouteModule { clientAction?: ClientActionFunction; clientLoader?: ClientLoaderFunction; ErrorBoundary?: ErrorBoundaryComponent; HydrateFallback?: HydrateFallbackComponent; Layout?: LayoutComponent; default: RouteComponent; handle?: RouteHandle; links?: LinksFunction; meta?: MetaFunction; shouldRevalidate?: ShouldRevalidateFunction; } /** * A function that handles data mutations for a route on the client */ export type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType; /** * Arguments passed to a route `clientAction` function */ export type ClientActionFunctionArgs = RRActionFunctionArgs & { serverAction: () => Promise>; }; /** * A function that loads data for a route on the client */ export type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType) & { hydrate?: boolean; }; /** * Arguments passed to a route `clientLoader` function */ export type ClientLoaderFunctionArgs = RRLoaderFunctionArgs & { serverLoader: () => Promise>; }; /** * ErrorBoundary to display for this route */ export type ErrorBoundaryComponent = ComponentType; /** * `` component to render on initial loads * when client loaders are present */ export type HydrateFallbackComponent = ComponentType; /** * Optional, root-only `` component to wrap the root content in. * Useful for defining the // document shell shared by the * Component, HydrateFallback, and ErrorBoundary */ export type LayoutComponent = ComponentType<{ children: ReactElement; }>; /** * A function that defines `` tags to be inserted into the `` of * the document on route transitions. * * @see https://remix.run/route/meta */ export interface LinksFunction { (): LinkDescriptor[]; } export interface MetaMatch { id: RouteId; pathname: DataRouteMatch["pathname"]; data: Loader extends LoaderFunction ? SerializeFrom : unknown; handle?: RouteHandle; params: DataRouteMatch["params"]; meta: MetaDescriptor[]; error?: unknown; } export type MetaMatches = Record> = Array<{ [K in keyof MatchLoaders]: MetaMatch, MatchLoaders[K]>; }[keyof MatchLoaders]>; export interface MetaArgs = Record> { data: (Loader extends LoaderFunction ? SerializeFrom : AppData) | undefined; params: Params; location: Location; matches: MetaMatches; error?: unknown; } export interface MetaFunction = Record> { (args: MetaArgs): MetaDescriptor[] | undefined; } export type MetaDescriptor = { 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; /** * A React component that is rendered for a route. */ export type RouteComponent = ComponentType<{}>; /** * An arbitrary object that is associated with a route. * * @see https://remix.run/route/handle */ export type RouteHandle = unknown; export declare function loadRouteModule(route: EntryRoute, routeModulesCache: RouteModules): Promise; export {};