-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpsi.d.ts
114 lines (108 loc) · 2.68 KB
/
psi.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* eslint-disable @typescript-eslint/no-explicit-any */
// declare module 'kootDiagnosePSI';
export type Category =
| 'accessibility'
| 'best-practices'
| 'performance'
| 'pwa'
| 'seo';
export interface Result {
lighthouseResult: {
audits: {
[auditId: string]: Audit;
};
categories: {
[categoryId: string]: {
id: string;
title: string;
auditRefs: {
[auditId: number]: {
id: string;
weight: number;
group?: string;
};
};
score: number;
description?: string;
manualDescription?: string;
};
};
categoryGroups: {
[groupId: string]: {
title: string;
description?: string;
};
};
[key: string]: any;
};
[errorType: string]: any;
}
export type AuditDetailsType =
| 'table'
| 'opportunity'
| 'debugdata'
| 'filmstrip';
export type AuditDetailsHeadingType =
| 'text'
| 'url'
| 'timespanMs'
| 'thumbnail'
| 'bytes'
| 'ms'
| 'code';
export interface AuditDetailsHeading {
key: string;
label?: string;
text?: string;
valueType?: AuditDetailsHeadingType;
itemType?: AuditDetailsHeadingType;
displayUnit?: 'duration' | 'kb';
}
export interface Audit {
id: string;
title: string;
description?: string;
score: string;
scoreDisplayMode: string;
numericValue?: number;
displayValue?: string;
details: {
type: AuditDetailsType;
headings?: Array<AuditDetailsHeading>;
items?: Array<{
[key: string]: any;
}>;
overallSavingsMs?: number;
overallSavingsBytes?: number;
summary?: {
[summaryKey: string]: any;
};
scale?: number;
[detail: string]: any;
};
warnings?: Array<any>;
}
/**
* 对目标域名的首页进行 PageSpeed Insights 检测
*/
async function psi(
url: string | URL,
/**
* Google PageSpeed API Key
* - 如果提供,检测时会使用该 Key 进行请求
*/
apiKey?: string,
/**
* Google PageSpeed API 参数
* https://developers.google.com/speed/docs/insights/v5/reference/pagespeedapi/runpagespeed#parameters
*/
parameters: {
category?: Category | Category[];
locale?: string;
strategy?: 'desktop' | 'mobile';
utm_campaign?: string;
utm_source?: string;
[errorType: string]: any;
} = {}
): Promise<Result>;
export default psi;