@@ -13,7 +13,7 @@ import { setIframeServerContext } from '@vue/devtools-kit'
1313import { createHooks } from 'hookable'
1414import { debounce } from 'perfect-debounce'
1515import { events as inspectorEvents , hasData as inspectorHasData , state as inspectorState } from 'vite-plugin-vue-tracer/client/overlay'
16- import { computed , markRaw , reactive , ref , shallowReactive , shallowRef , toRef , watch } from 'vue'
16+ import { computed , markRaw , nextTick , reactive , ref , shallowReactive , shallowRef , toRef , watch } from 'vue'
1717
1818import { initTimelineMetrics } from '../../function-metrics-helpers'
1919import { settings } from '../../settings'
@@ -191,6 +191,7 @@ export async function setupDevToolsClient({
191191
192192const props = reactive < NuxtDevToolsInspectorProps > ( {
193193mouse : { x : 0 , y : 0 } ,
194+ hasParent : false ,
194195matched : undefined ,
195196} )
196197
@@ -203,33 +204,40 @@ export async function setupDevToolsClient({
203204component . addEventListener ( 'close' , ( ) => {
204205props . matched = undefined
205206inspectorState . isEnabled = false
207+ inspectorState . isVisible = false
206208} )
207209component . addEventListener ( 'selectParent' , ( ) => {
208210const parent = inspectorState . main ?. getParent ( )
209211if ( parent ) {
210212inspectorState . main = parent
211213props . matched = parent
214+ nextTick ( ( ) => {
215+ props . hasParent = ! ! inspectorState . main ?. getParent ( )
216+ } )
212217}
213218} )
214219// eslint-disable-next-line ts/ban-ts-comment
215220// @ts -ignore WebComponent types
216- component . addEventListener ( 'openInEditor' , ( e ) => {
221+ component . addEventListener ( 'openInEditor' , async ( e ) => {
217222const url = ( e as any ) ?. detail ?. [ 0 ]
218223if ( url )
219- client . hooks . callHook ( 'host:inspector:click' , url )
224+ await client . hooks . callHook ( 'host:inspector:click' , url )
220225} )
221226
222227inspectorEvents . on ( 'hover' , ( ) => {
223228inspectorState . isFocused = false
229+ props . hasParent = ! ! inspectorState . main ?. getParent ( )
224230} )
225231inspectorEvents . on ( 'disabled' , ( ) => {
226232inspectorState . isVisible = false
227233client ?. hooks . callHook ( 'host:inspector:close' )
228234} )
229235inspectorEvents . on ( 'enabled' , ( ) => {
230236inspectorState . isVisible = true
237+ inspectorState . isEnabled = true
231238} )
232239inspectorEvents . on ( 'click' , async ( info , e ) => {
240+ inspectorState . isEnabled = false
233241inspectorState . isFocused = true
234242inspectorState . isVisible = true
235243
@@ -246,15 +254,18 @@ export async function setupDevToolsClient({
246254
247255return inspector = markRaw ( {
248256 isAvailable,
249- isEnabled : toRef ( inspectorState , 'isEnabled ' ) ,
257+ isEnabled : toRef ( inspectorState , 'isVisible ' ) ,
250258enable : ( ) => {
259+ inspectorState . isVisible = true
251260inspectorState . isEnabled = true
252261} ,
253262disable : ( ) => {
263+ inspectorState . isVisible = false
254264inspectorState . isEnabled = false
255265} ,
256266toggle : ( ) => {
257267inspectorState . isEnabled = ! inspectorState . isEnabled
268+ inspectorState . isVisible = inspectorState . isEnabled
258269} ,
259270} )
260271}
0 commit comments