lighthouse 8.3.0-dev.20210907 → 8.3.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 (196) hide show
  1. package/changelog.md +1 -1
  2. package/dist/report/standalone.js +196 -0
  3. package/jest.config.js +0 -4
  4. package/lighthouse-cli/cli-flags.js +6 -14
  5. package/lighthouse-cli/run.js +1 -1
  6. package/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +3 -9
  7. package/lighthouse-cli/test/smokehouse/report-assert.js +16 -36
  8. package/lighthouse-core/audits/large-javascript-libraries.js +166 -0
  9. package/lighthouse-core/audits/seo/http-status-code.js +6 -2
  10. package/lighthouse-core/audits/viewport.js +1 -2
  11. package/lighthouse-core/config/config-helpers.js +75 -9
  12. package/lighthouse-core/config/config.js +50 -6
  13. package/lighthouse-core/config/constants.js +0 -1
  14. package/lighthouse-core/config/default-config.js +0 -3
  15. package/lighthouse-core/config/experimental-config.js +8 -0
  16. package/lighthouse-core/config/metrics-to-audits.js +0 -1
  17. package/lighthouse-core/fraggle-rock/config/config.js +4 -3
  18. package/lighthouse-core/fraggle-rock/config/default-config.js +1 -3
  19. package/lighthouse-core/fraggle-rock/config/validation.js +0 -201
  20. package/lighthouse-core/fraggle-rock/gather/base-artifacts.js +0 -4
  21. package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +8 -16
  22. package/lighthouse-core/fraggle-rock/gather/runner-helpers.js +0 -4
  23. package/lighthouse-core/fraggle-rock/gather/session.js +5 -30
  24. package/lighthouse-core/gather/driver/navigation.js +6 -7
  25. package/lighthouse-core/gather/driver/wait-for-condition.js +0 -27
  26. package/lighthouse-core/gather/fetcher.js +7 -17
  27. package/lighthouse-core/gather/gather-runner.js +0 -1
  28. package/lighthouse-core/gather/gatherers/seo/robots-txt.js +6 -2
  29. package/lighthouse-core/gather/gatherers/seo/tap-targets.js +2 -2
  30. package/lighthouse-core/gather/gatherers/stacks.js +1 -1
  31. package/lighthouse-core/lib/asset-saver.js +2 -2
  32. package/lighthouse-core/lib/cdt/SDK.js +0 -1
  33. package/lighthouse-core/lib/csp-evaluator.js +4 -17
  34. package/{report/generator → lighthouse-core/lib}/file-namer.js +0 -0
  35. package/lighthouse-core/lib/i18n/README.md +1 -1
  36. package/lighthouse-core/lib/i18n/i18n.js +7 -7
  37. package/lighthouse-core/lib/i18n/locales/ar-XB.json +18 -0
  38. package/lighthouse-core/lib/i18n/locales/ar.json +18 -0
  39. package/lighthouse-core/lib/i18n/locales/bg.json +18 -0
  40. package/lighthouse-core/lib/i18n/locales/ca.json +18 -0
  41. package/lighthouse-core/lib/i18n/locales/cs.json +18 -0
  42. package/lighthouse-core/lib/i18n/locales/da.json +18 -0
  43. package/lighthouse-core/lib/i18n/locales/de.json +18 -0
  44. package/lighthouse-core/lib/i18n/locales/el.json +18 -0
  45. package/lighthouse-core/lib/i18n/locales/en-GB.json +18 -0
  46. package/lighthouse-core/lib/i18n/locales/en-US.json +18 -18
  47. package/lighthouse-core/lib/i18n/locales/en-XA.json +18 -0
  48. package/lighthouse-core/lib/i18n/locales/en-XL.json +18 -18
  49. package/lighthouse-core/lib/i18n/locales/es-419.json +18 -0
  50. package/lighthouse-core/lib/i18n/locales/es.json +18 -0
  51. package/lighthouse-core/lib/i18n/locales/fi.json +18 -0
  52. package/lighthouse-core/lib/i18n/locales/fil.json +18 -0
  53. package/lighthouse-core/lib/i18n/locales/fr.json +18 -0
  54. package/lighthouse-core/lib/i18n/locales/he.json +18 -0
  55. package/lighthouse-core/lib/i18n/locales/hi.json +18 -0
  56. package/lighthouse-core/lib/i18n/locales/hr.json +18 -0
  57. package/lighthouse-core/lib/i18n/locales/hu.json +18 -0
  58. package/lighthouse-core/lib/i18n/locales/id.json +18 -0
  59. package/lighthouse-core/lib/i18n/locales/it.json +18 -0
  60. package/lighthouse-core/lib/i18n/locales/ja.json +18 -0
  61. package/lighthouse-core/lib/i18n/locales/ko.json +18 -0
  62. package/lighthouse-core/lib/i18n/locales/lt.json +18 -0
  63. package/lighthouse-core/lib/i18n/locales/lv.json +18 -0
  64. package/lighthouse-core/lib/i18n/locales/nl.json +18 -0
  65. package/lighthouse-core/lib/i18n/locales/no.json +18 -0
  66. package/lighthouse-core/lib/i18n/locales/pl.json +18 -0
  67. package/lighthouse-core/lib/i18n/locales/pt-PT.json +18 -0
  68. package/lighthouse-core/lib/i18n/locales/pt.json +18 -0
  69. package/lighthouse-core/lib/i18n/locales/ro.json +18 -0
  70. package/lighthouse-core/lib/i18n/locales/ru.json +18 -0
  71. package/lighthouse-core/lib/i18n/locales/sk.json +18 -0
  72. package/lighthouse-core/lib/i18n/locales/sl.json +18 -0
  73. package/lighthouse-core/lib/i18n/locales/sr-Latn.json +18 -0
  74. package/lighthouse-core/lib/i18n/locales/sr.json +18 -0
  75. package/lighthouse-core/lib/i18n/locales/sv.json +18 -0
  76. package/lighthouse-core/lib/i18n/locales/ta.json +18 -0
  77. package/lighthouse-core/lib/i18n/locales/te.json +18 -0
  78. package/lighthouse-core/lib/i18n/locales/th.json +18 -0
  79. package/lighthouse-core/lib/i18n/locales/tr.json +18 -0
  80. package/lighthouse-core/lib/i18n/locales/uk.json +18 -0
  81. package/lighthouse-core/lib/i18n/locales/vi.json +18 -0
  82. package/lighthouse-core/lib/i18n/locales/zh-HK.json +18 -0
  83. package/lighthouse-core/lib/i18n/locales/zh-TW.json +18 -0
  84. package/lighthouse-core/lib/i18n/locales/zh.json +18 -0
  85. package/lighthouse-core/lib/large-javascript-libraries/bundlephobia-database.json +62 -0
  86. package/lighthouse-core/lib/large-javascript-libraries/library-suggestions.js +20 -0
  87. package/lighthouse-core/lib/network-request.js +1 -3
  88. package/lighthouse-core/lib/traces/pwmetrics-events.js +2 -2
  89. package/lighthouse-core/lib/url-shim.js +1 -7
  90. package/lighthouse-core/runner.js +1 -4
  91. package/lighthouse-core/util-commonjs.js +2 -2
  92. package/now.json +1 -1
  93. package/package.json +13 -20
  94. package/report/README.md +2 -2
  95. package/report/assets/standalone-template.html +1 -0
  96. package/report/assets/styles.css +27 -23
  97. package/report/assets/templates.html +40 -37
  98. package/report/clients/bundle.js +0 -1
  99. package/report/{package.json → clients/package.json} +0 -0
  100. package/report/clients/psi.js +3 -13
  101. package/report/clients/standalone.js +1 -1
  102. package/report/{types/buffer.d.ts → clients/treemap.js} +13 -11
  103. package/report/renderer/category-renderer.js +2 -2
  104. package/report/renderer/components.js +48 -46
  105. package/report/renderer/crc-details-renderer.js +16 -16
  106. package/report/renderer/details-renderer.js +1 -1
  107. package/report/renderer/dom.js +0 -17
  108. package/report/renderer/element-screenshot-renderer.js +9 -9
  109. package/{flow-report/test/setup/global-setup.ts → report/renderer/file-namer.js} +2 -5
  110. package/report/renderer/logger.js +4 -4
  111. package/report/renderer/package.json +4 -0
  112. package/report/renderer/report-renderer.js +11 -4
  113. package/report/renderer/report-ui-features.js +656 -43
  114. package/report/renderer/text-encoding.js +1 -1
  115. package/report/renderer/util.js +2 -2
  116. package/report/{generator/report-assets.js → report-assets.js} +3 -9
  117. package/report/{generator/report-generator.js → report-generator.js} +9 -37
  118. package/report/test/clients/package.json +4 -0
  119. package/report/test/clients/psi-test.js +1 -3
  120. package/report/test/renderer/category-renderer-test.js +3 -8
  121. package/report/test/renderer/components-test.js +0 -35
  122. package/report/test/renderer/crc-details-renderer-test.js +4 -5
  123. package/report/test/renderer/details-renderer-test.js +1 -3
  124. package/report/test/renderer/dom-test.js +6 -8
  125. package/report/test/renderer/i18n-test.js +0 -1
  126. package/report/test/renderer/package.json +4 -0
  127. package/report/test/renderer/performance-category-renderer-test.js +27 -30
  128. package/report/test/renderer/pwa-category-renderer-test.js +1 -2
  129. package/report/test/renderer/report-renderer-test.js +0 -1
  130. package/report/test/renderer/report-ui-features-test.js +28 -20
  131. package/report/test/renderer/snippet-renderer-test.js +0 -1
  132. package/report/test/renderer/text-encoding-test.js +0 -2
  133. package/report/test/renderer/util-test.js +0 -1
  134. package/report/test/{generator/report-generator-test.js → report-generator-test.js} +7 -9
  135. package/third-party/chromium-synchronization/installability-errors-test.js +27 -28
  136. package/third-party/snyk/snapshot.json +0 -2
  137. package/tsconfig.json +5 -24
  138. package/types/artifacts.d.ts +18 -5
  139. package/types/{lhr/audit-details.d.ts → audit-details.d.ts} +3 -18
  140. package/types/audit.d.ts +58 -7
  141. package/types/{lhr/budget.d.ts → budget.d.ts} +0 -0
  142. package/types/bundle-phobia-cli/index.d.ts +40 -0
  143. package/types/config.d.ts +8 -3
  144. package/types/externs.d.ts +119 -5
  145. package/types/gatherer.d.ts +2 -3
  146. package/types/global-lh.d.ts +14 -16
  147. package/{report/types/report-result.d.ts → types/html-renderer.d.ts} +17 -8
  148. package/types/{lhr/i18n.d.ts → i18n.d.ts} +25 -2
  149. package/types/{lhr/lhr.d.ts → lhr.d.ts} +9 -41
  150. package/types/smokehouse.d.ts +3 -3
  151. package/types/{lhr/treemap.d.ts → treemap.d.ts} +3 -3
  152. package/flow-report/assets/standalone-flow-template.html +0 -38
  153. package/flow-report/assets/styles.css +0 -310
  154. package/flow-report/jest.config.js +0 -24
  155. package/flow-report/src/app.tsx +0 -40
  156. package/flow-report/src/common.tsx +0 -72
  157. package/flow-report/src/icons.tsx +0 -96
  158. package/flow-report/src/sidebar/flow.tsx +0 -72
  159. package/flow-report/src/sidebar/sidebar.tsx +0 -89
  160. package/flow-report/src/summary/summary.tsx +0 -178
  161. package/flow-report/src/util.ts +0 -160
  162. package/flow-report/src/wrappers/gauge.tsx +0 -40
  163. package/flow-report/src/wrappers/report-renderer.tsx +0 -46
  164. package/flow-report/src/wrappers/report.tsx +0 -71
  165. package/flow-report/standalone-flow.tsx +0 -23
  166. package/flow-report/test/app-test.tsx +0 -48
  167. package/flow-report/test/common-test.tsx +0 -131
  168. package/flow-report/test/setup/env-setup.ts +0 -25
  169. package/flow-report/test/sidebar/flow-test.tsx +0 -71
  170. package/flow-report/test/sidebar/sidebar-test.tsx +0 -53
  171. package/flow-report/test/summary/summary-test.tsx +0 -132
  172. package/flow-report/test/util-test.tsx +0 -109
  173. package/flow-report/tsconfig.json +0 -39
  174. package/flow-report/types/flow-report.d.ts +0 -27
  175. package/lighthouse-core/audits/lcp-lazy-loaded.js +0 -83
  176. package/report/.eslintrc.cjs +0 -33
  177. package/report/generator/README.md +0 -9
  178. package/report/generator/flow-report-assets.js +0 -20
  179. package/report/generator/package.json +0 -4
  180. package/report/generator/tsconfig.json +0 -28
  181. package/report/renderer/drop-down-menu.js +0 -215
  182. package/report/renderer/features-util.js +0 -26
  183. package/report/renderer/open-tab.js +0 -137
  184. package/report/renderer/topbar-features.js +0 -309
  185. package/report/test/generator/file-namer-test.js +0 -28
  186. package/report/test/generator/package.json +0 -4
  187. package/report/test-assets/faux-psi-template.html +0 -126
  188. package/report/test-assets/faux-psi.js +0 -92
  189. package/report/tsconfig.json +0 -39
  190. package/report/types/augment-dom.d.ts +0 -24
  191. package/report/types/html-renderer.d.ts +0 -28
  192. package/types/lhr/audit-result.d.ts +0 -59
  193. package/types/lhr/flow.d.ts +0 -16
  194. package/types/lhr/settings.d.ts +0 -105
  195. package/types/lhr/tsconfig.json +0 -24
  196. package/types/query-selector.d.ts +0 -36
