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,132 +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 fs from 'fs';
8
- import {dirname} from 'path';
9
- import {fileURLToPath} from 'url';
10
-
11
- import {render} from '@testing-library/preact';
12
- import {FunctionComponent} from 'preact';
13
-
14
- import {SummaryHeader, SummaryFlowStep} from '../../src/summary/summary';
15
- import {FlowResultContext} from '../../src/util';
16
- import {ReportRendererProvider} from '../../src/wrappers/report-renderer';
17
-
18
- const flowResult: LH.FlowResult = JSON.parse(
19
- fs.readFileSync(
20
- // eslint-disable-next-line max-len
21
- `${dirname(fileURLToPath(import.meta.url))}/../../../lighthouse-core/test/fixtures/fraggle-rock/reports/sample-lhrs.json`,
22
- 'utf-8'
23
- )
24
- );
25
-
26
- let wrapper: FunctionComponent;
27
-
28
- beforeEach(() => {
29
- wrapper = ({children}) => (
30
- <FlowResultContext.Provider value={flowResult}>
31
- <ReportRendererProvider>
32
- {children}
33
- </ReportRendererProvider>
34
- </FlowResultContext.Provider>
35
- );
36
- });
37
-
38
- describe('SummaryHeader', () => {
39
- it('renders header content', async () => {
40
- const root = render(<SummaryHeader/>, {wrapper});
41
-
42
- const lhrCounts = root.getByText(/·/);
43
- expect(root.getByText('Summary')).toBeTruthy();
44
- expect(lhrCounts.textContent).toEqual(
45
- '2 navigation reports · 1 timespan reports · 1 snapshot reports'
46
- );
47
- });
48
- });
49
-
50
- describe('SummaryFlowStep', () => {
51
- it('renders navigation step', async () => {
52
- const root = render(<SummaryFlowStep
53
- lhr={flowResult.lhrs[0]}
54
- label="Navigation (1)"
55
- hashIndex={0}
56
- />, {wrapper});
57
-
58
- expect(root.getByTestId('SummaryNavigationHeader')).toBeTruthy();
59
-
60
- expect(root.getByText('Navigation (1)')).toBeTruthy();
61
-
62
- const screenshot = root.getByTestId('SummaryFlowStep__screenshot') as HTMLImageElement;
63
- expect(screenshot.src).toMatch(/data:image\/jpeg;base64/);
64
-
65
- const gauges = root.getAllByTestId('Gauge');
66
- expect(gauges).toHaveLength(4);
67
-
68
- const links = root.getAllByRole('link') as HTMLAnchorElement[];
69
- expect(links.map(a => a.href)).toEqual([
70
- 'file:///Users/example/report.html/#index=0',
71
- 'file:///Users/example/report.html/#index=0&anchor=performance',
72
- 'file:///Users/example/report.html/#index=0&anchor=accessibility',
73
- 'file:///Users/example/report.html/#index=0&anchor=best-practices',
74
- 'file:///Users/example/report.html/#index=0&anchor=seo',
75
- ]);
76
- });
77
-
78
- it('renders timespan step', async () => {
79
- const root = render(<SummaryFlowStep
80
- lhr={flowResult.lhrs[1]}
81
- label="Timespan (1)"
82
- hashIndex={1}
83
- />, {wrapper});
84
-
85
- expect(() => root.getByTestId('SummaryNavigationHeader')).toThrow();
86
-
87
- expect(root.getByText('Timespan (1)')).toBeTruthy();
88
-
89
- const screenshot = root.getByTestId('SummaryFlowStep__screenshot') as HTMLImageElement;
90
- expect(screenshot.src).toBeFalsy();
91
-
92
- expect(root.getByTestId('SummaryCategory__null'));
93
- const gauges = root.getAllByTestId('CategoryRatio');
94
- expect(gauges).toHaveLength(3);
95
-
96
- const links = root.getAllByRole('link') as HTMLAnchorElement[];
97
- expect(links.map(a => a.href)).toEqual([
98
- 'file:///Users/example/report.html/#index=1',
99
- 'file:///Users/example/report.html/#index=1&anchor=performance',
100
- // Accessibility is missing in timespan.
101
- 'file:///Users/example/report.html/#index=1&anchor=best-practices',
102
- 'file:///Users/example/report.html/#index=1&anchor=seo',
103
- ]);
104
- });
105
-
106
- it('renders snapshot step', async () => {
107
- const root = render(<SummaryFlowStep
108
- lhr={flowResult.lhrs[2]}
109
- label="Snapshot (1)"
110
- hashIndex={2}
111
- />, {wrapper});
112
-
113
- expect(() => root.getByTestId('SummaryNavigationHeader')).toThrow();
114
-
115
- expect(root.getByText('Snapshot (1)')).toBeTruthy();
116
-
117
- const screenshot = root.getByTestId('SummaryFlowStep__screenshot') as HTMLImageElement;
118
- expect(screenshot.src).toMatch(/data:image\/jpeg;base64/);
119
-
120
- const gauges = root.getAllByTestId('CategoryRatio');
121
- expect(gauges).toHaveLength(4);
122
-
123
- const links = root.getAllByRole('link') as HTMLAnchorElement[];
124
- expect(links.map(a => a.href)).toEqual([
125
- 'file:///Users/example/report.html/#index=2',
126
- 'file:///Users/example/report.html/#index=2&anchor=performance',
127
- 'file:///Users/example/report.html/#index=2&anchor=accessibility',
128
- 'file:///Users/example/report.html/#index=2&anchor=best-practices',
129
- 'file:///Users/example/report.html/#index=2&anchor=seo',
130
- ]);
131
- });
132
- });
@@ -1,109 +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 fs from 'fs';
8
- import {dirname} from 'path';
9
- import {fileURLToPath} from 'url';
10
-
11
- import {renderHook} from '@testing-library/preact-hooks';
12
- import {FunctionComponent} from 'preact';
13
- import {act} from 'preact/test-utils';
14
-
15
- import {FlowResultContext, useCurrentLhr, useDerivedStepNames} from '../src/util';
16
-
17
- const flowResult: LH.FlowResult = JSON.parse(
18
- fs.readFileSync(
19
- // eslint-disable-next-line max-len
20
- `${dirname(fileURLToPath(import.meta.url))}/../../lighthouse-core/test/fixtures/fraggle-rock/reports/sample-lhrs.json`,
21
- 'utf-8'
22
- )
23
- );
24
-
25
- let wrapper: FunctionComponent;
26
-
27
- beforeEach(() => {
28
- wrapper = ({children}) => (
29
- <FlowResultContext.Provider value={flowResult}>{children}</FlowResultContext.Provider>
30
- );
31
- });
32
-
33
- describe('useCurrentLhr', () => {
34
- it('gets current lhr index from url hash', () => {
35
- global.location.hash = '#index=1';
36
- const {result} = renderHook(() => useCurrentLhr(), {wrapper});
37
- expect(result.current).toEqual({
38
- index: 1,
39
- value: flowResult.lhrs[1],
40
- });
41
- });
42
-
43
- it('changes on navigation', async () => {
44
- global.location.hash = '#index=1';
45
- const render = renderHook(() => useCurrentLhr(), {wrapper});
46
-
47
- expect(render.result.current).toEqual({
48
- index: 1,
49
- value: flowResult.lhrs[1],
50
- });
51
-
52
- await act(() => {
53
- global.location.hash = '#index=2';
54
- });
55
- await render.waitForNextUpdate();
56
-
57
- expect(render.result.current).toEqual({
58
- index: 2,
59
- value: flowResult.lhrs[2],
60
- });
61
- });
62
-
63
- it('return null if lhr index is unset', () => {
64
- const {result} = renderHook(() => useCurrentLhr(), {wrapper});
65
- expect(result.current).toBeNull();
66
- });
67
-
68
- it('return null if lhr index is out of bounds', () => {
69
- global.location.hash = '#index=5';
70
- const {result} = renderHook(() => useCurrentLhr(), {wrapper});
71
- expect(result.current).toBeNull();
72
- });
73
-
74
- it('returns null for invalid value', () => {
75
- global.location.hash = '#index=OHNO';
76
- const {result} = renderHook(() => useCurrentLhr(), {wrapper});
77
- expect(result.current).toBeNull();
78
- });
79
- });
80
-
81
- describe('useDerivedStepNames', () => {
82
- it('counts up for each mode', () => {
83
- const {result} = renderHook(() => useDerivedStepNames(), {wrapper});
84
- expect(result.current).toEqual([
85
- 'Navigation report (www.mikescerealshack.co/)',
86
- 'Timespan report (www.mikescerealshack.co/search)',
87
- 'Snapshot report (www.mikescerealshack.co/search)',
88
- 'Navigation report (www.mikescerealshack.co/corrections)',
89
- ]);
90
- });
91
-
92
- it('enumerates if multiple in same group', () => {
93
- const lhrs = flowResult.lhrs;
94
- lhrs[3] = lhrs[2];
95
- const newFlowResult = {lhrs};
96
- const wrapper: FunctionComponent = ({children}) => (
97
- <FlowResultContext.Provider value={newFlowResult}>{children}</FlowResultContext.Provider>
98
- );
99
-
100
- const {result} = renderHook(() => useDerivedStepNames(), {wrapper});
101
-
102
- expect(result.current).toEqual([
103
- 'Navigation report (www.mikescerealshack.co/)',
104
- 'Timespan report (www.mikescerealshack.co/search)',
105
- 'Snapshot report 1 (www.mikescerealshack.co/search)',
106
- 'Snapshot report 2 (www.mikescerealshack.co/search)',
107
- ]);
108
- });
109
- });
@@ -1,39 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "composite": true,
4
- "outDir": "../.tmp/tsbuildinfo/flow-report",
5
- "emitDeclarationOnly": false,
6
- "declarationMap": true,
7
-
8
- // Limit to base JS and DOM defs.
9
- "lib": ["es2020", "dom", "dom.iterable"],
10
- // Selectively include types from node_modules.
11
- "types": ["node", "jest"],
12
- "target": "es2020",
13
- "module": "es2020",
14
- "moduleResolution": "node",
15
- "esModuleInterop": true,
16
-
17
- "allowJs": true,
18
- "checkJs": true,
19
- "strict": true,
20
- // TODO: remove the next line to be fully `strict`.
21
- "useUnknownInCatchVariables": false,
22
-
23
- // "listFiles": true,
24
- // "noErrorTruncation": true,
25
- "extendedDiagnostics": true,
26
-
27
- "jsx": "react-jsx",
28
- "jsxImportSource": "preact",
29
- },
30
- "include": [
31
- "**/*.ts",
32
- "**/*.tsx",
33
- "./types",
34
- ],
35
- "references": [
36
- {"path": "../types/lhr/"},
37
- {"path": "../report"},
38
- ],
39
- }
@@ -1,27 +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 FlowResult_ from '../../types/lhr/flow';
8
- import * as Settings from '../../types/lhr/settings';
9
-
10
- // Import to augment querySelector/querySelectorAll with stricter type checking.
11
- import '../../types/query-selector';
12
- import '../../report/types/html-renderer';
13
-
14
- declare global {
15
- interface Window {
16
- __LIGHTHOUSE_FLOW_JSON__: FlowResult_;
17
- __initLighthouseFlowReport__: () => void;
18
- }
19
-
20
- // Expose global types in LH namespace.
21
- module LH {
22
- export type FlowResult = FlowResult_;
23
- export type ConfigSettings = Settings.ConfigSettings;
24
- }
25
- }
26
-
27
- export {};
@@ -1,83 +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
- const Audit = require('./audit.js');
9
- const i18n = require('../lib/i18n/i18n.js');
10
-
11
- const UIStrings = {
12
- /** Title of a Lighthouse audit that provides detail on whether the largest above-the-fold image was loaded with sufficient priority. This descriptive title is shown to users when the image was loaded properly. */
13
- title: 'Largest Contentful Paint image was not lazily loaded',
14
- /** Title of a Lighthouse audit that provides detail on whether the largest above-the-fold image was loaded with sufficient priority. This descriptive title is shown to users when the image was loaded inefficiently using the `loading=lazy` attribute. */
15
- failureTitle: 'Largest Contentful Paint image was lazily loaded',
16
- /** Description of a Lighthouse audit that tells the user why the advice is important. This is displayed after a user expands the section to see more. No character length limits. */
17
- description: 'Above-the-fold images that are lazily loaded render later in the page lifecycle, which can delay the largest contentful paint. [Learn more](https://web.dev/lcp-lazy-loading/).',
18
- };
19
-
20
- const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
21
-
22
- class LargestContentfulPaintLazyLoaded extends Audit {
23
- /**
24
- * @return {LH.Audit.Meta}
25
- */
26
- static get meta() {
27
- return {
28
- id: 'lcp-lazy-loaded',
29
- title: str_(UIStrings.title),
30
- description: str_(UIStrings.description),
31
- supportedModes: ['navigation'],
32
- requiredArtifacts: ['TraceElements', 'ViewportDimensions', 'ImageElements'],
33
- };
34
- }
35
-
36
- /**
37
- * @param {LH.Artifacts.ImageElement} image
38
- * @param {LH.Artifacts.ViewportDimensions} viewportDimensions
39
- * @return {boolean}
40
- */
41
- static isImageInViewport(image, viewportDimensions) {
42
- const imageTop = image.clientRect.top;
43
- const viewportHeight = viewportDimensions.innerHeight;
44
- return imageTop < viewportHeight;
45
- }
46
-
47
- /**
48
- * @param {LH.Artifacts} artifacts
49
- * @return {LH.Audit.Product}
50
- */
51
- static audit(artifacts) {
52
- const lcpElement = artifacts.TraceElements
53
- .find(element => element.traceEventType === 'largest-contentful-paint');
54
- const lcpElementImage = lcpElement ? artifacts.ImageElements.find(elem => {
55
- return elem.node.devtoolsNodePath === lcpElement.node.devtoolsNodePath;
56
- }) : undefined;
57
-
58
-
59
- if (!lcpElementImage ||
60
- !this.isImageInViewport(lcpElementImage, artifacts.ViewportDimensions)) {
61
- return {score: 1, notApplicable: true};
62
- }
63
-
64
- /** @type {LH.Audit.Details.Table['headings']} */
65
- const headings = [
66
- {key: 'node', itemType: 'node', text: str_(i18n.UIStrings.columnElement)},
67
- ];
68
-
69
- const details = Audit.makeTableDetails(headings, [
70
- {
71
- node: Audit.makeNodeItem(lcpElementImage.node),
72
- },
73
- ]);
74
-
75
- return {
76
- score: lcpElementImage.loading === 'lazy' ? 0 : 1,
77
- details,
78
- };
79
- }
80
- }
81
-
82
- module.exports = LargestContentfulPaintLazyLoaded;
83
- module.exports.UIStrings = UIStrings;
@@ -1,33 +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
- /**
9
- * eslint does not support ESM rc files, so this must be a .cjs file.
10
- * @see https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats
11
- * @see https://github.com/eslint/eslint/issues/13481
12
- */
13
-
14
- module.exports = {
15
- env: {
16
- browser: true,
17
- },
18
- rules: {
19
- // TODO(esmodules): move to root eslint when all code is ESM
20
- // or when this is resolved: https://github.com/import-js/eslint-plugin-import/issues/2214
21
- 'import/order': [2, {
22
- 'groups': [
23
- 'builtin',
24
- 'external',
25
- ['sibling', 'parent'],
26
- 'index',
27
- 'object',
28
- 'type',
29
- ],
30
- 'newlines-between': 'always',
31
- }],
32
- },
33
- };
@@ -1,9 +0,0 @@
1
- # Lighthouse Report Generator
2
-
3
- ## Overview
4
-
5
- Lighthouse's report generator is the entry point for creating reports from an **LHR** (Lighthouse Result object). It returns results as HTML, JSON, and CSV.
6
-
7
- It runs natively in Node.js but can run in the browser after a compile step is applied during our bundling pipeline. That compile step uses `brfs`, which takes any `fs.readFileSync()` calls and replaces them with the stringified file content.
8
-
9
- Because it's shared between core and the report, dependencies (both code and types) should be kept minimal.
@@ -1,20 +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
- const fs = require('fs');
9
-
10
- /* eslint-disable max-len */
11
- const FLOW_REPORT_TEMPLATE = fs.readFileSync(`${__dirname}/../../flow-report/assets/standalone-flow-template.html`, 'utf8');
12
- const FLOW_REPORT_CSS = fs.readFileSync(`${__dirname}/../../flow-report/assets/styles.css`, 'utf8');
13
- const FLOW_REPORT_JAVASCRIPT = fs.readFileSync(`${__dirname}/../../dist/report/flow.js`, 'utf8');
14
- /* eslint-enable max-len */
15
-
16
- module.exports = {
17
- FLOW_REPORT_TEMPLATE,
18
- FLOW_REPORT_CSS,
19
- FLOW_REPORT_JAVASCRIPT,
20
- };
@@ -1,4 +0,0 @@
1
- {
2
- "type": "commonjs",
3
- "//": "Preserve commonjs in this directory. Temporary file until converted to type: module"
4
- }
@@ -1,28 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "composite": true,
4
- "outDir": "../../.tmp/tsbuildinfo/report/generator",
5
- "emitDeclarationOnly": true,
6
- "declarationMap": true,
7
-
8
- "target": "ES2020",
9
- "module": "commonjs",
10
- "moduleResolution": "node",
11
-
12
- "allowJs": true,
13
- "checkJs": true,
14
- "strict": true,
15
- // TODO: remove the next line to be fully `strict`.
16
- "useUnknownInCatchVariables": false,
17
-
18
- // "listFiles": true,
19
- // "noErrorTruncation": true,
20
- "extendedDiagnostics": true,
21
- },
22
- "references": [
23
- {"path": "../../types/lhr/"},
24
- ],
25
- "include": [
26
- "**/*.js",
27
- ],
28
- }