@paulirish/trace_engine 0.0.50 → 0.0.51

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 (225) hide show
  1. package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
  2. package/core/platform/Constructor.d.ts +2 -2
  3. package/core/platform/Constructor.js.map +1 -1
  4. package/core/platform/StringUtilities.d.ts +2 -5
  5. package/core/platform/StringUtilities.js +0 -3
  6. package/core/platform/StringUtilities.js.map +1 -1
  7. package/core/platform/TypescriptUtilities.d.ts +1 -1
  8. package/core/platform/TypescriptUtilities.js +1 -1
  9. package/core/platform/TypescriptUtilities.js.map +1 -1
  10. package/core/platform/devtools_entrypoint-bundle-typescript-tsconfig.json +2 -2
  11. package/core/platform/platform-tsconfig.json +2 -3
  12. package/core/platform/platform.d.ts +1 -2
  13. package/core/platform/platform.js +1 -2
  14. package/core/platform/platform.js.map +1 -1
  15. package/generated/protocol.d.ts +156 -31
  16. package/locales/af.json +63 -3
  17. package/locales/am.json +63 -3
  18. package/locales/ar.json +63 -3
  19. package/locales/as.json +63 -3
  20. package/locales/az.json +63 -3
  21. package/locales/be.json +64 -4
  22. package/locales/bg.json +62 -2
  23. package/locales/bn.json +63 -3
  24. package/locales/bs.json +63 -3
  25. package/locales/ca.json +62 -2
  26. package/locales/cs.json +62 -2
  27. package/locales/cy.json +63 -3
  28. package/locales/da.json +63 -3
  29. package/locales/de.json +63 -3
  30. package/locales/el.json +62 -2
  31. package/locales/en-GB.json +63 -3
  32. package/locales/en-US.json +55 -22
  33. package/locales/en-XL.json +55 -22
  34. package/locales/es-419.json +63 -3
  35. package/locales/es.json +64 -4
  36. package/locales/et.json +64 -4
  37. package/locales/eu.json +79 -19
  38. package/locales/fa.json +62 -2
  39. package/locales/fi.json +63 -3
  40. package/locales/fil.json +63 -3
  41. package/locales/fr-CA.json +63 -3
  42. package/locales/fr.json +63 -3
  43. package/locales/gl.json +62 -2
  44. package/locales/gu.json +63 -3
  45. package/locales/he.json +63 -3
  46. package/locales/hi.json +62 -2
  47. package/locales/hr.json +63 -3
  48. package/locales/hu.json +62 -2
  49. package/locales/hy.json +63 -3
  50. package/locales/id.json +62 -2
  51. package/locales/is.json +64 -4
  52. package/locales/it.json +64 -4
  53. package/locales/ja.json +63 -3
  54. package/locales/ka.json +63 -3
  55. package/locales/kk.json +62 -2
  56. package/locales/km.json +62 -2
  57. package/locales/kn.json +63 -3
  58. package/locales/ko.json +63 -3
  59. package/locales/ky.json +63 -3
  60. package/locales/lo.json +63 -3
  61. package/locales/lt.json +62 -2
  62. package/locales/lv.json +62 -2
  63. package/locales/mk.json +62 -2
  64. package/locales/ml.json +63 -3
  65. package/locales/mn.json +63 -3
  66. package/locales/mr.json +64 -4
  67. package/locales/ms.json +63 -3
  68. package/locales/my.json +63 -3
  69. package/locales/ne.json +64 -4
  70. package/locales/nl.json +63 -3
  71. package/locales/no.json +62 -2
  72. package/locales/or.json +63 -3
  73. package/locales/pa.json +62 -2
  74. package/locales/pl.json +62 -2
  75. package/locales/pt-PT.json +62 -2
  76. package/locales/pt.json +63 -3
  77. package/locales/ro.json +63 -3
  78. package/locales/ru.json +63 -3
  79. package/locales/si.json +63 -3
  80. package/locales/sk.json +63 -3
  81. package/locales/sl.json +62 -2
  82. package/locales/sq.json +63 -3
  83. package/locales/sr-Latn.json +62 -2
  84. package/locales/sr.json +62 -2
  85. package/locales/sv.json +62 -2
  86. package/locales/sw.json +63 -3
  87. package/locales/ta.json +66 -6
  88. package/locales/te.json +63 -3
  89. package/locales/th.json +63 -3
  90. package/locales/tr.json +63 -3
  91. package/locales/uk.json +63 -3
  92. package/locales/ur.json +64 -4
  93. package/locales/uz.json +62 -2
  94. package/locales/vi.json +62 -2
  95. package/locales/zh-HK.json +63 -3
  96. package/locales/zh-TW.json +63 -3
  97. package/locales/zh.json +62 -2
  98. package/locales/zu.json +63 -3
  99. package/models/cpu_profile/CPUProfileDataModel.d.ts +8 -0
  100. package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
  101. package/models/cpu_profile/cpu_profile-tsconfig.json +2 -2
  102. package/models/cpu_profile/devtools_entrypoint-bundle-typescript-tsconfig.json +2 -2
  103. package/models/trace/Processor.d.ts +1 -1
  104. package/models/trace/Processor.js +94 -74
  105. package/models/trace/Processor.js.map +1 -1
  106. package/models/trace/TracingManager.js.map +1 -1
  107. package/models/trace/bundle-tsconfig.json +1 -1
  108. package/models/trace/devtools_entrypoint-bundle-typescript-tsconfig.json +20 -2
  109. package/models/trace/extras/ScriptDuplication.d.ts +11 -15
  110. package/models/trace/extras/ScriptDuplication.js +59 -77
  111. package/models/trace/extras/ScriptDuplication.js.map +1 -1
  112. package/models/trace/extras/ThirdParties.d.ts +6 -13
  113. package/models/trace/extras/ThirdParties.js +69 -133
  114. package/models/trace/extras/ThirdParties.js.map +1 -1
  115. package/models/trace/extras/TraceTree.d.ts +15 -3
  116. package/models/trace/extras/TraceTree.js +36 -8
  117. package/models/trace/extras/TraceTree.js.map +1 -1
  118. package/models/trace/extras/devtools_entrypoint-bundle-typescript-tsconfig.json +2 -2
  119. package/models/trace/extras/extras-tsconfig.json +2 -2
  120. package/models/trace/extras/extras.d.ts +880 -787
  121. package/models/trace/extras/extras.js +880 -787
  122. package/models/trace/handlers/AsyncJSCallsHandler.js +36 -4
  123. package/models/trace/handlers/AsyncJSCallsHandler.js.map +1 -1
  124. package/models/trace/handlers/InvalidationsHandler.js +1 -0
  125. package/models/trace/handlers/InvalidationsHandler.js.map +1 -1
  126. package/models/trace/handlers/ModelHandlers.d.ts +0 -1
  127. package/models/trace/handlers/ModelHandlers.js +0 -1
  128. package/models/trace/handlers/ModelHandlers.js.map +1 -1
  129. package/models/trace/handlers/NetworkRequestsHandler.js +1 -1
  130. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
  131. package/models/trace/handlers/RendererHandler.d.ts +1 -1
  132. package/models/trace/handlers/RendererHandler.js +2 -2
  133. package/models/trace/handlers/RendererHandler.js.map +1 -1
  134. package/models/trace/handlers/ScreenshotsHandler.js +3 -1
  135. package/models/trace/handlers/ScreenshotsHandler.js.map +1 -1
  136. package/models/trace/handlers/ScriptsHandler.d.ts +12 -0
  137. package/models/trace/handlers/ScriptsHandler.js +93 -1
  138. package/models/trace/handlers/ScriptsHandler.js.map +1 -1
  139. package/models/trace/handlers/devtools_entrypoint-bundle-typescript-tsconfig.json +2 -2
  140. package/models/trace/handlers/handlers-tsconfig.json +2 -3
  141. package/models/trace/helpers/Network.d.ts +5 -0
  142. package/models/trace/helpers/Network.js +17 -0
  143. package/models/trace/helpers/Network.js.map +1 -1
  144. package/models/trace/helpers/SamplesIntegrator.js +19 -23
  145. package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
  146. package/models/trace/helpers/SyntheticEvents.d.ts +0 -1
  147. package/models/trace/helpers/SyntheticEvents.js +0 -4
  148. package/models/trace/helpers/SyntheticEvents.js.map +1 -1
  149. package/models/trace/helpers/Trace.d.ts +2 -1
  150. package/models/trace/helpers/Trace.js +101 -1
  151. package/models/trace/helpers/Trace.js.map +1 -1
  152. package/models/trace/helpers/TreeHelpers.d.ts +2 -5
  153. package/models/trace/helpers/TreeHelpers.js +0 -4
  154. package/models/trace/helpers/TreeHelpers.js.map +1 -1
  155. package/models/trace/helpers/devtools_entrypoint-bundle-typescript-tsconfig.json +2 -2
  156. package/models/trace/helpers/helpers-tsconfig.json +2 -2
  157. package/models/trace/insights/{UseCache.d.ts → Cache.d.ts} +2 -2
  158. package/models/trace/insights/{UseCache.js → Cache.js} +11 -5
  159. package/models/trace/insights/Cache.js.map +1 -0
  160. package/models/trace/insights/Common.d.ts +21 -2
  161. package/models/trace/insights/Common.js +86 -2
  162. package/models/trace/insights/Common.js.map +1 -1
  163. package/models/trace/insights/DocumentLatency.js +2 -8
  164. package/models/trace/insights/DocumentLatency.js.map +1 -1
  165. package/models/trace/insights/DuplicatedJavaScript.d.ts +7 -4
  166. package/models/trace/insights/DuplicatedJavaScript.js +25 -5
  167. package/models/trace/insights/DuplicatedJavaScript.js.map +1 -1
  168. package/models/trace/insights/ForcedReflow.d.ts +5 -1
  169. package/models/trace/insights/ForcedReflow.js +6 -2
  170. package/models/trace/insights/ForcedReflow.js.map +1 -1
  171. package/models/trace/insights/InteractionToNextPaint.d.ts +1 -0
  172. package/models/trace/insights/InteractionToNextPaint.js +3 -0
  173. package/models/trace/insights/InteractionToNextPaint.js.map +1 -1
  174. package/models/trace/insights/LegacyJavaScript.d.ts +32 -0
  175. package/models/trace/insights/LegacyJavaScript.js +77 -0
  176. package/models/trace/insights/LegacyJavaScript.js.map +1 -0
  177. package/models/trace/insights/Models.d.ts +3 -1
  178. package/models/trace/insights/Models.js +3 -1
  179. package/models/trace/insights/Models.js.map +1 -1
  180. package/models/trace/insights/ModernHTTP.d.ts +51 -0
  181. package/models/trace/insights/ModernHTTP.js +187 -0
  182. package/models/trace/insights/ModernHTTP.js.map +1 -0
  183. package/models/trace/insights/NetworkDependencyTree.js +1 -1
  184. package/models/trace/insights/NetworkDependencyTree.js.map +1 -1
  185. package/models/trace/insights/ThirdParties.d.ts +1 -5
  186. package/models/trace/insights/ThirdParties.js +8 -21
  187. package/models/trace/insights/ThirdParties.js.map +1 -1
  188. package/models/trace/insights/devtools_entrypoint-bundle-typescript-tsconfig.json +2 -2
  189. package/models/trace/insights/insights-tsconfig.json +8 -3
  190. package/models/trace/insights/types.d.ts +1 -0
  191. package/models/trace/insights/types.js.map +1 -1
  192. package/models/trace/lantern/core/core-tsconfig.json +2 -2
  193. package/models/trace/lantern/core/devtools_entrypoint-bundle-typescript-tsconfig.json +2 -2
  194. package/models/trace/lantern/devtools_entrypoint-bundle-typescript-tsconfig.json +2 -2
  195. package/models/trace/lantern/graph/devtools_entrypoint-bundle-typescript-tsconfig.json +2 -2
  196. package/models/trace/lantern/graph/graph-tsconfig.json +2 -2
  197. package/models/trace/lantern/lantern-tsconfig.json +2 -2
  198. package/models/trace/lantern/metrics/Metric.d.ts +4 -4
  199. package/models/trace/lantern/metrics/Metric.js +4 -6
  200. package/models/trace/lantern/metrics/Metric.js.map +1 -1
  201. package/models/trace/lantern/metrics/devtools_entrypoint-bundle-typescript-tsconfig.json +2 -2
  202. package/models/trace/lantern/metrics/metrics-tsconfig.json +2 -2
  203. package/models/trace/lantern/simulation/devtools_entrypoint-bundle-typescript-tsconfig.json +2 -2
  204. package/models/trace/lantern/simulation/simulation-tsconfig.json +2 -2
  205. package/models/trace/lantern/types/devtools_entrypoint-bundle-typescript-tsconfig.json +2 -2
  206. package/models/trace/lantern/types/types-tsconfig.json +2 -2
  207. package/models/trace/trace-tsconfig.json +2 -2
  208. package/models/trace/types/Configuration.d.ts +2 -0
  209. package/models/trace/types/Configuration.js.map +1 -1
  210. package/models/trace/types/TraceEvents.d.ts +28 -50
  211. package/models/trace/types/TraceEvents.js +8 -23
  212. package/models/trace/types/TraceEvents.js.map +1 -1
  213. package/models/trace/types/devtools_entrypoint-bundle-typescript-tsconfig.json +2 -2
  214. package/models/trace/types/types-tsconfig.json +2 -2
  215. package/package.json +3 -2
  216. package/test/test-trace-engine.mjs +19 -17
  217. package/third_party/legacy-javascript/legacy-javascript.d.ts +1 -0
  218. package/third_party/legacy-javascript/legacy-javascript.js +1 -0
  219. package/core/platform/ServerTiming.d.ts +0 -31
  220. package/core/platform/ServerTiming.js +0 -212
  221. package/core/platform/ServerTiming.js.map +0 -1
  222. package/models/trace/handlers/ServerTimingsHandler.d.ts +0 -9
  223. package/models/trace/handlers/ServerTimingsHandler.js +0 -106
  224. package/models/trace/handlers/ServerTimingsHandler.js.map +0 -1
  225. package/models/trace/insights/UseCache.js.map +0 -1
