| 'false'
}
-type UseLinkOptions = VueUseOptions<RouterLinkOptions>
+export type UseLinkOptions = VueUseOptions<RouterLinkOptions>
// TODO: we could allow currentRoute as a prop to expose `isActive` and
// `isExactActive` behavior should go through an RFC
export type HistoryLocation = string
// pushState clones the state passed and do not accept everything
// it doesn't accept symbols, nor functions as values. It also ignores Symbols as keys
+/**
+ * Allowed variables in HTML5 history state
+ */
type HistoryStateValue =
| string
| number
| HistoryState
| HistoryStateArray
+/**
+ * Allowed HTML history.state
+ */
export interface HistoryState {
[x: number]: HistoryStateValue
[x: string]: HistoryStateValue
export { createWebHistory } from './history/html5'
export { createMemoryHistory } from './history/memory'
export { createWebHashHistory } from './history/hash'
-export { createRouterMatcher } from './matcher'
+export { createRouterMatcher, RouterMatcher } from './matcher'
export {
LocationQuery,
LocationQueryValueRaw,
} from './query'
-export { RouterHistory } from './history/common'
+export { RouterHistory, HistoryState } from './history/common'
export { RouteRecord, RouteRecordNormalized } from './matcher/types'
} from './injectionSymbols'
export {
- RouteMeta,
+ // route location
_RouteLocationBase,
- _RouteRecordBase,
+ LocationAsPath,
+ LocationAsRelativeRaw,
+ RouteQueryAndHash,
RouteLocationRaw,
RouteLocation,
RouteLocationNormalized,
RouteLocationNormalizedLoaded,
- START_LOCATION_NORMALIZED as START_LOCATION,
RouteParams,
+ RouteParamValue,
RouteLocationMatched,
RouteLocationOptions,
+ RouteRecordRedirectOption,
+ // route records
+ _RouteRecordBase,
+ RouteMeta,
+ START_LOCATION_NORMALIZED as START_LOCATION,
+ RouteComponent,
+ // RawRouteComponent,
+ RouteRecordName,
RouteRecordRaw,
NavigationGuard,
NavigationGuardNext,
+ NavigationGuardWithThis,
NavigationHookAfter,
} from './types'
+
export {
createRouter,
Router,
RouterOptions,
- ErrorHandler,
RouterScrollBehavior,
} from './router'
} from './errors'
export { onBeforeRouteLeave, onBeforeRouteUpdate } from './navigationGuards'
-export { RouterLink, useLink, RouterLinkProps } from './RouterLink'
+export {
+ RouterLink,
+ useLink,
+ RouterLinkProps,
+ UseLinkOptions,
+} from './RouterLink'
export { RouterView, RouterViewProps } from './RouterView'
export * from './useApi'
import { warn } from '../warning'
import { assign, noop } from '../utils'
+/**
+ * Internal RouterMatcher
+ *
+ * @internal
+ */
export interface RouterMatcher {
addRoute: (record: RouteRecordRaw, parent?: RouteRecordMatcher) => () => void
removeRoute: {
* Internal type to define an ErrorHandler
* @internal
*/
-export type ErrorHandler = (error: any) => any
+export type _ErrorHandler = (error: any) => any
// resolve, reject arguments of Promise constructor
type OnReadyCallback = [() => void, (reason?: any) => void]
*
* @param handler - error handler to register
*/
- onError(handler: ErrorHandler): () => void
+ onError(handler: _ErrorHandler): () => void
/**
* Returns a Promise that resolves when the router has completed the initial
* navigation, which means it has resolved all async enter hooks and async
// Initialization and Errors
let readyHandlers = useCallbacks<OnReadyCallback>()
- let errorHandlers = useCallbacks<ErrorHandler>()
+ let errorHandlers = useCallbacks<_ErrorHandler>()
let ready: boolean
/**
readonly [P in keyof T]: Immutable<T[P]>
}
+/**
+ * Type to transform a static object into one that allows passing Refs as
+ * values.
+ * @internal
+ */
export type VueUseOptions<T> = {
[k in keyof T]: Ref<T[k]> | T[k] | ComputedRef<T[k]>
}
export type TODO = any
+/**
+ * @internal
+ */
export type RouteParamValue = string
+/**
+ * @internal
+ */
export type RouteParamValueRaw = RouteParamValue | number
export type RouteParams = Record<string, RouteParamValue | RouteParamValue[]>
export type RouteParamsRaw = Record<
RouteParamValueRaw | RouteParamValueRaw[]
>
-// TODO: document, mark as internal and export intermediate types for RouteLocationRaw
+/**
+ * @internal
+ */
export interface RouteQueryAndHash {
query?: LocationQueryRaw
hash?: string
}
+
+/**
+ * @internal
+ */
export interface LocationAsPath {
path: string
}
params?: RouteParams
}
+/**
+ * @internal
+ */
export interface LocationAsRelativeRaw {
name?: RouteRecordName
params?: RouteParamsRaw
matched: RouteRecordNormalized[] // non-enumerable
}
+/**
+ * Allowed Component in {@link RouteLocationMatched}
+ */
export type RouteComponent = Component
+/**
+ * Allowed Component definitions in route records provided by the user
+ */
export type RawRouteComponent = RouteComponent | Lazy<RouteComponent>
+/**
+ * Possible values for a user-defined route record's name
+ */
export type RouteRecordName = string | symbol
/**
*/
export interface RouteMeta extends Record<string | number | symbol, any> {}
+/**
+ * @internal
+ */
export type RouteRecordRedirectOption =
| RouteLocationRaw
| ((to: RouteLocation) => RouteLocationRaw)