lighthouse 11.7.0-dev.20240416 → 11.7.0-dev.20240417

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 (94) hide show
  1. package/cli/bin.js +0 -7
  2. package/cli/cli-flags.d.ts +1 -5
  3. package/cli/cli-flags.js +1 -5
  4. package/cli/test/smokehouse/core-tests.js +0 -2
  5. package/core/audits/byte-efficiency/render-blocking-resources.js +3 -1
  6. package/core/audits/byte-efficiency/unminified-css.js +2 -2
  7. package/core/audits/byte-efficiency/unused-css-rules.js +3 -1
  8. package/core/audits/font-display.js +2 -2
  9. package/core/audits/resource-summary.d.ts +2 -0
  10. package/core/audits/resource-summary.js +5 -4
  11. package/core/computed/resource-summary.d.ts +10 -12
  12. package/core/computed/resource-summary.js +12 -19
  13. package/core/computed/unused-css.d.ts +3 -1
  14. package/core/computed/unused-css.js +6 -5
  15. package/core/config/config-helpers.js +0 -4
  16. package/core/config/constants.js +0 -1
  17. package/core/config/default-config.js +1 -14
  18. package/core/gather/gatherers/css-usage.d.ts +0 -21
  19. package/core/gather/gatherers/css-usage.js +9 -119
  20. package/core/gather/gatherers/stylesheets.d.ts +26 -0
  21. package/core/gather/gatherers/stylesheets.js +138 -0
  22. package/core/lib/i18n/i18n.d.ts +0 -1
  23. package/core/lib/i18n/i18n.js +0 -2
  24. package/core/runner.js +0 -1
  25. package/dist/report/bundle.esm.js +2 -19
  26. package/dist/report/flow.js +5 -22
  27. package/dist/report/standalone.js +3 -20
  28. package/package.json +1 -1
  29. package/readme.md +2 -2
  30. package/report/assets/styles.css +0 -17
  31. package/report/renderer/components.js +1 -1
  32. package/report/renderer/dom.d.ts +1 -1
  33. package/report/renderer/dom.js +1 -1
  34. package/report/renderer/performance-category-renderer.js +0 -21
  35. package/shared/localization/locales/ar-XB.json +61 -91
  36. package/shared/localization/locales/ar.json +61 -91
  37. package/shared/localization/locales/bg.json +61 -91
  38. package/shared/localization/locales/ca.json +61 -91
  39. package/shared/localization/locales/cs.json +61 -91
  40. package/shared/localization/locales/da.json +61 -91
  41. package/shared/localization/locales/de.json +61 -91
  42. package/shared/localization/locales/el.json +61 -91
  43. package/shared/localization/locales/en-GB.json +61 -91
  44. package/shared/localization/locales/en-US.json +0 -30
  45. package/shared/localization/locales/en-XA.json +61 -91
  46. package/shared/localization/locales/en-XL.json +0 -30
  47. package/shared/localization/locales/es-419.json +61 -91
  48. package/shared/localization/locales/es.json +61 -91
  49. package/shared/localization/locales/fi.json +61 -91
  50. package/shared/localization/locales/fil.json +60 -90
  51. package/shared/localization/locales/fr.json +61 -91
  52. package/shared/localization/locales/he.json +61 -91
  53. package/shared/localization/locales/hi.json +61 -91
  54. package/shared/localization/locales/hr.json +62 -92
  55. package/shared/localization/locales/hu.json +61 -91
  56. package/shared/localization/locales/id.json +61 -91
  57. package/shared/localization/locales/it.json +61 -91
  58. package/shared/localization/locales/ja.json +61 -91
  59. package/shared/localization/locales/ko.json +61 -91
  60. package/shared/localization/locales/lt.json +61 -91
  61. package/shared/localization/locales/lv.json +61 -91
  62. package/shared/localization/locales/nl.json +61 -91
  63. package/shared/localization/locales/no.json +61 -91
  64. package/shared/localization/locales/pl.json +60 -90
  65. package/shared/localization/locales/pt-PT.json +61 -91
  66. package/shared/localization/locales/pt.json +63 -93
  67. package/shared/localization/locales/ro.json +61 -91
  68. package/shared/localization/locales/ru.json +61 -91
  69. package/shared/localization/locales/sk.json +61 -91
  70. package/shared/localization/locales/sl.json +61 -91
  71. package/shared/localization/locales/sr-Latn.json +61 -91
  72. package/shared/localization/locales/sr.json +61 -91
  73. package/shared/localization/locales/sv.json +61 -91
  74. package/shared/localization/locales/ta.json +60 -90
  75. package/shared/localization/locales/te.json +61 -91
  76. package/shared/localization/locales/th.json +61 -91
  77. package/shared/localization/locales/tr.json +61 -91
  78. package/shared/localization/locales/uk.json +61 -91
  79. package/shared/localization/locales/vi.json +60 -90
  80. package/shared/localization/locales/zh-HK.json +61 -91
  81. package/shared/localization/locales/zh-TW.json +60 -90
  82. package/shared/localization/locales/zh.json +61 -91
  83. package/tsconfig.json +0 -1
  84. package/types/artifacts.d.ts +3 -1
  85. package/types/externs.d.ts +0 -2
  86. package/types/lh.d.ts +0 -2
  87. package/types/lhr/settings.d.ts +0 -4
  88. package/core/audits/performance-budget.d.ts +0 -39
  89. package/core/audits/performance-budget.js +0 -154
  90. package/core/audits/timing-budget.d.ts +0 -43
  91. package/core/audits/timing-budget.js +0 -175
  92. package/core/config/budget.d.ts +0 -74
  93. package/core/config/budget.js +0 -340
  94. package/types/lhr/budget.d.ts +0 -60
