MCPcopy
hub / github.com/vuejs/devtools-v6 / setupDevtoolsPlugin

Function setupDevtoolsPlugin

packages/api/src/index.ts:31–56  ·  view source on GitHub ↗
(pluginDescriptor: Narrow<TDescriptor>, setupFn: SetupFunction<TSettings>)

Source from the content-addressed store, hash-verified

29export type SetupFunction<TSettings = any> = (api: DevtoolsPluginApi<TSettings>) => void
30
31export function setupDevtoolsPlugin<
32 TDescriptor extends Exact<TDescriptor, PluginDescriptor>,
33 TSettings = ExtractSettingsTypes<TDescriptor extends { settings: infer S } ? S extends Record<string, PluginSettingsItem> ? S : Record<string, PluginSettingsItem> : Record<string, PluginSettingsItem>>,
34>(pluginDescriptor: Narrow<TDescriptor>, setupFn: SetupFunction<TSettings>) {
35 const descriptor = pluginDescriptor as unknown as PluginDescriptor
36 const target = getTarget()
37 const hook = getDevtoolsGlobalHook()
38 const enableProxy = isProxyAvailable && descriptor.enableEarlyProxy
39 if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) {
40 hook.emit(HOOK_SETUP, pluginDescriptor, setupFn)
41 }
42 else {
43 const proxy = enableProxy ? new ApiProxy(descriptor, hook) : null
44
45 const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || []
46 list.push({
47 pluginDescriptor: descriptor,
48 setupFn,
49 proxy,
50 })
51
52 if (proxy) {
53 setupFn(proxy.proxiedTarget as DevtoolsPluginApi<TSettings>)
54 }
55 }
56}

Callers 3

simple.jsFile · 0.85
index.jsFile · 0.85
setupPluginFunction · 0.85

Calls 2

getTargetFunction · 0.85
getDevtoolsGlobalHookFunction · 0.85

Tested by

no test coverage detected