import { PrefetchConfigs, PrefetchStrategy } from '../types/prefetch'; import { ResolvedRoute, WithData } from '../types/resolved'; import { HasVueAppStore } from './createVueAppStore'; import { CallbackContextPush, CallbackContextReject, CallbackContextSuccess } from '../types/callbackContext'; import { PropsResult } from '../utilities/props'; import { MaybePromise } from '../types/utilities'; /** * A navigation that was superseded before its values settled. The navigation that replaced it owns the * outcome, so this one reports that it went nowhere rather than a success it never had. */ type RouteValueAbandoned = { status: 'ABANDONED'; }; export type RouteValueResponse = CallbackContextSuccess | CallbackContextPush | CallbackContextReject | RouteValueAbandoned; /** * How a navigation's props and loaders settled. Reported separately because props are what a view renders * with while loaders hold nothing up, so a slow loader must not be what decides when props are known. */ export type RouteValueResponses = { props: Promise; loaders: Promise; }; /** * A link's own bucket of prefetched values, handed to the current navigation when the link is followed and * discarded otherwise. */ export type PrefetchStore = { /** * Computes props for views whose prefetch option matches the given strategy. */ prefetch: (strategy: PrefetchStrategy, route: ResolvedRoute, configs: PrefetchConfigs) => void; /** * Stages the prefetched store for the next navigation to adopt. */ commit: () => void; /** * Abandons what was prefetched and starts over, for a link that now points somewhere else. */ reset: () => void; /** * Abandons what was prefetched, for a link that is gone. */ dispose: () => void; }; export type RouteValueStore = HasVueAppStore & { createPrefetchStore: () => PrefetchStore; setRouteValues: (route: ResolvedRoute) => RouteValueResponses; getProps: (id: string, name: string, route: ResolvedRoute) => MaybePromise; /** * What a route exposes as `data`. Resolved per read rather than captured, so it stays correct as * navigations replace the store its values live in. */ getData: (route: ResolvedRoute) => WithData['data']; }; export declare function createRouteValueStore(): RouteValueStore; export {};