lighthouse 12.5.1-dev.20250407 → 12.5.1-dev.20250409

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.
@@ -1,5 +1,10 @@
1
1
  export default NetworkDependencyTreeInsight;
2
2
  declare class NetworkDependencyTreeInsight extends Audit {
3
+ /**
4
+ * @param {import('@paulirish/trace_engine').Insights.Models.NetworkDependencyTree.CriticalRequestNode[]} nodes
5
+ * @return {LH.Audit.Details.NetworkNode}
6
+ */
7
+ static traceEngineNodesToDetailsNodes(nodes: import("@paulirish/trace_engine").Insights.Models.NetworkDependencyTree.CriticalRequestNode[]): LH.Audit.Details.NetworkNode;
3
8
  /**
4
9
  * @param {LH.Artifacts} artifacts
5
10
  * @param {LH.Audit.Context} context
@@ -1,5 +1,3 @@
1
- /* eslint-disable no-unused-vars */ // TODO: remove once implemented.
2
-
3
1
  /**
4
2
  * @license
5
3
  * Copyright 2025 Google LLC
@@ -10,7 +8,7 @@ import {UIStrings} from '@paulirish/trace_engine/models/trace/insights/NetworkDe
10
8
 
11
9
  import {Audit} from '../audit.js';
12
10
  import * as i18n from '../../lib/i18n/i18n.js';
13
- import {adaptInsightToAuditProduct, makeNodeItemForNodeId} from './insight-audit.js';
11
+ import {adaptInsightToAuditProduct} from './insight-audit.js';
14
12
 
15
13
  // eslint-disable-next-line max-len
16
14
  const str_ = i18n.createIcuMessageFn('node_modules/@paulirish/trace_engine/models/trace/insights/NetworkDependencyTree.js', UIStrings);
@@ -25,27 +23,51 @@ class NetworkDependencyTreeInsight extends Audit {
25
23
  title: str_(UIStrings.title),
26
24
  failureTitle: str_(UIStrings.title),
27
25
  description: str_(UIStrings.description),
28
- guidanceLevel: 3,
29
- requiredArtifacts: ['traces', 'TraceElements', 'SourceMaps'],
26
+ guidanceLevel: 1,
27
+ requiredArtifacts: ['traces', 'SourceMaps'],
30
28
  replacesAudits: ['critical-request-chains'],
31
29
  };
32
30
  }
33
31
 
32
+ /**
33
+ * @param {import('@paulirish/trace_engine').Insights.Models.NetworkDependencyTree.CriticalRequestNode[]} nodes
34
+ * @return {LH.Audit.Details.NetworkNode}
35
+ */
36
+ static traceEngineNodesToDetailsNodes(nodes) {
37
+ /** @type {LH.Audit.Details.NetworkNode} */
38
+ const simpleRequestNode = {};
39
+
40
+ for (const node of nodes) {
41
+ const {request} = node;
42
+
43
+ simpleRequestNode[request.args.data.requestId] = {
44
+ url: request.args.data.url,
45
+ navStartToEndTime: Math.round(node.timeFromInitialRequest / 1000),
46
+ transferSize: request.args.data.encodedDataLength,
47
+ isLongest: node.isLongest,
48
+ children: this.traceEngineNodesToDetailsNodes(node.children),
49
+ };
50
+ }
51
+
52
+ return simpleRequestNode;
53
+ }
54
+
34
55
  /**
35
56
  * @param {LH.Artifacts} artifacts
36
57
  * @param {LH.Audit.Context} context
37
58
  * @return {Promise<LH.Audit.Product>}
38
59
  */
39
60
  static async audit(artifacts, context) {
40
- // TODO: implement.
41
61
  return adaptInsightToAuditProduct(artifacts, context, 'NetworkDependencyTree', (insight) => {
42
- /** @type {LH.Audit.Details.Table['headings']} */
43
- const headings = [
44
- ];
45
- /** @type {LH.Audit.Details.Table['items']} */
46
- const items = [
47
- ];
48
- return Audit.makeTableDetails(headings, items);
62
+ const chains = this.traceEngineNodesToDetailsNodes(insight.rootNodes);
63
+
64
+ return {
65
+ type: 'network-tree',
66
+ chains,
67
+ longestChain: {
68
+ duration: Math.round(insight.maxTime / 1000),
69
+ },
70
+ };
49
71
  });
50
72
  }
51
73
  }
package/core/scoring.d.ts CHANGED
@@ -53,6 +53,24 @@ export class ReportScoring {
53
53
  [x: string]: any;
54
54
  type: "debugdata";
55
55
  } | undefined;
56
+ } | {
57
+ type: "network-tree";
58
+ longestChain: {
59
+ duration: number;
60
+ };
61
+ chains: {
62
+ [x: string]: {
63
+ url: string | import("./index.js").IcuMessage;
64
+ navStartToEndTime: number;
65
+ transferSize: number;
66
+ isLongest?: boolean | undefined;
67
+ children?: /*elided*/ any | undefined;
68
+ };
69
+ };
70
+ debugData?: {
71
+ [x: string]: any;
72
+ type: "debugdata";
73
+ } | undefined;
56
74
  } | {
57
75
  [x: string]: any;
58
76
  type: "debugdata";