lighthouse 11.6.0-dev.20240302 → 11.6.0-dev.20240304

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 (67) hide show
  1. package/core/audits/byte-efficiency/byte-efficiency-audit.d.ts +2 -2
  2. package/core/audits/byte-efficiency/byte-efficiency-audit.js +7 -7
  3. package/core/audits/byte-efficiency/render-blocking-resources.d.ts +4 -3
  4. package/core/audits/byte-efficiency/render-blocking-resources.js +6 -6
  5. package/core/audits/dobetterweb/uses-http2.d.ts +3 -3
  6. package/core/audits/dobetterweb/uses-http2.js +4 -4
  7. package/core/audits/installable-manifest.d.ts +2 -0
  8. package/core/audits/installable-manifest.js +2 -0
  9. package/core/audits/prioritize-lcp-image.d.ts +1 -1
  10. package/core/computed/document-urls.js +1 -1
  11. package/core/computed/load-simulator.d.ts +1 -1
  12. package/core/computed/load-simulator.js +1 -1
  13. package/core/computed/main-resource.js +1 -1
  14. package/core/computed/metrics/lantern-first-contentful-paint.d.ts +6 -6
  15. package/core/computed/metrics/lantern-first-contentful-paint.js +4 -4
  16. package/core/computed/metrics/lantern-first-meaningful-paint.d.ts +2 -2
  17. package/core/computed/metrics/lantern-first-meaningful-paint.js +1 -1
  18. package/core/computed/metrics/lantern-interactive.d.ts +2 -6
  19. package/core/computed/metrics/lantern-interactive.js +2 -2
  20. package/core/computed/metrics/lantern-largest-contentful-paint.d.ts +2 -2
  21. package/core/computed/metrics/lantern-largest-contentful-paint.js +1 -1
  22. package/core/computed/metrics/lantern-max-potential-fid.d.ts +2 -2
  23. package/core/computed/metrics/lantern-max-potential-fid.js +2 -2
  24. package/core/computed/metrics/lantern-metric.d.ts +7 -6
  25. package/core/computed/metrics/lantern-metric.js +4 -4
  26. package/core/computed/metrics/lantern-speed-index.d.ts +2 -2
  27. package/core/computed/metrics/lantern-speed-index.js +2 -2
  28. package/core/computed/metrics/lantern-total-blocking-time.d.ts +2 -2
  29. package/core/computed/metrics/lantern-total-blocking-time.js +2 -2
  30. package/core/computed/network-analysis.js +1 -1
  31. package/core/computed/page-dependency-graph.d.ts +9 -9
  32. package/core/computed/page-dependency-graph.js +9 -9
  33. package/core/lib/asset-saver.js +1 -1
  34. package/core/lib/{dependency-graph → lantern}/base-node.d.ts +12 -8
  35. package/core/lib/{dependency-graph → lantern}/base-node.js +8 -3
  36. package/core/lib/{dependency-graph → lantern}/cpu-node.d.ts +5 -1
  37. package/core/lib/{dependency-graph → lantern}/cpu-node.js +4 -0
  38. package/core/lib/lantern/lantern.d.ts +9 -0
  39. package/core/lib/lantern/lantern.js +34 -0
  40. package/core/lib/{dependency-graph → lantern}/network-node.d.ts +16 -10
  41. package/core/lib/lantern/network-node.js +113 -0
  42. package/core/lib/{dependency-graph → lantern}/simulator/connection-pool.d.ts +11 -11
  43. package/core/lib/{dependency-graph → lantern}/simulator/connection-pool.js +6 -5
  44. package/core/lib/{dependency-graph → lantern}/simulator/dns-cache.d.ts +4 -5
  45. package/core/lib/{dependency-graph → lantern}/simulator/dns-cache.js +3 -3
  46. package/core/lib/{dependency-graph → lantern}/simulator/network-analyzer.d.ts +35 -32
  47. package/core/lib/{dependency-graph → lantern}/simulator/network-analyzer.js +21 -17
  48. package/core/lib/{dependency-graph → lantern}/simulator/simulator.d.ts +3 -3
  49. package/core/lib/{dependency-graph → lantern}/simulator/simulator.js +8 -7
  50. package/core/lib/lantern-trace-saver.d.ts +4 -4
  51. package/core/lib/lantern-trace-saver.js +6 -4
  52. package/core/lib/navigation-error.js +1 -1
  53. package/core/lib/network-request.d.ts +5 -0
  54. package/core/lib/network-request.js +12 -0
  55. package/package.json +1 -1
  56. package/shared/localization/locales/en-US.json +3 -0
  57. package/shared/localization/locales/en-XL.json +3 -0
  58. package/third-party/chromium-synchronization/installability-errors-test.js +1 -1
  59. package/tsconfig.json +5 -5
  60. package/types/artifacts.d.ts +1 -1
  61. package/types/gatherer.d.ts +5 -5
  62. package/types/internal/lantern.d.ts +82 -0
  63. package/core/lib/dependency-graph/network-node.js +0 -99
  64. /package/core/lib/{dependency-graph → lantern}/simulator/simulator-timing-map.d.ts +0 -0
  65. /package/core/lib/{dependency-graph → lantern}/simulator/simulator-timing-map.js +0 -0
  66. /package/core/lib/{dependency-graph → lantern}/simulator/tcp-connection.d.ts +0 -0
  67. /package/core/lib/{dependency-graph → lantern}/simulator/tcp-connection.js +0 -0
