lighthouse 12.0.0-dev.20240609 → 12.0.0-dev.20240611

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 (45) hide show
  1. package/core/audits/long-tasks.d.ts +7 -6
  2. package/core/audits/long-tasks.js +5 -4
  3. package/core/computed/metrics/lantern-metric.js +2 -2
  4. package/core/computed/metrics/lantern-speed-index.js +1 -1
  5. package/core/computed/metrics/total-blocking-time.js +1 -1
  6. package/core/computed/navigation-insights.d.ts +2 -22
  7. package/core/computed/page-dependency-graph.js +5 -2
  8. package/core/computed/processed-navigation.d.ts +1 -1
  9. package/core/computed/tbt-impact-tasks.js +3 -2
  10. package/core/computed/trace-engine-result.d.ts +0 -12
  11. package/core/computed/trace-engine-result.js +5 -20
  12. package/core/config/constants.d.ts +28 -53
  13. package/core/config/constants.js +2 -43
  14. package/core/gather/driver/target-manager.d.ts +1 -1
  15. package/core/gather/gatherers/root-causes.js +0 -1
  16. package/core/gather/session.d.ts +3 -3
  17. package/core/lib/lantern/cpu-node.d.ts +10 -10
  18. package/core/lib/lantern/cpu-node.js +5 -5
  19. package/core/lib/lantern/lantern.d.ts +48 -11
  20. package/core/lib/lantern/lantern.js +40 -43
  21. package/core/lib/lantern/metric.d.ts +10 -12
  22. package/core/lib/lantern/metric.js +7 -7
  23. package/core/lib/lantern/metrics/interactive.d.ts +3 -8
  24. package/core/lib/lantern/metrics/interactive.js +5 -5
  25. package/core/lib/lantern/metrics/largest-contentful-paint.d.ts +4 -3
  26. package/core/lib/lantern/metrics/largest-contentful-paint.js +4 -4
  27. package/core/lib/lantern/metrics/max-potential-fid.d.ts +3 -8
  28. package/core/lib/lantern/metrics/max-potential-fid.js +5 -5
  29. package/core/lib/lantern/metrics/speed-index.d.ts +3 -8
  30. package/core/lib/lantern/metrics/speed-index.js +8 -8
  31. package/core/lib/lantern/metrics/total-blocking-time.d.ts +3 -8
  32. package/core/lib/lantern/metrics/total-blocking-time.js +6 -6
  33. package/core/lib/lantern/page-dependency-graph.d.ts +17 -49
  34. package/core/lib/lantern/page-dependency-graph.js +45 -354
  35. package/core/lib/lantern/simulator/network-analyzer.d.ts +6 -6
  36. package/core/lib/lantern/simulator/network-analyzer.js +2 -2
  37. package/core/lib/lantern/simulator/simulator.js +6 -6
  38. package/core/lib/lantern/trace-engine-computation-data.d.ts +25 -0
  39. package/core/lib/lantern/trace-engine-computation-data.js +468 -0
  40. package/core/lib/lantern/types/lantern.d.ts +77 -5
  41. package/core/lib/lantern-trace-saver.js +1 -1
  42. package/package.json +8 -8
  43. package/types/artifacts.d.ts +4 -11
  44. /package/core/{computed/metrics → lib/lantern}/tbt-utils.d.ts +0 -0
  45. /package/core/{computed/metrics → lib/lantern}/tbt-utils.js +0 -0
@@ -6,10 +6,7 @@
6
6
 
7
7
  import * as Lantern from './types/lantern.js';
8
8
 
