lighthouse 12.0.0-dev.20240610 → 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 (33) 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/processed-navigation.d.ts +1 -1
  4. package/core/computed/tbt-impact-tasks.js +2 -1
  5. package/core/config/constants.d.ts +28 -53
  6. package/core/config/constants.js +2 -43
  7. package/core/lib/lantern/cpu-node.d.ts +10 -10
  8. package/core/lib/lantern/cpu-node.js +5 -5
  9. package/core/lib/lantern/lantern.d.ts +49 -7
  10. package/core/lib/lantern/lantern.js +45 -1
  11. package/core/lib/lantern/metric.d.ts +8 -8
  12. package/core/lib/lantern/metric.js +6 -6
  13. package/core/lib/lantern/metrics/interactive.d.ts +3 -8
  14. package/core/lib/lantern/metrics/interactive.js +5 -5
  15. package/core/lib/lantern/metrics/largest-contentful-paint.d.ts +4 -3
  16. package/core/lib/lantern/metrics/largest-contentful-paint.js +4 -4
  17. package/core/lib/lantern/metrics/max-potential-fid.d.ts +3 -8
  18. package/core/lib/lantern/metrics/max-potential-fid.js +5 -5
  19. package/core/lib/lantern/metrics/speed-index.d.ts +3 -8
  20. package/core/lib/lantern/metrics/speed-index.js +6 -6
  21. package/core/lib/lantern/metrics/total-blocking-time.d.ts +3 -8
  22. package/core/lib/lantern/metrics/total-blocking-time.js +5 -5
  23. package/core/lib/lantern/page-dependency-graph.d.ts +17 -6
  24. package/core/lib/lantern/page-dependency-graph.js +45 -12
  25. package/core/lib/lantern/simulator/network-analyzer.d.ts +6 -6
  26. package/core/lib/lantern/simulator/network-analyzer.js +2 -2
  27. package/core/lib/lantern/simulator/simulator.js +6 -6
  28. package/core/lib/lantern/trace-engine-computation-data.d.ts +5 -5
  29. package/core/lib/lantern/trace-engine-computation-data.js +13 -9
  30. package/core/lib/lantern/types/lantern.d.ts +77 -5
  31. package/core/lib/lantern-trace-saver.js +1 -1
  32. package/package.json +4 -4
  33. package/types/artifacts.d.ts +2 -8
@@ -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,9 +70,9 @@ 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');
@@ -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
@@ -13,7 +13,7 @@ import {BLOCKING_TIME_THRESHOLD, calculateSumOfBlockingTime} from '../tbt-utils.
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,12 +65,12 @@ 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;
73
+ static createGraph(mainThreadEvents: Lantern.TraceEvent[], networkRequests: Lantern.NetworkRequest[], URL: Lantern.Simulation.URL): Node;
63
74
  /**
64
75
  * @param {Node} rootNode
65
76
  */
@@ -8,11 +8,18 @@ import * as Lantern from './types/lantern.js';
8
8
  import {NetworkRequestTypes} from './lantern.js';
9
9
  import {NetworkNode} from './network-node.js';
10
10
  import {CPUNode} from './cpu-node.js';
11
- import {TraceProcessor} from '../tracehouse/trace-processor.js';
12
11
  import {NetworkAnalyzer} from './simulator/network-analyzer.js';
13
12
 
13
+ // COMPAT: m71+ We added RunTask to `disabled-by-default-lighthouse`
14
+ const SCHEDULABLE_TASK_TITLE_LH = 'RunTask';
15
+ // m69-70 DoWork is different and we now need RunTask, see https://bugs.chromium.org/p/chromium/issues/detail?id=871204#c11
16
+ const SCHEDULABLE_TASK_TITLE_ALT1 = 'ThreadControllerImpl::RunTask';
17
+ // In m66-68 refactored to this task title, https://crrev.com/c/883346
18
+ const SCHEDULABLE_TASK_TITLE_ALT2 = 'ThreadControllerImpl::DoWork';
19
+ // m65 and earlier
20
+ const SCHEDULABLE_TASK_TITLE_ALT3 = 'TaskQueueManager::ProcessTaskFromWorkQueue';
21
+
14
22
  /** @typedef {import('./base-node.js').Node} Node */
15
- /** @typedef {Omit<LH.Artifacts['URL'], 'finalDisplayedUrl'>} URLArtifact */
16
23
 
