lighthouse 11.6.0-dev.20240305 → 11.6.0-dev.20240307

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/core/computed/load-simulator.d.ts +0 -2
  2. package/core/computed/load-simulator.js +2 -3
  3. package/core/computed/metrics/lantern-first-contentful-paint.d.ts +12 -0
  4. package/core/computed/metrics/lantern-first-meaningful-paint.d.ts +12 -0
  5. package/core/computed/metrics/lantern-interactive.d.ts +6 -0
  6. package/core/computed/metrics/lantern-interactive.js +1 -1
  7. package/core/computed/metrics/lantern-largest-contentful-paint.d.ts +12 -0
  8. package/core/computed/metrics/lantern-max-potential-fid.d.ts +6 -0
  9. package/core/computed/metrics/lantern-max-potential-fid.js +1 -1
  10. package/core/computed/metrics/lantern-metric.d.ts +4 -64
  11. package/core/computed/metrics/lantern-metric.js +6 -124
  12. package/core/computed/metrics/lantern-speed-index.d.ts +6 -0
  13. package/core/computed/metrics/lantern-speed-index.js +1 -1
  14. package/core/computed/metrics/lantern-total-blocking-time.d.ts +6 -0
  15. package/core/computed/metrics/lantern-total-blocking-time.js +1 -1
  16. package/core/gather/gatherers/accessibility.js +2 -1
  17. package/core/gather/session.js +5 -0
  18. package/core/lib/emulation.js +0 -3
  19. package/core/lib/lantern/metric.d.ts +71 -0
  20. package/core/lib/lantern/metric.js +143 -0
  21. package/core/lib/lantern/network-node.d.ts +5 -5
  22. package/core/lib/lantern/network-node.js +3 -4
  23. package/core/lib/lantern/page-dependency-graph.d.ts +7 -7
  24. package/core/lib/lantern/page-dependency-graph.js +4 -4
  25. package/core/lib/lantern/simulator/connection-pool.d.ts +14 -15
  26. package/core/lib/lantern/simulator/connection-pool.js +7 -9
  27. package/core/lib/lantern/simulator/dns-cache.d.ts +5 -11
  28. package/core/lib/lantern/simulator/dns-cache.js +3 -3
  29. package/core/lib/lantern/simulator/network-analyzer.d.ts +30 -30
  30. package/core/lib/lantern/simulator/network-analyzer.js +14 -15
  31. package/core/lib/lantern/simulator/simulator.d.ts +13 -16
  32. package/core/lib/lantern/simulator/simulator.js +10 -16
  33. package/core/lib/lantern/types/lantern.d.ts +129 -0
  34. package/core/lib/lantern/types/lantern.js +7 -0
  35. package/core/lib/network-request.d.ts +3 -4
  36. package/core/lib/network-request.js +2 -3
  37. package/package.json +1 -1
  38. package/tsconfig.json +1 -0
  39. package/types/gatherer.d.ts +1 -1
  40. package/types/internal/lantern.d.ts +0 -124
