-
Notifications
You must be signed in to change notification settings - Fork 9.3k
/
config.d.ts
132 lines (113 loc) · 4.43 KB
/
config.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/**
* @license Copyright 2018 The Lighthouse Authors. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
import Audit = require('../lighthouse-core/audits/audit.js');
interface ClassOf<T> {
new (): T;
}
declare global {
module LH {
module Config {
/**
* The pre-normalization Lighthouse Config format.
*/
export interface Json {
extends?: 'lighthouse:default' | string | boolean;
settings?: SharedFlagsSettings;
passes?: PassJson[] | null;
audits?: Config.AuditJson[] | null;
categories?: Record<string, CategoryJson> | null;
groups?: Record<string, Config.GroupJson> | null;
plugins?: Array<string>,
}
export interface PassJson {
passName: string;
loadFailureMode?: 'fatal'|'warn'|'ignore';
recordTrace?: boolean;
useThrottling?: boolean;
pauseAfterFcpMs?: number;
pauseAfterLoadMs?: number;
networkQuietThresholdMs?: number;
cpuQuietThresholdMs?: number;
blockedUrlPatterns?: string[];
blankPage?: string;
gatherers?: GathererJson[];
}
export type GathererJson = {
path: string;
options?: {};
} | {
implementation: ClassOf<Gatherer.GathererInstance>;
options?: {};
} | {
instance: Gatherer.GathererInstance;
options?: {};
} | Gatherer.GathererInstance | ClassOf<Gatherer.GathererInstance> | string;
export interface CategoryJson {
title: string | IcuMessage;
auditRefs: AuditRefJson[];
description?: string | IcuMessage;
manualDescription?: string | IcuMessage;
}
export interface GroupJson {
title: string | IcuMessage;
description?: string | IcuMessage;
}
export type AuditJson = {
path: string,
options?: {};
} | {
implementation: typeof Audit;
options?: {};
} | typeof Audit | string;
/**
* Reference to an audit member of a category and how its score should be
* weighted and how its results grouped with other members.
*/
export interface AuditRefJson {
id: string;
weight: number;
group?: string;
}
export interface Settings extends Required<SharedFlagsSettings> {
throttling: Required<ThrottlingSettings>;
}
export interface Pass extends Required<PassJson> {
gatherers: GathererDefn[];
}
export interface GathererDefn {
implementation?: ClassOf<Gatherer.GathererInstance>;
instance: Gatherer.GathererInstance;
path?: string;
}
export interface AuditDefn {
implementation: typeof Audit;
path?: string;
options: {};
}
// TODO: For now, these are unchanged from JSON and Result versions. Need to harmonize.
export interface AuditRef extends AuditRefJson {}
export interface Category extends CategoryJson {
auditRefs: AuditRef[];
}
export interface Group extends GroupJson {}
export interface Plugin {
/** Optionally provide more audits to run in addition to those specified by the base config. */
audits?: Array<{path: string}>;
/** Provide a category to display the plugin results in the report. */
category: LH.Config.Category;
/** Optionally provide more groups in addition to those specified by the base config. */
groups?: Record<string, LH.Config.GroupJson>;
}
export type MergeOptionsOfItems = <T extends {path?: string, options: Record<string, any>}>(items: T[]) => T[];
export type Merge = {
<T extends Record<string, any>, U extends Record<string, any>>(base: T|null|undefined, extension: U, overwriteArrays?: boolean): T & U;
<T extends Array<any>, U extends Array<any>>(base: T|null|undefined, extension: T, overwriteArrays?: boolean): T & U;
}
}
}
}
// empty export to keep file a module
export {};