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
@@ -6,7 +6,6 @@
6
6
  'use strict';
7
7
 
8
8
  import {strict as assert} from 'assert';
9
-
10
9
  import {Util} from '../../renderer/util.js';
11
10
  import {I18n} from '../../renderer/i18n.js';
12
11
  import sampleResult from '../../../lighthouse-core/test/results/sample_v2.json';
@@ -7,12 +7,10 @@
7
7
 
8
8
  const assert = require('assert').strict;
9
9
  const fs = require('fs');
10
-
10
+ const ReportGenerator = require('../report-generator.js');
11
+ const sampleResults = require('../../lighthouse-core/test/results/sample_v2.json');
11
12
  const csvValidator = require('csv-validator');
12
13
 
13
- const ReportGenerator = require('../../generator/report-generator.js');
14
- const sampleResults = require('../../../lighthouse-core/test/results/sample_v2.json');
15
-
16
14
  /* eslint-env jest */
17
15
 
18
16
  describe('ReportGenerator', () => {
@@ -95,11 +93,11 @@ describe('ReportGenerator', () => {
95
93
  const lines = csvOutput.split('\n');
96
94
  expect(lines.length).toBeGreaterThan(100);
97
95
  expect(lines.slice(0, 3).join('\n')).toMatchInlineSnapshot(`
98
- "requestedUrl,finalUrl,category,name,title,type,score
99
- \\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"Performance\\",\\"performance-score\\",\\"Overall Performance Category Score\\",\\"numeric\\",\\"0.26\\"
100
- \\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"Performance\\",\\"first-contentful-paint\\",\\"First Contentful Paint\\",\\"numeric\\",\\"0.02\\"
101
- "
102
- `);
96
+ "requestedUrl,finalUrl,category,name,title,type,score
97
+ \\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"Performance\\",\\"performance-score\\",\\"Overall Performance Category Score\\",\\"numeric\\",\\"0.57\\"
98
+ \\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"Performance\\",\\"first-contentful-paint\\",\\"First Contentful Paint\\",\\"numeric\\",\\"0.24\\"
99
+ "
100
+ `);
103
101
 
104
102
  try {
105
103
  await csvValidator(path, headers);
@@ -44,34 +44,33 @@ describe('installabilityErrors', () => {
44
44
 
45
45
  it('should notify us if something changed', () => {
46
46
  expect(chromiumErrorIds).toMatchInlineSnapshot(`
47
- Array [
48
- "already-installed",
49
- "cannot-download-icon",
50
- "ids-do-not-match",
51
- "in-incognito",
52
- "manifest-display-not-supported",
53
- "manifest-display-override-not-supported",
54
- "manifest-empty",
55
- "manifest-location-changed",
56
- "manifest-missing-name-or-short-name",
57
- "manifest-missing-suitable-icon",
58
- "no-acceptable-icon",
59
- "no-icon-available",
60
- "no-id-specified",
61
- "no-manifest",
62
- "no-matching-service-worker",
63
- "no-url-for-service-worker",
64
- "not-from-secure-origin",
65
- "not-offline-capable",
66
- "pipeline-restarted",
67
- "platform-not-supported-on-android",
68
- "prefer-related-applications",
69
- "prefer-related-applications-only-beta-stable",
70
- "start-url-not-valid",
71
- "url-not-supported-for-webapk",
72
- "warn-not-offline-capable",
73
- ]
74
- `);
47
+ Array [
48
+ "already-installed",
49
+ "cannot-download-icon",
50
+ "ids-do-not-match",
51
+ "in-incognito",
52
+ "manifest-display-not-supported",
53
+ "manifest-display-override-not-supported",
54
+ "manifest-empty",
55
+ "manifest-location-changed",
56
+ "manifest-missing-name-or-short-name",
57
+ "manifest-missing-suitable-icon",
58
+ "no-acceptable-icon",
59
+ "no-icon-available",
60
+ "no-id-specified",
61
+ "no-manifest",
62
+ "no-matching-service-worker",
63
+ "no-url-for-service-worker",
64
+ "not-from-secure-origin",
65
+ "not-offline-capable",
66
+ "platform-not-supported-on-android",
67
+ "prefer-related-applications",
68
+ "prefer-related-applications-only-beta-stable",
69
+ "start-url-not-valid",
70
+ "url-not-supported-for-webapk",
71
+ "warn-not-offline-capable",
72
+ ]
73
+ `);
75
74
  });
76
75
 
77
76
  it('are each handled explicitly in the gatherer', () => {
@@ -129,8 +129,6 @@
129
129
  {"id":"npm:mustache:20110814","severity":"medium","semver":{"vulnerable":["< 0.3.1"]}}
130
130
  ],
131
131
  "next":[
132
- {"id":"SNYK-JS-NEXT-1577139","severity":"medium","semver":{"vulnerable":[">=10.0.0 <11.1.1"]}},
133
- {"id":"SNYK-JS-NEXT-1540422","severity":"medium","semver":{"vulnerable":["<11.1.0"]}},
134
132
  {"id":"SNYK-JS-NEXT-1063481","severity":"medium","semver":{"vulnerable":[">=9.5.0 <9.5.4"]}},
135
133
  {"id":"SNYK-JS-NEXT-571938","severity":"high","semver":{"vulnerable":["<5.1.0"]}},
136
134
  {"id":"SNYK-JS-NEXT-561584","severity":"medium","semver":{"vulnerable":["<9.3.2"]}},
package/tsconfig.json CHANGED
@@ -6,41 +6,23 @@
6
6
  "allowJs": true,
7
7
  "checkJs": true,
8
8
  "strict": true,
9
- // TODO: remove the next line to be fully `strict`.
10
- "useUnknownInCatchVariables": false,
11
9
  // "listFiles": true,
12
10
  // "noErrorTruncation": true,
13
11
 
14
12
  "resolveJsonModule": true,
15
- "diagnostics": true,
16
- "composite": true,
17
- "outDir": ".tmp/tsbuildinfo/",
13
+ "diagnostics": true
18
14
  },
19
15
  "include": [
20
- "root.js",
21
16
  "lighthouse-cli/**/*.js",
22
17
  "lighthouse-core/**/*.js",
18
+ "report/**/*.js",
23
19
  "clients/**/*.js",
24
20
  "build/**/*.js",
25
21
  "./types/**/*.d.ts",
26
22
  "eslint-local-rules.js",
27
-
28
- // TODO(esmodules): JSON files included via resolveJsonModule. Removable on the switch to ES Modules.
29
- "package.json",
30
- "lighthouse-core/lib/i18n/locales/en-US.json",
31
- "lighthouse-core/test/results/sample_v2.json",
32
- "lighthouse-core/lib/sd-validation/assets/*.json",
33
- "lighthouse-core/test/fixtures/unresolved-perflog.json",
34
- "lighthouse-core/test/fixtures/traces/lcp-m78.devtools.log.json",
35
- "third-party/snyk/snapshot.json",
36
- "lighthouse-core/audits/byte-efficiency/polyfill-graph-data.json",
37
- ],
38
- "references": [
39
- {"path": "./types/lhr/"},
40
- {"path": "./report/"},
41
- {"path": "./report/generator/"},
42
23
  ],
43
24
  "exclude": [
25
+ "lighthouse-core/lib/cdt",
44
26
  "lighthouse-core/test/audits/**/*.js",
45
27
  "lighthouse-core/test/fixtures/**/*.js",
46
28
  "lighthouse-core/test/computed/**/*.js",
@@ -49,6 +31,7 @@
49
31
  "lighthouse-core/scripts/legacy-javascript/variants",
50
32
  "lighthouse-core/test/chromium-web-tests/webtests",
51
33
  // These test files require further changes before they can be type checked.
34
+ "report/test/**/*.js",
52
35
  "lighthouse-core/test/config/budget-test.js",
53
36
  "lighthouse-core/test/config/config-helpers-test.js",
54
37
  "lighthouse-core/test/config/config-plugin-test.js",
@@ -120,9 +103,7 @@
120
103
  "lighthouse-core/test/scripts/i18n/collect-strings-test.js",
121
104
  ],
122
105
  "files": [
123
- // Opt-in to typechecking for some core tests and test-support files.
106
+ // Opt-in to typechecking for some core tests.
124
107
  "lighthouse-core/test/audits/script-treemap-data-test.js",
125
- "lighthouse-cli/test/fixtures/static-server.js",
126
- "lighthouse-core/test/fixtures/config-plugins/lighthouse-plugin-simple/plugin-simple.js",
127
108
  ],
128
109
  }
@@ -14,11 +14,9 @@ import ArbitraryEqualityMap = require('../lighthouse-core/lib/arbitrary-equality
14
14
 
15
15
  type _TaskNode = import('../lighthouse-core/lib/tracehouse/main-thread-tasks.js').TaskNode;
16
16
 
17
- import AuditDetails from './lhr/audit-details'
18
17
  import Config from './config';
19
18
  import Gatherer from './gatherer';
20
- import {IcuMessage} from './lhr/i18n';
21
- import LHResult from './lhr/lhr'
19
+ import {IcuMessage} from './i18n';
22
20
  import Protocol from './protocol';
23
21
 
24
22
  export interface Artifacts extends BaseArtifacts, GathererArtifacts {}
@@ -534,7 +532,14 @@ declare module Artifacts {
534
532
  };
535
533
  }
536
534
 
537
- type Rect = AuditDetails.Rect;
535
+ interface Rect {
536
+ width: number;
537
+ height: number;
538
+ top: number;
539
+ right: number;
540
+ bottom: number;
541
+ left: number;
542
+ }
538
543
 
539
544
  interface TapTarget {
540
545
  node: NodeDetails;
@@ -593,7 +598,15 @@ declare module Artifacts {
593
598
  }[];
594
599
  }
595
600
 
596
- type MeasureEntry = LHResult.MeasureEntry;
601
+ interface MeasureEntry {
602
+ // From PerformanceEntry
603
+ readonly duration: number;
604
+ readonly entryType: string;
605
+ readonly name: string;
606
+ readonly startTime: number;
607
+ /** Whether timing entry was collected during artifact gathering. */
608
+ gather?: boolean;
609
+ }
597
610
 
598
611
  interface MetricComputationDataInput {
599
612
  devtoolsLog: DevtoolsLog;
@@ -6,6 +6,7 @@
6
6
 
7
7
  import {IcuMessage} from './i18n';
8
8
  import Treemap from './treemap';
9
+ import {Artifacts} from './artifacts';
9
10
 
10
11
  type Details =
11
12
  Details.CriticalRequestChain |
@@ -82,24 +83,8 @@ declare module Details {
82
83
  * and the locations of interesting nodes.
83
84
  * Used by element screenshots renderer.
84
85
  */
85
- interface FullPageScreenshot {
86
+ interface FullPageScreenshot extends Artifacts.FullPageScreenshot {
86
87
  type: 'full-page-screenshot';
87
- screenshot: {
88
- /** Base64 image data URL. */
89
- data: string;
90
- width: number;
91
- height: number;
92
- };
93
- nodes: Record<string, Rect>;
94
- }
95
-
96
- interface Rect {
97
- width: number;
98
- height: number;
99
- top: number;
100
- right: number;
101
- bottom: number;
102
- left: number;
103
88
  }
104
89
 
105
90
  interface Table {
@@ -241,7 +226,7 @@ declare module Details {
241
226
  lhId?: string;
242
227
  path?: string;
243
228
  selector?: string;
244
- boundingRect?: Rect;
229
+ boundingRect?: Artifacts.Rect;
245
230
  /** An HTML snippet used to identify the node. */
246
231
  snippet?: string;
247
232
  /** A human-friendly text descriptor that's used to identify the node more quickly. */
package/types/audit.d.ts CHANGED
@@ -6,17 +6,13 @@
6
6
 
7
7
  import ArbitraryEqualityMap = require('../lighthouse-core/lib/arbitrary-equality-map.js');
8
8
  import {Artifacts} from './artifacts';
9
- import AuditDetails from './lhr/audit-details';
9
+ import AuditDetails from './audit-details';
10
10
  import Config from './config';
11
11
  import Gatherer from './gatherer';
12
- import {FormattedIcu, IcuMessage} from './lhr/i18n';
13
- import * as AuditResult from './lhr/audit-result';
12
+ import {FormattedIcu, IcuMessage} from './i18n';
14
13
 
15
14
  declare module Audit {
16
15
  export import Details = AuditDetails;
17
- export type Result = AuditResult.Result;
18
- export type ScoreDisplayMode = AuditResult.ScoreDisplayMode;
19
- export type ScoreDisplayModes = AuditResult.ScoreDisplayModes;
20
16
 
21
17
  type Context = Immutable<{
22
18
  /** audit options */
@@ -35,6 +31,23 @@ declare module Audit {
35
31
  median: number;
36
32
  }
37
33
 
34
+ interface ScoreDisplayModes {
35
+ /** Scores of 0-1 (map to displayed scores of 0-100). */
36
+ NUMERIC: 'numeric';
37
+ /** Pass/fail audit (0 and 1 are only possible scores). */
38
+ BINARY: 'binary';
39
+ /** The audit exists only to tell you to review something yourself. Score is null and should be ignored. */
40
+ MANUAL: 'manual';
41
+ /** The audit is an FYI only, and can't be interpreted as pass/fail. Score is null and should be ignored. */
42
+ INFORMATIVE: 'informative';
43
+ /** The audit turned out to not apply to the page. Score is null and should be ignored. */
44
+ NOT_APPLICABLE: 'notApplicable';
45
+ /** There was an error while running the audit (check `errorMessage` for details). Score is null and should be ignored. */
46
+ ERROR: 'error';
47
+ }
48
+
49
+ type ScoreDisplayMode = Audit.ScoreDisplayModes[keyof Audit.ScoreDisplayModes];
50
+
38
51
  interface Meta {
39
52
  /** The string identifier of the audit, in kebab case. */
40
53
  id: string;
@@ -49,7 +62,7 @@ declare module Audit {
49
62
  /** A list of the members of LH.Artifacts that augment the audit, but aren't necessary. For internal use only with experimental-config. */
50
63
  __internalOptionalArtifacts?: Array<keyof Artifacts>;
51
64
  /** A string identifying how the score should be interpreted for display. */
52
- scoreDisplayMode?: AuditResult.ScoreDisplayMode;
65
+ scoreDisplayMode?: Audit.ScoreDisplayMode;
53
66
  /** A list of gather modes that this audit is applicable to. */
54
67
  supportedModes?: Gatherer.GatherMode[],
55
68
  }
@@ -98,6 +111,44 @@ declare module Audit {
98
111
  /** Type returned by Audit.audit(). Only score is required. */
99
112
  type Product = NonNumericProduct | NumericProduct;
100
113
 
114
+ /* Audit result returned in Lighthouse report. All audits offer a description and score of 0-1. */
115
+ interface Result {
116
+ displayValue?: string;
117
+ /** An explanation of why the audit failed on the test page. */
118
+ explanation?: string;
119
+ /** Error message from any exception thrown while running this audit. */
120
+ errorMessage?: string;
121
+ warnings?: string[];
122
+ /** The scored value of the audit, provided in the range `0-1`, or null if `scoreDisplayMode` indicates not scored. */
123
+ score: number|null;
124
+ /**
125
+ * A string identifying how the score should be interpreted:
126
+ * - 'binary': pass/fail audit (0 and 1 are only possible scores).
127
+ * - 'numeric': scores of 0-1 (map to displayed scores of 0-100).
128
+ * - 'informative': the audit is an FYI only, and can't be interpreted as pass/fail. Score is null and should be ignored.
129
+ * - 'notApplicable': the audit turned out to not apply to the page. Score is null and should be ignored.
130
+ * - 'manual': The audit exists only to tell you to review something yourself. Score is null and should be ignored.
131
+ * - 'error': There was an error while running the audit (check `errorMessage` for details). Score is null and should be ignored.
132
+ */
133
+ scoreDisplayMode: ScoreDisplayMode;
134
+ /** Short, user-visible title for the audit. The text can change depending on if the audit passed or failed. */
135
+ title: string;
136
+ /** The string identifier of the audit, in kebab case. */
137
+ id: string;
138
+ /** A more detailed description that describes why the audit is important and links to Lighthouse documentation on the audit; markdown links supported. */
139
+ description: string;
140
+ /** 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. */
141
+ numericValue?: number;
142
+ /** The unit of `numericValue`, used when the consumer wishes to convert numericValue to a display string. */
143
+ numericUnit?: string;
144
+ /** 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. */
145
+ details?: FormattedIcu<AuditDetails>;
146
+ }
147
+
148
+ interface Results {
149
+ [metric: string]: Result;
150
+ }
151
+
101
152
  type MultiCheckAuditP1 = Partial<Record<Artifacts.ManifestValueCheckID, boolean>>;
102
153
  type MultiCheckAuditP2 = Partial<Artifacts.ManifestValues>;
103
154
  interface MultiCheckAuditP3 {
File without changes
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @license Copyright 2020 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
+ declare module 'bundle-phobia-cli' {
8
+ interface Assets {
9
+ gzip: number;
10
+ name: string;
11
+ size: number;
12
+ type: string;
13
+ }
14
+
15
+ interface DependencySize {
16
+ approximateSize: number;
17
+ name: string;
18
+ }
19
+
20
+ interface BundlePhobiaLibrary {
21
+ assets: Assets[];
22
+ dependencyCount: number;
23
+ dependencySizes: DependencySize[];
24
+ description: string;
25
+ gzip: number;
26
+ hasJSModule: boolean;
27
+ hasJSNext: boolean;
28
+ hasSideEffects: boolean;
29
+ name: string;
30
+ repository: string;
31
+ scoped: boolean;
32
+ size: number;
33
+ version: string;
34
+ }
35
+
36
+ export namespace fetchPackageStats {
37
+ export function getPackageVersionList(packageName: string, limit: number): string[];
38
+ export function fetchPackageStats(packageName: string): Array<BundlePhobiaLibrary | undefined>;
39
+ }
40
+ }
package/types/config.d.ts CHANGED
@@ -6,9 +6,9 @@
6
6
  */
7
7
 
8
8
  import Audit = require('../lighthouse-core/audits/audit.js');
9
- import {SharedFlagsSettings, ConfigSettings} from './lhr/settings';
9
+ import {ScreenEmulationSettings, SharedFlagsSettings, ThrottlingSettings} from './externs';
10
10
  import Gatherer from './gatherer';
11
- import {IcuMessage} from './lhr/i18n';
11
+ import {IcuMessage} from './i18n';
12
12
 
13
13
  interface ClassOf<T> {
14
14
  new (): T;
@@ -161,7 +161,10 @@ declare module Config {
161
161
  relevantAudits?: string[];
162
162
  }
163
163
 
164
- type Settings = ConfigSettings;
164
+ interface Settings extends Required<SharedFlagsSettings> {
165
+ throttling: Required<ThrottlingSettings>;
166
+ screenEmulation: ScreenEmulationSettings;
167
+ }
165
168
 
166
169
  interface Pass extends Required<PassJson> {
167
170
  gatherers: GathererDefn[];
@@ -227,6 +230,8 @@ declare module Config {
227
230
  groups?: Record<string, Config.GroupJson>;
228
231
  }
229
232
 
233
+ type MergeOptionsOfItems = <T extends {path?: string, options: Record<string, any>}>(items: T[]) => T[];
234
+
230
235
  type Merge = {
231
236
  <T extends Record<string, any>, U extends Record<string, any>>(base: T|null|undefined, extension: U, overwriteArrays?: boolean): T & U;
232
237
  <T extends Array<any>, U extends Array<any>>(base: T|null|undefined, extension: T, overwriteArrays?: boolean): T & U;
@@ -4,9 +4,31 @@
4
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
5
  */
6
6
 
7
+ import {ParseSelectorToTagNames} from 'typed-query-selector/parser';
8
+ import Crdp from 'devtools-protocol/types/protocol';
9
+
7
10
  import {Artifacts} from './artifacts';
8
- import LHResult from './lhr/lhr';
9
- import {SharedFlagsSettings, OutputMode} from './lhr/settings';
11
+ import Budget from './budget';
12
+ import {Locale} from './i18n';
13
+ import LHResult from './lhr';
14
+
15
+ /** Merge properties of the types in union `T`. Where properties overlap, property types becomes the union of the two (or more) possible types. */
16
+ type MergeTypes<T> = {
17
+ [K in (T extends unknown ? keyof T : never)]: T extends Record<K, infer U> ? U : never;
18
+ };
19
+
20
+ // Helper types for strict querySelector/querySelectorAll that includes the overlap
21
+ // between HTML and SVG node names (<a>, <script>, etc).
22
+ // see https://github.com/GoogleChrome/lighthouse/issues/12011
23
+ type HtmlAndSvgElementTagNameMap = MergeTypes<HTMLElementTagNameMap|SVGElementTagNameMap> & {
24
+ // Fall back to Element (base of HTMLElement and SVGElement) if no specific tag name matches.
25
+ [id: string]: Element;
26
+ };
27
+ type QuerySelectorParse<I extends string> = ParseSelectorToTagNames<I> extends infer TagNames ?
28
+ TagNames extends Array<string> ?
29
+ HtmlAndSvgElementTagNameMap[TagNames[number]] :
30
+ Element: // Fall back for queries typed-query-selector fails to parse, e.g. `'[alt], [aria-label]'`.
31
+ never;
10
32
 
11
33
  declare global {
12
34
  // Augment Intl to include
@@ -30,13 +52,16 @@ declare global {
30
52
  __lighthouseNodesDontTouchOrAllVarianceGoesAway: Map<Element, string>;
31
53
  __lighthouseExecutionContextId?: number;
32
54
 
33
- /** Injected into the page when the `--debug` flag is used. */
34
- continueLighthouseRun(): void;
35
-
36
55
  // Not defined in tsc yet: https://github.com/microsoft/TypeScript/issues/40807
37
56
  requestIdleCallback(callback: (deadline: {didTimeout: boolean, timeRemaining: () => DOMHighResTimeStamp}) => void, options?: {timeout: number}): number;
38
57
  }
39
58
 
59
+ // Stricter querySelector/querySelectorAll using typed-query-selector.
60
+ interface ParentNode {
61
+ querySelector<S extends string>(selector: S): QuerySelectorParse<S> | null;
62
+ querySelectorAll<S extends string>(selector: S): NodeListOf<QuerySelectorParse<S>>;
63
+ }
64
+
40
65
  /** Make properties K in T optional. */
41
66
  type MakeOptional<T, K extends keyof T> = {
42
67
  [P in Exclude<keyof T, K>]: T[P]
@@ -120,6 +145,95 @@ declare global {
120
145
  }
121
146
  }
122
147
 
148
+ /** Simulation settings that control the amount of network & cpu throttling in the run. */
149
+ export interface ThrottlingSettings {
150
+ /** The round trip time in milliseconds. */
151
+ rttMs?: number;
152
+ /** The network throughput in kilobits per second. */
153
+ throughputKbps?: number;
154
+ // devtools settings
155
+ /** The network request latency in milliseconds. */
156
+ requestLatencyMs?: number;
157
+ /** The network download throughput in kilobits per second. */
158
+ downloadThroughputKbps?: number;
159
+ /** The network upload throughput in kilobits per second. */
160
+ uploadThroughputKbps?: number;
161
+ // used by both
162
+ /** The amount of slowdown applied to the cpu (1/<cpuSlowdownMultiplier>). */
163
+ cpuSlowdownMultiplier?: number
164
+ }
165
+
166
+ export interface PrecomputedLanternData {
167
+ additionalRttByOrigin: {[origin: string]: number};
168
+ serverResponseTimeByOrigin: {[origin: string]: number};
169
+ }
170
+
171
+ export type OutputMode = 'json' | 'html' | 'csv';
172
+
173
+ export type ScreenEmulationSettings = {
174
+ /** Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override. */
175
+ width: number;
176
+ /** Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override. */
177
+ height: number;
178
+ /** Overriding device scale factor value. 0 disables the override. */
179
+ deviceScaleFactor: number;
180
+ /** Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more. */
181
+ mobile: boolean;
182
+ /** Whether screen emulation is disabled. If true, the other emulation settings are ignored. */
183
+ disabled: boolean;
184
+ };
185
+
186
+ /**
187
+ * Options that are found in both the flags used by the Lighthouse module
188
+ * interface and the Config's `settings` object.
189
+ */
190
+ export interface SharedFlagsSettings {
191
+ /** The type(s) of report output to be produced. */
192
+ output?: OutputMode|OutputMode[];
193
+ /** The locale to use for the output. */
194
+ locale?: Locale;
195
+ /** 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. */
196
+ maxWaitForFcp?: number;
197
+ /** The maximum amount of time to wait for a page to load, in ms. */
198
+ maxWaitForLoad?: number;
199
+ /** List of URL patterns to block. */
200
+ blockedUrlPatterns?: string[] | null;
201
+ /** Comma-delimited list of trace categories to include. */
202
+ additionalTraceCategories?: string | null;
203
+ /** Flag indicating the run should only audit. */
204
+ auditMode?: boolean | string;
205
+ /** Flag indicating the run should only gather. */
206
+ gatherMode?: boolean | string;
207
+ /** Flag indicating that the browser storage should not be reset for the audit. */
208
+ disableStorageReset?: boolean;
209
+
210
+ /** 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. */
211
+ formFactor?: 'mobile'|'desktop';
212
+ /** 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. */
213
+ screenEmulation?: Partial<ScreenEmulationSettings>;
214
+ /** User Agent string to apply, `false` to not change the host's UA string, or `true` to use Lighthouse's default UA string. */
215
+ emulatedUserAgent?: string | boolean;
216
+
217
+ /** The method used to throttle the network. */
218
+ throttlingMethod?: 'devtools'|'simulate'|'provided';
219
+ /** The throttling config settings. */
220
+ throttling?: ThrottlingSettings;
221
+ /** If present, the run should only conduct this list of audits. */
222
+ onlyAudits?: string[] | null;
223
+ /** If present, the run should only conduct this list of categories. */
224
+ onlyCategories?: string[] | null;
225
+ /** If present, the run should skip this list of audits. */
226
+ skipAudits?: string[] | null;
227
+ /** List of extra HTTP Headers to include. */
228
+ extraHeaders?: Crdp.Network.Headers | null; // See extraHeaders TODO in bin.js
229
+ /** How Lighthouse was run, e.g. from the Chrome extension or from the npm module */
230
+ channel?: string
231
+ /** Precomputed lantern estimates to use instead of observed analysis. */
232
+ precomputedLanternData?: PrecomputedLanternData | null;
233
+ /** The budget.json object for LightWallet. */
234
+ budgets?: Array<Budget> | null;
235
+ }
236
+
123
237
  /**
124
238
  * Extends the flags in SharedFlagsSettings with flags used to configure the
125
239
  * Lighthouse module but will not end up in the Config settings.
@@ -14,8 +14,7 @@ import ArbitraryEqualityMap = require('../lighthouse-core/lib/arbitrary-equality
14
14
 
15
15
  import {Artifacts, BaseArtifacts, GathererArtifacts} from './artifacts';
16
16
  import Config from './config';
17
- import {IcuMessage} from './lhr/i18n';
18
- import Result from './lhr/lhr';
17
+ import {IcuMessage} from './i18n';
19
18
  import Protocol from './protocol';
20
19
  import {Trace, DevtoolsLog} from './artifacts';
21
20
 
@@ -78,7 +77,7 @@ declare module Gatherer {
78
77
  type PhaseResultNonPromise = void | GathererArtifacts[keyof GathererArtifacts];
79
78
  type PhaseResult = PhaseResultNonPromise | Promise<PhaseResultNonPromise>
80
79
 
81
- type GatherMode = Result.GatherMode;
80
+ type GatherMode = 'snapshot'|'timespan'|'navigation';
82
81
 
83
82
  type DefaultDependenciesKey = '__none__'
84
83
  type DependencyKey = keyof GathererArtifacts | DefaultDependenciesKey