lighthouse 12.0.0 → 12.1.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.
Files changed (219) hide show
  1. package/cli/run.js +5 -38
  2. package/cli/test/smokehouse/lighthouse-runners/bundle.js +1 -1
  3. package/cli/test/smokehouse/smokehouse.js +11 -1
  4. package/core/audits/accessibility/aria-allowed-role.js +7 -9
  5. package/core/audits/byte-efficiency/byte-efficiency-audit.d.ts +2 -2
  6. package/core/audits/byte-efficiency/byte-efficiency-audit.js +3 -3
  7. package/core/audits/byte-efficiency/offscreen-images.js +1 -1
  8. package/core/audits/byte-efficiency/render-blocking-resources.d.ts +3 -3
  9. package/core/audits/byte-efficiency/render-blocking-resources.js +10 -10
  10. package/core/audits/dobetterweb/uses-http2.d.ts +2 -2
  11. package/core/audits/dobetterweb/uses-http2.js +5 -5
  12. package/core/audits/long-tasks.d.ts +7 -6
  13. package/core/audits/long-tasks.js +5 -4
  14. package/core/audits/metrics/first-meaningful-paint.d.ts +1 -17
  15. package/core/audits/metrics/first-meaningful-paint.js +5 -47
  16. package/core/audits/metrics/interactive.d.ts +1 -1
  17. package/core/audits/metrics/interactive.js +1 -1
  18. package/core/audits/predictive-perf.js +0 -6
  19. package/core/audits/prioritize-lcp-image.d.ts +1 -1
  20. package/core/audits/prioritize-lcp-image.js +2 -2
  21. package/core/audits/redirects.js +2 -3
  22. package/core/audits/third-party-facades.js +1 -1
  23. package/core/audits/third-party-summary.js +1 -1
  24. package/core/audits/uses-rel-preconnect.js +2 -2
  25. package/core/audits/uses-rel-preload.js +9 -9
  26. package/core/computed/critical-request-chains.js +3 -3
  27. package/core/computed/document-urls.js +3 -2
  28. package/core/computed/load-simulator.d.ts +4 -4
  29. package/core/computed/load-simulator.js +3 -54
  30. package/core/computed/main-resource.js +3 -2
  31. package/core/computed/metrics/interactive.d.ts +6 -0
  32. package/core/computed/metrics/interactive.js +2 -2
  33. package/core/computed/metrics/lantern-first-contentful-paint.d.ts +4 -4
  34. package/core/computed/metrics/lantern-first-contentful-paint.js +3 -3
  35. package/core/computed/metrics/lantern-interactive.d.ts +4 -4
  36. package/core/computed/metrics/lantern-interactive.js +6 -6
  37. package/core/computed/metrics/lantern-largest-contentful-paint.d.ts +4 -4
  38. package/core/computed/metrics/lantern-largest-contentful-paint.js +3 -3
  39. package/core/computed/metrics/lantern-max-potential-fid.d.ts +4 -4
  40. package/core/computed/metrics/lantern-max-potential-fid.js +3 -3
  41. package/core/computed/metrics/lantern-metric.d.ts +21 -2
  42. package/core/computed/metrics/lantern-metric.js +39 -4
  43. package/core/computed/metrics/lantern-speed-index.d.ts +4 -4
  44. package/core/computed/metrics/lantern-speed-index.js +4 -4
  45. package/core/computed/metrics/lantern-total-blocking-time.d.ts +4 -4
  46. package/core/computed/metrics/lantern-total-blocking-time.js +3 -3
  47. package/core/computed/metrics/timing-summary.js +0 -6
  48. package/core/computed/metrics/total-blocking-time.js +3 -1
  49. package/core/computed/navigation-insights.d.ts +2 -20
  50. package/core/computed/network-analysis.d.ts +0 -5
  51. package/core/computed/network-analysis.js +2 -42
  52. package/core/computed/page-dependency-graph.d.ts +5 -3
  53. package/core/computed/page-dependency-graph.js +17 -7
  54. package/core/computed/processed-navigation.d.ts +1 -1
  55. package/core/computed/tbt-impact-tasks.js +4 -2
  56. package/core/computed/trace-engine-result.d.ts +0 -11
  57. package/core/computed/trace-engine-result.js +5 -19
  58. package/core/config/constants.d.ts +28 -53
  59. package/core/config/constants.js +2 -43
  60. package/core/gather/driver/navigation.js +1 -1
  61. package/core/gather/driver/network-monitor.d.ts +2 -1
  62. package/core/gather/driver/network-monitor.js +4 -4
  63. package/core/gather/driver/target-manager.d.ts +1 -1
  64. package/core/gather/driver.d.ts +0 -12
  65. package/core/gather/driver.js +1 -26
  66. package/core/gather/gatherers/inspector-issues.js +1 -0
  67. package/core/gather/gatherers/root-causes.js +0 -1
  68. package/core/gather/session.d.ts +5 -3
  69. package/core/gather/session.js +22 -1
  70. package/core/lib/asset-saver.d.ts +13 -9
  71. package/core/lib/asset-saver.js +77 -30
  72. package/core/lib/bf-cache-strings.js +2 -2
  73. package/core/lib/lantern/{base-node.d.ts → BaseNode.d.ts} +7 -9
  74. package/core/lib/lantern/{base-node.js → BaseNode.js} +6 -6
  75. package/core/lib/lantern/BaseNode.test.js +385 -0
  76. package/core/lib/lantern/CpuNode.d.ts +43 -0
  77. package/core/lib/lantern/{cpu-node.js → CpuNode.js} +8 -9
  78. package/core/lib/lantern/{lantern-error.d.ts → LanternError.d.ts} +1 -1
  79. package/core/lib/lantern/{metric.d.ts → Metric.d.ts} +23 -25
  80. package/core/lib/lantern/{metric.js → Metric.js} +14 -16
  81. package/core/lib/lantern/{network-node.d.ts → NetworkNode.d.ts} +6 -7
  82. package/core/lib/lantern/{network-node.js → NetworkNode.js} +7 -9
  83. package/core/lib/lantern/PageDependencyGraph.d.ts +82 -0
  84. package/core/lib/lantern/{page-dependency-graph.js → PageDependencyGraph.js} +185 -50
  85. package/core/lib/lantern/PageDependencyGraph.test.js +654 -0
  86. package/core/{computed/metrics/tbt-utils.d.ts → lib/lantern/TBTUtils.d.ts} +1 -1
  87. package/core/lib/lantern/TBTUtils.test.d.ts +2 -0
  88. package/core/lib/lantern/TBTUtils.test.js +130 -0
  89. package/core/lib/lantern/TraceEngineComputationData.d.ts +25 -0
  90. package/core/lib/lantern/TraceEngineComputationData.js +466 -0
  91. package/core/lib/lantern/lantern.d.ts +19 -7
  92. package/core/lib/lantern/lantern.js +21 -1
  93. package/core/lib/lantern/metrics/{first-contentful-paint.d.ts → FirstContentfulPaint.d.ts} +11 -11
  94. package/core/lib/lantern/metrics/{first-contentful-paint.js → FirstContentfulPaint.js} +11 -13
  95. package/core/lib/lantern/metrics/FirstContentfulPaint.test.js +54 -0
  96. package/core/lib/lantern/metrics/Interactive.d.ts +20 -0
  97. package/core/lib/lantern/metrics/{interactive.js → Interactive.js} +23 -26
  98. package/core/lib/lantern/metrics/Interactive.test.js +56 -0
  99. package/core/lib/lantern/metrics/LargestContentfulPaint.d.ts +19 -0
  100. package/core/lib/lantern/metrics/{largest-contentful-paint.js → LargestContentfulPaint.js} +16 -19
  101. package/core/lib/lantern/metrics/LargestContentfulPaint.test.js +42 -0
  102. package/core/lib/lantern/metrics/MaxPotentialFID.d.ts +24 -0
  103. package/core/lib/lantern/metrics/{max-potential-fid.js → MaxPotentialFID.js} +12 -13
  104. package/core/lib/lantern/metrics/MetricTestUtils.d.ts +19 -0
  105. package/core/lib/lantern/metrics/MetricTestUtils.js +48 -0
  106. package/core/lib/lantern/metrics/{speed-index.d.ts → SpeedIndex.d.ts} +7 -13
  107. package/core/lib/lantern/metrics/{speed-index.js → SpeedIndex.js} +14 -16
  108. package/core/lib/lantern/metrics/SpeedIndex.test.js +83 -0
  109. package/core/lib/lantern/metrics/TotalBlockingTime.d.ts +25 -0
  110. package/core/lib/lantern/metrics/{total-blocking-time.js → TotalBlockingTime.js} +13 -16
  111. package/core/lib/lantern/metrics/__snapshots__/FirstContentfulPaint.test.js.snap +11 -0
  112. package/core/lib/lantern/metrics/__snapshots__/Interactive.test.js.snap +17 -0
  113. package/core/lib/lantern/metrics/metrics.d.ts +9 -0
  114. package/core/lib/lantern/metrics/metrics.js +16 -0
  115. package/core/lib/lantern/{simulator/connection-pool.d.ts → simulation/ConnectionPool.d.ts} +15 -15
  116. package/core/lib/lantern/{simulator/connection-pool.js → simulation/ConnectionPool.js} +25 -25
  117. package/core/lib/lantern/simulation/ConnectionPool.test.js +195 -0
  118. package/core/lib/lantern/simulation/Constants.d.ts +52 -0
  119. package/core/lib/lantern/simulation/Constants.js +48 -0
  120. package/core/lib/lantern/{simulator/dns-cache.d.ts → simulation/DNSCache.d.ts} +3 -3
  121. package/core/lib/lantern/{simulator/dns-cache.js → simulation/DNSCache.js} +2 -2
  122. package/core/lib/lantern/simulation/DNSCache.test.js +72 -0
  123. package/core/lib/lantern/{simulator/network-analyzer.d.ts → simulation/NetworkAnalyzer.d.ts} +34 -21
  124. package/core/lib/lantern/{simulator/network-analyzer.js → simulation/NetworkAnalyzer.js} +106 -57
  125. package/core/lib/lantern/simulation/NetworkAnalyzer.test.js +475 -0
  126. package/core/lib/lantern/{simulator/simulator-timing-map.d.ts → simulation/SimulationTimingMap.d.ts} +7 -7
  127. package/core/lib/lantern/{simulator/simulator-timing-map.js → simulation/SimulationTimingMap.js} +5 -6
  128. package/core/lib/lantern/{simulator/simulator.d.ts → simulation/Simulator.d.ts} +21 -19
  129. package/core/lib/lantern/{simulator/simulator.js → simulation/Simulator.js} +100 -45
  130. package/core/lib/lantern/simulation/Simulator.test.js +434 -0
  131. package/core/lib/lantern/simulation/TCPConnection.test.d.ts +2 -0
  132. package/core/lib/lantern/simulation/TCPConnection.test.js +374 -0
  133. package/core/lib/lantern/{simulator/tcp-connection.d.ts → simulation/TcpConnection.d.ts} +2 -2
  134. package/core/lib/lantern/{simulator/tcp-connection.js → simulation/TcpConnection.js} +1 -1
  135. package/core/lib/lantern/simulation/simulation.d.ts +21 -0
  136. package/core/lib/lantern/simulation/simulation.js +28 -0
  137. package/core/lib/lantern/types/lantern.d.ts +145 -20
  138. package/core/lib/lantern-trace-saver.d.ts +4 -4
  139. package/core/lib/lantern-trace-saver.js +4 -4
  140. package/core/lib/navigation-error.js +3 -3
  141. package/core/lib/network-recorder.js +2 -2
  142. package/core/lib/network-request.d.ts +29 -3
  143. package/core/lib/network-request.js +20 -13
  144. package/core/lib/tracehouse/trace-processor.d.ts +0 -2
  145. package/core/lib/tracehouse/trace-processor.js +1 -31
  146. package/core/lib/traces/metric-trace-events.js +0 -5
  147. package/dist/report/bundle.esm.js +1 -1
  148. package/dist/report/flow.js +1 -1
  149. package/dist/report/standalone.js +1 -1
  150. package/package.json +14 -13
  151. package/report/renderer/performance-category-renderer.js +1 -1
  152. package/shared/localization/locales/ar-XB.json +43 -4
  153. package/shared/localization/locales/ar.json +43 -4
  154. package/shared/localization/locales/bg.json +43 -4
  155. package/shared/localization/locales/ca.json +44 -5
  156. package/shared/localization/locales/cs.json +43 -4
  157. package/shared/localization/locales/da.json +43 -4
  158. package/shared/localization/locales/de.json +43 -4
  159. package/shared/localization/locales/el.json +43 -4
  160. package/shared/localization/locales/en-GB.json +42 -3
  161. package/shared/localization/locales/en-US.json +4 -4
  162. package/shared/localization/locales/en-XA.json +43 -4
  163. package/shared/localization/locales/en-XL.json +4 -4
  164. package/shared/localization/locales/es-419.json +43 -4
  165. package/shared/localization/locales/es.json +42 -3
  166. package/shared/localization/locales/fi.json +43 -4
  167. package/shared/localization/locales/fil.json +42 -3
  168. package/shared/localization/locales/fr.json +42 -3
  169. package/shared/localization/locales/he.json +48 -9
  170. package/shared/localization/locales/hi.json +43 -4
  171. package/shared/localization/locales/hr.json +43 -4
  172. package/shared/localization/locales/hu.json +42 -3
  173. package/shared/localization/locales/id.json +42 -3
  174. package/shared/localization/locales/it.json +43 -4
  175. package/shared/localization/locales/ja.json +42 -3
  176. package/shared/localization/locales/ko.json +43 -4
  177. package/shared/localization/locales/lt.json +42 -3
  178. package/shared/localization/locales/lv.json +43 -4
  179. package/shared/localization/locales/nl.json +44 -5
  180. package/shared/localization/locales/no.json +42 -3
  181. package/shared/localization/locales/pl.json +43 -4
  182. package/shared/localization/locales/pt-PT.json +43 -4
  183. package/shared/localization/locales/pt.json +43 -4
  184. package/shared/localization/locales/ro.json +43 -4
  185. package/shared/localization/locales/ru.json +43 -4
  186. package/shared/localization/locales/sk.json +43 -4
  187. package/shared/localization/locales/sl.json +42 -3
  188. package/shared/localization/locales/sr-Latn.json +43 -4
  189. package/shared/localization/locales/sr.json +43 -4
  190. package/shared/localization/locales/sv.json +42 -3
  191. package/shared/localization/locales/ta.json +42 -3
  192. package/shared/localization/locales/te.json +43 -4
  193. package/shared/localization/locales/th.json +44 -5
  194. package/shared/localization/locales/tr.json +43 -4
  195. package/shared/localization/locales/uk.json +43 -4
  196. package/shared/localization/locales/vi.json +43 -4
  197. package/shared/localization/locales/zh-HK.json +43 -4
  198. package/shared/localization/locales/zh-TW.json +43 -4
  199. package/shared/localization/locales/zh.json +43 -4
  200. package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +1 -0
  201. package/tsconfig-all.json +1 -0
  202. package/tsconfig.json +11 -7
  203. package/types/artifacts.d.ts +23 -25
  204. package/types/gatherer.d.ts +2 -3
  205. package/types/lhr/lhr.d.ts +2 -0
  206. package/core/computed/metrics/first-meaningful-paint.d.ts +0 -21
  207. package/core/computed/metrics/first-meaningful-paint.js +0 -44
  208. package/core/computed/metrics/lantern-first-meaningful-paint.d.ts +0 -25
  209. package/core/computed/metrics/lantern-first-meaningful-paint.js +0 -43
  210. package/core/lib/lantern/cpu-node.d.ts +0 -44
  211. package/core/lib/lantern/metrics/first-meaningful-paint.d.ts +0 -6
  212. package/core/lib/lantern/metrics/first-meaningful-paint.js +0 -64
  213. package/core/lib/lantern/metrics/interactive.d.ts +0 -26
  214. package/core/lib/lantern/metrics/largest-contentful-paint.d.ts +0 -19
  215. package/core/lib/lantern/metrics/max-potential-fid.d.ts +0 -30
  216. package/core/lib/lantern/metrics/total-blocking-time.d.ts +0 -31
  217. package/core/lib/lantern/page-dependency-graph.d.ts +0 -58
  218. /package/core/lib/lantern/{lantern-error.js → LanternError.js} +0 -0
  219. /package/core/{computed/metrics/tbt-utils.js → lib/lantern/TBTUtils.js} +0 -0
