lighthouse 12.8.2-dev.20251004 → 12.8.2-dev.20251006

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 (126) hide show
  1. package/cli/test/smokehouse/config/exclusions.js +0 -2
  2. package/core/audits/audit.js +0 -1
  3. package/core/audits/insights/cls-culprits-insight.js +1 -1
  4. package/core/audits/insights/dom-size-insight.js +6 -6
  5. package/core/audits/redirects.js +1 -0
  6. package/core/audits/server-response-time.d.ts +0 -5
  7. package/core/audits/server-response-time.js +12 -26
  8. package/core/computed/metrics/lcp-breakdown.js +1 -0
  9. package/core/config/default-config.js +20 -63
  10. package/core/config/experimental-config.js +1 -26
  11. package/core/config/filters.js +6 -9
  12. package/core/config/lr-desktop-config.js +0 -1
  13. package/core/config/lr-mobile-config.js +0 -1
  14. package/core/gather/gatherers/trace-elements.js +1 -0
  15. package/core/lib/proto-preprocessor.js +5 -22
  16. package/dist/report/bundle.esm.js +10 -49
  17. package/dist/report/flow.js +12 -51
  18. package/dist/report/standalone.js +11 -50
  19. package/flow-report/src/i18n/i18n.d.ts +4 -6
  20. package/package.json +3 -3
  21. package/report/assets/styles.css +0 -39
  22. package/report/renderer/api.js +0 -1
  23. package/report/renderer/category-renderer.js +6 -0
  24. package/report/renderer/components.js +1 -1
  25. package/report/renderer/dom.d.ts +0 -13
  26. package/report/renderer/dom.js +0 -38
  27. package/report/renderer/performance-category-renderer.d.ts +0 -26
  28. package/report/renderer/performance-category-renderer.js +10 -142
  29. package/report/renderer/report-ui-features.d.ts +0 -1
  30. package/report/renderer/report-ui-features.js +3 -13
  31. package/report/renderer/report-utils.d.ts +2 -3
  32. package/report/renderer/report-utils.js +4 -6
  33. package/report/types/report-renderer.d.ts +0 -6
  34. package/shared/localization/locales/ar-XB.json +0 -330
  35. package/shared/localization/locales/ar.json +0 -330
  36. package/shared/localization/locales/bg.json +0 -330
  37. package/shared/localization/locales/ca.json +0 -330
  38. package/shared/localization/locales/cs.json +0 -330
  39. package/shared/localization/locales/da.json +0 -330
  40. package/shared/localization/locales/de.json +0 -330
  41. package/shared/localization/locales/el.json +0 -330
  42. package/shared/localization/locales/en-GB.json +0 -330
  43. package/shared/localization/locales/en-US.json +26 -275
  44. package/shared/localization/locales/en-XA.json +0 -330
  45. package/shared/localization/locales/en-XL.json +26 -275
  46. package/shared/localization/locales/es-419.json +0 -330
  47. package/shared/localization/locales/es.json +0 -330
  48. package/shared/localization/locales/fi.json +0 -330
  49. package/shared/localization/locales/fil.json +0 -330
  50. package/shared/localization/locales/fr.json +0 -330
  51. package/shared/localization/locales/he.json +0 -330
  52. package/shared/localization/locales/hi.json +0 -330
  53. package/shared/localization/locales/hr.json +0 -330
  54. package/shared/localization/locales/hu.json +0 -330
  55. package/shared/localization/locales/id.json +0 -330
  56. package/shared/localization/locales/it.json +0 -330
  57. package/shared/localization/locales/ja.json +0 -330
  58. package/shared/localization/locales/ko.json +0 -330
  59. package/shared/localization/locales/lt.json +0 -330
  60. package/shared/localization/locales/lv.json +0 -330
  61. package/shared/localization/locales/nl.json +0 -330
  62. package/shared/localization/locales/no.json +0 -330
  63. package/shared/localization/locales/pl.json +0 -330
  64. package/shared/localization/locales/pt-PT.json +0 -330
  65. package/shared/localization/locales/pt.json +0 -330
  66. package/shared/localization/locales/ro.json +0 -330
  67. package/shared/localization/locales/ru.json +0 -330
  68. package/shared/localization/locales/sk.json +0 -330
  69. package/shared/localization/locales/sl.json +0 -330
  70. package/shared/localization/locales/sr-Latn.json +0 -330
  71. package/shared/localization/locales/sr.json +0 -330
  72. package/shared/localization/locales/sv.json +0 -330
  73. package/shared/localization/locales/ta.json +0 -330
  74. package/shared/localization/locales/te.json +0 -330
  75. package/shared/localization/locales/th.json +0 -330
  76. package/shared/localization/locales/tr.json +0 -330
  77. package/shared/localization/locales/uk.json +0 -330
  78. package/shared/localization/locales/vi.json +0 -330
  79. package/shared/localization/locales/zh-HK.json +0 -330
  80. package/shared/localization/locales/zh-TW.json +0 -330
  81. package/shared/localization/locales/zh.json +0 -330
  82. package/types/artifacts.d.ts +1 -0
  83. package/types/audit.d.ts +1 -1
  84. package/types/lhr/settings.d.ts +1 -1
  85. package/core/audits/byte-efficiency/duplicated-javascript.d.ts +0 -45
  86. package/core/audits/byte-efficiency/duplicated-javascript.js +0 -223
  87. package/core/audits/byte-efficiency/efficient-animated-content.d.ts +0 -22
  88. package/core/audits/byte-efficiency/efficient-animated-content.js +0 -93
  89. package/core/audits/byte-efficiency/legacy-javascript.d.ts +0 -28
  90. package/core/audits/byte-efficiency/legacy-javascript.js +0 -144
  91. package/core/audits/byte-efficiency/modern-image-formats.d.ts +0 -38
  92. package/core/audits/byte-efficiency/modern-image-formats.js +0 -187
  93. package/core/audits/byte-efficiency/render-blocking-resources.d.ts +0 -53
  94. package/core/audits/byte-efficiency/render-blocking-resources.js +0 -312
  95. package/core/audits/byte-efficiency/uses-long-cache-ttl.d.ts +0 -59
  96. package/core/audits/byte-efficiency/uses-long-cache-ttl.js +0 -293
  97. package/core/audits/byte-efficiency/uses-optimized-images.d.ts +0 -33
  98. package/core/audits/byte-efficiency/uses-optimized-images.js +0 -146
  99. package/core/audits/byte-efficiency/uses-responsive-images-snapshot.d.ts +0 -16
  100. package/core/audits/byte-efficiency/uses-responsive-images-snapshot.js +0 -106
  101. package/core/audits/byte-efficiency/uses-responsive-images.d.ts +0 -44
  102. package/core/audits/byte-efficiency/uses-responsive-images.js +0 -202
  103. package/core/audits/byte-efficiency/uses-text-compression.d.ts +0 -14
  104. package/core/audits/byte-efficiency/uses-text-compression.js +0 -108
  105. package/core/audits/critical-request-chains.d.ts +0 -44
  106. package/core/audits/critical-request-chains.js +0 -221
  107. package/core/audits/dobetterweb/dom-size.d.ts +0 -32
  108. package/core/audits/dobetterweb/dom-size.js +0 -182
  109. package/core/audits/dobetterweb/uses-http2.d.ts +0 -72
  110. package/core/audits/dobetterweb/uses-http2.js +0 -276
  111. package/core/audits/font-display.d.ts +0 -32
  112. package/core/audits/font-display.js +0 -195
  113. package/core/audits/largest-contentful-paint-element.d.ts +0 -34
  114. package/core/audits/largest-contentful-paint-element.js +0 -181
  115. package/core/audits/lcp-lazy-loaded.d.ts +0 -22
  116. package/core/audits/lcp-lazy-loaded.js +0 -115
  117. package/core/audits/prioritize-lcp-image.d.ts +0 -74
  118. package/core/audits/prioritize-lcp-image.js +0 -297
  119. package/core/audits/third-party-summary.d.ts +0 -78
  120. package/core/audits/third-party-summary.js +0 -236
  121. package/core/audits/uses-rel-preconnect.d.ts +0 -37
  122. package/core/audits/uses-rel-preconnect.js +0 -286
  123. package/core/audits/viewport.d.ts +0 -17
  124. package/core/audits/viewport.js +0 -87
  125. package/core/audits/work-during-interaction.d.ts +0 -81
  126. package/core/audits/work-during-interaction.js +0 -287