@@ -0,0 +1,187 @@
1
+ // Copyright 2025 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+ // import * as i18n from '../../../core/i18n/i18n.js';
5
+ import * as Platform from '../../../core/platform/platform.js';
6
+ import * as Handlers from '../handlers/handlers.js';
7
+ import * as Helpers from '../helpers/helpers.js';
8
+ import { InsightCategory, } from './types.js';
9
+ export const UIStrings = {
10
+ /**
11
+ * @description Title of an insight that recommends using HTTP/2 over HTTP/1.1 because of the performance benefits. "HTTP" should not be translated.
12
+ */
13
+ title: 'Modern HTTP',
14
+ /**
15
+ * @description Description of an insight that recommends recommends using HTTP/2 over HTTP/1.1 because of the performance benefits. "HTTP" should not be translated.
16
+ */
17
+ description: 'HTTP/2 and HTTP/3 offer many benefits over HTTP/1.1, such as multiplexing. [Learn more about using modern HTTP](https://developer.chrome.com/docs/lighthouse/best-practices/uses-http2/).',
18
+ /**
19
+ * @description Column header for a table where each cell represents a network request.
20
+ */
21
+ request: 'Request',
22
+ /**
23
+ * @description Column header for a table where each cell represents the protocol of a network request.
24
+ */
25
+ protocol: 'Protocol',
26
+ /**
27
+ * @description Text explaining that there were not requests that were slowed down by using HTTP/1.1. "HTTP/1.1" should not be translated.
28
+ */
29
+ noOldProtocolRequests: 'No requests used HTTP/1.1'
30
+ };
31
+ // const str_ = i18n.i18n.registerUIStrings('models/trace/insights/ModernHTTP.ts', UIStrings);
32
+ export const i18nString = (i18nId, values) => ({i18nId, values}); // i18n.i18n.getLocalizedString.bind(undefined, str_);
33
+ /**
34
+ * Determines whether a network request is a "static resource" that would benefit from H2 multiplexing.
35
+ * XHRs, tracking pixels, etc generally don't benefit as much because they aren't requested en-masse
36
+ * for the same origin at the exact same time.
37
+ */
38
+ function isMultiplexableStaticAsset(request, entityMappings, firstPartyEntity) {
39
+ if (!Helpers.Network.STATIC_RESOURCE_TYPES.has(request.args.data.resourceType)) {
40
+ return false;
41
+ }
42
+ // Resources from third-parties that are less than 100 bytes are usually tracking pixels, not actual resources.
43
+ // They can masquerade as static types though (gifs, documents, etc)
44
+ if (request.args.data.decodedBodyLength < 100) {
45
+ const entity = entityMappings.entityByEvent.get(request);
46
+ if (entity) {
47
+ // Third-party assets are multiplexable in their first-party context.
48
+ if (firstPartyEntity?.name === entity.name) {
49
+ return true;
50
+ }
51
+ // Skip recognizable third-parties' requests.
52
+ if (!entity.isUnrecognized) {
53
+ return false;
54
+ }
55
+ }
56
+ }
57
+ return true;
58
+ }
59
+ /**
60
+ * Determine the set of resources that aren't HTTP/2 but should be.
61
+ * We're a little conservative about what we surface for a few reasons:
62
+ *
63
+ * - The simulator approximation of HTTP/2 is a little more generous than reality.
64
+ * - There's a bit of debate surrounding HTTP/2 due to its worse performance in environments with high packet loss. [1][2][3]
65
+ * - It's something that you'd have absolutely zero control over with a third-party (can't defer to fix it for example).
66
+ *
67
+ * Therefore, we only surface requests that were...
68
+ *
69
+ * - Served over HTTP/1.1 or earlier
70
+ * - Served over an origin that serves at least 6 static asset requests
71
+ * (if there aren't more requests than browser's max/host, multiplexing isn't as big a deal)
72
+ * - Not served on localhost (h2 is a pain to deal with locally & and CI)
73
+ *
74
+ * [1] https://news.ycombinator.com/item?id=19086639
75
+ * [2] https://www.twilio.com/blog/2017/10/http2-issues.html
76
+ * [3] https://www.cachefly.com/http-2-is-not-a-magic-bullet/
77
+ */
78
+ export function determineNonHttp2Resources(requests, entityMappings, firstPartyEntity) {
79
+ const nonHttp2Resources = [];
80
+ const groupedByOrigin = new Map();
81
+ for (const record of requests) {
82
+ const url = new URL(record.args.data.url);
83
+ if (!isMultiplexableStaticAsset(record, entityMappings, firstPartyEntity)) {
84
+ continue;
85
+ }
86
+ if (Helpers.Network.isSyntheticNetworkRequestLocalhost(record)) {
87
+ continue;
88
+ }
89
+ const originRequests = Platform.MapUtilities.getWithDefault(groupedByOrigin, url.origin, () => []);
90
+ originRequests.push(record);
91
+ }
92
+ const seenURLs = new Set();
93
+ for (const request of requests) {
94
+ // Skip duplicates.
95
+ if (seenURLs.has(request.args.data.url)) {
96
+ continue;
97
+ }
98
+ // Check if record is not served through the service worker, servicer worker uses http/1.1 as a protocol.
99
+ // These can generate false positives (bug: https://github.com/GoogleChrome/lighthouse/issues/7158).
100
+ if (request.args.data.fromServiceWorker) {
101
+ continue;
102
+ }
103
+ // Test the protocol to see if it was http/1.1.
104
+ const isOldHttp = /HTTP\/[01][.\d]?/i.test(request.args.data.protocol);
105
+ if (!isOldHttp) {
106
+ continue;
107
+ }
108
+ const url = new URL(request.args.data.url);
109
+ // Check if the origin has enough requests to bother flagging.
110
+ const group = groupedByOrigin.get(url.origin) || [];
111
+ if (group.length < 6) {
112
+ continue;
113
+ }
114
+ seenURLs.add(request.args.data.url);
115
+ nonHttp2Resources.push(request);
116
+ }
117
+ return nonHttp2Resources;
118
+ }
119
+ /**
120
+ * Computes the estimated effect of all results being converted to http/2 on the provided graph.
121
+ */
122
+ function computeWasteWithGraph(urlsToChange, graph, simulator) {
123
+ const simulationBefore = simulator.simulate(graph);
124
+ // Update all the protocols to reflect implementing our recommendations
125
+ const originalProtocols = new Map();
126
+ graph.traverse(node => {
127
+ if (node.type !== 'network') {
128
+ return;
129
+ }
130
+ if (!urlsToChange.has(node.request.url)) {
131
+ return;
132
+ }
133
+ originalProtocols.set(node.request.requestId, node.request.protocol);
134
+ node.request.protocol = 'h2';
135
+ });
136
+ const simulationAfter = simulator.simulate(graph);
137
+ // Restore the original protocol after we've done our simulation
138
+ graph.traverse(node => {
139
+ if (node.type !== 'network') {
140
+ return;
141
+ }
142
+ const originalProtocol = originalProtocols.get(node.request.requestId);
143
+ if (originalProtocol === undefined) {
144
+ return;
145
+ }
146
+ node.request.protocol = originalProtocol;
147
+ });
148
+ const savings = simulationBefore.timeInMs - simulationAfter.timeInMs;
149
+ return Platform.NumberUtilities.floor(savings, 1 / 10);
150
+ }
151
+ function computeMetricSavings(nonHttp2Requests, context) {
152
+ if (!context.navigation || !context.lantern) {
153
+ return;
154
+ }
155
+ const urlsToChange = new Set(nonHttp2Requests.map(r => r.args.data.url));
156
+ const fcpGraph = context.lantern.metrics.firstContentfulPaint.optimisticGraph;
157
+ const lcpGraph = context.lantern.metrics.largestContentfulPaint.optimisticGraph;
158
+ return {
159
+ FCP: computeWasteWithGraph(urlsToChange, fcpGraph, context.lantern.simulator),
160
+ LCP: computeWasteWithGraph(urlsToChange, lcpGraph, context.lantern.simulator),
161
+ };
162
+ }
163
+ function finalize(partialModel) {
164
+ return {
165
+ insightKey: "ImageDelivery" /* InsightKeys.IMAGE_DELIVERY */,
166
+ strings: UIStrings,
167
+ title: i18nString(UIStrings.title),
168
+ description: i18nString(UIStrings.description),
169
+ category: InsightCategory.LCP,
170
+ state: partialModel.requests.length > 0 ? 'fail' : 'pass',
171
+ ...partialModel,
172
+ relatedEvents: partialModel.requests,
173
+ };
174
+ }
175
+ export function generateInsight(parsedTrace, context) {
176
+ const isWithinContext = (event) => Helpers.Timing.eventIsInBounds(event, context.bounds);
177
+ const contextRequests = parsedTrace.NetworkRequests.byTime.filter(isWithinContext);
178
+ const entityMappings = parsedTrace.NetworkRequests.entityMappings;
179
+ const firstPartyUrl = context.navigation?.args.data?.documentLoaderURL ?? parsedTrace.Meta.mainFrameURL;
180
+ const firstPartyEntity = Handlers.Helpers.getEntityForUrl(firstPartyUrl, entityMappings.createdEntityCache);
181
+ const nonHttp2Requests = determineNonHttp2Resources(contextRequests, entityMappings, firstPartyEntity ?? null);
182
+ return finalize({
183
+ requests: nonHttp2Requests,
184
+ metricSavings: computeMetricSavings(nonHttp2Requests, context),
185
+ });
186
+ }
187
+ //# sourceMappingURL=ModernHTTP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModernHTTP.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/ModernHTTP.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAIjD,OAAO,EACL,eAAe,GAMhB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,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SD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Platform from '../../../core/platform/platform.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Lantern from '../lantern/lantern.js';\nimport type * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type MetricSavings,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n * @description Title of an insight that recommends using HTTP/2 over HTTP/1.1 because of the performance benefits. \"HTTP\" should not be translated.\n */\n title: 'Modern HTTP',\n /**\n * @description Description of an insight that recommends recommends using HTTP/2 over HTTP/1.1 because of the performance benefits. \"HTTP\" should not be translated.\n */\n description:\n 'HTTP/2 and HTTP/3 offer many benefits over HTTP/1.1, such as multiplexing. [Learn more about using modern HTTP](https://developer.chrome.com/docs/lighthouse/best-practices/uses-http2/).',\n /**\n * @description Column header for a table where each cell represents a network request.\n */\n request: 'Request',\n /**\n * @description Column header for a table where each cell represents the protocol of a network request.\n */\n protocol: 'Protocol',\n /**\n * @description Text explaining that there were not requests that were slowed down by using HTTP/1.1. \"HTTP/1.1\" should not be translated.\n */\n noOldProtocolRequests: 'No requests used HTTP/1.1'\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/ModernHTTP.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport type UseModernHTTPInsightModel = InsightModel<typeof UIStrings, {\n requests: Types.Events.SyntheticNetworkRequest[],\n}>;\n\n/**\n * Determines whether a network request is a \"static resource\" that would benefit from H2 multiplexing.\n * XHRs, tracking pixels, etc generally don't benefit as much because they aren't requested en-masse\n * for the same origin at the exact same time.\n */\nfunction isMultiplexableStaticAsset(\n request: Types.Events.SyntheticNetworkRequest, entityMappings: Handlers.Helpers.EntityMappings,\n firstPartyEntity: Handlers.Helpers.Entity|null): boolean {\n if (!Helpers.Network.STATIC_RESOURCE_TYPES.has(request.args.data.resourceType)) {\n return false;\n }\n\n // Resources from third-parties that are less than 100 bytes are usually tracking pixels, not actual resources.\n // They can masquerade as static types though (gifs, documents, etc)\n if (request.args.data.decodedBodyLength < 100) {\n const entity = entityMappings.entityByEvent.get(request);\n if (entity) {\n // Third-party assets are multiplexable in their first-party context.\n if (firstPartyEntity?.name === entity.name) {\n return true;\n }\n // Skip recognizable third-parties' requests.\n if (!entity.isUnrecognized) {\n return false;\n }\n }\n }\n\n return true;\n}\n\n/**\n * Determine the set of resources that aren't HTTP/2 but should be.\n * We're a little conservative about what we surface for a few reasons:\n *\n * - The simulator approximation of HTTP/2 is a little more generous than reality.\n * - There's a bit of debate surrounding HTTP/2 due to its worse performance in environments with high packet loss. [1][2][3]\n * - It's something that you'd have absolutely zero control over with a third-party (can't defer to fix it for example).\n *\n * Therefore, we only surface requests that were...\n *\n * - Served over HTTP/1.1 or earlier\n * - Served over an origin that serves at least 6 static asset requests\n * (if there aren't more requests than browser's max/host, multiplexing isn't as big a deal)\n * - Not served on localhost (h2 is a pain to deal with locally & and CI)\n *\n * [1] https://news.ycombinator.com/item?id=19086639\n * [2] https://www.twilio.com/blog/2017/10/http2-issues.html\n * [3] https://www.cachefly.com/http-2-is-not-a-magic-bullet/\n */\nexport function determineNonHttp2Resources(\n requests: Types.Events.SyntheticNetworkRequest[], entityMappings: Handlers.Helpers.EntityMappings,\n firstPartyEntity: Handlers.Helpers.Entity|null): Types.Events.SyntheticNetworkRequest[] {\n const nonHttp2Resources: Types.Events.SyntheticNetworkRequest[] = [];\n\n const groupedByOrigin = new Map<string, Types.Events.SyntheticNetworkRequest[]>();\n for (const record of requests) {\n const url = new URL(record.args.data.url);\n if (!isMultiplexableStaticAsset(record, entityMappings, firstPartyEntity)) {\n continue;\n }\n if (Helpers.Network.isSyntheticNetworkRequestLocalhost(record)) {\n continue;\n }\n const originRequests = Platform.MapUtilities.getWithDefault(groupedByOrigin, url.origin, () => []);\n originRequests.push(record);\n }\n\n const seenURLs = new Set<string>();\n\n for (const request of requests) {\n // Skip duplicates.\n if (seenURLs.has(request.args.data.url)) {\n continue;\n }\n\n // Check if record is not served through the service worker, servicer worker uses http/1.1 as a protocol.\n // These can generate false positives (bug: https://github.com/GoogleChrome/lighthouse/issues/7158).\n if (request.args.data.fromServiceWorker) {\n continue;\n }\n\n // Test the protocol to see if it was http/1.1.\n const isOldHttp = /HTTP\\/[01][.\\d]?/i.test(request.args.data.protocol);\n if (!isOldHttp) {\n continue;\n }\n\n const url = new URL(request.args.data.url);\n\n // Check if the origin has enough requests to bother flagging.\n const group = groupedByOrigin.get(url.origin) || [];\n if (group.length < 6) {\n continue;\n }\n\n seenURLs.add(request.args.data.url);\n nonHttp2Resources.push(request);\n }\n\n return nonHttp2Resources;\n}\n\n/**\n * Computes the estimated effect of all results being converted to http/2 on the provided graph.\n */\nfunction computeWasteWithGraph(\n urlsToChange: Set<string>, graph: Lantern.Graph.Node, simulator: Lantern.Simulation.Simulator): Types.Timing.Milli {\n const simulationBefore = simulator.simulate(graph);\n\n // Update all the protocols to reflect implementing our recommendations\n const originalProtocols = new Map();\n graph.traverse(node => {\n if (node.type !== 'network') {\n return;\n }\n if (!urlsToChange.has(node.request.url)) {\n return;\n }\n\n originalProtocols.set(node.request.requestId, node.request.protocol);\n node.request.protocol = 'h2';\n });\n\n const simulationAfter = simulator.simulate(graph);\n\n // Restore the original protocol after we've done our simulation\n graph.traverse(node => {\n if (node.type !== 'network') {\n return;\n }\n const originalProtocol = originalProtocols.get(node.request.requestId);\n if (originalProtocol === undefined) {\n return;\n }\n node.request.protocol = originalProtocol;\n });\n\n const savings = simulationBefore.timeInMs - simulationAfter.timeInMs;\n\n return Platform.NumberUtilities.floor(savings, 1 / 10) as Types.Timing.Milli;\n}\n\nfunction computeMetricSavings(\n nonHttp2Requests: Types.Events.SyntheticNetworkRequest[], context: InsightSetContext): MetricSavings|undefined {\n if (!context.navigation || !context.lantern) {\n return;\n }\n\n const urlsToChange = new Set(nonHttp2Requests.map(r => r.args.data.url));\n\n const fcpGraph = context.lantern.metrics.firstContentfulPaint.optimisticGraph;\n const lcpGraph = context.lantern.metrics.largestContentfulPaint.optimisticGraph;\n\n return {\n FCP: computeWasteWithGraph(urlsToChange, fcpGraph, context.lantern.simulator),\n LCP: computeWasteWithGraph(urlsToChange, lcpGraph, context.lantern.simulator),\n };\n}\n\nfunction finalize(partialModel: PartialInsightModel<UseModernHTTPInsightModel>): UseModernHTTPInsightModel {\n return {\n insightKey: InsightKeys.IMAGE_DELIVERY,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.LCP,\n state: partialModel.requests.length > 0 ? 'fail' : 'pass',\n ...partialModel,\n relatedEvents: partialModel.requests,\n };\n}\n\nexport function generateInsight(\n parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): UseModernHTTPInsightModel {\n const isWithinContext = (event: Types.Events.Event): boolean => Helpers.Timing.eventIsInBounds(event, context.bounds);\n\n const contextRequests = parsedTrace.NetworkRequests.byTime.filter(isWithinContext);\n\n const entityMappings = parsedTrace.NetworkRequests.entityMappings;\n const firstPartyUrl = context.navigation?.args.data?.documentLoaderURL ?? parsedTrace.Meta.mainFrameURL;\n const firstPartyEntity = Handlers.Helpers.getEntityForUrl(firstPartyUrl, entityMappings.createdEntityCache);\n const nonHttp2Requests = determineNonHttp2Resources(contextRequests, entityMappings, firstPartyEntity ?? null);\n\n return finalize({\n requests: nonHttp2Requests,\n metricSavings: computeMetricSavings(nonHttp2Requests, context),\n });\n}\n"]}
@@ -68,7 +68,7 @@ function isCritical(request, context) {
68
68
  }
