forked from vuejs/router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinjectionSymbols.ts
65 lines (58 loc) · 1.93 KB
/
injectionSymbols.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { InjectionKey, ComputedRef, Ref } from 'vue'
import { RouteLocationNormalizedLoaded } from './types'
import { Router } from './router'
import { RouteRecordNormalized } from './matcher/types'
export const hasSymbol =
typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'
export const PolySymbol = (name: string) =>
// vr = vue router
hasSymbol
? Symbol(__DEV__ ? '[vue-router]: ' + name : name)
: (__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>>
/**
* 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>
/**
* Allows overriding the router instance returned by `useRouter` in tests. r
* stands for router
*
* @internal
*/
export const routerKey = /*#__PURE__*/ PolySymbol(
__DEV__ ? 'router' : 'r'
) as InjectionKey<Router>
/**
* Allows overriding the current route returned by `useRoute` in tests. rl
* stands for route location
*
* @internal
*/
export const routeLocationKey = /*#__PURE__*/ PolySymbol(
__DEV__ ? 'route location' : 'rl'
) as InjectionKey<RouteLocationNormalizedLoaded>
/**
* Allows overriding the current route used by router-view. Internally this is
* used when the `route` prop is passed.
*
* @internal
*/
export const routerViewLocationKey = /*#__PURE__*/ PolySymbol(
__DEV__ ? 'router view location' : 'rvl'
) as InjectionKey<Ref<RouteLocationNormalizedLoaded>>