lighthouse 10.1.1-dev.20230502 → 10.1.1-dev.20230503

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 (50) hide show
  1. package/core/audits/accessibility/accesskeys.js +1 -1
  2. package/core/audits/accessibility/aria-allowed-attr.js +1 -1
  3. package/core/audits/accessibility/aria-command-name.js +1 -1
  4. package/core/audits/accessibility/aria-hidden-body.js +1 -1
  5. package/core/audits/accessibility/aria-hidden-focus.js +1 -1
  6. package/core/audits/accessibility/aria-input-field-name.js +1 -1
  7. package/core/audits/accessibility/aria-meter-name.js +1 -1
  8. package/core/audits/accessibility/aria-progressbar-name.js +1 -1
  9. package/core/audits/accessibility/aria-required-attr.js +1 -1
  10. package/core/audits/accessibility/aria-required-children.js +1 -1
  11. package/core/audits/accessibility/aria-required-parent.js +1 -1
  12. package/core/audits/accessibility/aria-roles.js +1 -1
  13. package/core/audits/accessibility/aria-toggle-field-name.js +1 -1
  14. package/core/audits/accessibility/aria-tooltip-name.js +1 -1
  15. package/core/audits/accessibility/aria-treeitem-name.js +1 -1
  16. package/core/audits/accessibility/aria-valid-attr-value.js +1 -1
  17. package/core/audits/accessibility/aria-valid-attr.js +1 -1
  18. package/core/audits/accessibility/button-name.js +1 -1
  19. package/core/audits/accessibility/bypass.js +1 -1
  20. package/core/audits/accessibility/color-contrast.js +1 -1
  21. package/core/audits/accessibility/definition-list.js +1 -1
  22. package/core/audits/accessibility/dlitem.js +1 -1
  23. package/core/audits/accessibility/document-title.js +1 -1
  24. package/core/audits/accessibility/duplicate-id-active.js +1 -1
  25. package/core/audits/accessibility/duplicate-id-aria.js +1 -1
  26. package/core/audits/accessibility/form-field-multiple-labels.js +1 -1
  27. package/core/audits/accessibility/frame-title.js +1 -1
  28. package/core/audits/accessibility/heading-order.js +1 -1
  29. package/core/audits/accessibility/html-has-lang.js +1 -1
  30. package/core/audits/accessibility/html-lang-valid.js +1 -1
  31. package/core/audits/accessibility/image-alt.js +1 -1
  32. package/core/audits/accessibility/input-image-alt.js +1 -1
  33. package/core/audits/accessibility/label.js +1 -1
  34. package/core/audits/accessibility/link-name.js +1 -1
  35. package/core/audits/accessibility/list.js +1 -1
  36. package/core/audits/accessibility/listitem.js +1 -1
  37. package/core/audits/accessibility/meta-refresh.js +1 -1
  38. package/core/audits/accessibility/meta-viewport.js +1 -1
  39. package/core/audits/accessibility/object-alt.js +1 -1
  40. package/core/audits/accessibility/tabindex.js +1 -1
  41. package/core/audits/accessibility/td-headers-attr.js +1 -1
  42. package/core/audits/accessibility/th-has-data-cells.js +1 -1
  43. package/core/audits/accessibility/valid-lang.js +1 -1
  44. package/core/audits/accessibility/video-caption.js +1 -1
  45. package/core/audits/largest-contentful-paint-element.d.ts +16 -2
  46. package/core/audits/largest-contentful-paint-element.js +77 -4
  47. package/core/lib/stack-packs.js +9 -1
  48. package/package.json +5 -5
  49. package/shared/localization/locales/en-US.json +92 -44
  50. package/shared/localization/locales/en-XL.json +92 -44
@@ -6,6 +6,8 @@
6
6
 
7
7
  import {Audit} from './audit.js';
8
8
  import * as i18n from '../lib/i18n/i18n.js';
9
+ import {LargestContentfulPaint} from '../computed/metrics/largest-contentful-paint.js';
10
+ import {LCPBreakdown} from '../computed/metrics/lcp-breakdown.js';
9
11
 