@@ -0,0 +1,143 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import * as Lantern from './types/lantern.js';
8
+ import {BaseNode} from '../../lib/lantern/base-node.js';
9
+ import {NetworkRequest} from '../../lib/network-request.js';
10
+
11
+ /** @typedef {import('./base-node.js').Node} Node */
12
+ /** @typedef {import('./network-node.js').NetworkNode} NetworkNode */
13
+ /** @typedef {import('./simulator/simulator.js').Simulator} Simulator */
14
+
15
+ /**
16
+ * @typedef Extras
17
+ * @property {boolean} optimistic
18
+ * @property {LH.Artifacts.LanternMetric=} fcpResult
19
+ * @property {LH.Artifacts.LanternMetric=} fmpResult
20
+ * @property {LH.Artifacts.LanternMetric=} interactiveResult
21
+ * @property {{speedIndex: number}=} speedline
22
+ */
23
+
24
+ class Metric {
25
+ /**
26
+ * @param {Node} dependencyGraph
27
+ * @param {function(NetworkNode):boolean=} treatNodeAsRenderBlocking
28
+ * @return {Set<string>}
29
+ */
30
+ static getScriptUrls(dependencyGraph, treatNodeAsRenderBlocking) {
31
+ /** @type {Set<string>} */
32
+ const scriptUrls = new Set();
33
+
34
+ dependencyGraph.traverse(node => {
35
+ if (node.type !== BaseNode.TYPES.NETWORK) return;
36
+ if (node.record.resourceType !== NetworkRequest.TYPES.Script) return;
37
+ if (treatNodeAsRenderBlocking?.(node)) {
38
+ scriptUrls.add(node.record.url);
39
+ }
40
+ });
41
+
42
+ return scriptUrls;
43
+ }
44
+
45
+ /**
46
+ * @return {Lantern.Simulation.MetricCoefficients}
47
+ */
48
+ static get COEFFICIENTS() {
49
+ throw new Error('COEFFICIENTS unimplemented!');
50
+ }
51
+
52
+ /**
53
+ * Returns the coefficients, scaled by the throttling settings if needed by the metric.
54
+ * Some lantern metrics (speed-index) use components in their estimate that are not
55
+ * from the simulator. In this case, we need to adjust the coefficients as the target throttling
56
+ * settings change.
57
+ *
58
+ * @param {number} rttMs
59
+ * @return {Lantern.Simulation.MetricCoefficients}
60
+ */
61
+ static getScaledCoefficients(rttMs) { // eslint-disable-line no-unused-vars
62
+ return this.COEFFICIENTS;
63
+ }
64
+
65
+ /**
66
+ * @param {Node} dependencyGraph
67
+ * @param {LH.Artifacts.ProcessedNavigation} processedNavigation
68
+ * @return {Node}
69
+ */
70
+ static getOptimisticGraph(dependencyGraph, processedNavigation) { // eslint-disable-line no-unused-vars
71
+ throw new Error('Optimistic graph unimplemented!');
72
+ }
73
+
74
+ /**
75
+ * @param {Node} dependencyGraph
76
+ * @param {LH.Artifacts.ProcessedNavigation} processedNavigation
77
+ * @return {Node}
78
+ */
79
+ static getPessimisticGraph(dependencyGraph, processedNavigation) { // eslint-disable-line no-unused-vars
80
+ throw new Error('Pessmistic graph unimplemented!');
81
+ }
82
+
83
+ /**
84
+ * @param {Lantern.Simulation.Result} simulationResult
85
+ * @param {Extras} extras
86
+ * @return {Lantern.Simulation.Result}
87
+ */
88
+ static getEstimateFromSimulation(simulationResult, extras) { // eslint-disable-line no-unused-vars
89
+ return simulationResult;
90
+ }
91
+
92
+ /**
93
+ * @param {Lantern.Simulation.MetricComputationDataInput} data
94
+ * @param {Omit<Extras, 'optimistic'>=} extras
95
+ * @return {Promise<LH.Artifacts.LanternMetric>}
96
+ */
97
+ static async compute(data, extras) {
98
+ const {simulator, graph, processedNavigation} = data;
99
+
100
+ const metricName = this.name.replace('Lantern', '');
101
+ const optimisticGraph = this.getOptimisticGraph(graph, processedNavigation);
102
+ const pessimisticGraph = this.getPessimisticGraph(graph, processedNavigation);
103
+
104
+ /** @type {{flexibleOrdering?: boolean, label?: string}} */
105
+ let simulateOptions = {label: `optimistic${metricName}`};
106
+ const optimisticSimulation = simulator.simulate(optimisticGraph, simulateOptions);
107
+
108
+ simulateOptions = {label: `optimisticFlex${metricName}`, flexibleOrdering: true};
109
+ const optimisticFlexSimulation = simulator.simulate(optimisticGraph, simulateOptions);
110
+
111
+ simulateOptions = {label: `pessimistic${metricName}`};
112
+ const pessimisticSimulation = simulator.simulate(pessimisticGraph, simulateOptions);
113
+
114
+ const optimisticEstimate = this.getEstimateFromSimulation(
115
+ optimisticSimulation.timeInMs < optimisticFlexSimulation.timeInMs ?
116
+ optimisticSimulation : optimisticFlexSimulation, {...extras, optimistic: true}
117
+ );
118
+
119
+ const pessimisticEstimate = this.getEstimateFromSimulation(
120
+ pessimisticSimulation,
121
+ {...extras, optimistic: false}
122
+ );
123
+
124
+ const coefficients = this.getScaledCoefficients(simulator.rtt);
125
+ // Estimates under 1s don't really follow the normal curve fit, minimize the impact of the intercept
126
+ const interceptMultiplier = coefficients.intercept > 0 ?
127
+ Math.min(1, optimisticEstimate.timeInMs / 1000) : 1;
128
+ const timing =
129
+ coefficients.intercept * interceptMultiplier +
130
+ coefficients.optimistic * optimisticEstimate.timeInMs +
131
+ coefficients.pessimistic * pessimisticEstimate.timeInMs;
132
+
133
+ return {
134
+ timing,
135
+ optimisticEstimate,
136
+ pessimisticEstimate,
137
+ optimisticGraph,
138
+ pessimisticGraph,
139
+ };
140
+ }
141
+ }
142
+
143
+ export {Metric};
@@ -1,13 +1,12 @@
1
- export type NetworkRequest<T> = import('../../../types/internal/lantern.js').Lantern.NetworkRequest<T>;
2
1
  /**
3
2
  * @template [T=any]
4
3
  * @extends {BaseNode<T>}
5
4
  */