@@ -1,286 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2018 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import {Audit} from './audit.js';
8
- import UrlUtils from '../lib/url-utils.js';
9
- import * as i18n from '../lib/i18n/i18n.js';
10
- import {NetworkRecords} from '../computed/network-records.js';
11
- import {MainResource} from '../computed/main-resource.js';
12
- import {LoadSimulator} from '../computed/load-simulator.js';
13
- import {ProcessedNavigation} from '../computed/processed-navigation.js';
14
- import {PageDependencyGraph} from '../computed/page-dependency-graph.js';
15
- import {LanternLargestContentfulPaint} from '../computed/metrics/lantern-largest-contentful-paint.js';
16
- import {LanternFirstContentfulPaint} from '../computed/metrics/lantern-first-contentful-paint.js';
17
-
18
- // Preconnect establishes a "clean" socket. Chrome's socket manager will keep an unused socket
19
- // around for 10s. Meaning, the time delta between processing preconnect a request should be <10s,
20
- // otherwise it's wasted. We add a 5s margin so we are sure to capture all key requests.
21
- // @see https://github.com/GoogleChrome/lighthouse/issues/3106#issuecomment-333653747
22
- const PRECONNECT_SOCKET_MAX_IDLE_IN_MS = 15_000;
23
-
24
- const IGNORE_THRESHOLD_IN_MS = 50;
25
-
26
- const UIStrings = {
27
- /** Imperative title of a Lighthouse audit that tells the user to connect early to internet domains that will be used to load page resources. Origin is the correct term, however 'domain name' could be used if neccsesary. This is displayed in a list of audit titles that Lighthouse generates. */
28
- title: 'Preconnect to required origins',
29
- /** Description of a Lighthouse audit that tells the user how to connect early to third-party domains that will be used to load page resources. This is displayed after a user expands the section to see more. No character length limits. The last sentence starting with 'Learn' becomes link text to additional documentation. */
30
- description:
31
- 'Consider adding `preconnect` or `dns-prefetch` resource hints to establish early ' +
32
- 'connections to important third-party origins. ' +
33
- '[Learn how to preconnect to required origins](https://developer.chrome.com/docs/lighthouse/performance/uses-rel-preconnect/).',
34
- /**
35
- * @description A warning message that is shown when the user tried to follow the advice of the audit, but it's not working as expected.
36
- * @example {https://example.com} securityOrigin
37
- * */
38
- unusedWarning: 'A `<link rel=preconnect>` was found for "{securityOrigin}" but was not used ' +
39
- 'by the browser. Only use `preconnect` for important origins ' +
40
- 'that the page will certainly request.',
41
- /**
42
- * @description A warning message that is shown when the user tried to follow the advice of the audit, but it's not working as expected. Forgetting to set the `crossorigin` HTML attribute, or setting it to an incorrect value, on the link is a common mistake when adding preconnect links.
43
- * @example {https://example.com} securityOrigin
44
- * */
45
- crossoriginWarning: 'A `<link rel=preconnect>` was found for "{securityOrigin}" but was not ' +
46
- 'used by the browser. Check that you are using the `crossorigin` attribute properly.',
47
- /** A warning message that is shown when found more than 2 preconnected links */
48
- tooManyPreconnectLinksWarning: 'More than 2 `<link rel=preconnect>` connections were found. ' +
49
- 'These should be used sparingly and only to the most important origins.',
50
- };
51
-
52
- const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
53
-
54
- class UsesRelPreconnectAudit extends Audit {
55
- /**
56
- * @return {LH.Audit.Meta}
57
- */
58
- static get meta() {
59
- return {
60
- id: 'uses-rel-preconnect',
61
- title: str_(UIStrings.title),
62
- description: str_(UIStrings.description),
63
- supportedModes: ['navigation'],
64
- guidanceLevel: 3,
65
- requiredArtifacts: ['Trace', 'DevtoolsLog', 'URL', 'LinkElements', 'SourceMaps'],
66
- scoreDisplayMode: Audit.SCORING_MODES.METRIC_SAVINGS,
67
- };
68
- }
69
-
70
- /**
71
- * Check if record has valid timing
72
- * @param {LH.Artifacts.NetworkRequest} record
73
- * @return {boolean}
74
- */
75
- static hasValidTiming(record) {
76
- return !!record.timing && record.timing.connectEnd >= 0 && record.timing.connectStart >= 0;
77
- }
78
-
79
- /**
80
- * Check is the connection is already open
81
- * @param {LH.Artifacts.NetworkRequest} record
82
- * @return {boolean}
83
- */
84
- static hasAlreadyConnectedToOrigin(record) {
85
- if (!record.timing) return false;
86
-
87
- // When these values are given as -1, that means the page has
88
- // a connection for this origin and paid these costs already.
89
- if (
90
- record.timing.dnsStart === -1 && record.timing.dnsEnd === -1 &&
91
- record.timing.connectStart === -1 && record.timing.connectEnd === -1
92
- ) {
93
- return true;
94
- }
95
-
96
- // Less understood: if the connection setup took no time at all, consider
97
- // it the same as the above. It is unclear if this is correct, or is even possible.
98
- if (
99
- record.timing.dnsEnd - record.timing.dnsStart === 0 &&
100
- record.timing.connectEnd - record.timing.connectStart === 0
101
- ) {
102
- return true;
103
- }
104
-
105
- return false;
106
- }
107
-
108
- /**
109
- * Check is the connection has started before the socket idle time
110
- * @param {LH.Artifacts.NetworkRequest} record
111
- * @param {LH.Artifacts.NetworkRequest} mainResource
112
- * @return {boolean}
113
- */
114
- static socketStartTimeIsBelowThreshold(record, mainResource) {
115
- const timeSinceMainEnd = Math.max(0, record.networkRequestTime - mainResource.networkEndTime);
116
- return timeSinceMainEnd < PRECONNECT_SOCKET_MAX_IDLE_IN_MS;
117
- }
118
-
119
- /**
120
- * @param {LH.Artifacts} artifacts
121
- * @param {LH.Audit.Context} context
122
- * @return {Promise<LH.Audit.Product>}
123
- */
124
- static async audit(artifacts, context) {
125
- const trace = artifacts.Trace;
126
- const devtoolsLog = artifacts.DevtoolsLog;
127
- const {URL, SourceMaps} = artifacts;
128
- const settings = context.settings;
129
-
130
- let maxWastedLcp = 0;
131
- let maxWastedFcp = 0;
132
- /** @type {Array<LH.IcuMessage>} */
133
- const warnings = [];
134
-
135
- const [networkRecords, mainResource, loadSimulator, processedNavigation, pageGraph] =
136
- await Promise.all([
137
- NetworkRecords.request(devtoolsLog, context),
138
- MainResource.request({devtoolsLog, URL}, context),
139
- LoadSimulator.request({devtoolsLog, settings}, context),
140
- ProcessedNavigation.request(trace, context),
141
- PageDependencyGraph.request(
142
- {settings, trace, devtoolsLog, URL, SourceMaps, fromTrace: false}, context),
143
- ]);
144
-
145
- const {rtt, additionalRttByOrigin} = loadSimulator.getOptions();
146
- const lcpGraph =
147
- LanternLargestContentfulPaint.getPessimisticGraph(pageGraph, processedNavigation);
148
- /** @type {Set<string>} */
149
- const lcpGraphURLs = new Set();
150
- lcpGraph.traverse(node => {
151
- if (node.type === 'network') lcpGraphURLs.add(node.request.url);
152
- });
153
-
154
- const fcpGraph =
155
- LanternFirstContentfulPaint.getPessimisticGraph(pageGraph, processedNavigation);
156
- const fcpGraphURLs = new Set();
157
- fcpGraph.traverse(node => {
158
- if (node.type === 'network') fcpGraphURLs.add(node.request.url);
159
- });
160
-
161
- /** @type {Map<string, LH.Artifacts.NetworkRequest[]>} */
162
- const origins = new Map();
163
- networkRecords
164
- .forEach(record => {
165
- if (
166
- // Filter out all resources where timing info was invalid.
167
- !UsesRelPreconnectAudit.hasValidTiming(record) ||
168
- // Filter out all resources that are loaded by the document. Connections are already early.
169
- record.initiator.url === mainResource.url ||
170
- // Filter out urls that do not have an origin (data, file, etc).
171
- !record.parsedURL || !record.parsedURL.securityOrigin ||
172
- // Filter out all resources that have the same origin. We're already connected.
173
- mainResource.parsedURL.securityOrigin === record.parsedURL.securityOrigin ||
174
- // Filter out anything that wasn't part of LCP. Only recommend important origins.
175
- !lcpGraphURLs.has(record.url) ||
176
- // Filter out all resources where origins are already resolved.
177
- UsesRelPreconnectAudit.hasAlreadyConnectedToOrigin(record) ||
178
- // Make sure the requests are below the PRECONNECT_SOCKET_MAX_IDLE_IN_MS (15s) mark.
179
- !UsesRelPreconnectAudit.socketStartTimeIsBelowThreshold(record, mainResource)
180
- ) {
181
- return;
182
- }
183
-
184
- const securityOrigin = record.parsedURL.securityOrigin;
185
- const records = origins.get(securityOrigin) || [];
186
- records.push(record);
187
- origins.set(securityOrigin, records);
188
- });
189
-
190
- const preconnectLinks = artifacts.LinkElements.filter(el => el.rel === 'preconnect');
191
- const preconnectOrigins =
192
- new Set(preconnectLinks.map(link => UrlUtils.getOrigin(link.href || '')));
193
-
194
- /** @type {Array<{url: string, wastedMs: number}>}*/
195
- let results = [];
196
- origins.forEach(records => {
197
- // Sometimes requests are done simultaneous and the connection has not been made
198
- // chrome will try to connect for each network record, we get the first record
199
- const firstRecordOfOrigin = records.reduce((firstRecord, record) => {
200
- return (record.networkRequestTime < firstRecord.networkRequestTime) ? record : firstRecord;
201
- });
202
-
203
- // Skip the origin if we don't have timing information
204
- if (!firstRecordOfOrigin.timing) return;
205
-
206
- const securityOrigin = firstRecordOfOrigin.parsedURL.securityOrigin;
207
-
208
- // Approximate the connection time with the duration of TCP (+potentially SSL) handshake
209
- // DNS time can be large but can also be 0 if a commonly used origin that's cached, so make
210
- // no assumption about DNS.
211
- const additionalRtt = additionalRttByOrigin.get(securityOrigin) || 0;
212
- let connectionTime = rtt + additionalRtt;
213
- // TCP Handshake will be at least 2 RTTs for TLS connections
214
- if (firstRecordOfOrigin.parsedURL.scheme === 'https') connectionTime = connectionTime * 2;
215
-
216
- const timeBetweenMainResourceAndDnsStart =
217
- firstRecordOfOrigin.networkRequestTime -
218
- mainResource.networkEndTime +
219
- firstRecordOfOrigin.timing.dnsStart;
220
-
221
- const wastedMs = Math.min(connectionTime, timeBetweenMainResourceAndDnsStart);
222
- if (wastedMs < IGNORE_THRESHOLD_IN_MS) return;
223
-
224
- if (preconnectOrigins.has(securityOrigin)) {
225
- // Add a warning for any origin the user tried to preconnect to but failed
226
- warnings.push(str_(UIStrings.crossoriginWarning, {securityOrigin}));
227
- return;
228
- }
229
-
230
- maxWastedLcp = Math.max(wastedMs, maxWastedLcp);
231
-
232
- if (fcpGraphURLs.has(firstRecordOfOrigin.url)) {
233
- maxWastedFcp = Math.max(wastedMs, maxWastedLcp);
234
- }
235
- results.push({
236
- url: securityOrigin,
237
- wastedMs: wastedMs,
238
- });
239
- });
240
-
241
- results = results
242
- .sort((a, b) => b.wastedMs - a.wastedMs);
243
-
244
- // Add warnings for any preconnect origins that aren't being used.
245
- for (const origin of preconnectOrigins) {
246
- if (!origin) continue;
247
- if (networkRecords.some(record => origin === record.parsedURL.securityOrigin)) continue;
248
- warnings.push(str_(UIStrings.unusedWarning, {securityOrigin: origin}));
249
- }
250
-
251
- // Shortcut early with a pass when the user has already configured preconnect.
252
- // https://twitter.com/_tbansal/status/1197771385172480001
253
- if (preconnectLinks.length >= 2) {
254
- return {
255
- score: 1,
256
- warnings: preconnectLinks.length >= 3 ?
257
- [...warnings, str_(UIStrings.tooManyPreconnectLinksWarning)] : warnings,
258
- metricSavings: {LCP: maxWastedLcp, FCP: maxWastedFcp},
259
- };
260
- }
261
-
262
- /** @type {LH.Audit.Details.Opportunity['headings']} */
263
- const headings = [
264
- {key: 'url', valueType: 'url', label: str_(i18n.UIStrings.columnURL)},
265
- {key: 'wastedMs', valueType: 'timespanMs', label: str_(i18n.UIStrings.columnWastedMs)},
266
- ];
267
-
268
- const details = Audit.makeOpportunityDetails(headings, results,
269
- {overallSavingsMs: maxWastedLcp, sortedBy: ['wastedMs']});
270
-
271
- return {
272
- score: results.length ? 0 : 1,
273
- numericValue: maxWastedLcp,
274
- numericUnit: 'millisecond',
275
- displayValue: maxWastedLcp ?
276
- str_(i18n.UIStrings.displayValueMsSavings, {wastedMs: maxWastedLcp}) :
277
- '',
278
- warnings,
279
- details,
280
- metricSavings: {LCP: maxWastedLcp, FCP: maxWastedFcp},
281
- };
282
- }
283
- }
284
-
285
- export default UsesRelPreconnectAudit;
286
- export {UIStrings};
@@ -1,17 +0,0 @@
1
- export default Viewport;
2
- declare class Viewport extends Audit {
3
- /**
4
- * @param {LH.Artifacts} artifacts
5
- * @param {LH.Audit.Context} context
6
- * @return {Promise<LH.Audit.Product>}
7
- */
8
- static audit(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<LH.Audit.Product>;
9
- }
10
- export namespace UIStrings {
11
- let title: string;
12
- let failureTitle: string;
13
- let description: string;
14
- let explanationNoTag: string;
15
- }
16
- import { Audit } from './audit.js';
17
- //# sourceMappingURL=viewport.d.ts.map
@@ -1,87 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2016 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import {Audit} from './audit.js';
8
- import {ViewportMeta} from '../computed/viewport-meta.js';
9
- import * as i18n from '../lib/i18n/i18n.js';
10
-
11
- const UIStrings = {
12
- /** Title of a Lighthouse audit that provides detail on the viewport meta tag in a web page's html. This descriptive title is shown to users when a viewport tag is set and configured. */
13
- title: 'Has a `<meta name="viewport">` tag with `width` or `initial-scale`',
14
- /** Title of a Lighthouse audit that provides detail on the viewport meta tag in a web page's html. This descriptive title is shown to users when a viewport tag is not set or configured. */
15
- failureTitle: 'Does not have a `<meta name="viewport">` tag with `width` ' +
16
- 'or `initial-scale`',
17
- /** Description of a Lighthouse audit that tells the user why they should have a viewport meta tag in their html. This is displayed after a user expands the section to see more. No character length limits. The last sentence starting with 'Learn' becomes link text to additional documentation. */
18
- description: 'A `<meta name="viewport">` not only optimizes your app for mobile screen sizes, ' +
19
- 'but also prevents [a 300 millisecond delay to user input](https://developer.chrome.com/blog/300ms-tap-delay-gone-away/). ' +
20
- '[Learn more about using the viewport meta tag](https://developer.chrome.com/docs/lighthouse/pwa/viewport/).',
21
- /** Explanatory message stating that no viewport meta tag exists on the page. */
22
- explanationNoTag: 'No `<meta name="viewport">` tag found',
23
- };
24
-
25
- const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
26
-
27
- class Viewport extends Audit {
28
- /**
29
- * @return {LH.Audit.Meta}
30
- */
31
- static get meta() {
32
- return {
33
- id: 'viewport',
34
- title: str_(UIStrings.title),
35
- failureTitle: str_(UIStrings.failureTitle),
36
- description: str_(UIStrings.description),
37
- guidanceLevel: 3,
38
- requiredArtifacts: ['MetaElements'],
39
- scoreDisplayMode: Audit.SCORING_MODES.METRIC_SAVINGS,
40
- };
41
- }
42
-
43
- /**
44
- * @param {LH.Artifacts} artifacts
45
- * @param {LH.Audit.Context} context
46
- * @return {Promise<LH.Audit.Product>}
47
- */
48
- static async audit(artifacts, context) {
49
- const viewportMeta = await ViewportMeta.request(artifacts.MetaElements, context);
50
-
51
- let inpSavings = 300;
52
- if (!viewportMeta.hasViewportTag) {
53
- return {
54
- score: 0,
55
- explanation: str_(UIStrings.explanationNoTag),
56
- metricSavings: {
57
- INP: inpSavings,
58
- },
59
- };
60
- }
61
-
62
- if (viewportMeta.isMobileOptimized) {
63
- inpSavings = 0;
64
- }
65
-
66
- /** @type {LH.Audit.Details.DebugData|undefined} */
67
- let details;
68
- if (viewportMeta.rawContentString !== undefined) {
69
- details = {
70
- type: 'debugdata',
71
- viewportContent: viewportMeta.rawContentString,
72
- };
73
- }
74
-
75
- return {
76
- score: Number(viewportMeta.isMobileOptimized),
77
- metricSavings: {
78
- INP: inpSavings,
79
- },
80
- warnings: viewportMeta.parserWarnings,
81
- details,
82
- };
83
- }
84
- }
85
-
86
- export default Viewport;
87
- export {UIStrings};
@@ -1,81 +0,0 @@
1
- export default WorkDuringInteraction;
2
- export type EventTimingEvent = import("../computed/metrics/responsiveness.js").EventTimingEvent;
3
- export type TaskNode = import("../lib/tracehouse/main-thread-tasks.js").TaskNode;
4
- /**
5
- * @fileoverview This metric gives a high-percentile measure of responsiveness to input.
6
- */
7
- declare class WorkDuringInteraction extends Audit {
8
- /**
9
- * @param {TaskNode} task
10
- * @param {TaskNode|undefined} parent
11
- * @param {number} startTs
12
- * @param {number} endTs
13
- * @return {number}
14
- */
15
- static recursivelyClipTasks(task: TaskNode, parent: TaskNode | undefined, startTs: number, endTs: number): number;
16
- /**
17
- * Clip the tasks by the start and end points. Take the easy route and drop
18
- * to duration 0 if out of bounds, since only durations are needed in the
19
- * end (for now).
20
- * Assumes owned tasks, so modifies in place. Can be called multiple times on
21
- * the same `tasks` because always computed from original event timing.
22
- * @param {Array<TaskNode>} tasks
23
- * @param {number} startTs
24
- * @param {number} endTs
25
- */
26
- static clipTasksByTs(tasks: Array<TaskNode>, startTs: number, endTs: number): void;
27
- /**
28
- * @param {EventTimingEvent} interactionEvent
29
- */
30
- static getPhaseTimes(interactionEvent: EventTimingEvent): {
31
- inputDelay: {
32
- startTs: number;
33
- endTs: number;
34
- };
35
- processingDuration: {
36
- startTs: number;
37
- endTs: number;
38
- };
39
- presentationDelay: {
40
- startTs: number;
41
- endTs: number;
42
- };
43
- };
44
- /**
45
- * @param {EventTimingEvent} interactionEvent
46
- * @param {LH.Trace} trace
47
- * @param {LH.Artifacts.ProcessedTrace} processedTrace
48
- * @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
49
- * @return {{table: LH.Audit.Details.Table, phases: Record<string, {startTs: number, endTs: number}>}}
50
- */
51
- static getThreadBreakdownTable(interactionEvent: EventTimingEvent, trace: LH.Trace, processedTrace: LH.Artifacts.ProcessedTrace, networkRecords: Array<LH.Artifacts.NetworkRequest>): {
52
- table: LH.Audit.Details.Table;
53
- phases: Record<string, {
54
- startTs: number;
55
- endTs: number;
56
- }>;
57
- };
58
- /**
59
- * @param {LH.Artifacts['TraceElements']} traceElements
60
- * @return {LH.Audit.Details.Table | undefined}
61
- */
62
- static getTraceElementTable(traceElements: LH.Artifacts["TraceElements"]): LH.Audit.Details.Table | undefined;
63
- /**
64
- * @param {LH.Artifacts} artifacts
65
- * @param {LH.Audit.Context} context
66
- * @return {Promise<LH.Audit.Product>}
67
- */
68
- static audit(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<LH.Audit.Product>;
69
- }
70
- export namespace UIStrings {
71
- let title: string;
72
- let failureTitle: string;
73
- let description: string;
74
- let inputDelay: string;
75
- let processingDuration: string;
76
- let presentationDelay: string;
77
- let displayValue: string;
78
- let eventTarget: string;
79
- }
80
- import { Audit } from './audit.js';
81
- //# sourceMappingURL=work-during-interaction.d.ts.map