@@ -4,21 +4,20 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import * as Lantern from '../types/lantern.js';
8
- import {BaseNode} from '../base-node.js';
9
- import {TcpConnection} from './tcp-connection.js';
10
- import {ConnectionPool} from './connection-pool.js';
11
- import {DNSCache} from './dns-cache.js';
12
- import {SimulatorTimingMap} from './simulator-timing-map.js';
13
- import * as constants from '../../../config/constants.js';
14
-
15
- const mobileSlow4G = constants.throttling.mobileSlow4G;
16
-
17
- /** @typedef {import('../base-node.js').Node} Node */
18
- /** @typedef {import('../network-node.js').NetworkNode} NetworkNode */
19
- /** @typedef {import('../cpu-node.js').CPUNode} CpuNode */
20
- /** @typedef {import('./simulator-timing-map.js').CpuNodeTimingComplete | import('./simulator-timing-map.js').NetworkNodeTimingComplete} CompleteNodeTiming */
21
- /** @typedef {import('./simulator-timing-map.js').ConnectionTiming} ConnectionTiming */
7
+ import * as Lantern from '../lantern.js';
8
+ import {TcpConnection} from './TcpConnection.js';
9
+ import {ConnectionPool} from './ConnectionPool.js';
10
+ import {DNSCache} from './DNSCache.js';
11
+ import {SimulatorTimingMap} from './SimulationTimingMap.js';
12
+
13
+ const Constants = Lantern.Simulation.Constants;
14
+ const defaultThrottling = Constants.throttling.mobileSlow4G;
15
+
16
+ /** @typedef {import('../BaseNode.js').Node} Node */
17
+ /** @typedef {import('../NetworkNode.js').NetworkNode} NetworkNode */
18
+ /** @typedef {import('../CpuNode.js').CPUNode} CpuNode */
19
+ /** @typedef {import('./SimulationTimingMap.js').CpuNodeTimingComplete | import('./SimulationTimingMap.js').NetworkNodeTimingComplete} CompleteNodeTiming */
20
+ /** @typedef {import('./SimulationTimingMap.js').ConnectionTiming} ConnectionTiming */
22
21
 