69
69
  // Requests that have no initiatorRequest are typically ambiguous late-load assets.
70
70
  // Even on the off chance they were important, we don't have any parent to display for them.
71
- const initiatorUrl = request.args.data.initiator?.url || Helpers.Trace.getZeroIndexedStackTraceForEvent(request)?.at(0)?.url;
71
+ const initiatorUrl = request.args.data.initiator?.url || Helpers.Trace.getZeroIndexedStackTraceInEventPayload(request)?.at(0)?.url;
72
72
  if (!initiatorUrl) {
73
73
  return false;
74
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkDependencyTree.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/NetworkDependencyTree.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AAGnD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAEjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EACL,eAAe,GAOhB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,yBAAyB;IAChC;;OAEG;IACH,WAAW,EACP,0QAA0Q;IAC9Q;;OAEG;IACH,kBAAkB,EACd,sLAAsL;IAC1L;;OAEG;IACH,uBAAuB,EAAE,qDAAqD;IAC9E;;;OAGG;IACH,sBAAsB,EAAE,4BAA4B;CAC5C,CAAC;AAEX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,gDAAgD,EAAE,SAAS,CAAC,CAAC;AACtG,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAE7E,8FAA8F;AAC9F,gCAAgC;AAChC,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAgC;;;;;CAKvE,CAAC,CAAC;AAkBH,SAAS,QAAQ,CAAC,YAAoE;IAEpF,OAAO;QACL,UAAU,mEAAqC;QAC/C,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC;QAClC,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC;QAC9C,QAAQ,EAAE,eAAe,CAAC,GAAG;QAC7B,KAA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AO,CAAC,CAAC;YAClE,IAAI,KAAK,EAAE,CAAC;gBACV,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;gBACvB,YAAY,GAAG,KAAK,CAAC,QAAQ,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;YAClE,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;QACd,SAAS;QACT,OAAO;QACP,IAAI;QACJ,aAAa;KACd,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2025 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Protocol from '../../../generated/protocol.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Lantern from '../lantern/lantern.js';\nimport * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type InsightSetContextWithNavigation,\n type PartialInsightModel,\n type RelatedEventsMap,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n * @description Title of an insight that recommends avoiding chaining critical requests.\n */\n title: 'Network dependency tree',\n /**\n * @description Description of an insight that recommends avoiding chaining critical requests.\n */\n description:\n '[Avoid chaining critical requests](https://developer.chrome.com/docs/lighthouse/performance/critical-request-chains) by reducing the length of chains, reducing the download size of resources, or deferring the download of unnecessary resources to improve page load.',\n /**\n * @description Description of the warning that recommends avoiding chaining critical requests.\n */\n warningDescription:\n 'Avoid chaining critical requests by reducing the length of chains, reducing the download size of resources, or deferring the download of unnecessary resources to improve page load.',\n /**\n * @description Text status indicating that there isn't long chaining critical network requests.\n */\n noNetworkDependencyTree: 'No rendering tasks impacted by network dependencies',\n /**\n * @description Text for the maximum critical path latency. This refers to the longest chain of network requests that\n * the browser must download before it can render the page.\n */\n maxCriticalPathLatency: 'Max critical path latency:'\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/NetworkDependencyTree.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\n// XHRs are fetched at High priority, but we exclude them, as they are unlikely to be critical\n// Images are also non-critical.\nconst nonCriticalResourceTypes = new Set<Protocol.Network.ResourceType>([\n Protocol.Network.ResourceType.Image,\n Protocol.Network.ResourceType.XHR,\n Protocol.Network.ResourceType.Fetch,\n Protocol.Network.ResourceType.EventSource,\n]);\n\nexport interface CriticalRequestNode {\n request: Types.Events.SyntheticNetworkRequest;\n timeFromInitialRequest: Types.Timing.Micro;\n children: CriticalRequestNode[];\n isLongest?: boolean;\n // Store all the requests that appear in any chains this request appears in.\n // Use set to avoid duplication.\n relatedRequests: Set<Types.Events.SyntheticNetworkRequest>;\n}\n\nexport type NetworkDependencyTreeInsightModel = InsightModel<typeof UIStrings, {\n rootNodes: CriticalRequestNode[],\n maxTime: Types.Timing.Micro,\n fail: boolean,\n}>;\n\nfunction finalize(partialModel: PartialInsightModel<NetworkDependencyTreeInsightModel>):\n NetworkDependencyTreeInsightModel {\n return {\n insightKey: InsightKeys.NETWORK_DEPENDENCY_TREE,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.LCP,\n state: partialModel.fail ? 'fail' : 'pass',\n ...partialModel,\n };\n}\n\nfunction isCritical(request: Types.Events.SyntheticNetworkRequest, context: InsightSetContextWithNavigation): boolean {\n // The main resource is always critical.\n if (request.args.data.requestId === context.navigationId) {\n return true;\n }\n\n // Treat any preloaded resource as non-critical\n if (request.args.data.isLinkPreload) {\n return false;\n }\n\n // Iframes are considered High Priority but they are not render blocking\n const isIframe = request.args.data.resourceType === Protocol.Network.ResourceType.Document &&\n request.args.data.frame !== context.frameId;\n\n if (nonCriticalResourceTypes.has(request.args.data.resourceType) || isIframe ||\n // Treat any missed images, primarily favicons, as non-critical resources\n request.args.data.mimeType.startsWith('image/')) {\n return false;\n }\n\n // Requests that have no initiatorRequest are typically ambiguous late-load assets.\n // Even on the off chance they were important, we don't have any parent to display for them.\n const initiatorUrl =\n request.args.data.initiator?.url || Helpers.Trace.getZeroIndexedStackTraceForEvent(request)?.at(0)?.url;\n if (!initiatorUrl) {\n return false;\n }\n\n const isBlocking = Helpers.Network.isSyntheticNetworkRequestEventRenderBlocking(request);\n const isHighPriority = Helpers.Network.isSyntheticNetworkRequestHighPriority(request);\n return isHighPriority || isBlocking;\n}\n\nexport function generateInsight(\n _parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): NetworkDependencyTreeInsightModel {\n if (!context.navigation) {\n return finalize({\n rootNodes: [],\n maxTime: Types.Timing.Micro(0),\n fail: false,\n });\n }\n\n const rootNodes: CriticalRequestNode[] = [];\n const relatedEvents: RelatedEventsMap = new Map();\n let maxTime = Types.Timing.Micro(0);\n let fail = false;\n\n let longestChain: Types.Events.SyntheticNetworkRequest[] = [];\n\n function addChain(path: Types.Events.SyntheticNetworkRequest[]): void {\n if (path.length === 0) {\n return;\n }\n if (path.length >= 2) {\n fail = true;\n }\n const initialRequest = path[0];\n const lastRequest = path[path.length - 1];\n const totalChainTime = Types.Timing.Micro(lastRequest.ts + lastRequest.dur - initialRequest.ts);\n if (totalChainTime > maxTime) {\n maxTime = totalChainTime;\n longestChain = path;\n }\n\n let currentNodes = rootNodes;\n\n for (let depth = 0; depth < path.length; ++depth) {\n const request = path[depth];\n // find the request\n let found = currentNodes.find(node => node.request === request);\n\n if (!found) {\n const timeFromInitialRequest = Types.Timing.Micro(request.ts + request.dur - initialRequest.ts);\n found = {\n request,\n timeFromInitialRequest,\n children: [],\n relatedRequests: new Set(),\n };\n currentNodes.push(found);\n }\n\n path.forEach(request => found?.relatedRequests.add(request));\n\n // TODO(b/372897712) Switch the UIString to markdown.\n relatedEvents.set(request, depth < 2 ? [] : [i18nString(UIStrings.warningDescription)]);\n\n currentNodes = found.children;\n }\n }\n // By default `traverse` will discover nodes in BFS-order regardless of dependencies, but\n // here we need traversal in a topological sort order. We'll visit a node only when its\n // dependencies have been met.\n const seenNodes = new Set<Lantern.Graph.Node<Types.Events.SyntheticNetworkRequest>>();\n function getNextNodes(node: Lantern.Graph.Node<Types.Events.SyntheticNetworkRequest>):\n Array<Lantern.Graph.Node<Types.Events.SyntheticNetworkRequest>> {\n return node.getDependents().filter(n => n.getDependencies().every(d => seenNodes.has(d)));\n }\n\n context.lantern?.graph.traverse((node, traversalPath) => {\n seenNodes.add(node);\n if (node.type !== 'network') {\n return;\n }\n const networkNode = node;\n if (!isCritical(networkNode.rawRequest, context)) {\n return;\n }\n\n const networkPath = traversalPath.filter(node => node.type === 'network').reverse().map(node => node.rawRequest);\n\n // Ignore if some ancestor is not a critical request.\n if (networkPath.some(request => (!isCritical(request, context)))) {\n return;\n }\n\n // Ignore non-network things (like data urls).\n if (node.isNonNetworkProtocol) {\n return;\n }\n\n addChain(networkPath);\n }, getNextNodes);\n\n // Mark the longest chain\n if (longestChain.length > 0) {\n let currentNodes = rootNodes;\n for (const request of longestChain) {\n const found = currentNodes.find(node => node.request === request);\n if (found) {\n found.isLongest = true;\n currentNodes = found.children;\n } else {\n console.error('Some request in the longest chain is not found');\n }\n }\n }\n\n return finalize({\n rootNodes,\n maxTime,\n fail,\n relatedEvents,\n });\n}\n"]}
1
+ {"version":3,"file":"NetworkDependencyTree.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/NetworkDependencyTree.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AAGnD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAEjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EACL,eAAe,GAOhB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,yBAAyB;IAChC;;OAE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AI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEjH,qDAAqD;QACrD,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YACjE,OAAO;QACT,CAAC;QAED,8CAA8C;QAC9C,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,QAAQ,CAAC,WAAW,CAAC,CAAC;IACxB,CAAC,EAAE,YAAY,CAAC,CAAC;IAEjB,yBAAyB;IACzB,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,IAAI,YAAY,GAAG,SAAS,CAAC;QAC7B,KAAK,MAAM,OAAO,IAAI,YAAY,EAAE,CAAC;YACnC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;YAClE,IAAI,KAAK,EAAE,CAAC;gBACV,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;gBACvB,YAAY,GAAG,KAAK,CAAC,QAAQ,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;YAClE,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;QACd,SAAS;QACT,OAAO;QACP,IAAI;QACJ,aAAa;KACd,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2025 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Protocol from '../../../generated/protocol.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Lantern from '../lantern/lantern.js';\nimport * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type InsightSetContextWithNavigation,\n type PartialInsightModel,\n type RelatedEventsMap,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n * @description Title of an insight that recommends avoiding chaining critical requests.\n */\n title: 'Network dependency tree',\n /**\n * @description Description of an insight that recommends avoiding chaining critical requests.\n */\n description:\n '[Avoid chaining critical requests](https://developer.chrome.com/docs/lighthouse/performance/critical-request-chains) by reducing the length of chains, reducing the download size of resources, or deferring the download of unnecessary resources to improve page load.',\n /**\n * @description Description of the warning that recommends avoiding chaining critical requests.\n */\n warningDescription:\n 'Avoid chaining critical requests by reducing the length of chains, reducing the download size of resources, or deferring the download of unnecessary resources to improve page load.',\n /**\n * @description Text status indicating that there isn't long chaining critical network requests.\n */\n noNetworkDependencyTree: 'No rendering tasks impacted by network dependencies',\n /**\n * @description Text for the maximum critical path latency. This refers to the longest chain of network requests that\n * the browser must download before it can render the page.\n */\n maxCriticalPathLatency: 'Max critical path latency:'\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/NetworkDependencyTree.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\n// XHRs are fetched at High priority, but we exclude them, as they are unlikely to be critical\n// Images are also non-critical.\nconst nonCriticalResourceTypes = new Set<Protocol.Network.ResourceType>([\n Protocol.Network.ResourceType.Image,\n Protocol.Network.ResourceType.XHR,\n Protocol.Network.ResourceType.Fetch,\n Protocol.Network.ResourceType.EventSource,\n]);\n\nexport interface CriticalRequestNode {\n request: Types.Events.SyntheticNetworkRequest;\n timeFromInitialRequest: Types.Timing.Micro;\n children: CriticalRequestNode[];\n isLongest?: boolean;\n // Store all the requests that appear in any chains this request appears in.\n // Use set to avoid duplication.\n relatedRequests: Set<Types.Events.SyntheticNetworkRequest>;\n}\n\nexport type NetworkDependencyTreeInsightModel = InsightModel<typeof UIStrings, {\n rootNodes: CriticalRequestNode[],\n maxTime: Types.Timing.Micro,\n fail: boolean,\n}>;\n\nfunction finalize(partialModel: PartialInsightModel<NetworkDependencyTreeInsightModel>):\n NetworkDependencyTreeInsightModel {\n return {\n insightKey: InsightKeys.NETWORK_DEPENDENCY_TREE,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.LCP,\n state: partialModel.fail ? 'fail' : 'pass',\n ...partialModel,\n };\n}\n\nfunction isCritical(request: Types.Events.SyntheticNetworkRequest, context: InsightSetContextWithNavigation): boolean {\n // The main resource is always critical.\n if (request.args.data.requestId === context.navigationId) {\n return true;\n }\n\n // Treat any preloaded resource as non-critical\n if (request.args.data.isLinkPreload) {\n return false;\n }\n\n // Iframes are considered High Priority but they are not render blocking\n const isIframe = request.args.data.resourceType === Protocol.Network.ResourceType.Document &&\n request.args.data.frame !== context.frameId;\n\n if (nonCriticalResourceTypes.has(request.args.data.resourceType) || isIframe ||\n // Treat any missed images, primarily favicons, as non-critical resources\n request.args.data.mimeType.startsWith('image/')) {\n return false;\n }\n\n // Requests that have no initiatorRequest are typically ambiguous late-load assets.\n // Even on the off chance they were important, we don't have any parent to display for them.\n const initiatorUrl =\n request.args.data.initiator?.url || Helpers.Trace.getZeroIndexedStackTraceInEventPayload(request)?.at(0)?.url;\n if (!initiatorUrl) {\n return false;\n }\n\n const isBlocking = Helpers.Network.isSyntheticNetworkRequestEventRenderBlocking(request);\n const isHighPriority = Helpers.Network.isSyntheticNetworkRequestHighPriority(request);\n return isHighPriority || isBlocking;\n}\n\nexport function generateInsight(\n _parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): NetworkDependencyTreeInsightModel {\n if (!context.navigation) {\n return finalize({\n rootNodes: [],\n maxTime: Types.Timing.Micro(0),\n fail: false,\n });\n }\n\n const rootNodes: CriticalRequestNode[] = [];\n const relatedEvents: RelatedEventsMap = new Map();\n let maxTime = Types.Timing.Micro(0);\n let fail = false;\n\n let longestChain: Types.Events.SyntheticNetworkRequest[] = [];\n\n function addChain(path: Types.Events.SyntheticNetworkRequest[]): void {\n if (path.length === 0) {\n return;\n }\n if (path.length >= 2) {\n fail = true;\n }\n const initialRequest = path[0];\n const lastRequest = path[path.length - 1];\n const totalChainTime = Types.Timing.Micro(lastRequest.ts + lastRequest.dur - initialRequest.ts);\n if (totalChainTime > maxTime) {\n maxTime = totalChainTime;\n longestChain = path;\n }\n\n let currentNodes = rootNodes;\n\n for (let depth = 0; depth < path.length; ++depth) {\n const request = path[depth];\n // find the request\n let found = currentNodes.find(node => node.request === request);\n\n if (!found) {\n const timeFromInitialRequest = Types.Timing.Micro(request.ts + request.dur - initialRequest.ts);\n found = {\n request,\n timeFromInitialRequest,\n children: [],\n relatedRequests: new Set(),\n };\n currentNodes.push(found);\n }\n\n path.forEach(request => found?.relatedRequests.add(request));\n\n // TODO(b/372897712) Switch the UIString to markdown.\n relatedEvents.set(request, depth < 2 ? [] : [i18nString(UIStrings.warningDescription)]);\n\n currentNodes = found.children;\n }\n }\n // By default `traverse` will discover nodes in BFS-order regardless of dependencies, but\n // here we need traversal in a topological sort order. We'll visit a node only when its\n // dependencies have been met.\n const seenNodes = new Set<Lantern.Graph.Node<Types.Events.SyntheticNetworkRequest>>();\n function getNextNodes(node: Lantern.Graph.Node<Types.Events.SyntheticNetworkRequest>):\n Array<Lantern.Graph.Node<Types.Events.SyntheticNetworkRequest>> {\n return node.getDependents().filter(n => n.getDependencies().every(d => seenNodes.has(d)));\n }\n\n context.lantern?.graph.traverse((node, traversalPath) => {\n seenNodes.add(node);\n if (node.type !== 'network') {\n return;\n }\n const networkNode = node;\n if (!isCritical(networkNode.rawRequest, context)) {\n return;\n }\n\n const networkPath = traversalPath.filter(node => node.type === 'network').reverse().map(node => node.rawRequest);\n\n // Ignore if some ancestor is not a critical request.\n if (networkPath.some(request => (!isCritical(request, context)))) {\n return;\n }\n\n // Ignore non-network things (like data urls).\n if (node.isNonNetworkProtocol) {\n return;\n }\n\n addChain(networkPath);\n }, getNextNodes);\n\n // Mark the longest chain\n if (longestChain.length > 0) {\n let currentNodes = rootNodes;\n for (const request of longestChain) {\n const found = currentNodes.find(node => node.request === request);\n if (found) {\n found.isLongest = true;\n currentNodes = found.children;\n } else {\n console.error('Some request in the longest chain is not found');\n }\n }\n }\n\n return finalize({\n rootNodes,\n maxTime,\n fail,\n relatedEvents,\n });\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  import * as Extras from '../extras/extras.js';
2
2
  import * as Handlers from '../handlers/handlers.js';
3
- import type * as Types from '../types/types.js';
4
3
  import { type InsightModel, type InsightSetContext } from './types.js';
5
4
  export declare const UIStrings: {
6
5
  /** Title of an insight that provides details about the code on a web page that the user doesn't control (referred to as "third-party code"). */
@@ -23,11 +22,8 @@ export declare const UIStrings: {
23
22
  };
24
23
  export declare const i18nString: (id: string, values?: Record<string, string> | undefined) => Record<string, string>;
25
24
  export type ThirdPartiesInsightModel = InsightModel<typeof UIStrings, {
26
- eventsByEntity: Map<Extras.ThirdParties.Entity, Types.Events.Event[]>;
27
- summaryByEntity: Map<Extras.ThirdParties.Entity, Extras.ThirdParties.Summary>;
28
- summaryByUrl: Map<string, Extras.ThirdParties.Summary>;
29
- urlsByEntity: Map<Extras.ThirdParties.Entity, Set<string>>;
30
25
  /** The entity for this navigation's URL. Any other entity is from a third party. */
31
26
  firstPartyEntity?: Extras.ThirdParties.Entity;
27
+ summaries: Extras.ThirdParties.Summary[];
32
28
  }>;
33
29
  export declare function generateInsight(parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): ThirdPartiesInsightModel;
@@ -5,7 +5,6 @@
5
5
  import * as ThirdPartyWeb from '../../../third_party/third-party-web/third-party-web.js';
6
6
  import * as Extras from '../extras/extras.js';
7
7
  import * as Handlers from '../handlers/handlers.js';
8
- import * as Helpers from '../helpers/helpers.js';
9
8
  import { InsightCategory, } from './types.js';
10
9
  export const UIStrings = {
11
10
  /** Title of an insight that provides details about the code on a web page that the user doesn't control (referred to as "third-party code"). */
@@ -31,8 +30,9 @@ export const UIStrings = {
31
30
  export const i18nString = (i18nId, values) => ({i18nId, values}); // i18n.i18n.getLocalizedString.bind(undefined, str_);
32
31
  function getRelatedEvents(summaries, firstPartyEntity) {
33
32
  const relatedEvents = [];
34
- for (const [entity, events] of summaries.eventsByEntity.entries()) {
35
- if (entity !== firstPartyEntity) {
33
+ for (const summary of summaries) {
34
+ if (summary.entity !== firstPartyEntity) {
35
+ const events = summary.relatedEvents ?? [];
36
36
  relatedEvents.push(...events);
37
37
  }
38
38
  }
@@ -45,33 +45,20 @@ function finalize(partialModel) {
45
45
  title: i18nString(UIStrings.title),
46
46
  description: i18nString(UIStrings.description),
47
47
  category: InsightCategory.ALL,
48
- state: [...partialModel.summaryByEntity.entries()].find(kv => kv[0] !== partialModel.firstPartyEntity) ?
49
- 'informative' :
48
+ state: partialModel.summaries.find(summary => summary.entity !== partialModel.firstPartyEntity) ? 'informative' :
50
49
  'pass',
51
50
  ...partialModel,
52
51
  };
53
52
  }
54
53
  export function generateInsight(parsedTrace, context) {
55
- const networkRequests = parsedTrace.NetworkRequests.byTime.filter(event => {
56
- if (!context.navigation) {
57
- return false;
58
- }
59
- if (event.args.data.frame !== context.frameId) {
60
- return false;
61
- }
62
- return Helpers.Timing.eventIsInBounds(event, context.bounds);
63
- });
64
- const thirdPartySummary = Extras.ThirdParties.summarizeThirdParties(parsedTrace, context.bounds, networkRequests);
54
+ const summaries = Extras.ThirdParties.summarizeThirdParties(parsedTrace, context.bounds);
65
55
  const firstPartyUrl = context.navigation?.args.data?.documentLoaderURL ?? parsedTrace.Meta.mainFrameURL;
66
56
  const firstPartyEntity = ThirdPartyWeb.ThirdPartyWeb.getEntity(firstPartyUrl) ||
67
- Handlers.Helpers.makeUpEntity(thirdPartySummary.madeUpEntityCache, firstPartyUrl);
57
+ Handlers.Helpers.makeUpEntity(parsedTrace.Renderer.entityMappings.createdEntityCache, firstPartyUrl);
68
58
  return finalize({
69
- relatedEvents: getRelatedEvents(thirdPartySummary, firstPartyEntity),
70
- eventsByEntity: thirdPartySummary.eventsByEntity,
71
- summaryByEntity: thirdPartySummary.byEntity,
72
- summaryByUrl: thirdPartySummary.byUrl,
73
- urlsByEntity: thirdPartySummary.urlsByEntity,
59
+ relatedEvents: getRelatedEvents(summaries, firstPartyEntity),
74
60
  firstPartyEntity,
61
+ summaries,
75
62
  });
76
63
  }
77
64
  //# sourceMappingURL=ThirdParties.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThirdParties.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/ThirdParties.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,aAAa,MAAM,yDAAyD,CAAC;AACzF,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EACL,eAAe,GAKhB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,gJAAgJ;IAChJ,KAAK,EAAE,aAAa;IACpB;;;OAGG;IACH,WAAW,EAAE,4DAA4D;QACrE,4MAA4M;IAChN,iFAAiF;IACjF,gBAAgB,EAAE,WAAW;IAC7B,4GAA4G;IAC5G,kBAAkB,EAAE,eAAe;IACnC,wJAAwJ;IACxJ,oBAAoB,EAAE,kBAAkB;IACxC;;OAEG;IACH,cAAc,EAAE,wBAAwB;CAChC,CAAC;AAEX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,uCAAuC,EAAE,SAAS,CAAC,CAAC;AAC7F,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,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K,CAAC;QACf,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,MAAM,CAAC,YAAY,CAAC,qBAAqB,CAC/D,WAAyC,EAAE,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAEhF,MAAM,aAAa,GAAG,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,iBAAiB,IAAI,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC;IACxG,MAAM,gBAAgB,GAAG,aAAa,CAAC,aAAa,CAAC,SAAS,CAAC,aAAa,CAAC;QACzE,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;IAEtF,OAAO,QAAQ,CAAC;QACd,aAAa,EAAE,gBAAgB,CAAC,iBAAiB,EAAE,gBAAgB,CAAC;QACpE,cAAc,EAAE,iBAAiB,CAAC,cAAc;QAChD,eAAe,EAAE,iBAAiB,CAAC,QAAQ;QAC3C,YAAY,EAAE,iBAAiB,CAAC,KAAK;QACrC,YAAY,EAAE,iBAAiB,CAAC,YAAY;QAC5C,gBAAgB;KACjB,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as ThirdPartyWeb from '../../../third_party/third-party-web/third-party-web.js';\nimport * as Extras from '../extras/extras.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /** Title of an insight that provides details about the code on a web page that the user doesn't control (referred to as \"third-party code\"). */\n title: '3rd parties',\n /**\n * @description Description of a DevTools insight that identifies the code on the page that the user doesn't control.\n * This is displayed after a user expands the section to see more. No character length limits.\n */\n description: '3rd party code can significantly impact load performance. ' +\n '[Reduce and defer loading of 3rd party code](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript/) to prioritize your page\\'s content.',\n /** Label for a table column that displays the name of a third-party provider. */\n columnThirdParty: '3rd party',\n /** Label for a column in a data table; entries will be the download size of a web resource in kilobytes. */\n columnTransferSize: 'Transfer size',\n /** Label for a table column that displays how much time each row spent running on the main thread, entries will be the number of milliseconds spent. */\n columnMainThreadTime: 'Main thread time',\n /**\n * @description Text block indicating that no third party content was detected on the page\n */\n noThirdParties: 'No third parties found',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/ThirdParties.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport type ThirdPartiesInsightModel = InsightModel<typeof UIStrings, {\n eventsByEntity: Map<Extras.ThirdParties.Entity, Types.Events.Event[]>,\n summaryByEntity: Map<Extras.ThirdParties.Entity, Extras.ThirdParties.Summary>,\n summaryByUrl: Map<string, Extras.ThirdParties.Summary>,\n urlsByEntity: Map<Extras.ThirdParties.Entity, Set<string>>,\n /** The entity for this navigation's URL. Any other entity is from a third party. */\n firstPartyEntity?: Extras.ThirdParties.Entity,\n}>;\n\nfunction getRelatedEvents(\n summaries: Extras.ThirdParties.ThirdPartySummary,\n firstPartyEntity: Extras.ThirdParties.Entity|undefined): Types.Events.Event[] {\n const relatedEvents = [];\n\n for (const [entity, events] of summaries.eventsByEntity.entries()) {\n if (entity !== firstPartyEntity) {\n relatedEvents.push(...events);\n }\n }\n\n return relatedEvents;\n}\n\nfunction finalize(partialModel: PartialInsightModel<ThirdPartiesInsightModel>): ThirdPartiesInsightModel {\n return {\n insightKey: InsightKeys.THIRD_PARTIES,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.ALL,\n state: [...partialModel.summaryByEntity.entries()].find(kv => kv[0] !== partialModel.firstPartyEntity) ?\n 'informative' :\n 'pass',\n ...partialModel,\n };\n}\n\nexport function generateInsight(\n parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): ThirdPartiesInsightModel {\n const networkRequests = parsedTrace.NetworkRequests.byTime.filter(event => {\n if (!context.navigation) {\n return false;\n }\n\n if (event.args.data.frame !== context.frameId) {\n return false;\n }\n\n return Helpers.Timing.eventIsInBounds(event, context.bounds);\n });\n\n const thirdPartySummary = Extras.ThirdParties.summarizeThirdParties(\n parsedTrace as Handlers.Types.ParsedTrace, context.bounds, networkRequests);\n\n const firstPartyUrl = context.navigation?.args.data?.documentLoaderURL ?? parsedTrace.Meta.mainFrameURL;\n const firstPartyEntity = ThirdPartyWeb.ThirdPartyWeb.getEntity(firstPartyUrl) ||\n Handlers.Helpers.makeUpEntity(thirdPartySummary.madeUpEntityCache, firstPartyUrl);\n\n return finalize({\n relatedEvents: getRelatedEvents(thirdPartySummary, firstPartyEntity),\n eventsByEntity: thirdPartySummary.eventsByEntity,\n summaryByEntity: thirdPartySummary.byEntity,\n summaryByUrl: thirdPartySummary.byUrl,\n urlsByEntity: thirdPartySummary.urlsByEntity,\n firstPartyEntity,\n });\n}\n"]}
1
+ {"version":3,"file":"ThirdParties.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/ThirdParties.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,aAAa,MAAM,yDAAyD,CAAC;AACzF,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EACL,eAAe,GAKhB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;I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,aAAa,CAAC,CAAC;YACf,MAAM;QACxG,GAAG,YAAY;KAChB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAC3B,WAAuC,EAAE,OAA0B;IACrE,MAAM,SAAS,GACX,MAAM,CAAC,YAAY,CAAC,qBAAqB,CAAC,WAAyC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzG,MAAM,aAAa,GAAG,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,iBAAiB,IAAI,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC;IACxG,MAAM,gBAAgB,GAAG,aAAa,CAAC,aAAa,CAAC,SAAS,CAAC,aAAa,CAAC;QACzE,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;IAEzG,OAAO,QAAQ,CAAC;QACd,aAAa,EAAE,gBAAgB,CAAC,SAAS,EAAE,gBAAgB,CAAC;QAC5D,gBAAgB;QAChB,SAAS;KACV,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as ThirdPartyWeb from '../../../third_party/third-party-web/third-party-web.js';\nimport * as Extras from '../extras/extras.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport type * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /** Title of an insight that provides details about the code on a web page that the user doesn't control (referred to as \"third-party code\"). */\n title: '3rd parties',\n /**\n * @description Description of a DevTools insight that identifies the code on the page that the user doesn't control.\n * This is displayed after a user expands the section to see more. No character length limits.\n */\n description: '3rd party code can significantly impact load performance. ' +\n '[Reduce and defer loading of 3rd party code](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript/) to prioritize your page\\'s content.',\n /** Label for a table column that displays the name of a third-party provider. */\n columnThirdParty: '3rd party',\n /** Label for a column in a data table; entries will be the download size of a web resource in kilobytes. */\n columnTransferSize: 'Transfer size',\n /** Label for a table column that displays how much time each row spent running on the main thread, entries will be the number of milliseconds spent. */\n columnMainThreadTime: 'Main thread time',\n /**\n * @description Text block indicating that no third party content was detected on the page\n */\n noThirdParties: 'No third parties found',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/ThirdParties.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport type ThirdPartiesInsightModel = InsightModel<typeof UIStrings, {\n /** The entity for this navigation's URL. Any other entity is from a third party. */\n firstPartyEntity?: Extras.ThirdParties.Entity, summaries: Extras.ThirdParties.Summary[],\n}>;\n\nfunction getRelatedEvents(\n summaries: Extras.ThirdParties.Summary[],\n firstPartyEntity: Extras.ThirdParties.Entity|undefined): Types.Events.Event[] {\n const relatedEvents = [];\n for (const summary of summaries) {\n if (summary.entity !== firstPartyEntity) {\n const events = summary.relatedEvents ?? [];\n relatedEvents.push(...events);\n }\n }\n\n return relatedEvents;\n}\n\nfunction finalize(partialModel: PartialInsightModel<ThirdPartiesInsightModel>): ThirdPartiesInsightModel {\n return {\n insightKey: InsightKeys.THIRD_PARTIES,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.ALL,\n state: partialModel.summaries.find(summary => summary.entity !== partialModel.firstPartyEntity) ? 'informative' :\n 'pass',\n ...partialModel,\n };\n}\n\nexport function generateInsight(\n parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): ThirdPartiesInsightModel {\n const summaries =\n Extras.ThirdParties.summarizeThirdParties(parsedTrace as Handlers.Types.ParsedTrace, context.bounds);\n\n const firstPartyUrl = context.navigation?.args.data?.documentLoaderURL ?? parsedTrace.Meta.mainFrameURL;\n const firstPartyEntity = ThirdPartyWeb.ThirdPartyWeb.getEntity(firstPartyUrl) ||\n Handlers.Helpers.makeUpEntity(parsedTrace.Renderer.entityMappings.createdEntityCache, firstPartyUrl);\n\n return finalize({\n relatedEvents: getRelatedEvents(summaries, firstPartyEntity),\n firstPartyEntity,\n summaries,\n });\n}\n"]}
@@ -18,6 +18,7 @@
18
18
  "noImplicitOverride": true,
19
19
  "noImplicitReturns": true,
20
20
  "noUnusedLocals": false,
21
+ "noUnusedParameters": true,
21
22
  "outDir": ".",
22
23
  "rootDir": "../../../../../../../front_end/models/trace/insights",
23
24
  "skipLibCheck": true,
@@ -32,8 +33,7 @@
32
33
  "../../../../../../../front_end/models/trace/insights/insights.ts",
33
34
  "../../../../../../../front_end/legacy/legacy-defs.d.ts",
34
35
  "../../../../../../../front_end/global_typings/global_defs.d.ts",
35
- "../../../../../../../node_modules/@types/filesystem/index.d.ts",
36
- "../../../../../../../node_modules/@types/wicg-task-scheduling/index.d.ts"
36
+ "../../../../../../../node_modules/@types/filesystem/index.d.ts"
37
37
  ],
38
38
  "references": [
39
39
  {
@@ -18,6 +18,7 @@
18
18
  "noImplicitOverride": true,
19
19
  "noImplicitReturns": true,
20
20
  "noUnusedLocals": false,
21
+ "noUnusedParameters": true,
21
22
  "outDir": ".",
22
23
  "rootDir": "../../../../../../../front_end/models/trace/insights",
23
24
  "skipLibCheck": true,
@@ -30,6 +31,7 @@
30
31
  },
31
32
  "files": [
32
33
  "../../../../../../../front_end/models/trace/insights/CLSCulprits.ts",
34
+ "../../../../../../../front_end/models/trace/insights/Cache.ts",
33
35
  "../../../../../../../front_end/models/trace/insights/Common.ts",
34
36
  "../../../../../../../front_end/models/trace/insights/DOMSize.ts",
35
37
  "../../../../../../../front_end/models/trace/insights/DocumentLatency.ts",
@@ -40,21 +42,24 @@
40
42
  "../../../../../../../front_end/models/trace/insights/InteractionToNextPaint.ts",
41
43
  "../../../../../../../front_end/models/trace/insights/LCPDiscovery.ts",
42
44
  "../../../../../../../front_end/models/trace/insights/LCPPhases.ts",
45
+ "../../../../../../../front_end/models/trace/insights/LegacyJavaScript.ts",
43
46
  "../../../../../../../front_end/models/trace/insights/Models.ts",
47
+ "../../../../../../../front_end/models/trace/insights/ModernHTTP.ts",
44
48
  "../../../../../../../front_end/models/trace/insights/NetworkDependencyTree.ts",
45
49
  "../../../../../../../front_end/models/trace/insights/RenderBlocking.ts",
46
50
  "../../../../../../../front_end/models/trace/insights/SlowCSSSelector.ts",
47
51
  "../../../../../../../front_end/models/trace/insights/Statistics.ts",
48
52
  "../../../../../../../front_end/models/trace/insights/ThirdParties.ts",
49
- "../../../../../../../front_end/models/trace/insights/UseCache.ts",
50
53
  "../../../../../../../front_end/models/trace/insights/Viewport.ts",
51
54
  "../../../../../../../front_end/models/trace/insights/types.ts",
52
55
  "../../../../../../../front_end/legacy/legacy-defs.d.ts",
53
56
  "../../../../../../../front_end/global_typings/global_defs.d.ts",
54
- "../../../../../../../node_modules/@types/filesystem/index.d.ts",
55
- "../../../../../../../node_modules/@types/wicg-task-scheduling/index.d.ts"
57
+ "../../../../../../../node_modules/@types/filesystem/index.d.ts"
56
58
  ],
57
59
  "references": [
60
+ {
61
+ "path": "../../../third_party/legacy-javascript/bundle-tsconfig.json"
62
+ },
58
63
  {
59
64
  "path": "../../../third_party/third-party-web/bundle-tsconfig.json"
60
65
  },
@@ -107,6 +107,7 @@ export declare const enum InsightKeys {
107
107
  FORCED_REFLOW = "ForcedReflow",
108
108
  IMAGE_DELIVERY = "ImageDelivery",
109
109
  LCP_DISCOVERY = "LCPDiscovery",
110
+ LEGACY_JAVASCRIPT = "LegacyJavaScript",
110
111
  NETWORK_DEPENDENCY_TREE = "NetworkDependencyTree",
111
112
  RENDER_BLOCKING = "RenderBlocking",
112
113
  SLOW_CSS_SELECTOR = "SlowCSSSelector",
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/types.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAmC7B,MAAM,CAAN,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,iCAAe,CAAA;IACf,mCAAiB,CAAA;IACjB,uEAAuE;IACvE,6DAA2C,CAAA;IAC3C,yCAAuB,CAAA;AACzB,CAAC,EANW,cAAc,KAAd,cAAc,QAMzB;AAYD,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8BAAW,CAAA;IACX,8BAAW,CAAA;IACX,8BAAW,CAAA;AACb,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Common from '../../../core/common/common.js';\nimport type * as Lantern from '../lantern/lantern.js';\nimport type * as Types from '../types/types.js';\n\nimport type * as Models from './Models.js';\n\n/**\n * Context for the portion of the trace an insight should look at.\n */\nexport type InsightSetContext = InsightSetContextWithoutNavigation|InsightSetContextWithNavigation;\n\nexport interface InsightSetContextWithoutNavigation {\n bounds: Types.Timing.TraceWindowMicro;\n frameId: string;\n navigation?: never;\n}\n\nexport interface InsightSetContextWithNavigation {\n bounds: Types.Timing.TraceWindowMicro;\n frameId: string;\n navigation: Types.Events.NavigationStart;\n navigationId: string;\n lantern?: LanternContext;\n}\n\nexport interface LanternContext {\n graph: Lantern.Graph.Node<Types.Events.SyntheticNetworkRequest>;\n simulator: Lantern.Simulation.Simulator<Types.Events.SyntheticNetworkRequest>;\n metrics: Record<string, Lantern.Metrics.MetricResult>;\n}\n\nexport type InsightModelsType = typeof Models;\n\nexport enum InsightWarning {\n NO_FP = 'NO_FP',\n NO_LCP = 'NO_LCP',\n // No network request could be identified as the primary HTML document.\n NO_DOCUMENT_REQUEST = 'NO_DOCUMENT_REQUEST',\n NO_LAYOUT = 'NO_LAYOUT',\n}\n\nexport interface MetricSavings {\n /* eslint-disable @typescript-eslint/naming-convention */\n FCP?: Types.Timing.Milli;\n LCP?: Types.Timing.Milli;\n TBT?: Types.Timing.Milli;\n CLS?: number;\n INP?: Types.Timing.Milli;\n /* eslint-enable @typescript-eslint/naming-convention */\n}\n\nexport enum InsightCategory {\n ALL = 'All',\n INP = 'INP',\n LCP = 'LCP',\n CLS = 'CLS',\n}\n\nexport type RelatedEventsMap = Map<Types.Events.Event, string[]>;\n\nexport type Checklist<Keys extends string> = Record<Keys, {label: Common.UIString.LocalizedString, value: boolean}>;\n\nexport type InsightModel<UIStrings extends Record<string, string> = Record<string, string>,\n ExtraDetail extends Record<string, unknown> = Record<string, unknown>> =\n ExtraDetail&{\n /** Used internally to identify the type of a model, not shown visibly to users **/\n insightKey: keyof InsightModelsType,\n /** Not used within DevTools - this is for external consumers (like Lighthouse). */\n strings: UIStrings,\n title: Common.UIString.LocalizedString,\n description: Common.UIString.LocalizedString,\n category: InsightCategory,\n state: 'pass' | 'fail' | 'informative',\n relatedEvents?: RelatedEventsMap | Types.Events.Event[],\n warnings?: InsightWarning[],\n metricSavings?: MetricSavings,\n frameId?: string,\n /**\n * If this insight is attached to a navigation, this stores its ID.\n */\n navigationId?: string,\n };\n\nexport type PartialInsightModel<T> =\n Omit<T, 'strings'|'title'|'description'|'category'|'state'|'insightKey'|'navigationId'|'frameId'>;\n\n/**\n * Contains insights for a specific navigation. If a trace began after a navigation already started,\n * this could instead represent the duration from the beginning of the trace up to the first recorded\n * navigation (or the end of the trace).\n */\nexport interface InsightSet {\n /** If for a navigation, this is the navigationId. Else it is Trace.Types.Events.NO_NAVIGATION. */\n id: Types.Events.NavigationId;\n /** The URL to show in the accordion list. */\n url: URL;\n frameId: string;\n bounds: Types.Timing.TraceWindowMicro;\n model: InsightModels;\n navigation?: Types.Events.NavigationStart;\n}\n\n/**\n * Contains insights for a specific insight set.\n */\nexport type InsightModels = {\n [I in keyof InsightModelsType]: ReturnType<InsightModelsType[I]['generateInsight']>;\n};\n\n/**\n * Contains insights for the entire trace. Insights are mostly grouped by `navigationId`, with one exception:\n *\n * If the analyzed trace started after the navigation, and has meaningful work with that span, there is no\n * navigation to map it to. In this case `Types.Events.NO_NAVIGATION` is used for the key.\n */\nexport type TraceInsightSets = Map<Types.Events.NavigationId, InsightSet>;\n\nexport const enum InsightKeys {\n LCP_PHASES = 'LCPPhases',\n INTERACTION_TO_NEXT_PAINT = 'InteractionToNextPaint',\n CLS_CULPRITS = 'CLSCulprits',\n THIRD_PARTIES = 'ThirdParties',\n DOCUMENT_LATENCY = 'DocumentLatency',\n DOM_SIZE = 'DOMSize',\n DUPLICATE_JAVASCRIPT = 'DuplicatedJavaScript',\n FONT_DISPLAY = 'FontDisplay',\n FORCED_REFLOW = 'ForcedReflow',\n IMAGE_DELIVERY = 'ImageDelivery',\n LCP_DISCOVERY = 'LCPDiscovery',\n NETWORK_DEPENDENCY_TREE = 'NetworkDependencyTree',\n RENDER_BLOCKING = 'RenderBlocking',\n SLOW_CSS_SELECTOR = 'SlowCSSSelector',\n VIEWPORT = 'Viewport',\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/types.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAmC7B,MAAM,CAAN,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,iCAAe,CAAA;IACf,mCAAiB,CAAA;IACjB,uEAAuE;IACvE,6DAA2C,CAAA;IAC3C,yCAAuB,CAAA;AACzB,CAAC,EANW,cAAc,KAAd,cAAc,QAMzB;AAYD,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8BAAW,CAAA;IACX,8BAAW,CAAA;IACX,8BAAW,CAAA;AACb,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Common from '../../../core/common/common.js';\nimport type * as Lantern from '../lantern/lantern.js';\nimport type * as Types from '../types/types.js';\n\nimport type * as Models from './Models.js';\n\n/**\n * Context for the portion of the trace an insight should look at.\n */\nexport type InsightSetContext = InsightSetContextWithoutNavigation|InsightSetContextWithNavigation;\n\nexport interface InsightSetContextWithoutNavigation {\n bounds: Types.Timing.TraceWindowMicro;\n frameId: string;\n navigation?: never;\n}\n\nexport interface InsightSetContextWithNavigation {\n bounds: Types.Timing.TraceWindowMicro;\n frameId: string;\n navigation: Types.Events.NavigationStart;\n navigationId: string;\n lantern?: LanternContext;\n}\n\nexport interface LanternContext {\n graph: Lantern.Graph.Node<Types.Events.SyntheticNetworkRequest>;\n simulator: Lantern.Simulation.Simulator<Types.Events.SyntheticNetworkRequest>;\n metrics: Record<string, Lantern.Metrics.MetricResult>;\n}\n\nexport type InsightModelsType = typeof Models;\n\nexport enum InsightWarning {\n NO_FP = 'NO_FP',\n NO_LCP = 'NO_LCP',\n // No network request could be identified as the primary HTML document.\n NO_DOCUMENT_REQUEST = 'NO_DOCUMENT_REQUEST',\n NO_LAYOUT = 'NO_LAYOUT',\n}\n\nexport interface MetricSavings {\n /* eslint-disable @typescript-eslint/naming-convention */\n FCP?: Types.Timing.Milli;\n LCP?: Types.Timing.Milli;\n TBT?: Types.Timing.Milli;\n CLS?: number;\n INP?: Types.Timing.Milli;\n /* eslint-enable @typescript-eslint/naming-convention */\n}\n\nexport enum InsightCategory {\n ALL = 'All',\n INP = 'INP',\n LCP = 'LCP',\n CLS = 'CLS',\n}\n\nexport type RelatedEventsMap = Map<Types.Events.Event, string[]>;\n\nexport type Checklist<Keys extends string> = Record<Keys, {label: Common.UIString.LocalizedString, value: boolean}>;\n\nexport type InsightModel<UIStrings extends Record<string, string> = Record<string, string>,\n ExtraDetail extends Record<string, unknown> = Record<string, unknown>> =\n ExtraDetail&{\n /** Used internally to identify the type of a model, not shown visibly to users **/\n insightKey: keyof InsightModelsType,\n /** Not used within DevTools - this is for external consumers (like Lighthouse). */\n strings: UIStrings,\n title: Common.UIString.LocalizedString,\n description: Common.UIString.LocalizedString,\n category: InsightCategory,\n state: 'pass' | 'fail' | 'informative',\n relatedEvents?: RelatedEventsMap | Types.Events.Event[],\n warnings?: InsightWarning[],\n metricSavings?: MetricSavings,\n frameId?: string,\n /**\n * If this insight is attached to a navigation, this stores its ID.\n */\n navigationId?: string,\n };\n\nexport type PartialInsightModel<T> =\n Omit<T, 'strings'|'title'|'description'|'category'|'state'|'insightKey'|'navigationId'|'frameId'>;\n\n/**\n * Contains insights for a specific navigation. If a trace began after a navigation already started,\n * this could instead represent the duration from the beginning of the trace up to the first recorded\n * navigation (or the end of the trace).\n */\nexport interface InsightSet {\n /** If for a navigation, this is the navigationId. Else it is Trace.Types.Events.NO_NAVIGATION. */\n id: Types.Events.NavigationId;\n /** The URL to show in the accordion list. */\n url: URL;\n frameId: string;\n bounds: Types.Timing.TraceWindowMicro;\n model: InsightModels;\n navigation?: Types.Events.NavigationStart;\n}\n\n/**\n * Contains insights for a specific insight set.\n */\nexport type InsightModels = {\n [I in keyof InsightModelsType]: ReturnType<InsightModelsType[I]['generateInsight']>;\n};\n\n/**\n * Contains insights for the entire trace. Insights are mostly grouped by `navigationId`, with one exception:\n *\n * If the analyzed trace started after the navigation, and has meaningful work with that span, there is no\n * navigation to map it to. In this case `Types.Events.NO_NAVIGATION` is used for the key.\n */\nexport type TraceInsightSets = Map<Types.Events.NavigationId, InsightSet>;\n\nexport const enum InsightKeys {\n LCP_PHASES = 'LCPPhases',\n INTERACTION_TO_NEXT_PAINT = 'InteractionToNextPaint',\n CLS_CULPRITS = 'CLSCulprits',\n THIRD_PARTIES = 'ThirdParties',\n DOCUMENT_LATENCY = 'DocumentLatency',\n DOM_SIZE = 'DOMSize',\n DUPLICATE_JAVASCRIPT = 'DuplicatedJavaScript',\n FONT_DISPLAY = 'FontDisplay',\n FORCED_REFLOW = 'ForcedReflow',\n IMAGE_DELIVERY = 'ImageDelivery',\n LCP_DISCOVERY = 'LCPDiscovery',\n LEGACY_JAVASCRIPT = 'LegacyJavaScript',\n NETWORK_DEPENDENCY_TREE = 'NetworkDependencyTree',\n RENDER_BLOCKING = 'RenderBlocking',\n SLOW_CSS_SELECTOR = 'SlowCSSSelector',\n VIEWPORT = 'Viewport',\n}\n"]}
@@ -18,6 +18,7 @@
18
18
  "noImplicitOverride": true,
19
19
  "noImplicitReturns": true,
20
20
  "noUnusedLocals": false,
21
+ "noUnusedParameters": true,
21
22
  "outDir": ".",
22
23
  "rootDir": "../../../../../../../../front_end/models/trace/lantern/core",
23
24
  "skipLibCheck": true,
@@ -33,8 +34,7 @@
33
34
  "../../../../../../../../front_end/models/trace/lantern/core/NetworkAnalyzer.ts",
34
35
  "../../../../../../../../front_end/legacy/legacy-defs.d.ts",
35
36
  "../../../../../../../../front_end/global_typings/global_defs.d.ts",
36
- "../../../../../../../../node_modules/@types/filesystem/index.d.ts",
37
- "../../../../../../../../node_modules/@types/wicg-task-scheduling/index.d.ts"
37
+ "../../../../../../../../node_modules/@types/filesystem/index.d.ts"
38
38
  ],
39
39
  "references": [
40
40
  {
@@ -18,6 +18,7 @@
18
18
  "noImplicitOverride": true,
19
19
  "noImplicitReturns": true,
20
20
  "noUnusedLocals": false,
21
+ "noUnusedParameters": true,
21
22
  "outDir": ".",
22
23
  "rootDir": "../../../../../../../../front_end/models/trace/lantern/core",
23
24
  "skipLibCheck": true,
@@ -32,8 +33,7 @@
32
33
  "../../../../../../../../front_end/models/trace/lantern/core/core.ts",
33
34
  "../../../../../../../../front_end/legacy/legacy-defs.d.ts",
34
35
  "../../../../../../../../front_end/global_typings/global_defs.d.ts",
35
- "../../../../../../../../node_modules/@types/filesystem/index.d.ts",
36
- "../../../../../../../../node_modules/@types/wicg-task-scheduling/index.d.ts"
36
+ "../../../../../../../../node_modules/@types/filesystem/index.d.ts"
37
37
  ],
38
38
  "references": [
39
39
  {
@@ -18,6 +18,7 @@
18
18
  "noImplicitOverride": true,
19
19
  "noImplicitReturns": true,
20
20
  "noUnusedLocals": false,
21
+ "noUnusedParameters": true,
21
22
  "outDir": ".",
22
23
  "rootDir": "../../../../../../../front_end/models/trace/lantern",
23
24
  "skipLibCheck": true,
@@ -32,8 +33,7 @@
32
33
  "../../../../../../../front_end/models/trace/lantern/lantern.ts",
33
34
  "../../../../../../../front_end/legacy/legacy-defs.d.ts",
34
35
  "../../../../../../../front_end/global_typings/global_defs.d.ts",
35
- "../../../../../../../node_modules/@types/filesystem/index.d.ts",
36
- "../../../../../../../node_modules/@types/wicg-task-scheduling/index.d.ts"
36
+ "../../../../../../../node_modules/@types/filesystem/index.d.ts"
37
37
  ],
38
38
  "references": [
39
39
  {
@@ -18,6 +18,7 @@
18
18
  "noImplicitOverride": true,
19
19
  "noImplicitReturns": true,
20
20
  "noUnusedLocals": false,
21
+ "noUnusedParameters": true,
21
22
  "outDir": ".",
22
23
  "rootDir": "../../../../../../../../front_end/models/trace/lantern/graph",
23
24
  "skipLibCheck": true,
@@ -32,8 +33,7 @@
32
33
  "../../../../../../../../front_end/models/trace/lantern/graph/graph.ts",
33
34
  "../../../../../../../../front_end/legacy/legacy-defs.d.ts",
34
35
  "../../../../../../../../front_end/global_typings/global_defs.d.ts",
35
- "../../../../../../../../node_modules/@types/filesystem/index.d.ts",
36
- "../../../../../../../../node_modules/@types/wicg-task-scheduling/index.d.ts"
36
+ "../../../../../../../../node_modules/@types/filesystem/index.d.ts"
37
37
  ],
38
38
  "references": [
39
39
  {