@@ -0,0 +1,26 @@
1
+ export default Stylesheets;
2
+ declare class Stylesheets extends BaseGatherer {
3
+ /** @type {LH.Gatherer.ProtocolSession|undefined} */
4
+ _session: LH.Gatherer.ProtocolSession | undefined;
5
+ /** @type {Map<string, Promise<LH.Artifacts.CSSStyleSheetInfo|null>>} */
6
+ _sheetPromises: Map<string, Promise<LH.Artifacts.CSSStyleSheetInfo | null>>;
7
+ /**
8
+ * @param {LH.Crdp.CSS.StyleSheetAddedEvent} event
9
+ */
10
+ _onStylesheetAdded(event: LH.Crdp.CSS.StyleSheetAddedEvent): void;
11
+ /**
12
+ * @param {LH.Gatherer.Context} context
13
+ */
14
+ startInstrumentation(context: LH.Gatherer.Context): Promise<void>;
15
+ /**
16
+ * @param {LH.Gatherer.Context} context
17
+ */
18
+ stopInstrumentation(context: LH.Gatherer.Context): Promise<void>;
19
+ /**
20
+ * @param {LH.Gatherer.Context} context
21
+ * @return {Promise<LH.Artifacts['Stylesheets']>}
22
+ */
23
+ getArtifact(context: LH.Gatherer.Context): Promise<LH.Artifacts['Stylesheets']>;
24
+ }
25
+ import BaseGatherer from '../base-gatherer.js';
26
+ //# sourceMappingURL=stylesheets.d.ts.map
@@ -0,0 +1,138 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /**
8
+ * @fileoverview Collects all stylesheets and their contents.
9
+ */
10
+
11
+ import log from 'lighthouse-logger';
12
+
13
+ import BaseGatherer from '../base-gatherer.js';
14
+ import {Sentry} from '../../lib/sentry.js';
15
+
16
+ class Stylesheets extends BaseGatherer {
17
+ constructor() {
18
+ super();
19
+ /** @type {LH.Gatherer.ProtocolSession|undefined} */
20
+ this._session = undefined;
21
+ /** @type {Map<string, Promise<LH.Artifacts.CSSStyleSheetInfo|null>>} */
22
+ this._sheetPromises = new Map();
23
+ this._onStylesheetAdded = this._onStylesheetAdded.bind(this);
24
+ }
25
+
26
+ /** @type {LH.Gatherer.GathererMeta} */
27
+ meta = {
28
+ supportedModes: ['snapshot', 'timespan', 'navigation'],
29
+ };
30
+
31
+ /**
32
+ * @param {LH.Crdp.CSS.StyleSheetAddedEvent} event
33
+ */
34
+ _onStylesheetAdded(event) {
35
+ if (!this._session) throw new Error('Session not initialized');
36
+ const styleSheetId = event.header.styleSheetId;
37
+ const sheetPromise = this._session.sendCommand('CSS.getStyleSheetText', {styleSheetId})
38
+ .then(content => ({
39
+ header: event.header,
40
+ content: content.text,
41
+ }))
42
+ .catch(err => {
43
+ log.warn(
44
+ 'Stylesheets',
45
+ `Error fetching content of stylesheet with URL "${event.header.sourceURL}"`
46
+ );
47
+ Sentry.captureException(err, {
48
+ tags: {
49
+ gatherer: 'Stylesheets',
50
+ },
51
+ extra: {
52
+ url: event.header.sourceURL,
53
+ },
54
+ level: 'error',
55
+ });
56
+ return null;
57
+ });
58
+ this._sheetPromises.set(styleSheetId, sheetPromise);
59
+ }
60
+
61
+ /**
62
+ * @param {LH.Gatherer.Context} context
63
+ */
64
+ async startInstrumentation(context) {
65
+ const session = context.driver.defaultSession;
66
+ this._session = session;
67
+
68
+ // Calling `CSS.enable` will emit events for stylesheets currently on the page.
69
+ // We want to ignore these events in navigation mode because they are not relevant to the
70
+ // navigation that is about to happen. Adding the event listener *after* calling `CSS.enable`
71
+ // ensures that the events for pre-existing stylesheets are ignored.
72
+ const isNavigation = context.gatherMode === 'navigation';
73
+ if (!isNavigation) {
74
+ session.on('CSS.styleSheetAdded', this._onStylesheetAdded);
75
+ }
76
+
77
+ await session.sendCommand('DOM.enable');
78
+ await session.sendCommand('CSS.enable');
79
+
80
+ if (isNavigation) {
81
+ session.on('CSS.styleSheetAdded', this._onStylesheetAdded);
82
+ }
83
+ }
84
+
85
+
86
+ /**
87
+ * @param {LH.Gatherer.Context} context
88
+ */
89
+ async stopInstrumentation(context) {
90
+ const session = context.driver.defaultSession;
91
+ session.off('CSS.styleSheetAdded', this._onStylesheetAdded);
92
+
93
+ // Ensure we finish fetching all stylesheet contents before disabling the CSS domain
94
+ await Promise.all(this._sheetPromises.values());
95
+
96
+ await session.sendCommand('CSS.disable');
97
+ await session.sendCommand('DOM.disable');
98
+ }
99
+
100
+ /**
101
+ * @param {LH.Gatherer.Context} context
102
+ * @return {Promise<LH.Artifacts['Stylesheets']>}
103
+ */
104
+ async getArtifact(context) {
105
+ const executionContext = context.driver.executionContext;
106
+
107
+ if (context.gatherMode === 'snapshot') {
108
+ await this.startInstrumentation(context);
109
+
110
+ // Force style to recompute.
111
+ // Doesn't appear to be necessary in newer versions of Chrome.
112
+ await executionContext.evaluateAsync('getComputedStyle(document.body)');
113
+
114
+ await this.stopInstrumentation(context);
115
+ }
116
+
117
+ /** @type {Map<string, LH.Artifacts.CSSStyleSheetInfo>} */
118
+ const dedupedStylesheets = new Map();
119
+ const sheets = await Promise.all(this._sheetPromises.values());
120
+
121
+ for (const sheet of sheets) {
122
+ // Erroneous sheets will be reported via sentry and the log.
123
+ // We can ignore them here without throwing a fatal error.
124
+ if (!sheet) continue;
125
+
126
+ // Exclude empty stylesheets.
127
+ if (sheet.header.length === 0) {
128
+ continue;
129
+ }
130
+
131
+ dedupedStylesheets.set(sheet.content, sheet);
132
+ }
133
+
134
+ return Array.from(dedupedStylesheets.values());
135
+ }
136
+ }
137
+
138
+ export default Stylesheets;
@@ -19,7 +19,6 @@ export namespace UIStrings {
19
19
  const columnRequests: string;
20
20
  const columnName: string;
21
21
  const columnSource: string;
22
- const columnOverBudget: string;
23
22
  const columnElement: string;
24
23
  const columnStartTime: string;
25
24
  const columnDuration: string;
@@ -57,8 +57,6 @@ const UIStrings = {
57
57
  columnName: 'Name',
58
58
  /** Label for a column in a data table; entries will be the locations of JavaScript or CSS code, e.g. the name of a Javascript package or module. */
59
59
  columnSource: 'Source',
60
- /** Label for a column in a data table; entries will be how much a predetermined budget has been exeeded by. Depending on the context, this number could represent an excess in quantity or size of network requests, or, an excess in the duration of time that it takes for the page to load.*/
61
- columnOverBudget: 'Over Budget',
62
60
  /** Label for a column in a data table; entries will be a representation of a DOM element. */
63
61
  columnElement: 'Element',
64
62
  /** Label for a column in a data table; entries will be the number of milliseconds since the page started loading. */
package/core/runner.js CHANGED
@@ -298,7 +298,6 @@ class Runner {
298
298
  auditMode: undefined,
299
299
  output: undefined,
300
300
  channel: undefined,
301
- budgets: undefined,
302
301
  };
303
302
  const normalizedGatherSettings = Object.assign({}, artifacts.settings, overrides);
304
303
  const normalizedAuditSettings = Object.assign({}, settings, overrides);