@@ -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
192192 const props = reactive < NuxtDevToolsInspectorProps > ( {
193193 mouse : { x : 0 , y : 0 } ,
194+ hasParent : false ,
194195 matched : undefined ,
195196 } )
196197
@@ -203,33 +204,40 @@ export async function setupDevToolsClient({
203204 component . addEventListener ( 'close' , ( ) => {
204205 props . matched = undefined
205206 inspectorState . isEnabled = false
207+ inspectorState . isVisible = false
206208 } )
207209 component . addEventListener ( 'selectParent' , ( ) => {
208210 const parent = inspectorState . main ?. getParent ( )
209211 if ( parent ) {
210212 inspectorState . main = parent
211213 props . 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 ) => {
217222 const url = ( e as any ) ?. detail ?. [ 0 ]
218223 if ( url )
219- client . hooks . callHook ( 'host:inspector:click' , url )
224+ await client . hooks . callHook ( 'host:inspector:click' , url )
220225 } )
221226
222227 inspectorEvents . on ( 'hover' , ( ) => {
223228 inspectorState . isFocused = false
229+ props . hasParent = ! ! inspectorState . main ?. getParent ( )
224230 } )
225231 inspectorEvents . on ( 'disabled' , ( ) => {
226232 inspectorState . isVisible = false
227233 client ?. hooks . callHook ( 'host:inspector:close' )
228234 } )
229235 inspectorEvents . on ( 'enabled' , ( ) => {
230236 inspectorState . isVisible = true
237+ inspectorState . isEnabled = true
231238 } )
232239 inspectorEvents . on ( 'click' , async ( info , e ) => {
240+ inspectorState . isEnabled = false
233241 inspectorState . isFocused = true
234242 inspectorState . isVisible = true
235243
@@ -246,15 +254,18 @@ export async function setupDevToolsClient({
246254
247255 return inspector = markRaw ( {
248256 isAvailable,
249- isEnabled : toRef ( inspectorState , 'isEnabled ' ) ,
257+ isEnabled : toRef ( inspectorState , 'isVisible ' ) ,
250258 enable : ( ) => {
259+ inspectorState . isVisible = true
251260 inspectorState . isEnabled = true
252261 } ,
253262 disable : ( ) => {
263+ inspectorState . isVisible = false
254264 inspectorState . isEnabled = false
255265 } ,
256266 toggle : ( ) => {
257267 inspectorState . isEnabled = ! inspectorState . isEnabled
268+ inspectorState . isVisible = inspectorState . isEnabled
258269 } ,
259270 } )
260271 }
0 commit comments