@@ -33,20 +33,21 @@ export function initDevTools() {
3333 if ( target . __VUE_DEVTOOLS_GLOBAL_HOOK__ && isDevToolsNext )
3434 return
3535
36- if ( ! target . __VUE_DEVTOOLS_GLOBAL_HOOK__ ) {
37- target . __VUE_DEVTOOLS_GLOBAL_HOOK__ = createDevToolsHook ( )
38- }
39- else {
40- // respect old devtools hook in nuxt application
41- if ( ! isNuxtApp ) {
42- // override devtools hook directly
43- Object . assign ( __VUE_DEVTOOLS_GLOBAL_HOOK__ , createDevToolsHook ( ) )
36+ const _devtoolsHook = createDevToolsHook ( )
37+
38+ if ( target . __VUE_DEVTOOLS_HOOK_REPLAY__ ) {
39+ try {
40+ target . __VUE_DEVTOOLS_HOOK_REPLAY__ . forEach ( cb => cb ( _devtoolsHook ) )
41+ target . __VUE_DEVTOOLS_HOOK_REPLAY__ = [ ]
42+ }
43+ catch ( e ) {
44+ console . error ( '[vue-devtools] Error during hook replay' , e )
4445 }
4546 }
4647
4748 // @ts -expect-error skip type check
4849 // Vue2 app detection
49- target . __VUE_DEVTOOLS_GLOBAL_HOOK__ . once ( 'init' , ( Vue ) => {
50+ _devtoolsHook . once ( 'init' , ( Vue ) => {
5051 target . __VUE_DEVTOOLS_VUE2_APP_DETECTED__ = true
5152
5253 console . log ( '%c[_____Vue DevTools v7 log_____]' , 'color: red; font-bold: 600; font-size: 16px;' )
@@ -76,7 +77,7 @@ export function initDevTools() {
7677 onLegacyDevToolsPluginApiAvailable ( ( ) => {
7778 const normalizedPluginBuffer = devtoolsPluginBuffer . filter ( ( [ item ] ) => item . id !== 'components' )
7879 normalizedPluginBuffer . forEach ( ( [ pluginDescriptor , setupFn ] ) => {
79- target . __VUE_DEVTOOLS_GLOBAL_HOOK__ . emit ( DevToolsHooks . SETUP_DEVTOOLS_PLUGIN , pluginDescriptor , setupFn , { target : 'legacy' } )
80+ _devtoolsHook . emit ( DevToolsHooks . SETUP_DEVTOOLS_PLUGIN , pluginDescriptor , setupFn , { target : 'legacy' } )
8081 } )
8182 } )
8283
@@ -102,7 +103,7 @@ export function initDevTools() {
102103 connected : true ,
103104 } )
104105
105- target . __VUE_DEVTOOLS_GLOBAL_HOOK__ . apps . push ( app )
106+ _devtoolsHook . apps . push ( app )
106107 } )
107108
108109 hook . on . vueAppUnmount ( async ( app ) => {
@@ -126,7 +127,22 @@ export function initDevTools() {
126127 removeRegisteredPluginApp ( app )
127128 } )
128129
129- subscribeDevToolsHook ( )
130+ subscribeDevToolsHook ( _devtoolsHook )
131+
132+ if ( ! target . __VUE_DEVTOOLS_GLOBAL_HOOK__ ) {
133+ Object . defineProperty ( target , '__VUE_DEVTOOLS_GLOBAL_HOOK__' , {
134+ get ( ) {
135+ return _devtoolsHook
136+ } ,
137+ } )
138+ }
139+ else {
140+ // respect old devtools hook in nuxt application
141+ if ( ! isNuxtApp ) {
142+ // override devtools hook directly
143+ Object . assign ( __VUE_DEVTOOLS_GLOBAL_HOOK__ , _devtoolsHook )
144+ }
145+ }
130146}
131147
132148export function onDevToolsClientConnected ( fn : ( ) => void ) {
0 commit comments