viewDepthKey,
routerViewLocationKey,
} from './injectionSymbols'
-import { assign } from './utils'
+import { assign, isBrowser } from './utils'
import { warn } from './warning'
import { isSameRouteRecord } from './location'
route?: RouteLocationNormalized
}
+export interface RouterViewDevtoolsContext
+ extends Pick<RouteLocationMatched, 'path' | 'name' | 'meta'> {
+ depth: number
+}
+
export const RouterViewImpl = /*#__PURE__*/ defineComponent({
name: 'RouterView',
// #674 we manually inherit them
})
)
+ if (
+ (__DEV__ || __FEATURE_PROD_DEVTOOLS__) &&
+ isBrowser &&
+ component.ref
+ ) {
+ // TODO: can display if it's an alias, its props
+ const info: RouterViewDevtoolsContext = {
+ depth,
+ name: matchedRoute.name,
+ path: matchedRoute.path,
+ meta: matchedRoute.meta,
+ }
+
+ const internalInstances = Array.isArray(component.ref)
+ ? component.ref.map(r => r.i)
+ : [component.ref.i]
+
+ internalInstances.forEach(instance => {
+ // @ts-expect-error
+ instance.__vrv_devtools = info
+ })
+ }
+
return (
// pass the vnode to the slot as a prop.
// h and <component :is="..."> both accept vnodes
import { PathParser } from './matcher/pathParserRanker'
import { Router } from './router'
import { UseLinkDevtoolsContext } from './RouterLink'
+import { RouterViewDevtoolsContext } from './RouterView'
import { RouteLocationNormalized } from './types'
import { assign } from './utils'
}
})
- // mark router-link as active
+ // mark router-link as active and display tags on router views
api.on.visitComponentTree(({ treeNode: node, componentInstance }) => {
+ if (componentInstance.__vrv_devtools) {
+ const info =
+ componentInstance.__vrv_devtools as RouterViewDevtoolsContext
+
+ node.tags.push({
+ label: (info.name ? `${info.name.toString()}: ` : '') + info.path,
+ textColor: 0,
+ tooltip: 'This component is rendered by <router-view>',
+ backgroundColor: PINK_500,
+ })
+ }
// if multiple useLink are used
if (Array.isArray(componentInstance.__vrl_devtools)) {
componentInstance.__devtoolsApi = api