Skip to content

Commit

Permalink
feat: expose symbols as internals
Browse files Browse the repository at this point in the history
Allow integration for testing utils and other library-level integrations with vue router. These are marked as internal and should not be used by unofficial integrations as they could change at any time.
  • Loading branch information
posva committed Nov 20, 2020
1 parent fb72ccc commit ef62d96
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ export {
_PathParserOptions,
} from './matcher/pathParserRanker'

export { routeLocationKey, routerKey } from './injectionSymbols'
export {
routeLocationKey,
routerKey,
matchedRouteKey,
viewDepthKey,
} from './injectionSymbols'

export {
RouteMeta,
Expand Down
15 changes: 14 additions & 1 deletion src/injectionSymbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,23 @@ export const PolySymbol = (name: string) =>
: (__DEV__ ? '[vue-router]: ' : '_vr_') + name

// rvlm = Router View Location Matched
/**
* RouteRecord being rendered by the closest ancestor Router View. Used for
* `onBeforeRouteUpdate` and `onBeforeRouteLeave`. rvlm stands for Router View
* Location Matched
*
* @internal
*/
export const matchedRouteKey = /*#__PURE__*/ PolySymbol(
__DEV__ ? 'router view location matched' : 'rvlm'
) as InjectionKey<ComputedRef<RouteRecordNormalized | undefined>>
// rvd = Router View Depth

/**
* Allows overriding the router view depth to control which component in
* `matched` is rendered. rvd stands for Router View Depth
*
* @internal
*/
export const viewDepthKey = /*#__PURE__*/ PolySymbol(
__DEV__ ? 'router view depth' : 'rvd'
) as InjectionKey<number>
Expand Down

0 comments on commit ef62d96

Please sign in to comment.