9
- /** @typedef {import('@paulirish/trace_engine/models/trace/handlers/PageLoadMetricsHandler.js').MetricName} MetricName */
10
- /** @typedef {import('@paulirish/trace_engine/models/trace/handlers/PageLoadMetricsHandler.js').MetricScore} MetricScore */
11
-
12
- /** @type {LH.Util.SelfMap<LH.Crdp.Network.ResourceType>} */
9
+ /** @type {Lantern.Util.SelfMap<Lantern.ResourceType>} */
13
10
  const NetworkRequestTypes = {
14
11
  XHR: 'XHR',
15
12
  Fetch: 'Fetch',
@@ -31,48 +28,48 @@ const NetworkRequestTypes = {
31
28
  Prefetch: 'Prefetch',
32
29
  };
33
30
 
34
- /**
35
- * @param {LH.Artifacts.TraceEngineResult} traceEngineResult
36
- * @return {Lantern.Simulation.ProcessedNavigation}
37
- */
38
- function createProcessedNavigation(traceEngineResult) {
39
- const Meta = traceEngineResult.data.Meta;
40
- const frameId = Meta.mainFrameId;
41
- const scoresByNav = traceEngineResult.data.PageLoadMetrics.metricScoresByFrameId.get(frameId);
42
- if (!scoresByNav) {
43
- throw new Error('missing metric scores for main frame');
44
- }
31
+ const DEVTOOLS_RTT_ADJUSTMENT_FACTOR = 3.75;
32
+ const DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR = 0.9;
45
33
 
46
- const lastNavigationId = Meta.mainFrameNavigations.at(-1)?.args.data?.navigationId;
47
- const scores = lastNavigationId && scoresByNav.get(lastNavigationId);
48
- if (!scores) {
49
- throw new Error('missing metric scores for specified navigation');
50
- }
34
+ const throttling = {
35
+ DEVTOOLS_RTT_ADJUSTMENT_FACTOR,
36
+ DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,
37
+ // These values align with WebPageTest's definition of "Fast 3G"
38
+ // But offer similar characteristics to roughly the 75th percentile of 4G connections.
39
+ mobileSlow4G: {
40
+ rttMs: 150,
41
+ throughputKbps: 1.6 * 1024,
42
+ requestLatencyMs: 150 * DEVTOOLS_RTT_ADJUSTMENT_FACTOR,
43
+ downloadThroughputKbps: 1.6 * 1024 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,
44
+ uploadThroughputKbps: 750 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,
45
+ cpuSlowdownMultiplier: 4,
46
+ },
47
+ // These values partially align with WebPageTest's definition of "Regular 3G".
48
+ // These values are meant to roughly align with Chrome UX report's 3G definition which are based
49
+ // on HTTP RTT of 300-1400ms and downlink throughput of <700kbps.
50
+ mobileRegular3G: {
51
+ rttMs: 300,
52
+ throughputKbps: 700,
53
+ requestLatencyMs: 300 * DEVTOOLS_RTT_ADJUSTMENT_FACTOR,
54
+ downloadThroughputKbps: 700 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,
55
+ uploadThroughputKbps: 700 * DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR,
56
+ cpuSlowdownMultiplier: 4,
57
+ },
58
+ // Using a "broadband" connection type
59
+ // Corresponds to "Dense 4G 25th percentile" in https://docs.google.com/document/d/1Ft1Bnq9-t4jK5egLSOc28IL4TvR-Tt0se_1faTA4KTY/edit#heading=h.bb7nfy2x9e5v
60
+ desktopDense4G: {
61
+ rttMs: 40,
62
+ throughputKbps: 10 * 1024,
63
+ cpuSlowdownMultiplier: 1,
64
+ requestLatencyMs: 0, // 0 means unset
65
+ downloadThroughputKbps: 0,
66
+ uploadThroughputKbps: 0,
67
+ },
68
+ };
51
69
 
52
- /** @param {MetricName} metric */
53
- const getTimestampOrUndefined = metric => {
54
- const metricScore = scores.get(metric);
55
- if (!metricScore?.event) return;
56
- return metricScore.event.ts;
57
- };
58
- /** @param {MetricName} metric */
59
- const getTimestamp = metric => {
60
- const metricScore = scores.get(metric);
61
- if (!metricScore?.event) throw new Error(`missing metric: ${metric}`);
62
- return metricScore.event.ts;
63
- };
64
- // TODO: should use `MetricName.LCP`, but it is a const enum.
65
- const FCP = /** @type {MetricName} */('FCP');
66
- const LCP = /** @type {MetricName} */('LCP');
67
- return {
68
- timestamps: {
69
- firstContentfulPaint: getTimestamp(FCP),
70
- largestContentfulPaint: getTimestampOrUndefined(LCP),
71
- },
72
- };
73
- }
70
+ const constants = {throttling};
74
71
 
75
72
  export {
76
73
  NetworkRequestTypes,
77
- createProcessedNavigation,
74
+ constants,
78
75
  };
@@ -3,12 +3,10 @@ export type NetworkNode = import('./network-node.js').NetworkNode;
3
3
  export type Simulator = import('./simulator/simulator.js').Simulator;
4
4
  export type Extras = {
5
5
  optimistic: boolean;
6
- fcpResult?: LH.Artifacts.LanternMetric | undefined;
7
- lcpResult?: LH.Artifacts.LanternMetric | undefined;
8
- interactiveResult?: LH.Artifacts.LanternMetric | undefined;
9
- speedline?: {
10
- speedIndex: number;
11
- } | undefined;
6
+ fcpResult?: Lantern.Metric | undefined;
7
+ lcpResult?: Lantern.Metric | undefined;
8
+ interactiveResult?: Lantern.Metric | undefined;
9
+ observedSpeedIndex?: number | undefined;
12
10
  };
13
11
  /** @typedef {import('./base-node.js').Node} Node */
14
12
  /** @typedef {import('./network-node.js').NetworkNode} NetworkNode */
@@ -16,10 +14,10 @@ export type Extras = {
16
14
  /**
17
15
  * @typedef Extras
18
16
  * @property {boolean} optimistic
19
- * @property {LH.Artifacts.LanternMetric=} fcpResult
20
- * @property {LH.Artifacts.LanternMetric=} lcpResult
21
- * @property {LH.Artifacts.LanternMetric=} interactiveResult
22
- * @property {{speedIndex: number}=} speedline
17
+ * @property {Lantern.Metric=} fcpResult
18
+ * @property {Lantern.Metric=} lcpResult
19
+ * @property {Lantern.Metric=} interactiveResult
20
+ * @property {number=} observedSpeedIndex
23
21
  */
24
22
  export class Metric {
25
23
  /**
@@ -63,9 +61,9 @@ export class Metric {
63
61
  /**
64
62
  * @param {Lantern.Simulation.MetricComputationDataInput} data
65
63
  * @param {Omit<Extras, 'optimistic'>=} extras
66
- * @return {Promise<LH.Artifacts.LanternMetric>}
64
+ * @return {Promise<Lantern.Metric>}
67
65
  */
68
- static compute(data: Lantern.Simulation.MetricComputationDataInput, extras?: Omit<Extras, 'optimistic'> | undefined): Promise<LH.Artifacts.LanternMetric>;
66
+ static compute(data: Lantern.Simulation.MetricComputationDataInput, extras?: Omit<Extras, 'optimistic'> | undefined): Promise<Lantern.Metric>;
69
67
  }
70
68
  import * as Lantern from './types/lantern.js';
71
69
  //# sourceMappingURL=metric.d.ts.map
@@ -5,8 +5,8 @@
5
5
  */
6
6
 
7
7
  import * as Lantern from './types/lantern.js';
8
- import {BaseNode} from '../../lib/lantern/base-node.js';
9
- import {RESOURCE_TYPES} from '../../lib/network-request.js';
8
+ import {BaseNode} from './base-node.js';
9
+ import {RESOURCE_TYPES} from '../network-request.js';
10
10
 
11
11
  /** @typedef {import('./base-node.js').Node} Node */
12
12
  /** @typedef {import('./network-node.js').NetworkNode} NetworkNode */
@@ -15,10 +15,10 @@ import {RESOURCE_TYPES} from '../../lib/network-request.js';
15
15
  /**
16
16
  * @typedef Extras
17
17
  * @property {boolean} optimistic
18
- * @property {LH.Artifacts.LanternMetric=} fcpResult
19
- * @property {LH.Artifacts.LanternMetric=} lcpResult
20
- * @property {LH.Artifacts.LanternMetric=} interactiveResult
21
- * @property {{speedIndex: number}=} speedline
18
+ * @property {Lantern.Metric=} fcpResult
19
+ * @property {Lantern.Metric=} lcpResult
20
+ * @property {Lantern.Metric=} interactiveResult
21
+ * @property {number=} observedSpeedIndex
22
22
  */
23
23
 
24
24
  class Metric {
@@ -92,7 +92,7 @@ class Metric {
92
92
  /**
93
93
  * @param {Lantern.Simulation.MetricComputationDataInput} data
94
94
  * @param {Omit<Extras, 'optimistic'>=} extras
95
- * @return {Promise<LH.Artifacts.LanternMetric>}
95
+ * @return {Promise<Lantern.Metric>}
96
96
  */
97
97
  static async compute(data, extras) {
98
98
  const {simulator, graph, processedNavigation} = data;
@@ -11,16 +11,11 @@ export class Interactive extends Metric {
11
11
  */
12
12
  static getPessimisticGraph(dependencyGraph: Node): Node;
13
13
  /**
14
- * @param {LH.Gatherer.Simulation.Result} simulationResult
15
- * @param {import('../metric.js').Extras} extras
16
- * @return {LH.Gatherer.Simulation.Result}
17
- */
18
- static getEstimateFromSimulation(simulationResult: LH.Gatherer.Simulation.Result, extras: import('../metric.js').Extras): LH.Gatherer.Simulation.Result;
19
- /**
20
- * @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
14
+ * @param {Lantern.Simulation.Result['nodeTimings']} nodeTimings
21
15
  * @return {number}
22
16
  */
23
- static getLastLongTaskEndTime(nodeTimings: LH.Gatherer.Simulation.Result['nodeTimings'], duration?: number): number;
17
+ static getLastLongTaskEndTime(nodeTimings: Lantern.Simulation.Result['nodeTimings'], duration?: number): number;
24
18
  }
25
19
  import { Metric } from '../metric.js';
20
+ import * as Lantern from '../types/lantern.js';
26
21
  //# sourceMappingURL=interactive.d.ts.map
@@ -16,7 +16,7 @@ const CRITICAL_LONG_TASK_THRESHOLD = 20;
16
16
 
17
17
  class Interactive extends Metric {
18
18
  /**
19
- * @return {LH.Gatherer.Simulation.MetricCoefficients}
19
+ * @return {Lantern.Simulation.MetricCoefficients}
20
20
  */
21
21
  static get COEFFICIENTS() {
22
22
  return {
@@ -61,9 +61,9 @@ class Interactive extends Metric {
61
61
  }
62
62
 
63
63
  /**
64
- * @param {LH.Gatherer.Simulation.Result} simulationResult
64
+ * @param {Lantern.Simulation.Result} simulationResult
65
65
  * @param {import('../metric.js').Extras} extras
66
- * @return {LH.Gatherer.Simulation.Result}
66
+ * @return {Lantern.Simulation.Result}
67
67
  */
68
68
  static getEstimateFromSimulation(simulationResult, extras) {
69
69
  if (!extras.lcpResult) throw new Error('missing lcpResult');
@@ -81,7 +81,7 @@ class Interactive extends Metric {
81
81
  /**
82
82
  * @param {Lantern.Simulation.MetricComputationDataInput} data
83
83
  * @param {Omit<import('../metric.js').Extras, 'optimistic'>=} extras
84
- * @return {Promise<LH.Artifacts.LanternMetric>}
84
+ * @return {Promise<Lantern.Metric>}
85
85
  */
86
86
  static async compute(data, extras) {
87
87
  const lcpResult = extras?.lcpResult;
@@ -95,7 +95,7 @@ class Interactive extends Metric {
95
95
  }
96
96
 
97
97
  /**
98
- * @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
98
+ * @param {Lantern.Simulation.Result['nodeTimings']} nodeTimings
99
99
  * @return {number}
100
100
  */
101
101
  static getLastLongTaskEndTime(nodeTimings, duration = 50) {
@@ -10,10 +10,11 @@ export class LargestContentfulPaint extends Metric {
10
10
  */
11
11
  static isNotLowPriorityImageNode(node: Node): boolean;
12
12
  /**
13
- * @param {LH.Gatherer.Simulation.Result} simulationResult
14
- * @return {LH.Gatherer.Simulation.Result}
13
+ * @param {Lantern.Simulation.Result} simulationResult
14
+ * @return {Lantern.Simulation.Result}
15
15
  */
16
- static getEstimateFromSimulation(simulationResult: LH.Gatherer.Simulation.Result): LH.Gatherer.Simulation.Result;
16
+ static getEstimateFromSimulation(simulationResult: Lantern.Simulation.Result): Lantern.Simulation.Result;
17
17
  }
18
18
  import { Metric } from '../metric.js';
19
+ import * as Lantern from '../types/lantern.js';
19
20
  //# sourceMappingURL=largest-contentful-paint.d.ts.map
@@ -13,7 +13,7 @@ import {LanternError} from '../lantern-error.js';
13
13
 
14
14
  class LargestContentfulPaint extends Metric {
15
15
  /**
16
- * @return {LH.Gatherer.Simulation.MetricCoefficients}
16
+ * @return {Lantern.Simulation.MetricCoefficients}
17
17
  */
18
18
  static get COEFFICIENTS() {
19
19
  return {
@@ -74,8 +74,8 @@ class LargestContentfulPaint extends Metric {
74
74
  }
75
75
 
76
76
  /**
77
- * @param {LH.Gatherer.Simulation.Result} simulationResult
78
- * @return {LH.Gatherer.Simulation.Result}
77
+ * @param {Lantern.Simulation.Result} simulationResult
78
+ * @return {Lantern.Simulation.Result}
79
79
  */
80
80
  static getEstimateFromSimulation(simulationResult) {
81
81
  const nodeTimesNotOffscreenImages = Array.from(simulationResult.nodeTimings.entries())
@@ -91,7 +91,7 @@ class LargestContentfulPaint extends Metric {
91
91
  /**
92
92
  * @param {Lantern.Simulation.MetricComputationDataInput} data
93
93
  * @param {Omit<import('../metric.js').Extras, 'optimistic'>=} extras
94
- * @return {Promise<LH.Artifacts.LanternMetric>}
94
+ * @return {Promise<Lantern.Metric>}
95
95
  */
96
96
  static async compute(data, extras) {
97
97
  const fcpResult = extras?.fcpResult;
@@ -12,19 +12,14 @@ export class MaxPotentialFID extends Metric {
12
12
  */
13
13
  static getPessimisticGraph(dependencyGraph: Node): Node;
14
14
  /**
15
- * @param {LH.Gatherer.Simulation.Result} simulation
16
- * @param {import('../metric.js').Extras} extras
17
- * @return {LH.Gatherer.Simulation.Result}
18
- */
19
- static getEstimateFromSimulation(simulation: LH.Gatherer.Simulation.Result, extras: import('../metric.js').Extras): LH.Gatherer.Simulation.Result;
20
- /**
21
- * @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
15
+ * @param {Lantern.Simulation.Result['nodeTimings']} nodeTimings
22
16
  * @param {number} fcpTimeInMs
23
17
  * @return {Array<{duration: number}>}
24
18
  */
25
- static getTimingsAfterFCP(nodeTimings: LH.Gatherer.Simulation.Result['nodeTimings'], fcpTimeInMs: number): Array<{
19
+ static getTimingsAfterFCP(nodeTimings: Lantern.Simulation.Result['nodeTimings'], fcpTimeInMs: number): Array<{
26
20
  duration: number;
27
21
  }>;
28
22
  }
29
23
  import { Metric } from '../metric.js';
24
+ import * as Lantern from '../types/lantern.js';
30
25
  //# sourceMappingURL=max-potential-fid.d.ts.map
@@ -12,7 +12,7 @@ import {BaseNode} from '../base-node.js';
12
12
 
13
13
  class MaxPotentialFID extends Metric {
14
14
  /**
15
- * @return {LH.Gatherer.Simulation.MetricCoefficients}
15
+ * @return {Lantern.Simulation.MetricCoefficients}
16
16
  */
17
17
  static get COEFFICIENTS() {
18
18
  return {
@@ -39,9 +39,9 @@ class MaxPotentialFID extends Metric {
39
39
  }
40
40
 
41
41
  /**
42
- * @param {LH.Gatherer.Simulation.Result} simulation
42
+ * @param {Lantern.Simulation.Result} simulation
43
43
  * @param {import('../metric.js').Extras} extras
44
- * @return {LH.Gatherer.Simulation.Result}
44
+ * @return {Lantern.Simulation.Result}
45
45
  */
46
46
  static getEstimateFromSimulation(simulation, extras) {
47
47
  if (!extras.fcpResult) throw new Error('missing fcpResult');
@@ -66,7 +66,7 @@ class MaxPotentialFID extends Metric {
66
66
  /**
67
67
  * @param {Lantern.Simulation.MetricComputationDataInput} data
68
68
  * @param {Omit<import('../metric.js').Extras, 'optimistic'>=} extras
69
- * @return {Promise<LH.Artifacts.LanternMetric>}
69
+ * @return {Promise<Lantern.Metric>}
70
70
  */
71
71
  static compute(data, extras) {
72
72
  const fcpResult = extras?.fcpResult;
@@ -78,7 +78,7 @@ class MaxPotentialFID extends Metric {
78
78
  }
79
79
 
80
80
  /**
81
- * @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
81
+ * @param {Lantern.Simulation.Result['nodeTimings']} nodeTimings
82
82
  * @param {number} fcpTimeInMs
83
83
  * @return {Array<{duration: number}>}
84
84
  */
@@ -11,12 +11,6 @@ export class SpeedIndex extends Metric {
11
11
  * @return {Node}
12
12
  */
13
13
  static getPessimisticGraph(dependencyGraph: Node): Node;
14
- /**
15
- * @param {LH.Gatherer.Simulation.Result} simulationResult
16
- * @param {import('../metric.js').Extras} extras
17
- * @return {LH.Gatherer.Simulation.Result}
18
- */
19
- static getEstimateFromSimulation(simulationResult: LH.Gatherer.Simulation.Result, extras: import('../metric.js').Extras): LH.Gatherer.Simulation.Result;
20
14
  /**
21
15
  * Approximate speed index using layout events from the simulated node timings.
22
16
  * The layout-based speed index is the weighted average of the endTime of CPU nodes that contained
@@ -28,11 +22,12 @@ export class SpeedIndex extends Metric {
28
22
  * different methods. Read more in the evaluation doc.
29
23
  *
30
24
  * @see https://docs.google.com/document/d/1qJWXwxoyVLVadezIp_Tgdk867G3tDNkkVRvUJSH3K1E/edit#
31
- * @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
25
+ * @param {Lantern.Simulation.Result['nodeTimings']} nodeTimings
32
26
  * @param {number} fcpTimeInMs
33
27
  * @return {number}
34
28
  */
35
- static computeLayoutBasedSpeedIndex(nodeTimings: LH.Gatherer.Simulation.Result['nodeTimings'], fcpTimeInMs: number): number;
29
+ static computeLayoutBasedSpeedIndex(nodeTimings: Lantern.Simulation.Result['nodeTimings'], fcpTimeInMs: number): number;
36
30
  }
37
31
  import { Metric } from '../metric.js';
32
+ import * as Lantern from '../types/lantern.js';
38
33
  //# sourceMappingURL=speed-index.d.ts.map
@@ -14,7 +14,7 @@ const mobileSlow4GRtt = 150;
14
14
 
15
15
  class SpeedIndex extends Metric {
16
16
  /**
17
- * @return {LH.Gatherer.Simulation.MetricCoefficients}
17
+ * @return {Lantern.Simulation.MetricCoefficients}
18
18
  */
19
19
  static get COEFFICIENTS() {
20
20
  return {
@@ -28,7 +28,7 @@ class SpeedIndex extends Metric {
28
28
 
29
29
  /**
30
30
  * @param {number} rttMs
31
- * @return {LH.Gatherer.Simulation.MetricCoefficients}
31
+ * @return {Lantern.Simulation.MetricCoefficients}
32
32
  */
33
33
  static getScaledCoefficients(rttMs) { // eslint-disable-line no-unused-vars
34
34
  // We want to scale our default coefficients based on the speed of the connection.
@@ -70,17 +70,17 @@ class SpeedIndex extends Metric {
70
70
  }
71
71
 
72
72
  /**
73
- * @param {LH.Gatherer.Simulation.Result} simulationResult
73
+ * @param {Lantern.Simulation.Result} simulationResult
74
74
  * @param {import('../metric.js').Extras} extras
75
- * @return {LH.Gatherer.Simulation.Result}
75
+ * @return {Lantern.Simulation.Result}
76
76
  */
77
77
  static getEstimateFromSimulation(simulationResult, extras) {
78
78
  if (!extras.fcpResult) throw new Error('missing fcpResult');
79
- if (!extras.speedline) throw new Error('missing speedline');
79
+ if (extras.observedSpeedIndex === undefined) throw new Error('missing observedSpeedIndex');
80
80
 
81
81
  const fcpTimeInMs = extras.fcpResult.pessimisticEstimate.timeInMs;
82
82
  const estimate = extras.optimistic
83
- ? extras.speedline.speedIndex
83
+ ? extras.observedSpeedIndex
84
84
  : SpeedIndex.computeLayoutBasedSpeedIndex(simulationResult.nodeTimings, fcpTimeInMs);
85
85
  return {
86
86
  timeInMs: estimate,
@@ -91,7 +91,7 @@ class SpeedIndex extends Metric {
91
91
  /**
92
92
  * @param {Lantern.Simulation.MetricComputationDataInput} data
93
93
  * @param {Omit<import('../metric.js').Extras, 'optimistic'>=} extras
94
- * @return {Promise<LH.Artifacts.LanternMetric>}
94
+ * @return {Promise<Lantern.Metric>}
95
95
  */
96
96
  static async compute(data, extras) {
97
97
  const fcpResult = extras?.fcpResult;
@@ -115,7 +115,7 @@ class SpeedIndex extends Metric {
115
115
  * different methods. Read more in the evaluation doc.
116
116
  *
117
117
  * @see https://docs.google.com/document/d/1qJWXwxoyVLVadezIp_Tgdk867G3tDNkkVRvUJSH3K1E/edit#
118
- * @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
118
+ * @param {Lantern.Simulation.Result['nodeTimings']} nodeTimings
119
119
  * @param {number} fcpTimeInMs
120
120
  * @return {number}
121
121
  */
@@ -12,20 +12,15 @@ export class TotalBlockingTime extends Metric {
12
12
  */
13
13
  static getPessimisticGraph(dependencyGraph: Node): Node;
14
14
  /**
15
- * @param {LH.Gatherer.Simulation.Result} simulation
16
- * @param {import('../metric.js').Extras} extras
17
- * @return {LH.Gatherer.Simulation.Result}
18
- */
19
- static getEstimateFromSimulation(simulation: LH.Gatherer.Simulation.Result, extras: import('../metric.js').Extras): LH.Gatherer.Simulation.Result;
20
- /**
21
- * @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
15
+ * @param {Lantern.Simulation.Result['nodeTimings']} nodeTimings
22
16
  * @param {number} minDurationMs
23
17
  */
24
- static getTopLevelEvents(nodeTimings: LH.Gatherer.Simulation.Result['nodeTimings'], minDurationMs: number): {
18
+ static getTopLevelEvents(nodeTimings: Lantern.Simulation.Result['nodeTimings'], minDurationMs: number): {
25
19
  start: number;
26
20
  end: number;
27
21
  duration: number;
28
22
  }[];
29
23
  }
30
24
  import { Metric } from '../metric.js';
25
+ import * as Lantern from '../types/lantern.js';
31
26
  //# sourceMappingURL=total-blocking-time.d.ts.map
@@ -7,13 +7,13 @@
7
7
  import * as Lantern from '../types/lantern.js';
8
8
  import {Metric} from '../metric.js';
9
9
  import {BaseNode} from '../base-node.js';
10
- import {BLOCKING_TIME_THRESHOLD, calculateSumOfBlockingTime} from '../../../computed/metrics/tbt-utils.js';
10
+ import {BLOCKING_TIME_THRESHOLD, calculateSumOfBlockingTime} from '../tbt-utils.js';
11
11
 
12
12
  /** @typedef {import('../base-node.js').Node} Node */
13
13
 
14
14
  class TotalBlockingTime extends Metric {
15
15
  /**
16
- * @return {LH.Gatherer.Simulation.MetricCoefficients}
16
+ * @return {Lantern.Simulation.MetricCoefficients}
17
17
  */
18
18
  static get COEFFICIENTS() {
19
19
  return {
@@ -40,9 +40,9 @@ class TotalBlockingTime extends Metric {
40
40
  }
41
41
 
42
42
  /**
43
- * @param {LH.Gatherer.Simulation.Result} simulation
43
+ * @param {Lantern.Simulation.Result} simulation
44
44
  * @param {import('../metric.js').Extras} extras
45
- * @return {LH.Gatherer.Simulation.Result}
45
+ * @return {Lantern.Simulation.Result}
46
46
  */
47
47
  static getEstimateFromSimulation(simulation, extras) {
48
48
  if (!extras.fcpResult) throw new Error('missing fcpResult');
@@ -84,7 +84,7 @@ class TotalBlockingTime extends Metric {
84
84
  /**
85
85
  * @param {Lantern.Simulation.MetricComputationDataInput} data
86
86
  * @param {Omit<import('../metric.js').Extras, 'optimistic'>=} extras
87
- * @return {Promise<LH.Artifacts.LanternMetric>}
87
+ * @return {Promise<Lantern.Metric>}
88
88
  */
89
89
  static async compute(data, extras) {
90
90
  const fcpResult = extras?.fcpResult;
@@ -101,7 +101,7 @@ class TotalBlockingTime extends Metric {
101
101
  }
102
102
 
103
103
  /**
104
- * @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
104
+ * @param {Lantern.Simulation.Result['nodeTimings']} nodeTimings
105
105
  * @param {number} minDurationMs
106
106
  */
107
107
  static getTopLevelEvents(nodeTimings, minDurationMs) {
@@ -1,5 +1,4 @@
1
1
  export type Node = import('./base-node.js').Node;
2
- export type URLArtifact = Omit<LH.Artifacts['URL'], 'finalDisplayedUrl'>;
3
2
  export type NetworkNodeOutput = {
4
3
  nodes: Array<NetworkNode>;
5
4
  idToNodeMap: Map<string, NetworkNode>;
@@ -18,10 +17,22 @@ export class PageDependencyGraph {
18
17
  */
19
18
  static getNetworkNodeOutput(networkRequests: Array<Lantern.NetworkRequest>): NetworkNodeOutput;
20
19
  /**
21
- * @param {LH.TraceEvent[]} mainThreadEvents
20
+ * @param {Lantern.TraceEvent} evt
21
+ * @return {boolean}
22
+ */
23
+ static isScheduleableTask(evt: Lantern.TraceEvent): boolean;
24
+ /**
25
+ * There should *always* be at least one top level event, having 0 typically means something is
26
+ * drastically wrong with the trace and we should just give up early and loudly.
27
+ *
28
+ * @param {Lantern.TraceEvent[]} events
29
+ */
30
+ static assertHasToplevelEvents(events: Lantern.TraceEvent[]): void;
31
+ /**
32
+ * @param {Lantern.TraceEvent[]} mainThreadEvents
22
33
  * @return {Array<CPUNode>}
23
34
  */
24
- static getCPUNodes(mainThreadEvents: LH.TraceEvent[]): Array<CPUNode>;
35
+ static getCPUNodes(mainThreadEvents: Lantern.TraceEvent[]): Array<CPUNode>;
25
36
  /**
26
37
  * @param {NetworkNode} rootNode
27
38
  * @param {NetworkNodeOutput} networkNodeOutput
@@ -54,56 +65,13 @@ export class PageDependencyGraph {
54
65
  */
55
66
  static _debugNormalizeRequests(lanternRequests: Lantern.NetworkRequest[]): never;
56
67
  /**
57
- * @param {LH.TraceEvent[]} mainThreadEvents
68
+ * @param {Lantern.TraceEvent[]} mainThreadEvents
58
69
  * @param {Lantern.NetworkRequest[]} networkRequests
59
- * @param {URLArtifact} URL
70
+ * @param {Lantern.Simulation.URL} URL
60
71
  * @return {Node}
61
72
  */
62
- static createGraph(mainThreadEvents: LH.TraceEvent[], networkRequests: Lantern.NetworkRequest[], URL: URLArtifact): Node;
63
- /**
64
- * @param {Lantern.NetworkRequest} request The request to find the initiator of
65
- * @param {Map<string, Lantern.NetworkRequest[]>} requestsByURL
66
- * @return {Lantern.NetworkRequest|null}
67
- */
68
- static chooseInitiatorRequest(request: Lantern.NetworkRequest, requestsByURL: Map<string, Lantern.NetworkRequest[]>): Lantern.NetworkRequest | null;
69
- /**
70
- * Returns a map of `pid` -> `tid[]`.
71
- * @param {LH.Trace} trace
72
- * @return {Map<number, number[]>}
73
- */
74
- static _findWorkerThreads(trace: LH.Trace): Map<number, number[]>;
75
- /**
76
- * @param {URL|string} url
77
- */
78
- static _createParsedUrl(url: URL | string): {
79
- scheme: string;
80
- host: string;
81
- securityOrigin: string;
82
- };
83
- /**
84
- * @param {LH.Artifacts.TraceEngineResult} traceEngineResult
85
- * @param {Map<number, number[]>} workerThreads
86
- * @param {import('@paulirish/trace_engine/models/trace/types/TraceEvents.js').SyntheticNetworkRequest} request
87
- * @return {Lantern.NetworkRequest=}
88
- */
89
- static _createLanternRequest(traceEngineResult: LH.Artifacts.TraceEngineResult, workerThreads: Map<number, number[]>, request: import('@paulirish/trace_engine/models/trace/types/TraceEvents.js').SyntheticNetworkRequest): Lantern.NetworkRequest | undefined;
90
- /**
91
- *
92
- * @param {Lantern.NetworkRequest[]} lanternRequests
93
- */
94
- static _linkInitiators(lanternRequests: Lantern.NetworkRequest[]): void;
73
+ static createGraph(mainThreadEvents: Lantern.TraceEvent[], networkRequests: Lantern.NetworkRequest[], URL: Lantern.Simulation.URL): Node;
95
74
  /**
96
- * @param {LH.TraceEvent[]} mainThreadEvents
97
- * @param {LH.Trace} trace
98
- * @param {LH.Artifacts.TraceEngineResult} traceEngineResult
99
- * @param {LH.Artifacts.URL} URL
100
- */
101
- static createGraphFromTrace(mainThreadEvents: LH.TraceEvent[], trace: LH.Trace, traceEngineResult: LH.Artifacts.TraceEngineResult, URL: LH.Artifacts.URL): Promise<{
102
- graph: Node;
103
- records: Lantern.NetworkRequest<any>[];
104
- }>;
105
- /**
106
- *
107
75
  * @param {Node} rootNode
108
76
  */
109
77
  static printGraph(rootNode: Node, widthInCharacters?: number): void;