17
24
  /**
18
25
  * @typedef {Object} NetworkNodeOutput
@@ -109,7 +116,31 @@ class PageDependencyGraph {
109
116
  }
110
117
 
111
118
  /**
112
- * @param {LH.TraceEvent[]} mainThreadEvents
119
+ * @param {Lantern.TraceEvent} evt
120
+ * @return {boolean}
121
+ */
122
+ static isScheduleableTask(evt) {
123
+ return evt.name === SCHEDULABLE_TASK_TITLE_LH ||
124
+ evt.name === SCHEDULABLE_TASK_TITLE_ALT1 ||
125
+ evt.name === SCHEDULABLE_TASK_TITLE_ALT2 ||
126
+ evt.name === SCHEDULABLE_TASK_TITLE_ALT3;
127
+ }
128
+
129
+ /**
130
+ * There should *always* be at least one top level event, having 0 typically means something is
131
+ * drastically wrong with the trace and we should just give up early and loudly.
132
+ *
133
+ * @param {Lantern.TraceEvent[]} events
134
+ */
135
+ static assertHasToplevelEvents(events) {
136
+ const hasToplevelTask = events.some(this.isScheduleableTask);
137
+ if (!hasToplevelTask) {
138
+ throw new Error('Could not find any top level events');
139
+ }
140
+ }
141
+
142
+ /**
143
+ * @param {Lantern.TraceEvent[]} mainThreadEvents
113
144
  * @return {Array<CPUNode>}
114
145
  */
