lighthouse 12.0.0-dev.20240610 → 12.0.0-dev.20240612
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.
- package/core/audits/byte-efficiency/byte-efficiency-audit.d.ts +2 -2
- package/core/audits/byte-efficiency/byte-efficiency-audit.js +2 -2
- package/core/audits/byte-efficiency/render-blocking-resources.d.ts +3 -3
- package/core/audits/byte-efficiency/render-blocking-resources.js +4 -4
- package/core/audits/dobetterweb/uses-http2.d.ts +2 -2
- package/core/audits/dobetterweb/uses-http2.js +2 -2
- package/core/audits/long-tasks.d.ts +7 -6
- package/core/audits/long-tasks.js +5 -4
- package/core/audits/prioritize-lcp-image.d.ts +1 -1
- package/core/computed/document-urls.js +3 -2
- package/core/computed/load-simulator.d.ts +4 -4
- package/core/computed/load-simulator.js +3 -3
- package/core/computed/main-resource.js +3 -2
- package/core/computed/metrics/lantern-first-contentful-paint.d.ts +4 -4
- package/core/computed/metrics/lantern-first-contentful-paint.js +3 -3
- package/core/computed/metrics/lantern-interactive.d.ts +4 -4
- package/core/computed/metrics/lantern-interactive.js +3 -3
- package/core/computed/metrics/lantern-largest-contentful-paint.d.ts +4 -4
- package/core/computed/metrics/lantern-largest-contentful-paint.js +3 -3
- package/core/computed/metrics/lantern-max-potential-fid.d.ts +4 -4
- package/core/computed/metrics/lantern-max-potential-fid.js +3 -3
- package/core/computed/metrics/lantern-metric.d.ts +4 -3
- package/core/computed/metrics/lantern-metric.js +4 -4
- package/core/computed/metrics/lantern-speed-index.d.ts +4 -4
- package/core/computed/metrics/lantern-speed-index.js +3 -3
- package/core/computed/metrics/lantern-total-blocking-time.d.ts +4 -4
- package/core/computed/metrics/lantern-total-blocking-time.js +3 -3
- package/core/computed/metrics/total-blocking-time.js +3 -1
- package/core/computed/network-analysis.js +2 -2
- package/core/computed/page-dependency-graph.d.ts +2 -2
- package/core/computed/page-dependency-graph.js +6 -6
- package/core/computed/processed-navigation.d.ts +1 -1
- package/core/computed/tbt-impact-tasks.js +4 -2
- package/core/config/constants.d.ts +28 -53
- package/core/config/constants.js +2 -43
- package/core/lib/asset-saver.js +2 -2
- package/core/lib/lantern/{base-node.d.ts → BaseNode.d.ts} +7 -9
- package/core/lib/lantern/{base-node.js → BaseNode.js} +6 -6
- package/core/lib/lantern/BaseNode.test.js +385 -0
- package/core/lib/lantern/CpuNode.d.ts +43 -0
- package/core/lib/lantern/{cpu-node.js → CpuNode.js} +8 -9
- package/core/lib/lantern/{lantern-error.d.ts → LanternError.d.ts} +1 -1
- package/core/lib/lantern/{metric.d.ts → Metric.d.ts} +17 -17
- package/core/lib/lantern/{metric.js → Metric.js} +10 -12
- package/core/lib/lantern/{network-node.d.ts → NetworkNode.d.ts} +4 -5
- package/core/lib/lantern/{network-node.js → NetworkNode.js} +4 -5
- package/core/lib/lantern/{page-dependency-graph.d.ts → PageDependencyGraph.d.ts} +22 -11
- package/core/lib/lantern/{page-dependency-graph.js → PageDependencyGraph.js} +56 -22
- package/core/lib/lantern/PageDependencyGraph.test.js +654 -0
- package/core/lib/lantern/{tbt-utils.d.ts → TBTUtils.d.ts} +1 -1
- package/core/lib/lantern/TBTUtils.test.d.ts +2 -0
- package/core/lib/lantern/TBTUtils.test.js +130 -0
- package/core/lib/lantern/{trace-engine-computation-data.d.ts → TraceEngineComputationData.d.ts} +7 -7
- package/core/lib/lantern/{trace-engine-computation-data.js → TraceEngineComputationData.js} +18 -16
- package/core/lib/lantern/lantern.d.ts +19 -7
- package/core/lib/lantern/lantern.js +21 -1
- package/core/lib/lantern/metrics/{first-contentful-paint.d.ts → FirstContentfulPaint.d.ts} +11 -11
- package/core/lib/lantern/metrics/{first-contentful-paint.js → FirstContentfulPaint.js} +8 -10
- package/core/lib/lantern/metrics/FirstContentfulPaint.test.js +54 -0
- package/core/lib/lantern/metrics/Interactive.d.ts +20 -0
- package/core/lib/lantern/metrics/{interactive.js → Interactive.js} +14 -17
- package/core/lib/lantern/metrics/Interactive.test.js +56 -0
- package/core/lib/lantern/metrics/LargestContentfulPaint.d.ts +19 -0
- package/core/lib/lantern/metrics/{largest-contentful-paint.js → LargestContentfulPaint.js} +12 -15
- package/core/lib/lantern/metrics/LargestContentfulPaint.test.js +42 -0
- package/core/lib/lantern/metrics/MaxPotentialFID.d.ts +24 -0
- package/core/lib/lantern/metrics/{max-potential-fid.js → MaxPotentialFID.js} +12 -13
- package/core/lib/lantern/metrics/MetricTestUtils.d.ts +19 -0
- package/core/lib/lantern/metrics/MetricTestUtils.js +48 -0
- package/core/lib/lantern/metrics/{speed-index.d.ts → SpeedIndex.d.ts} +7 -13
- package/core/lib/lantern/metrics/{speed-index.js → SpeedIndex.js} +12 -14
- package/core/lib/lantern/metrics/SpeedIndex.test.js +83 -0
- package/core/lib/lantern/metrics/TotalBlockingTime.d.ts +25 -0
- package/core/lib/lantern/metrics/{total-blocking-time.js → TotalBlockingTime.js} +13 -16
- package/core/lib/lantern/metrics/__snapshots__/first-contentful-paint-test.js.snap +11 -0
- package/core/lib/lantern/metrics/__snapshots__/interactive-test.js.snap +17 -0
- package/core/lib/lantern/metrics/metrics.d.ts +9 -0
- package/core/lib/lantern/metrics/metrics.js +16 -0
- package/core/lib/lantern/{simulator/connection-pool.d.ts → simulation/ConnectionPool.d.ts} +5 -5
- package/core/lib/lantern/{simulator/connection-pool.js → simulation/ConnectionPool.js} +3 -3
- package/core/lib/lantern/simulation/ConnectionPool.test.js +195 -0
- package/core/lib/lantern/simulation/Constants.d.ts +52 -0
- package/core/lib/lantern/simulation/Constants.js +48 -0
- package/core/lib/lantern/{simulator/dns-cache.d.ts → simulation/DNSCache.d.ts} +2 -2
- package/core/lib/lantern/{simulator/dns-cache.js → simulation/DNSCache.js} +1 -1
- package/core/lib/lantern/simulation/DNSCache.test.js +72 -0
- package/core/lib/lantern/{simulator/network-analyzer.d.ts → simulation/NetworkAnalyzer.d.ts} +8 -8
- package/core/lib/lantern/{simulator/network-analyzer.js → simulation/NetworkAnalyzer.js} +3 -3
- package/core/lib/lantern/simulation/NetworkAnalyzer.test.js +475 -0
- package/core/lib/lantern/{simulator/simulator-timing-map.d.ts → simulation/SimulationTimingMap.d.ts} +7 -7
- package/core/lib/lantern/{simulator/simulator-timing-map.js → simulation/SimulationTimingMap.js} +5 -6
- package/core/lib/lantern/{simulator/simulator.d.ts → simulation/Simulator.d.ts} +13 -15
- package/core/lib/lantern/{simulator/simulator.js → simulation/Simulator.js} +29 -30
- package/core/lib/lantern/simulation/Simulator.test.js +434 -0
- package/core/lib/lantern/simulation/TCPConnection.test.d.ts +2 -0
- package/core/lib/lantern/simulation/TCPConnection.test.js +374 -0
- package/core/lib/lantern/{simulator/tcp-connection.d.ts → simulation/TcpConnection.d.ts} +2 -2
- package/core/lib/lantern/{simulator/tcp-connection.js → simulation/TcpConnection.js} +1 -1
- package/core/lib/lantern/simulation/simulation.d.ts +21 -0
- package/core/lib/lantern/simulation/simulation.js +28 -0
- package/core/lib/lantern/types/lantern.d.ts +81 -9
- package/core/lib/lantern-trace-saver.d.ts +4 -4
- package/core/lib/lantern-trace-saver.js +3 -3
- package/core/lib/navigation-error.js +3 -3
- package/core/lib/network-recorder.js +2 -2
- package/core/lib/network-request.d.ts +1 -1
- package/core/lib/network-request.js +1 -1
- package/package.json +5 -5
- package/tsconfig.json +10 -8
- package/types/artifacts.d.ts +3 -10
- package/types/gatherer.d.ts +1 -1
- package/core/lib/lantern/cpu-node.d.ts +0 -44
- package/core/lib/lantern/metrics/interactive.d.ts +0 -26
- package/core/lib/lantern/metrics/largest-contentful-paint.d.ts +0 -19
- package/core/lib/lantern/metrics/max-potential-fid.d.ts +0 -30
- package/core/lib/lantern/metrics/total-blocking-time.d.ts +0 -31
- /package/core/lib/lantern/{lantern-error.js → LanternError.js} +0 -0
- /package/core/lib/lantern/{tbt-utils.js → TBTUtils.js} +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export type Node = import('./
|
|
2
|
-
export type URLArtifact = Omit<LH.Artifacts['URL'], 'finalDisplayedUrl'>;
|
|
1
|
+
export type Node = import('./BaseNode.js').Node;
|
|
3
2
|
export type NetworkNodeOutput = {
|
|
4
3
|
nodes: Array<NetworkNode>;
|
|
5
4
|
idToNodeMap: Map<string, NetworkNode>;
|
|
@@ -18,10 +17,22 @@ export class PageDependencyGraph {
|
|
|
18
17
|
*/
|
|
19
18
|
static getNetworkNodeOutput(networkRequests: Array<Lantern.NetworkRequest>): NetworkNodeOutput;
|
|
20
19
|
/**
|
|
21
|
-
* @param {
|
|
20
|
+
* @param {Lantern.TraceEvent} evt
|
|
21
|
+
* @return {boolean}
|
|
22
|
+
*/
|
|
23
|
+
static isScheduleableTask(evt: Lantern.TraceEvent): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* There should *always* be at least one top level event, having 0 typically means something is
|
|
26
|
+
* drastically wrong with the trace and we should just give up early and loudly.
|
|
27
|
+
*
|
|
28
|
+
* @param {Lantern.TraceEvent[]} events
|
|
29
|
+
*/
|
|
30
|
+
static assertHasToplevelEvents(events: Lantern.TraceEvent[]): void;
|
|
31
|
+
/**
|
|
32
|
+
* @param {Lantern.TraceEvent[]} mainThreadEvents
|
|
22
33
|
* @return {Array<CPUNode>}
|
|
23
34
|
*/
|
|
24
|
-
static getCPUNodes(mainThreadEvents:
|
|
35
|
+
static getCPUNodes(mainThreadEvents: Lantern.TraceEvent[]): Array<CPUNode>;
|
|
25
36
|
/**
|
|
26
37
|
* @param {NetworkNode} rootNode
|
|
27
38
|
* @param {NetworkNodeOutput} networkNodeOutput
|
|
@@ -54,18 +65,18 @@ export class PageDependencyGraph {
|
|
|
54
65
|
*/
|
|
55
66
|
static _debugNormalizeRequests(lanternRequests: Lantern.NetworkRequest[]): never;
|
|
56
67
|
/**
|
|
57
|
-
* @param {
|
|
68
|
+
* @param {Lantern.TraceEvent[]} mainThreadEvents
|
|
58
69
|
* @param {Lantern.NetworkRequest[]} networkRequests
|
|
59
|
-
* @param {
|
|
70
|
+
* @param {Lantern.Simulation.URL} URL
|
|
60
71
|
* @return {Node}
|
|
61
72
|
*/
|
|
62
|
-
static createGraph(mainThreadEvents:
|
|
73
|
+
static createGraph(mainThreadEvents: Lantern.TraceEvent[], networkRequests: Lantern.NetworkRequest[], URL: Lantern.Simulation.URL): Node;
|
|
63
74
|
/**
|
|
64
75
|
* @param {Node} rootNode
|
|
65
76
|
*/
|
|
66
77
|
static printGraph(rootNode: Node, widthInCharacters?: number): void;
|
|
67
78
|
}
|
|
68
|
-
import { NetworkNode } from './
|
|
69
|
-
import * as Lantern from './
|
|
70
|
-
import { CPUNode } from './
|
|
71
|
-
//# sourceMappingURL=
|
|
79
|
+
import { NetworkNode } from './NetworkNode.js';
|
|
80
|
+
import * as Lantern from './lantern.js';
|
|
81
|
+
import { CPUNode } from './CpuNode.js';
|
|
82
|
+
//# sourceMappingURL=PageDependencyGraph.d.ts.map
|
|
@@ -4,15 +4,20 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import * as Lantern from './
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {CPUNode} from './cpu-node.js';
|
|
11
|
-
import {TraceProcessor} from '../tracehouse/trace-processor.js';
|
|
12
|
-
import {NetworkAnalyzer} from './simulator/network-analyzer.js';
|
|
7
|
+
import * as Lantern from './lantern.js';
|
|
8
|
+
import {NetworkNode} from './NetworkNode.js';
|
|
9
|
+
import {CPUNode} from './CpuNode.js';
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
// COMPAT: m71+ We added RunTask to `disabled-by-default-lighthouse`
|
|
12
|
+
const SCHEDULABLE_TASK_TITLE_LH = 'RunTask';
|
|
13
|
+
// m69-70 DoWork is different and we now need RunTask, see https://bugs.chromium.org/p/chromium/issues/detail?id=871204#c11
|
|
14
|
+
const SCHEDULABLE_TASK_TITLE_ALT1 = 'ThreadControllerImpl::RunTask';
|
|
15
|
+
// In m66-68 refactored to this task title, https://crrev.com/c/883346
|
|
16
|
+
const SCHEDULABLE_TASK_TITLE_ALT2 = 'ThreadControllerImpl::DoWork';
|
|
17
|
+
// m65 and earlier
|
|
18
|
+
const SCHEDULABLE_TASK_TITLE_ALT3 = 'TaskQueueManager::ProcessTaskFromWorkQueue';
|
|
19
|
+
|
|
20
|
+
/** @typedef {import('./BaseNode.js').Node} Node */
|
|
16
21
|
|
|
17
22
|
/**
|
|
18
23
|
* @typedef {Object} NetworkNodeOutput
|
|
@@ -97,7 +102,7 @@ class PageDependencyGraph {
|
|
|
97
102
|
// If the request was for the root document of an iframe, save an entry in our
|
|
98
103
|
// map so we can link up the task `args.data.frame` dependencies later in graph creation.
|
|
99
104
|
if (request.frameId &&
|
|
100
|
-
request.resourceType === NetworkRequestTypes.Document &&
|
|
105
|
+
request.resourceType === Lantern.NetworkRequestTypes.Document &&
|
|
101
106
|
request.documentURL === request.url) {
|
|
102
107
|
// If there's ever any ambiguity, permanently set the value to `false` to avoid loops in the graph.
|
|
103
108
|
const value = frameIdToNodeMap.has(request.frameId) ? null : node;
|
|
@@ -109,7 +114,31 @@ class PageDependencyGraph {
|
|
|
109
114
|
}
|
|
110
115
|
|
|
111
116
|
/**
|
|
112
|
-
* @param {
|
|
117
|
+
* @param {Lantern.TraceEvent} evt
|
|
118
|
+
* @return {boolean}
|
|
119
|
+
*/
|
|
120
|
+
static isScheduleableTask(evt) {
|
|
121
|
+
return evt.name === SCHEDULABLE_TASK_TITLE_LH ||
|
|
122
|
+
evt.name === SCHEDULABLE_TASK_TITLE_ALT1 ||
|
|
123
|
+
evt.name === SCHEDULABLE_TASK_TITLE_ALT2 ||
|
|
124
|
+
evt.name === SCHEDULABLE_TASK_TITLE_ALT3;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* There should *always* be at least one top level event, having 0 typically means something is
|
|
129
|
+
* drastically wrong with the trace and we should just give up early and loudly.
|
|
130
|
+
*
|
|
131
|
+
* @param {Lantern.TraceEvent[]} events
|
|
132
|
+
*/
|
|
133
|
+
static assertHasToplevelEvents(events) {
|
|
134
|
+
const hasToplevelTask = events.some(this.isScheduleableTask);
|
|
135
|
+
if (!hasToplevelTask) {
|
|
136
|
+
throw new Error('Could not find any top level events');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @param {Lantern.TraceEvent[]} mainThreadEvents
|
|
113
142
|
* @return {Array<CPUNode>}
|
|
114
143
|
*/
|
|
115
144
|
static getCPUNodes(mainThreadEvents) {
|
|
@@ -117,14 +146,14 @@ class PageDependencyGraph {
|
|
|
117
146
|
const nodes = [];
|
|
118
147
|
let i = 0;
|
|
119
148
|
|
|
120
|
-
|
|
149
|
+
PageDependencyGraph.assertHasToplevelEvents(mainThreadEvents);
|
|
121
150
|
|
|
122
151
|
while (i < mainThreadEvents.length) {
|
|
123
152
|
const evt = mainThreadEvents[i];
|
|
124
153
|
i++;
|
|
125
154
|
|
|
126
155
|
// Skip all trace events that aren't schedulable tasks with sizable duration
|
|
127
|
-
if (!
|
|
156
|
+
if (!PageDependencyGraph.isScheduleableTask(evt) || !evt.dur) {
|
|
128
157
|
continue;
|
|
129
158
|
}
|
|
130
159
|
|
|
@@ -132,23 +161,25 @@ class PageDependencyGraph {
|
|
|
132
161
|
let correctedEndTs = undefined;
|
|
133
162
|
|
|
134
163
|
// Capture all events that occurred within the task
|
|
135
|
-
/** @type {Array<
|
|
164
|
+
/** @type {Array<Lantern.TraceEvent>} */
|
|
136
165
|
const children = [];
|
|
137
166
|
for (
|
|
138
167
|
const endTime = evt.ts + evt.dur;
|
|
139
168
|
i < mainThreadEvents.length && mainThreadEvents[i].ts < endTime;
|
|
140
169
|
i++
|
|
141
170
|
) {
|
|
171
|
+
const event = mainThreadEvents[i];
|
|
172
|
+
|
|
142
173
|
// Temporary fix for a Chrome bug where some RunTask events can be overlapping.
|
|
143
174
|
// We correct that here be ensuring each RunTask ends at least 1 microsecond before the next
|
|
144
175
|
// https://github.com/GoogleChrome/lighthouse/issues/15896
|
|
145
176
|
// https://issues.chromium.org/issues/329678173
|
|
146
|
-
if (
|
|
147
|
-
correctedEndTs =
|
|
177
|
+
if (PageDependencyGraph.isScheduleableTask(event) && event.dur) {
|
|
178
|
+
correctedEndTs = event.ts - 1;
|
|
148
179
|
break;
|
|
149
180
|
}
|
|
150
181
|
|
|
151
|
-
children.push(
|
|
182
|
+
children.push(event);
|
|
152
183
|
}
|
|
153
184
|
|
|
154
185
|
nodes.push(new CPUNode(evt, children, correctedEndTs));
|
|
@@ -210,9 +241,11 @@ class PageDependencyGraph {
|
|
|
210
241
|
* @param {Array<CPUNode>} cpuNodes
|
|
211
242
|
*/
|
|
212
243
|
static linkCPUNodes(rootNode, networkNodeOutput, cpuNodes) {
|
|
213
|
-
/** @type {Set<
|
|
244
|
+
/** @type {Set<Lantern.ResourceType|undefined>} */
|
|
214
245
|
const linkableResourceTypes = new Set([
|
|
215
|
-
NetworkRequestTypes.XHR,
|
|
246
|
+
Lantern.NetworkRequestTypes.XHR,
|
|
247
|
+
Lantern.NetworkRequestTypes.Fetch,
|
|
248
|
+
Lantern.NetworkRequestTypes.Script,
|
|
216
249
|
]);
|
|
217
250
|
|
|
218
251
|
/** @param {CPUNode} cpuNode @param {string} reqId */
|
|
@@ -506,9 +539,9 @@ class PageDependencyGraph {
|
|
|
506
539
|
}
|
|
507
540
|
|
|
508
541
|
/**
|
|
509
|
-
* @param {
|
|
542
|
+
* @param {Lantern.TraceEvent[]} mainThreadEvents
|
|
510
543
|
* @param {Lantern.NetworkRequest[]} networkRequests
|
|
511
|
-
* @param {
|
|
544
|
+
* @param {Lantern.Simulation.URL} URL
|
|
512
545
|
* @return {Node}
|
|
513
546
|
*/
|
|
514
547
|
static createGraph(mainThreadEvents, networkRequests, URL) {
|
|
@@ -520,12 +553,13 @@ class PageDependencyGraph {
|
|
|
520
553
|
if (!requestedUrl) throw new Error('requestedUrl is required to get the root request');
|
|
521
554
|
if (!mainDocumentUrl) throw new Error('mainDocumentUrl is required to get the main resource');
|
|
522
555
|
|
|
523
|
-
const rootRequest =
|
|
556
|
+
const rootRequest =
|
|
557
|
+
Lantern.Simulation.NetworkAnalyzer.findResourceForUrl(networkRequests, requestedUrl);
|
|
524
558
|
if (!rootRequest) throw new Error('rootRequest not found');
|
|
525
559
|
const rootNode = networkNodeOutput.idToNodeMap.get(rootRequest.requestId);
|
|
526
560
|
if (!rootNode) throw new Error('rootNode not found');
|
|
527
561
|
const mainDocumentRequest =
|
|
528
|
-
NetworkAnalyzer.findLastDocumentForUrl(networkRequests, mainDocumentUrl);
|
|
562
|
+
Lantern.Simulation.NetworkAnalyzer.findLastDocumentForUrl(networkRequests, mainDocumentUrl);
|
|
529
563
|
if (!mainDocumentRequest) throw new Error('mainDocumentRequest not found');
|
|
530
564
|
const mainDocumentNode = networkNodeOutput.idToNodeMap.get(mainDocumentRequest.requestId);
|
|
531
565
|
if (!mainDocumentNode) throw new Error('mainDocumentNode not found');
|