@@ -1,28 +0,0 @@
1
- /**
2
- * @license Copyright 2017 The Lighthouse Authors. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5
- */
6
- 'use strict';
7
-
8
- const assert = require('assert').strict;
9
-
10
- const getFilenamePrefix = require('../../generator/file-namer.js').getFilenamePrefix;
11
-
12
- /* eslint-env jest */
13
- describe('file-namer helper', () => {
14
- it('generates filename prefixes', () => {
15
- const results = {
16
- finalUrl: 'https://testexample.com',
17
- fetchTime: '2017-01-06T02:34:56.217Z',
18
- };
19
- const str = getFilenamePrefix(results);
20
- // we want the filename to match user timezone, however these tests will run on multiple TZs
21
- assert.ok(str.startsWith('testexample.com'), 'hostname is missing');
22
- assert.ok(str.includes('2017-'), 'full year is missing');
23
- assert.ok(str.endsWith('-56'), 'seconds value is not at the end');
24
- // regex of hostname_YYYY-MM-DD_HH-MM-SS
25
- const regex = /testexample\.com_\d{4}-[0-1][[0-9]-[0-1][[0-9]_[0-2][0-9]-[0-5][0-9]-[0-5][0-9]/;
26
- assert.ok(regex.test(str), `${str} doesn't match pattern: hostname_YYYY-MM-DD_HH-MM-SS`);
27
- });
28
- });
@@ -1,4 +0,0 @@
1
- {
2
- "type": "commonjs",
3
- "//": "Preserve commonjs in this directory. Temporary file until converted to type: module"
4
- }
@@ -1,126 +0,0 @@
1
- <!--
2
- * Copyright 2021 The Lighthouse Authors. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5
- -->
6
-
7
- <!--
8
- This fake psi page is intended to reproduce the experience of rendering two LHRs within the same DOM,
9
- like in PageSpeed Insights. This helps surface the peculiar behavior around tabs,
10
- expectations of unique IDs, and scoped report containment.
11
- -->
12
-
13
- <!doctype html>
14
- <html lang="en">
15
- <head>
16
- <meta charset="utf-8">
17
- <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
18
- <title>Faux PageSpeed Report</title>
19
- <style>/*%%LIGHTHOUSE_CSS%%*/</style>
20
-
21
- <style>
22
- /* Inspired by https://codepen.io/markcaron/pen/MvGRYV?editors=1100 but improved. s*/
23
- /*
24
- The tab visibility basics
25
- */
26
- .tabset > input[type="radio"] {
27
- position: absolute;
28
- left: -200vw;
29
- }
30
-
31
- .tabset .tab-panel {
32
- display: none;
33
- }
34
-
35
- .tabset > input:nth-of-type(1):checked ~ .tab-panels > .tab-panel:nth-of-type(1),
36
- .tabset > input:nth-of-type(2):checked ~ .tab-panels > .tab-panel:nth-of-type(2) {
37
- display: block;
38
- }
39
-
40
- /*
41
- Purdy tabs
42
- */
43
- .tabset > label {
44
- position: relative;
45
- display: inline-block;
46
- padding: 15px 55px 15px;
47
- border: 1px solid transparent;
48
- border-bottom: 0;
49
- cursor: pointer;
50
- font-weight: 600;
51
- }
52
-
53
- .tabset > label:hover {
54
- background-color: hsl(0deg 0% 100% / 24%);
55
- }
56
-
57
- .tabset > label:hover,
58
- .tabset > input:focus + label {
59
- color: #06c;
60
- }
61
-
62
- .tabset > input:checked + label {
63
- border-color: #ccc;
64
- border-bottom: 1px solid #fff;
65
- margin-bottom: -1px;
66
- background: white;
67
- }
68
-
69
- .tab-panel {
70
- padding: 30px 0;
71
- border-top: 1px solid #ccc;
72
- }
73
-
74
- body {
75
- padding: 30px;
76
- }
77
-
78
- .tabset {
79
- max-width: 65em;
80
- background: #eee;
81
- }
82
-
83
- .tab-panels {
84
- background: white;
85
- }
86
-
87
- /* extra styles */
88
- body {
89
- background: hsl(217deg 89% 61%);
90
- }
91
- </style>
92
- </head>
93
- <body >
94
- <noscript>PSI requires JavaScript. Please enable.</noscript>
95
-
96
- <div class="element-screenshots-container"></div>
97
-
98
-
99
- <div class="tabset lh-vars lh-root">
100
-
101
- <input type="radio" name="tabset" id="tab1" aria-controls="mobile" checked>
102
- <label for="tab1">Mobile</label>
103
-
104
- <input type="radio" name="tabset" id="tab2" aria-controls="desktop">
105
- <label for="tab2">Desktop</label>
106
-
107
- <div class="tab-panels">
108
- <section id="mobile" class="tab-panel">
109
- <main></main>
110
- </section>
111
-
112
- <section id="desktop" class="tab-panel">
113
- <main></main>
114
- </section>
115
-
116
- </div>
117
- </div>
118
-
119
- <script>window.__LIGHTHOUSE_JSON__ = %%LIGHTHOUSE_JSON%%;</script>
120
- <script type="module">
121
- %%LIGHTHOUSE_JAVASCRIPT%%
122
- //# sourceURL=psi-reportrenderer.js
123
- </script>
124
- <script>console.log('window.__LIGHTHOUSE_JSON__', __LIGHTHOUSE_JSON__);</script>
125
- </body>
126
- </html>
@@ -1,92 +0,0 @@
1
- /**
2
- * @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5
- */
6
- 'use strict';
7
-
8
- /** @fileoverview This file is a glorified call of prepareLabData. */
9
-
10
- /** @typedef {import('../clients/psi.js').PrepareLabDataResult} PrepareLabDataResult */
11
-
12
- (async function __initPsiReports__() {
13
- // @ts-expect-error
14
- const mobileLHR = window.__LIGHTHOUSE_JSON__;
15
- const desktopLHR = JSON.parse(JSON.stringify(mobileLHR));
16
-
17
- const lhrs = {
18
- 'mobile': mobileLHR,
19
- 'desktop': desktopLHR,
20
- };
21
-
22
- for (const [tabId, lhr] of Object.entries(lhrs)) {
23
- await distinguishLHR(lhr, tabId);
24
-
25
- // @ts-expect-error
26
- const pldd = /** @type {PrepareLabDataResult} */ (window.prepareLabData(lhr, document));
27
- const {scoreGaugeEl, perfCategoryEl,
28
- finalScreenshotDataUri, scoreScaleEl, installFeatures} = pldd;
29
-
30
- const container = document.querySelector(`#${tabId} main`);
31
- if (!container) throw new Error('Unexpected DOM. Bailing.');
32
- container.append(scoreGaugeEl);
33
- container.append(scoreScaleEl);
34
- if (finalScreenshotDataUri) {
35
- const imgEl = document.createElement('img');
36
- imgEl.src = finalScreenshotDataUri;
37
- container.append(imgEl);
38
- }
39
- container.append(perfCategoryEl);
40
- installFeatures(container);
41
- }
42
- })();
43
-
44
-
45
- /**
46
- * Tweak the LHR to make the desktop and mobile reports easier to identify.
47
- * Adjusted: Perf category name and score, and emoji placed on top of key screenshots.
48
- * @param {LH.Result} lhr
49
- * @param {string} tabId
50
- */
51
- async function distinguishLHR(lhr, tabId) {
52
- lhr.categories.performance.title += ` ${tabId}`; // for easier identification
53
- if (tabId === 'desktop') {
54
- lhr.categories.performance.score = 0.81;
55
- }
56
-
57
- const finalSSDetails = lhr.audits['final-screenshot'] && lhr.audits['final-screenshot'].details;
58
- if (!finalSSDetails || finalSSDetails.type !== 'screenshot') throw new Error();
59
- finalSSDetails.data = await decorateScreenshot(finalSSDetails.data, tabId);
60
-
61
- const fpSSDetails = lhr.audits['full-page-screenshot'] &&
62
- lhr.audits['full-page-screenshot'].details;
63
- if (!fpSSDetails || fpSSDetails.type !== 'full-page-screenshot') throw new Error();
64
- fpSSDetails.screenshot.data = await decorateScreenshot(fpSSDetails.screenshot.data, tabId);
65
- }
66
-
67
- /**
68
- * Add 📱 and 💻 emoji on top of screenshot
69
- * @param {string} datauri
70
- * @param {string} tabId
71
- */
72
- async function decorateScreenshot(datauri, tabId) {
73
- const img = document.createElement('img');
74
-
75
- await new Promise((resolve, reject) => {
76
- img.addEventListener('load', () => resolve(img));
77
- img.addEventListener('error', (err) => reject(err));
78
- img.src = datauri;
79
- });
80
- const c = document.createElement('canvas');
81
- c.width = img.width;
82
- c.height = img.height;
83
-
84
- const ctx = c.getContext('2d');
85
- if (!ctx) throw new Error();
86
- ctx.drawImage(img, 0, 0);
87
- ctx.font = `${img.width / 2}px serif`;
88
- ctx.textAlign = 'center';
89
- ctx.globalAlpha = 0.7;
90
- ctx.fillText(tabId === 'mobile' ? '📱' : '💻', img.width / 2, Math.min(img.height / 2, 700));
91
- return c.toDataURL();
92
- }
@@ -1,39 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "composite": true,
4
- "outDir": "../.tmp/tsbuildinfo/report",
5
- "emitDeclarationOnly": true,
6
- "declarationMap": true,
7
-
8
- // Limit to base JS and DOM defs.
9
- "lib": ["es2020", "dom", "dom.iterable"],
10
- // Don't include any types from node_modules.
11
- "types": [],
12
- "target": "es2020",
13
- "module": "es2020",
14
- "moduleResolution": "node",
15
-
16
- "allowJs": true,
17
- "checkJs": true,
18
- "strict": true,
19
- // TODO: remove the next line to be fully `strict`.
20
- "useUnknownInCatchVariables": false,
21
-
22
- // "listFiles": true,
23
- // "noErrorTruncation": true,
24
- "extendedDiagnostics": true,
25
- },
26
- "include": [
27
- "**/*.js",
28
- "types/**/*.d.ts",
29
- ],
30
- "references": [
31
- {"path": "../types/lhr/"},
32
- {"path": "./generator/"}
33
- ],
34
- "exclude": [
35
- "generator/**/*.js",
36
- // These test files require further changes before they can be type checked.
37
- "test/**/*.js",
38
- ],
39
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5
- */
6
-
7
- /**
8
- * @fileoverview Augment global scope with needed DOM APIs that are newer or not
9
- * widely supported enough to be in tsc's lib `dom`.
10
- */
11
-
12
- // Import to augment querySelector/querySelectorAll with stricter type checking.
13
- import '../../types/query-selector';
14
-
15
- declare global {
16
- var CompressionStream: {
17
- prototype: CompressionStream,
18
- new (format: string): CompressionStream,
19
- };
20
-
21
- interface CompressionStream extends GenericTransformStream {
22
- readonly format: string;
23
- }
24
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5
- */
6
-
7
- import AuditDetails from '../../types/lhr/audit-details';
8
- import {FormattedIcu as FormattedIcu_} from '../../types/lhr/i18n';
9
- import LHResult from '../../types/lhr/lhr';
10
- import ReportResult_ from './report-result';
11
- import * as Settings from '../../types/lhr/settings';
12
- import Treemap_ from '../../types/lhr/treemap';
13
-
14
- declare global {
15
- // Expose global types in LH namespace.
16
- module LH {
17
- export import Result = LHResult;
18
- export import ReportResult = ReportResult_;
19
- export import Locale = Settings.Locale;
20
- export type FormattedIcu<T> = FormattedIcu_<T>;
21
-
22
- module Audit {
23
- export import Details = AuditDetails;
24
- }
25
-
26
- export import Treemap = Treemap_;
27
- }
28
- }
@@ -1,59 +0,0 @@
1
- /**
2
- * @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5
- */
6
-
7
- import {FormattedIcu} from './i18n';
8
- import AuditDetails from './audit-details';
9
-
10
- interface ScoreDisplayModes {
11
- /** Scores of 0-1 (map to displayed scores of 0-100). */
12
- NUMERIC: 'numeric';
13
- /** Pass/fail audit (0 and 1 are only possible scores). */
14
- BINARY: 'binary';
15
- /** The audit exists only to tell you to review something yourself. Score is null and should be ignored. */
16
- MANUAL: 'manual';
17
- /** The audit is an FYI only, and can't be interpreted as pass/fail. Score is null and should be ignored. */
18
- INFORMATIVE: 'informative';
19
- /** The audit turned out to not apply to the page. Score is null and should be ignored. */
20
- NOT_APPLICABLE: 'notApplicable';
21
- /** There was an error while running the audit (check `errorMessage` for details). Score is null and should be ignored. */
22
- ERROR: 'error';
23
- }
24
-
25
- type ScoreDisplayMode = ScoreDisplayModes[keyof ScoreDisplayModes];
26
-
27
- /** Audit result returned in Lighthouse report. All audits offer a description and score of 0-1. */
28
- export interface Result {
29
- displayValue?: string;
30
- /** An explanation of why the audit failed on the test page. */
31
- explanation?: string;
32
- /** Error message from any exception thrown while running this audit. */
33
- errorMessage?: string;
34
- warnings?: string[];
35
- /** The scored value of the audit, provided in the range `0-1`, or null if `scoreDisplayMode` indicates not scored. */
36
- score: number|null;
37
- /**
38
- * A string identifying how the score should be interpreted:
39
- * - 'binary': pass/fail audit (0 and 1 are only possible scores).
40
- * - 'numeric': scores of 0-1 (map to displayed scores of 0-100).
41
- * - 'informative': the audit is an FYI only, and can't be interpreted as pass/fail. Score is null and should be ignored.
42
- * - 'notApplicable': the audit turned out to not apply to the page. Score is null and should be ignored.
43
- * - 'manual': The audit exists only to tell you to review something yourself. Score is null and should be ignored.
44
- * - 'error': There was an error while running the audit (check `errorMessage` for details). Score is null and should be ignored.
45
- */
46
- scoreDisplayMode: ScoreDisplayMode;
47
- /** Short, user-visible title for the audit. The text can change depending on if the audit passed or failed. */
48
- title: string;
49
- /** The string identifier of the audit, in kebab case. */
50
- id: string;
51
- /** A more detailed description that describes why the audit is important and links to Lighthouse documentation on the audit; markdown links supported. */
52
- description: string;
53
- /** A numeric value that has a meaning specific to the audit, e.g. the number of nodes in the DOM or the timestamp of a specific load event. More information can be found in the audit details, if present. */
54
- numericValue?: number;
55
- /** The unit of `numericValue`, used when the consumer wishes to convert numericValue to a display string. */
56
- numericUnit?: string;
57
- /** Extra information about the page provided by some types of audits, in one of several possible forms that can be rendered in the HTML report. */
58
- details?: FormattedIcu<AuditDetails>;
59
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5
- */
6
-
7
- import Result from './lhr';
8
-
9
- /**
10
- * The full output of a Lighthouse flow. Includes a series of Lighthouse runs.
11
- * TODO(FR-COMPAT): Add flow specific metadata (e.g. interaction steps).
12
- */
13
- export default interface FlowResult {
14
- /** Ordered list of lighthouse results corresponding to a navigation, timespan, or snapshot. */
15
- lhrs: Result[];
16
- }
@@ -1,105 +0,0 @@
1
- /**
2
- * @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5
- */
6
-
7
- import Budget from './budget';
8
-
9
- export type Locale = 'en-US'|'en'|'en-AU'|'en-GB'|'en-IE'|'en-SG'|'en-ZA'|'en-IN'|'ar-XB'|'ar'|'bg'|'ca'|'cs'|'da'|'de'|'el'|'en-XA'|'en-XL'|'es'|'es-419'|'es-AR'|'es-BO'|'es-BR'|'es-BZ'|'es-CL'|'es-CO'|'es-CR'|'es-CU'|'es-DO'|'es-EC'|'es-GT'|'es-HN'|'es-MX'|'es-NI'|'es-PA'|'es-PE'|'es-PR'|'es-PY'|'es-SV'|'es-US'|'es-UY'|'es-VE'|'fi'|'fil'|'fr'|'he'|'hi'|'hr'|'hu'|'gsw'|'id'|'in'|'it'|'iw'|'ja'|'ko'|'lt'|'lv'|'mo'|'nl'|'nb'|'no'|'pl'|'pt'|'pt-PT'|'ro'|'ru'|'sk'|'sl'|'sr'|'sr-Latn'|'sv'|'ta'|'te'|'th'|'tl'|'tr'|'uk'|'vi'|'zh'|'zh-HK'|'zh-TW';
10
-
11
- /** Simulation settings that control the amount of network & cpu throttling in the run. */
12
- export interface ThrottlingSettings {
13
- /** The round trip time in milliseconds. */
14
- rttMs?: number;
15
- /** The network throughput in kilobits per second. */
16
- throughputKbps?: number;
17
- // devtools settings
18
- /** The network request latency in milliseconds. */
19
- requestLatencyMs?: number;
20
- /** The network download throughput in kilobits per second. */
21
- downloadThroughputKbps?: number;
22
- /** The network upload throughput in kilobits per second. */
23
- uploadThroughputKbps?: number;
24
- // used by both
25
- /** The amount of slowdown applied to the cpu (1/<cpuSlowdownMultiplier>). */
26
- cpuSlowdownMultiplier?: number
27
- }
28
-
29
- export interface PrecomputedLanternData {
30
- additionalRttByOrigin: {[origin: string]: number};
31
- serverResponseTimeByOrigin: {[origin: string]: number};
32
- }
33
-
34
- export type OutputMode = 'json' | 'html' | 'csv';
35
-
36
- export type ScreenEmulationSettings = {
37
- /** Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override. */
38
- width: number;
39
- /** Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override. */
40
- height: number;
41
- /** Overriding device scale factor value. 0 disables the override. */
42
- deviceScaleFactor: number;
43
- /** Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more. */
44
- mobile: boolean;
45
- /** Whether screen emulation is disabled. If true, the other emulation settings are ignored. */
46
- disabled: boolean;
47
- };
48
-
49
- /**
50
- * Options that are found in both the flags used by the Lighthouse module
51
- * interface and the Config's `settings` object.
52
- */
53
- export interface SharedFlagsSettings {
54
- /** The type(s) of report output to be produced. */
55
- output?: OutputMode|OutputMode[];
56
- /** The locale to use for the output. */
57
- locale?: Locale;
58
- /** The maximum amount of time to wait for a page content render, in ms. If no content is rendered within this limit, the run is aborted with an error. */
59
- maxWaitForFcp?: number;
60
- /** The maximum amount of time to wait for a page to load, in ms. */
61
- maxWaitForLoad?: number;
62
- /** List of URL patterns to block. */
63
- blockedUrlPatterns?: string[] | null;
64
- /** Comma-delimited list of trace categories to include. */
65
- additionalTraceCategories?: string | null;
66
- /** Flag indicating the run should only audit. */
67
- auditMode?: boolean | string;
68
- /** Flag indicating the run should only gather. */
69
- gatherMode?: boolean | string;
70
- /** Flag indicating that the browser storage should not be reset for the audit. */
71
- disableStorageReset?: boolean;
72
- /** Flag indicating that Lighthouse should pause after page load to wait for the user's permission to continue the audit. */
73
- debugNavigation?: boolean;
74
-
75
- /** How Lighthouse should interpret this run in regards to scoring performance metrics and skipping mobile-only tests in desktop. Must be set even if throttling/emulation is being applied outside of Lighthouse. */
76
- formFactor?: 'mobile'|'desktop';
77
- /** Screen emulation properties (width, height, dpr, mobile viewport) to apply or an object of `{disabled: true}` if Lighthouse should avoid applying screen emulation. If either emulation is applied outside of Lighthouse, or it's being run on a mobile device, it typically should be set to disabled. For desktop, we recommend applying consistent desktop screen emulation. */
78
- screenEmulation?: Partial<ScreenEmulationSettings>;
79
- /** User Agent string to apply, `false` to not change the host's UA string, or `true` to use Lighthouse's default UA string. */
80
- emulatedUserAgent?: string | boolean;
81
-
82
- /** The method used to throttle the network. */
83
- throttlingMethod?: 'devtools'|'simulate'|'provided';
84
- /** The throttling config settings. */
85
- throttling?: ThrottlingSettings;
86
- /** If present, the run should only conduct this list of audits. */
87
- onlyAudits?: string[] | null;
88
- /** If present, the run should only conduct this list of categories. */
89
- onlyCategories?: string[] | null;
90
- /** If present, the run should skip this list of audits. */
91
- skipAudits?: string[] | null;
92
- /** List of extra HTTP Headers to include. */
93
- extraHeaders?: Record<string, string> | null; // Matches `Protocol.Network.Headers`.
94
- /** How Lighthouse was run, e.g. from the Chrome extension or from the npm module */
95
- channel?: string
96
- /** Precomputed lantern estimates to use instead of observed analysis. */
97
- precomputedLanternData?: PrecomputedLanternData | null;
98
- /** The budget.json object for LightWallet. */
99
- budgets?: Array<Budget> | null;
100
- }
101
-
102
- export interface ConfigSettings extends Required<SharedFlagsSettings> {
103
- throttling: Required<ThrottlingSettings>;
104
- screenEmulation: ScreenEmulationSettings;
105
- }
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "esnext",
4
- "target": "esnext",
5
- "esModuleInterop": true,
6
- "moduleResolution": "node",
7
-
8
- "strict": true,
9
- "extendedDiagnostics": true,
10
-
11
- // We only need the base JS definitions, no libs in node_modules, no DOM, etc.
12
- "lib": ["esnext"],
13
- "types": [],
14
-
15
- // "listFiles": true,
16
- // "noErrorTruncation": true,
17
-
18
- "composite": true,
19
- "outDir": "../../.tmp/tsbuildinfo/types/lhr",
20
- },
21
- "include": [
22
- "*.d.ts",
23
- ],
24
- }
@@ -1,36 +0,0 @@
1
- /**
2
- * @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5
- */
6
-
7
- /**
8
- * @fileoverview Stricter querySelector/querySelectorAll using typed-query-selector.
9
- */
10
-
11
- import {ParseSelectorToTagNames} from 'typed-query-selector/parser';
12
-
13
- /** Merge properties of the types in union `T`. Where properties overlap, property types becomes the union of the two (or more) possible types. */
14
- type MergeTypes<T> = {
15
- [K in (T extends unknown ? keyof T : never)]: T extends Record<K, infer U> ? U : never;
16
- };
17
-
18
- // Helper types for strict querySelector/querySelectorAll that includes the overlap
19
- // between HTML and SVG node names (<a>, <script>, etc).
20
- // see https://github.com/GoogleChrome/lighthouse/issues/12011
21
- type HtmlAndSvgElementTagNameMap = MergeTypes<HTMLElementTagNameMap|SVGElementTagNameMap> & {
22
- // Fall back to Element (base of HTMLElement and SVGElement) if no specific tag name matches.
23
- [id: string]: Element;
24
- };
25
- type QuerySelectorParse<I extends string> = ParseSelectorToTagNames<I> extends infer TagNames ?
26
- TagNames extends Array<string> ?
27
- HtmlAndSvgElementTagNameMap[TagNames[number]] :
28
- Element: // Fall back for queries typed-query-selector fails to parse, e.g. `'[alt], [aria-label]'`.
29
- never;
30
-
31
- declare global {
32
- interface ParentNode {
33
- querySelector<S extends string>(selector: S): QuerySelectorParse<S> | null;
34
- querySelectorAll<S extends string>(selector: S): NodeListOf<QuerySelectorParse<S>>;
35
- }
36
- }