@@ -4,6 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
+ import * as Lantern from '../lantern.js';
7
8
  import UrlUtils from '../../url-utils.js';
8
9
 
9
10
  const INITIAL_CWD = 14 * 1024;
@@ -31,8 +32,8 @@ class NetworkAnalyzer {
31
32
  }
32
33
 
33
34
  /**
34
- * @param {LH.Artifacts.NetworkRequest[]} records
35
- * @return {Map<string, LH.Artifacts.NetworkRequest[]>}
35
+ * @param {Lantern.NetworkRequest[]} records
36
+ * @return {Map<string, Lantern.NetworkRequest[]>}
36
37
  */
37
38
  static groupByOrigin(records) {
38
39
  const grouped = new Map();
@@ -87,10 +88,10 @@ class NetworkAnalyzer {
87
88
  return summaryByKey;
88
89
  }
89
90
 
90
- /** @typedef {{record: LH.Artifacts.NetworkRequest, timing: LH.Crdp.Network.ResourceTiming, connectionReused?: boolean}} RequestInfo */
91
+ /** @typedef {{record: Lantern.NetworkRequest, timing: LH.Crdp.Network.ResourceTiming, connectionReused?: boolean}} RequestInfo */
91
92
 
92
93
  /**
93
- * @param {LH.Artifacts.NetworkRequest[]} records
94
+ * @param {Lantern.NetworkRequest[]} records
94
95
  * @param {(e: RequestInfo) => number | number[] | undefined} iteratee
95
96
  * @return {Map<string, number[]>}
96
97
  */
@@ -249,7 +250,7 @@ class NetworkAnalyzer {
249
250
  /**
250
251
  * Given the RTT to each origin, estimates the observed server response times.
251
252
  *
252
- * @param {LH.Artifacts.NetworkRequest[]} records
253
+ * @param {Lantern.NetworkRequest[]} records
253
254
  * @param {Map<string, number>} rttByOrigin
254
255
  * @return {Map<string, number[]>}
255
256
  */
@@ -270,7 +271,7 @@ class NetworkAnalyzer {
270
271
  }
271
272
 
272
273
  /**
273
- * @param {LH.Artifacts.NetworkRequest[]} records
274
+ * @param {Lantern.NetworkRequest[]} records
274
275
  * @return {boolean}
275
276
  */
276
277
  static canTrustConnectionInformation(records) {
@@ -290,7 +291,7 @@ class NetworkAnalyzer {
290
291
  * Returns a map of requestId -> connectionReused, estimating the information if the information
291
292
  * available in the records themselves appears untrustworthy.
292
293
  *
293
- * @param {LH.Artifacts.NetworkRequest[]} records
294
+ * @param {Lantern.NetworkRequest[]} records
294
295
  * @param {{forceCoarseEstimates: boolean}} [options]
295
296
  * @return {Map<string, boolean>}
296
297
  */
@@ -334,7 +335,7 @@ class NetworkAnalyzer {
334
335
  * Attempts to use the most accurate information first and falls back to coarser estimates when it
335
336
  * is unavailable.
336
337
  *
337
- * @param {LH.Artifacts.NetworkRequest[]} records
338
+ * @param {Lantern.NetworkRequest[]} records
338
339
  * @param {RTTEstimateOptions} [options]
339
340
  * @return {Map<string, Summary>}
340
341
  */
@@ -415,7 +416,7 @@ class NetworkAnalyzer {
415
416
  * Estimates the server response time of each origin. RTT times can be passed in or will be
416
417
  * estimated automatically if not provided.
417
418
  *
418
- * @param {LH.Artifacts.NetworkRequest[]} records
419
+ * @param {Lantern.NetworkRequest[]} records
419
420
  * @param {RTTEstimateOptions & {rttByOrigin?: Map<string, number>}} [options]
420
421
  * @return {Map<string, Summary>}
421
422
  */
@@ -441,7 +442,7 @@ class NetworkAnalyzer {
441
442
  * Excludes data URI, failed or otherwise incomplete, and cached requests.
442
443
  * Returns Infinity if there were no analyzable network records.
443
444
  *
444
- * @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
445
+ * @param {Array<Lantern.NetworkRequest>} networkRecords
445
446
  * @return {number}
446
447
  */
447
448
  static estimateThroughput(networkRecords) {
@@ -494,9 +495,10 @@ class NetworkAnalyzer {
494
495
  }
495
496
 
496
497
  /**
497
- * @param {Array<LH.Artifacts.NetworkRequest>} records
498
+ * @template {Lantern.NetworkRequest} T
499
+ * @param {Array<T>} records
498
500
  * @param {string} resourceUrl
499
- * @return {LH.Artifacts.NetworkRequest|undefined}
501
+ * @return {T|undefined}
500
502
  */
501
503
  static findResourceForUrl(records, resourceUrl) {
502
504
  // equalWithExcludedFragments is expensive, so check that the resourceUrl starts with the request url first
@@ -507,9 +509,10 @@ class NetworkAnalyzer {
507
509
  }
508
510
 
509
511
  /**
510
- * @param {Array<LH.Artifacts.NetworkRequest>} records
512
+ * @template {Lantern.NetworkRequest} T
513
+ * @param {Array<T>} records
511
514
  * @param {string} resourceUrl
512
- * @return {LH.Artifacts.NetworkRequest|undefined}
515
+ * @return {T|undefined}
513
516
  */
514
517
  static findLastDocumentForUrl(records, resourceUrl) {
515
518
  // equalWithExcludedFragments is expensive, so check that the resourceUrl starts with the request url first
@@ -526,11 +529,12 @@ class NetworkAnalyzer {
526
529
  * Resolves redirect chain given a main document.
527
530
  * See: {@link NetworkAnalyzer.findLastDocumentForUrl}) for how to retrieve main document.
528
531
  *
529
- * @param {LH.Artifacts.NetworkRequest} request
530
- * @return {LH.Artifacts.NetworkRequest}
532
+ * @template {Lantern.NetworkRequest} T
533
+ * @param {T} request
534
+ * @return {T}
531
535
  */
532
536
  static resolveRedirects(request) {
533
- while (request.redirectDestination) request = request.redirectDestination;
537
+ while (request.redirectDestination) request = /** @type {T} */(request.redirectDestination);
534
538
  return request;
535
539
  }
536
540
  }
@@ -5,7 +5,7 @@ export type CompleteNodeTiming = import('./simulator-timing-map.js').CpuNodeTimi
5
5
  export type ConnectionTiming = import('./simulator-timing-map.js').ConnectionTiming;
6
6
  export class Simulator {
7
7
  /** @return {Map<string, Map<Node, CompleteNodeTiming>>} */
8
- static get ALL_NODE_TIMINGS(): Map<string, Map<import("../base-node.js").Node, CompleteNodeTiming>>;
8
+ static get ALL_NODE_TIMINGS(): Map<string, Map<Node, CompleteNodeTiming>>;
9
9
  /**
10
10
  * We attempt to start nodes by their observed start time using the record priority as a tie breaker.
11
11
  * When simulating, just because a low priority image started 5ms before a high priority image doesn't mean
@@ -67,10 +67,10 @@ export class Simulator {
67
67
  */
68
68
  _markNodeAsComplete(node: Node, endTime: number, connectionTiming?: import("./simulator-timing-map.js").ConnectionTiming | undefined): void;
69
69
  /**
70
- * @param {LH.Artifacts.NetworkRequest} record
70
+ * @param {Lantern.NetworkRequest} record
71
71
  * @return {?TcpConnection}
72
72
  */
73
- _acquireConnection(record: LH.Artifacts.NetworkRequest): TcpConnection | null;
73
+ _acquireConnection(record: import("../../../../types/internal/lantern.js").NetworkRequest<any>): TcpConnection | null;
74
74
  /**
75
75
  * @return {Node[]}
76
76
  */
@@ -4,6 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
+ import * as Lantern from '../lantern.js';
7
8
  import * as LH from '../../../../types/lh.js';
8
9
  import {BaseNode} from '../base-node.js';
9
10
  import {TcpConnection} from './tcp-connection.js';
@@ -101,11 +102,11 @@ class Simulator {
101
102
  * @param {Node} graph
102
103
  */
103
104
  _initializeConnectionPool(graph) {
104
- /** @type {LH.Artifacts.NetworkRequest[]} */
105
+ /** @type {Lantern.NetworkRequest[]} */
105
106
  const records = [];
106
107
  graph.getRootNode().traverse(node => {
107
108
  if (node.type === BaseNode.TYPES.NETWORK) {
108
- records.push(node.record);
109
+ records.push(node.request);
109
110
  }
110
111
  });
111
112
 
@@ -190,7 +191,7 @@ class Simulator {
190
191
  }
191
192
 
192
193
  /**
193
- * @param {LH.Artifacts.NetworkRequest} record
194
+ * @param {Lantern.NetworkRequest} record
194
195
  * @return {?TcpConnection}
195
196
  */
196
197
  _acquireConnection(record) {
@@ -228,7 +229,7 @@ class Simulator {
228
229
  // Start a network request if we're not at max requests and a connection is available
229
230
  const numberOfActiveRequests = this._numberInProgress(node.type);
230
231
  if (numberOfActiveRequests >= this._maximumConcurrentRequests) return;
231
- const connection = this._acquireConnection(node.record);
232
+ const connection = this._acquireConnection(node.request);
232
233
  if (!connection) return;
233
234
  }
234
235
 
@@ -286,7 +287,7 @@ class Simulator {
286
287
  * @return {number}
287
288
  */
288
289
  _estimateNetworkTimeRemaining(networkNode) {
289
- const record = networkNode.record;
290
+ const record = networkNode.request;
290
291
  const timingData = this._nodeTimings.getNetworkStarted(networkNode);
291
292
 
292
293
  let timeElapsed = 0;
@@ -354,7 +355,7 @@ class Simulator {
354
355
  if (node.type !== BaseNode.TYPES.NETWORK) throw new Error('Unsupported');
355
356
  if (!('bytesDownloaded' in timingData)) throw new Error('Invalid timing data');
356
357
 
357
- const record = node.record;
358
+ const record = node.request;
358
359
  const connection = this._connectionPool.acquireActiveConnectionFromRecord(record);
359
360
  const dnsResolutionTime = this._dns.getTimeUntilResolution(record, {
360
361
  requestedAt: timingData.startTime,
@@ -535,7 +536,7 @@ class Simulator {
535
536
  */
536
537
  static _computeNodeStartPosition(node) {
537
538
  if (node.type === 'cpu') return node.startTime;
538
- return node.startTime + (PriorityStartTimePenalty[node.record.priority] * 1000 * 1000 || 0);
539
+ return node.startTime + (PriorityStartTimePenalty[node.request.priority] * 1000 * 1000 || 0);
539
540
  }
540
541
  }
541
542
 
@@ -3,15 +3,15 @@ declare namespace _default {
3
3
  export { convertNodeTimingsToTrace };
4
4
  }
5
5
  export default _default;
6
- export type Node = import('./dependency-graph/base-node.js').Node;
7
- export type CompleteNodeTiming = import('./dependency-graph/simulator/simulator.js').CompleteNodeTiming;
6
+ export type Node = import('./lantern/base-node.js').Node<LH.Artifacts.NetworkRequest>;
7
+ export type CompleteNodeTiming = import('./lantern/simulator/simulator.js').CompleteNodeTiming;
8
8
  /**
9
9
  * @license
10
10
  * Copyright 2018 Google LLC
11
11
  * SPDX-License-Identifier: Apache-2.0
12
12
  */
13
- /** @typedef {import('./dependency-graph/base-node.js').Node} Node */
14
- /** @typedef {import('./dependency-graph/simulator/simulator.js').CompleteNodeTiming} CompleteNodeTiming */
13
+ /** @typedef {import('./lantern/base-node.js').Node<LH.Artifacts.NetworkRequest>} Node */
14
+ /** @typedef {import('./lantern/simulator/simulator.js').CompleteNodeTiming} CompleteNodeTiming */
15
15
  /**
16
16
  * @param {Map<Node, CompleteNodeTiming>} nodeTimings
17
17
  * @return {LH.Trace}
@@ -4,8 +4,8 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- /** @typedef {import('./dependency-graph/base-node.js').Node} Node */
8
- /** @typedef {import('./dependency-graph/simulator/simulator.js').CompleteNodeTiming} CompleteNodeTiming */
7
+ /** @typedef {import('./lantern/base-node.js').Node<LH.Artifacts.NetworkRequest>} Node */
8
+ /** @typedef {import('./lantern/simulator/simulator.js').CompleteNodeTiming} CompleteNodeTiming */
9
9
 
10
10
  /**
11
11
  * @param {Map<Node, CompleteNodeTiming>} nodeTimings
@@ -32,9 +32,11 @@ function convertNodeTimingsToTrace(nodeTimings) {
32
32
  // Represent all CPU work that was bundled in a task as an EvaluateScript event
33
33
  traceEvents.push(...createFakeTaskEvents(node, timing));
34
34
  } else {
35
+ /** @type {LH.Artifacts.NetworkRequest} */
36
+ const record = node.record;
35
37
  // Ignore data URIs as they don't really add much value
36
- if (/^data/.test(node.record.url)) continue;
37
- traceEvents.push(...createFakeNetworkEvents(requestId, node.record, timing));
38
+ if (/^data/.test(record.url)) continue;
39
+ traceEvents.push(...createFakeNetworkEvents(requestId, record, timing));
38
40
  requestId++;
39
41
  }
40
42
  }
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import {LighthouseError} from './lh-error.js';
8
- import {NetworkAnalyzer} from './dependency-graph/simulator/network-analyzer.js';
8
+ import {NetworkAnalyzer} from './lantern/simulator/network-analyzer.js';
9
9
  import {NetworkRequest} from './network-request.js';
10
10
  import * as i18n from '../lib/i18n/i18n.js';
11
11
 
@@ -47,6 +47,11 @@ export class NetworkRequest {
47
47
  */
48
48
  static _headersDictToHeadersArray(headersDict: LH.Crdp.Network.Headers): Array<HeaderEntry>;
49
49
  static get TYPES(): LH.Util.SelfMap<LH.Crdp.Network.ResourceType>;
50
+ /**
51
+ * @param {NetworkRequest} record
52
+ * @return {Lantern.NetworkRequest<NetworkRequest>}
53
+ */
54
+ static asLanternNetworkRequest(record: NetworkRequest): import("../../types/internal/lantern.js").NetworkRequest<any>;
50
55
  /**
51
56
  * @param {NetworkRequest} record
52
57
  * @return {boolean}
@@ -53,6 +53,7 @@
53
53
  */
54
54
 
55
55
  import * as LH from '../../types/lh.js';
56
+ import * as Lantern from './lantern/lantern.js';
56
57
  import UrlUtils from './url-utils.js';
57
58
 
58
59
  // Lightrider X-Header names for timing information.
@@ -568,6 +569,17 @@ class NetworkRequest {
568
569
  return RESOURCE_TYPES;
569
570
  }
570
571
 
572
+ /**
573
+ * @param {NetworkRequest} record
574
+ * @return {Lantern.NetworkRequest<NetworkRequest>}
575
+ */
576
+ static asLanternNetworkRequest(record) {
577
+ return {
578
+ ...record,
579
+ record,
580
+ };
581
+ }
582
+
571
583
  /**
572
584
  * @param {NetworkRequest} record
573
585
  * @return {boolean}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lighthouse",
3
3
  "type": "module",
4
- "version": "11.6.0-dev.20240302",
4
+ "version": "11.6.0-dev.20240304",
5
5
  "description": "Automated auditing, performance metrics, and best practices for the web.",
6
6
  "main": "./core/index.js",
7
7
  "bin": {
@@ -1046,6 +1046,9 @@
1046
1046
  "core/audits/installable-manifest.js | manifest-missing-suitable-icon": {
1047
1047
  "message": "Manifest does not contain a suitable icon - PNG, SVG or WebP format of at least {value0} px is required, the sizes attribute must be set, and the purpose attribute, if set, must include \"any\"."
1048
1048
  },
1049
+ "core/audits/installable-manifest.js | manifest-parsing-or-network-error": {
1050
+ "message": "Manifest could not be fetched, is empty, or could not be parsed"
1051
+ },
1049
1052
  "core/audits/installable-manifest.js | no-acceptable-icon": {
1050
1053
  "message": "No supplied icon is at least {value0} px square in PNG, SVG or WebP format, with the purpose attribute unset or set to \"any\""
1051
1054
  },
@@ -1046,6 +1046,9 @@
1046
1046
  "core/audits/installable-manifest.js | manifest-missing-suitable-icon": {
1047
1047
  "message": "M̂án̂íf̂éŝt́ d̂óêś n̂ót̂ ćôńt̂áîń â śûít̂áb̂ĺê íĉón̂ - ṔN̂Ǵ, ŜV́Ĝ ór̂ Ẃêb́P̂ f́ôŕm̂át̂ óf̂ át̂ ĺêáŝt́ {value0} p̂x́ îś r̂éq̂úîŕêd́, t̂h́ê śîźêś ât́t̂ŕîb́ût́ê ḿûśt̂ b́ê śêt́, âńd̂ t́ĥé p̂úr̂ṕôśê át̂t́r̂íb̂út̂é, îf́ ŝét̂, ḿûśt̂ ín̂ćl̂úd̂é \"âńŷ\"."
1048
1048
  },
1049
+ "core/audits/installable-manifest.js | manifest-parsing-or-network-error": {
1050
+ "message": "M̂án̂íf̂éŝt́ ĉóûĺd̂ ńôt́ b̂é f̂ét̂ćĥéd̂, íŝ ém̂ṕt̂ý, ôŕ ĉóûĺd̂ ńôt́ b̂é p̂ár̂śêd́"
1051
+ },
1049
1052
  "core/audits/installable-manifest.js | no-acceptable-icon": {
1050
1053
  "message": "N̂ó ŝúp̂ṕl̂íêd́ îćôń îś ât́ l̂éâśt̂ {value0} ṕx̂ śq̂úâŕê ín̂ ṔN̂Ǵ, ŜV́Ĝ ór̂ Ẃêb́P̂ f́ôŕm̂át̂, ẃît́ĥ t́ĥé p̂úr̂ṕôśê át̂t́r̂íb̂út̂é ûńŝét̂ ór̂ śêt́ t̂ó \"âńŷ\""
1051
1054
  },
@@ -49,10 +49,10 @@ Array [
49
49
  "in-incognito",
50
50
  "manifest-display-not-supported",
51
51
  "manifest-display-override-not-supported",
52
- "manifest-empty",
53
52
  "manifest-location-changed",
54
53
  "manifest-missing-name-or-short-name",
55
54
  "manifest-missing-suitable-icon",
55
+ "manifest-parsing-or-network-error",
56
56
  "no-acceptable-icon",
57
57
  "no-icon-available",
58
58
  "no-id-specified",
package/tsconfig.json CHANGED
@@ -65,14 +65,14 @@
65
65
  "core/test/index-test.js",
66
66
  "core/test/lib/arbitrary-equality-map-test.js",
67
67
  "core/test/lib/asset-saver-test.js",
68
- "core/test/lib/dependency-graph/base-node-test.js",
69
- "core/test/lib/dependency-graph/simulator/connection-pool-test.js",
70
- "core/test/lib/dependency-graph/simulator/dns-cache-test.js",
71
- "core/test/lib/dependency-graph/simulator/network-analyzer-test.js",
72
- "core/test/lib/dependency-graph/simulator/simulator-test.js",
73
68
  "core/test/lib/emulation-test.js",
74
69
  "core/test/lib/i18n/i18n-test.js",
75
70
  "core/test/lib/icons-test.js",
71
+ "core/test/lib/lantern/base-node-test.js",
72
+ "core/test/lib/lantern/simulator/connection-pool-test.js",
73
+ "core/test/lib/lantern/simulator/dns-cache-test.js",
74
+ "core/test/lib/lantern/simulator/network-analyzer-test.js",
75
+ "core/test/lib/lantern/simulator/simulator-test.js",
76
76
  "core/test/lib/lh-element-test.js",
77
77
  "core/test/lib/lighthouse-compatibility-test.js",
78
78
  "core/test/lib/manifest-parser-test.js",
@@ -9,7 +9,7 @@ import * as TraceEngine from '@paulirish/trace_engine';
9
9
  import {LayoutShiftRootCausesData} from '@paulirish/trace_engine/models/trace/root-causes/LayoutShift.js';
10
10
 
11
11
  import {parseManifest} from '../core/lib/manifest-parser.js';
12
- import {Simulator} from '../core/lib/dependency-graph/simulator/simulator.js';
12
+ import {Simulator} from '../core/lib/lantern/simulator/simulator.js';
13
13
  import {LighthouseError} from '../core/lib/lh-error.js';
14
14
  import {NetworkRequest as _NetworkRequest} from '../core/lib/network-request.js';
15
15
  import speedline from 'speedline-core';
@@ -7,9 +7,9 @@
7
7
  import {Protocol as Crdp} from 'devtools-protocol/types/protocol.js';
8
8
  import {ProtocolMapping as CrdpMappings} from 'devtools-protocol/types/protocol-mapping.js';
9
9
 
10
- import {NetworkNode as _NetworkNode} from '../core/lib/dependency-graph/network-node.js';
11
- import {CPUNode as _CPUNode} from '../core/lib/dependency-graph/cpu-node.js';
12
- import {Simulator as _Simulator} from '../core/lib/dependency-graph/simulator/simulator.js';
10
+ import {NetworkNode as _NetworkNode} from '../core/lib/lantern/network-node.js';
11
+ import {CPUNode as _CPUNode} from '../core/lib/lantern/cpu-node.js';
12
+ import {Simulator as _Simulator} from '../core/lib/lantern/simulator/simulator.js';
13
13
  import {ExecutionContext} from '../core/gather/driver/execution-context.js';
14
14
  import {NetworkMonitor} from '../core/gather/driver/network-monitor.js';
15
15
  import {Fetcher} from '../core/gather/fetcher.js';
@@ -133,8 +133,8 @@ declare module Gatherer {
133
133
  type AnyGathererInstance = GathererInstanceExpander<Gatherer.DependencyKey>
134
134
 
135
135
  namespace Simulation {
136
- type GraphNode = import('../core/lib/dependency-graph/base-node.js').Node;
137
- type GraphNetworkNode = _NetworkNode;
136
+ type GraphNode = import('../core/lib/lantern/base-node.js').Node<Artifacts.NetworkRequest>;
137
+ type GraphNetworkNode = _NetworkNode<Artifacts.NetworkRequest>;
138
138
  type GraphCPUNode = _CPUNode;
139
139
  type Simulator = _Simulator;
140
140
 
@@ -0,0 +1,82 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import * as LH from '../lh.js'
8
+
9
+ export type ParsedURL = {
10
+ /**
11
+ * Equivalent to a `new URL(url).protocol` BUT w/o the trailing colon (:)
12
+ */
13
+ scheme: string;
14
+ /**
15
+ * Equivalent to a `new URL(url).hostname`
16
+ */
17
+ host: string;
18
+ securityOrigin: string;
19
+ };
20
+ export type LightriderStatistics = {
21
+ /**
22
+ * The difference in networkEndTime between the observed Lighthouse networkEndTime and Lightrider's derived networkEndTime.
23
+ */
24
+ endTimeDeltaMs: number;
25
+ /**
26
+ * The time spent making a TCP connection (connect + SSL). Note: this is poorly named.
27
+ */
28
+ TCPMs: number;
29
+ /**
30
+ * The time spent requesting a resource from a remote server, we use this to approx RTT. Note: this is poorly names, it really should be "server response time".
31
+ */
32
+ requestMs: number;
33
+ /**
34
+ * Time to receive the entire response payload starting the clock on receiving the first fragment (first non-header byte).
35
+ */
36
+ responseMs: number;
37
+ };
38
+ export class NetworkRequest<T=any> {
39
+ /**
40
+ * The canonical network record.
41
+ * Users of Lantern must create NetworkRequests matching this interface,
42
+ * but can store the source-of-truth for their network model in this `record`
43
+ * property. This is then accessible as a read-only property on NetworkNode.
44
+ */
45
+ record?: T;
46
+
47
+ requestId: string;
48
+ connectionId: string;
49
+ connectionReused: boolean;
50
+ url: string;
51
+ protocol: string;
52
+ parsedURL: ParsedURL;
53
+ /** When the renderer process initially discovers a network request, in milliseconds. */
54
+ rendererStartTime: number;
55
+ /**
56
+ * When the network service is about to handle a request, ie. just before going to the
57
+ * HTTP cache or going to the network for DNS/connection setup, in milliseconds.
58
+ */
59
+ networkRequestTime: number;
60
+ /** When the last byte of the response headers is received, in milliseconds. */
61
+ responseHeadersEndTime: number;
62
+ /** When the last byte of the response body is received, in milliseconds. */
63
+ networkEndTime: number;
64
+ transferSize: number;
65
+ resourceSize: number;
66
+ fromDiskCache: boolean;
67
+ fromMemoryCache: boolean;
68
+ // TODO(15841): remove from lantern.
69
+ /** Extra timing information available only when run in Lightrider. */
70
+ lrStatistics: LightriderStatistics | undefined;
71
+ finished: boolean;
72
+ statusCode: number;
73
+ /** The network request that this one redirected to */
74
+ redirectDestination: NetworkRequest<T> | undefined;
75
+ failed: boolean;
76
+ initiator: LH.Crdp.Network.Initiator;
77
+ timing: LH.Crdp.Network.ResourceTiming | undefined;
78
+ resourceType: LH.Crdp.Network.ResourceType | undefined;
79
+ priority: LH.Crdp.Network.ResourcePriority;
80
+ }
81
+
82
+ export {};
@@ -1,99 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import * as LH from '../../../types/lh.js';
8
- import {BaseNode} from './base-node.js';
9
- import {NetworkRequest} from '../network-request.js';
10
-
11
- class NetworkNode extends BaseNode {
12
- /**
13
- * @param {LH.Artifacts.NetworkRequest} networkRecord
14
- */
15
- constructor(networkRecord) {
16
- super(networkRecord.requestId);
17
- /** @private */
18
- this._record = networkRecord;
19
- }
20
-
21
- get type() {
22
- return BaseNode.TYPES.NETWORK;
23
- }
24
-
25
- /**
26
- * @return {number}
27
- */
28
- get startTime() {
29
- return this._record.rendererStartTime * 1000;
30
- }
31
-
32
- /**
33
- * @return {number}
34
- */
35
- get endTime() {
36
- return this._record.networkEndTime * 1000;
37
- }
38
-
39
- /**
40
- * @return {LH.Artifacts.NetworkRequest}
41
- */
42
- get record() {
43
- return this._record;
44
- }
45
-
46
- /**
47
- * @return {string}
48
- */
49
- get initiatorType() {
50
- return this._record.initiator && this._record.initiator.type;
51
- }
52
-
53
- /**
54
- * @return {boolean}
55
- */
56
- get fromDiskCache() {
57
- return !!this._record.fromDiskCache;
58
- }
59
-
60
- /**
61
- * @return {boolean}
62
- */
63
- get isNonNetworkProtocol() {
64
- return NetworkRequest.isNonNetworkRequest(this._record);
65
- }
66
-
67
-
68
- /**
69
- * Returns whether this network record can be downloaded without a TCP connection.
70
- * During simulation we treat data coming in over a network connection separately from on-device data.
71
- * @return {boolean}
72
- */
73
- get isConnectionless() {
74
- return this.fromDiskCache || this.isNonNetworkProtocol;
75
- }
76
-
77
- /**
78
- * @return {boolean}
79
- */
80
- hasRenderBlockingPriority() {
81
- const priority = this._record.priority;
82
- const isScript = this._record.resourceType === NetworkRequest.TYPES.Script;
83
- const isDocument = this._record.resourceType === NetworkRequest.TYPES.Document;
84
- const isBlockingScript = priority === 'High' && isScript;
85
- const isBlockingHtmlImport = priority === 'High' && isDocument;
86
- return priority === 'VeryHigh' || isBlockingScript || isBlockingHtmlImport;
87
- }
88
-
89
- /**
90
- * @return {NetworkNode}
91
- */
92
- cloneWithoutRelationships() {
93
- const node = new NetworkNode(this._record);
94
- node.setIsMainDocument(this._isMainDocument);
95
- return node;
96
- }
97
- }
98
-
99
- export {NetworkNode};