115
146
  static getCPUNodes(mainThreadEvents) {
@@ -117,14 +148,14 @@ class PageDependencyGraph {
117
148
  const nodes = [];
118
149
  let i = 0;
119
150
 
120
- TraceProcessor.assertHasToplevelEvents(mainThreadEvents);
151
+ PageDependencyGraph.assertHasToplevelEvents(mainThreadEvents);
121
152
 
122
153
  while (i < mainThreadEvents.length) {
123
154
  const evt = mainThreadEvents[i];
124
155
  i++;
125
156
 
126
157
  // Skip all trace events that aren't schedulable tasks with sizable duration
127
- if (!TraceProcessor.isScheduleableTask(evt) || !evt.dur) {
158
+ if (!PageDependencyGraph.isScheduleableTask(evt) || !evt.dur) {
128
159
  continue;
129
160
  }
130
161
 
@@ -132,23 +163,25 @@ class PageDependencyGraph {
132
163
  let correctedEndTs = undefined;
133
164
 
134
165
  // Capture all events that occurred within the task
135
- /** @type {Array<LH.TraceEvent>} */
166
+ /** @type {Array<Lantern.TraceEvent>} */
136
167
  const children = [];
137
168
  for (
138
169
  const endTime = evt.ts + evt.dur;
139
170
  i < mainThreadEvents.length && mainThreadEvents[i].ts < endTime;
140
171
  i++
141
172
  ) {
173
+ const event = mainThreadEvents[i];
174
+
142
175
  // Temporary fix for a Chrome bug where some RunTask events can be overlapping.
143
176
  // We correct that here be ensuring each RunTask ends at least 1 microsecond before the next
144
177
  // https://github.com/GoogleChrome/lighthouse/issues/15896
145
178
  // https://issues.chromium.org/issues/329678173
146
- if (TraceProcessor.isScheduleableTask(mainThreadEvents[i]) && mainThreadEvents[i].dur) {
147
- correctedEndTs = mainThreadEvents[i].ts - 1;
179
+ if (PageDependencyGraph.isScheduleableTask(event) && event.dur) {
180
+ correctedEndTs = event.ts - 1;
148
181
  break;
149
182
  }
150
183
 
151
- children.push(mainThreadEvents[i]);
184
+ children.push(event);
152
185
  }
153
186
 
154
187
  nodes.push(new CPUNode(evt, children, correctedEndTs));
@@ -210,7 +243,7 @@ class PageDependencyGraph {
210
243
  * @param {Array<CPUNode>} cpuNodes
211
244
  */
212
245
  static linkCPUNodes(rootNode, networkNodeOutput, cpuNodes) {
213
- /** @type {Set<LH.Crdp.Network.ResourceType|undefined>} */
246
+ /** @type {Set<Lantern.ResourceType|undefined>} */
214
247
  const linkableResourceTypes = new Set([
215
248
  NetworkRequestTypes.XHR, NetworkRequestTypes.Fetch, NetworkRequestTypes.Script,
216
249
  ]);
@@ -506,9 +539,9 @@ class PageDependencyGraph {
506
539
  }
507
540
 
508
541
  /**
509
- * @param {LH.TraceEvent[]} mainThreadEvents
542
+ * @param {Lantern.TraceEvent[]} mainThreadEvents
510
543
  * @param {Lantern.NetworkRequest[]} networkRequests
511
- * @param {URLArtifact} URL
544
+ * @param {Lantern.Simulation.URL} URL
512
545
  * @return {Node}
513
546
  */
514
547
  static createGraph(mainThreadEvents, networkRequests, URL) {
@@ -46,7 +46,7 @@ export class NetworkAnalyzer {
46
46
  * @return {Map<string, Summary>}
47
47
  */
48
48
  static summarize(values: Map<string, number[]>): Map<string, Summary>;
49
- /** @typedef {{request: Lantern.NetworkRequest, timing: LH.Crdp.Network.ResourceTiming, connectionReused?: boolean}} RequestInfo */
49
+ /** @typedef {{request: Lantern.NetworkRequest, timing: Lantern.ResourceTiming, connectionReused?: boolean}} RequestInfo */
50
50
  /**
51
51
  * @param {Lantern.NetworkRequest[]} requests
52
52
  * @param {(e: RequestInfo) => number | number[] | undefined} iteratee
@@ -54,7 +54,7 @@ export class NetworkAnalyzer {
54
54
  */
55
55
  static _estimateValueByOrigin(requests: Lantern.NetworkRequest[], iteratee: (e: {
56
56
  request: Lantern.NetworkRequest;
57
- timing: LH.Crdp.Network.ResourceTiming;
57
+ timing: Lantern.ResourceTiming;
58
58
  connectionReused?: boolean | undefined;
59
59
  }) => number | number[] | undefined): Map<string, number[]>;
60
60
  /**
@@ -70,7 +70,7 @@ export class NetworkAnalyzer {
70
70
  */
71
71
  static _estimateRTTViaConnectionTiming(info: {
72
72
  request: Lantern.NetworkRequest;
73
- timing: LH.Crdp.Network.ResourceTiming;
73
+ timing: Lantern.ResourceTiming;
74
74
  connectionReused?: boolean | undefined;
75
75
  }): number[] | number | undefined;
76
76
  /**
@@ -83,7 +83,7 @@ export class NetworkAnalyzer {
83
83
  */
84
84
  static _estimateRTTViaDownloadTiming(info: {
85
85
  request: Lantern.NetworkRequest;
86
- timing: LH.Crdp.Network.ResourceTiming;
86
+ timing: Lantern.ResourceTiming;
87
87
  connectionReused?: boolean | undefined;
88
88
  }): number | undefined;
89
89
  /**
@@ -97,7 +97,7 @@ export class NetworkAnalyzer {
97
97
  */
98
98
  static _estimateRTTViaSendStartTiming(info: {
99
99
  request: Lantern.NetworkRequest;
100
- timing: LH.Crdp.Network.ResourceTiming;
100
+ timing: Lantern.ResourceTiming;
101
101
  connectionReused?: boolean | undefined;
102
102
  }): number | undefined;
103
103
  /**
@@ -111,7 +111,7 @@ export class NetworkAnalyzer {
111
111
  */
112
112
  static _estimateRTTViaHeadersEndTiming(info: {
113
113
  request: Lantern.NetworkRequest;
114
- timing: LH.Crdp.Network.ResourceTiming;
114
+ timing: Lantern.ResourceTiming;
115
115
  connectionReused?: boolean | undefined;
116
116
  }): number | undefined;
117
117
  /**
@@ -15,7 +15,7 @@ const DEFAULT_SERVER_RESPONSE_PERCENTAGE = 0.4;
15
15
  /**
16
16
  * For certain resource types, server response time takes up a greater percentage of TTFB (dynamic
17
17
  * assets like HTML documents, XHR/API calls, etc)
18
- * @type {Partial<Record<LH.Crdp.Network.ResourceType, number>>}
18
+ * @type {Partial<Record<Lantern.ResourceType, number>>}
19
19
  */
20
20
  const SERVER_RESPONSE_PERCENTAGE_OF_TTFB = {
21
21
  Document: 0.9,
@@ -88,7 +88,7 @@ class NetworkAnalyzer {
88
88
  return summaryByKey;
89
89
  }
90
90
 
91
- /** @typedef {{request: Lantern.NetworkRequest, timing: LH.Crdp.Network.ResourceTiming, connectionReused?: boolean}} RequestInfo */
91
+ /** @typedef {{request: Lantern.NetworkRequest, timing: Lantern.ResourceTiming, connectionReused?: boolean}} RequestInfo */
92
92
 
93
93
  /**
94
94
  * @param {Lantern.NetworkRequest[]} requests
@@ -10,9 +10,9 @@ import {TcpConnection} from './tcp-connection.js';
10
10
  import {ConnectionPool} from './connection-pool.js';
11
11
  import {DNSCache} from './dns-cache.js';
12
12
  import {SimulatorTimingMap} from './simulator-timing-map.js';
13
- import * as constants from '../../../config/constants.js';
13
+ import {constants} from '../lantern.js';
14
14
 
15
- const mobileSlow4G = constants.throttling.mobileSlow4G;
15
+ const defaultThrottling = constants.throttling.mobileSlow4G;
16
16
 
17
17
  /** @typedef {import('../base-node.js').Node} Node */
18
18
  /** @typedef {import('../network-node.js').NetworkNode} NetworkNode */
@@ -113,10 +113,10 @@ class Simulator {
113
113
  /** @type {Required<Lantern.Simulation.Options>} */
114
114
  this._options = Object.assign(
115
115
  {
116
- rtt: mobileSlow4G.rttMs,
117
- throughput: mobileSlow4G.throughputKbps * 1024,
116
+ rtt: defaultThrottling.rttMs,
117
+ throughput: defaultThrottling.throughputKbps * 1024,
118
118
  maximumConcurrentRequests: DEFAULT_MAXIMUM_CONCURRENT_REQUESTS,
119
- cpuSlowdownMultiplier: mobileSlow4G.cpuSlowdownMultiplier,
119
+ cpuSlowdownMultiplier: defaultThrottling.cpuSlowdownMultiplier,
120
120
  layoutTaskMultiplier: DEFAULT_LAYOUT_TASK_MULTIPLIER,
121
121
  additionalRttByOrigin: new Map(),
122
122
  serverResponseTimeByOrigin: new Map(),
@@ -533,7 +533,7 @@ class Simulator {
533
533
  const minimumTime = this._findNextNodeCompletionTime();
534
534
  totalElapsedTime += minimumTime;
535
535
 
536
- // While this is no longer strictly necessary, it's always better than LH hanging
536
+ // While this is no longer strictly necessary, it's always better than hanging
537
537
  if (!Number.isFinite(minimumTime) || iteration > 100000) {
538
538
  throw new Error('Simulation failed, depth exceeded');
539
539
  }
@@ -8,18 +8,18 @@ export type MetricScore = import('@paulirish/trace_engine/models/trace/handlers/
8
8
  */
9
9
  export function createProcessedNavigation(traceEngineData: TraceEngine.Handlers.Types.TraceParseData): Lantern.Simulation.ProcessedNavigation;
10
10
  /**
11
- * @param {LH.Trace} trace
11
+ * @param {Lantern.Trace} trace
12
12
  * @param {TraceEngine.Handlers.Types.TraceParseData} traceEngineData
13
13
  * @return {Lantern.NetworkRequest[]}
14
14
  */
15
- export function createNetworkRequests(trace: LH.Trace, traceEngineData: TraceEngine.Handlers.Types.TraceParseData): Lantern.NetworkRequest[];
15
+ export function createNetworkRequests(trace: Lantern.Trace, traceEngineData: TraceEngine.Handlers.Types.TraceParseData): Lantern.NetworkRequest[];
16
16
  /**
17
17
  * @param {Lantern.NetworkRequest[]} requests
18
- * @param {LH.Trace} trace
18
+ * @param {Lantern.Trace} trace
19
19
  * @param {TraceEngine.Handlers.Types.TraceParseData} traceEngineData
20
- * @param {LH.Artifacts.URL=} URL
20
+ * @param {Lantern.Simulation.URL=} URL
21
21
  */
22
- export function createGraph(requests: Lantern.NetworkRequest[], trace: LH.Trace, traceEngineData: TraceEngine.Handlers.Types.TraceParseData, URL?: LH.Artifacts.URL | undefined): import("./page-dependency-graph.js").Node;
22
+ export function createGraph(requests: Lantern.NetworkRequest[], trace: Lantern.Trace, traceEngineData: TraceEngine.Handlers.Types.TraceParseData, URL?: Lantern.Simulation.URL | undefined): import("./page-dependency-graph.js").Node;
23
23
  import * as TraceEngine from '@paulirish/trace_engine';
24
24
  import * as Lantern from './types/lantern.js';
25
25
  //# sourceMappingURL=trace-engine-computation-data.d.ts.map
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import * as TraceEngine from '@paulirish/trace_engine';
8
+ import * as Protocol from '@paulirish/trace_engine/generated/protocol.js';
8
9
 
9
10
  import * as Lantern from './types/lantern.js';
10
11
  import {PageDependencyGraph} from './page-dependency-graph.js';
@@ -71,7 +72,7 @@ function createParsedUrl(url) {
71
72
 
72
73
  /**
73
74
  * Returns a map of `pid` -> `tid[]`.
74
- * @param {LH.Trace} trace
75
+ * @param {Lantern.Trace} trace
75
76
  * @return {Map<number, number[]>}
76
77
  */
77
78
  function findWorkerThreads(trace) {
@@ -140,6 +141,9 @@ function createLanternRequest(traceEngineData, workerThreads, request) {
140
141
  fromWorker = true;
141
142
  }
142
143
 
144
+ // typescript const enums.... gotta stop using those ...
145
+ const Other = /** @type {Protocol.Network.InitiatorType.Other} */ ('other');
146
+
143
147
  // `initiator` in the trace does not contain the stack trace for JS-initiated
144
148
  // requests. Instead, that is stored in the `stackTrace` property of the SyntheticNetworkRequest.
145
149
  // There are some minor differences in the fields, accounted for here.
@@ -148,11 +152,11 @@ function createLanternRequest(traceEngineData, workerThreads, request) {
148
152
  // which means less edges in the graph, which mean worse results.
149
153
  // TODO: Should fix in Chromium.
150
154
  /** @type {Lantern.NetworkRequest['initiator']} */
151
- const initiator = request.args.data.initiator ?? {type: 'other'};
155
+ const initiator = request.args.data.initiator ?? {type: Other};
152
156
  if (request.args.data.stackTrace) {
153
157
  const callFrames = request.args.data.stackTrace.map(f => {
154
158
  return {
155
- scriptId: String(f.scriptId),
159
+ scriptId: /** @type {Protocol.Runtime.ScriptId} */(String(f.scriptId)),
156
160
  url: f.url,
157
161
  lineNumber: f.lineNumber - 1,
158
162
  columnNumber: f.columnNumber - 1,
@@ -160,6 +164,7 @@ function createLanternRequest(traceEngineData, workerThreads, request) {
160
164
  };
161
165
  });
162
166
  initiator.stack = {callFrames};
167
+ // Note: there is no `parent` to set ...
163
168
  }
164
169
 
165
170
  let resourceType = request.args.data.resourceType;
@@ -296,7 +301,7 @@ function linkInitiators(lanternRequests) {
296
301
  }
297
302
 
298
303
  /**
299
- * @param {LH.Trace} trace
304
+ * @param {Lantern.Trace} trace
300
305
  * @param {TraceEngine.Handlers.Types.TraceParseData} traceEngineData
301
306
  * @return {Lantern.NetworkRequest[]}
302
307
  */
@@ -390,9 +395,9 @@ function createNetworkRequests(trace, traceEngineData) {
390
395
  }
391
396
 
392
397
  /**
393
- * @param {LH.Trace} trace
398
+ * @param {Lantern.Trace} trace
394
399
  * @param {TraceEngine.Handlers.Types.TraceParseData} traceEngineData
395
- * @return {LH.TraceEvent[]}
400
+ * @return {Lantern.TraceEvent[]}
396
401
  */
397
402
  function collectMainThreadEvents(trace, traceEngineData) {
398
403
  const Meta = traceEngineData.Meta;
@@ -431,9 +436,9 @@ function collectMainThreadEvents(trace, traceEngineData) {
431
436
 
432
437
  /**
433
438
  * @param {Lantern.NetworkRequest[]} requests
434
- * @param {LH.Trace} trace
439
+ * @param {Lantern.Trace} trace
435
440
  * @param {TraceEngine.Handlers.Types.TraceParseData} traceEngineData
436
- * @param {LH.Artifacts.URL=} URL
441
+ * @param {Lantern.Simulation.URL=} URL
437
442
  */
438
443
  function createGraph(requests, trace, traceEngineData, URL) {
439
444
  const mainThreadEvents = collectMainThreadEvents(trace, traceEngineData);
@@ -444,7 +449,6 @@ function createGraph(requests, trace, traceEngineData, URL) {
444
449
  URL = {
445
450
  requestedUrl: requests[0].url,
446
451
  mainDocumentUrl: '',
447
- finalDisplayedUrl: '',
448
452
  };
449
453
 
450
454
  let request = requests[0];