10
12
  const UIStrings = {
11
13
  /** Descriptive title of a diagnostic audit that provides the element that was determined to be the Largest Contentful Paint. */
@@ -13,6 +15,20 @@ const UIStrings = {
13
15
  /** Description of a Lighthouse audit that tells the user that the element shown was determined to be the Largest Contentful Paint. */
14
16
  description: 'This is the largest contentful element painted within the viewport. ' +
15
17
  '[Learn more about the Largest Contentful Paint element](https://developer.chrome.com/docs/lighthouse/performance/lighthouse-largest-contentful-paint/)',
18
+ /** Label for a column in a data table; entries will be the name of a phase in the Largest Contentful Paint (LCP) metric. */
19
+ columnPhase: 'Phase',
20
+ /** Label for a column in a data table; entries will be the percent of Largest Contentful Paint (LCP) that a phase covers. */
21
+ columnPercentOfLCP: '% of LCP',
22
+ /** Label for a column in a data table; entries will be the amount of time spent in a phase in the Largest Contentful Paint (LCP) metric. */
23
+ columnTiming: 'Timing',
24
+ /** Table item value for the Time To First Byte (TTFB) phase of the Largest Contentful Paint (LCP) metric. */
25
+ itemTTFB: 'TTFB',
26
+ /** Table item value for the load delay phase of the Largest Contentful Paint (LCP) metric. */
27
+ itemLoadDelay: 'Load Delay',
28
+ /** Table item value for the load time phase of the Largest Contentful Paint (LCP) metric. */
29
+ itemLoadTime: 'Load Time',
30
+ /** Table item value for the render delay phase of the Largest Contentful Paint (LCP) metric. */
31
+ itemRenderDelay: 'Render Delay',
16
32
  };
17
33
 
18
34
  const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
@@ -28,15 +44,64 @@ class LargestContentfulPaintElement extends Audit {
28
44
  description: str_(UIStrings.description),
29
45
  scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE,
30
46
  supportedModes: ['navigation'],
31
- requiredArtifacts: ['traces', 'TraceElements'],
47
+ requiredArtifacts:
48
+ ['traces', 'TraceElements', 'devtoolsLogs', 'GatherContext', 'settings', 'URL'],
32
49
  };
33
50
  }
34
51
 
35
52
  /**
36
53
  * @param {LH.Artifacts} artifacts
37
- * @return {LH.Audit.Product}
54
+ * @param {LH.Audit.Context} context
55
+ * @return {Promise<LH.Audit.Details.Table|undefined>}
38
56
  */
