lighthouse 13.0.3 → 13.1.0

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.
Files changed (46) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/cli/test/smokehouse/__snapshots__/report-assert-test.js.snap +10 -10
  3. package/cli/test/smokehouse/config/exclusions.js +44 -0
  4. package/cli/test/smokehouse/frontends/smokehouse-bin.js +5 -4
  5. package/cli/test/smokehouse/lighthouse-runners/devtools-mcp.d.ts +14 -0
  6. package/cli/test/smokehouse/lighthouse-runners/devtools-mcp.js +141 -0
  7. package/core/audits/baseline.d.ts +25 -0
  8. package/core/audits/baseline.js +190 -0
  9. package/core/computed/document-urls.js +5 -2
  10. package/core/computed/main-resource.js +7 -3
  11. package/core/computed/network-analysis.js +4 -1
  12. package/core/config/default-config.js +2 -0
  13. package/core/gather/driver/wait-for-condition.js +11 -1
  14. package/core/gather/gatherers/trace.js +3 -0
  15. package/core/lib/baseline/web-features-metadata.json +3 -0
  16. package/core/lib/deprecations-strings.d.ts +169 -89
  17. package/core/lib/deprecations-strings.js +119 -24
  18. package/core/lib/navigation-error.js +11 -2
  19. package/core/lib/network-recorder.js +2 -1
  20. package/core/lib/network-request.js +1 -0
  21. package/core/scoring.d.ts +24 -0
  22. package/dist/report/bundle.esm.js +31 -3
  23. package/dist/report/flow.js +32 -4
  24. package/dist/report/standalone.js +32 -4
  25. package/package.json +11 -10
  26. package/report/assets/styles.css +28 -0
  27. package/report/renderer/components.js +1 -1
  28. package/report/renderer/details-renderer.d.ts +5 -0
  29. package/report/renderer/details-renderer.js +16 -0
  30. package/report/types/report-renderer.d.ts +1 -1
  31. package/report/types/report-result.d.ts +1 -1
  32. package/shared/localization/locales/en-US.json +12 -0
  33. package/shared/localization/locales/en-XL.json +12 -0
  34. package/tsconfig.json +2 -0
  35. package/types/artifacts.d.ts +33 -30
  36. package/types/audit.d.ts +1 -1
  37. package/types/config.d.ts +1 -1
  38. package/types/gatherer.d.ts +1 -1
  39. package/types/lhr/audit-details.d.ts +10 -4
  40. package/types/lhr/flow-result.d.ts +1 -1
  41. package/types/lhr/lhr.d.ts +1 -1
  42. package/types/lhr/treemap.d.ts +1 -1
  43. package/types/protocol.d.ts +1 -1
  44. package/types/puppeteer.d.ts +1 -1
  45. package/types/user-flow.d.ts +1 -1
  46. package/types/utility-types.d.ts +1 -1
@@ -4,22 +4,22 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import {Protocol as Crdp} from 'devtools-protocol/types/protocol.js';
7
+ import { Protocol as Crdp } from 'devtools-protocol/types/protocol.js';
8
8
  import * as TraceEngine from '@paulirish/trace_engine';
9
9
  import * as Lantern from '../core/lib/lantern/lantern.js';
10
10
 
11
- import {parseManifest} from '../core/lib/manifest-parser.js';
12
- import {LighthouseError} from '../core/lib/lh-error.js';
13
- import {NetworkRequest as _NetworkRequest} from '../core/lib/network-request.js';
11
+ import { parseManifest } from '../core/lib/manifest-parser.js';
12
+ import { LighthouseError } from '../core/lib/lh-error.js';
13
+ import { NetworkRequest as _NetworkRequest } from '../core/lib/network-request.js';
14
14
  import speedline from 'speedline-core';
15
15
  import * as CDTSourceMap from '../core/lib/cdt/generated/SourceMap.js';
16
- import {ArbitraryEqualityMap} from '../core/lib/arbitrary-equality-map.js';
16
+ import { ArbitraryEqualityMap } from '../core/lib/arbitrary-equality-map.js';
17
17
  import type { TaskNode as _TaskNode } from '../core/lib/tracehouse/main-thread-tasks.js';
18
18
  import AuditDetails from './lhr/audit-details.js'
19
19
  import Config from './config.js';
20
20
  import Gatherer from './gatherer.js';
