import { ResolvedRoute } from './resolved'; import { CreatedRouteOptions, Route } from './route'; import { RouteContextToRejection, RouteContextToRoute } from './routeContext'; import { RouterPush } from './routerPush'; import { RouterReject } from './routerReject'; import { RouterReplace } from './routerReplace'; import { RouteUpdate } from './routeUpdate'; import { LoadersDataReturnType } from './routeLoaders'; import { ViewsPropsReturnType } from './routeViews'; /** * Context provided to a callback attached to a route — an `addView` props getter, or a loader. Sourced * from the route: rejections/routes from the route's context, and the parent from the route's `matches`. */ export type RouteCallbackContext = { reject: RouterReject>; push: RouterPush<[TRoute] | RouteContextToRoute>; replace: RouterReplace<[TRoute] | RouteContextToRoute>; update: RouteUpdate>; parent: RouteCallbackParent; }; /** * The parent context ({ name, props, data }) reconstructed from the second-to-last `matches` entry, which * carries the parent's name, its views and its loaders. */ type RouteCallbackParent = TRoute['matches'] extends [...CreatedRouteOptions[], infer TParent extends CreatedRouteOptions, CreatedRouteOptions] ? { name: TParent['name']; props: ViewsPropsReturnType; data: LoadersDataReturnType; } : undefined; export {};