lighthouse 12.0.0-dev.20240610 → 12.0.0-dev.20240611

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 (33) hide show
  1. package/core/audits/long-tasks.d.ts +7 -6
  2. package/core/audits/long-tasks.js +5 -4
  3. package/core/computed/processed-navigation.d.ts +1 -1
  4. package/core/computed/tbt-impact-tasks.js +2 -1
  5. package/core/config/constants.d.ts +28 -53
  6. package/core/config/constants.js +2 -43
  7. package/core/lib/lantern/cpu-node.d.ts +10 -10
  8. package/core/lib/lantern/cpu-node.js +5 -5
  9. package/core/lib/lantern/lantern.d.ts +49 -7
  10. package/core/lib/lantern/lantern.js +45 -1
  11. package/core/lib/lantern/metric.d.ts +8 -8
  12. package/core/lib/lantern/metric.js +6 -6
  13. package/core/lib/lantern/metrics/interactive.d.ts +3 -8
  14. package/core/lib/lantern/metrics/interactive.js +5 -5
  15. package/core/lib/lantern/metrics/largest-contentful-paint.d.ts +4 -3
  16. package/core/lib/lantern/metrics/largest-contentful-paint.js +4 -4
  17. package/core/lib/lantern/metrics/max-potential-fid.d.ts +3 -8
  18. package/core/lib/lantern/metrics/max-potential-fid.js +5 -5
  19. package/core/lib/lantern/metrics/speed-index.d.ts +3 -8
  20. package/core/lib/lantern/metrics/speed-index.js +6 -6
  21. package/core/lib/lantern/metrics/total-blocking-time.d.ts +3 -8
  22. package/core/lib/lantern/metrics/total-blocking-time.js +5 -5
  23. package/core/lib/lantern/page-dependency-graph.d.ts +17 -6
  24. package/core/lib/lantern/page-dependency-graph.js +45 -12
  25. package/core/lib/lantern/simulator/network-analyzer.d.ts +6 -6
  26. package/core/lib/lantern/simulator/network-analyzer.js +2 -2
  27. package/core/lib/lantern/simulator/simulator.js +6 -6
  28. package/core/lib/lantern/trace-engine-computation-data.d.ts +5 -5
  29. package/core/lib/lantern/trace-engine-computation-data.js +13 -9
  30. package/core/lib/lantern/types/lantern.d.ts +77 -5
  31. package/core/lib/lantern-trace-saver.js +1 -1
  32. package/package.json +4 -4
  33. package/types/artifacts.d.ts +2 -8
@@ -4,7 +4,58 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import * as LH from '../../../../types/lh.js';
7
+ import * as Protocol from '@paulirish/trace_engine/generated/protocol.js';
8
+
9
+ declare module Util {
10
+ /** An object with the keys in the union K mapped to themselves as values. */
11
+ type SelfMap<K extends string> = {
12
+ [P in K]: P;
13
+ };
14
+ }
15
+
16
+ type TraceEvent = {
17
+ name: string;
18
+ cat: string;
19
+ args: {
20
+ name?: string;
21
+ fileName?: string;
22
+ snapshot?: string;
23
+ sync_id?: string;
24
+ beginData?: {
25
+ frame?: string;
26
+ startLine?: number;
27
+ url?: string;
28
+ };
29
+ data?: {
30
+ frame?: string;
31
+ readyState?: number;
32
+ stackTrace?: {
33
+ url: string
34
+ }[];
35
+ url?: string;
36
+ };
37
+ };
38
+ pid: number;
39
+ tid: number;
40
+ /** Timestamp of the event in microseconds. */
41
+ ts: number;
42
+ dur: number;
43
+ }
44
+ type Trace = {traceEvents: TraceEvent[]};
45
+ type ResourcePriority = ('VeryLow' | 'Low' | 'Medium' | 'High' | 'VeryHigh');
46
+ type ResourceType = ('Document' | 'Stylesheet' | 'Image' | 'Media' | 'Font' | 'Script' | 'TextTrack' | 'XHR' | 'Fetch' | 'Prefetch' | 'EventSource' | 'WebSocket' | 'Manifest' | 'SignedExchange' | 'Ping' | 'CSPViolationReport' | 'Preflight' | 'Other');
47
+ type InitiatorType = ('parser' | 'script' | 'preload' | 'SignedExchange' | 'preflight' | 'other');
48
+ type ResourceTiming = Protocol.Network.ResourceTiming;
49
+ type CallStack = {
50
+ callFrames: Array<{
51
+ scriptId: string;
52
+ url: string;
53
+ lineNumber: number;
54
+ columnNumber: number;
55
+ functionName: string;
56
+ }>;
57
+ parent?: CallStack;
58
+ }
8
59
 
