-
Notifications
You must be signed in to change notification settings - Fork 9.5k
/
Copy pathartifacts.d.ts
386 lines (350 loc) · 15.9 KB
/
artifacts.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
/**
* @license Copyright 2018 Google Inc. 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 parseManifest = require('../lighthouse-core/lib/manifest-parser.js');
import _LanternSimulator = require('../lighthouse-core/lib/dependency-graph/simulator/simulator.js');
import speedline = require('speedline');
type LanternSimulator = InstanceType<typeof _LanternSimulator>;
declare global {
module LH {
export interface Artifacts extends ComputedArtifacts {
// Created by by gather-runner
fetchTime: string;
LighthouseRunWarnings: string[];
UserAgent: string;
traces: {[passName: string]: Trace};
devtoolsLogs: {[passName: string]: DevtoolsLog};
settings: Config.Settings;
/** The URL initially requested and the post-redirects URL that was actually loaded. */
URL: {requestedUrl: string, finalUrl: string};
// Remaining are provided by default gatherers.
/** The results of running the aXe accessibility tests on the page. */
Accessibility: Artifacts.Accessibility;
/** Information on all anchors in the page that aren't nofollow or noreferrer. */
AnchorsWithNoRelNoopener: {href: string; rel: string; target: string}[];
/** The value of the page's <html> manifest attribute, or null if not defined */
AppCacheManifest: string | null;
/** Array of all URLs cached in CacheStorage. */
CacheContents: string[];
/** Href values of link[rel=canonical] nodes found in HEAD (or null, if no href attribute). */
Canonical: (string | null)[];
/** Console deprecation and intervention warnings logged by Chrome during page load. */
ChromeConsoleMessages: Crdp.Log.EntryAddedEvent[];
/** The href and innerText of all non-nofollow anchors in the page. */
CrawlableLinks: {href: string, text: string}[];
/** CSS coverage information for styles used by page's final state. */
CSSUsage: {rules: Crdp.CSS.RuleUsage[], stylesheets: Artifacts.CSSStyleSheetInfo[]};
/** Information on the size of all DOM nodes in the page and the most extreme members. */
DOMStats: Artifacts.DOMStats;
/** Relevant attributes and child properties of all <object>s, <embed>s and <applet>s in the page. */
EmbeddedContent: Artifacts.EmbeddedContentInfo[];
/** Information on all event listeners in the page. */
EventListeners: {url: string, type: string, handler?: {description?: string}, objectName: string, line: number, col: number}[];
/** Information for font faces used in the page. */
Fonts: Artifacts.Font[];
/** Information on poorly sized font usage and the text affected by it. */
FontSize: Artifacts.FontSize;
/** The hreflang and href values of all link[rel=alternate] nodes found in HEAD. */
Hreflang: {href: string, hreflang: string}[];
/** The page's document body innerText if loaded with JavaScript disabled. */
HTMLWithoutJavaScript: {value: string};
/** Whether the page ended up on an HTTPS page after attempting to load the HTTP version. */
HTTPRedirect: {value: boolean};
/** Information on size and loading for all the images in the page. */
ImageUsage: Artifacts.SingleImageUsage[];
/** Information on JS libraries and versions used by the page. */
JSLibraries: {name: string, version: string, npmPkgName: string}[];
/** JS coverage information for code used during page load. */
JsUsage: Crdp.Profiler.ScriptCoverage[];
/** Parsed version of the page's Web App Manifest, or null if none found. */
Manifest: Artifacts.Manifest | null;
/** The value of the <meta name="description">'s content attribute, or null. */
MetaDescription: string|null;
/** The value of the <meta name="robots">'s content attribute, or null. */
MetaRobots: string|null;
/** The status code of the attempted load of the page while network access is disabled. */
Offline: number;
/** Size and compression opportunity information for all the images in the page. */
OptimizedImages: Array<Artifacts.OptimizedImage | Artifacts.OptimizedImageError>;
/** HTML snippets from any password inputs that prevent pasting. */
PasswordInputsWithPreventedPaste: {snippet: string}[];
/** Size info of all network records sent without compression and their size after gzipping. */
ResponseCompression: {requestId: string, url: string, mimeType: string, transferSize: number, resourceSize: number, gzipSize: number}[];
/** Information on fetching and the content of the /robots.txt file. */
RobotsTxt: {status: number|null, content: string|null};
/** Set of exceptions thrown during page load. */
RuntimeExceptions: Crdp.Runtime.ExceptionThrownEvent[];
/** The content of all scripts loaded by the page, keyed by networkRecord requestId. */
Scripts: Record<string, string>;
/** Version information for all ServiceWorkers active after the first page load. */
ServiceWorker: {versions: Crdp.ServiceWorker.ServiceWorkerVersion[]};
/** The status of an offline fetch of the page's start_url. -1 and a debugString if missing or there was an error. */
StartUrl: {statusCode: number, debugString?: string};
/** Information on <script> and <link> tags blocking first paint. */
TagsBlockingFirstPaint: Artifacts.TagBlockingFirstPaint[];
/** The value of the <meta name="theme=color">'s content attribute, or null. */
ThemeColor: string|null;
/** The value of the <meta name="viewport">'s content attribute, or null. */
Viewport: string|null;
/** The dimensions and devicePixelRatio of the loaded viewport. */
ViewportDimensions: Artifacts.ViewportDimensions;
/** WebSQL database information for the page or null if none was found. */
WebSQL: Crdp.Database.Database | null;
}
export interface ComputedArtifacts {
requestCriticalRequestChains(data: {devtoolsLog: DevtoolsLog, URL: Artifacts['URL']}): Promise<Artifacts.CriticalRequestNode>;
requestDevtoolsTimelineModel(trace: Trace): Promise<Artifacts.DevtoolsTimelineModel>;
requestLoadSimulator(data: {devtoolsLog: DevtoolsLog, settings: Config.Settings}): Promise<LanternSimulator>;
requestMainResource(data: {devtoolsLog: DevtoolsLog, URL: Artifacts['URL']}): Promise<WebInspector.NetworkRequest>;
requestManifestValues(manifest: LH.Artifacts['Manifest']): Promise<LH.Artifacts.ManifestValues>;
requestNetworkAnalysis(devtoolsLog: DevtoolsLog): Promise<LH.Artifacts.NetworkAnalysis>;
requestNetworkThroughput(devtoolsLog: DevtoolsLog): Promise<number>;
requestNetworkRecords(devtoolsLog: DevtoolsLog): Promise<WebInspector.NetworkRequest[]>;
requestPageDependencyGraph(data: {trace: Trace, devtoolsLog: DevtoolsLog}): Promise<Gatherer.Simulation.GraphNode>;
requestPushedRequests(devtoolsLogs: DevtoolsLog): Promise<WebInspector.NetworkRequest[]>;
requestTraceOfTab(trace: Trace): Promise<Artifacts.TraceOfTab>;
requestScreenshots(trace: Trace): Promise<{timestamp: number, datauri: string}[]>;
requestSpeedline(trace: Trace): Promise<LH.Artifacts.Speedline>;
// Metrics.
requestInteractive(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric|Artifacts.Metric>;
requestEstimatedInputLatency(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric|Artifacts.Metric>;
requestFirstContentfulPaint(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric|Artifacts.Metric>;
requestFirstCPUIdle(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric|Artifacts.Metric>;
requestFirstMeaningfulPaint(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric|Artifacts.Metric>;
requestSpeedIndex(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric|Artifacts.Metric>;
// Lantern metrics.
requestLanternInteractive(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric>;
requestLanternEstimatedInputLatency(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric>;
requestLanternFirstContentfulPaint(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric>;
requestLanternFirstCPUIdle(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric>;
requestLanternFirstMeaningfulPaint(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric>;
requestLanternSpeedIndex(data: LH.Artifacts.MetricComputationDataInput): Promise<Artifacts.LanternMetric>;
}
module Artifacts {
export interface Accessibility {
violations: {
id: string;
nodes: {
path: string;
snippet: string;
target: string[];
}[];
}[];
notApplicable: {
id: string
}[];
}
export interface CSSStyleSheetInfo {
header: Crdp.CSS.CSSStyleSheetHeader;
content: string;
}
export interface DOMStats {
totalDOMNodes: number;
width: {max: number, pathToElement: Array<string>, snippet: string};
depth: {max: number, pathToElement: Array<string>, snippet: string};
}
export interface EmbeddedContentInfo {
tagName: string;
type: string | null;
src: string | null;
data: string | null;
code: string | null;
params: {name: string; value: string}[];
}
export interface Font {
display: string;
family: string;
featureSettings: string;
stretch: string;
style: string;
unicodeRange: string;
variant: string;
weight: string;
src?: string[];
}
export interface FontSize {
totalTextLength: number;
failingTextLength: number;
visitedTextLength: number;
analyzedFailingTextLength: number;
analyzedFailingNodesData: Array<{
fontSize: number;
textLength: number;
node: FontSize.DomNodeWithParent;
cssRule: {
type: 'Regular' | 'Inline' | 'Attributes';
range: {startLine: number, startColumn: number};
parentRule: {origin: Crdp.CSS.StyleSheetOrigin, selectors: {text: string}[]};
styleSheetId: string;
stylesheet: Crdp.CSS.CSSStyleSheetHeader;
}
}>
}
export module FontSize {
export interface DomNodeWithParent extends Crdp.DOM.Node {
parentId: number;
parentNode: DomNodeWithParent;
}
}
// TODO(bckenny): real type for parsed manifest.
export type Manifest = ReturnType<typeof parseManifest>;
export interface SingleImageUsage {
src: string;
clientWidth: number;
clientHeight: number;
naturalWidth: number;
naturalHeight: number;
isCss: boolean;
isPicture: boolean;
usesObjectFit: boolean;
clientRect: {
top: number;
bottom: number;
left: number;
right: number;
};
networkRecord?: {
url: string;
resourceSize: number;
startTime: number;
endTime: number;
responseReceivedTime: number;
mimeType: string;
};
width?: number;
height?: number;
}
export interface OptimizedImage {
failed: false;
fromProtocol: boolean;
originalSize: number;
jpegSize: number;
webpSize: number;
isSameOrigin: boolean;
isBase64DataUri: boolean;
requestId: string;
url: string;
mimeType: string;
resourceSize: number;
}
export interface OptimizedImageError {
failed: true;
errMsg: string;
isSameOrigin: boolean;
isBase64DataUri: boolean;
requestId: string;
url: string;
mimeType: string;
resourceSize: number;
}
export interface TagBlockingFirstPaint {
startTime: number;
endTime: number;
transferSize: number;
tag: {
tagName: string;
url: string;
};
}
export interface ViewportDimensions {
innerWidth: number;
innerHeight: number;
outerWidth: number;
outerHeight: number;
devicePixelRatio: number;
}
// Computed artifact types below.
export type CriticalRequestNode = {
[id: string]: {
request: WebInspector.NetworkRequest;
children: CriticalRequestNode;
}
}
export interface DevtoolsTimelineFilmStripModel {
frames(): Array<{
imageDataPromise(): Promise<string>;
timestamp: number;
}>;
}
export interface DevtoolsTimelineModelNode {
children: Map<string, DevtoolsTimelineModelNode>;
selfTime: number;
// SDK.TracingModel.Event
event: {
name: string;
};
}
export interface DevtoolsTimelineModel {
filmStripModel(): Artifacts.DevtoolsTimelineFilmStripModel;
bottomUpGroupBy(grouping: string): DevtoolsTimelineModelNode;
}
export interface ManifestValues {
isParseFailure: boolean;
parseFailureReason: string | undefined;
allChecks: {
id: string;
failureText: string;
passing: boolean;
}[];
}
export interface MetricComputationDataInput {
devtoolsLog: DevtoolsLog;
trace: Trace;
settings: Config.Settings;
simulator?: LanternSimulator;
}
export interface MetricComputationData extends MetricComputationDataInput {
networkRecords: Array<WebInspector.NetworkRequest>;
traceOfTab: TraceOfTab;
}
export interface Metric {
timing: number;
timestamp?: number;
}
export interface NetworkAnalysis {
rtt: number;
additionalRttByOrigin: Map<string, number>;
serverResponseTimeByOrigin: Map<string, number>;
throughput: number;
}
export interface LanternMetric {
timing: number;
timestamp?: never;
optimisticEstimate: Gatherer.Simulation.Result
pessimisticEstimate: Gatherer.Simulation.Result;
optimisticGraph: Gatherer.Simulation.GraphNode;
pessimisticGraph: Gatherer.Simulation.GraphNode;
}
export type Speedline = speedline.Output<'speedIndex'>;
// TODO(bckenny): all but navigationStart could actually be undefined.
export interface TraceTimes {
navigationStart: number;
firstPaint: number;
firstContentfulPaint: number;
firstMeaningfulPaint: number;
traceEnd: number;
load: number;
domContentLoaded: number;
}
// TODO(bckenny): events other than started and navStart could be undefined.
export interface TraceOfTab {
timings: TraceTimes;
timestamps: TraceTimes;
processEvents: Array<TraceEvent>;
mainThreadEvents: Array<TraceEvent>;
startedInPageEvt: TraceEvent;
navigationStartEvt: TraceEvent;
firstPaintEvt: TraceEvent;
firstContentfulPaintEvt: TraceEvent;
firstMeaningfulPaintEvt: TraceEvent;
loadEvt: TraceEvent;
domContentLoadedEvt: TraceEvent;
fmpFellBack: boolean;
}
}
}
}
// empty export to keep file a module
export {}