@vue/devtools-api 6.0.2 → 6.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +4 -3
- package/lib/esm/index.d.ts +12 -2
- package/lib/esm/index.js +4 -3
- package/lib/esm/plugin.d.ts +12 -0
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -17,17 +17,18 @@ const proxy_1 = require("./proxy");
|
|
|
17
17
|
__exportStar(require("./api"), exports);
|
|
18
18
|
__exportStar(require("./plugin"), exports);
|
|
19
19
|
function setupDevtoolsPlugin(pluginDescriptor, setupFn) {
|
|
20
|
+
const descriptor = pluginDescriptor;
|
|
20
21
|
const target = (0, env_1.getTarget)();
|
|
21
22
|
const hook = (0, env_1.getDevtoolsGlobalHook)();
|
|
22
|
-
const enableProxy = env_1.isProxyAvailable &&
|
|
23
|
+
const enableProxy = env_1.isProxyAvailable && descriptor.enableEarlyProxy;
|
|
23
24
|
if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) {
|
|
24
25
|
hook.emit(const_1.HOOK_SETUP, pluginDescriptor, setupFn);
|
|
25
26
|
}
|
|
26
27
|
else {
|
|
27
|
-
const proxy = enableProxy ? new proxy_1.ApiProxy(
|
|
28
|
+
const proxy = enableProxy ? new proxy_1.ApiProxy(descriptor, hook) : null;
|
|
28
29
|
const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || [];
|
|
29
30
|
list.push({
|
|
30
|
-
pluginDescriptor,
|
|
31
|
+
pluginDescriptor: descriptor,
|
|
31
32
|
setupFn,
|
|
32
33
|
proxy,
|
|
33
34
|
});
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { DevtoolsPluginApi } from './api';
|
|
2
|
-
import { PluginDescriptor } from './plugin';
|
|
2
|
+
import { PluginDescriptor, ExtractSettingsTypes, PluginSettingsItem } from './plugin';
|
|
3
3
|
export * from './api';
|
|
4
4
|
export * from './plugin';
|
|
5
5
|
export { PluginQueueItem } from './env';
|
|
6
|
+
declare type Cast<A, B> = A extends B ? A : B;
|
|
7
|
+
declare type Narrowable = string | number | bigint | boolean;
|
|
8
|
+
declare type Narrow<A> = Cast<A, [] | (A extends Narrowable ? A : never) | ({
|
|
9
|
+
[K in keyof A]: Narrow<A[K]>;
|
|
10
|
+
})>;
|
|
11
|
+
declare type Exact<C, T> = {
|
|
12
|
+
[K in keyof C]: K extends keyof T ? T[K] : never;
|
|
13
|
+
};
|
|
6
14
|
export declare type SetupFunction<TSettings = any> = (api: DevtoolsPluginApi<TSettings>) => void;
|
|
7
|
-
export declare function setupDevtoolsPlugin<
|
|
15
|
+
export declare function setupDevtoolsPlugin<TDescriptor extends Exact<TDescriptor, PluginDescriptor>, TSettings = ExtractSettingsTypes<TDescriptor extends {
|
|
16
|
+
settings: infer S;
|
|
17
|
+
} ? S extends Record<string, PluginSettingsItem> ? S : Record<string, PluginSettingsItem> : Record<string, PluginSettingsItem>>>(pluginDescriptor: Narrow<TDescriptor>, setupFn: SetupFunction<TSettings>): void;
|
package/lib/esm/index.js
CHANGED
|
@@ -4,17 +4,18 @@ import { ApiProxy } from './proxy';
|
|
|
4
4
|
export * from './api';
|
|
5
5
|
export * from './plugin';
|
|
6
6
|
export function setupDevtoolsPlugin(pluginDescriptor, setupFn) {
|
|
7
|
+
const descriptor = pluginDescriptor;
|
|
7
8
|
const target = getTarget();
|
|
8
9
|
const hook = getDevtoolsGlobalHook();
|
|
9
|
-
const enableProxy = isProxyAvailable &&
|
|
10
|
+
const enableProxy = isProxyAvailable && descriptor.enableEarlyProxy;
|
|
10
11
|
if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) {
|
|
11
12
|
hook.emit(HOOK_SETUP, pluginDescriptor, setupFn);
|
|
12
13
|
}
|
|
13
14
|
else {
|
|
14
|
-
const proxy = enableProxy ? new ApiProxy(
|
|
15
|
+
const proxy = enableProxy ? new ApiProxy(descriptor, hook) : null;
|
|
15
16
|
const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || [];
|
|
16
17
|
list.push({
|
|
17
|
-
pluginDescriptor,
|
|
18
|
+
pluginDescriptor: descriptor,
|
|
18
19
|
setupFn,
|
|
19
20
|
proxy,
|
|
20
21
|
});
|
package/lib/esm/plugin.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface PluginDescriptor {
|
|
|
18
18
|
}
|
|
19
19
|
export declare type PluginSettingsItem = {
|
|
20
20
|
label: string;
|
|
21
|
+
description?: string;
|
|
21
22
|
} & ({
|
|
22
23
|
type: 'boolean';
|
|
23
24
|
defaultValue: boolean;
|
|
@@ -33,3 +34,14 @@ export declare type PluginSettingsItem = {
|
|
|
33
34
|
type: 'text';
|
|
34
35
|
defaultValue: string;
|
|
35
36
|
});
|
|
37
|
+
declare type InferSettingsType<T extends PluginSettingsItem> = [T] extends [{
|
|
38
|
+
type: 'boolean';
|
|
39
|
+
}] ? boolean : [T] extends [{
|
|
40
|
+
type: 'choice';
|
|
41
|
+
}] ? T['options'][number]['value'] : [T] extends [{
|
|
42
|
+
type: 'text';
|
|
43
|
+
}] ? string : unknown;
|
|
44
|
+
export declare type ExtractSettingsTypes<O extends Record<string, PluginSettingsItem>> = {
|
|
45
|
+
[K in keyof O]: InferSettingsType<O[K]>;
|
|
46
|
+
};
|
|
47
|
+
export {};
|