1
+ import { target } from '@vue/devtools-shared'
1
2
import { App , PluginDescriptor , PluginSetupFunction } from '../../types'
2
3
import { hook } from '../../hook'
3
4
import { devtoolsContext , devtoolsPluginBuffer } from '../../ctx'
4
5
import { DevToolsPluginAPI } from '../../api'
5
6
6
7
export * from './components'
7
8
9
+ target . __VUE_DEVTOOLS_KIT__REGISTERED_PLUGIN_APPS__ ??= new Set < App > ( )
10
+
8
11
export function setupDevToolsPlugin ( pluginDescriptor : PluginDescriptor , setupFn : PluginSetupFunction ) {
9
12
return hook . setupDevToolsPlugin ( pluginDescriptor , setupFn )
10
13
}
11
14
12
15
export function callDevToolsPluginSetupFn ( plugin : [ PluginDescriptor , PluginSetupFunction ] , app : App ) {
13
16
const [ pluginDescriptor , setupFn ] = plugin
14
- // @TODO : need check
15
- // if (pluginDescriptor.app !== app)
16
- // return
17
+ if ( pluginDescriptor . app !== app )
18
+ return
17
19
18
20
const api = new DevToolsPluginAPI ( {
19
21
plugin : {
@@ -32,7 +34,17 @@ export function callDevToolsPluginSetupFn(plugin: [PluginDescriptor, PluginSetup
32
34
33
35
setupFn ( api )
34
36
}
37
+
38
+ export function removeRegisteredPluginApp ( app : App ) {
39
+ target . __VUE_DEVTOOLS_KIT__REGISTERED_PLUGIN_APPS__ . delete ( app )
40
+ }
41
+
35
42
export function registerDevToolsPlugin ( app : App ) {
43
+ if ( target . __VUE_DEVTOOLS_KIT__REGISTERED_PLUGIN_APPS__ . has ( app ) )
44
+ return
45
+
46
+ target . __VUE_DEVTOOLS_KIT__REGISTERED_PLUGIN_APPS__ . add ( app )
47
+
36
48
devtoolsPluginBuffer . forEach ( ( plugin ) => {
37
49
callDevToolsPluginSetupFn ( plugin , app )
38
50
} )
0 commit comments