23
22
  // see https://cs.chromium.org/search/?q=kDefaultMaxNumDelayableRequestsPerClient&sq=package:chromium&type=cs
24
23
  const DEFAULT_MAXIMUM_CONCURRENT_REQUESTS = 10;
@@ -34,7 +33,7 @@ const NodeState = {
34
33
  Complete: 3,
35
34
  };
36
35
 
37
- /** @type {Record<NetworkNode['record']['priority'], number>} */
36
+ /** @type {Record<NetworkNode['request']['priority'], number>} */
38
37
  const PriorityStartTimePenalty = {
39
38
  VeryHigh: 0,
40
39
  High: 0.25,
@@ -50,6 +49,62 @@ const ALL_SIMULATION_NODE_TIMINGS = new Map();
50
49
  * @template [T=any]
51
50
  */
52
51
  class Simulator {
52
+ /**
53
+ * @param {Lantern.Simulation.Settings} settings
54
+ */
55
+ static createSimulator(settings) {
56
+ const {throttlingMethod, throttling, precomputedLanternData, networkAnalysis} = settings;
57
+
58
+ /** @type {Lantern.Simulation.Options} */
59
+ const options = {
60
+ additionalRttByOrigin: networkAnalysis.additionalRttByOrigin,
61
+ serverResponseTimeByOrigin: networkAnalysis.serverResponseTimeByOrigin,
62
+ observedThroughput: networkAnalysis.throughput,
63
+ };
64
+
65
+ // If we have precomputed lantern data, overwrite our observed estimates and use precomputed instead
66
+ // for increased stability.
67
+ if (precomputedLanternData) {
68
+ options.additionalRttByOrigin = new Map(Object.entries(
69
+ precomputedLanternData.additionalRttByOrigin));
70
+ options.serverResponseTimeByOrigin = new Map(Object.entries(
71
+ precomputedLanternData.serverResponseTimeByOrigin));
72
+ }
73
+
74
+ switch (throttlingMethod) {
75
+ case 'provided':
76
+ options.rtt = networkAnalysis.rtt;
77
+ options.throughput = networkAnalysis.throughput;
78
+ options.cpuSlowdownMultiplier = 1;
79
+ options.layoutTaskMultiplier = 1;
80
+ break;
81
+ case 'devtools':
82
+ if (throttling) {
83
+ options.rtt =
84
+ throttling.requestLatencyMs / Constants.throttling.DEVTOOLS_RTT_ADJUSTMENT_FACTOR;
85
+ options.throughput =
86
+ throttling.downloadThroughputKbps * 1024 /
87
+ Constants.throttling.DEVTOOLS_THROUGHPUT_ADJUSTMENT_FACTOR;
88
+ }
89
+
90
+ options.cpuSlowdownMultiplier = 1;
91
+ options.layoutTaskMultiplier = 1;
92
+ break;
93
+ case 'simulate':
94
+ if (throttling) {
95
+ options.rtt = throttling.rttMs;
96
+ options.throughput = throttling.throughputKbps * 1024;
97
+ options.cpuSlowdownMultiplier = throttling.cpuSlowdownMultiplier;
98
+ }
99
+ break;
100
+ default:
101
+ // intentionally fallback to simulator defaults
102
+ break;
103
+ }
104
+
105
+ return new Simulator(options);
106
+ }
107
+
53
108
  /**
54
109
  * @param {Lantern.Simulation.Options} [options]
55
110
  */
@@ -57,10 +112,10 @@ class Simulator {
57
112
  /** @type {Required<Lantern.Simulation.Options>} */
58
113
  this._options = Object.assign(
59
114
  {
60
- rtt: mobileSlow4G.rttMs,
61
- throughput: mobileSlow4G.throughputKbps * 1024,
115
+ rtt: defaultThrottling.rttMs,
116
+ throughput: defaultThrottling.throughputKbps * 1024,
62
117
  maximumConcurrentRequests: DEFAULT_MAXIMUM_CONCURRENT_REQUESTS,
63
- cpuSlowdownMultiplier: mobileSlow4G.cpuSlowdownMultiplier,
118
+ cpuSlowdownMultiplier: defaultThrottling.cpuSlowdownMultiplier,
64
119
  layoutTaskMultiplier: DEFAULT_LAYOUT_TASK_MULTIPLIER,
65
120
  additionalRttByOrigin: new Map(),
66
121
  serverResponseTimeByOrigin: new Map(),
@@ -106,7 +161,7 @@ class Simulator {
106
161
  /** @type {Lantern.NetworkRequest[]} */
107
162
  const records = [];
108
163
  graph.getRootNode().traverse(node => {
109
- if (node.type === BaseNode.TYPES.NETWORK) {
164
+ if (node.type === Lantern.BaseNode.TYPES.NETWORK) {
110
165
  records.push(node.request);
111
166
  }
112
167
  });
@@ -192,11 +247,11 @@ class Simulator {
192
247
  }
193
248
 
194
249
  /**
195
- * @param {Lantern.NetworkRequest} record
250
+ * @param {Lantern.NetworkRequest} request
196
251
  * @return {?TcpConnection}
197
252
  */
198
- _acquireConnection(record) {
199
- return this._connectionPool.acquire(record);
253
+ _acquireConnection(request) {
254
+ return this._connectionPool.acquire(request);
200
255
  }
201
256
 
202
257
  /**
@@ -212,7 +267,7 @@ class Simulator {
212
267
  * @param {number} totalElapsedTime
213
268
  */
214
269
  _startNodeIfPossible(node, totalElapsedTime) {
215
- if (node.type === BaseNode.TYPES.CPU) {
270
+ if (node.type === Lantern.BaseNode.TYPES.CPU) {
216
271
  // Start a CPU task if there's no other CPU task in process
217
272
  if (this._numberInProgress(node.type) === 0) {
218
273
  this._markNodeAsInProgress(node, totalElapsedTime);
@@ -221,7 +276,7 @@ class Simulator {
221
276
  return;
222
277
  }
223
278
 
224
- if (node.type !== BaseNode.TYPES.NETWORK) throw new Error('Unsupported');
279
+ if (node.type !== Lantern.BaseNode.TYPES.NETWORK) throw new Error('Unsupported');
225
280
 
226
281
  // If a network request is connectionless, we can always start it, so skip the connection checks
227
282
  if (!node.isConnectionless) {
@@ -240,7 +295,7 @@ class Simulator {
240
295
  * currently in flight.
241
296
  */
242
297
  _updateNetworkCapacity() {
243
- const inFlight = this._numberInProgress(BaseNode.TYPES.NETWORK);
298
+ const inFlight = this._numberInProgress(Lantern.BaseNode.TYPES.NETWORK);
244
299
  if (inFlight === 0) return;
245
300
 
246
301
  for (const connection of this._connectionPool.connectionsInUse()) {
@@ -254,9 +309,9 @@ class Simulator {
254
309
  * @return {number}
255
310
  */
256
311
  _estimateTimeRemaining(node) {
257
- if (node.type === BaseNode.TYPES.CPU) {
312
+ if (node.type === Lantern.BaseNode.TYPES.CPU) {
258
313
  return this._estimateCPUTimeRemaining(node);
259
- } else if (node.type === BaseNode.TYPES.NETWORK) {
314
+ } else if (node.type === Lantern.BaseNode.TYPES.NETWORK) {
260
315
  return this._estimateNetworkTimeRemaining(node);
261
316
  } else {
262
317
  throw new Error('Unsupported');
@@ -286,7 +341,7 @@ class Simulator {
286
341
  * @return {number}
287
342
  */
288
343
  _estimateNetworkTimeRemaining(networkNode) {
289
- const record = networkNode.request;
344
+ const request = networkNode.request;
290
345
  const timingData = this._nodeTimings.getNetworkStarted(networkNode);
291
346
 
292
347
  let timeElapsed = 0;
@@ -294,23 +349,23 @@ class Simulator {
294
349
  // Rough access time for seeking to location on disk and reading sequentially.
295
350
  // 8ms per seek + 20ms/MB
296
351
  // @see http://norvig.com/21-days.html#answers
297
- const sizeInMb = (record.resourceSize || 0) / 1024 / 1024;
352
+ const sizeInMb = (request.resourceSize || 0) / 1024 / 1024;
298
353
  timeElapsed = 8 + 20 * sizeInMb - timingData.timeElapsed;
299
354
  } else if (networkNode.isNonNetworkProtocol) {
300
355
  // Estimates for the overhead of a data URL in Chromium and the decoding time for base64-encoded data.
301
356
  // 2ms per request + 10ms/MB
302
357
  // @see traces on https://dopiaza.org/tools/datauri/examples/index.php
303
- const sizeInMb = (record.resourceSize || 0) / 1024 / 1024;
358
+ const sizeInMb = (request.resourceSize || 0) / 1024 / 1024;
304
359
  timeElapsed = 2 + 10 * sizeInMb - timingData.timeElapsed;
305
360
  } else {
306
- const connection = this._connectionPool.acquireActiveConnectionFromRecord(record);
307
- const dnsResolutionTime = this._dns.getTimeUntilResolution(record, {
361
+ const connection = this._connectionPool.acquireActiveConnectionFromRequest(request);
362
+ const dnsResolutionTime = this._dns.getTimeUntilResolution(request, {
308
363
  requestedAt: timingData.startTime,
309
364
  shouldUpdateCache: true,
310
365
  });
311
366
  const timeAlreadyElapsed = timingData.timeElapsed;
312
367
  const calculation = connection.simulateDownloadUntil(
313
- record.transferSize - timingData.bytesDownloaded,
368
+ request.transferSize - timingData.bytesDownloaded,
314
369
  {timeAlreadyElapsed, dnsResolutionTime, maximumTimeToElapse: Infinity}
315
370
  );
316
371
 
@@ -345,23 +400,23 @@ class Simulator {
345
400
  const timingData = this._nodeTimings.getInProgress(node);
346
401
  const isFinished = timingData.estimatedTimeElapsed === timePeriodLength;
347
402
 
348
- if (node.type === BaseNode.TYPES.CPU || node.isConnectionless) {
403
+ if (node.type === Lantern.BaseNode.TYPES.CPU || node.isConnectionless) {
349
404
  return isFinished
350
405
  ? this._markNodeAsComplete(node, totalElapsedTime)
351
406
  : (timingData.timeElapsed += timePeriodLength);
352
407
  }
353
408
 
354
- if (node.type !== BaseNode.TYPES.NETWORK) throw new Error('Unsupported');
409
+ if (node.type !== Lantern.BaseNode.TYPES.NETWORK) throw new Error('Unsupported');
355
410
  if (!('bytesDownloaded' in timingData)) throw new Error('Invalid timing data');
356
411
 
357
- const record = node.request;
358
- const connection = this._connectionPool.acquireActiveConnectionFromRecord(record);
359
- const dnsResolutionTime = this._dns.getTimeUntilResolution(record, {
412
+ const request = node.request;
413
+ const connection = this._connectionPool.acquireActiveConnectionFromRequest(request);
414
+ const dnsResolutionTime = this._dns.getTimeUntilResolution(request, {
360
415
  requestedAt: timingData.startTime,
361
416
  shouldUpdateCache: true,
362
417
  });
363
418
  const calculation = connection.simulateDownloadUntil(
364
- record.transferSize - timingData.bytesDownloaded,
419
+ request.transferSize - timingData.bytesDownloaded,
365
420
  {
366
421
  dnsResolutionTime,
367
422
  timeAlreadyElapsed: timingData.timeElapsed,
@@ -374,7 +429,7 @@ class Simulator {
374
429
 
375
430
  if (isFinished) {
376
431
  connection.setWarmed(true);
377
- this._connectionPool.release(record);
432
+ this._connectionPool.release(request);
378
433
  this._markNodeAsComplete(node, totalElapsedTime, calculation.connectionTiming);
379
434
  } else {
380
435
  timingData.timeElapsed += calculation.timeElapsed;
@@ -424,7 +479,7 @@ class Simulator {
424
479
  *
425
480
  * Simulator/connection pool are allowed to deviate from what was
426
481
  * observed in the trace/devtoolsLog and start requests as soon as they are queued (i.e. do not
427
- * wait around for a warm connection to be available if the original record was fetched on a warm
482
+ * wait around for a warm connection to be available if the original request was fetched on a warm
428
483
  * connection).
429
484
  *
430
485
  * @param {Node} graph
@@ -432,7 +487,7 @@ class Simulator {
432
487
  * @return {Lantern.Simulation.Result<T>}
433
488
  */
434
489
  simulate(graph, options) {
435
- if (BaseNode.hasCycle(graph)) {
490
+ if (Lantern.BaseNode.hasCycle(graph)) {
436
491
  throw new Error('Cannot simulate graph with cycle');
437
492
  }
438
493
 
@@ -477,7 +532,7 @@ class Simulator {
477
532
  const minimumTime = this._findNextNodeCompletionTime();
478
533
  totalElapsedTime += minimumTime;
479
534
 
480
- // While this is no longer strictly necessary, it's always better than LH hanging
535
+ // While this is no longer strictly necessary, it's always better than hanging
481
536
  if (!Number.isFinite(minimumTime) || iteration > 100000) {
482
537
  throw new Error('Simulation failed, depth exceeded');
483
538
  }
@@ -524,7 +579,7 @@ class Simulator {
524
579
  }
525
580
 
526
581
  /**
527
- * We attempt to start nodes by their observed start time using the record priority as a tie breaker.
582
+ * We attempt to start nodes by their observed start time using the request priority as a tie breaker.
528
583
  * When simulating, just because a low priority image started 5ms before a high priority image doesn't mean
529
584
  * it would have happened like that when the network was slower.
530
585
  * @param {Node} node