lighthouse 11.7.1 → 12.0.0

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 (272) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/cli/bin.js +0 -7
  3. package/cli/cli-flags.d.ts +1 -5
  4. package/cli/cli-flags.js +4 -8
  5. package/cli/test/smokehouse/__snapshots__/report-assert-test.js.snap +14 -14
  6. package/cli/test/smokehouse/config/exclusions.js +3 -0
  7. package/cli/test/smokehouse/core-tests.js +6 -20
  8. package/cli/test/smokehouse/frontends/smokehouse-bin.js +2 -2
  9. package/core/audits/accessibility/aria-conditional-attr.d.ts +10 -0
  10. package/core/audits/accessibility/aria-conditional-attr.js +43 -0
  11. package/core/audits/accessibility/{duplicate-id-active.d.ts → aria-deprecated-role.d.ts} +3 -3
  12. package/core/audits/accessibility/aria-deprecated-role.js +43 -0
  13. package/core/audits/accessibility/aria-prohibited-attr.d.ts +10 -0
  14. package/core/audits/accessibility/aria-prohibited-attr.js +44 -0
  15. package/core/audits/accessibility/target-size.js +0 -1
  16. package/core/audits/byte-efficiency/byte-efficiency-audit.d.ts +0 -16
  17. package/core/audits/byte-efficiency/byte-efficiency-audit.js +1 -38
  18. package/core/audits/byte-efficiency/offscreen-images.d.ts +0 -11
  19. package/core/audits/byte-efficiency/offscreen-images.js +0 -15
  20. package/core/audits/byte-efficiency/render-blocking-resources.js +27 -26
  21. package/core/audits/byte-efficiency/unminified-css.js +2 -2
  22. package/core/audits/byte-efficiency/unused-css-rules.js +3 -1
  23. package/core/audits/dobetterweb/uses-http2.d.ts +0 -13
  24. package/core/audits/dobetterweb/uses-http2.js +4 -38
  25. package/core/audits/font-display.js +2 -2
  26. package/core/audits/layout-shifts.js +1 -1
  27. package/core/audits/preload-fonts.d.ts +1 -5
  28. package/core/audits/preload-fonts.js +1 -10
  29. package/core/audits/prioritize-lcp-image.js +2 -2
  30. package/core/audits/redirects-http.d.ts +19 -0
  31. package/core/audits/redirects-http.js +75 -0
  32. package/core/audits/resource-summary.d.ts +2 -0
  33. package/core/audits/resource-summary.js +5 -4
  34. package/core/audits/seo/is-crawlable.d.ts +2 -1
  35. package/core/audits/seo/link-text.js +12 -0
  36. package/core/audits/uses-rel-preload.d.ts +1 -5
  37. package/core/audits/uses-rel-preload.js +5 -15
  38. package/core/audits/work-during-interaction.d.ts +2 -2
  39. package/core/audits/work-during-interaction.js +2 -2
  40. package/core/computed/js-bundles.d.ts +1 -1
  41. package/core/computed/metrics/lantern-first-contentful-paint.d.ts +13 -82
  42. package/core/computed/metrics/lantern-first-contentful-paint.js +16 -178
  43. package/core/computed/metrics/lantern-first-meaningful-paint.d.ts +13 -12
  44. package/core/computed/metrics/lantern-first-meaningful-paint.js +11 -49
  45. package/core/computed/metrics/lantern-interactive.d.ts +13 -21
  46. package/core/computed/metrics/lantern-interactive.js +12 -84
  47. package/core/computed/metrics/lantern-largest-contentful-paint.d.ts +13 -25
  48. package/core/computed/metrics/lantern-largest-contentful-paint.js +13 -80
  49. package/core/computed/metrics/lantern-max-potential-fid.d.ts +13 -24
  50. package/core/computed/metrics/lantern-max-potential-fid.js +12 -64
  51. package/core/computed/metrics/lantern-metric.d.ts +14 -18
  52. package/core/computed/metrics/lantern-metric.js +34 -30
  53. package/core/computed/metrics/lantern-speed-index.d.ts +13 -32
  54. package/core/computed/metrics/lantern-speed-index.js +13 -116
  55. package/core/computed/metrics/lantern-total-blocking-time.d.ts +13 -25
  56. package/core/computed/metrics/lantern-total-blocking-time.js +10 -94
  57. package/core/computed/metrics/metric.js +1 -3
  58. package/core/computed/module-duplication.d.ts +1 -1
  59. package/core/computed/navigation-insights.d.ts +36 -0
  60. package/core/computed/navigation-insights.js +35 -0
  61. package/core/computed/page-dependency-graph.js +3 -7
  62. package/core/computed/resource-summary.d.ts +10 -12
  63. package/core/computed/resource-summary.js +12 -19
  64. package/core/computed/trace-engine-result.d.ts +16 -3
  65. package/core/computed/trace-engine-result.js +19 -14
  66. package/core/computed/unused-css.d.ts +3 -1
  67. package/core/computed/unused-css.js +6 -5
  68. package/core/config/config-helpers.js +0 -4
  69. package/core/config/constants.js +0 -1
  70. package/core/config/default-config.js +63 -142
  71. package/core/config/experimental-config.js +11 -0
  72. package/core/config/filters.js +0 -1
  73. package/core/gather/driver/navigation.js +4 -1
  74. package/core/gather/driver/prepare.js +1 -1
  75. package/core/gather/driver/target-manager.js +4 -3
  76. package/core/gather/driver/wait-for-condition.js +2 -3
  77. package/core/gather/driver.d.ts +12 -0
  78. package/core/gather/driver.js +27 -0
  79. package/core/gather/gatherers/accessibility.js +4 -6
  80. package/core/gather/gatherers/css-usage.d.ts +0 -21
  81. package/core/gather/gatherers/css-usage.js +9 -119
  82. package/core/gather/gatherers/root-causes.d.ts +2 -2
  83. package/core/gather/gatherers/root-causes.js +6 -5
  84. package/core/gather/gatherers/stylesheets.d.ts +26 -0
  85. package/core/gather/gatherers/stylesheets.js +138 -0
  86. package/core/gather/gatherers/trace-elements.d.ts +2 -12
  87. package/core/gather/gatherers/trace-elements.js +2 -21
  88. package/core/gather/navigation-runner.js +3 -1
  89. package/core/gather/session.d.ts +8 -0
  90. package/core/gather/session.js +14 -1
  91. package/core/lib/emulation.js +2 -2
  92. package/core/lib/i18n/i18n.d.ts +0 -1
  93. package/core/lib/i18n/i18n.js +0 -2
  94. package/core/lib/lantern/cpu-node.d.ts +7 -1
  95. package/core/lib/lantern/cpu-node.js +12 -2
  96. package/core/lib/lantern/lantern-error.d.ts +8 -0
  97. package/core/lib/lantern/lantern-error.js +9 -0
  98. package/core/lib/lantern/metric.js +2 -6
  99. package/core/lib/lantern/metrics/first-contentful-paint.d.ts +79 -0
  100. package/core/lib/lantern/metrics/first-contentful-paint.js +200 -0
  101. package/core/lib/lantern/metrics/first-meaningful-paint.d.ts +6 -0
  102. package/core/lib/lantern/metrics/first-meaningful-paint.js +64 -0
  103. package/core/lib/lantern/metrics/interactive.d.ts +26 -0
  104. package/core/lib/lantern/metrics/interactive.js +112 -0
  105. package/core/lib/lantern/metrics/largest-contentful-paint.d.ts +19 -0
  106. package/core/lib/lantern/metrics/largest-contentful-paint.js +108 -0
  107. package/core/lib/lantern/metrics/max-potential-fid.d.ts +30 -0
  108. package/core/lib/lantern/metrics/max-potential-fid.js +92 -0
  109. package/core/lib/lantern/metrics/speed-index.d.ts +38 -0
  110. package/core/lib/lantern/metrics/speed-index.js +144 -0
  111. package/core/lib/lantern/metrics/total-blocking-time.d.ts +31 -0
  112. package/core/lib/lantern/metrics/total-blocking-time.js +128 -0
  113. package/core/lib/lantern/network-node.js +28 -4
  114. package/core/lib/lantern/page-dependency-graph.d.ts +4 -4
  115. package/core/lib/lantern/page-dependency-graph.js +19 -7
  116. package/core/lib/lantern/simulator/connection-pool.d.ts +2 -12
  117. package/core/lib/lantern/simulator/connection-pool.js +3 -22
  118. package/core/lib/lantern/simulator/network-analyzer.js +1 -12
  119. package/core/lib/lantern/simulator/simulator.d.ts +2 -4
  120. package/core/lib/lantern/simulator/simulator.js +7 -14
  121. package/core/lib/lantern/types/lantern.d.ts +5 -3
  122. package/core/lib/lantern-trace-saver.js +0 -1
  123. package/core/lib/lh-error.d.ts +9 -0
  124. package/core/lib/lh-error.js +13 -3
  125. package/core/lib/lighthouse-compatibility.js +53 -10
  126. package/core/lib/navigation-error.js +3 -0
  127. package/core/lib/network-request.d.ts +1 -0
  128. package/core/lib/network-request.js +28 -0
  129. package/core/runner.js +18 -25
  130. package/dist/report/bundle.esm.js +11 -112
  131. package/dist/report/flow.js +16 -117
  132. package/dist/report/standalone.js +12 -113
  133. package/flow-report/src/help-dialog.tsx +0 -1
  134. package/flow-report/src/i18n/i18n.d.ts +0 -4
  135. package/flow-report/src/i18n/ui-strings.d.ts +0 -1
  136. package/flow-report/src/i18n/ui-strings.js +0 -2
  137. package/flow-report/src/summary/category.tsx +10 -12
  138. package/package.json +5 -5
  139. package/readme.md +4 -4
  140. package/report/assets/styles.css +1 -60
  141. package/report/assets/templates.html +0 -95
  142. package/report/renderer/category-renderer.js +1 -1
  143. package/report/renderer/components.d.ts +2 -2
  144. package/report/renderer/components.js +2 -103
  145. package/report/renderer/dom.d.ts +1 -1
  146. package/report/renderer/dom.js +1 -1
  147. package/report/renderer/performance-category-renderer.d.ts +0 -7
  148. package/report/renderer/performance-category-renderer.js +1 -32
  149. package/report/renderer/report-renderer.js +3 -13
  150. package/report/renderer/report-ui-features.js +1 -1
  151. package/report/renderer/report-utils.d.ts +0 -1
  152. package/report/renderer/report-utils.js +13 -13
  153. package/shared/localization/locales/ar-XB.json +62 -329
  154. package/shared/localization/locales/ar.json +62 -329
  155. package/shared/localization/locales/bg.json +62 -329
  156. package/shared/localization/locales/ca.json +62 -329
  157. package/shared/localization/locales/cs.json +62 -329
  158. package/shared/localization/locales/da.json +62 -329
  159. package/shared/localization/locales/de.json +62 -329
  160. package/shared/localization/locales/el.json +62 -329
  161. package/shared/localization/locales/en-GB.json +62 -329
  162. package/shared/localization/locales/en-US.json +41 -272
  163. package/shared/localization/locales/en-XA.json +62 -329
  164. package/shared/localization/locales/en-XL.json +41 -272
  165. package/shared/localization/locales/es-419.json +62 -329
  166. package/shared/localization/locales/es.json +62 -329
  167. package/shared/localization/locales/fi.json +62 -329
  168. package/shared/localization/locales/fil.json +61 -328
  169. package/shared/localization/locales/fr.json +62 -329
  170. package/shared/localization/locales/he.json +62 -329
  171. package/shared/localization/locales/hi.json +62 -329
  172. package/shared/localization/locales/hr.json +63 -330
  173. package/shared/localization/locales/hu.json +62 -329
  174. package/shared/localization/locales/id.json +62 -329
  175. package/shared/localization/locales/it.json +62 -329
  176. package/shared/localization/locales/ja.json +62 -329
  177. package/shared/localization/locales/ko.json +62 -329
  178. package/shared/localization/locales/lt.json +62 -329
  179. package/shared/localization/locales/lv.json +62 -329
  180. package/shared/localization/locales/nl.json +62 -329
  181. package/shared/localization/locales/no.json +62 -329
  182. package/shared/localization/locales/pl.json +61 -328
  183. package/shared/localization/locales/pt-PT.json +62 -329
  184. package/shared/localization/locales/pt.json +64 -331
  185. package/shared/localization/locales/ro.json +62 -329
  186. package/shared/localization/locales/ru.json +62 -329
  187. package/shared/localization/locales/sk.json +62 -329
  188. package/shared/localization/locales/sl.json +62 -329
  189. package/shared/localization/locales/sr-Latn.json +62 -329
  190. package/shared/localization/locales/sr.json +62 -329
  191. package/shared/localization/locales/sv.json +62 -329
  192. package/shared/localization/locales/ta.json +61 -328
  193. package/shared/localization/locales/te.json +62 -329
  194. package/shared/localization/locales/th.json +62 -329
  195. package/shared/localization/locales/tr.json +62 -329
  196. package/shared/localization/locales/uk.json +62 -329
  197. package/shared/localization/locales/vi.json +61 -328
  198. package/shared/localization/locales/zh-HK.json +62 -329
  199. package/shared/localization/locales/zh-TW.json +61 -328
  200. package/shared/localization/locales/zh.json +62 -329
  201. package/tsconfig.json +1 -3
  202. package/types/artifacts.d.ts +21 -110
  203. package/types/audit.d.ts +0 -10
  204. package/types/config.d.ts +0 -1
  205. package/types/externs.d.ts +0 -2
  206. package/types/gatherer.d.ts +3 -0
  207. package/types/internal/smokehouse.d.ts +1 -1
  208. package/types/lh.d.ts +0 -2
  209. package/types/lhr/audit-details.d.ts +9 -4
  210. package/types/lhr/lhr.d.ts +0 -4
  211. package/types/lhr/settings.d.ts +0 -4
  212. package/core/audits/accessibility/duplicate-id-active.js +0 -42
  213. package/core/audits/content-width.d.ts +0 -17
  214. package/core/audits/content-width.js +0 -76
  215. package/core/audits/installable-manifest.d.ts +0 -111
  216. package/core/audits/installable-manifest.js +0 -248
  217. package/core/audits/layout-shift-elements.d.ts +0 -16
  218. package/core/audits/layout-shift-elements.js +0 -101
  219. package/core/audits/manual/pwa-cross-browser.d.ts +0 -12
  220. package/core/audits/manual/pwa-cross-browser.js +0 -40
  221. package/core/audits/manual/pwa-each-page-has-url.d.ts +0 -12
  222. package/core/audits/manual/pwa-each-page-has-url.js +0 -38
  223. package/core/audits/manual/pwa-page-transitions.d.ts +0 -12
  224. package/core/audits/manual/pwa-page-transitions.js +0 -38
  225. package/core/audits/maskable-icon.d.ts +0 -25
  226. package/core/audits/maskable-icon.js +0 -70
  227. package/core/audits/multi-check-audit.d.ts +0 -28
  228. package/core/audits/multi-check-audit.js +0 -82
  229. package/core/audits/no-unload-listeners.d.ts +0 -16
  230. package/core/audits/no-unload-listeners.js +0 -86
  231. package/core/audits/performance-budget.d.ts +0 -39
  232. package/core/audits/performance-budget.js +0 -154
  233. package/core/audits/script-elements-test-audit.d.ts +0 -14
  234. package/core/audits/script-elements-test-audit.js +0 -29
  235. package/core/audits/seo/plugins.d.ts +0 -15
  236. package/core/audits/seo/plugins.js +0 -150
  237. package/core/audits/seo/tap-targets.d.ts +0 -50
  238. package/core/audits/seo/tap-targets.js +0 -352
  239. package/core/audits/splash-screen.d.ts +0 -37
  240. package/core/audits/splash-screen.js +0 -98
  241. package/core/audits/themed-omnibox.d.ts +0 -42
  242. package/core/audits/themed-omnibox.js +0 -102
  243. package/core/audits/timing-budget.d.ts +0 -43
  244. package/core/audits/timing-budget.js +0 -175
  245. package/core/computed/manifest-values.d.ts +0 -24
  246. package/core/computed/manifest-values.js +0 -136
  247. package/core/config/budget.d.ts +0 -74
  248. package/core/config/budget.js +0 -340
  249. package/core/config/metrics-to-audits.d.ts +0 -19
  250. package/core/config/metrics-to-audits.js +0 -62
  251. package/core/gather/driver/service-workers.d.ts +0 -16
  252. package/core/gather/driver/service-workers.js +0 -52
  253. package/core/gather/gatherers/dobetterweb/tags-blocking-first-paint.d.ts +0 -47
  254. package/core/gather/gatherers/dobetterweb/tags-blocking-first-paint.js +0 -233
  255. package/core/gather/gatherers/global-listeners.d.ts +0 -27
  256. package/core/gather/gatherers/global-listeners.js +0 -108
  257. package/core/gather/gatherers/installability-errors.d.ts +0 -17
  258. package/core/gather/gatherers/installability-errors.js +0 -56
  259. package/core/gather/gatherers/script-elements.d.ts +0 -21
  260. package/core/gather/gatherers/script-elements.js +0 -100
  261. package/core/gather/gatherers/seo/embedded-content.d.ts +0 -10
  262. package/core/gather/gatherers/seo/embedded-content.js +0 -63
  263. package/core/gather/gatherers/seo/tap-targets.d.ts +0 -21
  264. package/core/gather/gatherers/seo/tap-targets.js +0 -389
  265. package/core/gather/gatherers/service-worker.d.ts +0 -10
  266. package/core/gather/gatherers/service-worker.js +0 -32
  267. package/core/gather/gatherers/web-app-manifest.d.ts +0 -32
  268. package/core/gather/gatherers/web-app-manifest.js +0 -106
  269. package/report/renderer/pwa-category-renderer.d.ts +0 -55
  270. package/report/renderer/pwa-category-renderer.js +0 -184
  271. package/third-party/chromium-synchronization/installability-errors-test.js +0 -79
  272. package/types/lhr/budget.d.ts +0 -60