21
- import {IEntity} from 'third-party-web';
22
- import {IcuMessage} from './lhr/i18n.js';
21
+ import { IEntity } from 'third-party-web';
22
+ import { IcuMessage } from './lhr/i18n.js';
23
23
  import LHResult from './lhr/lhr.js'
24
24
  import Protocol from './protocol.js';
25
25
  import Util from './utility-types.js';
@@ -51,13 +51,13 @@ interface UniversalBaseArtifacts {
51
51
  /** The host's device pixel ratio. */
52
52
  HostDPR: number;
53
53
  /** Device which Chrome is running on. */
54
- HostFormFactor: 'desktop'|'mobile';
54
+ HostFormFactor: 'desktop' | 'mobile';
55
55
  /** The user agent string of the version of Chrome used. */
56
56
  HostUserAgent: string;
57
57
  /** The product string of the version of Chrome used. Example: HeadlessChrome/123.2.2.0 would be from old headless. */
58
58
  HostProduct: string;
59
59
  /** Information about how Lighthouse artifacts were gathered. */
60
- GatherContext: {gatherMode: Gatherer.GatherMode};
60
+ GatherContext: { gatherMode: Gatherer.GatherMode };
61
61
  }
62
62
 
63
63
  /**
@@ -87,7 +87,7 @@ interface PublicGathererArtifacts {
87
87
  /** The contents of the main HTML document network resource. */
88
88
  MainDocumentContent: string;
89
89
  /** The values of the <meta> elements in the head. */
90
- MetaElements: Array<{name?: string, content?: string, property?: string, httpEquiv?: string, charset?: string, node: Artifacts.NodeDetails}>;
90
+ MetaElements: Array<{ name?: string, content?: string, property?: string, httpEquiv?: string, charset?: string, node: Artifacts.NodeDetails }>;
91
91
  /** Information on all scripts in the page. */
92
92
  Scripts: Artifacts.Script[];
93
93
  /** The primary trace taken over the entire run. */