6
5
  export class NetworkNode<T = any> extends BaseNode<T> {
7
6
  /**
8
- * @param {NetworkRequest<T>} networkRequest
7
+ * @param {Lantern.NetworkRequest<T>} networkRequest
9
8
  */
10
- constructor(networkRequest: NetworkRequest<T>);
9
+ constructor(networkRequest: Lantern.NetworkRequest<T>);
11
10
  /** @private */
12
11
  private _request;
13
12
  get type(): "network";
@@ -16,9 +15,9 @@ export class NetworkNode<T = any> extends BaseNode<T> {
16
15
  */
17
16
  get record(): Readonly<T>;
18
17
  /**
19
- * @return {NetworkRequest<T>}
18
+ * @return {Lantern.NetworkRequest<T>}
20
19
  */
21
- get request(): import("../../../types/internal/lantern.js").Lantern.NetworkRequest<T>;
20
+ get request(): Lantern.NetworkRequest<T>;
22
21
  /**
23
22
  * @return {string}
24
23
  */
@@ -47,4 +46,5 @@ export class NetworkNode<T = any> extends BaseNode<T> {
47
46
  cloneWithoutRelationships(): NetworkNode<T>;
48
47
  }
49
48
  import { BaseNode } from './base-node.js';
49
+ import * as Lantern from './types/lantern.js';
50
50
  //# sourceMappingURL=network-node.d.ts.map
@@ -4,8 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- /** @template T @typedef {import('../../../types/internal/lantern.js').Lantern.NetworkRequest<T>} NetworkRequest */
8
-
7
+ import * as Lantern from './types/lantern.js';
9
8
  import {NetworkRequestTypes} from './lantern.js';
10
9
  import {BaseNode} from './base-node.js';
11
10
  // TODO(15841): bring impl of isNonNetworkRequest inside lantern and remove this.
@@ -17,7 +16,7 @@ import UrlUtils from '../url-utils.js';
17
16
  */
18
17
  class NetworkNode extends BaseNode {
19
18
  /**
20
- * @param {NetworkRequest<T>} networkRequest
19
+ * @param {Lantern.NetworkRequest<T>} networkRequest
21
20
  */
22
21
  constructor(networkRequest) {
23
22
  super(networkRequest.requestId);
@@ -51,7 +50,7 @@ class NetworkNode extends BaseNode {
51
50
  }
52
51
 
53
52
  /**
54
- * @return {NetworkRequest<T>}
53
+ * @return {Lantern.NetworkRequest<T>}
55
54
  */
56
55
  get request() {
57
56
  return this._request;
@@ -1,4 +1,3 @@
1
- export type NetworkRequest = import('../../../types/internal/lantern.js').Lantern.NetworkRequest;
2
1
  export type Node = import('./base-node.js').Node;
3
2
  export type URLArtifact = Omit<LH.Artifacts['URL'], 'finalDisplayedUrl'>;
4
3
  export type NetworkNodeOutput = {
@@ -9,15 +8,15 @@ export type NetworkNodeOutput = {
9
8
  };
10
9
  export class PageDependencyGraph {
11
10
  /**
12
- * @param {NetworkRequest} record
11
+ * @param {Lantern.NetworkRequest} record
13
12
  * @return {Array<string>}
14
13
  */
15
- static getNetworkInitiators(record: NetworkRequest): Array<string>;
14
+ static getNetworkInitiators(record: Lantern.NetworkRequest): Array<string>;
16
15
  /**
17
- * @param {Array<NetworkRequest>} networkRecords
16
+ * @param {Array<Lantern.NetworkRequest>} networkRecords
18
17
  * @return {NetworkNodeOutput}
19
18
  */
20
- static getNetworkNodeOutput(networkRecords: Array<NetworkRequest>): NetworkNodeOutput;
19
+ static getNetworkNodeOutput(networkRecords: Array<Lantern.NetworkRequest>): NetworkNodeOutput;
21
20
  /**
22
21
  * @param {LH.Artifacts.ProcessedTrace} processedTrace
23
22
  * @return {Array<CPUNode>}
@@ -42,11 +41,11 @@ export class PageDependencyGraph {
42
41
  static _pruneNode(node: Node): void;
43
42
  /**
44
43
  * @param {LH.Artifacts.ProcessedTrace} processedTrace
45
- * @param {Array<NetworkRequest>} networkRecords
44
+ * @param {Array<Lantern.NetworkRequest>} networkRecords
46
45
  * @param {URLArtifact} URL
47
46
  * @return {Node}
48
47
  */
49
- static createGraph(processedTrace: LH.Artifacts.ProcessedTrace, networkRecords: Array<NetworkRequest>, URL: URLArtifact): Node;
48
+ static createGraph(processedTrace: LH.Artifacts.ProcessedTrace, networkRecords: Array<Lantern.NetworkRequest>, URL: URLArtifact): Node;
50
49
  /**
51
50
  *
52
51
  * @param {Node} rootNode
@@ -54,5 +53,6 @@ export class PageDependencyGraph {
54
53
  static printGraph(rootNode: Node, widthInCharacters?: number): void;
55
54
  }
56
55
  import { NetworkNode } from './network-node.js';
56
+ import * as Lantern from './types/lantern.js';
57
57
  import { CPUNode } from './cpu-node.js';
58
58
  //# sourceMappingURL=page-dependency-graph.d.ts.map
@@ -4,13 +4,13 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
+ import * as Lantern from './types/lantern.js';
7
8
  import {NetworkRequestTypes} from './lantern.js';
8
9
  import {NetworkNode} from './network-node.js';
9
10
  import {CPUNode} from './cpu-node.js';
10
11
  import {TraceProcessor} from '../tracehouse/trace-processor.js';
11
12
  import {NetworkAnalyzer} from './simulator/network-analyzer.js';
12
13
 
13
- /** @typedef {import('../../../types/internal/lantern.js').Lantern.NetworkRequest} NetworkRequest */
14
14
  /** @typedef {import('./base-node.js').Node} Node */
15
15
  /** @typedef {Omit<LH.Artifacts['URL'], 'finalDisplayedUrl'>} URLArtifact */
16
16
 
@@ -31,7 +31,7 @@ const IGNORED_MIME_TYPES_REGEX = /^video/;
31
31
 
32
32
  class PageDependencyGraph {
33
33
  /**
34
- * @param {NetworkRequest} record
34
+ * @param {Lantern.NetworkRequest} record
35
35
  * @return {Array<string>}
36
36
  */
37
37
  static getNetworkInitiators(record) {
@@ -60,7 +60,7 @@ class PageDependencyGraph {
60
60
  }
61
61
 
62
62
  /**
63
- * @param {Array<NetworkRequest>} networkRecords
63
+ * @param {Array<Lantern.NetworkRequest>} networkRecords
64
64
  * @return {NetworkNodeOutput}
65
65
  */
66
66
  static getNetworkNodeOutput(networkRecords) {
@@ -394,7 +394,7 @@ class PageDependencyGraph {
394
394
 
395
395
  /**
396
396
  * @param {LH.Artifacts.ProcessedTrace} processedTrace
397
- * @param {Array<NetworkRequest>} networkRecords
397
+ * @param {Array<Lantern.NetworkRequest>} networkRecords
398
398
  * @param {URLArtifact} URL
399
399
  * @return {Node}
400
400
  */
@@ -1,15 +1,15 @@
1
1
  export class ConnectionPool {
2
2
  /**
3
- * @param {NetworkRequest[]} records
4
- * @param {Required<SimulationOptions>} options
3
+ * @param {Lantern.NetworkRequest[]} records
4
+ * @param {Required<Lantern.Simulation.Options>} options
5
5
  */
6
- constructor(records: NetworkRequest[], options: Required<SimulationOptions>);
7
- _options: Required<import("../../../../types/internal/lantern.js").Lantern.Simulation.Options>;
8
- _records: import("../../../../types/internal/lantern.js").Lantern.NetworkRequest<any>[];
6
+ constructor(records: Lantern.NetworkRequest[], options: Required<Lantern.Simulation.Options>);
7
+ _options: Required<Lantern.Simulation.Options>;
8
+ _records: Lantern.NetworkRequest<any>[];
9
9
  /** @type {Map<string, TcpConnection[]>} */
10
10
  _connectionsByOrigin: Map<string, TcpConnection[]>;
11
- /** @type {Map<NetworkRequest, TcpConnection>} */
12
- _connectionsByRecord: Map<NetworkRequest, TcpConnection>;
11
+ /** @type {Map<Lantern.NetworkRequest, TcpConnection>} */
12
+ _connectionsByRecord: Map<Lantern.NetworkRequest, TcpConnection>;
13
13
  _connectionsInUse: Set<any>;
14
14
  _connectionReusedByRequestId: Map<string, boolean>;
15
15
  /**
@@ -33,27 +33,26 @@ 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 {NetworkRequest} record
36
+ * @param {Lantern.NetworkRequest} record
37
37
  * @param {{ignoreConnectionReused?: boolean}} options
38
38
  * @return {?TcpConnection}
39
39
  */
40
- acquire(record: NetworkRequest, options?: {
40
+ acquire(record: Lantern.NetworkRequest, 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 {NetworkRequest} record
47
+ * @param {Lantern.NetworkRequest} record
48
48
  * @return {TcpConnection}
49
49
  */
50
- acquireActiveConnectionFromRecord(record: NetworkRequest): TcpConnection;
50
+ acquireActiveConnectionFromRecord(record: Lantern.NetworkRequest): TcpConnection;
51
51
  /**
52
- * @param {NetworkRequest} record
52
+ * @param {Lantern.NetworkRequest} record
53
53
  */
54
- release(record: NetworkRequest): void;
54
+ release(record: Lantern.NetworkRequest): void;
55
55
  }
56
- export type NetworkRequest = import('../../../../types/internal/lantern.js').Lantern.NetworkRequest;
57
- export type SimulationOptions = import('../../../../types/internal/lantern.js').Lantern.Simulation.Options;
56
+ import * as Lantern from '../types/lantern.js';
58
57
  import { TcpConnection } from './tcp-connection.js';
59
58
  //# sourceMappingURL=connection-pool.d.ts.map
@@ -4,9 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- /** @typedef {import('../../../../types/internal/lantern.js').Lantern.NetworkRequest} NetworkRequest */
8
- /** @typedef {import('../../../../types/internal/lantern.js').Lantern.Simulation.Options} SimulationOptions */
9
-
7
+ import * as Lantern from '../types/lantern.js';
10
8
  import {NetworkAnalyzer} from './network-analyzer.js';
11
9
  import {TcpConnection} from './tcp-connection.js';
12
10
 
@@ -19,8 +17,8 @@ const CONNECTIONS_PER_ORIGIN = 6;
19
17
 
20
18
  export class ConnectionPool {
21
19
  /**
22
- * @param {NetworkRequest[]} records
23
- * @param {Required<SimulationOptions>} options
20
+ * @param {Lantern.NetworkRequest[]} records
21
+ * @param {Required<Lantern.Simulation.Options>} options
24
22
  */
25
23
  constructor(records, options) {
26
24
  this._options = options;
@@ -28,7 +26,7 @@ export class ConnectionPool {
28
26
  this._records = records;
29
27
  /** @type {Map<string, TcpConnection[]>} */
30
28
  this._connectionsByOrigin = new Map();
31
- /** @type {Map<NetworkRequest, TcpConnection>} */
29
+ /** @type {Map<Lantern.NetworkRequest, TcpConnection>} */
32
30
  this._connectionsByRecord = new Map();
33
31
  this._connectionsInUse = new Set();
34
32
  this._connectionReusedByRequestId = NetworkAnalyzer.estimateIfConnectionWasReused(records, {
@@ -126,7 +124,7 @@ export class ConnectionPool {
126
124
  * If ignoreConnectionReused is true, acquire will consider all connections not in use as available.
127
125
  * Otherwise, only connections that have matching "warmth" are considered available.
128
126
  *
129
- * @param {NetworkRequest} record
127
+ * @param {Lantern.NetworkRequest} record
130
128
  * @param {{ignoreConnectionReused?: boolean}} options
131
129
  * @return {?TcpConnection}
132
130
  */
@@ -152,7 +150,7 @@ export class ConnectionPool {
152
150
  * Return the connection currently being used to fetch a record. If no connection
153
151
  * currently being used for this record, an error will be thrown.
154
152
  *
155
- * @param {NetworkRequest} record
153
+ * @param {Lantern.NetworkRequest} record
156
154
  * @return {TcpConnection}
157
155
  */
158
156
  acquireActiveConnectionFromRecord(record) {
@@ -163,7 +161,7 @@ export class ConnectionPool {
163
161
  }
164
162
 
165
163
  /**
166
- * @param {NetworkRequest} record
164
+ * @param {Lantern.NetworkRequest} record
167
165
  */
168
166
  release(record) {
169
167
  const connection = this._connectionsByRecord.get(record);
@@ -1,4 +1,3 @@
1
- export type NetworkRequest = import('../../../../types/internal/lantern.js').Lantern.NetworkRequest;
2
1
  export class DNSCache {
3
2
  /**
4
3
  * @param {{rtt: number}} options
@@ -12,19 +11,19 @@ export class DNSCache {
12
11
  resolvedAt: number;
13
12
  }>;
14
13
  /**
15
- * @param {NetworkRequest} request
14
+ * @param {Lantern.NetworkRequest} request
16
15
  * @param {{requestedAt: number, shouldUpdateCache: boolean}=} options
17
16
  * @return {number}
18
17
  */
19
- getTimeUntilResolution(request: NetworkRequest, options?: {
18
+ getTimeUntilResolution(request: Lantern.NetworkRequest, options?: {
20
19
  requestedAt: number;
21
20
  shouldUpdateCache: boolean;
22
21
  } | undefined): number;
23
22
  /**
24
- * @param {NetworkRequest} request
23
+ * @param {Lantern.NetworkRequest} request
25
24
  * @param {number} resolvedAt
26
25
  */
27
- _updateCacheResolvedAtIfNeeded(request: NetworkRequest, resolvedAt: number): void;
26
+ _updateCacheResolvedAtIfNeeded(request: Lantern.NetworkRequest, resolvedAt: number): void;
28
27
  /**
29
28
  * Forcefully sets the DNS resolution time for a record.
30
29
  * Useful for testing and alternate execution simulations.
@@ -37,12 +36,7 @@ export class DNSCache {
37
36
  export namespace DNSCache {
38
37
  export { DNS_RESOLUTION_RTT_MULTIPLIER as RTT_MULTIPLIER };
39
38
  }
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
+ import * as Lantern from '../types/lantern.js';
46
40
  declare const DNS_RESOLUTION_RTT_MULTIPLIER: 2;
47
41
  export {};
48
42
  //# sourceMappingURL=dns-cache.d.ts.map
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- /** @typedef {import('../../../../types/internal/lantern.js').Lantern.NetworkRequest} NetworkRequest */
7
+ import * as Lantern from '../types/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 {NetworkRequest} request
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 {NetworkRequest} request
50
+ * @param {Lantern.NetworkRequest} request
51
51
  * @param {number} resolvedAt
52
52
  */
53
53
  _updateCacheResolvedAtIfNeeded(request, resolvedAt) {
@@ -1,4 +1,3 @@
1
- export type NetworkRequest = import('../../../../types/internal/lantern.js').Lantern.NetworkRequest;
2
1
  export type Summary = {
3
2
  min: number;
4
3
  max: number;
@@ -33,10 +32,10 @@ export class NetworkAnalyzer {
33
32
  */
34
33
  static get SUMMARY(): string;
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
- static groupByOrigin(records: NetworkRequest[]): Map<string, NetworkRequest[]>;
38
+ static groupByOrigin(records: Lantern.NetworkRequest[]): Map<string, Lantern.NetworkRequest[]>;
40
39
  /**
41
40
  * @param {number[]} values
42
41
  * @return {Summary}
@@ -47,14 +46,14 @@ export class NetworkAnalyzer {
47
46
  * @return {Map<string, Summary>}
48
47
  */
49
48
  static summarize(values: Map<string, number[]>): Map<string, Summary>;
50
- /** @typedef {{record: NetworkRequest, timing: LH.Crdp.Network.ResourceTiming, connectionReused?: boolean}} RequestInfo */
49
+ /** @typedef {{record: Lantern.NetworkRequest, timing: LH.Crdp.Network.ResourceTiming, connectionReused?: boolean}} RequestInfo */
51
50
  /**
52
- * @param {NetworkRequest[]} records
51
+ * @param {Lantern.NetworkRequest[]} records
53
52
  * @param {(e: RequestInfo) => number | number[] | undefined} iteratee
54
53
  * @return {Map<string, number[]>}
55
54
  */
56
- static _estimateValueByOrigin(records: NetworkRequest[], iteratee: (e: {
57
- record: NetworkRequest;
55
+ static _estimateValueByOrigin(records: Lantern.NetworkRequest[], iteratee: (e: {
56
+ record: Lantern.NetworkRequest;
58
57
  timing: LH.Crdp.Network.ResourceTiming;
59
58
  connectionReused?: boolean | undefined;
60
59
  }) => number | number[] | undefined): Map<string, number[]>;
@@ -70,7 +69,7 @@ export class NetworkAnalyzer {
70
69
  * @return {number[]|number|undefined}
71
70
  */
72
71
  static _estimateRTTViaConnectionTiming(info: {
73
- record: NetworkRequest;
72
+ record: Lantern.NetworkRequest;
74
73
  timing: LH.Crdp.Network.ResourceTiming;
75
74
  connectionReused?: boolean | undefined;
76
75
  }): number[] | number | undefined;
@@ -83,7 +82,7 @@ export class NetworkAnalyzer {
83
82
  * @return {number|undefined}
84
83
  */
85
84
  static _estimateRTTViaDownloadTiming(info: {
86
- record: NetworkRequest;
85
+ record: Lantern.NetworkRequest;
87
86
  timing: LH.Crdp.Network.ResourceTiming;
88
87
  connectionReused?: boolean | undefined;
89
88
  }): number | undefined;
@@ -97,7 +96,7 @@ export class NetworkAnalyzer {
97
96
  * @return {number|undefined}
98
97
  */
99
98
  static _estimateRTTViaSendStartTiming(info: {
100
- record: NetworkRequest;
99
+ record: Lantern.NetworkRequest;
101
100
  timing: LH.Crdp.Network.ResourceTiming;
102
101
  connectionReused?: boolean | undefined;
103
102
  }): number | undefined;
@@ -111,32 +110,32 @@ export class NetworkAnalyzer {
111
110
  * @return {number|undefined}
112
111
  */
113
112
  static _estimateRTTViaHeadersEndTiming(info: {
114
- record: NetworkRequest;
113
+ record: Lantern.NetworkRequest;
115
114
  timing: LH.Crdp.Network.ResourceTiming;
116
115
  connectionReused?: boolean | undefined;
117
116
  }): number | undefined;
118
117
  /**
119
118
  * Given the RTT to each origin, estimates the observed server response times.
120
119
  *
121
- * @param {NetworkRequest[]} records
120
+ * @param {Lantern.NetworkRequest[]} records
122
121
  * @param {Map<string, number>} rttByOrigin
123
122
  * @return {Map<string, number[]>}
124
123
  */
125
- static _estimateResponseTimeByOrigin(records: NetworkRequest[], rttByOrigin: Map<string, number>): Map<string, number[]>;
124
+ static _estimateResponseTimeByOrigin(records: Lantern.NetworkRequest[], rttByOrigin: Map<string, number>): Map<string, number[]>;
126
125
  /**
127
- * @param {NetworkRequest[]} records
126
+ * @param {Lantern.NetworkRequest[]} records
128
127
  * @return {boolean}
129
128
  */
130
- static canTrustConnectionInformation(records: NetworkRequest[]): boolean;
129
+ static canTrustConnectionInformation(records: Lantern.NetworkRequest[]): boolean;
131
130
  /**
132
131
  * Returns a map of requestId -> connectionReused, estimating the information if the information
133
132
  * available in the records themselves appears untrustworthy.
134
133
  *
135
- * @param {NetworkRequest[]} records
134
+ * @param {Lantern.NetworkRequest[]} records
136
135
  * @param {{forceCoarseEstimates: boolean}} [options]
137
136
  * @return {Map<string, boolean>}
138
137
  */
139
- static estimateIfConnectionWasReused(records: NetworkRequest[], options?: {
138
+ static estimateIfConnectionWasReused(records: Lantern.NetworkRequest[], options?: {
140
139
  forceCoarseEstimates: boolean;
141
140
  } | undefined): Map<string, boolean>;
142
141
  /**
@@ -144,20 +143,20 @@ export class NetworkAnalyzer {
144
143
  * Attempts to use the most accurate information first and falls back to coarser estimates when it
145
144
  * is unavailable.
146
145
  *
147
- * @param {NetworkRequest[]} records
146
+ * @param {Lantern.NetworkRequest[]} records
148
147
  * @param {RTTEstimateOptions} [options]
149
148
  * @return {Map<string, Summary>}
150
149
  */
151
- static estimateRTTByOrigin(records: NetworkRequest[], options?: RTTEstimateOptions | undefined): Map<string, Summary>;
150
+ static estimateRTTByOrigin(records: Lantern.NetworkRequest[], options?: RTTEstimateOptions | undefined): Map<string, Summary>;
152
151
  /**
153
152
  * Estimates the server response time of each origin. RTT times can be passed in or will be
154
153
  * estimated automatically if not provided.
155
154
  *
156
- * @param {NetworkRequest[]} records
155
+ * @param {Lantern.NetworkRequest[]} records
157
156
  * @param {RTTEstimateOptions & {rttByOrigin?: Map<string, number>}} [options]
158
157
  * @return {Map<string, Summary>}
159
158
  */
160
- static estimateServerResponseTimeByOrigin(records: NetworkRequest[], options?: (RTTEstimateOptions & {
159
+ static estimateServerResponseTimeByOrigin(records: Lantern.NetworkRequest[], options?: (RTTEstimateOptions & {
161
160
  rttByOrigin?: Map<string, number> | undefined;
162
161
  }) | undefined): Map<string, Summary>;
163
162
  /**
@@ -165,32 +164,33 @@ export class NetworkAnalyzer {
165
164
  * Excludes data URI, failed or otherwise incomplete, and cached requests.
166
165
  * Returns Infinity if there were no analyzable network records.
167
166
  *
168
- * @param {Array<NetworkRequest>} networkRecords
167
+ * @param {Array<Lantern.NetworkRequest>} networkRecords
169
168
  * @return {number}
170
169
  */
171
- static estimateThroughput(networkRecords: Array<NetworkRequest>): number;
170
+ static estimateThroughput(networkRecords: Array<Lantern.NetworkRequest>): number;
172
171
  /**
173
- * @template {NetworkRequest} T
172
+ * @template {Lantern.NetworkRequest} T
174
173
  * @param {Array<T>} records
175
174
  * @param {string} resourceUrl
176
175
  * @return {T|undefined}
177
176
  */
178
- static findResourceForUrl<T extends import("../../../../types/internal/lantern.js").Lantern.NetworkRequest<any>>(records: T[], resourceUrl: string): T | undefined;
177
+ static findResourceForUrl<T extends Lantern.NetworkRequest<any>>(records: T[], resourceUrl: string): T | undefined;
179
178
  /**
180
- * @template {NetworkRequest} T
179
+ * @template {Lantern.NetworkRequest} T
181
180
  * @param {Array<T>} records
182
181
  * @param {string} resourceUrl
183
182
  * @return {T|undefined}
184
183
  */
185
- static findLastDocumentForUrl<T_1 extends import("../../../../types/internal/lantern.js").Lantern.NetworkRequest<any>>(records: T_1[], resourceUrl: string): T_1 | undefined;
184
+ static findLastDocumentForUrl<T_1 extends Lantern.NetworkRequest<any>>(records: T_1[], resourceUrl: string): T_1 | undefined;
186
185
  /**
187
186
  * Resolves redirect chain given a main document.
188
187
  * See: {@link NetworkAnalyzer.findLastDocumentForUrl}) for how to retrieve main document.
189
188
  *
190
- * @template {NetworkRequest} T
189
+ * @template {Lantern.NetworkRequest} T
191
190
  * @param {T} request
192
191
  * @return {T}
193
192
  */
194
- static resolveRedirects<T_2 extends import("../../../../types/internal/lantern.js").Lantern.NetworkRequest<any>>(request: T_2): T_2;
193
+ static resolveRedirects<T_2 extends Lantern.NetworkRequest<any>>(request: T_2): T_2;
195
194
  }
195
+ import * as Lantern from '../types/lantern.js';
196
196
  //# sourceMappingURL=network-analyzer.d.ts.map