@@ -1,70 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2020 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import {Audit} from './audit.js';
8
- import {ManifestValues} from '../computed/manifest-values.js';
9
- import * as i18n from '../lib/i18n/i18n.js';
10
-
11
- const UIStrings = {
12
- /** Title of a Lighthouse audit that provides detail on if the manifest contains a maskable icon. This descriptive title is shown to users when the manifest contains at least one maskable icon. */
13
- title: 'Manifest has a maskable icon',
14
- /** Title of a Lighthouse audit that provides detial on if the manifest contains a maskable icon. this descriptive title is shown to users when the manifest contains no icons that are maskable. */
15
- failureTitle: 'Manifest doesn\'t have a maskable icon',
16
- /** Description of a Lighthouse audit that tells the user why they their manifest should have at least one maskable icon. 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. */
17
- description: 'A maskable icon ensures that the image fills the entire ' +
18
- 'shape without being letterboxed when installing ' +
19
- 'the app on a device. [Learn about maskable manifest icons](https://developer.chrome.com/docs/lighthouse/pwa/maskable-icon-audit/).',
20
- };
21
-
22
- const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
23
-
24
- /**
25
- * @fileoverview
26
- * Audits if a manifest contains at least one icon that is maskable
27
- *
28
- * Requirements:
29
- * * manifest is not empty
30
- * * manifest has valid icons
31
- * * at least one of the icons has a purpose of 'maskable'
32
- */
33
-
34
- class MaskableIcon extends Audit {
35
- /**
36
- * @return {LH.Audit.Meta}
37
- */
38
- static get meta() {
39
- return {
40
- id: 'maskable-icon',
41
- title: str_(UIStrings.title),
42
- failureTitle: str_(UIStrings.failureTitle),
43
- description: str_(UIStrings.description),
44
- supportedModes: ['navigation'],
45
- requiredArtifacts: ['WebAppManifest', 'InstallabilityErrors'],
46
- };
47
- }
48
-
49
- /**
50
- * @param {LH.Artifacts} artifacts
51
- * @param {LH.Audit.Context} context
52
- * @return {Promise<LH.Audit.Product>}
53
- */
54
- static async audit(artifacts, context) {
55
- const manifestValues = await ManifestValues.request(artifacts, context);
56
- if (manifestValues.isParseFailure) {
57
- return {
58
- score: 0,
59
- explanation: manifestValues.parseFailureReason,
60
- };
61
- }
62
- const maskableIconCheck = manifestValues.allChecks.find(i => i.id === 'hasMaskableIcon');
63
- return {
64
- score: maskableIconCheck?.passing ? 1 : 0,
65
- };
66
- }
67
- }
68
-
69
- export default MaskableIcon;
70
- export {UIStrings};
@@ -1,28 +0,0 @@
1
- export default MultiCheckAudit;
2
- declare class MultiCheckAudit 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
- * @param {{failures: Array<string>, manifestValues?: LH.Artifacts.ManifestValues}} result
11
- * @return {LH.Audit.Product}
12
- */
13
- static createAuditProduct(result: {
14
- failures: Array<string>;
15
- manifestValues?: LH.Artifacts.ManifestValues;
16
- }): LH.Audit.Product;
17
- /**
18
- * @param {LH.Artifacts} artifacts
19
- * @param {LH.Audit.Context} context
20
- * @return {Promise<{failures: Array<string>, manifestValues?: LH.Artifacts.ManifestValues}>}
21
- */
22
- static audit_(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<{
23
- failures: Array<string>;
24
- manifestValues?: LH.Artifacts.ManifestValues;
25
- }>;
26
- }
27
- import { Audit } from './audit.js';
28
- //# sourceMappingURL=multi-check-audit.d.ts.map
@@ -1,82 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- /**
8
- * @fileoverview Base class for boolean audits that can have multiple reasons for failure
9
- */
10
-
11
- import {Audit} from './audit.js';
12
-
13
- class MultiCheckAudit extends Audit {
14
- /**
15
- * @param {LH.Artifacts} artifacts
16
- * @param {LH.Audit.Context} context
17
- * @return {Promise<LH.Audit.Product>}
18
- */
19
- static async audit(artifacts, context) {
20
- const multiProduct = await this.audit_(artifacts, context);
21
- return this.createAuditProduct(multiProduct);
22
- }
23
-
24
- /**
25
- * @param {{failures: Array<string>, manifestValues?: LH.Artifacts.ManifestValues}} result
26
- * @return {LH.Audit.Product}
27
- */
28
- static createAuditProduct(result) {
29
- /** @type {LH.Audit.MultiCheckAuditDetails} */
30
- const detailsItem = {
31
- ...result,
32
- ...result.manifestValues,
33
- manifestValues: undefined,
34
- allChecks: undefined,
35
- };
36
-
37
- if (result.manifestValues?.allChecks) {
38
- result.manifestValues.allChecks.forEach(check => {
39
- detailsItem[check.id] = check.passing;
40
- });
41
- }
42
-
43
- // Include the detailed pass/fail checklist as a diagnostic.
44
- /** @type {LH.Audit.Details.DebugData} */
45
- const details = {
46
- type: 'debugdata',
47
- // TODO: Consider not nesting detailsItem under `items`.
48
- items: [detailsItem],
49
- };
50
-
51
- // If we fail, share the failures
52
- if (result.failures.length > 0) {
53
- return {
54
- score: 0,
55
- // TODO(#11495): make this i18n-able.
56
- explanation: `Failures: ${result.failures.join(',\n')}.`,
57
- details,
58
- };
59
- }
60
-
61
- // Otherwise, we pass
62
- return {
63
- score: 1,
64
- details,
65
- };
66
- }
67
-
68
- /* eslint-disable no-unused-vars */
69
-
70
- /**
71
- * @param {LH.Artifacts} artifacts
72
- * @param {LH.Audit.Context} context
73
- * @return {Promise<{failures: Array<string>, manifestValues?: LH.Artifacts.ManifestValues}>}
74
- */
75
- static audit_(artifacts, context) {
76
- throw new Error('audit_ unimplemented');
77
- }
78
-
79
- /* eslint-enable no-unused-vars */
80
- }
81
-
82
- export default MultiCheckAudit;
@@ -1,16 +0,0 @@
1
- export default NoUnloadListeners;
2
- declare class NoUnloadListeners 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
- const title: string;
12
- const failureTitle: string;
13
- const description: string;
14
- }
15
- import { Audit } from './audit.js';
16
- //# sourceMappingURL=no-unload-listeners.d.ts.map
@@ -1,86 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2020 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import {Audit} from './audit.js';
8
- import {JSBundles} from '../computed/js-bundles.js';
9
- import * as i18n from './../lib/i18n/i18n.js';
10
-
11
- const UIStrings = {
12
- /** Descriptive title of a Lighthouse audit that checks if a web page has 'unload' event listeners and finds none. */
13
- title: 'Avoids `unload` event listeners',
14
- /** Descriptive title of a Lighthouse audit that checks if a web page has 'unload' event listeners and finds that it is using them. */
15
- failureTitle: 'Registers an `unload` listener',
16
- /** Description of a Lighthouse audit that tells the user why pages should not use the 'unload' event. This is displayed after a user expands the section to see more. The last sentence starting with 'Learn' becomes link text to additional documentation. */
17
- description: 'The `unload` event does not fire reliably and listening for it can prevent browser optimizations like the Back-Forward Cache. Use `pagehide` or `visibilitychange` events instead. [Learn more about unload event listeners](https://web.dev/articles/bfcache#never_use_the_unload_event)',
18
- };
19
-
20
- const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
21
-
22
- class NoUnloadListeners extends Audit {
23
- /**
24
- * @return {LH.Audit.Meta}
25
- */
26
- static get meta() {
27
- return {
28
- id: 'no-unload-listeners',
29
- title: str_(UIStrings.title),
30
- failureTitle: str_(UIStrings.failureTitle),
31
- description: str_(UIStrings.description),
32
- requiredArtifacts: ['GlobalListeners', 'SourceMaps', 'Scripts'],
33
- };
34
- }
35
-
36
- /**
37
- * @param {LH.Artifacts} artifacts
38
- * @param {LH.Audit.Context} context
39
- * @return {Promise<LH.Audit.Product>}
40
- */
41
- static async audit(artifacts, context) {
42
- const unloadListeners = artifacts.GlobalListeners.filter(l => l.type === 'unload');
43
- if (!unloadListeners.length) {
44
- return {
45
- score: 1,
46
- };
47
- }
48
-
49
- const bundles = await JSBundles.request(artifacts, context);
50
-
51
- /** @type {LH.Audit.Details.Table['headings']} */
52
- const headings = [
53
- {key: 'source', valueType: 'source-location', label: str_(i18n.UIStrings.columnSource)},
54
- ];
55
-
56
- /** @type {Array<{source: LH.Audit.Details.ItemValue}>} */
57
- const tableItems = unloadListeners.map(listener => {
58
- const {lineNumber, columnNumber} = listener;
59
- const script = artifacts.Scripts.find(s => s.scriptId === listener.scriptId);
60
-
61
- // If we can't find a url, still show something so the user can manually
62
- // look for where an `unload` handler is being created.
63
- if (!script) {
64
- return {
65
- source: {
66
- type: 'url',
67
- value: `(unknown):${lineNumber}:${columnNumber}`,
68
- },
69
- };
70
- }
71
-
72
- const bundle = bundles.find(bundle => bundle.script.scriptId === script.scriptId);
73
- return {
74
- source: Audit.makeSourceLocation(script.url, lineNumber, columnNumber, bundle),
75
- };
76
- });
77
-
78
- return {
79
- score: 0,
80
- details: Audit.makeTableDetails(headings, tableItems),
81
- };
82
- }
83
- }
84
-
85
- export default NoUnloadListeners;
86
- export {UIStrings};
@@ -1,39 +0,0 @@
1
- export default ResourceBudget;
2
- export type ResourceEntry = import('../computed/resource-summary.js').ResourceEntry;
3
- export type BudgetItem = {
4
- resourceType: LH.Budget.ResourceType;
5
- label: LH.IcuMessage;
6
- requestCount: number;
7
- transferSize: number;
8
- sizeOverBudget: number | undefined;
9
- countOverBudget: LH.IcuMessage | undefined;
10
- };
11
- /** @typedef {import('../computed/resource-summary.js').ResourceEntry} ResourceEntry */
12
- /** @typedef {{resourceType: LH.Budget.ResourceType, label: LH.IcuMessage, requestCount: number, transferSize: number, sizeOverBudget: number | undefined, countOverBudget: LH.IcuMessage | undefined}} BudgetItem */
13
- declare class ResourceBudget extends Audit {
14
- /**
15
- * @param {LH.Budget.ResourceType} resourceType
16
- * @return {string}
17
- */
18
- static getRowLabel(resourceType: LH.Budget.ResourceType): string;
19
- /**
20
- * @param {LH.Util.Immutable<LH.Budget>} budget
21
- * @param {Record<LH.Budget.ResourceType, ResourceEntry>} summary
22
- * @return {Array<BudgetItem>}
23
- */
24
- static tableItems(budget: LH.Util.Immutable<LH.Budget>, summary: Record<LH.Budget.ResourceType, ResourceEntry>): Array<BudgetItem>;
25
- /**
26
- * @param {LH.Artifacts} artifacts
27
- * @param {LH.Audit.Context} context
28
- * @return {Promise<LH.Audit.Product>}
29
- */
30
- static audit(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<LH.Audit.Product>;
31
- }
32
- export namespace UIStrings {
33
- const title: string;
34
- const description: string;
35
- const requestCountOverBudget: string;
36
- }
37
- import { Budget } from '../config/budget.js';
38
- import { Audit } from './audit.js';
39
- //# sourceMappingURL=performance-budget.d.ts.map
@@ -1,154 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2019 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import {Audit} from './audit.js';
8
- import {ResourceSummary} from '../computed/resource-summary.js';
9
- import {MainResource} from '../computed/main-resource.js';
10
- import {Budget} from '../config/budget.js';
11
- import * as i18n from '../lib/i18n/i18n.js';
12
-
13
- const UIStrings = {
14
- /** Title of a Lighthouse audit that compares the size and quantity of page resources against targets set by the user. These targets are thought of as "performance budgets" because these metrics impact page performance (i.e. how quickly a page loads). */
15
- title: 'Performance budget',
16
- /** Description of a Lighthouse audit where a user sets budgets for the quantity and size of page resources. No character length limits. The last sentence starting with 'Learn' becomes link text to additional documentation. */
17
- description: 'Keep the quantity and size of network requests under the targets ' +
18
- 'set by the provided performance budget. ' +
19
- '[Learn more about performance budgets](https://developers.google.com/web/tools/lighthouse/audits/budgets).',
20
- /** [ICU Syntax] Entry in a data table identifying the number of network requests of a particular type. Count will be a whole number. String should be as short as possible to be able to fit well into the table. */
21
- requestCountOverBudget: `{count, plural,
22
- =1 {1 request}
23
- other {# requests}
24
- }`,
25
- };
26
-
27
- const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
28
-
29
- /** @typedef {import('../computed/resource-summary.js').ResourceEntry} ResourceEntry */
30
- /** @typedef {{resourceType: LH.Budget.ResourceType, label: LH.IcuMessage, requestCount: number, transferSize: number, sizeOverBudget: number | undefined, countOverBudget: LH.IcuMessage | undefined}} BudgetItem */
31
-
32
- class ResourceBudget extends Audit {
33
- /**
34
- * @return {LH.Audit.Meta}
35
- */
36
- static get meta() {
37
- return {
38
- id: 'performance-budget',
39
- title: str_(UIStrings.title),
40
- description: str_(UIStrings.description),
41
- scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE,
42
- supportedModes: ['navigation'],
43
- requiredArtifacts: ['devtoolsLogs', 'URL'],
44
- };
45
- }
46
-
47
- /**
48
- * @param {LH.Budget.ResourceType} resourceType
49
- * @return {string}
50
- */
51
- static getRowLabel(resourceType) {
52
- /** @type {Record<LH.Budget.ResourceType,string>} */
53
- const strMappings = {
54
- 'total': i18n.UIStrings.totalResourceType,
55
- 'document': i18n.UIStrings.documentResourceType,
56
- 'script': i18n.UIStrings.scriptResourceType,
57
- 'stylesheet': i18n.UIStrings.stylesheetResourceType,
58
- 'image': i18n.UIStrings.imageResourceType,
59
- 'media': i18n.UIStrings.mediaResourceType,
60
- 'font': i18n.UIStrings.fontResourceType,
61
- 'other': i18n.UIStrings.otherResourceType,
62
- 'third-party': i18n.UIStrings.thirdPartyResourceType,
63
- };
64
- return strMappings[resourceType];
65
- }
66
-
67
- /**
68
- * @param {LH.Util.Immutable<LH.Budget>} budget
69
- * @param {Record<LH.Budget.ResourceType, ResourceEntry>} summary
70
- * @return {Array<BudgetItem>}
71
- */
72
- static tableItems(budget, summary) {
73
- const resourceTypes = /** @type {Array<LH.Budget.ResourceType>} */ (Object.keys(summary));
74
- return resourceTypes.map((resourceType) => {
75
- const label = str_(this.getRowLabel(resourceType));
76
- const requestCount = summary[resourceType].count;
77
- const transferSize = summary[resourceType].transferSize;
78
-
79
- let sizeOverBudget;
80
- let countOverBudget;
81
-
82
- if (budget.resourceSizes) {
83
- const sizeBudget = budget.resourceSizes.find(b => b.resourceType === resourceType);
84
- if (sizeBudget && (transferSize > (sizeBudget.budget * 1024))) {
85
- sizeOverBudget = transferSize - (sizeBudget.budget * 1024);
86
- }
87
- }
88
- if (budget.resourceCounts) {
89
- const countBudget = budget.resourceCounts.find(b => b.resourceType === resourceType);
90
- if (countBudget && (requestCount > countBudget.budget)) {
91
- const requestDifference = requestCount - countBudget.budget;
92
- countOverBudget = str_(UIStrings.requestCountOverBudget, {count: requestDifference});
93
- }
94
- }
95
- return {
96
- resourceType,
97
- label,
98
- requestCount,
99
- transferSize,
100
- countOverBudget,
101
- sizeOverBudget,
102
- };
103
- }).filter((row) => {
104
- // Only resources with budgets should be included in the table
105
- if (budget.resourceSizes) {
106
- if (budget.resourceSizes.some(b => b.resourceType === row.resourceType)) return true;
107
- }
108
- if (budget.resourceCounts) {
109
- if (budget.resourceCounts.some(b => b.resourceType === row.resourceType)) return true;
110
- }
111
- return false;
112
- }).sort((a, b) => {
113
- return (b.sizeOverBudget || 0) - (a.sizeOverBudget || 0);
114
- });
115
- }
116
-
117
- /**
118
- * @param {LH.Artifacts} artifacts
119
- * @param {LH.Audit.Context} context
120
- * @return {Promise<LH.Audit.Product>}
121
- */
122
- static async audit(artifacts, context) {
123
- const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
124
- const data = {devtoolsLog, URL: artifacts.URL, budgets: context.settings.budgets};
125
- const summary = await ResourceSummary.request(data, context);
126
- const mainResource = await MainResource.request({URL: artifacts.URL, devtoolsLog}, context);
127
- const budget = Budget.getMatchingBudget(context.settings.budgets, mainResource.url);
128
-
129
- if (!budget) {
130
- return {
131
- score: 0,
132
- notApplicable: true,
133
- };
134
- }
135
-
136
- /** @type {LH.Audit.Details.Table['headings']} */
137
- const headers = [
138
- {key: 'label', valueType: 'text', label: str_(i18n.UIStrings.columnResourceType)},
139
- {key: 'requestCount', valueType: 'numeric', label: str_(i18n.UIStrings.columnRequests)},
140
- {key: 'transferSize', valueType: 'bytes', label: str_(i18n.UIStrings.columnTransferSize)},
141
- {key: 'countOverBudget', valueType: 'text', label: ''},
142
- {key: 'sizeOverBudget', valueType: 'bytes', label: str_(i18n.UIStrings.columnOverBudget)},
143
- ];
144
-
145
- return {
146
- details: Audit.makeTableDetails(headers,
147
- this.tableItems(budget, summary), {sortedBy: ['sizeOverBudget']}),
148
- score: 1,
149
- };
150
- }
151
- }
152
-
153
- export default ResourceBudget;
154
- export {UIStrings};
@@ -1,14 +0,0 @@
1
- declare namespace _default {
2
- namespace meta {
3
- const id: string;
4
- const title: string;
5
- const failureTitle: string;
6
- const description: string;
7
- const requiredArtifacts: string[];
8
- }
9
- function audit(): {
10
- score: number;
11
- };
12
- }
13
- export default _default;
14
- //# sourceMappingURL=script-elements-test-audit.d.ts.map
@@ -1,29 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2022 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- /**
8
- * @fileoverview This is a fake audit used exclusively in smoke tests to force inclusion of ScriptElements artifact.
9
- * It is included here for complex reasons in the way the bundled smoketests work.
10
- *
11
- * The smokehouse configs are evaluated first in the node CLI side (which requires an absolute path using LH_ROOT).
12
- * The smokehouse configs are then *re-evaluated* in the bundled context for execution by Lighthouse (which *cannot* use an absolute path using LH_ROOT).
13
- *
14
- * This mismatch in environment demands that the audit path in the config must be context-aware,
15
- * yet the require-graph for the config is included before even the CLI knows that it will be using
16
- * a bundled runner. Rather than force a massive smoketest architecture change, we include a harmless,
17
- * test-only audit in our core list instead.
18
- */
19
-
20
- export default {
21
- meta: {
22
- id: 'script-elements-test-audit',
23
- title: 'ScriptElements',
24
- failureTitle: 'ScriptElements',
25
- description: 'Audit to force the inclusion of ScriptElements artifact',
26
- requiredArtifacts: ['ScriptElements'],
27
- },
28
- audit: () => ({score: 1}),
29
- };
@@ -1,15 +0,0 @@
1
- export default Plugins;
2
- declare class Plugins extends Audit {
3
- /**
4
- * @param {LH.Artifacts} artifacts
5
- * @return {LH.Audit.Product}
6
- */
7
- static audit(artifacts: LH.Artifacts): LH.Audit.Product;
8
- }
9
- export namespace UIStrings {
10
- const title: string;
11
- const failureTitle: string;
12
- const description: string;
13
- }
14
- import { Audit } from '../audit.js';
15
- //# sourceMappingURL=plugins.d.ts.map