You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
1021 B
27 lines
1021 B
import { getDevtoolsGlobalHook, getTarget, isProxyAvailable } from './env.js';
|
|
import { HOOK_SETUP } from './const.js';
|
|
import { ApiProxy } from './proxy.js';
|
|
export * from './api/index.js';
|
|
export * from './plugin.js';
|
|
export * from './time.js';
|
|
export function setupDevtoolsPlugin(pluginDescriptor, setupFn) {
|
|
const descriptor = pluginDescriptor;
|
|
const target = getTarget();
|
|
const hook = getDevtoolsGlobalHook();
|
|
const enableProxy = isProxyAvailable && descriptor.enableEarlyProxy;
|
|
if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) {
|
|
hook.emit(HOOK_SETUP, pluginDescriptor, setupFn);
|
|
}
|
|
else {
|
|
const proxy = enableProxy ? new ApiProxy(descriptor, hook) : null;
|
|
const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || [];
|
|
list.push({
|
|
pluginDescriptor: descriptor,
|
|
setupFn,
|
|
proxy,
|
|
});
|
|
if (proxy) {
|
|
setupFn(proxy.proxiedTarget);
|
|
}
|
|
}
|
|
}
|