9
60
  type ParsedURL = {
10
61
  /**
@@ -80,24 +131,45 @@ export class NetworkRequest<T = any> {
80
131
  redirectSource: NetworkRequest<T> | undefined;
81
132
  /** The network request that this one redirected to */
82
133
  redirectDestination: NetworkRequest<T> | undefined;
83
- initiator: LH.Crdp.Network.Initiator;
134
+ // TODO: can't use Protocol.Network.Initiator because of type mismatch in Lighthouse initiator.
135
+ initiator: {
136
+ type: InitiatorType;
137
+ url?: string;
138
+ stack?: CallStack;
139
+ };
84
140
  initiatorRequest: NetworkRequest<T> | undefined;
85
141
  /** The chain of network requests that redirected to this one */
86
142
  redirects: NetworkRequest[] | undefined;
87
- timing: LH.Crdp.Network.ResourceTiming | undefined;
143
+ timing: Protocol.Network.ResourceTiming | undefined;
88
144
  /**
89
145
  * Optional value for how long the server took to respond to this request.
90
146
  * When not provided, the server response time is derived from the timing object.
91
147
  */
92
148
  serverResponseTime?: number;
93
- resourceType: LH.Crdp.Network.ResourceType | undefined;
149
+ resourceType: ResourceType | undefined;
94
150
  mimeType: string;
95
- priority: LH.Crdp.Network.ResourcePriority;
151
+ priority: ResourcePriority;
96
152
  frameId: string | undefined;
97
153
  fromWorker: boolean;
98
154
  }
99
155
 
156
+ interface Metric<T = any> {
157
+ timing: number;
158
+ timestamp?: never;
159
+ optimisticEstimate: Simulation.Result<T>;
160
+ pessimisticEstimate: Simulation.Result<T>;
161
+ optimisticGraph: Simulation.GraphNode<T>;
162
+ pessimisticGraph: Simulation.GraphNode<T>;
163
+ }
164
+
100
165
  export namespace Simulation {
166
+ type URL = {
167
+ /** URL of the initially requested URL */
168
+ requestedUrl?: string;
169
+ /** URL of the last document request */
170
+ mainDocumentUrl?: string;
171
+ };
172
+
101
173
  type GraphNode<T> = import('../base-node.js').Node<T>;
102
174
  type GraphNetworkNode<T> = import('../network-node.js').NetworkNode<T>;
103
175
  type GraphCPUNode = import('../cpu-node.js').CPUNode;
@@ -116,7 +116,7 @@ function convertNodeTimingsToTrace(nodeTimings) {
116
116
  const ts = eventTs + (event.ts - nestedBaseTs) * multiplier;
117
117
  const newEvent = {...event, ...{pid: baseEvent.pid, tid: baseEvent.tid}, ts};
118
118
  if (event.dur) newEvent.dur = event.dur * multiplier;
119
- events.push(newEvent);
119
+ events.push(/** @type {LH.TraceEvent} */(newEvent));
120
120
  }
121
121
 
122
122
  return events;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lighthouse",
3
3
  "type": "module",
4
- "version": "12.0.0-dev.20240610",
4
+ "version": "12.0.0-dev.20240611",
5
5
  "description": "Automated auditing, performance metrics, and best practices for the web.",
6
6
  "main": "./core/index.js",
7
7
  "bin": {
@@ -187,7 +187,7 @@
187
187
  "chrome-launcher": "^1.1.1",
188
188
  "configstore": "^5.0.1",
189
189
  "csp_evaluator": "1.1.1",
190
- "devtools-protocol": "0.0.1299070",
190
+ "devtools-protocol": "0.0.1312386",
191
191
  "enquirer": "^2.3.6",
192
192
  "http-link-header": "^1.1.1",
193
193
  "intl-messageformat": "^10.5.3",
@@ -211,8 +211,8 @@
211
211
  "yargs-parser": "^21.0.0"
212
212
  },
213
213
  "resolutions": {
214
- "puppeteer/**/devtools-protocol": "0.0.1299070",
215
- "puppeteer-core/**/devtools-protocol": "0.0.1299070"
214
+ "puppeteer/**/devtools-protocol": "0.0.1312386",
215
+ "puppeteer-core/**/devtools-protocol": "0.0.1312386"
216
216
  },
217
217
  "repository": "GoogleChrome/lighthouse",
218
218
  "keywords": [
@@ -6,6 +6,7 @@
6
6
 
7
7
  import {Protocol as Crdp} from 'devtools-protocol/types/protocol.js';
8
8
  import * as TraceEngine from '@paulirish/trace_engine';
9
+ import * as Lantern from '../core/lib/lantern/types/lantern.js';
9
10
  import {LayoutShiftRootCausesData} from '@paulirish/trace_engine/models/trace/root-causes/LayoutShift.js';
10
11
 
11
12
  import {parseManifest} from '../core/lib/manifest-parser.js';
@@ -591,14 +592,7 @@ declare module Artifacts {
591
592
  throughput: number;
592
593
  }
593
594
 
594
- interface LanternMetric {
595
- timing: number;
596
- timestamp?: never;
597
- optimisticEstimate: Gatherer.Simulation.Result
598
- pessimisticEstimate: Gatherer.Simulation.Result;
599
- optimisticGraph: Gatherer.Simulation.GraphNode;
600
- pessimisticGraph: Gatherer.Simulation.GraphNode;
601
- }
595
+ type LanternMetric = Lantern.Metric<Artifacts.NetworkRequest>;
602
596
 
603
597
  type Speedline = speedline.Output<'speedIndex'>;
604
598