79 lines
No EOL
4.4 KiB
TypeScript
79 lines
No EOL
4.4 KiB
TypeScript
import { d as ErrorDefault$1, i as DefineDataLoaderOptionsBase_DefinedData } from "./createDataLoader-DgP0poyl.cjs";
|
|
import { RouteLocationNormalizedLoaded, RouteMap } from "vue-router";
|
|
import { DataLoaderContextBase, DataLoaderEntryBase, DefineDataLoaderOptionsBase_LaxData, DefineLoaderFn, UseDataLoader } from "unplugin-vue-router/data-loaders";
|
|
|
|
//#region src/data-loaders/defineLoader.d.ts
|
|
|
|
/**
|
|
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version `data` is always defined.
|
|
*
|
|
* @param name - name of the route
|
|
* @param loader - function that returns a promise with the data
|
|
* @param options - options to configure the data loader
|
|
*/
|
|
declare function defineBasicLoader<Name extends keyof RouteMap, Data>(name: Name, loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded<Name>>, options?: DefineDataLoaderOptions_DefinedData): UseDataLoaderBasic_DefinedData<Data>;
|
|
/**
|
|
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version, `data` can be `undefined`.
|
|
*
|
|
* @param name - name of the route
|
|
* @param loader - function that returns a promise with the data
|
|
* @param options - options to configure the data loader
|
|
*/
|
|
declare function defineBasicLoader<Name extends keyof RouteMap, Data>(name: Name, loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded<Name>>, options: DefineDataLoaderOptions_LaxData): UseDataLoaderBasic_LaxData<Data>;
|
|
/**
|
|
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version `data` is always defined.
|
|
*
|
|
* @param loader - function that returns a promise with the data
|
|
* @param options - options to configure the data loader
|
|
*/
|
|
declare function defineBasicLoader<Data>(loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded>, options?: DefineDataLoaderOptions_DefinedData): UseDataLoaderBasic_DefinedData<Data>;
|
|
/**
|
|
* Creates a data loader composable that can be exported by pages to attach the data loading to a route. In this version, `data` can be `undefined`.
|
|
*
|
|
* @param loader - function that returns a promise with the data
|
|
* @param options - options to configure the data loader
|
|
*/
|
|
declare function defineBasicLoader<Data>(loader: DefineLoaderFn<Data, DataLoaderContext, RouteLocationNormalizedLoaded>, options: DefineDataLoaderOptions_LaxData): UseDataLoaderBasic_LaxData<Data>;
|
|
interface DefineDataLoaderOptions_LaxData extends DefineDataLoaderOptionsBase_LaxData {
|
|
/**
|
|
* Key to use for SSR state. This will be used to read the initial data from `initialData`'s object.
|
|
*/
|
|
key?: string;
|
|
}
|
|
interface DefineDataLoaderOptions_DefinedData extends DefineDataLoaderOptionsBase_DefinedData {
|
|
key?: string;
|
|
}
|
|
/**
|
|
* @deprecated use {@link DefineDataLoaderOptions_LaxData} instead
|
|
*/
|
|
type DefineDataLoaderOptions = DefineDataLoaderOptions_LaxData;
|
|
interface DataLoaderContext extends DataLoaderContextBase {}
|
|
/**
|
|
* Symbol used to store the data in the router so it can be retrieved after the initial navigation.
|
|
* @internal
|
|
*/
|
|
declare const SERVER_INITIAL_DATA_KEY: unique symbol;
|
|
/**
|
|
* Initial data generated on server and consumed on client.
|
|
* @internal
|
|
*/
|
|
declare const INITIAL_DATA_KEY: unique symbol;
|
|
declare module 'vue-router' {
|
|
interface Router {
|
|
/**
|
|
* Gives access to the initial state during rendering. Should be set to `false` once it's consumed.
|
|
* @internal
|
|
*/
|
|
[SERVER_INITIAL_DATA_KEY]?: Record<string, unknown> | false;
|
|
[INITIAL_DATA_KEY]?: Record<string, unknown> | false;
|
|
}
|
|
}
|
|
interface UseDataLoaderBasic_LaxData<Data> extends UseDataLoader<Data | undefined, ErrorDefault$1> {}
|
|
/**
|
|
* @deprecated use {@link UseDataLoaderBasic_LaxData} instead
|
|
*/
|
|
type UseDataLoaderBasic<Data> = UseDataLoaderBasic_LaxData<Data>;
|
|
interface UseDataLoaderBasic_DefinedData<Data> extends UseDataLoader<Data, ErrorDefault$1> {}
|
|
interface DataLoaderBasicEntry<TData, TError = unknown, TDataInitial extends TData | undefined = TData | undefined> extends DataLoaderEntryBase<TData, TError, TDataInitial> {}
|
|
//#endregion
|
|
export { type DataLoaderBasicEntry, type DataLoaderContext, type DefineDataLoaderOptions, type DefineDataLoaderOptions_DefinedData, type DefineDataLoaderOptions_LaxData, type UseDataLoaderBasic, type UseDataLoaderBasic_DefinedData, type UseDataLoaderBasic_LaxData, defineBasicLoader }; |