39
- static audit(artifacts) {
57
+ static async makePhaseTable(artifacts, context) {
58
+ const trace = artifacts.traces[Audit.DEFAULT_PASS];
59
+ const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
60
+ const gatherContext = artifacts.GatherContext;
61
+ const metricComputationData = {trace, devtoolsLog, gatherContext,
62
+ settings: context.settings, URL: artifacts.URL};
63
+
64
+ const {timing: metricLcp} =
65
+ await LargestContentfulPaint.request(metricComputationData, context);
66
+ const {ttfb, loadStart, loadEnd} = await LCPBreakdown.request(metricComputationData, context);
67
+
68
+ let loadDelay = 0;
69
+ let loadTime = 0;
70
+ let renderDelay = metricLcp - ttfb;
71
+
72
+ if (loadStart && loadEnd) {
73
+ loadDelay = loadStart - ttfb;
74
+ loadTime = loadEnd - loadStart;
75
+ renderDelay = metricLcp - loadEnd;
76
+ }
77
+
78
+ const results = [
79
+ {phase: str_(UIStrings.itemTTFB), timing: ttfb},
80
+ {phase: str_(UIStrings.itemLoadDelay), timing: loadDelay},
81
+ {phase: str_(UIStrings.itemLoadTime), timing: loadTime},
82
+ {phase: str_(UIStrings.itemRenderDelay), timing: renderDelay},
83
+ ].map(result => {
84
+ const percent = 100 * result.timing / metricLcp;
85
+ const percentStr = `${percent.toFixed(0)}%`;
86
+ return {...result, percent: percentStr};
87
+ });
88
+
89
+ /** @type {LH.Audit.Details.Table['headings']} */
90
+ const headings = [
91
+ {key: 'phase', valueType: 'text', label: str_(UIStrings.columnPhase)},
92
+ {key: 'percent', valueType: 'text', label: str_(UIStrings.columnPercentOfLCP)},
93
+ {key: 'timing', valueType: 'ms', label: str_(UIStrings.columnTiming)},
94
+ ];
95
+
96
+ return Audit.makeTableDetails(headings, results);
97
+ }
98
+
99
+ /**
100
+ * @param {LH.Artifacts} artifacts
101
+ * @param {LH.Audit.Context} context
102
+ * @return {Promise<LH.Audit.Product>}
103
+ */
104
+ static async audit(artifacts, context) {
40
105
  const lcpElement = artifacts.TraceElements
41
106
  .find(element => element.traceEventType === 'largest-contentful-paint');
42
107
  const lcpElementDetails = [];
@@ -51,7 +116,15 @@ class LargestContentfulPaintElement extends Audit {
51
116
  {key: 'node', valueType: 'node', label: str_(i18n.UIStrings.columnElement)},
52
117
  ];
53
118
 
54
- const details = Audit.makeTableDetails(headings, lcpElementDetails);
119
+ const elementTable = Audit.makeTableDetails(headings, lcpElementDetails);
120
+
121
+ const items = [elementTable];
122
+ if (elementTable.items.length) {
123
+ const phaseTable = await this.makePhaseTable(artifacts, context);
124
+ if (phaseTable) items.push(phaseTable);
125
+ }
126
+
127
+ const details = Audit.makeListDetails(items);
55
128
 
56
129
  const displayValue = str_(i18n.UIStrings.displayValueElementsFound,
57
130
  {nodeCount: lcpElementDetails.length});
@@ -15,6 +15,10 @@ import * as i18n from './i18n/i18n.js';
15
15
  * @type {Array<{packId: string, requiredStacks: Array<string>}>}
16
16
  */
17
17
  const stackPacksToInclude = [
18
+ {
19
+ packId: 'gatsby',
20
+ requiredStacks: ['js:gatsby'],
21
+ },
18
22
  {
19
23
  packId: 'wordpress',
20
24
  requiredStacks: ['js:wordpress'],
@@ -117,7 +121,11 @@ function getStackPacks(pageStacks) {
117
121
  });
118
122
  }
119
123
 
120
- return packs;
124
+ return packs.sort((a, b) => {
125
+ const aVal = stackPacksToInclude.findIndex(p => p.packId === a.id);
126
+ const bVal = stackPacksToInclude.findIndex(p => p.packId === b.id);
127
+ return aVal - bVal;
128
+ });
121
129
  }
122
130
 
123
131
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lighthouse",
3
3
  "type": "module",
4
- "version": "10.1.1-dev.20230502",
4
+ "version": "10.1.1-dev.20230503",
5
5
  "description": "Automated auditing, performance metrics, and best practices for the web.",
6
6
  "main": "./core/index.js",
7
7
  "bin": {
@@ -169,7 +169,7 @@
169
169
  "pako": "^2.0.3",
170
170
  "preact": "^10.7.2",
171
171
  "pretty-json-stringify": "^0.0.2",
172
- "puppeteer": "^19.11.0",
172
+ "puppeteer": "^20.1.0",
173
173
  "resolve": "^1.20.0",
174
174
  "rollup": "^2.52.7",
175
175
  "rollup-plugin-node-resolve": "^5.2.0",
@@ -187,7 +187,7 @@
187
187
  },
188
188
  "dependencies": {
189
189
  "@sentry/node": "^6.17.4",
190
- "axe-core": "4.6.3",
190
+ "axe-core": "4.7.0",
191
191
  "chrome-launcher": "^0.15.2",
192
192
  "configstore": "^5.0.1",
193
193
  "csp_evaluator": "1.1.1",
@@ -198,14 +198,14 @@
198
198
  "jpeg-js": "^0.4.4",
199
199
  "js-library-detector": "^6.6.0",
200
200
  "lighthouse-logger": "^1.3.0",
201
- "lighthouse-stack-packs": "1.9.1",
201
+ "lighthouse-stack-packs": "1.10.0",
202
202
  "lodash": "^4.17.21",
203
203
  "lookup-closest-locale": "6.2.0",
204
204
  "metaviewport-parser": "0.3.0",
205
205
  "open": "^8.4.0",
206
206
  "parse-cache-control": "1.0.1",
207
207
  "ps-list": "^8.0.0",
208
- "puppeteer-core": "^19.11.0",
208
+ "puppeteer-core": "^20.1.0",
209
209
  "robots-parser": "^3.0.0",
210
210
  "semver": "^5.3.0",
211
211
  "speedline-core": "^1.4.3",