vite-plugin-performance 2.0.0 → 2.0.1
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/dist/index.d.mts +35 -8
- package/dist/index.d.ts +35 -8
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,33 +1,51 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @description Vite 插件 hook 名称
|
|
5
|
+
*/
|
|
3
6
|
type PluginHookName = Extract<keyof Plugin, string>;
|
|
7
|
+
/**
|
|
8
|
+
* @description hook 执行上下文
|
|
9
|
+
*/
|
|
4
10
|
interface HookExecutionContext {
|
|
5
11
|
pluginName: string;
|
|
6
12
|
hookName: PluginHookName;
|
|
7
13
|
args: unknown[];
|
|
8
14
|
duration: number;
|
|
9
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* @description 日志输出函数
|
|
18
|
+
*/
|
|
10
19
|
type HookLogger = (message: string, context: HookExecutionContext) => void;
|
|
20
|
+
/**
|
|
21
|
+
* @description 日志格式化函数
|
|
22
|
+
*/
|
|
11
23
|
type HookFormatter = (context: HookExecutionContext) => string;
|
|
24
|
+
/**
|
|
25
|
+
* @description 自定义计时函数
|
|
26
|
+
*/
|
|
12
27
|
type HookClock = () => number;
|
|
13
28
|
interface WrapPluginOptions {
|
|
14
|
-
/**
|
|
29
|
+
/** 仅包裹这些 hooks;传入 `all` 表示包裹插件上的所有函数 hook。 */
|
|
15
30
|
hooks?: PluginHookName[] | 'all';
|
|
16
|
-
/**
|
|
31
|
+
/** 触发日志/通知的最小耗时(毫秒)。 */
|
|
17
32
|
threshold?: number;
|
|
18
|
-
/**
|
|
33
|
+
/** 关闭默认日志输出。 */
|
|
19
34
|
silent?: boolean;
|
|
20
|
-
/**
|
|
35
|
+
/** 自定义日志函数,默认使用 `console.log`。 */
|
|
21
36
|
logger?: HookLogger;
|
|
22
|
-
/**
|
|
37
|
+
/** 自定义日志格式化函数。 */
|
|
23
38
|
formatter?: HookFormatter;
|
|
24
|
-
/**
|
|
39
|
+
/** hook 执行完成后的回调。 */
|
|
25
40
|
onHookExecution?: (context: HookExecutionContext) => void;
|
|
26
|
-
/**
|
|
41
|
+
/** 自定义高精度计时函数。 */
|
|
27
42
|
clock?: HookClock;
|
|
28
|
-
/** @deprecated
|
|
43
|
+
/** @deprecated 兼容旧拼写 */
|
|
29
44
|
slient?: boolean;
|
|
30
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* @description 解析后的插件配置
|
|
48
|
+
*/
|
|
31
49
|
interface ResolvedWrapPluginOptions {
|
|
32
50
|
hooks: PluginHookName[] | 'all';
|
|
33
51
|
threshold: number;
|
|
@@ -38,9 +56,18 @@ interface ResolvedWrapPluginOptions {
|
|
|
38
56
|
clock: HookClock;
|
|
39
57
|
}
|
|
40
58
|
|
|
59
|
+
/**
|
|
60
|
+
* @description 默认需要包裹的插件 hooks
|
|
61
|
+
*/
|
|
41
62
|
declare const DEFAULT_PLUGIN_HOOKS: PluginHookName[];
|
|
63
|
+
/**
|
|
64
|
+
* @description 默认耗时阈值(毫秒)
|
|
65
|
+
*/
|
|
42
66
|
declare const DEFAULT_THRESHOLD = 0;
|
|
43
67
|
|
|
68
|
+
/**
|
|
69
|
+
* @description 解析插件配置并补全默认值
|
|
70
|
+
*/
|
|
44
71
|
declare function resolveOptions(options?: Partial<WrapPluginOptions>): ResolvedWrapPluginOptions;
|
|
45
72
|
|
|
46
73
|
declare function wrapPlugin(maybePlugin: Plugin, options?: Partial<WrapPluginOptions>): Plugin;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,33 +1,51 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @description Vite 插件 hook 名称
|
|
5
|
+
*/
|
|
3
6
|
type PluginHookName = Extract<keyof Plugin, string>;
|
|
7
|
+
/**
|
|
8
|
+
* @description hook 执行上下文
|
|
9
|
+
*/
|
|
4
10
|
interface HookExecutionContext {
|
|
5
11
|
pluginName: string;
|
|
6
12
|
hookName: PluginHookName;
|
|
7
13
|
args: unknown[];
|
|
8
14
|
duration: number;
|
|
9
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* @description 日志输出函数
|
|
18
|
+
*/
|
|
10
19
|
type HookLogger = (message: string, context: HookExecutionContext) => void;
|
|
20
|
+
/**
|
|
21
|
+
* @description 日志格式化函数
|
|
22
|
+
*/
|
|
11
23
|
type HookFormatter = (context: HookExecutionContext) => string;
|
|
24
|
+
/**
|
|
25
|
+
* @description 自定义计时函数
|
|
26
|
+
*/
|
|
12
27
|
type HookClock = () => number;
|
|
13
28
|
interface WrapPluginOptions {
|
|
14
|
-
/**
|
|
29
|
+
/** 仅包裹这些 hooks;传入 `all` 表示包裹插件上的所有函数 hook。 */
|
|
15
30
|
hooks?: PluginHookName[] | 'all';
|
|
16
|
-
/**
|
|
31
|
+
/** 触发日志/通知的最小耗时(毫秒)。 */
|
|
17
32
|
threshold?: number;
|
|
18
|
-
/**
|
|
33
|
+
/** 关闭默认日志输出。 */
|
|
19
34
|
silent?: boolean;
|
|
20
|
-
/**
|
|
35
|
+
/** 自定义日志函数,默认使用 `console.log`。 */
|
|
21
36
|
logger?: HookLogger;
|
|
22
|
-
/**
|
|
37
|
+
/** 自定义日志格式化函数。 */
|
|
23
38
|
formatter?: HookFormatter;
|
|
24
|
-
/**
|
|
39
|
+
/** hook 执行完成后的回调。 */
|
|
25
40
|
onHookExecution?: (context: HookExecutionContext) => void;
|
|
26
|
-
/**
|
|
41
|
+
/** 自定义高精度计时函数。 */
|
|
27
42
|
clock?: HookClock;
|
|
28
|
-
/** @deprecated
|
|
43
|
+
/** @deprecated 兼容旧拼写 */
|
|
29
44
|
slient?: boolean;
|
|
30
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* @description 解析后的插件配置
|
|
48
|
+
*/
|
|
31
49
|
interface ResolvedWrapPluginOptions {
|
|
32
50
|
hooks: PluginHookName[] | 'all';
|
|
33
51
|
threshold: number;
|
|
@@ -38,9 +56,18 @@ interface ResolvedWrapPluginOptions {
|
|
|
38
56
|
clock: HookClock;
|
|
39
57
|
}
|
|
40
58
|
|
|
59
|
+
/**
|
|
60
|
+
* @description 默认需要包裹的插件 hooks
|
|
61
|
+
*/
|
|
41
62
|
declare const DEFAULT_PLUGIN_HOOKS: PluginHookName[];
|
|
63
|
+
/**
|
|
64
|
+
* @description 默认耗时阈值(毫秒)
|
|
65
|
+
*/
|
|
42
66
|
declare const DEFAULT_THRESHOLD = 0;
|
|
43
67
|
|
|
68
|
+
/**
|
|
69
|
+
* @description 解析插件配置并补全默认值
|
|
70
|
+
*/
|
|
44
71
|
declare function resolveOptions(options?: Partial<WrapPluginOptions>): ResolvedWrapPluginOptions;
|
|
45
72
|
|
|
46
73
|
declare function wrapPlugin(maybePlugin: Plugin, options?: Partial<WrapPluginOptions>): Plugin;
|