lighthouse 11.6.0-dev.20240306 → 11.6.0-dev.20240308
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/cli/test/smokehouse/core-tests.js +2 -0
- package/core/computed/load-simulator.d.ts +0 -2
- package/core/computed/load-simulator.js +2 -3
- package/core/computed/metrics/lantern-first-contentful-paint.d.ts +12 -0
- package/core/computed/metrics/lantern-first-meaningful-paint.d.ts +12 -0
- package/core/computed/metrics/lantern-interactive.d.ts +6 -0
- package/core/computed/metrics/lantern-interactive.js +1 -1
- package/core/computed/metrics/lantern-largest-contentful-paint.d.ts +12 -0
- package/core/computed/metrics/lantern-max-potential-fid.d.ts +6 -0
- package/core/computed/metrics/lantern-max-potential-fid.js +1 -1
- package/core/computed/metrics/lantern-metric.d.ts +4 -64
- package/core/computed/metrics/lantern-metric.js +6 -124
- package/core/computed/metrics/lantern-speed-index.d.ts +6 -0
- package/core/computed/metrics/lantern-speed-index.js +1 -1
- package/core/computed/metrics/lantern-total-blocking-time.d.ts +6 -0
- package/core/computed/metrics/lantern-total-blocking-time.js +1 -1
- package/core/gather/gatherers/full-page-screenshot.d.ts +4 -0
- package/core/gather/gatherers/full-page-screenshot.js +26 -32
- package/core/lib/lantern/metric.d.ts +71 -0
- package/core/lib/lantern/metric.js +143 -0
- package/core/lib/lantern/network-node.d.ts +5 -5
- package/core/lib/lantern/network-node.js +3 -4
- package/core/lib/lantern/page-dependency-graph.d.ts +7 -7
- package/core/lib/lantern/page-dependency-graph.js +4 -4
- package/core/lib/lantern/simulator/connection-pool.d.ts +14 -15
- package/core/lib/lantern/simulator/connection-pool.js +7 -9
- package/core/lib/lantern/simulator/dns-cache.d.ts +5 -11
- package/core/lib/lantern/simulator/dns-cache.js +3 -3
- package/core/lib/lantern/simulator/network-analyzer.d.ts +30 -30
- package/core/lib/lantern/simulator/network-analyzer.js +14 -15
- package/core/lib/lantern/simulator/simulator.d.ts +13 -16
- package/core/lib/lantern/simulator/simulator.js +10 -16
- package/core/lib/lantern/types/lantern.d.ts +129 -0
- package/core/lib/lantern/types/lantern.js +7 -0
- package/core/lib/network-request.d.ts +3 -4
- package/core/lib/network-request.js +2 -3
- package/package.json +1 -1
- package/tsconfig.json +1 -0
- package/types/gatherer.d.ts +1 -1
- package/types/lhr/lhr.d.ts +1 -1
- package/types/internal/lantern.d.ts +0 -124
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import * as Lantern from '../types/lantern.js';
|
|
9
8
|
import UrlUtils from '../../url-utils.js';
|
|
10
9
|
|
|
11
10
|
const INITIAL_CWD = 14 * 1024;
|
|
@@ -33,8 +32,8 @@ class NetworkAnalyzer {
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
/**
|
|
36
|
-
* @param {NetworkRequest[]} records
|
|
37
|
-
* @return {Map<string, NetworkRequest[]>}
|
|
35
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
36
|
+
* @return {Map<string, Lantern.NetworkRequest[]>}
|
|
38
37
|
*/
|
|
39
38
|
static groupByOrigin(records) {
|
|
40
39
|
const grouped = new Map();
|
|
@@ -89,10 +88,10 @@ class NetworkAnalyzer {
|
|
|
89
88
|
return summaryByKey;
|
|
90
89
|
}
|
|
91
90
|
|
|
92
|
-
/** @typedef {{record: NetworkRequest, timing: LH.Crdp.Network.ResourceTiming, connectionReused?: boolean}} RequestInfo */
|
|
91
|
+
/** @typedef {{record: Lantern.NetworkRequest, timing: LH.Crdp.Network.ResourceTiming, connectionReused?: boolean}} RequestInfo */
|
|
93
92
|
|
|
94
93
|
/**
|
|
95
|
-
* @param {NetworkRequest[]} records
|
|
94
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
96
95
|
* @param {(e: RequestInfo) => number | number[] | undefined} iteratee
|
|
97
96
|
* @return {Map<string, number[]>}
|
|
98
97
|
*/
|
|
@@ -251,7 +250,7 @@ class NetworkAnalyzer {
|
|
|
251
250
|
/**
|
|
252
251
|
* Given the RTT to each origin, estimates the observed server response times.
|
|
253
252
|
*
|
|
254
|
-
* @param {NetworkRequest[]} records
|
|
253
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
255
254
|
* @param {Map<string, number>} rttByOrigin
|
|
256
255
|
* @return {Map<string, number[]>}
|
|
257
256
|
*/
|
|
@@ -272,7 +271,7 @@ class NetworkAnalyzer {
|
|
|
272
271
|
}
|
|
273
272
|
|
|
274
273
|
/**
|
|
275
|
-
* @param {NetworkRequest[]} records
|
|
274
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
276
275
|
* @return {boolean}
|
|
277
276
|
*/
|
|
278
277
|
static canTrustConnectionInformation(records) {
|
|
@@ -292,7 +291,7 @@ class NetworkAnalyzer {
|
|
|
292
291
|
* Returns a map of requestId -> connectionReused, estimating the information if the information
|
|
293
292
|
* available in the records themselves appears untrustworthy.
|
|
294
293
|
*
|
|
295
|
-
* @param {NetworkRequest[]} records
|
|
294
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
296
295
|
* @param {{forceCoarseEstimates: boolean}} [options]
|
|
297
296
|
* @return {Map<string, boolean>}
|
|
298
297
|
*/
|
|
@@ -336,7 +335,7 @@ class NetworkAnalyzer {
|
|
|
336
335
|
* Attempts to use the most accurate information first and falls back to coarser estimates when it
|
|
337
336
|
* is unavailable.
|
|
338
337
|
*
|
|
339
|
-
* @param {NetworkRequest[]} records
|
|
338
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
340
339
|
* @param {RTTEstimateOptions} [options]
|
|
341
340
|
* @return {Map<string, Summary>}
|
|
342
341
|
*/
|
|
@@ -417,7 +416,7 @@ class NetworkAnalyzer {
|
|
|
417
416
|
* Estimates the server response time of each origin. RTT times can be passed in or will be
|
|
418
417
|
* estimated automatically if not provided.
|
|
419
418
|
*
|
|
420
|
-
* @param {NetworkRequest[]} records
|
|
419
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
421
420
|
* @param {RTTEstimateOptions & {rttByOrigin?: Map<string, number>}} [options]
|
|
422
421
|
* @return {Map<string, Summary>}
|
|
423
422
|
*/
|
|
@@ -443,7 +442,7 @@ class NetworkAnalyzer {
|
|
|
443
442
|
* Excludes data URI, failed or otherwise incomplete, and cached requests.
|
|
444
443
|
* Returns Infinity if there were no analyzable network records.
|
|
445
444
|
*
|
|
446
|
-
* @param {Array<NetworkRequest>} networkRecords
|
|
445
|
+
* @param {Array<Lantern.NetworkRequest>} networkRecords
|
|
447
446
|
* @return {number}
|
|
448
447
|
*/
|
|
449
448
|
static estimateThroughput(networkRecords) {
|
|
@@ -496,7 +495,7 @@ class NetworkAnalyzer {
|
|
|
496
495
|
}
|
|
497
496
|
|
|
498
497
|
/**
|
|
499
|
-
* @template {NetworkRequest} T
|
|
498
|
+
* @template {Lantern.NetworkRequest} T
|
|
500
499
|
* @param {Array<T>} records
|
|
501
500
|
* @param {string} resourceUrl
|
|
502
501
|
* @return {T|undefined}
|
|
@@ -510,7 +509,7 @@ class NetworkAnalyzer {
|
|
|
510
509
|
}
|
|
511
510
|
|
|
512
511
|
/**
|
|
513
|
-
* @template {NetworkRequest} T
|
|
512
|
+
* @template {Lantern.NetworkRequest} T
|
|
514
513
|
* @param {Array<T>} records
|
|
515
514
|
* @param {string} resourceUrl
|
|
516
515
|
* @return {T|undefined}
|
|
@@ -530,7 +529,7 @@ class NetworkAnalyzer {
|
|
|
530
529
|
* Resolves redirect chain given a main document.
|
|
531
530
|
* See: {@link NetworkAnalyzer.findLastDocumentForUrl}) for how to retrieve main document.
|
|
532
531
|
*
|
|
533
|
-
* @template {NetworkRequest} T
|
|
532
|
+
* @template {Lantern.NetworkRequest} T
|
|
534
533
|
* @param {T} request
|
|
535
534
|
* @return {T}
|
|
536
535
|
*/
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
export type NetworkRequest = import('../../../../types/internal/lantern.js').Lantern.NetworkRequest;
|
|
2
|
-
export type SimulationOptions = import('../../../../types/internal/lantern.js').Lantern.Simulation.Options;
|
|
3
|
-
export type SimulationNodeTiming = import('../../../../types/internal/lantern.js').Lantern.Simulation.NodeTiming;
|
|
4
|
-
export type SimulationResult<T> = import('../../../../types/internal/lantern.js').Lantern.Simulation.Result<T>;
|
|
5
1
|
export type Node = import('../base-node.js').Node;
|
|
6
2
|
export type NetworkNode = import('../network-node.js').NetworkNode;
|
|
7
3
|
export type CpuNode = import('../cpu-node.js').CPUNode;
|
|
@@ -21,11 +17,11 @@ export class Simulator<T = any> {
|
|
|
21
17
|
*/
|
|
22
18
|
static _computeNodeStartPosition(node: Node): number;
|
|
23
19
|
/**
|
|
24
|
-
* @param {
|
|
20
|
+
* @param {Lantern.Simulation.Options} [options]
|
|
25
21
|
*/
|
|
26
|
-
constructor(options?:
|
|
27
|
-
/** @type {Required<
|
|
28
|
-
_options: Required<
|
|
22
|
+
constructor(options?: Lantern.Simulation.Options | undefined);
|
|
23
|
+
/** @type {Required<Lantern.Simulation.Options>} */
|
|
24
|
+
_options: Required<Lantern.Simulation.Options>;
|
|
29
25
|
_rtt: number;
|
|
30
26
|
_throughput: number;
|
|
31
27
|
_maximumConcurrentRequests: number;
|
|
@@ -74,10 +70,10 @@ export class Simulator<T = any> {
|
|
|
74
70
|
*/
|
|
75
71
|
_markNodeAsComplete(node: Node, endTime: number, connectionTiming?: import("./simulator-timing-map.js").ConnectionTiming | undefined): void;
|
|
76
72
|
/**
|
|
77
|
-
* @param {NetworkRequest} record
|
|
73
|
+
* @param {Lantern.NetworkRequest} record
|
|
78
74
|
* @return {?TcpConnection}
|
|
79
75
|
*/
|
|
80
|
-
_acquireConnection(record: NetworkRequest): TcpConnection | null;
|
|
76
|
+
_acquireConnection(record: Lantern.NetworkRequest): TcpConnection | null;
|
|
81
77
|
/**
|
|
82
78
|
* @return {Node[]}
|
|
83
79
|
*/
|
|
@@ -121,16 +117,16 @@ export class Simulator<T = any> {
|
|
|
121
117
|
*/
|
|
122
118
|
_updateProgressMadeInTimePeriod(node: Node, timePeriodLength: number, totalElapsedTime: number): number | void;
|
|
123
119
|
/**
|
|
124
|
-
* @return {{nodeTimings: Map<Node,
|
|
120
|
+
* @return {{nodeTimings: Map<Node, Lantern.Simulation.NodeTiming>, completeNodeTimings: Map<Node, CompleteNodeTiming>}}
|
|
125
121
|
*/
|
|
126
122
|
_computeFinalNodeTimings(): {
|
|
127
|
-
nodeTimings: Map<Node,
|
|
123
|
+
nodeTimings: Map<Node, Lantern.Simulation.NodeTiming>;
|
|
128
124
|
completeNodeTimings: Map<Node, CompleteNodeTiming>;
|
|
129
125
|
};
|
|
130
126
|
/**
|
|
131
|
-
* @return {Required<
|
|
127
|
+
* @return {Required<Lantern.Simulation.Options>}
|
|
132
128
|
*/
|
|
133
|
-
getOptions(): Required<
|
|
129
|
+
getOptions(): Required<Lantern.Simulation.Options>;
|
|
134
130
|
/**
|
|
135
131
|
* Estimates the time taken to process all of the graph's nodes, returns the overall time along with
|
|
136
132
|
* each node annotated by start/end times.
|
|
@@ -142,17 +138,18 @@ export class Simulator<T = any> {
|
|
|
142
138
|
*
|
|
143
139
|
* @param {Node} graph
|
|
144
140
|
* @param {{flexibleOrdering?: boolean, label?: string}=} options
|
|
145
|
-
* @return {
|
|
141
|
+
* @return {Lantern.Simulation.Result<T>}
|
|
146
142
|
*/
|
|
147
143
|
simulate(graph: Node, options?: {
|
|
148
144
|
flexibleOrdering?: boolean;
|
|
149
145
|
label?: string;
|
|
150
|
-
} | undefined):
|
|
146
|
+
} | undefined): Lantern.Simulation.Result<T>;
|
|
151
147
|
/**
|
|
152
148
|
* @param {number} wastedBytes
|
|
153
149
|
*/
|
|
154
150
|
computeWastedMsFromWastedBytes(wastedBytes: number): number;
|
|
155
151
|
}
|
|
152
|
+
import * as Lantern from '../types/lantern.js';
|
|
156
153
|
import { SimulatorTimingMap } from './simulator-timing-map.js';
|
|
157
154
|
import { DNSCache } from './dns-cache.js';
|
|
158
155
|
import { ConnectionPool } from './connection-pool.js';
|
|
@@ -4,13 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
// https://github.com/microsoft/TypeScript/issues/41825
|
|
9
|
-
/** @typedef {import('../../../../types/internal/lantern.js').Lantern.NetworkRequest} NetworkRequest */
|
|
10
|
-
/** @typedef {import('../../../../types/internal/lantern.js').Lantern.Simulation.Options} SimulationOptions */
|
|
11
|
-
/** @typedef {import('../../../../types/internal/lantern.js').Lantern.Simulation.NodeTiming} SimulationNodeTiming */
|
|
12
|
-
/** @template T @typedef {import('../../../../types/internal/lantern.js').Lantern.Simulation.Result<T>} SimulationResult */
|
|
13
|
-
|
|
7
|
+
import * as Lantern from '../types/lantern.js';
|
|
14
8
|
import {BaseNode} from '../base-node.js';
|
|
15
9
|
import {TcpConnection} from './tcp-connection.js';
|
|
16
10
|
import {ConnectionPool} from './connection-pool.js';
|
|
@@ -57,10 +51,10 @@ const ALL_SIMULATION_NODE_TIMINGS = new Map();
|
|
|
57
51
|
*/
|
|
58
52
|
class Simulator {
|
|
59
53
|
/**
|
|
60
|
-
* @param {
|
|
54
|
+
* @param {Lantern.Simulation.Options} [options]
|
|
61
55
|
*/
|
|
62
56
|
constructor(options) {
|
|
63
|
-
/** @type {Required<
|
|
57
|
+
/** @type {Required<Lantern.Simulation.Options>} */
|
|
64
58
|
this._options = Object.assign(
|
|
65
59
|
{
|
|
66
60
|
rtt: mobileSlow4G.rttMs,
|
|
@@ -110,7 +104,7 @@ class Simulator {
|
|
|
110
104
|
* @param {Node} graph
|
|
111
105
|
*/
|
|
112
106
|
_initializeConnectionPool(graph) {
|
|
113
|
-
/** @type {NetworkRequest[]} */
|
|
107
|
+
/** @type {Lantern.NetworkRequest[]} */
|
|
114
108
|
const records = [];
|
|
115
109
|
graph.getRootNode().traverse(node => {
|
|
116
110
|
if (node.type === BaseNode.TYPES.NETWORK) {
|
|
@@ -199,7 +193,7 @@ class Simulator {
|
|
|
199
193
|
}
|
|
200
194
|
|
|
201
195
|
/**
|
|
202
|
-
* @param {NetworkRequest} record
|
|
196
|
+
* @param {Lantern.NetworkRequest} record
|
|
203
197
|
* @return {?TcpConnection}
|
|
204
198
|
*/
|
|
205
199
|
_acquireConnection(record) {
|
|
@@ -393,7 +387,7 @@ class Simulator {
|
|
|
393
387
|
}
|
|
394
388
|
|
|
395
389
|
/**
|
|
396
|
-
* @return {{nodeTimings: Map<Node,
|
|
390
|
+
* @return {{nodeTimings: Map<Node, Lantern.Simulation.NodeTiming>, completeNodeTimings: Map<Node, CompleteNodeTiming>}}
|
|
397
391
|
*/
|
|
398
392
|
_computeFinalNodeTimings() {
|
|
399
393
|
/** @type {Array<[Node, CompleteNodeTiming]>} */
|
|
@@ -404,8 +398,8 @@ class Simulator {
|
|
|
404
398
|
// Most consumers will want the entries sorted by startTime, so insert them in that order
|
|
405
399
|
completeNodeTimingEntries.sort((a, b) => a[1].startTime - b[1].startTime);
|
|
406
400
|
|
|
407
|
-
// Trimmed version of type `
|
|
408
|
-
/** @type {Array<[Node,
|
|
401
|
+
// Trimmed version of type `Lantern.Simulation.NodeTiming`.
|
|
402
|
+
/** @type {Array<[Node, Lantern.Simulation.NodeTiming]>} */
|
|
409
403
|
const nodeTimingEntries = completeNodeTimingEntries.map(([node, timing]) => {
|
|
410
404
|
return [node, {
|
|
411
405
|
startTime: timing.startTime,
|
|
@@ -421,7 +415,7 @@ class Simulator {
|
|
|
421
415
|
}
|
|
422
416
|
|
|
423
417
|
/**
|
|
424
|
-
* @return {Required<
|
|
418
|
+
* @return {Required<Lantern.Simulation.Options>}
|
|
425
419
|
*/
|
|
426
420
|
getOptions() {
|
|
427
421
|
return this._options;
|
|
@@ -438,7 +432,7 @@ class Simulator {
|
|
|
438
432
|
*
|
|
439
433
|
* @param {Node} graph
|
|
440
434
|
* @param {{flexibleOrdering?: boolean, label?: string}=} options
|
|
441
|
-
* @return {
|
|
435
|
+
* @return {Lantern.Simulation.Result<T>}
|
|
442
436
|
*/
|
|
443
437
|
simulate(graph, options) {
|
|
444
438
|
if (BaseNode.hasCycle(graph)) {
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as LH from '../../../../types/lh.js';
|
|
8
|
+
|
|
9
|
+
type ParsedURL = {
|
|
10
|
+
/**
|
|
11
|
+
* Equivalent to a `new URL(url).protocol` BUT w/o the trailing colon (:)
|
|
12
|
+
*/
|
|
13
|
+
scheme: string;
|
|
14
|
+
/**
|
|
15
|
+
* Equivalent to a `new URL(url).hostname`
|
|
16
|
+
*/
|
|
17
|
+
host: string;
|
|
18
|
+
securityOrigin: string;
|
|
19
|
+
};
|
|
20
|
+
type LightriderStatistics = {
|
|
21
|
+
/**
|
|
22
|
+
* The difference in networkEndTime between the observed Lighthouse networkEndTime and Lightrider's derived networkEndTime.
|
|
23
|
+
*/
|
|
24
|
+
endTimeDeltaMs: number;
|
|
25
|
+
/**
|
|
26
|
+
* The time spent making a TCP connection (connect + SSL). Note: this is poorly named.
|
|
27
|
+
*/
|
|
28
|
+
TCPMs: number;
|
|
29
|
+
/**
|
|
30
|
+
* The time spent requesting a resource from a remote server, we use this to approx RTT. Note: this is poorly names, it really should be "server response time".
|
|
31
|
+
*/
|
|
32
|
+
requestMs: number;
|
|
33
|
+
/**
|
|
34
|
+
* Time to receive the entire response payload starting the clock on receiving the first fragment (first non-header byte).
|
|
35
|
+
*/
|
|
36
|
+
responseMs: number;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export class NetworkRequest<T = any> {
|
|
40
|
+
/**
|
|
41
|
+
* The canonical network record.
|
|
42
|
+
* Users of Lantern must create NetworkRequests matching this interface,
|
|
43
|
+
* but can store the source-of-truth for their network model in this `record`
|
|
44
|
+
* property. This is then accessible as a read-only property on NetworkNode.
|
|
45
|
+
*/
|
|
46
|
+
record?: T;
|
|
47
|
+
|
|
48
|
+
requestId: string;
|
|
49
|
+
connectionId: string;
|
|
50
|
+
connectionReused: boolean;
|
|
51
|
+
url: string;
|
|
52
|
+
protocol: string;
|
|
53
|
+
parsedURL: ParsedURL;
|
|
54
|
+
documentURL: string;
|
|
55
|
+
/** When the renderer process initially discovers a network request, in milliseconds. */
|
|
56
|
+
rendererStartTime: number;
|
|
57
|
+
/**
|
|
58
|
+
* When the network service is about to handle a request, ie. just before going to the
|
|
59
|
+
* HTTP cache or going to the network for DNS/connection setup, in milliseconds.
|
|
60
|
+
*/
|
|
61
|
+
networkRequestTime: number;
|
|
62
|
+
/** When the last byte of the response headers is received, in milliseconds. */
|
|
63
|
+
responseHeadersEndTime: number;
|
|
64
|
+
/** When the last byte of the response body is received, in milliseconds. */
|
|
65
|
+
networkEndTime: number;
|
|
66
|
+
transferSize: number;
|
|
67
|
+
resourceSize: number;
|
|
68
|
+
fromDiskCache: boolean;
|
|
69
|
+
fromMemoryCache: boolean;
|
|
70
|
+
// TODO(15841): remove from lantern.
|
|
71
|
+
/** Extra timing information available only when run in Lightrider. */
|
|
72
|
+
lrStatistics: LightriderStatistics | undefined;
|
|
73
|
+
finished: boolean;
|
|
74
|
+
statusCode: number;
|
|
75
|
+
/** The network request that this one redirected to */
|
|
76
|
+
redirectDestination: NetworkRequest<T> | undefined;
|
|
77
|
+
failed: boolean;
|
|
78
|
+
initiator: LH.Crdp.Network.Initiator;
|
|
79
|
+
initiatorRequest: NetworkRequest<T> | undefined;
|
|
80
|
+
/** The chain of network requests that redirected to this one */
|
|
81
|
+
redirects: NetworkRequest[] | undefined;
|
|
82
|
+
timing: LH.Crdp.Network.ResourceTiming | undefined;
|
|
83
|
+
resourceType: LH.Crdp.Network.ResourceType | undefined;
|
|
84
|
+
mimeType: string;
|
|
85
|
+
priority: LH.Crdp.Network.ResourcePriority;
|
|
86
|
+
frameId: string | undefined;
|
|
87
|
+
sessionTargetType: LH.Protocol.TargetType | undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export namespace Simulation {
|
|
91
|
+
type GraphNode<T> = import('../base-node.js').Node<T>;
|
|
92
|
+
type GraphNetworkNode<T> = import('../network-node.js').NetworkNode<T>;
|
|
93
|
+
type GraphCPUNode = import('../cpu-node.js').CPUNode;
|
|
94
|
+
type Simulator<T> = import('../simulator/simulator.js').Simulator<T>;
|
|
95
|
+
|
|
96
|
+
interface MetricCoefficients {
|
|
97
|
+
intercept: number;
|
|
98
|
+
optimistic: number;
|
|
99
|
+
pessimistic: number;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
interface Options {
|
|
103
|
+
rtt?: number;
|
|
104
|
+
throughput?: number;
|
|
105
|
+
observedThroughput: number;
|
|
106
|
+
maximumConcurrentRequests?: number;
|
|
107
|
+
cpuSlowdownMultiplier?: number;
|
|
108
|
+
layoutTaskMultiplier?: number;
|
|
109
|
+
additionalRttByOrigin?: Map<string, number>;
|
|
110
|
+
serverResponseTimeByOrigin?: Map<string, number>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface NodeTiming {
|
|
114
|
+
startTime: number;
|
|
115
|
+
endTime: number;
|
|
116
|
+
duration: number;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
interface Result<T = any> {
|
|
120
|
+
timeInMs: number;
|
|
121
|
+
nodeTimings: Map<GraphNode<T>, NodeTiming>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
interface MetricComputationDataInput {
|
|
125
|
+
simulator: Simulator<any>;
|
|
126
|
+
graph: GraphNode<any>;
|
|
127
|
+
processedNavigation: LH.Artifacts.ProcessedNavigation;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export type LanternNetworkRequest<T> = import('../../types/internal/lantern.js').Lantern.NetworkRequest<T>;
|
|
2
1
|
export type HeaderEntry = {
|
|
3
2
|
name: string;
|
|
4
3
|
value: string;
|
|
@@ -50,9 +49,9 @@ export class NetworkRequest {
|
|
|
50
49
|
static get TYPES(): LH.Util.SelfMap<LH.Crdp.Network.ResourceType>;
|
|
51
50
|
/**
|
|
52
51
|
* @param {NetworkRequest} record
|
|
53
|
-
* @return {
|
|
52
|
+
* @return {Lantern.NetworkRequest<NetworkRequest>}
|
|
54
53
|
*/
|
|
55
|
-
static asLanternNetworkRequest(record: NetworkRequest):
|
|
54
|
+
static asLanternNetworkRequest(record: NetworkRequest): Lantern.NetworkRequest<NetworkRequest>;
|
|
56
55
|
/**
|
|
57
56
|
* @param {NetworkRequest} record
|
|
58
57
|
* @return {boolean}
|
|
@@ -259,7 +258,7 @@ export namespace NetworkRequest {
|
|
|
259
258
|
export { HEADER_PROTOCOL_IS_H2 };
|
|
260
259
|
}
|
|
261
260
|
import * as LH from '../../types/lh.js';
|
|
262
|
-
|
|
261
|
+
import * as Lantern from './lantern/types/lantern.js';
|
|
263
262
|
declare const HEADER_TCP: "X-TCPMs";
|
|
264
263
|
declare const HEADER_SSL: "X-SSLMs";
|
|
265
264
|
declare const HEADER_REQ: "X-RequestMs";
|
|
@@ -53,10 +53,9 @@
|
|
|
53
53
|
*/
|
|
54
54
|
|
|
55
55
|
import * as LH from '../../types/lh.js';
|
|
56
|
+
import * as Lantern from './lantern/types/lantern.js';
|
|
56
57
|
import UrlUtils from './url-utils.js';
|
|
57
58
|
|
|
58
|
-
/** @template T @typedef {import('../../types/internal/lantern.js').Lantern.NetworkRequest<T>} LanternNetworkRequest */
|
|
59
|
-
|
|
60
59
|
// Lightrider X-Header names for timing information.
|
|
61
60
|
// See: _updateTransferSizeForLightrider and _updateTimingsForLightrider.
|
|
62
61
|
const HEADER_TCP = 'X-TCPMs'; // Note: this should have been called something like ConnectMs, as it includes SSL.
|
|
@@ -572,7 +571,7 @@ class NetworkRequest {
|
|
|
572
571
|
|
|
573
572
|
/**
|
|
574
573
|
* @param {NetworkRequest} record
|
|
575
|
-
* @return {
|
|
574
|
+
* @return {Lantern.NetworkRequest<NetworkRequest>}
|
|
576
575
|
*/
|
|
577
576
|
static asLanternNetworkRequest(record) {
|
|
578
577
|
return {
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
package/types/gatherer.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ import Config from './config.js';
|
|
|
17
17
|
import Result from './lhr/lhr.js';
|
|
18
18
|
import Protocol from './protocol.js';
|
|
19
19
|
import Puppeteer from './puppeteer.js';
|
|
20
|
-
import
|
|
20
|
+
import * as Lantern from '../core/lib/lantern/types/lantern.js';
|
|
21
21
|
|
|
22
22
|
type CrdpEvents = CrdpMappings.Events;
|
|
23
23
|
type CrdpCommands = CrdpMappings.Commands;
|
package/types/lhr/lhr.d.ts
CHANGED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2024 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import * as LH from '../lh.js';
|
|
8
|
-
|
|
9
|
-
declare namespace Lantern {
|
|
10
|
-
type ParsedURL = {
|
|
11
|
-
/**
|
|
12
|
-
* Equivalent to a `new URL(url).protocol` BUT w/o the trailing colon (:)
|
|
13
|
-
*/
|
|
14
|
-
scheme: string;
|
|
15
|
-
/**
|
|
16
|
-
* Equivalent to a `new URL(url).hostname`
|
|
17
|
-
*/
|
|
18
|
-
host: string;
|
|
19
|
-
securityOrigin: string;
|
|
20
|
-
};
|
|
21
|
-
type LightriderStatistics = {
|
|
22
|
-
/**
|
|
23
|
-
* The difference in networkEndTime between the observed Lighthouse networkEndTime and Lightrider's derived networkEndTime.
|
|
24
|
-
*/
|
|
25
|
-
endTimeDeltaMs: number;
|
|
26
|
-
/**
|
|
27
|
-
* The time spent making a TCP connection (connect + SSL). Note: this is poorly named.
|
|
28
|
-
*/
|
|
29
|
-
TCPMs: number;
|
|
30
|
-
/**
|
|
31
|
-
* The time spent requesting a resource from a remote server, we use this to approx RTT. Note: this is poorly names, it really should be "server response time".
|
|
32
|
-
*/
|
|
33
|
-
requestMs: number;
|
|
34
|
-
/**
|
|
35
|
-
* Time to receive the entire response payload starting the clock on receiving the first fragment (first non-header byte).
|
|
36
|
-
*/
|
|
37
|
-
responseMs: number;
|
|
38
|
-
};
|
|
39
|
-
class NetworkRequest<T = any> {
|
|
40
|
-
/**
|
|
41
|
-
* The canonical network record.
|
|
42
|
-
* Users of Lantern must create NetworkRequests matching this interface,
|
|
43
|
-
* but can store the source-of-truth for their network model in this `record`
|
|
44
|
-
* property. This is then accessible as a read-only property on NetworkNode.
|
|
45
|
-
*/
|
|
46
|
-
record?: T;
|
|
47
|
-
|
|
48
|
-
requestId: string;
|
|
49
|
-
connectionId: string;
|
|
50
|
-
connectionReused: boolean;
|
|
51
|
-
url: string;
|
|
52
|
-
protocol: string;
|
|
53
|
-
parsedURL: ParsedURL;
|
|
54
|
-
documentURL: string;
|
|
55
|
-
/** When the renderer process initially discovers a network request, in milliseconds. */
|
|
56
|
-
rendererStartTime: number;
|
|
57
|
-
/**
|
|
58
|
-
* When the network service is about to handle a request, ie. just before going to the
|
|
59
|
-
* HTTP cache or going to the network for DNS/connection setup, in milliseconds.
|
|
60
|
-
*/
|
|
61
|
-
networkRequestTime: number;
|
|
62
|
-
/** When the last byte of the response headers is received, in milliseconds. */
|
|
63
|
-
responseHeadersEndTime: number;
|
|
64
|
-
/** When the last byte of the response body is received, in milliseconds. */
|
|
65
|
-
networkEndTime: number;
|
|
66
|
-
transferSize: number;
|
|
67
|
-
resourceSize: number;
|
|
68
|
-
fromDiskCache: boolean;
|
|
69
|
-
fromMemoryCache: boolean;
|
|
70
|
-
// TODO(15841): remove from lantern.
|
|
71
|
-
/** Extra timing information available only when run in Lightrider. */
|
|
72
|
-
lrStatistics: LightriderStatistics | undefined;
|
|
73
|
-
finished: boolean;
|
|
74
|
-
statusCode: number;
|
|
75
|
-
/** The network request that this one redirected to */
|
|
76
|
-
redirectDestination: NetworkRequest<T> | undefined;
|
|
77
|
-
failed: boolean;
|
|
78
|
-
initiator: LH.Crdp.Network.Initiator;
|
|
79
|
-
initiatorRequest: NetworkRequest<T> | undefined;
|
|
80
|
-
/** The chain of network requests that redirected to this one */
|
|
81
|
-
redirects: NetworkRequest[] | undefined;
|
|
82
|
-
timing: LH.Crdp.Network.ResourceTiming | undefined;
|
|
83
|
-
resourceType: LH.Crdp.Network.ResourceType | undefined;
|
|
84
|
-
mimeType: string;
|
|
85
|
-
priority: LH.Crdp.Network.ResourcePriority;
|
|
86
|
-
frameId: string | undefined;
|
|
87
|
-
sessionTargetType: LH.Protocol.TargetType | undefined;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export namespace Simulation {
|
|
91
|
-
type GraphNode<T> = import('../../core/lib/lantern/base-node.js').Node<T>;
|
|
92
|
-
type GraphNetworkNode<T> = import('../../core/lib/lantern/network-node.js').NetworkNode<T>;
|
|
93
|
-
type GraphCPUNode = import('../../core/lib/lantern/cpu-node.js').CPUNode;
|
|
94
|
-
type Simulator<T> = import('../../core/lib/lantern/simulator/simulator.js').Simulator<T>;
|
|
95
|
-
|
|
96
|
-
interface MetricCoefficients {
|
|
97
|
-
intercept: number;
|
|
98
|
-
optimistic: number;
|
|
99
|
-
pessimistic: number;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
interface Options {
|
|
103
|
-
rtt?: number;
|
|
104
|
-
throughput?: number;
|
|
105
|
-
observedThroughput: number;
|
|
106
|
-
maximumConcurrentRequests?: number;
|
|
107
|
-
cpuSlowdownMultiplier?: number;
|
|
108
|
-
layoutTaskMultiplier?: number;
|
|
109
|
-
additionalRttByOrigin?: Map<string, number>;
|
|
110
|
-
serverResponseTimeByOrigin?: Map<string, number>;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
interface NodeTiming {
|
|
114
|
-
startTime: number;
|
|
115
|
-
endTime: number;
|
|
116
|
-
duration: number;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
interface Result<T = any> {
|
|
120
|
-
timeInMs: number;
|
|
121
|
-
nodeTimings: Map<GraphNode<T>, NodeTiming>;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|