(pluginDescriptor: Narrow<TDescriptor>, setupFn: SetupFunction<TSettings>)
| 29 | export type SetupFunction<TSettings = any> = (api: DevtoolsPluginApi<TSettings>) => void |
| 30 | |
| 31 | export 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 | } |
no test coverage detected