lighthouse 11.6.0-dev.20240304 → 11.6.0-dev.20240305
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/prioritize-lcp-image.d.ts +1 -1
- package/core/computed/load-simulator.d.ts +3 -1
- package/core/computed/load-simulator.js +3 -1
- package/core/computed/metrics/lantern-metric.d.ts +1 -1
- package/core/computed/page-dependency-graph.d.ts +1 -54
- package/core/computed/page-dependency-graph.js +3 -450
- package/core/lib/lantern/lantern.d.ts +0 -1
- package/core/lib/lantern/lantern.js +0 -3
- package/core/lib/lantern/network-node.d.ts +5 -4
- package/core/lib/lantern/network-node.js +7 -5
- package/core/lib/lantern/page-dependency-graph.d.ts +58 -0
- package/core/lib/lantern/page-dependency-graph.js +463 -0
- package/core/lib/lantern/simulator/connection-pool.d.ts +15 -14
- package/core/lib/lantern/simulator/connection-pool.js +9 -8
- package/core/lib/lantern/simulator/dns-cache.d.ts +11 -4
- package/core/lib/lantern/simulator/dns-cache.js +3 -3
- package/core/lib/lantern/simulator/network-analyzer.d.ts +30 -29
- package/core/lib/lantern/simulator/network-analyzer.js +15 -14
- package/core/lib/lantern/simulator/simulator.d.ts +20 -14
- package/core/lib/lantern/simulator/simulator.js +19 -11
- package/core/lib/network-recorder.js +1 -1
- package/core/lib/network-request.d.ts +4 -2
- package/core/lib/network-request.js +3 -2
- package/package.json +1 -1
- package/tsconfig.json +1 -0
- package/types/gatherer.d.ts +8 -35
- package/types/internal/lantern.d.ts +115 -73
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type NetworkRequest = import('../../../../types/internal/lantern.js').Lantern.NetworkRequest;
|
|
1
2
|
export class DNSCache {
|
|
2
3
|
/**
|
|
3
4
|
* @param {{rtt: number}} options
|
|
@@ -11,19 +12,19 @@ export class DNSCache {
|
|
|
11
12
|
resolvedAt: number;
|
|
12
13
|
}>;
|
|
13
14
|
/**
|
|
14
|
-
* @param {
|
|
15
|
+
* @param {NetworkRequest} request
|
|
15
16
|
* @param {{requestedAt: number, shouldUpdateCache: boolean}=} options
|
|
16
17
|
* @return {number}
|
|
17
18
|
*/
|
|
18
|
-
getTimeUntilResolution(request:
|
|
19
|
+
getTimeUntilResolution(request: NetworkRequest, options?: {
|
|
19
20
|
requestedAt: number;
|
|
20
21
|
shouldUpdateCache: boolean;
|
|
21
22
|
} | undefined): number;
|
|
22
23
|
/**
|
|
23
|
-
* @param {
|
|
24
|
+
* @param {NetworkRequest} request
|
|
24
25
|
* @param {number} resolvedAt
|
|
25
26
|
*/
|
|
26
|
-
_updateCacheResolvedAtIfNeeded(request:
|
|
27
|
+
_updateCacheResolvedAtIfNeeded(request: NetworkRequest, resolvedAt: number): void;
|
|
27
28
|
/**
|
|
28
29
|
* Forcefully sets the DNS resolution time for a record.
|
|
29
30
|
* Useful for testing and alternate execution simulations.
|
|
@@ -36,6 +37,12 @@ export class DNSCache {
|
|
|
36
37
|
export namespace DNSCache {
|
|
37
38
|
export { DNS_RESOLUTION_RTT_MULTIPLIER as RTT_MULTIPLIER };
|
|
38
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* @license
|
|
42
|
+
* Copyright 2018 Google LLC
|
|
43
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
44
|
+
*/
|
|
45
|
+
/** @typedef {import('../../../../types/internal/lantern.js').Lantern.NetworkRequest} NetworkRequest */
|
|
39
46
|
declare const DNS_RESOLUTION_RTT_MULTIPLIER: 2;
|
|
40
47
|
export {};
|
|
41
48
|
//# sourceMappingURL=dns-cache.d.ts.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/** @typedef {import('../../../../types/internal/lantern.js').Lantern.NetworkRequest} NetworkRequest */
|
|
8
8
|
|
|
9
9
|
// A DNS lookup will usually take ~1-2 roundtrips of connection latency plus the extra DNS routing time.
|
|
10
10
|
// Example: https://www.webpagetest.org/result/180703_3A_e33ec79747c002ed4d7bcbfc81462203/1/details/#waterfall_view_step1
|
|
@@ -25,7 +25,7 @@ class DNSCache {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* @param {
|
|
28
|
+
* @param {NetworkRequest} request
|
|
29
29
|
* @param {{requestedAt: number, shouldUpdateCache: boolean}=} options
|
|
30
30
|
* @return {number}
|
|
31
31
|
*/
|
|
@@ -47,7 +47,7 @@ class DNSCache {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* @param {
|
|
50
|
+
* @param {NetworkRequest} request
|
|
51
51
|
* @param {number} resolvedAt
|
|
52
52
|
*/
|
|
53
53
|
_updateCacheResolvedAtIfNeeded(request, resolvedAt) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type NetworkRequest = import('../../../../types/internal/lantern.js').Lantern.NetworkRequest;
|
|
1
2
|
export type Summary = {
|
|
2
3
|
min: number;
|
|
3
4
|
max: number;
|
|
@@ -32,10 +33,10 @@ export class NetworkAnalyzer {
|
|
|
32
33
|
*/
|
|
33
34
|
static get SUMMARY(): string;
|
|
34
35
|
/**
|
|
35
|
-
* @param {
|
|
36
|
-
* @return {Map<string,
|
|
36
|
+
* @param {NetworkRequest[]} records
|
|
37
|
+
* @return {Map<string, NetworkRequest[]>}
|
|
37
38
|
*/
|
|
38
|
-
static groupByOrigin(records:
|
|
39
|
+
static groupByOrigin(records: NetworkRequest[]): Map<string, NetworkRequest[]>;
|
|
39
40
|
/**
|
|
40
41
|
* @param {number[]} values
|
|
41
42
|
* @return {Summary}
|
|
@@ -46,14 +47,14 @@ export class NetworkAnalyzer {
|
|
|
46
47
|
* @return {Map<string, Summary>}
|
|
47
48
|
*/
|
|
48
49
|
static summarize(values: Map<string, number[]>): Map<string, Summary>;
|
|
49
|
-
/** @typedef {{record:
|
|
50
|
+
/** @typedef {{record: NetworkRequest, timing: LH.Crdp.Network.ResourceTiming, connectionReused?: boolean}} RequestInfo */
|
|
50
51
|
/**
|
|
51
|
-
* @param {
|
|
52
|
+
* @param {NetworkRequest[]} records
|
|
52
53
|
* @param {(e: RequestInfo) => number | number[] | undefined} iteratee
|
|
53
54
|
* @return {Map<string, number[]>}
|
|
54
55
|
*/
|
|
55
|
-
static _estimateValueByOrigin(records:
|
|
56
|
-
record:
|
|
56
|
+
static _estimateValueByOrigin(records: NetworkRequest[], iteratee: (e: {
|
|
57
|
+
record: NetworkRequest;
|
|
57
58
|
timing: LH.Crdp.Network.ResourceTiming;
|
|
58
59
|
connectionReused?: boolean | undefined;
|
|
59
60
|
}) => number | number[] | undefined): Map<string, number[]>;
|
|
@@ -69,7 +70,7 @@ export class NetworkAnalyzer {
|
|
|
69
70
|
* @return {number[]|number|undefined}
|
|
70
71
|
*/
|
|
71
72
|
static _estimateRTTViaConnectionTiming(info: {
|
|
72
|
-
record:
|
|
73
|
+
record: NetworkRequest;
|
|
73
74
|
timing: LH.Crdp.Network.ResourceTiming;
|
|
74
75
|
connectionReused?: boolean | undefined;
|
|
75
76
|
}): number[] | number | undefined;
|
|
@@ -82,7 +83,7 @@ export class NetworkAnalyzer {
|
|
|
82
83
|
* @return {number|undefined}
|
|
83
84
|
*/
|
|
84
85
|
static _estimateRTTViaDownloadTiming(info: {
|
|
85
|
-
record:
|
|
86
|
+
record: NetworkRequest;
|
|
86
87
|
timing: LH.Crdp.Network.ResourceTiming;
|
|
87
88
|
connectionReused?: boolean | undefined;
|
|
88
89
|
}): number | undefined;
|
|
@@ -96,7 +97,7 @@ export class NetworkAnalyzer {
|
|
|
96
97
|
* @return {number|undefined}
|
|
97
98
|
*/
|
|
98
99
|
static _estimateRTTViaSendStartTiming(info: {
|
|
99
|
-
record:
|
|
100
|
+
record: NetworkRequest;
|
|
100
101
|
timing: LH.Crdp.Network.ResourceTiming;
|
|
101
102
|
connectionReused?: boolean | undefined;
|
|
102
103
|
}): number | undefined;
|
|
@@ -110,32 +111,32 @@ export class NetworkAnalyzer {
|
|
|
110
111
|
* @return {number|undefined}
|
|
111
112
|
*/
|
|
112
113
|
static _estimateRTTViaHeadersEndTiming(info: {
|
|
113
|
-
record:
|
|
114
|
+
record: NetworkRequest;
|
|
114
115
|
timing: LH.Crdp.Network.ResourceTiming;
|
|
115
116
|
connectionReused?: boolean | undefined;
|
|
116
117
|
}): number | undefined;
|
|
117
118
|
/**
|
|
118
119
|
* Given the RTT to each origin, estimates the observed server response times.
|
|
119
120
|
*
|
|
120
|
-
* @param {
|
|
121
|
+
* @param {NetworkRequest[]} records
|
|
121
122
|
* @param {Map<string, number>} rttByOrigin
|
|
122
123
|
* @return {Map<string, number[]>}
|
|
123
124
|
*/
|
|
124
|
-
static _estimateResponseTimeByOrigin(records:
|
|
125
|
+
static _estimateResponseTimeByOrigin(records: NetworkRequest[], rttByOrigin: Map<string, number>): Map<string, number[]>;
|
|
125
126
|
/**
|
|
126
|
-
* @param {
|
|
127
|
+
* @param {NetworkRequest[]} records
|
|
127
128
|
* @return {boolean}
|
|
128
129
|
*/
|
|
129
|
-
static canTrustConnectionInformation(records:
|
|
130
|
+
static canTrustConnectionInformation(records: NetworkRequest[]): boolean;
|
|
130
131
|
/**
|
|
131
132
|
* Returns a map of requestId -> connectionReused, estimating the information if the information
|
|
132
133
|
* available in the records themselves appears untrustworthy.
|
|
133
134
|
*
|
|
134
|
-
* @param {
|
|
135
|
+
* @param {NetworkRequest[]} records
|
|
135
136
|
* @param {{forceCoarseEstimates: boolean}} [options]
|
|
136
137
|
* @return {Map<string, boolean>}
|
|
137
138
|
*/
|
|
138
|
-
static estimateIfConnectionWasReused(records:
|
|
139
|
+
static estimateIfConnectionWasReused(records: NetworkRequest[], options?: {
|
|
139
140
|
forceCoarseEstimates: boolean;
|
|
140
141
|
} | undefined): Map<string, boolean>;
|
|
141
142
|
/**
|
|
@@ -143,20 +144,20 @@ export class NetworkAnalyzer {
|
|
|
143
144
|
* Attempts to use the most accurate information first and falls back to coarser estimates when it
|
|
144
145
|
* is unavailable.
|
|
145
146
|
*
|
|
146
|
-
* @param {
|
|
147
|
+
* @param {NetworkRequest[]} records
|
|
147
148
|
* @param {RTTEstimateOptions} [options]
|
|
148
149
|
* @return {Map<string, Summary>}
|
|
149
150
|
*/
|
|
150
|
-
static estimateRTTByOrigin(records:
|
|
151
|
+
static estimateRTTByOrigin(records: NetworkRequest[], options?: RTTEstimateOptions | undefined): Map<string, Summary>;
|
|
151
152
|
/**
|
|
152
153
|
* Estimates the server response time of each origin. RTT times can be passed in or will be
|
|
153
154
|
* estimated automatically if not provided.
|
|
154
155
|
*
|
|
155
|
-
* @param {
|
|
156
|
+
* @param {NetworkRequest[]} records
|
|
156
157
|
* @param {RTTEstimateOptions & {rttByOrigin?: Map<string, number>}} [options]
|
|
157
158
|
* @return {Map<string, Summary>}
|
|
158
159
|
*/
|
|
159
|
-
static estimateServerResponseTimeByOrigin(records:
|
|
160
|
+
static estimateServerResponseTimeByOrigin(records: NetworkRequest[], options?: (RTTEstimateOptions & {
|
|
160
161
|
rttByOrigin?: Map<string, number> | undefined;
|
|
161
162
|
}) | undefined): Map<string, Summary>;
|
|
162
163
|
/**
|
|
@@ -164,32 +165,32 @@ export class NetworkAnalyzer {
|
|
|
164
165
|
* Excludes data URI, failed or otherwise incomplete, and cached requests.
|
|
165
166
|
* Returns Infinity if there were no analyzable network records.
|
|
166
167
|
*
|
|
167
|
-
* @param {Array<
|
|
168
|
+
* @param {Array<NetworkRequest>} networkRecords
|
|
168
169
|
* @return {number}
|
|
169
170
|
*/
|
|
170
|
-
static estimateThroughput(networkRecords: Array<
|
|
171
|
+
static estimateThroughput(networkRecords: Array<NetworkRequest>): number;
|
|
171
172
|
/**
|
|
172
|
-
* @template {
|
|
173
|
+
* @template {NetworkRequest} T
|
|
173
174
|
* @param {Array<T>} records
|
|
174
175
|
* @param {string} resourceUrl
|
|
175
176
|
* @return {T|undefined}
|
|
176
177
|
*/
|
|
177
|
-
static findResourceForUrl<T extends import("../../../../types/internal/lantern.js").NetworkRequest<any>>(records: T[], resourceUrl: string): T | undefined;
|
|
178
|
+
static findResourceForUrl<T extends import("../../../../types/internal/lantern.js").Lantern.NetworkRequest<any>>(records: T[], resourceUrl: string): T | undefined;
|
|
178
179
|
/**
|
|
179
|
-
* @template {
|
|
180
|
+
* @template {NetworkRequest} T
|
|
180
181
|
* @param {Array<T>} records
|
|
181
182
|
* @param {string} resourceUrl
|
|
182
183
|
* @return {T|undefined}
|
|
183
184
|
*/
|
|
184
|
-
static findLastDocumentForUrl<T_1 extends import("../../../../types/internal/lantern.js").NetworkRequest<any>>(records: T_1[], resourceUrl: string): T_1 | undefined;
|
|
185
|
+
static findLastDocumentForUrl<T_1 extends import("../../../../types/internal/lantern.js").Lantern.NetworkRequest<any>>(records: T_1[], resourceUrl: string): T_1 | undefined;
|
|
185
186
|
/**
|
|
186
187
|
* Resolves redirect chain given a main document.
|
|
187
188
|
* See: {@link NetworkAnalyzer.findLastDocumentForUrl}) for how to retrieve main document.
|
|
188
189
|
*
|
|
189
|
-
* @template {
|
|
190
|
+
* @template {NetworkRequest} T
|
|
190
191
|
* @param {T} request
|
|
191
192
|
* @return {T}
|
|
192
193
|
*/
|
|
193
|
-
static resolveRedirects<T_2 extends import("../../../../types/internal/lantern.js").NetworkRequest<any>>(request: T_2): T_2;
|
|
194
|
+
static resolveRedirects<T_2 extends import("../../../../types/internal/lantern.js").Lantern.NetworkRequest<any>>(request: T_2): T_2;
|
|
194
195
|
}
|
|
195
196
|
//# sourceMappingURL=network-analyzer.d.ts.map
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/** @typedef {import('../../../../types/internal/lantern.js').Lantern.NetworkRequest} NetworkRequest */
|
|
8
|
+
|
|
8
9
|
import UrlUtils from '../../url-utils.js';
|
|
9
10
|
|
|
10
11
|
const INITIAL_CWD = 14 * 1024;
|
|
@@ -32,8 +33,8 @@ class NetworkAnalyzer {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
|
-
* @param {
|
|
36
|
-
* @return {Map<string,
|
|
36
|
+
* @param {NetworkRequest[]} records
|
|
37
|
+
* @return {Map<string, NetworkRequest[]>}
|
|
37
38
|
*/
|
|
38
39
|
static groupByOrigin(records) {
|
|
39
40
|
const grouped = new Map();
|
|
@@ -88,10 +89,10 @@ class NetworkAnalyzer {
|
|
|
88
89
|
return summaryByKey;
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
/** @typedef {{record:
|
|
92
|
+
/** @typedef {{record: NetworkRequest, timing: LH.Crdp.Network.ResourceTiming, connectionReused?: boolean}} RequestInfo */
|
|
92
93
|
|
|
93
94
|
/**
|
|
94
|
-
* @param {
|
|
95
|
+
* @param {NetworkRequest[]} records
|
|
95
96
|
* @param {(e: RequestInfo) => number | number[] | undefined} iteratee
|
|
96
97
|
* @return {Map<string, number[]>}
|
|
97
98
|
*/
|
|
@@ -250,7 +251,7 @@ class NetworkAnalyzer {
|
|
|
250
251
|
/**
|
|
251
252
|
* Given the RTT to each origin, estimates the observed server response times.
|
|
252
253
|
*
|
|
253
|
-
* @param {
|
|
254
|
+
* @param {NetworkRequest[]} records
|
|
254
255
|
* @param {Map<string, number>} rttByOrigin
|
|
255
256
|
* @return {Map<string, number[]>}
|
|
256
257
|
*/
|
|
@@ -271,7 +272,7 @@ class NetworkAnalyzer {
|
|
|
271
272
|
}
|
|
272
273
|
|
|
273
274
|
/**
|
|
274
|
-
* @param {
|
|
275
|
+
* @param {NetworkRequest[]} records
|
|
275
276
|
* @return {boolean}
|
|
276
277
|
*/
|
|
277
278
|
static canTrustConnectionInformation(records) {
|
|
@@ -291,7 +292,7 @@ class NetworkAnalyzer {
|
|
|
291
292
|
* Returns a map of requestId -> connectionReused, estimating the information if the information
|
|
292
293
|
* available in the records themselves appears untrustworthy.
|
|
293
294
|
*
|
|
294
|
-
* @param {
|
|
295
|
+
* @param {NetworkRequest[]} records
|
|
295
296
|
* @param {{forceCoarseEstimates: boolean}} [options]
|
|
296
297
|
* @return {Map<string, boolean>}
|
|
297
298
|
*/
|
|
@@ -335,7 +336,7 @@ class NetworkAnalyzer {
|
|
|
335
336
|
* Attempts to use the most accurate information first and falls back to coarser estimates when it
|
|
336
337
|
* is unavailable.
|
|
337
338
|
*
|
|
338
|
-
* @param {
|
|
339
|
+
* @param {NetworkRequest[]} records
|
|
339
340
|
* @param {RTTEstimateOptions} [options]
|
|
340
341
|
* @return {Map<string, Summary>}
|
|
341
342
|
*/
|
|
@@ -416,7 +417,7 @@ class NetworkAnalyzer {
|
|
|
416
417
|
* Estimates the server response time of each origin. RTT times can be passed in or will be
|
|
417
418
|
* estimated automatically if not provided.
|
|
418
419
|
*
|
|
419
|
-
* @param {
|
|
420
|
+
* @param {NetworkRequest[]} records
|
|
420
421
|
* @param {RTTEstimateOptions & {rttByOrigin?: Map<string, number>}} [options]
|
|
421
422
|
* @return {Map<string, Summary>}
|
|
422
423
|
*/
|
|
@@ -442,7 +443,7 @@ class NetworkAnalyzer {
|
|
|
442
443
|
* Excludes data URI, failed or otherwise incomplete, and cached requests.
|
|
443
444
|
* Returns Infinity if there were no analyzable network records.
|
|
444
445
|
*
|
|
445
|
-
* @param {Array<
|
|
446
|
+
* @param {Array<NetworkRequest>} networkRecords
|
|
446
447
|
* @return {number}
|
|
447
448
|
*/
|
|
448
449
|
static estimateThroughput(networkRecords) {
|
|
@@ -495,7 +496,7 @@ class NetworkAnalyzer {
|
|
|
495
496
|
}
|
|
496
497
|
|
|
497
498
|
/**
|
|
498
|
-
* @template {
|
|
499
|
+
* @template {NetworkRequest} T
|
|
499
500
|
* @param {Array<T>} records
|
|
500
501
|
* @param {string} resourceUrl
|
|
501
502
|
* @return {T|undefined}
|
|
@@ -509,7 +510,7 @@ class NetworkAnalyzer {
|
|
|
509
510
|
}
|
|
510
511
|
|
|
511
512
|
/**
|
|
512
|
-
* @template {
|
|
513
|
+
* @template {NetworkRequest} T
|
|
513
514
|
* @param {Array<T>} records
|
|
514
515
|
* @param {string} resourceUrl
|
|
515
516
|
* @return {T|undefined}
|
|
@@ -529,7 +530,7 @@ class NetworkAnalyzer {
|
|
|
529
530
|
* Resolves redirect chain given a main document.
|
|
530
531
|
* See: {@link NetworkAnalyzer.findLastDocumentForUrl}) for how to retrieve main document.
|
|
531
532
|
*
|
|
532
|
-
* @template {
|
|
533
|
+
* @template {NetworkRequest} T
|
|
533
534
|
* @param {T} request
|
|
534
535
|
* @return {T}
|
|
535
536
|
*/
|
|
@@ -1,9 +1,16 @@
|
|
|
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>;
|
|
1
5
|
export type Node = import('../base-node.js').Node;
|
|
2
6
|
export type NetworkNode = import('../network-node.js').NetworkNode;
|
|
3
7
|
export type CpuNode = import('../cpu-node.js').CPUNode;
|
|
4
8
|
export type CompleteNodeTiming = import('./simulator-timing-map.js').CpuNodeTimingComplete | import('./simulator-timing-map.js').NetworkNodeTimingComplete;
|
|
5
9
|
export type ConnectionTiming = import('./simulator-timing-map.js').ConnectionTiming;
|
|
6
|
-
|
|
10
|
+
/**
|
|
11
|
+
* @template [T=any]
|
|
12
|
+
*/
|
|
13
|
+
export class Simulator<T = any> {
|
|
7
14
|
/** @return {Map<string, Map<Node, CompleteNodeTiming>>} */
|
|
8
15
|
static get ALL_NODE_TIMINGS(): Map<string, Map<Node, CompleteNodeTiming>>;
|
|
9
16
|
/**
|
|
@@ -14,11 +21,11 @@ export class Simulator {
|
|
|
14
21
|
*/
|
|
15
22
|
static _computeNodeStartPosition(node: Node): number;
|
|
16
23
|
/**
|
|
17
|
-
* @param {
|
|
24
|
+
* @param {SimulationOptions} [options]
|
|
18
25
|
*/
|
|
19
|
-
constructor(options?:
|
|
20
|
-
/** @type {Required<
|
|
21
|
-
_options: Required<
|
|
26
|
+
constructor(options?: import("../../../../types/internal/lantern.js").Lantern.Simulation.Options | undefined);
|
|
27
|
+
/** @type {Required<SimulationOptions>} */
|
|
28
|
+
_options: Required<SimulationOptions>;
|
|
22
29
|
_rtt: number;
|
|
23
30
|
_throughput: number;
|
|
24
31
|
_maximumConcurrentRequests: number;
|
|
@@ -67,10 +74,10 @@ export class Simulator {
|
|
|
67
74
|
*/
|
|
68
75
|
_markNodeAsComplete(node: Node, endTime: number, connectionTiming?: import("./simulator-timing-map.js").ConnectionTiming | undefined): void;
|
|
69
76
|
/**
|
|
70
|
-
* @param {
|
|
77
|
+
* @param {NetworkRequest} record
|
|
71
78
|
* @return {?TcpConnection}
|
|
72
79
|
*/
|
|
73
|
-
_acquireConnection(record:
|
|
80
|
+
_acquireConnection(record: NetworkRequest): TcpConnection | null;
|
|
74
81
|
/**
|
|
75
82
|
* @return {Node[]}
|
|
76
83
|
*/
|
|
@@ -114,16 +121,16 @@ export class Simulator {
|
|
|
114
121
|
*/
|
|
115
122
|
_updateProgressMadeInTimePeriod(node: Node, timePeriodLength: number, totalElapsedTime: number): number | void;
|
|
116
123
|
/**
|
|
117
|
-
* @return {{nodeTimings: Map<Node,
|
|
124
|
+
* @return {{nodeTimings: Map<Node, SimulationNodeTiming>, completeNodeTimings: Map<Node, CompleteNodeTiming>}}
|
|
118
125
|
*/
|
|
119
126
|
_computeFinalNodeTimings(): {
|
|
120
|
-
nodeTimings: Map<Node,
|
|
127
|
+
nodeTimings: Map<Node, SimulationNodeTiming>;
|
|
121
128
|
completeNodeTimings: Map<Node, CompleteNodeTiming>;
|
|
122
129
|
};
|
|
123
130
|
/**
|
|
124
|
-
* @return {Required<
|
|
131
|
+
* @return {Required<SimulationOptions>}
|
|
125
132
|
*/
|
|
126
|
-
getOptions(): Required<
|
|
133
|
+
getOptions(): Required<SimulationOptions>;
|
|
127
134
|
/**
|
|
128
135
|
* Estimates the time taken to process all of the graph's nodes, returns the overall time along with
|
|
129
136
|
* each node annotated by start/end times.
|
|
@@ -135,18 +142,17 @@ export class Simulator {
|
|
|
135
142
|
*
|
|
136
143
|
* @param {Node} graph
|
|
137
144
|
* @param {{flexibleOrdering?: boolean, label?: string}=} options
|
|
138
|
-
* @return {
|
|
145
|
+
* @return {SimulationResult<T>}
|
|
139
146
|
*/
|
|
140
147
|
simulate(graph: Node, options?: {
|
|
141
148
|
flexibleOrdering?: boolean;
|
|
142
149
|
label?: string;
|
|
143
|
-
} | undefined):
|
|
150
|
+
} | undefined): SimulationResult<T>;
|
|
144
151
|
/**
|
|
145
152
|
* @param {number} wastedBytes
|
|
146
153
|
*/
|
|
147
154
|
computeWastedMsFromWastedBytes(wastedBytes: number): number;
|
|
148
155
|
}
|
|
149
|
-
import * as LH from '../../../../types/lh.js';
|
|
150
156
|
import { SimulatorTimingMap } from './simulator-timing-map.js';
|
|
151
157
|
import { DNSCache } from './dns-cache.js';
|
|
152
158
|
import { ConnectionPool } from './connection-pool.js';
|
|
@@ -4,8 +4,13 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
// This could be replaced by jsdoc namespace import, when ready.
|
|
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
|
+
|
|
9
14
|
import {BaseNode} from '../base-node.js';
|
|
10
15
|
import {TcpConnection} from './tcp-connection.js';
|
|
11
16
|
import {ConnectionPool} from './connection-pool.js';
|
|
@@ -47,12 +52,15 @@ const PriorityStartTimePenalty = {
|
|
|
47
52
|
/** @type {Map<string, Map<Node, CompleteNodeTiming>>} */
|
|
48
53
|
const ALL_SIMULATION_NODE_TIMINGS = new Map();
|
|
49
54
|
|
|
55
|
+
/**
|
|
56
|
+
* @template [T=any]
|
|
57
|
+
*/
|
|
50
58
|
class Simulator {
|
|
51
59
|
/**
|
|
52
|
-
* @param {
|
|
60
|
+
* @param {SimulationOptions} [options]
|
|
53
61
|
*/
|
|
54
62
|
constructor(options) {
|
|
55
|
-
/** @type {Required<
|
|
63
|
+
/** @type {Required<SimulationOptions>} */
|
|
56
64
|
this._options = Object.assign(
|
|
57
65
|
{
|
|
58
66
|
rtt: mobileSlow4G.rttMs,
|
|
@@ -102,7 +110,7 @@ class Simulator {
|
|
|
102
110
|
* @param {Node} graph
|
|
103
111
|
*/
|
|
104
112
|
_initializeConnectionPool(graph) {
|
|
105
|
-
/** @type {
|
|
113
|
+
/** @type {NetworkRequest[]} */
|
|
106
114
|
const records = [];
|
|
107
115
|
graph.getRootNode().traverse(node => {
|
|
108
116
|
if (node.type === BaseNode.TYPES.NETWORK) {
|
|
@@ -191,7 +199,7 @@ class Simulator {
|
|
|
191
199
|
}
|
|
192
200
|
|
|
193
201
|
/**
|
|
194
|
-
* @param {
|
|
202
|
+
* @param {NetworkRequest} record
|
|
195
203
|
* @return {?TcpConnection}
|
|
196
204
|
*/
|
|
197
205
|
_acquireConnection(record) {
|
|
@@ -385,7 +393,7 @@ class Simulator {
|
|
|
385
393
|
}
|
|
386
394
|
|
|
387
395
|
/**
|
|
388
|
-
* @return {{nodeTimings: Map<Node,
|
|
396
|
+
* @return {{nodeTimings: Map<Node, SimulationNodeTiming>, completeNodeTimings: Map<Node, CompleteNodeTiming>}}
|
|
389
397
|
*/
|
|
390
398
|
_computeFinalNodeTimings() {
|
|
391
399
|
/** @type {Array<[Node, CompleteNodeTiming]>} */
|
|
@@ -396,8 +404,8 @@ class Simulator {
|
|
|
396
404
|
// Most consumers will want the entries sorted by startTime, so insert them in that order
|
|
397
405
|
completeNodeTimingEntries.sort((a, b) => a[1].startTime - b[1].startTime);
|
|
398
406
|
|
|
399
|
-
// Trimmed version of type `
|
|
400
|
-
/** @type {Array<[Node,
|
|
407
|
+
// Trimmed version of type `SimulationNodeTiming`.
|
|
408
|
+
/** @type {Array<[Node, SimulationNodeTiming]>} */
|
|
401
409
|
const nodeTimingEntries = completeNodeTimingEntries.map(([node, timing]) => {
|
|
402
410
|
return [node, {
|
|
403
411
|
startTime: timing.startTime,
|
|
@@ -413,7 +421,7 @@ class Simulator {
|
|
|
413
421
|
}
|
|
414
422
|
|
|
415
423
|
/**
|
|
416
|
-
* @return {Required<
|
|
424
|
+
* @return {Required<SimulationOptions>}
|
|
417
425
|
*/
|
|
418
426
|
getOptions() {
|
|
419
427
|
return this._options;
|
|
@@ -430,7 +438,7 @@ class Simulator {
|
|
|
430
438
|
*
|
|
431
439
|
* @param {Node} graph
|
|
432
440
|
* @param {{flexibleOrdering?: boolean, label?: string}=} options
|
|
433
|
-
* @return {
|
|
441
|
+
* @return {SimulationResult<T>}
|
|
434
442
|
*/
|
|
435
443
|
simulate(graph, options) {
|
|
436
444
|
if (BaseNode.hasCycle(graph)) {
|
|
@@ -10,7 +10,7 @@ import log from 'lighthouse-logger';
|
|
|
10
10
|
|
|
11
11
|
import * as LH from '../../types/lh.js';
|
|
12
12
|
import {NetworkRequest} from './network-request.js';
|
|
13
|
-
import {PageDependencyGraph} from '../
|
|
13
|
+
import {PageDependencyGraph} from '../lib/lantern/page-dependency-graph.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @typedef {{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type LanternNetworkRequest<T> = import('../../types/internal/lantern.js').Lantern.NetworkRequest<T>;
|
|
1
2
|
export type HeaderEntry = {
|
|
2
3
|
name: string;
|
|
3
4
|
value: string;
|
|
@@ -49,9 +50,9 @@ export class NetworkRequest {
|
|
|
49
50
|
static get TYPES(): LH.Util.SelfMap<LH.Crdp.Network.ResourceType>;
|
|
50
51
|
/**
|
|
51
52
|
* @param {NetworkRequest} record
|
|
52
|
-
* @return {
|
|
53
|
+
* @return {LanternNetworkRequest<NetworkRequest>}
|
|
53
54
|
*/
|
|
54
|
-
static asLanternNetworkRequest(record: NetworkRequest):
|
|
55
|
+
static asLanternNetworkRequest(record: NetworkRequest): LanternNetworkRequest<NetworkRequest>;
|
|
55
56
|
/**
|
|
56
57
|
* @param {NetworkRequest} record
|
|
57
58
|
* @return {boolean}
|
|
@@ -258,6 +259,7 @@ export namespace NetworkRequest {
|
|
|
258
259
|
export { HEADER_PROTOCOL_IS_H2 };
|
|
259
260
|
}
|
|
260
261
|
import * as LH from '../../types/lh.js';
|
|
262
|
+
/** @template T @typedef {import('../../types/internal/lantern.js').Lantern.NetworkRequest<T>} LanternNetworkRequest */
|
|
261
263
|
declare const HEADER_TCP: "X-TCPMs";
|
|
262
264
|
declare const HEADER_SSL: "X-SSLMs";
|
|
263
265
|
declare const HEADER_REQ: "X-RequestMs";
|
|
@@ -53,9 +53,10 @@
|
|
|
53
53
|
*/
|
|
54
54
|
|
|
55
55
|
import * as LH from '../../types/lh.js';
|
|
56
|
-
import * as Lantern from './lantern/lantern.js';
|
|
57
56
|
import UrlUtils from './url-utils.js';
|
|
58
57
|
|
|
58
|
+
/** @template T @typedef {import('../../types/internal/lantern.js').Lantern.NetworkRequest<T>} LanternNetworkRequest */
|
|
59
|
+
|
|
59
60
|
// Lightrider X-Header names for timing information.
|
|
60
61
|
// See: _updateTransferSizeForLightrider and _updateTimingsForLightrider.
|
|
61
62
|
const HEADER_TCP = 'X-TCPMs'; // Note: this should have been called something like ConnectMs, as it includes SSL.
|
|
@@ -571,7 +572,7 @@ class NetworkRequest {
|
|
|
571
572
|
|
|
572
573
|
/**
|
|
573
574
|
* @param {NetworkRequest} record
|
|
574
|
-
* @return {
|
|
575
|
+
* @return {LanternNetworkRequest<NetworkRequest>}
|
|
575
576
|
*/
|
|
576
577
|
static asLanternNetworkRequest(record) {
|
|
577
578
|
return {
|
package/package.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
"core/test/lib/i18n/i18n-test.js",
|
|
70
70
|
"core/test/lib/icons-test.js",
|
|
71
71
|
"core/test/lib/lantern/base-node-test.js",
|
|
72
|
+
"core/test/lib/lantern/page-dependency-graph-test.js",
|
|
72
73
|
"core/test/lib/lantern/simulator/connection-pool-test.js",
|
|
73
74
|
"core/test/lib/lantern/simulator/dns-cache-test.js",
|
|
74
75
|
"core/test/lib/lantern/simulator/network-analyzer-test.js",
|