lighthouse 11.6.0 → 11.7.0
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 -2
- 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/metrics/interaction-to-next-paint.js +1 -3
- package/core/audits/prioritize-lcp-image.d.ts +1 -1
- package/core/audits/work-during-interaction.js +0 -8
- package/core/computed/document-urls.js +1 -1
- package/core/computed/load-simulator.d.ts +2 -2
- package/core/computed/load-simulator.js +3 -2
- package/core/computed/main-resource.js +1 -1
- package/core/computed/metrics/lantern-first-contentful-paint.d.ts +18 -6
- package/core/computed/metrics/lantern-first-contentful-paint.js +4 -4
- package/core/computed/metrics/lantern-first-meaningful-paint.d.ts +14 -2
- package/core/computed/metrics/lantern-first-meaningful-paint.js +1 -1
- package/core/computed/metrics/lantern-interactive.d.ts +8 -6
- package/core/computed/metrics/lantern-interactive.js +3 -3
- package/core/computed/metrics/lantern-largest-contentful-paint.d.ts +14 -2
- package/core/computed/metrics/lantern-largest-contentful-paint.js +1 -1
- package/core/computed/metrics/lantern-max-potential-fid.d.ts +8 -2
- package/core/computed/metrics/lantern-max-potential-fid.js +3 -3
- package/core/computed/metrics/lantern-metric.d.ts +4 -63
- package/core/computed/metrics/lantern-metric.js +6 -124
- package/core/computed/metrics/lantern-speed-index.d.ts +8 -2
- package/core/computed/metrics/lantern-speed-index.js +3 -3
- package/core/computed/metrics/lantern-total-blocking-time.d.ts +8 -2
- package/core/computed/metrics/lantern-total-blocking-time.js +3 -3
- package/core/computed/metrics/responsiveness.d.ts +5 -13
- package/core/computed/metrics/responsiveness.js +10 -14
- package/core/computed/network-analysis.js +1 -1
- package/core/computed/page-dependency-graph.d.ts +4 -57
- package/core/computed/page-dependency-graph.js +4 -451
- package/core/config/config-helpers.js +1 -1
- package/core/gather/driver/execution-context.d.ts +2 -1
- package/core/gather/driver/execution-context.js +9 -9
- package/core/gather/driver/wait-for-condition.js +4 -2
- package/core/gather/gatherers/accessibility.js +2 -1
- package/core/gather/gatherers/css-usage.d.ts +1 -9
- package/core/gather/gatherers/css-usage.js +23 -25
- package/core/gather/gatherers/devtools-log.d.ts +4 -0
- package/core/gather/gatherers/devtools-log.js +7 -0
- package/core/gather/gatherers/full-page-screenshot.d.ts +4 -0
- package/core/gather/gatherers/full-page-screenshot.js +31 -35
- package/core/gather/gatherers/root-causes.js +1 -3
- package/core/gather/gatherers/trace-elements.js +1 -1
- package/core/gather/gatherers/trace.d.ts +1 -0
- package/core/gather/gatherers/trace.js +4 -0
- package/core/gather/navigation-runner.js +49 -62
- package/core/gather/session.js +5 -0
- package/core/gather/snapshot-runner.js +25 -25
- package/core/gather/timespan-runner.js +24 -25
- package/core/lib/asset-saver.js +1 -1
- package/core/lib/emulation.js +0 -3
- 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 +8 -0
- package/core/lib/lantern/lantern.js +31 -0
- package/core/lib/lantern/metric.d.ts +71 -0
- package/core/lib/lantern/metric.js +143 -0
- package/core/lib/{dependency-graph → lantern}/network-node.d.ts +17 -10
- package/core/lib/lantern/network-node.js +114 -0
- package/core/lib/lantern/page-dependency-graph.d.ts +58 -0
- package/core/lib/lantern/page-dependency-graph.js +463 -0
- package/core/lib/{dependency-graph → lantern}/simulator/connection-pool.d.ts +14 -14
- package/core/lib/{dependency-graph → lantern}/simulator/connection-pool.js +7 -7
- package/core/lib/{dependency-graph → lantern}/simulator/dns-cache.d.ts +5 -5
- package/core/lib/{dependency-graph → lantern}/simulator/dns-cache.js +3 -3
- package/core/lib/{dependency-graph → lantern}/simulator/network-analyzer.d.ts +36 -32
- package/core/lib/{dependency-graph → lantern}/simulator/network-analyzer.js +21 -17
- package/core/lib/{dependency-graph → lantern}/simulator/simulator.d.ts +18 -15
- package/core/lib/{dependency-graph → lantern}/simulator/simulator.js +18 -15
- package/core/lib/lantern/types/lantern.d.ts +129 -0
- package/core/lib/lantern/types/lantern.js +7 -0
- 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-recorder.js +2 -2
- package/core/lib/network-request.d.ts +6 -0
- package/core/lib/network-request.js +12 -0
- package/package.json +4 -5
- package/shared/localization/locales/ar-XB.json +1 -1
- package/shared/localization/locales/ar.json +1 -1
- package/shared/localization/locales/bg.json +1 -1
- package/shared/localization/locales/ca.json +1 -1
- package/shared/localization/locales/cs.json +1 -1
- package/shared/localization/locales/da.json +2 -2
- package/shared/localization/locales/de.json +1 -1
- package/shared/localization/locales/el.json +1 -1
- package/shared/localization/locales/en-GB.json +1 -1
- package/shared/localization/locales/en-US.json +3 -0
- package/shared/localization/locales/en-XA.json +1 -1
- package/shared/localization/locales/en-XL.json +3 -0
- package/shared/localization/locales/es-419.json +1 -1
- package/shared/localization/locales/es.json +1 -1
- package/shared/localization/locales/fi.json +1 -1
- package/shared/localization/locales/fil.json +1 -1
- package/shared/localization/locales/he.json +1 -1
- package/shared/localization/locales/hi.json +1 -1
- package/shared/localization/locales/hr.json +1 -1
- package/shared/localization/locales/hu.json +1 -1
- package/shared/localization/locales/id.json +1 -1
- package/shared/localization/locales/it.json +1 -1
- package/shared/localization/locales/ko.json +1 -1
- package/shared/localization/locales/lt.json +1 -1
- package/shared/localization/locales/nl.json +1 -1
- package/shared/localization/locales/no.json +1 -1
- package/shared/localization/locales/pl.json +1 -1
- package/shared/localization/locales/pt-PT.json +1 -1
- package/shared/localization/locales/pt.json +1 -1
- package/shared/localization/locales/ro.json +1 -1
- package/shared/localization/locales/sk.json +1 -1
- package/shared/localization/locales/sl.json +1 -1
- package/shared/localization/locales/sr-Latn.json +1 -1
- package/shared/localization/locales/sr.json +1 -1
- package/shared/localization/locales/sv.json +1 -1
- package/shared/localization/locales/ta.json +1 -1
- package/shared/localization/locales/te.json +1 -1
- package/shared/localization/locales/th.json +4 -4
- package/shared/localization/locales/tr.json +1 -1
- package/shared/localization/locales/uk.json +1 -1
- package/shared/localization/locales/vi.json +1 -1
- package/shared/localization/locales/zh-HK.json +1 -1
- package/shared/localization/locales/zh-TW.json +1 -1
- package/shared/localization/locales/zh.json +1 -1
- package/third-party/chromium-synchronization/installability-errors-test.js +1 -1
- package/tsconfig.json +7 -5
- package/types/artifacts.d.ts +1 -1
- package/types/gatherer.d.ts +8 -35
- package/types/lhr/lhr.d.ts +1 -1
- 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
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export type Node = import('./base-node.js').Node;
|
|
2
|
+
export type NetworkNode = import('./network-node.js').NetworkNode;
|
|
3
|
+
export type Simulator = import('./simulator/simulator.js').Simulator;
|
|
4
|
+
export type Extras = {
|
|
5
|
+
optimistic: boolean;
|
|
6
|
+
fcpResult?: LH.Artifacts.LanternMetric | undefined;
|
|
7
|
+
fmpResult?: LH.Artifacts.LanternMetric | undefined;
|
|
8
|
+
interactiveResult?: LH.Artifacts.LanternMetric | undefined;
|
|
9
|
+
speedline?: {
|
|
10
|
+
speedIndex: number;
|
|
11
|
+
} | undefined;
|
|
12
|
+
};
|
|
13
|
+
/** @typedef {import('./base-node.js').Node} Node */
|
|
14
|
+
/** @typedef {import('./network-node.js').NetworkNode} NetworkNode */
|
|
15
|
+
/** @typedef {import('./simulator/simulator.js').Simulator} Simulator */
|
|
16
|
+
/**
|
|
17
|
+
* @typedef Extras
|
|
18
|
+
* @property {boolean} optimistic
|
|
19
|
+
* @property {LH.Artifacts.LanternMetric=} fcpResult
|
|
20
|
+
* @property {LH.Artifacts.LanternMetric=} fmpResult
|
|
21
|
+
* @property {LH.Artifacts.LanternMetric=} interactiveResult
|
|
22
|
+
* @property {{speedIndex: number}=} speedline
|
|
23
|
+
*/
|
|
24
|
+
export class Metric {
|
|
25
|
+
/**
|
|
26
|
+
* @param {Node} dependencyGraph
|
|
27
|
+
* @param {function(NetworkNode):boolean=} treatNodeAsRenderBlocking
|
|
28
|
+
* @return {Set<string>}
|
|
29
|
+
*/
|
|
30
|
+
static getScriptUrls(dependencyGraph: Node, treatNodeAsRenderBlocking?: ((arg0: NetworkNode) => boolean) | undefined): Set<string>;
|
|
31
|
+
/**
|
|
32
|
+
* @return {Lantern.Simulation.MetricCoefficients}
|
|
33
|
+
*/
|
|
34
|
+
static get COEFFICIENTS(): Lantern.Simulation.MetricCoefficients;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the coefficients, scaled by the throttling settings if needed by the metric.
|
|
37
|
+
* Some lantern metrics (speed-index) use components in their estimate that are not
|
|
38
|
+
* from the simulator. In this case, we need to adjust the coefficients as the target throttling
|
|
39
|
+
* settings change.
|
|
40
|
+
*
|
|
41
|
+
* @param {number} rttMs
|
|
42
|
+
* @return {Lantern.Simulation.MetricCoefficients}
|
|
43
|
+
*/
|
|
44
|
+
static getScaledCoefficients(rttMs: number): Lantern.Simulation.MetricCoefficients;
|
|
45
|
+
/**
|
|
46
|
+
* @param {Node} dependencyGraph
|
|
47
|
+
* @param {LH.Artifacts.ProcessedNavigation} processedNavigation
|
|
48
|
+
* @return {Node}
|
|
49
|
+
*/
|
|
50
|
+
static getOptimisticGraph(dependencyGraph: Node, processedNavigation: LH.Artifacts.ProcessedNavigation): Node;
|
|
51
|
+
/**
|
|
52
|
+
* @param {Node} dependencyGraph
|
|
53
|
+
* @param {LH.Artifacts.ProcessedNavigation} processedNavigation
|
|
54
|
+
* @return {Node}
|
|
55
|
+
*/
|
|
56
|
+
static getPessimisticGraph(dependencyGraph: Node, processedNavigation: LH.Artifacts.ProcessedNavigation): Node;
|
|
57
|
+
/**
|
|
58
|
+
* @param {Lantern.Simulation.Result} simulationResult
|
|
59
|
+
* @param {Extras} extras
|
|
60
|
+
* @return {Lantern.Simulation.Result}
|
|
61
|
+
*/
|
|
62
|
+
static getEstimateFromSimulation(simulationResult: Lantern.Simulation.Result, extras: Extras): Lantern.Simulation.Result;
|
|
63
|
+
/**
|
|
64
|
+
* @param {Lantern.Simulation.MetricComputationDataInput} data
|
|
65
|
+
* @param {Omit<Extras, 'optimistic'>=} extras
|
|
66
|
+
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
67
|
+
*/
|
|
68
|
+
static compute(data: Lantern.Simulation.MetricComputationDataInput, extras?: Omit<Extras, 'optimistic'> | undefined): Promise<LH.Artifacts.LanternMetric>;
|
|
69
|
+
}
|
|
70
|
+
import * as Lantern from './types/lantern.js';
|
|
71
|
+
//# sourceMappingURL=metric.d.ts.map
|
|
@@ -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,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: Lantern.NetworkRequest<T>);
|
|
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(): Lantern.NetworkRequest<T>;
|
|
13
21
|
/**
|
|
14
22
|
* @return {string}
|
|
15
23
|
*/
|
|
@@ -33,11 +41,10 @@ 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
|
|
42
|
-
import * as LH from '../../../types/lh.js';
|
|
49
|
+
import * as Lantern from './types/lantern.js';
|
|
43
50
|
//# sourceMappingURL=network-node.d.ts.map
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as Lantern from './types/lantern.js';
|
|
8
|
+
import {NetworkRequestTypes} from './lantern.js';
|
|
9
|
+
import {BaseNode} from './base-node.js';
|
|
10
|
+
// TODO(15841): bring impl of isNonNetworkRequest inside lantern and remove this.
|
|
11
|
+
import UrlUtils from '../url-utils.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @template [T=any]
|
|
15
|
+
* @extends {BaseNode<T>}
|
|
16
|
+
*/
|
|
17
|
+
class NetworkNode extends BaseNode {
|
|
18
|
+
/**
|
|
19
|
+
* @param {Lantern.NetworkRequest<T>} networkRequest
|
|
20
|
+
*/
|
|
21
|
+
constructor(networkRequest) {
|
|
22
|
+
super(networkRequest.requestId);
|
|
23
|
+
/** @private */
|
|
24
|
+
this._request = networkRequest;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get type() {
|
|
28
|
+
return BaseNode.TYPES.NETWORK;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @return {number}
|
|
33
|
+
*/
|
|
34
|
+
get startTime() {
|
|
35
|
+
return this._request.rendererStartTime * 1000;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @return {number}
|
|
40
|
+
*/
|
|
41
|
+
get endTime() {
|
|
42
|
+
return this._request.networkEndTime * 1000;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @return {Readonly<T>}
|
|
47
|
+
*/
|
|
48
|
+
get record() {
|
|
49
|
+
return /** @type {Required<T>} */ (this._request.record);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @return {Lantern.NetworkRequest<T>}
|
|
54
|
+
*/
|
|
55
|
+
get request() {
|
|
56
|
+
return this._request;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @return {string}
|
|
61
|
+
*/
|
|
62
|
+
get initiatorType() {
|
|
63
|
+
return this._request.initiator && this._request.initiator.type;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @return {boolean}
|
|
68
|
+
*/
|
|
69
|
+
get fromDiskCache() {
|
|
70
|
+
return !!this._request.fromDiskCache;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @return {boolean}
|
|
75
|
+
*/
|
|
76
|
+
get isNonNetworkProtocol() {
|
|
77
|
+
// The 'protocol' field in devtools a string more like a `scheme`
|
|
78
|
+
return UrlUtils.isNonNetworkProtocol(this.request.protocol) ||
|
|
79
|
+
// But `protocol` can fail to be populated if the request fails, so fallback to scheme.
|
|
80
|
+
UrlUtils.isNonNetworkProtocol(this.request.parsedURL.scheme);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Returns whether this network record can be downloaded without a TCP connection.
|
|
85
|
+
* During simulation we treat data coming in over a network connection separately from on-device data.
|
|
86
|
+
* @return {boolean}
|
|
87
|
+
*/
|
|
88
|
+
get isConnectionless() {
|
|
89
|
+
return this.fromDiskCache || this.isNonNetworkProtocol;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @return {boolean}
|
|
94
|
+
*/
|
|
95
|
+
hasRenderBlockingPriority() {
|
|
96
|
+
const priority = this._request.priority;
|
|
97
|
+
const isScript = this._request.resourceType === NetworkRequestTypes.Script;
|
|
98
|
+
const isDocument = this._request.resourceType === NetworkRequestTypes.Document;
|
|
99
|
+
const isBlockingScript = priority === 'High' && isScript;
|
|
100
|
+
const isBlockingHtmlImport = priority === 'High' && isDocument;
|
|
101
|
+
return priority === 'VeryHigh' || isBlockingScript || isBlockingHtmlImport;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @return {NetworkNode<T>}
|
|
106
|
+
*/
|
|
107
|
+
cloneWithoutRelationships() {
|
|
108
|
+
const node = new NetworkNode(this._request);
|
|
109
|
+
node.setIsMainDocument(this._isMainDocument);
|
|
110
|
+
return node;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export {NetworkNode};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type Node = import('./base-node.js').Node;
|
|
2
|
+
export type URLArtifact = Omit<LH.Artifacts['URL'], 'finalDisplayedUrl'>;
|
|
3
|
+
export type NetworkNodeOutput = {
|
|
4
|
+
nodes: Array<NetworkNode>;
|
|
5
|
+
idToNodeMap: Map<string, NetworkNode>;
|
|
6
|
+
urlToNodeMap: Map<string, Array<NetworkNode>>;
|
|
7
|
+
frameIdToNodeMap: Map<string, NetworkNode | null>;
|
|
8
|
+
};
|
|
9
|
+
export class PageDependencyGraph {
|
|
10
|
+
/**
|
|
11
|
+
* @param {Lantern.NetworkRequest} record
|
|
12
|
+
* @return {Array<string>}
|
|
13
|
+
*/
|
|
14
|
+
static getNetworkInitiators(record: Lantern.NetworkRequest): Array<string>;
|
|
15
|
+
/**
|
|
16
|
+
* @param {Array<Lantern.NetworkRequest>} networkRecords
|
|
17
|
+
* @return {NetworkNodeOutput}
|
|
18
|
+
*/
|
|
19
|
+
static getNetworkNodeOutput(networkRecords: Array<Lantern.NetworkRequest>): NetworkNodeOutput;
|
|
20
|
+
/**
|
|
21
|
+
* @param {LH.Artifacts.ProcessedTrace} processedTrace
|
|
22
|
+
* @return {Array<CPUNode>}
|
|
23
|
+
*/
|
|
24
|
+
static getCPUNodes({ mainThreadEvents }: LH.Artifacts.ProcessedTrace): Array<CPUNode>;
|
|
25
|
+
/**
|
|
26
|
+
* @param {NetworkNode} rootNode
|
|
27
|
+
* @param {NetworkNodeOutput} networkNodeOutput
|
|
28
|
+
*/
|
|
29
|
+
static linkNetworkNodes(rootNode: NetworkNode, networkNodeOutput: NetworkNodeOutput): void;
|
|
30
|
+
/**
|
|
31
|
+
* @param {Node} rootNode
|
|
32
|
+
* @param {NetworkNodeOutput} networkNodeOutput
|
|
33
|
+
* @param {Array<CPUNode>} cpuNodes
|
|
34
|
+
*/
|
|
35
|
+
static linkCPUNodes(rootNode: Node, networkNodeOutput: NetworkNodeOutput, cpuNodes: Array<CPUNode>): void;
|
|
36
|
+
/**
|
|
37
|
+
* Removes the given node from the graph, but retains all paths between its dependencies and
|
|
38
|
+
* dependents.
|
|
39
|
+
* @param {Node} node
|
|
40
|
+
*/
|
|
41
|
+
static _pruneNode(node: Node): void;
|
|
42
|
+
/**
|
|
43
|
+
* @param {LH.Artifacts.ProcessedTrace} processedTrace
|
|
44
|
+
* @param {Array<Lantern.NetworkRequest>} networkRecords
|
|
45
|
+
* @param {URLArtifact} URL
|
|
46
|
+
* @return {Node}
|
|
47
|
+
*/
|
|
48
|
+
static createGraph(processedTrace: LH.Artifacts.ProcessedTrace, networkRecords: Array<Lantern.NetworkRequest>, URL: URLArtifact): Node;
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param {Node} rootNode
|
|
52
|
+
*/
|
|
53
|
+
static printGraph(rootNode: Node, widthInCharacters?: number): void;
|
|
54
|
+
}
|
|
55
|
+
import { NetworkNode } from './network-node.js';
|
|
56
|
+
import * as Lantern from './types/lantern.js';
|
|
57
|
+
import { CPUNode } from './cpu-node.js';
|
|
58
|
+
//# sourceMappingURL=page-dependency-graph.d.ts.map
|