lighthouse 11.6.0-dev.20240303 → 11.6.0-dev.20240304
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 +7 -7
- package/core/audits/byte-efficiency/render-blocking-resources.d.ts +4 -3
- package/core/audits/byte-efficiency/render-blocking-resources.js +6 -6
- package/core/audits/dobetterweb/uses-http2.d.ts +3 -3
- package/core/audits/dobetterweb/uses-http2.js +4 -4
- package/core/audits/installable-manifest.d.ts +2 -0
- package/core/audits/installable-manifest.js +2 -0
- package/core/audits/prioritize-lcp-image.d.ts +1 -1
- package/core/computed/document-urls.js +1 -1
- package/core/computed/load-simulator.d.ts +1 -1
- package/core/computed/load-simulator.js +1 -1
- package/core/computed/main-resource.js +1 -1
- package/core/computed/metrics/lantern-first-contentful-paint.d.ts +6 -6
- package/core/computed/metrics/lantern-first-contentful-paint.js +4 -4
- package/core/computed/metrics/lantern-first-meaningful-paint.d.ts +2 -2
- package/core/computed/metrics/lantern-first-meaningful-paint.js +1 -1
- package/core/computed/metrics/lantern-interactive.d.ts +2 -6
- package/core/computed/metrics/lantern-interactive.js +2 -2
- package/core/computed/metrics/lantern-largest-contentful-paint.d.ts +2 -2
- package/core/computed/metrics/lantern-largest-contentful-paint.js +1 -1
- package/core/computed/metrics/lantern-max-potential-fid.d.ts +2 -2
- package/core/computed/metrics/lantern-max-potential-fid.js +2 -2
- package/core/computed/metrics/lantern-metric.d.ts +7 -6
- package/core/computed/metrics/lantern-metric.js +4 -4
- package/core/computed/metrics/lantern-speed-index.d.ts +2 -2
- package/core/computed/metrics/lantern-speed-index.js +2 -2
- package/core/computed/metrics/lantern-total-blocking-time.d.ts +2 -2
- package/core/computed/metrics/lantern-total-blocking-time.js +2 -2
- package/core/computed/network-analysis.js +1 -1
- package/core/computed/page-dependency-graph.d.ts +9 -9
- package/core/computed/page-dependency-graph.js +9 -9
- package/core/lib/asset-saver.js +1 -1
- package/core/lib/{dependency-graph → lantern}/base-node.d.ts +12 -8
- package/core/lib/{dependency-graph → lantern}/base-node.js +8 -3
- package/core/lib/{dependency-graph → lantern}/cpu-node.d.ts +5 -1
- package/core/lib/{dependency-graph → lantern}/cpu-node.js +4 -0
- package/core/lib/lantern/lantern.d.ts +9 -0
- package/core/lib/lantern/lantern.js +34 -0
- package/core/lib/{dependency-graph → lantern}/network-node.d.ts +16 -10
- package/core/lib/lantern/network-node.js +113 -0
- package/core/lib/{dependency-graph → lantern}/simulator/connection-pool.d.ts +11 -11
- package/core/lib/{dependency-graph → lantern}/simulator/connection-pool.js +6 -5
- package/core/lib/{dependency-graph → lantern}/simulator/dns-cache.d.ts +4 -5
- package/core/lib/{dependency-graph → lantern}/simulator/dns-cache.js +3 -3
- package/core/lib/{dependency-graph → lantern}/simulator/network-analyzer.d.ts +35 -32
- package/core/lib/{dependency-graph → lantern}/simulator/network-analyzer.js +21 -17
- package/core/lib/{dependency-graph → lantern}/simulator/simulator.d.ts +3 -3
- package/core/lib/{dependency-graph → lantern}/simulator/simulator.js +8 -7
- package/core/lib/lantern-trace-saver.d.ts +4 -4
- package/core/lib/lantern-trace-saver.js +6 -4
- package/core/lib/navigation-error.js +1 -1
- package/core/lib/network-request.d.ts +5 -0
- package/core/lib/network-request.js +12 -0
- package/package.json +1 -1
- package/shared/localization/locales/en-US.json +3 -0
- package/shared/localization/locales/en-XL.json +3 -0
- package/third-party/chromium-synchronization/installability-errors-test.js +1 -1
- package/tsconfig.json +5 -5
- package/types/artifacts.d.ts +1 -1
- package/types/gatherer.d.ts +5 -5
- package/types/internal/lantern.d.ts +82 -0
- package/core/lib/dependency-graph/network-node.js +0 -99
- /package/core/lib/{dependency-graph → lantern}/simulator/simulator-timing-map.d.ts +0 -0
- /package/core/lib/{dependency-graph → lantern}/simulator/simulator-timing-map.js +0 -0
- /package/core/lib/{dependency-graph → lantern}/simulator/tcp-connection.d.ts +0 -0
- /package/core/lib/{dependency-graph → lantern}/simulator/tcp-connection.js +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* A union of all types derived from BaseNode, allowing type check discrimination
|
|
3
3
|
* based on `node.type`. If a new node type is created, it should be added here.
|
|
4
4
|
*/
|
|
5
|
-
export type Node = import('./cpu-node.js').CPUNode | import('./network-node.js').NetworkNode
|
|
5
|
+
export type Node<T = any> = import('./cpu-node.js').CPUNode<T> | import('./network-node.js').NetworkNode<T>;
|
|
6
6
|
/**
|
|
7
7
|
* @license
|
|
8
8
|
* Copyright 2017 Google LLC
|
|
@@ -11,7 +11,8 @@ export type Node = import('./cpu-node.js').CPUNode | import('./network-node.js')
|
|
|
11
11
|
/**
|
|
12
12
|
* A union of all types derived from BaseNode, allowing type check discrimination
|
|
13
13
|
* based on `node.type`. If a new node type is created, it should be added here.
|
|
14
|
-
* @
|
|
14
|
+
* @template [T=any]
|
|
15
|
+
* @typedef {import('./cpu-node.js').CPUNode<T> | import('./network-node.js').NetworkNode<T>} Node
|
|
15
16
|
*/
|
|
16
17
|
/**
|
|
17
18
|
* @fileoverview This class encapsulates logic for handling resources and tasks used to model the
|
|
@@ -25,7 +26,10 @@ export type Node = import('./cpu-node.js').CPUNode | import('./network-node.js')
|
|
|
25
26
|
* This allows particular optimizations in this class so that we do no need to check for cycles as
|
|
26
27
|
* these methods are called and we can always start traversal at the root node.
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
|
+
/**
|
|
30
|
+
* @template [T=any]
|
|
31
|
+
*/
|
|
32
|
+
export class BaseNode<T = any> {
|
|
29
33
|
/**
|
|
30
34
|
* Returns whether the given node has a cycle in its dependent graph by performing a DFS.
|
|
31
35
|
* @param {Node} node
|
|
@@ -134,17 +138,17 @@ export class BaseNode {
|
|
|
134
138
|
*
|
|
135
139
|
* The `getNextNodes` function takes a visited node and returns which nodes to
|
|
136
140
|
* visit next. It defaults to returning the node's dependents.
|
|
137
|
-
* @param {(node: Node
|
|
138
|
-
* @param {function(Node): Node[]} [getNextNodes]
|
|
141
|
+
* @param {(node: Node<T>, traversalPath: Node<T>[]) => void} callback
|
|
142
|
+
* @param {function(Node<T>): Node<T>[]} [getNextNodes]
|
|
139
143
|
*/
|
|
140
|
-
traverse(callback: (node: Node
|
|
144
|
+
traverse(callback: (node: Node<T>, traversalPath: Node<T>[]) => void, getNextNodes?: ((arg0: Node<T>) => Node<T>[]) | undefined): void;
|
|
141
145
|
/**
|
|
142
146
|
* @see BaseNode.traverse
|
|
143
147
|
* @param {function(Node): Node[]} [getNextNodes]
|
|
144
148
|
*/
|
|
145
149
|
traverseGenerator(getNextNodes?: ((arg0: Node) => Node[]) | undefined): Generator<{
|
|
146
|
-
node: Node
|
|
147
|
-
traversalPath: Node[];
|
|
150
|
+
node: Node<any>;
|
|
151
|
+
traversalPath: Node<any>[];
|
|
148
152
|
}, void, unknown>;
|
|
149
153
|
/**
|
|
150
154
|
* @param {Node} node
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
/**
|
|
8
8
|
* A union of all types derived from BaseNode, allowing type check discrimination
|
|
9
9
|
* based on `node.type`. If a new node type is created, it should be added here.
|
|
10
|
-
* @
|
|
10
|
+
* @template [T=any]
|
|
11
|
+
* @typedef {import('./cpu-node.js').CPUNode<T> | import('./network-node.js').NetworkNode<T>} Node
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -22,6 +23,10 @@
|
|
|
22
23
|
* This allows particular optimizations in this class so that we do no need to check for cycles as
|
|
23
24
|
* these methods are called and we can always start traversal at the root node.
|
|
24
25
|
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @template [T=any]
|
|
29
|
+
*/
|
|
25
30
|
class BaseNode {
|
|
26
31
|
/**
|
|
27
32
|
* @param {string} id
|
|
@@ -256,8 +261,8 @@ class BaseNode {
|
|
|
256
261
|
*
|
|
257
262
|
* The `getNextNodes` function takes a visited node and returns which nodes to
|
|
258
263
|
* visit next. It defaults to returning the node's dependents.
|
|
259
|
-
* @param {(node: Node
|
|
260
|
-
* @param {function(Node): Node[]} [getNextNodes]
|
|
264
|
+
* @param {(node: Node<T>, traversalPath: Node<T>[]) => void} callback
|
|
265
|
+
* @param {function(Node<T>): Node<T>[]} [getNextNodes]
|
|
261
266
|
*/
|
|
262
267
|
traverse(callback, getNextNodes) {
|
|
263
268
|
for (const {node, traversalPath} of this.traverseGenerator(getNextNodes)) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export const NetworkRequest: import("../../../types/internal/lantern").NetworkRequest<any>;
|
|
7
|
+
/** @type {LH.Util.SelfMap<LH.Crdp.Network.ResourceType>} */
|
|
8
|
+
export const NetworkRequestTypes: LH.Util.SelfMap<LH.Crdp.Network.ResourceType>;
|
|
9
|
+
//# sourceMappingURL=lantern.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const NetworkRequest = /** @type {import('../../../types/internal/lantern').NetworkRequest} */({});
|
|
8
|
+
|
|
9
|
+
/** @type {LH.Util.SelfMap<LH.Crdp.Network.ResourceType>} */
|
|
10
|
+
const NetworkRequestTypes = {
|
|
11
|
+
XHR: 'XHR',
|
|
12
|
+
Fetch: 'Fetch',
|
|
13
|
+
EventSource: 'EventSource',
|
|
14
|
+
Script: 'Script',
|
|
15
|
+
Stylesheet: 'Stylesheet',
|
|
16
|
+
Image: 'Image',
|
|
17
|
+
Media: 'Media',
|
|
18
|
+
Font: 'Font',
|
|
19
|
+
Document: 'Document',
|
|
20
|
+
TextTrack: 'TextTrack',
|
|
21
|
+
WebSocket: 'WebSocket',
|
|
22
|
+
Other: 'Other',
|
|
23
|
+
Manifest: 'Manifest',
|
|
24
|
+
SignedExchange: 'SignedExchange',
|
|
25
|
+
Ping: 'Ping',
|
|
26
|
+
Preflight: 'Preflight',
|
|
27
|
+
CSPViolationReport: 'CSPViolationReport',
|
|
28
|
+
Prefetch: 'Prefetch',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
NetworkRequest,
|
|
33
|
+
NetworkRequestTypes,
|
|
34
|
+
};
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @template [T=any]
|
|
3
|
+
* @extends {BaseNode<T>}
|
|
4
|
+
*/
|
|
5
|
+
export class NetworkNode<T = any> extends BaseNode<T> {
|
|
2
6
|
/**
|
|
3
|
-
* @param {
|
|
7
|
+
* @param {Lantern.NetworkRequest<T>} networkRequest
|
|
4
8
|
*/
|
|
5
|
-
constructor(
|
|
9
|
+
constructor(networkRequest: import("../../../types/internal/lantern.js").NetworkRequest<any>);
|
|
6
10
|
/** @private */
|
|
7
|
-
private
|
|
11
|
+
private _request;
|
|
8
12
|
get type(): "network";
|
|
9
13
|
/**
|
|
10
|
-
* @return {
|
|
14
|
+
* @return {Readonly<T>}
|
|
11
15
|
*/
|
|
12
|
-
get record():
|
|
16
|
+
get record(): Readonly<T>;
|
|
17
|
+
/**
|
|
18
|
+
* @return {Lantern.NetworkRequest<T>}
|
|
19
|
+
*/
|
|
20
|
+
get request(): import("../../../types/internal/lantern.js").NetworkRequest<any>;
|
|
13
21
|
/**
|
|
14
22
|
* @return {string}
|
|
15
23
|
*/
|
|
@@ -33,11 +41,9 @@ export class NetworkNode extends BaseNode {
|
|
|
33
41
|
*/
|
|
34
42
|
hasRenderBlockingPriority(): boolean;
|
|
35
43
|
/**
|
|
36
|
-
* @return {NetworkNode}
|
|
44
|
+
* @return {NetworkNode<T>}
|
|
37
45
|
*/
|
|
38
|
-
cloneWithoutRelationships(): NetworkNode
|
|
46
|
+
cloneWithoutRelationships(): NetworkNode<T>;
|
|
39
47
|
}
|
|
40
48
|
import { BaseNode } from './base-node.js';
|
|
41
|
-
import { NetworkRequest } from '../network-request.js';
|
|
42
|
-
import * as LH from '../../../types/lh.js';
|
|
43
49
|
//# sourceMappingURL=network-node.d.ts.map
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as Lantern from './lantern.js';
|
|
8
|
+
import {BaseNode} from './base-node.js';
|
|
9
|
+
// TODO(15841): bring impl of isNonNetworkRequest inside lantern and remove this.
|
|
10
|
+
import UrlUtils from '../url-utils.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @template [T=any]
|
|
14
|
+
* @extends {BaseNode<T>}
|
|
15
|
+
*/
|
|
16
|
+
class NetworkNode extends BaseNode {
|
|
17
|
+
/**
|
|
18
|
+
* @param {Lantern.NetworkRequest<T>} networkRequest
|
|
19
|
+
*/
|
|
20
|
+
constructor(networkRequest) {
|
|
21
|
+
super(networkRequest.requestId);
|
|
22
|
+
/** @private */
|
|
23
|
+
this._request = networkRequest;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get type() {
|
|
27
|
+
return BaseNode.TYPES.NETWORK;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @return {number}
|
|
32
|
+
*/
|
|
33
|
+
get startTime() {
|
|
34
|
+
return this._request.rendererStartTime * 1000;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @return {number}
|
|
39
|
+
*/
|
|
40
|
+
get endTime() {
|
|
41
|
+
return this._request.networkEndTime * 1000;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @return {Readonly<T>}
|
|
46
|
+
*/
|
|
47
|
+
get record() {
|
|
48
|
+
return /** @type {Required<T>} */ (this._request.record);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @return {Lantern.NetworkRequest<T>}
|
|
53
|
+
*/
|
|
54
|
+
get request() {
|
|
55
|
+
return this._request;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @return {string}
|
|
60
|
+
*/
|
|
61
|
+
get initiatorType() {
|
|
62
|
+
return this._request.initiator && this._request.initiator.type;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @return {boolean}
|
|
67
|
+
*/
|
|
68
|
+
get fromDiskCache() {
|
|
69
|
+
return !!this._request.fromDiskCache;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @return {boolean}
|
|
74
|
+
*/
|
|
75
|
+
get isNonNetworkProtocol() {
|
|
76
|
+
// The 'protocol' field in devtools a string more like a `scheme`
|
|
77
|
+
return UrlUtils.isNonNetworkProtocol(this.request.protocol) ||
|
|
78
|
+
// But `protocol` can fail to be populated if the request fails, so fallback to scheme.
|
|
79
|
+
UrlUtils.isNonNetworkProtocol(this.request.parsedURL.scheme);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Returns whether this network record can be downloaded without a TCP connection.
|
|
84
|
+
* During simulation we treat data coming in over a network connection separately from on-device data.
|
|
85
|
+
* @return {boolean}
|
|
86
|
+
*/
|
|
87
|
+
get isConnectionless() {
|
|
88
|
+
return this.fromDiskCache || this.isNonNetworkProtocol;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @return {boolean}
|
|
93
|
+
*/
|
|
94
|
+
hasRenderBlockingPriority() {
|
|
95
|
+
const priority = this._request.priority;
|
|
96
|
+
const isScript = this._request.resourceType === Lantern.NetworkRequestTypes.Script;
|
|
97
|
+
const isDocument = this._request.resourceType === Lantern.NetworkRequestTypes.Document;
|
|
98
|
+
const isBlockingScript = priority === 'High' && isScript;
|
|
99
|
+
const isBlockingHtmlImport = priority === 'High' && isDocument;
|
|
100
|
+
return priority === 'VeryHigh' || isBlockingScript || isBlockingHtmlImport;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @return {NetworkNode<T>}
|
|
105
|
+
*/
|
|
106
|
+
cloneWithoutRelationships() {
|
|
107
|
+
const node = new NetworkNode(this._request);
|
|
108
|
+
node.setIsMainDocument(this._isMainDocument);
|
|
109
|
+
return node;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export {NetworkNode};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export class ConnectionPool {
|
|
2
2
|
/**
|
|
3
|
-
* @param {
|
|
3
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
4
4
|
* @param {Required<LH.Gatherer.Simulation.Options>} options
|
|
5
5
|
*/
|
|
6
|
-
constructor(records:
|
|
6
|
+
constructor(records: import("../../../../types/internal/lantern.js").NetworkRequest<any>[], options: Required<LH.Gatherer.Simulation.Options>);
|
|
7
7
|
_options: Required<LH.Gatherer.Simulation.Options>;
|
|
8
|
-
_records: import("
|
|
8
|
+
_records: import("../../../../types/internal/lantern.js").NetworkRequest<any>[];
|
|
9
9
|
/** @type {Map<string, TcpConnection[]>} */
|
|
10
10
|
_connectionsByOrigin: Map<string, TcpConnection[]>;
|
|
11
|
-
/** @type {Map<
|
|
12
|
-
_connectionsByRecord: Map<
|
|
11
|
+
/** @type {Map<Lantern.NetworkRequest, TcpConnection>} */
|
|
12
|
+
_connectionsByRecord: Map<import("../../../../types/internal/lantern.js").NetworkRequest<any>, TcpConnection>;
|
|
13
13
|
_connectionsInUse: Set<any>;
|
|
14
14
|
_connectionReusedByRequestId: Map<string, boolean>;
|
|
15
15
|
/**
|
|
@@ -33,25 +33,25 @@ export class ConnectionPool {
|
|
|
33
33
|
* If ignoreConnectionReused is true, acquire will consider all connections not in use as available.
|
|
34
34
|
* Otherwise, only connections that have matching "warmth" are considered available.
|
|
35
35
|
*
|
|
36
|
-
* @param {
|
|
36
|
+
* @param {Lantern.NetworkRequest} record
|
|
37
37
|
* @param {{ignoreConnectionReused?: boolean}} options
|
|
38
38
|
* @return {?TcpConnection}
|
|
39
39
|
*/
|
|
40
|
-
acquire(record:
|
|
40
|
+
acquire(record: import("../../../../types/internal/lantern.js").NetworkRequest<any>, options?: {
|
|
41
41
|
ignoreConnectionReused?: boolean;
|
|
42
42
|
}): TcpConnection | null;
|
|
43
43
|
/**
|
|
44
44
|
* Return the connection currently being used to fetch a record. If no connection
|
|
45
45
|
* currently being used for this record, an error will be thrown.
|
|
46
46
|
*
|
|
47
|
-
* @param {
|
|
47
|
+
* @param {Lantern.NetworkRequest} record
|
|
48
48
|
* @return {TcpConnection}
|
|
49
49
|
*/
|
|
50
|
-
acquireActiveConnectionFromRecord(record:
|
|
50
|
+
acquireActiveConnectionFromRecord(record: import("../../../../types/internal/lantern.js").NetworkRequest<any>): TcpConnection;
|
|
51
51
|
/**
|
|
52
|
-
* @param {
|
|
52
|
+
* @param {Lantern.NetworkRequest} record
|
|
53
53
|
*/
|
|
54
|
-
release(record:
|
|
54
|
+
release(record: import("../../../../types/internal/lantern.js").NetworkRequest<any>): void;
|
|
55
55
|
}
|
|
56
56
|
import * as LH from '../../../../types/lh.js';
|
|
57
57
|
import { TcpConnection } from './tcp-connection.js';
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import * as LH from '../../../../types/lh.js';
|
|
8
|
+
import * as Lantern from '../lantern.js';
|
|
8
9
|
import {NetworkAnalyzer} from './network-analyzer.js';
|
|
9
10
|
import {TcpConnection} from './tcp-connection.js';
|
|
10
11
|
|
|
@@ -17,7 +18,7 @@ const CONNECTIONS_PER_ORIGIN = 6;
|
|
|
17
18
|
|
|
18
19
|
export class ConnectionPool {
|
|
19
20
|
/**
|
|
20
|
-
* @param {
|
|
21
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
21
22
|
* @param {Required<LH.Gatherer.Simulation.Options>} options
|
|
22
23
|
*/
|
|
23
24
|
constructor(records, options) {
|
|
@@ -26,7 +27,7 @@ export class ConnectionPool {
|
|
|
26
27
|
this._records = records;
|
|
27
28
|
/** @type {Map<string, TcpConnection[]>} */
|
|
28
29
|
this._connectionsByOrigin = new Map();
|
|
29
|
-
/** @type {Map<
|
|
30
|
+
/** @type {Map<Lantern.NetworkRequest, TcpConnection>} */
|
|
30
31
|
this._connectionsByRecord = new Map();
|
|
31
32
|
this._connectionsInUse = new Set();
|
|
32
33
|
this._connectionReusedByRequestId = NetworkAnalyzer.estimateIfConnectionWasReused(records, {
|
|
@@ -124,7 +125,7 @@ export class ConnectionPool {
|
|
|
124
125
|
* If ignoreConnectionReused is true, acquire will consider all connections not in use as available.
|
|
125
126
|
* Otherwise, only connections that have matching "warmth" are considered available.
|
|
126
127
|
*
|
|
127
|
-
* @param {
|
|
128
|
+
* @param {Lantern.NetworkRequest} record
|
|
128
129
|
* @param {{ignoreConnectionReused?: boolean}} options
|
|
129
130
|
* @return {?TcpConnection}
|
|
130
131
|
*/
|
|
@@ -150,7 +151,7 @@ export class ConnectionPool {
|
|
|
150
151
|
* Return the connection currently being used to fetch a record. If no connection
|
|
151
152
|
* currently being used for this record, an error will be thrown.
|
|
152
153
|
*
|
|
153
|
-
* @param {
|
|
154
|
+
* @param {Lantern.NetworkRequest} record
|
|
154
155
|
* @return {TcpConnection}
|
|
155
156
|
*/
|
|
156
157
|
acquireActiveConnectionFromRecord(record) {
|
|
@@ -161,7 +162,7 @@ export class ConnectionPool {
|
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
/**
|
|
164
|
-
* @param {
|
|
165
|
+
* @param {Lantern.NetworkRequest} record
|
|
165
166
|
*/
|
|
166
167
|
release(record) {
|
|
167
168
|
const connection = this._connectionsByRecord.get(record);
|
|
@@ -11,19 +11,19 @@ export class DNSCache {
|
|
|
11
11
|
resolvedAt: number;
|
|
12
12
|
}>;
|
|
13
13
|
/**
|
|
14
|
-
* @param {
|
|
14
|
+
* @param {Lantern.NetworkRequest} request
|
|
15
15
|
* @param {{requestedAt: number, shouldUpdateCache: boolean}=} options
|
|
16
16
|
* @return {number}
|
|
17
17
|
*/
|
|
18
|
-
getTimeUntilResolution(request:
|
|
18
|
+
getTimeUntilResolution(request: import("../../../../types/internal/lantern.js").NetworkRequest<any>, options?: {
|
|
19
19
|
requestedAt: number;
|
|
20
20
|
shouldUpdateCache: boolean;
|
|
21
21
|
} | undefined): number;
|
|
22
22
|
/**
|
|
23
|
-
* @param {
|
|
23
|
+
* @param {Lantern.NetworkRequest} request
|
|
24
24
|
* @param {number} resolvedAt
|
|
25
25
|
*/
|
|
26
|
-
_updateCacheResolvedAtIfNeeded(request:
|
|
26
|
+
_updateCacheResolvedAtIfNeeded(request: import("../../../../types/internal/lantern.js").NetworkRequest<any>, resolvedAt: number): void;
|
|
27
27
|
/**
|
|
28
28
|
* Forcefully sets the DNS resolution time for a record.
|
|
29
29
|
* Useful for testing and alternate execution simulations.
|
|
@@ -36,7 +36,6 @@ export class DNSCache {
|
|
|
36
36
|
export namespace DNSCache {
|
|
37
37
|
export { DNS_RESOLUTION_RTT_MULTIPLIER as RTT_MULTIPLIER };
|
|
38
38
|
}
|
|
39
|
-
import * as LH from '../../../../types/lh.js';
|
|
40
39
|
declare const DNS_RESOLUTION_RTT_MULTIPLIER: 2;
|
|
41
40
|
export {};
|
|
42
41
|
//# sourceMappingURL=dns-cache.d.ts.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import * as
|
|
7
|
+
import * as Lantern from '../lantern.js';
|
|
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 {Lantern.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 {Lantern.NetworkRequest} request
|
|
51
51
|
* @param {number} resolvedAt
|
|
52
52
|
*/
|
|
53
53
|
_updateCacheResolvedAtIfNeeded(request, resolvedAt) {
|
|
@@ -32,10 +32,10 @@ export class NetworkAnalyzer {
|
|
|
32
32
|
*/
|
|
33
33
|
static get SUMMARY(): string;
|
|
34
34
|
/**
|
|
35
|
-
* @param {
|
|
36
|
-
* @return {Map<string,
|
|
35
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
36
|
+
* @return {Map<string, Lantern.NetworkRequest[]>}
|
|
37
37
|
*/
|
|
38
|
-
static groupByOrigin(records:
|
|
38
|
+
static groupByOrigin(records: import("../../../../types/internal/lantern.js").NetworkRequest<any>[]): Map<string, import("../../../../types/internal/lantern.js").NetworkRequest<any>[]>;
|
|
39
39
|
/**
|
|
40
40
|
* @param {number[]} values
|
|
41
41
|
* @return {Summary}
|
|
@@ -46,14 +46,14 @@ export class NetworkAnalyzer {
|
|
|
46
46
|
* @return {Map<string, Summary>}
|
|
47
47
|
*/
|
|
48
48
|
static summarize(values: Map<string, number[]>): Map<string, Summary>;
|
|
49
|
-
/** @typedef {{record:
|
|
49
|
+
/** @typedef {{record: Lantern.NetworkRequest, timing: LH.Crdp.Network.ResourceTiming, connectionReused?: boolean}} RequestInfo */
|
|
50
50
|
/**
|
|
51
|
-
* @param {
|
|
51
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
52
52
|
* @param {(e: RequestInfo) => number | number[] | undefined} iteratee
|
|
53
53
|
* @return {Map<string, number[]>}
|
|
54
54
|
*/
|
|
55
|
-
static _estimateValueByOrigin(records:
|
|
56
|
-
record:
|
|
55
|
+
static _estimateValueByOrigin(records: import("../../../../types/internal/lantern.js").NetworkRequest<any>[], iteratee: (e: {
|
|
56
|
+
record: import("../../../../types/internal/lantern.js").NetworkRequest<any>;
|
|
57
57
|
timing: LH.Crdp.Network.ResourceTiming;
|
|
58
58
|
connectionReused?: boolean | undefined;
|
|
59
59
|
}) => number | number[] | undefined): Map<string, number[]>;
|
|
@@ -69,7 +69,7 @@ export class NetworkAnalyzer {
|
|
|
69
69
|
* @return {number[]|number|undefined}
|
|
70
70
|
*/
|
|
71
71
|
static _estimateRTTViaConnectionTiming(info: {
|
|
72
|
-
record:
|
|
72
|
+
record: import("../../../../types/internal/lantern.js").NetworkRequest<any>;
|
|
73
73
|
timing: LH.Crdp.Network.ResourceTiming;
|
|
74
74
|
connectionReused?: boolean | undefined;
|
|
75
75
|
}): number[] | number | undefined;
|
|
@@ -82,7 +82,7 @@ export class NetworkAnalyzer {
|
|
|
82
82
|
* @return {number|undefined}
|
|
83
83
|
*/
|
|
84
84
|
static _estimateRTTViaDownloadTiming(info: {
|
|
85
|
-
record:
|
|
85
|
+
record: import("../../../../types/internal/lantern.js").NetworkRequest<any>;
|
|
86
86
|
timing: LH.Crdp.Network.ResourceTiming;
|
|
87
87
|
connectionReused?: boolean | undefined;
|
|
88
88
|
}): number | undefined;
|
|
@@ -96,7 +96,7 @@ export class NetworkAnalyzer {
|
|
|
96
96
|
* @return {number|undefined}
|
|
97
97
|
*/
|
|
98
98
|
static _estimateRTTViaSendStartTiming(info: {
|
|
99
|
-
record:
|
|
99
|
+
record: import("../../../../types/internal/lantern.js").NetworkRequest<any>;
|
|
100
100
|
timing: LH.Crdp.Network.ResourceTiming;
|
|
101
101
|
connectionReused?: boolean | undefined;
|
|
102
102
|
}): number | undefined;
|
|
@@ -110,32 +110,32 @@ export class NetworkAnalyzer {
|
|
|
110
110
|
* @return {number|undefined}
|
|
111
111
|
*/
|
|
112
112
|
static _estimateRTTViaHeadersEndTiming(info: {
|
|
113
|
-
record:
|
|
113
|
+
record: import("../../../../types/internal/lantern.js").NetworkRequest<any>;
|
|
114
114
|
timing: LH.Crdp.Network.ResourceTiming;
|
|
115
115
|
connectionReused?: boolean | undefined;
|
|
116
116
|
}): number | undefined;
|
|
117
117
|
/**
|
|
118
118
|
* Given the RTT to each origin, estimates the observed server response times.
|
|
119
119
|
*
|
|
120
|
-
* @param {
|
|
120
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
121
121
|
* @param {Map<string, number>} rttByOrigin
|
|
122
122
|
* @return {Map<string, number[]>}
|
|
123
123
|
*/
|
|
124
|
-
static _estimateResponseTimeByOrigin(records:
|
|
124
|
+
static _estimateResponseTimeByOrigin(records: import("../../../../types/internal/lantern.js").NetworkRequest<any>[], rttByOrigin: Map<string, number>): Map<string, number[]>;
|
|
125
125
|
/**
|
|
126
|
-
* @param {
|
|
126
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
127
127
|
* @return {boolean}
|
|
128
128
|
*/
|
|
129
|
-
static canTrustConnectionInformation(records:
|
|
129
|
+
static canTrustConnectionInformation(records: import("../../../../types/internal/lantern.js").NetworkRequest<any>[]): boolean;
|
|
130
130
|
/**
|
|
131
131
|
* Returns a map of requestId -> connectionReused, estimating the information if the information
|
|
132
132
|
* available in the records themselves appears untrustworthy.
|
|
133
133
|
*
|
|
134
|
-
* @param {
|
|
134
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
135
135
|
* @param {{forceCoarseEstimates: boolean}} [options]
|
|
136
136
|
* @return {Map<string, boolean>}
|
|
137
137
|
*/
|
|
138
|
-
static estimateIfConnectionWasReused(records:
|
|
138
|
+
static estimateIfConnectionWasReused(records: import("../../../../types/internal/lantern.js").NetworkRequest<any>[], options?: {
|
|
139
139
|
forceCoarseEstimates: boolean;
|
|
140
140
|
} | undefined): Map<string, boolean>;
|
|
141
141
|
/**
|
|
@@ -143,20 +143,20 @@ export class NetworkAnalyzer {
|
|
|
143
143
|
* Attempts to use the most accurate information first and falls back to coarser estimates when it
|
|
144
144
|
* is unavailable.
|
|
145
145
|
*
|
|
146
|
-
* @param {
|
|
146
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
147
147
|
* @param {RTTEstimateOptions} [options]
|
|
148
148
|
* @return {Map<string, Summary>}
|
|
149
149
|
*/
|
|
150
|
-
static estimateRTTByOrigin(records:
|
|
150
|
+
static estimateRTTByOrigin(records: import("../../../../types/internal/lantern.js").NetworkRequest<any>[], options?: RTTEstimateOptions | undefined): Map<string, Summary>;
|
|
151
151
|
/**
|
|
152
152
|
* Estimates the server response time of each origin. RTT times can be passed in or will be
|
|
153
153
|
* estimated automatically if not provided.
|
|
154
154
|
*
|
|
155
|
-
* @param {
|
|
155
|
+
* @param {Lantern.NetworkRequest[]} records
|
|
156
156
|
* @param {RTTEstimateOptions & {rttByOrigin?: Map<string, number>}} [options]
|
|
157
157
|
* @return {Map<string, Summary>}
|
|
158
158
|
*/
|
|
159
|
-
static estimateServerResponseTimeByOrigin(records:
|
|
159
|
+
static estimateServerResponseTimeByOrigin(records: import("../../../../types/internal/lantern.js").NetworkRequest<any>[], options?: (RTTEstimateOptions & {
|
|
160
160
|
rttByOrigin?: Map<string, number> | undefined;
|
|
161
161
|
}) | undefined): Map<string, Summary>;
|
|
162
162
|
/**
|
|
@@ -164,29 +164,32 @@ export class NetworkAnalyzer {
|
|
|
164
164
|
* Excludes data URI, failed or otherwise incomplete, and cached requests.
|
|
165
165
|
* Returns Infinity if there were no analyzable network records.
|
|
166
166
|
*
|
|
167
|
-
* @param {Array<
|
|
167
|
+
* @param {Array<Lantern.NetworkRequest>} networkRecords
|
|
168
168
|
* @return {number}
|
|
169
169
|
*/
|
|
170
|
-
static estimateThroughput(networkRecords: Array<
|
|
170
|
+
static estimateThroughput(networkRecords: Array<import("../../../../types/internal/lantern.js").NetworkRequest<any>>): number;
|
|
171
171
|
/**
|
|
172
|
-
* @
|
|
172
|
+
* @template {Lantern.NetworkRequest} T
|
|
173
|
+
* @param {Array<T>} records
|
|
173
174
|
* @param {string} resourceUrl
|
|
174
|
-
* @return {
|
|
175
|
+
* @return {T|undefined}
|
|
175
176
|
*/
|
|
176
|
-
static findResourceForUrl(
|
|
177
|
+
static findResourceForUrl<T extends import("../../../../types/internal/lantern.js").NetworkRequest<any>>(records: T[], resourceUrl: string): T | undefined;
|
|
177
178
|
/**
|
|
178
|
-
* @
|
|
179
|
+
* @template {Lantern.NetworkRequest} T
|
|
180
|
+
* @param {Array<T>} records
|
|
179
181
|
* @param {string} resourceUrl
|
|
180
|
-
* @return {
|
|
182
|
+
* @return {T|undefined}
|
|
181
183
|
*/
|
|
182
|
-
static findLastDocumentForUrl(
|
|
184
|
+
static findLastDocumentForUrl<T_1 extends import("../../../../types/internal/lantern.js").NetworkRequest<any>>(records: T_1[], resourceUrl: string): T_1 | undefined;
|
|
183
185
|
/**
|
|
184
186
|
* Resolves redirect chain given a main document.
|
|
185
187
|
* See: {@link NetworkAnalyzer.findLastDocumentForUrl}) for how to retrieve main document.
|
|
186
188
|
*
|
|
187
|
-
* @
|
|
188
|
-
* @
|
|
189
|
+
* @template {Lantern.NetworkRequest} T
|
|
190
|
+
* @param {T} request
|
|
191
|
+
* @return {T}
|
|
189
192
|
*/
|
|
190
|
-
static resolveRedirects(request:
|
|
193
|
+
static resolveRedirects<T_2 extends import("../../../../types/internal/lantern.js").NetworkRequest<any>>(request: T_2): T_2;
|
|
191
194
|
}
|
|
192
195
|
//# sourceMappingURL=network-analyzer.d.ts.map
|