1
1
import type { VueAppInstance } from '@vue/devtools-schema'
2
+ import { debounce } from 'perfect-debounce'
2
3
import { setupDevToolsPlugin } from '../../api/plugin'
3
4
import { getAppRecord , getComponentId , getComponentInstance } from '../component/general'
4
5
import { devtoolsContext } from '../general/state'
@@ -84,6 +85,14 @@ export function registerComponentsDevTools(app: VueAppInstance) {
84
85
}
85
86
} )
86
87
88
+ const debounceSendInspectorTree = debounce ( ( ) => {
89
+ api . sendInspectorTree ( INSPECTOR_ID )
90
+ } , 120 )
91
+
92
+ const debounceSendInspectorState = debounce ( ( ) => {
93
+ api . sendInspectorState ( INSPECTOR_ID )
94
+ } , 120 )
95
+
87
96
const componentAddedCleanup = hook . on . componentAdded ( async ( app , uid , parentUid , component ) => {
88
97
if ( app ?. _instance ?. type ?. devtools ?. hide )
89
98
return
@@ -109,7 +118,7 @@ export function registerComponentsDevTools(app: VueAppInstance) {
109
118
if ( ! appRecord )
110
119
return
111
120
112
- api . sendInspectorTree ( INSPECTOR_ID )
121
+ debounceSendInspectorTree ( )
113
122
} )
114
123
115
124
const componentUpdatedCleanup = hook . on . componentUpdated ( async ( app , uid , parentUid , component ) => {
@@ -137,8 +146,8 @@ export function registerComponentsDevTools(app: VueAppInstance) {
137
146
if ( ! appRecord )
138
147
return
139
148
140
- api . sendInspectorTree ( INSPECTOR_ID )
141
- api . sendInspectorState ( INSPECTOR_ID )
149
+ debounceSendInspectorTree ( )
150
+ debounceSendInspectorState ( )
142
151
} )
143
152
const componentRemovedCleanup = hook . on . componentRemoved ( async ( app , uid , parentUid , component ) => {
144
153
if ( app ?. _instance ?. type ?. devtools ?. hide )
@@ -159,7 +168,7 @@ export function registerComponentsDevTools(app: VueAppInstance) {
159
168
} ) as string
160
169
appRecord ?. instanceMap . delete ( id )
161
170
162
- api . sendInspectorTree ( INSPECTOR_ID )
171
+ debounceSendInspectorTree ( )
163
172
} )
164
173
devtoolsContext . componentPluginHookBuffer = [
165
174
componentAddedCleanup ,
0 commit comments