@@ -117,7 +117,7 @@ export interface GathererArtifacts extends PublicGathererArtifacts {
117
117
  /** All the iframe elements in the page. */
118
118
  IFrameElements: Artifacts.IFrameElement[];
119
119
  /** All the input elements, including associated form and label elements. */
120
- Inputs: {inputs: Artifacts.InputElement[]; forms: Artifacts.FormElement[]; labels: Artifacts.LabelElement[]};
120
+ Inputs: { inputs: Artifacts.InputElement[]; forms: Artifacts.FormElement[]; labels: Artifacts.LabelElement[] };
121
121
  /** Screenshot of the entire page (rather than just the above the fold content). */
122
122
  FullPageScreenshot: LHResult.FullPageScreenshot | null;
123
123
  /** The issues surfaced in the devtools Issues panel */
@@ -128,7 +128,7 @@ export interface GathererArtifacts extends PublicGathererArtifacts {
128
128
  /** The user agent string that Lighthouse used to load the page. Set to the empty string if unknown. */
129
129
  NetworkUserAgent: string;
130
130
  /** Information on fetching and the content of the /robots.txt file. */
131
- RobotsTxt: {status: number|null, content: string|null, errorMessage?: string};
131
+ RobotsTxt: { status: number | null, content: string | null, errorMessage?: string };
132
132
  /** Source maps of scripts executed in the page. */
133
133
  SourceMaps: Array<Artifacts.SourceMap>;
134
134
  /** Information on detected tech stacks (e.g. JS libraries) used by the page. */
@@ -148,7 +148,7 @@ declare module Artifacts {
148
148
 
149
149
  type NetworkRequest = _NetworkRequest;
150
150
  type TaskNode = _TaskNode;
151
- type TBTImpactTask = TaskNode & {tbtImpact: number, selfTbtImpact: number, selfBlockingTime: number};
151
+ type TBTImpactTask = TaskNode & { tbtImpact: number, selfTbtImpact: number, selfBlockingTime: number };
152
152
  type MetaElement = Artifacts['MetaElements'][0];
153
153
 
154
154
  interface URL {
@@ -188,7 +188,7 @@ declare module Artifacts {
188
188
  impact?: string;
189
189
  tags: Array<string>;
190
190
  nodes: Array<{
191
- target: Array<string|string[]>;
191
+ target: Array<string | string[]>;
192
192
  failureSummary?: string;
193
193
  node: NodeDetails;
194
194
  relatedNodes: NodeDetails[];
@@ -239,7 +239,7 @@ declare module Artifacts {
239
239
  /** @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#Attributes */
240
240
  interface LinkElement {
241
241
  /** The `rel` attribute of the link, normalized to lower case. @see https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types */
242
- rel: 'alternate'|'canonical'|'dns-prefetch'|'preconnect'|'preload'|'stylesheet'|string;
242
+ rel: 'alternate' | 'canonical' | 'dns-prefetch' | 'preconnect' | 'preload' | 'stylesheet' | string;
243
243
  /** The `href` attribute of the link or `null` if it was invalid in the header. */
244
244
  href: string | null
245
245
  /** The raw value of the `href` attribute. Only different from `href` when source is 'headers' */
@@ -251,13 +251,13 @@ declare module Artifacts {
251
251
  /** The `crossOrigin` attribute of the link */
252
252
  crossOrigin: string | null
253
253
  /** Where the link was found, either in the DOM or in the headers of the main document */
254
- source: 'head'|'body'|'headers'
254
+ source: 'head' | 'body' | 'headers'
255
255
  node: NodeDetails | null
256
256
  /** The fetch priority hint for preload links. */
257
257
  fetchPriority?: string;
258
258
  }
259
259
 
260
- interface Script extends Omit<Crdp.Debugger.ScriptParsedEvent, 'url'|'embedderName'> {
260
+ interface Script extends Omit<Crdp.Debugger.ScriptParsedEvent, 'url' | 'embedderName'> {
261
261
  /**
262
262
  * Set by a sourceURL= magic comment if present, otherwise this is the same as the URL.
263
263
  * Use this field for presentational purposes only.
@@ -288,7 +288,7 @@ declare module Artifacts {
288
288
  * `map` is optional because the spec defines that either `url` or `map` must be defined.
289
289
  * We explicitly only support `map` here.
290
290
  */
291
- sections?: Array<{offset: {line: number, column: number}, map?: RawSourceMap}>
291
+ sections?: Array<{ offset: { line: number, column: number }, map?: RawSourceMap }>
292
292
  }
293
293
 
294
294
  /**
@@ -326,7 +326,7 @@ declare module Artifacts {
326
326
  files: Record<string, number>;
327
327
  unmappedBytes: number;
328
328
  totalBytes: number;
329
- } | {errorMessage: string};
329
+ } | { errorMessage: string };
330
330
  }
331
331
 
332
332
  /** @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Attributes */
@@ -429,10 +429,10 @@ declare module Artifacts {
429
429
  }
430
430
 
431
431
  interface TraceElement {
432
- traceEventType: 'trace-engine'|'layout-shift'|'animation';
432
+ traceEventType: 'trace-engine' | 'layout-shift' | 'animation';
433
433
  node: NodeDetails;
434
434
  nodeId: number;
435
- animations?: {name?: string, failureReasonsMask?: number, unsupportedProperties?: string[]}[];
435
+ animations?: { name?: string, failureReasonsMask?: number, unsupportedProperties?: string[] }[];
436
436
  type?: string;
437
437
  }
438
438
 
@@ -541,9 +541,9 @@ declare module Artifacts {
541
541
  /** The subset of trace events from the main frame and any child frames, sorted by timestamp. */
542
542
  frameTreeEvents: Array<TraceEvent>;
543
543
  /** IDs for the trace's main frame, and process. The startingPid is the initial process id, however cross-origin navigations may incur changes to the pid while the frame ID remains identical. */
544
- mainFrameInfo: {startingPid: number, frameId: string};
544
+ mainFrameInfo: { startingPid: number, frameId: string };
545
545
  /** The list of frames committed in the trace. */
546
- frames: Array<{id: string, url: string}>;
546
+ frames: Array<{ id: string, url: string }>;
547
547
  /** The trace event marking the time at which the run should consider to have begun. Typically the same as the navigationStart but might differ due to SPA navigations, client-side redirects, etc. In the timespan case, this event is injected by Lighthouse itself. */
548
548
  timeOriginEvt: TraceEvent;
549
549
  /** All received trace events subsetted to important categories. */
@@ -761,7 +761,7 @@ export interface Trace {
761
761
 
762
762
  /** The type of the Profile & ProfileChunk event in Chromium traces. Note that this is subtly different from Crdp.Profiler.Profile. */
763
763
  export interface TraceCpuProfile {
764
- nodes?: Array<{id: number, callFrame: {functionName: string, url?: string}, parent?: number}>
764
+ nodes?: Array<{ id: number, callFrame: { functionName: string, url?: string }, parent?: number }>
765
765
  samples?: Array<number>
766
766
  timeDeltas?: Array<number>
767
767
  }
@@ -831,7 +831,7 @@ export interface TraceEvent {
831
831
  unsupportedProperties?: string[];
832
832
  size?: number;
833
833
  /** Responsiveness data. */
834
- interactionType?: 'drag'|'keyboard'|'tapOrClick';
834
+ interactionType?: 'drag' | 'keyboard' | 'tapOrClick';
835
835
  maxDuration?: number;
836
836
  type?: string;
837
837
  functionName?: string;
@@ -851,21 +851,24 @@ export interface TraceEvent {
851
851
  connectionReused?: boolean;
852
852
  encodedDataLength?: number;
853
853
  decodedBodyLength?: number;
854
- initiator?: {type: string, url?: string, stack?: any};
854
+ initiator?: { type: string, url?: string, stack?: any };
855
855
  protocol?: string;
856
856
  finishTime?: number;
857
- headers?: Array<{name: string, value: string}>;
857
+ headers?: Array<{ name: string, value: string }>;
858
858
  };
859
859
  frame?: string;
860
860
  name?: string;
861
861
  labels?: string;
862
+ feature?: string;
863
+ lineNumber?: number;
864
+ columnNumber?: number;
862
865
  };
863
866
  pid: number;
864
867
  tid: number;
865
868
  /** Timestamp of the event in microseconds. */
866
869
  ts: number;
867
870
  dur: number;
868
- ph: 'B'|'b'|'D'|'E'|'e'|'F'|'I'|'M'|'N'|'n'|'O'|'R'|'S'|'T'|'X';
871
+ ph: 'B' | 'b' | 'D' | 'E' | 'e' | 'F' | 'I' | 'M' | 'N' | 'n' | 'O' | 'R' | 'S' | 'T' | 'X';
869
872
  s?: 't';
870
873
  id?: string;
871
874
  id2?: {
@@ -873,7 +876,7 @@ export interface TraceEvent {
873
876
  };
874
877
  }
875
878
 
876
- declare module Trace {
879
+ declare namespace Trace {
877
880
  /**
878
881
  * Base event of a `ph: 'X'` 'complete' event. Extend with `name` and `args` as
879
882
  * needed.
@@ -894,7 +897,7 @@ declare module Trace {
894
897
  * more specific `ph` (if needed).
895
898
  */
896
899
  interface AsyncEvent {
897
- ph: 'b'|'e'|'n';
900
+ ph: 'b' | 'e' | 'n';
898
901
  cat: string;
899
902
  pid: number;
900
903
  tid: number;
package/types/audit.d.ts CHANGED
@@ -13,7 +13,7 @@ import {IcuMessage} from './lhr/i18n.js';
13
13
  import * as AuditResult from './lhr/audit-result.js';
14
14
  import Util from './utility-types.js';
15
15
 
16
- declare module Audit {
16
+ declare namespace Audit {
17
17
  export import Details = AuditDetails;
18
18
  export type Result = AuditResult.Result;
19
19
  export type ScoreDisplayMode = AuditResult.ScoreDisplayMode;
package/types/config.d.ts CHANGED
@@ -28,7 +28,7 @@ interface Config {
28
28
  plugins?: Array<string>;
29
29
  }
30
30
 
31
- declare module Config {
31
+ declare namespace Config {
32
32
  /**
33
33
  * The normalized and fully resolved config.
34
34
  */
@@ -22,7 +22,7 @@ import * as Lantern from '../core/lib/lantern/lantern.js';
22
22
  type CrdpEvents = CrdpMappings.Events;
23
23
  type CrdpCommands = CrdpMappings.Commands;
24
24
 
25
- declare module Gatherer {
25
+ declare namespace Gatherer {
26
26
  /** The Lighthouse wrapper around a raw CDP session. */
27
27
  interface ProtocolSession {
28
28
  setTargetInfo(targetInfo: Crdp.Target.TargetInfo): void;
@@ -26,7 +26,7 @@ type Details =
26
26
  Details.Table;
27
27
 
28
28
  // Details namespace.
29
- declare module Details {
29
+ declare namespace Details {
30
30
  type NetworkNode = {
31
31
  [id: string]: {
32
32
  url: string;
@@ -97,7 +97,7 @@ declare module Details {
97
97
  // NOTE: any `Details` type *should* be usable in `items`, but check
98
98
  // styles/report-ui-features are good before adding.
99
99
  type ListableDetail = Table | Checklist | NetworkTree | NodeValue | TextValue | DebugData;
100
-
100
+
101
101
  interface ListSectionItem {
102
102
  type: 'list-section';
103
103
  title?: IcuMessage | string;
@@ -195,10 +195,10 @@ declare module Details {
195
195
  }
196
196
 
197
197
  /** String enum of possible types of values found within table items. */
198
- type ItemValueType = 'bytes' | 'code' | 'link' | 'ms' | 'multi' | 'node' | 'source-location' | 'numeric' | 'text' | 'thumbnail' | 'timespanMs' | 'url';
198
+ type ItemValueType = 'bytes' | 'code' | 'link' | 'ms' | 'multi' | 'node' | 'source-location' | 'numeric' | 'text' | 'thumbnail' | 'timespanMs' | 'url' | 'baseline-status';
199
199
 
200
200
  /** Possible types of values found within table items. */
201
- type ItemValue = string | number | boolean | DebugData | NodeValue | SourceLocationValue | LinkValue | UrlValue | CodeValue | NumericValue | TextValue | IcuMessage | TableSubItems;
201
+ type ItemValue = string | number | boolean | DebugData | NodeValue | SourceLocationValue | LinkValue | UrlValue | CodeValue | NumericValue | TextValue | IcuMessage | TableSubItems | BaselineStatusValue;
202
202
 
203
203
  interface TableColumnHeading {
204
204
  /**
@@ -363,6 +363,12 @@ declare module Details {
363
363
  type: 'text',
364
364
  value: IcuMessage | string,
365
365
  }
366
+
367
+ interface BaselineStatusValue {
368
+ type: 'baseline-status',
369
+ status: 'high' | 'low' | 'limited' | string,
370
+ displayString: IcuMessage | string,
371
+ }
366
372
  }
367
373
 
368
374
  export default Details;
@@ -6,7 +6,7 @@
6
6
 
7
7
  import Result from './lhr.js';
8
8
 
9
- declare module FlowResult {
9
+ declare namespace FlowResult {
10
10
  interface Step {
11
11
  /** Lighthouse report for this flow step. */
12
12
  lhr: Result;
@@ -70,7 +70,7 @@ interface Result {
70
70
  }
71
71
 
72
72
  // Result namespace
73
- declare module Result {
73
+ declare namespace Result {
74
74
  interface Environment {
75
75
  /** The user agent string of the version of Chrome used. */
76
76
  hostUserAgent: string;
@@ -7,7 +7,7 @@
7
7
  import {Result as AuditResult} from './audit-result.js';
8
8
  import {Locale} from './settings.js';
9
9
 
10
- declare module Treemap {
10
+ declare namespace Treemap {
11
11
  interface Options {
12
12
  lhr: {
13
13
  mainDocumentUrl?: string;
@@ -9,7 +9,7 @@ import {ProtocolMapping as CrdpMappings} from 'devtools-protocol/types/protocol-
9
9
  type CrdpEvents = CrdpMappings.Events;
10
10
  type CrdpCommands = CrdpMappings.Commands;
11
11
 
12
- declare module Protocol {
12
+ declare namespace Protocol {
13
13
  type TargetType = 'page' | 'iframe' | 'worker';
14
14
 
15
15
  /**
@@ -13,7 +13,7 @@ import * as puppeteerCore from 'puppeteer-core';
13
13
 
14
14
  type IfNotAny<T> = [T & 0] extends [1] ? never : T;
15
15
 
16
- declare module Puppeteer {
16
+ declare namespace Puppeteer {
17
17
  // @ts-ignore Puppeteer is an optional dependency. `IfNotAny` will handle the `any` type if it's not installed.
18
18
  export type Browser = puppeteerCore.Browser | IfNotAny<import('puppeteer').Browser>;
19
19
  // @ts-ignore Puppeteer is an optional dependency. `IfNotAny` will handle the `any` type if it's not installed.
@@ -9,7 +9,7 @@ import Config from './config.js';
9
9
  import {Flags} from './externs.js';
10
10
  import {Artifacts} from './artifacts.js';
11
11
 
12
- declare module UserFlow {
12
+ declare namespace UserFlow {
13
13
  export interface FlowArtifacts {
14
14
  gatherSteps: GatherStep[];
15
15
  name?: string;
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- declare module Util {
7
+ declare namespace Util {
8
8
  /** Make properties K in T optional. */
9
9
  type MakeOptional<T, K extends keyof T> = {
10
10
  [P in Exclude<keyof T, K>]: T[P]