lighthouse 9.5.0-dev.20220607 → 9.6.2
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.
- package/dist/report/bundle.esm.js +467 -520
- package/dist/report/flow.js +22 -22
- package/dist/report/standalone.js +19 -19
- package/flow-report/src/summary/category.tsx +1 -1
- package/flow-report/src/topbar.tsx +2 -10
- package/flow-report/src/util.ts +1 -1
- package/flow-report/test/topbar-test.tsx +8 -7
- package/jest.config.js +1 -1
- package/lighthouse-cli/.eslintrc.cjs +4 -3
- package/lighthouse-cli/bin.js +1 -0
- package/lighthouse-cli/cli-flags.js +4 -3
- package/lighthouse-cli/commands/commands.js +1 -0
- package/lighthouse-cli/commands/list-audits.js +1 -0
- package/lighthouse-cli/commands/list-locales.js +1 -0
- package/lighthouse-cli/commands/list-trace-categories.js +1 -0
- package/lighthouse-cli/index.js +1 -0
- package/lighthouse-cli/printer.js +1 -0
- package/lighthouse-cli/run.js +24 -9
- package/lighthouse-cli/sentry-prompt.js +1 -0
- package/lighthouse-cli/test/smokehouse/core-tests.js +1 -0
- package/lighthouse-cli/test/smokehouse/frontends/back-compat-util.js +1 -0
- package/lighthouse-cli/test/smokehouse/frontends/lib.js +1 -0
- package/lighthouse-cli/test/smokehouse/frontends/node.js +1 -0
- package/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +1 -0
- package/lighthouse-cli/test/smokehouse/lib/child-process-error.js +1 -0
- package/lighthouse-cli/test/smokehouse/lib/concurrent-mapper.js +1 -0
- package/lighthouse-cli/test/smokehouse/lib/local-console.js +1 -0
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/bundle.js +23 -109
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js +3 -2
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/devtools.js +19 -28
- package/lighthouse-cli/test/smokehouse/report-assert.js +4 -3
- package/lighthouse-cli/test/smokehouse/smokehouse.js +1 -1
- package/lighthouse-cli/test/smokehouse/version-check-test.js +3 -0
- package/lighthouse-cli/test/smokehouse/version-check.js +1 -0
- package/lighthouse-core/audits/accessibility/accesskeys.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-allowed-attr.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-command-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-hidden-body.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-hidden-focus.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-input-field-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-meter-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-progressbar-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-required-attr.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-required-children.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-required-parent.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-roles.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-toggle-field-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-tooltip-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-treeitem-name.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-valid-attr-value.js +1 -1
- package/lighthouse-core/audits/accessibility/aria-valid-attr.js +1 -1
- package/lighthouse-core/audits/accessibility/button-name.js +1 -1
- package/lighthouse-core/audits/accessibility/bypass.js +1 -1
- package/lighthouse-core/audits/accessibility/color-contrast.js +1 -1
- package/lighthouse-core/audits/accessibility/definition-list.js +1 -1
- package/lighthouse-core/audits/accessibility/dlitem.js +1 -1
- package/lighthouse-core/audits/accessibility/document-title.js +1 -1
- package/lighthouse-core/audits/accessibility/duplicate-id-active.js +1 -1
- package/lighthouse-core/audits/accessibility/duplicate-id-aria.js +1 -1
- package/lighthouse-core/audits/accessibility/form-field-multiple-labels.js +1 -1
- package/lighthouse-core/audits/accessibility/frame-title.js +1 -1
- package/lighthouse-core/audits/accessibility/heading-order.js +1 -1
- package/lighthouse-core/audits/accessibility/html-has-lang.js +1 -1
- package/lighthouse-core/audits/accessibility/html-lang-valid.js +1 -1
- package/lighthouse-core/audits/accessibility/image-alt.js +1 -1
- package/lighthouse-core/audits/accessibility/input-image-alt.js +1 -1
- package/lighthouse-core/audits/accessibility/label.js +1 -1
- package/lighthouse-core/audits/accessibility/link-name.js +1 -1
- package/lighthouse-core/audits/accessibility/list.js +1 -1
- package/lighthouse-core/audits/accessibility/listitem.js +5 -5
- package/lighthouse-core/audits/accessibility/meta-refresh.js +1 -1
- package/lighthouse-core/audits/accessibility/meta-viewport.js +1 -1
- package/lighthouse-core/audits/accessibility/object-alt.js +1 -1
- package/lighthouse-core/audits/accessibility/tabindex.js +1 -1
- package/lighthouse-core/audits/accessibility/td-headers-attr.js +1 -1
- package/lighthouse-core/audits/accessibility/th-has-data-cells.js +1 -1
- package/lighthouse-core/audits/accessibility/valid-lang.js +1 -1
- package/lighthouse-core/audits/accessibility/video-caption.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +1 -2
- package/lighthouse-core/audits/byte-efficiency/duplicated-javascript.js +12 -11
- package/lighthouse-core/audits/byte-efficiency/efficient-animated-content.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/legacy-javascript.js +24 -22
- package/lighthouse-core/audits/byte-efficiency/offscreen-images.js +2 -3
- package/lighthouse-core/audits/byte-efficiency/render-blocking-resources.js +3 -2
- package/lighthouse-core/audits/byte-efficiency/unminified-css.js +5 -3
- package/lighthouse-core/audits/byte-efficiency/unminified-javascript.js +11 -10
- package/lighthouse-core/audits/byte-efficiency/unused-css-rules.js +1 -0
- package/lighthouse-core/audits/byte-efficiency/unused-javascript.js +8 -11
- package/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/uses-text-compression.js +1 -1
- package/lighthouse-core/audits/deprecations.js +598 -8
- package/lighthouse-core/audits/diagnostics.js +3 -4
- package/lighthouse-core/audits/dobetterweb/doctype.js +9 -20
- package/lighthouse-core/audits/dobetterweb/geolocation-on-start.js +1 -1
- package/lighthouse-core/audits/dobetterweb/no-document-write.js +1 -1
- package/lighthouse-core/audits/dobetterweb/notification-on-start.js +1 -1
- package/lighthouse-core/audits/dobetterweb/uses-http2.js +1 -2
- package/lighthouse-core/audits/dobetterweb/uses-passive-event-listeners.js +1 -1
- package/lighthouse-core/audits/errors-in-console.js +2 -2
- package/lighthouse-core/audits/long-tasks.js +2 -3
- package/lighthouse-core/audits/metrics/first-contentful-paint-3g.js +2 -2
- package/lighthouse-core/audits/metrics/first-contentful-paint.js +2 -3
- package/lighthouse-core/audits/metrics/first-meaningful-paint.js +2 -3
- package/lighthouse-core/audits/metrics/interactive.js +2 -3
- package/lighthouse-core/audits/metrics/largest-contentful-paint.js +2 -3
- package/lighthouse-core/audits/metrics/max-potential-fid.js +2 -3
- package/lighthouse-core/audits/metrics/speed-index.js +2 -3
- package/lighthouse-core/audits/metrics/total-blocking-time.js +2 -3
- package/lighthouse-core/audits/metrics.js +2 -3
- package/lighthouse-core/audits/no-unload-listeners.js +15 -7
- package/lighthouse-core/audits/predictive-perf.js +1 -2
- package/lighthouse-core/audits/preload-lcp-image.js +3 -3
- package/lighthouse-core/audits/redirects.js +1 -1
- package/lighthouse-core/audits/script-treemap-data.js +45 -45
- package/lighthouse-core/audits/seo/http-status-code.js +4 -2
- package/lighthouse-core/audits/seo/link-text.js +0 -2
- package/lighthouse-core/audits/server-response-time.js +17 -2
- package/lighthouse-core/audits/service-worker.js +2 -7
- package/lighthouse-core/audits/timing-budget.js +2 -3
- package/lighthouse-core/audits/uses-rel-preconnect.js +1 -1
- package/lighthouse-core/audits/uses-rel-preload.js +1 -1
- package/lighthouse-core/audits/valid-source-maps.js +14 -12
- package/lighthouse-core/audits/violation-audit.js +1 -1
- package/lighthouse-core/audits/work-during-interaction.js +2 -2
- package/lighthouse-core/computed/critical-request-chains.js +9 -5
- package/lighthouse-core/computed/js-bundles.js +11 -11
- package/lighthouse-core/computed/main-resource.js +2 -3
- package/lighthouse-core/computed/metrics/first-contentful-paint-all-frames.js +1 -1
- package/lighthouse-core/computed/metrics/first-contentful-paint.js +1 -1
- package/lighthouse-core/computed/metrics/first-meaningful-paint.js +1 -1
- package/lighthouse-core/computed/metrics/interactive.js +1 -1
- package/lighthouse-core/computed/metrics/lantern-first-contentful-paint.js +1 -1
- package/lighthouse-core/computed/metrics/lantern-first-meaningful-paint.js +1 -1
- package/lighthouse-core/computed/metrics/lantern-interactive.js +1 -1
- package/lighthouse-core/computed/metrics/lantern-largest-contentful-paint.js +1 -1
- package/lighthouse-core/computed/metrics/lantern-max-potential-fid.js +1 -1
- package/lighthouse-core/computed/metrics/lantern-metric.js +5 -3
- package/lighthouse-core/computed/metrics/lantern-speed-index.js +1 -1
- package/lighthouse-core/computed/metrics/lantern-total-blocking-time.js +1 -1
- package/lighthouse-core/computed/metrics/largest-contentful-paint-all-frames.js +1 -1
- package/lighthouse-core/computed/metrics/largest-contentful-paint.js +1 -1
- package/lighthouse-core/computed/metrics/max-potential-fid.js +1 -1
- package/lighthouse-core/computed/metrics/metric.js +0 -1
- package/lighthouse-core/computed/metrics/speed-index.js +1 -1
- package/lighthouse-core/computed/metrics/timing-summary.js +6 -13
- package/lighthouse-core/computed/metrics/total-blocking-time.js +1 -1
- package/lighthouse-core/computed/module-duplication.js +5 -6
- package/lighthouse-core/computed/page-dependency-graph.js +28 -55
- package/lighthouse-core/computed/resource-summary.js +5 -5
- package/lighthouse-core/computed/unused-css.js +7 -6
- package/lighthouse-core/computed/unused-javascript-summary.js +36 -16
- package/lighthouse-core/config/budget.js +2 -2
- package/lighthouse-core/config/default-config.js +1 -2
- package/lighthouse-core/fraggle-rock/api.js +1 -1
- package/lighthouse-core/fraggle-rock/config/default-config.js +0 -3
- package/lighthouse-core/fraggle-rock/gather/base-artifacts.js +3 -6
- package/lighthouse-core/fraggle-rock/gather/driver.js +2 -2
- package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +26 -51
- package/lighthouse-core/fraggle-rock/gather/runner-helpers.js +3 -0
- package/lighthouse-core/fraggle-rock/gather/session.js +22 -23
- package/lighthouse-core/fraggle-rock/gather/snapshot-runner.js +4 -5
- package/lighthouse-core/fraggle-rock/gather/timespan-runner.js +6 -6
- package/lighthouse-core/gather/connections/cri.js +1 -5
- package/lighthouse-core/gather/driver/execution-context.js +2 -5
- package/lighthouse-core/gather/driver/navigation.js +10 -13
- package/lighthouse-core/gather/driver/network-monitor.js +3 -16
- package/lighthouse-core/gather/driver.js +1 -6
- package/lighthouse-core/gather/fetcher.js +210 -34
- package/lighthouse-core/gather/gather-runner.js +17 -13
- package/lighthouse-core/gather/gatherers/accessibility.js +4 -16
- package/lighthouse-core/gather/gatherers/console-messages.js +2 -4
- package/lighthouse-core/gather/gatherers/dobetterweb/doctype.js +2 -4
- package/lighthouse-core/gather/gatherers/full-page-screenshot.js +2 -3
- package/lighthouse-core/gather/gatherers/iframe-elements.js +1 -4
- package/lighthouse-core/gather/gatherers/image-elements.js +0 -2
- package/lighthouse-core/gather/gatherers/js-usage.js +87 -12
- package/lighthouse-core/gather/gatherers/link-elements.js +14 -12
- package/lighthouse-core/gather/gatherers/main-document-content.js +8 -8
- package/lighthouse-core/gather/gatherers/script-elements.js +56 -7
- package/lighthouse-core/gather/gatherers/seo/robots-txt.js +30 -2
- package/lighthouse-core/gather/gatherers/source-maps.js +1 -8
- package/lighthouse-core/gather/gatherers/web-app-manifest.js +2 -2
- package/lighthouse-core/index.js +2 -26
- package/lighthouse-core/lib/cdt/generated/SourceMap.js +1 -1
- package/lighthouse-core/lib/dependency-graph/simulator/network-analyzer.js +29 -8
- package/lighthouse-core/lib/navigation-error.js +4 -13
- package/lighthouse-core/lib/page-functions.js +1 -3
- package/lighthouse-core/lib/script-helpers.js +6 -11
- package/lighthouse-core/lib/url-shim.js +2 -2
- package/lighthouse-core/runner.js +5 -0
- package/lighthouse-core/scripts/manual-chrome-launcher.js +1 -0
- package/lighthouse-core/util-commonjs.js +6 -8
- package/package.json +13 -13
- package/readme.md +1 -1
- package/report/.eslintrc.cjs +1 -3
- package/report/assets/styles.css +5 -10
- package/report/assets/templates.html +9 -10
- package/report/clients/bundle.js +1 -0
- package/report/clients/standalone.js +1 -0
- package/report/generator/report-generator.js +21 -46
- package/report/renderer/api.js +2 -0
- package/report/renderer/category-renderer.js +24 -20
- package/report/renderer/components.js +304 -303
- package/report/renderer/crc-details-renderer.js +24 -21
- package/report/renderer/details-renderer.js +12 -12
- package/report/renderer/dom.js +7 -6
- package/report/renderer/drop-down-menu.js +1 -0
- package/report/renderer/element-screenshot-renderer.js +5 -1
- package/report/renderer/features-util.js +1 -0
- package/report/renderer/i18n.js +62 -118
- package/report/renderer/logger.js +1 -0
- package/report/renderer/open-tab.js +3 -1
- package/report/renderer/performance-category-renderer.js +11 -10
- package/report/renderer/pwa-category-renderer.js +4 -3
- package/report/renderer/report-renderer.js +17 -17
- package/report/renderer/report-ui-features.js +1 -0
- package/report/renderer/snippet-renderer.js +3 -2
- package/report/renderer/swap-locale-feature.js +1 -0
- package/report/renderer/text-encoding.js +1 -0
- package/report/renderer/topbar-features.js +1 -0
- package/report/renderer/util.js +6 -7
- package/report/test/clients/bundle-test.js +5 -0
- package/report/test/generator/file-namer-test.js +1 -0
- package/report/test/generator/report-generator-test.js +20 -25
- package/report/test/renderer/category-renderer-test.js +4 -3
- package/report/test/renderer/components-test.js +3 -0
- package/report/test/renderer/crc-details-renderer-test.js +3 -0
- package/report/test/renderer/details-renderer-test.js +3 -49
- package/report/test/renderer/dom-test.js +3 -0
- package/report/test/renderer/element-screenshot-renderer-test.js +6 -3
- package/report/test/renderer/i18n-test.js +25 -70
- package/report/test/renderer/performance-category-renderer-test.js +5 -14
- package/report/test/renderer/pwa-category-renderer-test.js +4 -3
- package/report/test/renderer/report-renderer-axe-test.js +4 -3
- package/report/test/renderer/report-renderer-test.js +4 -3
- package/report/test/renderer/report-ui-features-test.js +4 -3
- package/report/test/renderer/snippet-renderer-test.js +3 -0
- package/report/test/renderer/text-encoding-test.js +3 -0
- package/report/test/renderer/util-test.js +5 -4
- package/report/test-assets/faux-psi.js +1 -2
- package/shared/localization/format.js +3 -7
- package/shared/localization/locales/en-US.json +238 -55
- package/shared/localization/locales/en-XL.json +238 -55
- package/shared/test/localization/format-test.js +2 -8
- package/shared/test/localization/locales-test.js +2 -0
- package/shared/test/localization/swap-locale-test.js +2 -0
- package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +2 -0
- package/third-party/chromium-synchronization/installability-errors-test.js +2 -0
- package/tsconfig.json +0 -1
- package/types/artifacts.d.ts +8 -47
- package/types/config.d.ts +0 -2
- package/types/externs.d.ts +2 -3
- package/types/gatherer.d.ts +2 -1
- package/types/global-lh.d.ts +0 -3
- package/types/lhr/lhr.d.ts +2 -2
- package/types/lhr/treemap.d.ts +1 -0
- package/changelog.md +0 -5902
- package/lighthouse-core/audits/script-elements-test-audit.js +0 -30
- package/lighthouse-core/gather/gatherers/scripts.js +0 -154
- package/lighthouse-core/scripts/package.json +0 -4
- package/report/test/.eslintrc.cjs +0 -11
- package/shared/test/localization/.eslintrc.cjs +0 -11
|
@@ -88,7 +88,6 @@ class SourceMaps extends FRGatherer {
|
|
|
88
88
|
|
|
89
89
|
if (!rawSourceMapUrl) {
|
|
90
90
|
return {
|
|
91
|
-
scriptId: event.scriptId,
|
|
92
91
|
scriptUrl,
|
|
93
92
|
errorMessage: `Could not resolve map url: ${event.sourceMapURL}`,
|
|
94
93
|
};
|
|
@@ -101,23 +100,16 @@ class SourceMaps extends FRGatherer {
|
|
|
101
100
|
const map = isSourceMapADataUri ?
|
|
102
101
|
this.parseSourceMapFromDataUrl(rawSourceMapUrl) :
|
|
103
102
|
await this.fetchSourceMap(driver, rawSourceMapUrl);
|
|
104
|
-
|
|
105
|
-
if (typeof map.version !== 'number') throw new Error('Map has no numeric `version` field');
|
|
106
|
-
if (!Array.isArray(map.sources)) throw new Error('Map has no `sources` list');
|
|
107
|
-
if (typeof map.mappings !== 'string') throw new Error('Map has no `mappings` field');
|
|
108
|
-
|
|
109
103
|
if (map.sections) {
|
|
110
104
|
map.sections = map.sections.filter(section => section.map);
|
|
111
105
|
}
|
|
112
106
|
return {
|
|
113
|
-
scriptId: event.scriptId,
|
|
114
107
|
scriptUrl,
|
|
115
108
|
sourceMapUrl,
|
|
116
109
|
map,
|
|
117
110
|
};
|
|
118
111
|
} catch (err) {
|
|
119
112
|
return {
|
|
120
|
-
scriptId: event.scriptId,
|
|
121
113
|
scriptUrl,
|
|
122
114
|
sourceMapUrl,
|
|
123
115
|
errorMessage: err.toString(),
|
|
@@ -148,6 +140,7 @@ class SourceMaps extends FRGatherer {
|
|
|
148
140
|
* @return {Promise<LH.Artifacts['SourceMaps']>}
|
|
149
141
|
*/
|
|
150
142
|
async getArtifact(context) {
|
|
143
|
+
await context.driver.fetcher.enable();
|
|
151
144
|
const eventProcessPromises = this._scriptParsedEvents
|
|
152
145
|
.map((event) => this._retrieveMapFromScriptParsedEvent(context.driver, event));
|
|
153
146
|
return Promise.all(eventProcessPromises);
|
|
@@ -94,8 +94,8 @@ class WebAppManifest extends FRGatherer {
|
|
|
94
94
|
*/
|
|
95
95
|
getArtifact(context) {
|
|
96
96
|
const driver = context.driver;
|
|
97
|
-
|
|
98
|
-
return WebAppManifest.getWebAppManifest(driver.defaultSession,
|
|
97
|
+
|
|
98
|
+
return WebAppManifest.getWebAppManifest(driver.defaultSession, context.url);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
package/lighthouse-core/index.js
CHANGED
|
@@ -10,7 +10,6 @@ const log = require('lighthouse-logger');
|
|
|
10
10
|
const ChromeProtocol = require('./gather/connections/cri.js');
|
|
11
11
|
const Config = require('./config/config.js');
|
|
12
12
|
const URL = require('./lib/url-shim.js');
|
|
13
|
-
const fraggleRock = require('./fraggle-rock/api.js');
|
|
14
13
|
|
|
15
14
|
/** @typedef {import('./gather/connections/connection.js')} Connection */
|
|
16
15
|
|
|
@@ -34,32 +33,10 @@ const fraggleRock = require('./fraggle-rock/api.js');
|
|
|
34
33
|
* they will override any settings in the config.
|
|
35
34
|
* @param {LH.Config.Json=} configJSON Configuration for the Lighthouse run. If
|
|
36
35
|
* not present, the default config is used.
|
|
37
|
-
* @param {LH.Puppeteer.Page=} page
|
|
38
|
-
* @return {Promise<LH.RunnerResult|undefined>}
|
|
39
|
-
*/
|
|
40
|
-
async function lighthouse(url, flags = {}, configJSON, page) {
|
|
41
|
-
const configContext = {
|
|
42
|
-
configPath: flags.configPath,
|
|
43
|
-
settingsOverrides: flags,
|
|
44
|
-
logLevel: flags.logLevel,
|
|
45
|
-
hostname: flags.hostname,
|
|
46
|
-
port: flags.port,
|
|
47
|
-
};
|
|
48
|
-
return fraggleRock.navigation(url, {page, config: configJSON, configContext});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Run Lighthouse using the legacy navigation runner.
|
|
53
|
-
* This is left in place for any clients that don't support FR navigations yet (e.g. Lightrider)
|
|
54
|
-
* @param {string=} url The URL to test. Optional if running in auditMode.
|
|
55
|
-
* @param {LH.Flags=} flags Optional settings for the Lighthouse run. If present,
|
|
56
|
-
* they will override any settings in the config.
|
|
57
|
-
* @param {LH.Config.Json=} configJSON Configuration for the Lighthouse run. If
|
|
58
|
-
* not present, the default config is used.
|
|
59
36
|
* @param {Connection=} userConnection
|
|
60
37
|
* @return {Promise<LH.RunnerResult|undefined>}
|
|
61
38
|
*/
|
|
62
|
-
async function
|
|
39
|
+
async function lighthouse(url, flags = {}, configJSON, userConnection) {
|
|
63
40
|
// set logging preferences, assume quiet
|
|
64
41
|
flags.logLevel = flags.logLevel || 'error';
|
|
65
42
|
log.setLevel(flags.logLevel);
|
|
@@ -89,12 +66,11 @@ function generateConfig(configJson, flags) {
|
|
|
89
66
|
return new Config(configJson, flags);
|
|
90
67
|
}
|
|
91
68
|
|
|
92
|
-
lighthouse.legacyNavigation = legacyNavigation;
|
|
93
69
|
lighthouse.generateConfig = generateConfig;
|
|
94
70
|
lighthouse.getAuditList = Runner.getAuditList;
|
|
95
71
|
lighthouse.traceCategories = require('./gather/driver.js').traceCategories;
|
|
96
72
|
lighthouse.Audit = require('./audits/audit.js');
|
|
97
|
-
lighthouse.Gatherer = require('./
|
|
73
|
+
lighthouse.Gatherer = require('./gather/gatherers/gatherer.js');
|
|
98
74
|
|
|
99
75
|
// Explicit type reference (hidden by makeComputedArtifact) for d.ts export.
|
|
100
76
|
// TODO(esmodules): should be a workaround for module.export and can be removed when in esm.
|
|
@@ -149,7 +149,7 @@ class TextSourceMap {
|
|
|
149
149
|
}
|
|
150
150
|
return mappings.slice(startIndex, endIndex);
|
|
151
151
|
}
|
|
152
|
-
/** @return {Array<{lineNumber: number, columnNumber: number, sourceURL?: string, sourceLineNumber
|
|
152
|
+
/** @return {Array<{lineNumber: number, columnNumber: number, sourceURL?: string, sourceLineNumber, sourceColumnNumber: number, name?: string, lastColumnNumber?: number}>} */
|
|
153
153
|
mappings() {
|
|
154
154
|
if (this.mappingsInternal === null) {
|
|
155
155
|
this.mappingsInternal = [];
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const INITIAL_CWD = 14 * 1024;
|
|
9
|
+
const NetworkRequest = require('../../network-request.js');
|
|
9
10
|
const URL = require('../../url-shim.js');
|
|
10
11
|
|
|
11
12
|
// Assume that 40% of TTFB was server response time by default for static assets
|
|
@@ -433,20 +434,40 @@ class NetworkAnalyzer {
|
|
|
433
434
|
|
|
434
435
|
/**
|
|
435
436
|
* @param {Array<LH.Artifacts.NetworkRequest>} records
|
|
436
|
-
* @param {string}
|
|
437
|
+
* @param {string} [finalURL]
|
|
438
|
+
* @return {LH.Artifacts.NetworkRequest}
|
|
439
|
+
*/
|
|
440
|
+
static findMainDocument(records, finalURL) {
|
|
441
|
+
const mainDocument = NetworkAnalyzer.findOptionalMainDocument(records, finalURL);
|
|
442
|
+
if (!mainDocument) throw new Error('Unable to identify the main resource');
|
|
443
|
+
return mainDocument;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* @param {Array<LH.Artifacts.NetworkRequest>} records
|
|
448
|
+
* @param {string} [finalURL]
|
|
437
449
|
* @return {LH.Artifacts.NetworkRequest|undefined}
|
|
438
450
|
*/
|
|
439
|
-
static
|
|
440
|
-
//
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
451
|
+
static findOptionalMainDocument(records, finalURL) {
|
|
452
|
+
// Try to find an exact match with the final URL first if we have one
|
|
453
|
+
if (finalURL) {
|
|
454
|
+
// equalWithExcludedFragments is expensive, so check that the finalUrl starts with the request first
|
|
455
|
+
const mainResource = records.find(request => finalURL.startsWith(request.url) &&
|
|
456
|
+
URL.equalWithExcludedFragments(request.url, finalURL));
|
|
457
|
+
if (mainResource) return mainResource;
|
|
458
|
+
// TODO: beacon !mainResource to Sentry, https://github.com/GoogleChrome/lighthouse/issues/7041
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const documentRequests = records.filter(record => record.resourceType ===
|
|
462
|
+
NetworkRequest.TYPES.Document);
|
|
463
|
+
if (!documentRequests.length) return undefined;
|
|
464
|
+
// The main document is the earliest document request, using position in networkRecords array to break ties.
|
|
465
|
+
return documentRequests.reduce((min, r) => (r.startTime < min.startTime ? r : min));
|
|
445
466
|
}
|
|
446
467
|
|
|
447
468
|
/**
|
|
448
469
|
* Resolves redirect chain given a main document.
|
|
449
|
-
* See: {@link NetworkAnalyzer.
|
|
470
|
+
* See: {@link NetworkAnalyzer.findMainDocument}) for how to retrieve main document.
|
|
450
471
|
*
|
|
451
472
|
* @param {LH.Artifacts.NetworkRequest} request
|
|
452
473
|
* @return {LH.Artifacts.NetworkRequest}
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
const LHError = require('./lh-error.js');
|
|
9
9
|
const NetworkAnalyzer = require('./dependency-graph/simulator/network-analyzer.js');
|
|
10
|
-
const NetworkRequest = require('./network-request.js');
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Returns an error if the original network request failed or wasn't found.
|
|
@@ -101,18 +100,10 @@ function getNonHtmlError(finalRecord) {
|
|
|
101
100
|
function getPageLoadError(navigationError, context) {
|
|
102
101
|
const {url, loadFailureMode, networkRecords} = context;
|
|
103
102
|
/** @type {LH.Artifacts.NetworkRequest|undefined} */
|
|
104
|
-
let mainRecord
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (!mainRecord) {
|
|
109
|
-
const documentRequests = networkRecords.filter(record =>
|
|
110
|
-
record.resourceType === NetworkRequest.TYPES.Document
|
|
111
|
-
);
|
|
112
|
-
if (documentRequests.length) {
|
|
113
|
-
mainRecord = documentRequests.reduce((min, r) => (r.startTime < min.startTime ? r : min));
|
|
114
|
-
}
|
|
115
|
-
}
|
|
103
|
+
let mainRecord;
|
|
104
|
+
try {
|
|
105
|
+
mainRecord = NetworkAnalyzer.findMainDocument(networkRecords, url);
|
|
106
|
+
} catch (_) {}
|
|
116
107
|
|
|
117
108
|
// MIME Type is only set on the final redirected document request. Use this for the HTML check instead of root.
|
|
118
109
|
let finalRecord;
|
|
@@ -434,10 +434,8 @@ function getNodeLabel(element) {
|
|
|
434
434
|
* @return {LH.Artifacts.Rect}
|
|
435
435
|
*/
|
|
436
436
|
function getBoundingClientRect(element) {
|
|
437
|
-
const realBoundingClientRect = window.__HTMLElementBoundingClientRect ||
|
|
438
|
-
window.HTMLElement.prototype.getBoundingClientRect;
|
|
439
437
|
// The protocol does not serialize getters, so extract the values explicitly.
|
|
440
|
-
const rect =
|
|
438
|
+
const rect = element.getBoundingClientRect();
|
|
441
439
|
return {
|
|
442
440
|
top: Math.round(rect.top),
|
|
443
441
|
bottom: Math.round(rect.bottom),
|
|
@@ -5,25 +5,20 @@
|
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* @param {LH.Artifacts.Script} script
|
|
10
|
-
* @return {boolean}
|
|
11
|
-
*/
|
|
12
|
-
function isInline(script) {
|
|
13
|
-
return Boolean(script.startLine || script.startColumn);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
8
|
/**
|
|
17
9
|
* @param {LH.Artifacts.NetworkRequest[]} networkRecords
|
|
18
|
-
* @param {LH.Artifacts.
|
|
10
|
+
* @param {LH.Artifacts.ScriptElement|undefined} script
|
|
19
11
|
* @return {LH.Artifacts.NetworkRequest|undefined}
|
|
20
12
|
*/
|
|
21
13
|
function getRequestForScript(networkRecords, script) {
|
|
22
|
-
|
|
14
|
+
if (!script) return;
|
|
15
|
+
let networkRequest = script.requestId &&
|
|
16
|
+
networkRecords.find(request => request.requestId === script.requestId);
|
|
17
|
+
if (!networkRequest) networkRequest = networkRecords.find(request => request.url === script.src);
|
|
23
18
|
while (networkRequest?.redirectDestination) {
|
|
24
19
|
networkRequest = networkRequest.redirectDestination;
|
|
25
20
|
}
|
|
26
21
|
return networkRequest;
|
|
27
22
|
}
|
|
28
23
|
|
|
29
|
-
module.exports = {getRequestForScript
|
|
24
|
+
module.exports = {getRequestForScript};
|
|
@@ -236,9 +236,9 @@ class URLShim extends URL {
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
if (url.protocol === 'data:') {
|
|
239
|
-
const match = url.pathname.match(
|
|
239
|
+
const match = url.pathname.match(/image\/(png|jpeg|svg\+xml|webp|gif|avif)(?=;)/);
|
|
240
240
|
if (!match) return undefined;
|
|
241
|
-
return match[
|
|
241
|
+
return match[0];
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
const match = url.pathname.toLowerCase().match(/\.(png|jpeg|jpg|svg|webp|gif|avif)$/);
|
|
@@ -158,6 +158,11 @@ class Runner {
|
|
|
158
158
|
// No browser required, just load the artifacts from disk.
|
|
159
159
|
const path = this._getDataSavePath(settings);
|
|
160
160
|
artifacts = assetSaver.loadArtifacts(path);
|
|
161
|
+
const requestedUrl = artifacts.URL.requestedUrl;
|
|
162
|
+
|
|
163
|
+
if (!requestedUrl) {
|
|
164
|
+
throw new Error('Cannot run audit mode on empty URL');
|
|
165
|
+
}
|
|
161
166
|
} else {
|
|
162
167
|
const runnerStatus = {msg: 'Gather phase', id: 'lh:runner:gather'};
|
|
163
168
|
log.time(runnerStatus, 'verbose');
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// Auto-generated by lighthouse-core/scripts/copy-util-commonjs.sh
|
|
3
3
|
// Temporary solution until all our code uses esmodules
|
|
4
|
-
'use strict';
|
|
5
4
|
/**
|
|
6
5
|
* @license
|
|
7
6
|
* Copyright 2017 The Lighthouse Authors. All Rights Reserved.
|
|
@@ -18,6 +17,7 @@
|
|
|
18
17
|
* See the License for the specific language governing permissions and
|
|
19
18
|
* limitations under the License.
|
|
20
19
|
*/
|
|
20
|
+
'use strict';
|
|
21
21
|
|
|
22
22
|
/** @template T @typedef {import('./i18n').I18n<T>} I18n */
|
|
23
23
|
|
|
@@ -433,11 +433,10 @@ class Util {
|
|
|
433
433
|
break;
|
|
434
434
|
case 'devtools': {
|
|
435
435
|
const {cpuSlowdownMultiplier, requestLatencyMs} = throttling;
|
|
436
|
-
// eslint-disable-next-line max-len
|
|
437
436
|
cpuThrottling = `${Util.i18n.formatNumber(cpuSlowdownMultiplier)}x slowdown (DevTools)`;
|
|
438
|
-
networkThrottling = `${Util.i18n.
|
|
439
|
-
`${Util.i18n.
|
|
440
|
-
`${Util.i18n.
|
|
437
|
+
networkThrottling = `${Util.i18n.formatNumber(requestLatencyMs)}${NBSP}ms HTTP RTT, ` +
|
|
438
|
+
`${Util.i18n.formatNumber(throttling.downloadThroughputKbps)}${NBSP}Kbps down, ` +
|
|
439
|
+
`${Util.i18n.formatNumber(throttling.uploadThroughputKbps)}${NBSP}Kbps up (DevTools)`;
|
|
441
440
|
|
|
442
441
|
const isSlow4G = () => {
|
|
443
442
|
return requestLatencyMs === 150 * 3.75 &&
|
|
@@ -449,10 +448,9 @@ class Util {
|
|
|
449
448
|
}
|
|
450
449
|
case 'simulate': {
|
|
451
450
|
const {cpuSlowdownMultiplier, rttMs, throughputKbps} = throttling;
|
|
452
|
-
// eslint-disable-next-line max-len
|
|
453
451
|
cpuThrottling = `${Util.i18n.formatNumber(cpuSlowdownMultiplier)}x slowdown (Simulated)`;
|
|
454
|
-
networkThrottling = `${Util.i18n.
|
|
455
|
-
`${Util.i18n.
|
|
452
|
+
networkThrottling = `${Util.i18n.formatNumber(rttMs)}${NBSP}ms TCP RTT, ` +
|
|
453
|
+
`${Util.i18n.formatNumber(throughputKbps)}${NBSP}Kbps throughput (Simulated)`;
|
|
456
454
|
|
|
457
455
|
const isSlow4G = () => {
|
|
458
456
|
return rttMs === 150 && throughputKbps === 1.6 * 1024;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lighthouse",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.6.2",
|
|
4
4
|
"description": "Automated auditing, performance metrics, and best practices for the web.",
|
|
5
5
|
"main": "./lighthouse-core/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"build-smokehouse-bundle": "node ./build/build-smokehouse-bundle.js",
|
|
25
25
|
"build-lr": "yarn reset-link && node ./build/build-lightrider-bundles.js",
|
|
26
26
|
"build-pack": "bash build/build-pack.sh",
|
|
27
|
-
"build-report": "node build/build-report-components.js && bash lighthouse-core/scripts/copy-util-commonjs.sh && node build/build-report.js",
|
|
27
|
+
"build-report": "node build/build-report-components.js && yarn eslint --fix report/renderer/components.js && bash lighthouse-core/scripts/copy-util-commonjs.sh && node build/build-report.js",
|
|
28
28
|
"build-sample-reports": "yarn build-report && node build/build-sample-reports.js",
|
|
29
29
|
"build-treemap": "node ./build/build-treemap.js",
|
|
30
30
|
"build-viewer": "node ./build/build-viewer.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"start": "yarn build-report --standalone && node ./lighthouse-cli/index.js",
|
|
38
38
|
"jest": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
|
|
39
39
|
"test": "yarn diff:sample-json && yarn lint --quiet && yarn unit && yarn type-check",
|
|
40
|
-
"test-bundle": "yarn smoke --runner bundle --retries=2",
|
|
40
|
+
"test-bundle": "yarn smoke --runner bundle -j=1 --retries=2 --invert-match forms",
|
|
41
41
|
"test-clients": "yarn jest \"$PWD/clients/\" && yarn jest --testMatch=\"**/clients/test/**/*-test-pptr.js\"",
|
|
42
42
|
"test-viewer": "yarn unit-viewer && yarn jest --testMatch=\"**/viewer/**/*-test-pptr.js\"",
|
|
43
43
|
"test-treemap": "yarn unit-treemap && yarn jest --testMatch=\"**/treemap/**/*-test-pptr.js\"",
|
|
@@ -68,28 +68,28 @@
|
|
|
68
68
|
"vercel-build": "yarn build-sample-reports && yarn build-viewer && yarn build-treemap",
|
|
69
69
|
"dogfood-lhci": "./lighthouse-core/scripts/dogfood-lhci.sh",
|
|
70
70
|
"timing-trace": "node lighthouse-core/scripts/generate-timing-trace.js",
|
|
71
|
-
"changelog": "conventional-changelog --config ./build/changelog-generator/index.
|
|
71
|
+
"changelog": "conventional-changelog --config ./build/changelog-generator/index.js --infile changelog.md --same-file",
|
|
72
72
|
"type-check": "tsc --build ./tsconfig-all.json",
|
|
73
73
|
"i18n:checks": "./lighthouse-core/scripts/i18n/assert-strings-collected.sh",
|
|
74
74
|
"i18n:collect-strings": "node lighthouse-core/scripts/i18n/collect-strings.js",
|
|
75
75
|
"update:lantern-baseline": "node lighthouse-core/scripts/lantern/update-baseline-lantern-values.js",
|
|
76
76
|
"update:sample-artifacts": "node lighthouse-core/scripts/update-report-fixtures.js",
|
|
77
|
-
"update:sample-json": "yarn i18n:collect-strings && node ./lighthouse-cli -A=./lighthouse-core/test/results/artifacts --config-path=./lighthouse-core/test/results/sample-config.js --output=json --output-path=./lighthouse-core/test/results/sample_v2.json && node lighthouse-core/scripts/cleanup-LHR-for-diff.js ./lighthouse-core/test/results/sample_v2.json --only-remove-timing
|
|
78
|
-
"update:flow-sample-json": "
|
|
77
|
+
"update:sample-json": "yarn i18n:collect-strings && node ./lighthouse-cli -A=./lighthouse-core/test/results/artifacts --config-path=./lighthouse-core/test/results/sample-config.js --output=json --output-path=./lighthouse-core/test/results/sample_v2.json && node lighthouse-core/scripts/cleanup-LHR-for-diff.js ./lighthouse-core/test/results/sample_v2.json --only-remove-timing",
|
|
78
|
+
"update:flow-sample-json": "node ./lighthouse-core/scripts/update-flow-fixtures.js",
|
|
79
|
+
"update:snapshot-sample-json": "node ./lighthouse-core/scripts/update-snapshot-sample.js",
|
|
79
80
|
"update:test-devtools": "bash lighthouse-core/test/chromium-web-tests/test-locally.sh --reset-results",
|
|
80
81
|
"test-devtools": "bash lighthouse-core/test/chromium-web-tests/test-locally.sh",
|
|
81
82
|
"open-devtools": "bash lighthouse-core/scripts/open-devtools.sh",
|
|
82
83
|
"run-devtools": "node lighthouse-core/scripts/pptr-run-devtools.js",
|
|
83
84
|
"diff:sample-json": "yarn i18n:checks && bash lighthouse-core/scripts/assert-golden-lhr-unchanged.sh",
|
|
84
|
-
"diff:flow-sample-json": "yarn i18n:collect-strings && bash lighthouse-core/scripts/assert-baseline-flow-result-unchanged.sh",
|
|
85
85
|
"computeBenchmarkIndex": "./lighthouse-core/scripts/benchmark.js",
|
|
86
86
|
"minify-latest-run": "./lighthouse-core/scripts/lantern/minify-trace.js ./latest-run/defaultPass.trace.json ./latest-run/defaultPass.trace.min.json && ./lighthouse-core/scripts/lantern/minify-devtoolslog.js ./latest-run/defaultPass.devtoolslog.json ./latest-run/defaultPass.devtoolslog.min.json",
|
|
87
87
|
"save-latest-run": "./lighthouse-core/scripts/save-latest-run.sh",
|
|
88
88
|
"compile-proto": "protoc --python_out=./ ./proto/lighthouse-result.proto && mv ./proto/*_pb2.py ./proto/scripts || (echo \"❌ Install protobuf ≥ 3.7.1 to compile the proto file.\" && false)",
|
|
89
89
|
"build-proto-roundtrip": "mkdir -p .tmp && cross-env PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=2 python proto/scripts/json_roundtrip_via_proto.py",
|
|
90
90
|
"static-server": "node lighthouse-cli/test/fixtures/static-server.js",
|
|
91
|
-
"serve-dist": "cd dist &&
|
|
92
|
-
"serve-gh-pages": "cd dist/gh-pages &&
|
|
91
|
+
"serve-dist": "cd dist && python -m SimpleHTTPServer",
|
|
92
|
+
"serve-gh-pages": "cd dist/gh-pages && python -m SimpleHTTPServer",
|
|
93
93
|
"serve-treemap": "yarn serve-gh-pages",
|
|
94
94
|
"serve-viewer": "yarn serve-gh-pages",
|
|
95
95
|
"flow-report": "yarn build-report --flow && node ./lighthouse-core/scripts/build-test-flow-report.js"
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"cpy": "^8.1.2",
|
|
139
139
|
"cross-env": "^7.0.2",
|
|
140
140
|
"csv-validator": "^0.0.3",
|
|
141
|
-
"devtools-protocol": "0.0.
|
|
141
|
+
"devtools-protocol": "0.0.999451",
|
|
142
142
|
"es-main": "^1.0.2",
|
|
143
143
|
"eslint": "^8.4.1",
|
|
144
144
|
"eslint-config-google": "^0.14.0",
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
"dependencies": {
|
|
183
183
|
"@sentry/node": "^6.17.4",
|
|
184
184
|
"axe-core": "4.4.1",
|
|
185
|
-
"chrome-launcher": "^0.15.
|
|
185
|
+
"chrome-launcher": "^0.15.0",
|
|
186
186
|
"configstore": "^5.0.1",
|
|
187
187
|
"csp_evaluator": "1.1.0",
|
|
188
188
|
"cssstyle": "1.2.1",
|
|
@@ -209,8 +209,8 @@
|
|
|
209
209
|
"yargs-parser": "^21.0.0"
|
|
210
210
|
},
|
|
211
211
|
"resolutions": {
|
|
212
|
-
"puppeteer/**/devtools-protocol": "0.0.
|
|
213
|
-
"puppeteer-core/**/devtools-protocol": "0.0.
|
|
212
|
+
"puppeteer/**/devtools-protocol": "0.0.999451",
|
|
213
|
+
"puppeteer-core/**/devtools-protocol": "0.0.999451"
|
|
214
214
|
},
|
|
215
215
|
"repository": "GoogleChrome/lighthouse",
|
|
216
216
|
"keywords": [
|
package/readme.md
CHANGED
|
@@ -99,7 +99,7 @@ Configuration:
|
|
|
99
99
|
--screenEmulation Sets screen emulation parameters. See also --preset. Use --screenEmulation.disabled to disable. Otherwise set these 4 parameters individually: --screenEmulation.mobile --screenEmulation.width=360 --screenEmulation.height=640 --screenEmulation.deviceScaleFactor=2
|
|
100
100
|
--emulatedUserAgent Sets useragent emulation [string]
|
|
101
101
|
--max-wait-for-load The timeout (in milliseconds) to wait before the page is considered done loading and the run should continue. WARNING: Very high values can lead to large traces and instability [number]
|
|
102
|
-
--enable-error-reporting Enables error reporting, overriding any saved preference. --no-enable-error-reporting will do the opposite. More: https://
|
|
102
|
+
--enable-error-reporting Enables error reporting, overriding any saved preference. --no-enable-error-reporting will do the opposite. More: https://git.io/vFFTO [boolean]
|
|
103
103
|
--gather-mode, -G Collect artifacts from a connected browser and save to disk. (Artifacts folder path may optionally be provided). If audit-mode is not also enabled, the run will quit early.
|
|
104
104
|
--audit-mode, -A Process saved artifacts from disk. (Artifacts folder path may be provided, otherwise defaults to ./latest-run/)
|
|
105
105
|
--only-audits Only run the specified audits [array]
|
package/report/.eslintrc.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
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
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
|
+
'use strict';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* eslint does not support ESM rc files, so this must be a .cjs file.
|
|
@@ -31,7 +32,4 @@ module.exports = {
|
|
|
31
32
|
'import/group-exports': 2,
|
|
32
33
|
'import/exports-last': 2,
|
|
33
34
|
},
|
|
34
|
-
parserOptions: {
|
|
35
|
-
sourceType: 'module',
|
|
36
|
-
},
|
|
37
35
|
};
|
package/report/assets/styles.css
CHANGED
|
@@ -698,10 +698,11 @@
|
|
|
698
698
|
border-top: 1px solid var(--report-border-color-secondary);
|
|
699
699
|
}
|
|
700
700
|
|
|
701
|
-
.lh-
|
|
701
|
+
.lh-metric:nth-last-child(-n+2) {
|
|
702
702
|
border-bottom: 1px solid var(--report-border-color-secondary);
|
|
703
703
|
}
|
|
704
704
|
|
|
705
|
+
|
|
705
706
|
.lh-metric__innerwrap {
|
|
706
707
|
display: grid;
|
|
707
708
|
/**
|
|
@@ -748,7 +749,7 @@
|
|
|
748
749
|
.lh-metric {
|
|
749
750
|
border-bottom: none !important;
|
|
750
751
|
}
|
|
751
|
-
.lh-
|
|
752
|
+
.lh-metric:nth-last-child(1) {
|
|
752
753
|
border-bottom: 1px solid var(--report-border-color-secondary) !important;
|
|
753
754
|
}
|
|
754
755
|
|
|
@@ -1421,9 +1422,6 @@
|
|
|
1421
1422
|
.lh-category-wrapper {
|
|
1422
1423
|
border-bottom: 1px solid var(--color-gray-200);
|
|
1423
1424
|
}
|
|
1424
|
-
.lh-category-wrapper:last-of-type {
|
|
1425
|
-
border-bottom: 0;
|
|
1426
|
-
}
|
|
1427
1425
|
|
|
1428
1426
|
.lh-category-header {
|
|
1429
1427
|
margin-bottom: var(--section-padding-vertical);
|
|
@@ -1750,18 +1748,15 @@ details[open] .lh-clump-toggletext--hide { display: block;}
|
|
|
1750
1748
|
|
|
1751
1749
|
/* Element screenshot */
|
|
1752
1750
|
.lh-element-screenshot {
|
|
1751
|
+
position: relative;
|
|
1752
|
+
overflow: hidden;
|
|
1753
1753
|
float: left;
|
|
1754
1754
|
margin-right: 20px;
|
|
1755
1755
|
}
|
|
1756
1756
|
.lh-element-screenshot__content {
|
|
1757
1757
|
overflow: hidden;
|
|
1758
|
-
min-width: 110px;
|
|
1759
|
-
display: flex;
|
|
1760
|
-
justify-content: center;
|
|
1761
|
-
background-color: var(--report-background-color);
|
|
1762
1758
|
}
|
|
1763
1759
|
.lh-element-screenshot__image {
|
|
1764
|
-
position: relative;
|
|
1765
1760
|
/* Set by ElementScreenshotRenderer.installFullPageScreenshotCssVariable */
|
|
1766
1761
|
background-image: var(--element-screenshot-url);
|
|
1767
1762
|
outline: 2px solid #777;
|
|
@@ -893,17 +893,16 @@ limitations under the License.
|
|
|
893
893
|
<template id="elementScreenshot">
|
|
894
894
|
<div class="lh-element-screenshot">
|
|
895
895
|
<div class="lh-element-screenshot__content">
|
|
896
|
-
<div class="lh-element-
|
|
897
|
-
<
|
|
898
|
-
<
|
|
899
|
-
<
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
</svg>
|
|
904
|
-
</div>
|
|
905
|
-
<div class="lh-element-screenshot__element-marker"></div>
|
|
896
|
+
<div class="lh-element-screenshot__mask">
|
|
897
|
+
<svg height="0" width="0">
|
|
898
|
+
<defs>
|
|
899
|
+
<clipPath clipPathUnits="objectBoundingBox"></clipPath>
|
|
900
|
+
<!-- clipPath filled by ElementScreenshotRenderer.renderClipPath -->
|
|
901
|
+
</defs>
|
|
902
|
+
</svg>
|
|
906
903
|
</div>
|
|
904
|
+
<div class="lh-element-screenshot__image"></div>
|
|
905
|
+
<div class="lh-element-screenshot__element-marker"></div>
|
|
907
906
|
</div>
|
|
908
907
|
</div>
|
|
909
908
|
</template>
|
package/report/clients/bundle.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
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
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
|
+
'use strict';
|
|
6
7
|
|
|
7
8
|
// This file is used to generate a bundle that can be imported
|
|
8
9
|
// into an esmodules codebase to render the lighthouse report.
|
|
@@ -3,6 +3,7 @@
|
|
|
3
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
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
|
+
'use strict';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @fileoverview The entry point for rendering the Lighthouse report for the HTML
|
|
@@ -93,54 +93,29 @@ class ReportGenerator {
|
|
|
93
93
|
const separator = ',';
|
|
94
94
|
/** @param {string} value @return {string} */
|
|
95
95
|
const escape = value => `"${value.replace(/"/g, '""')}"`;
|
|
96
|
-
/** @param {
|
|
97
|
-
const rowFormatter = row => row.map(value =>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
// Some spacing.
|
|
111
|
-
rows.push([]);
|
|
112
|
-
|
|
113
|
-
// Categories.
|
|
114
|
-
rows.push(['category', 'score']);
|
|
115
|
-
for (const category of Object.values(lhr.categories)) {
|
|
116
|
-
rows.push(rowFormatter([
|
|
117
|
-
category.id,
|
|
118
|
-
category.score,
|
|
119
|
-
]));
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
rows.push([]);
|
|
123
|
-
|
|
124
|
-
// Audits.
|
|
125
|
-
rows.push(['category', 'audit', 'score', 'displayValue', 'description']);
|
|
126
|
-
for (const category of Object.values(lhr.categories)) {
|
|
127
|
-
for (const auditRef of category.auditRefs) {
|
|
96
|
+
/** @param {Array<string | number>} row @return {string[]} */
|
|
97
|
+
const rowFormatter = row => row.map(value => value.toString()).map(escape);
|
|
98
|
+
|
|
99
|
+
// Possible TODO: tightly couple headers and row values
|
|
100
|
+
const header = ['requestedUrl', 'finalUrl', 'category', 'name', 'title', 'type', 'score'];
|
|
101
|
+
const table = Object.keys(lhr.categories).map(categoryId => {
|
|
102
|
+
const rows = [];
|
|
103
|
+
const category = lhr.categories[categoryId];
|
|
104
|
+
const overallCategoryScore = category.score === null ? -1 : category.score;
|
|
105
|
+
rows.push(rowFormatter([lhr.requestedUrl, lhr.finalUrl, category.title,
|
|
106
|
+
`${categoryId}-score`, `Overall ${category.title} Category Score`, 'numeric',
|
|
107
|
+
overallCategoryScore]));
|
|
108
|
+
return rows.concat(category.auditRefs.map(auditRef => {
|
|
128
109
|
const audit = lhr.audits[auditRef.id];
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
audit.displayValue || '',
|
|
136
|
-
audit.description,
|
|
137
|
-
]));
|
|
138
|
-
}
|
|
139
|
-
}
|
|
110
|
+
// CSV validator wants all scores to be numeric, use -1 for now
|
|
111
|
+
const numericScore = audit.score === null ? -1 : audit.score;
|
|
112
|
+
return rowFormatter([lhr.requestedUrl, lhr.finalUrl, category.title, audit.id, audit.title,
|
|
113
|
+
audit.scoreDisplayMode, numericScore]);
|
|
114
|
+
}));
|
|
115
|
+
});
|
|
140
116
|
|
|
141
|
-
return
|
|
142
|
-
.map(row => row.join(separator))
|
|
143
|
-
.join(CRLF);
|
|
117
|
+
return [header].concat(...table)
|
|
118
|
+
.map(row => row.join(separator)).join(CRLF);
|
|
144
119
|
}
|
|
145
120
|
|
|
146
121
|
/**
|
package/report/renderer/api.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
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
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
|
+
'use strict';
|
|
7
|
+
|
|
6
8
|
|
|
7
9
|
import {DOM} from '../renderer/dom.js';
|
|
8
10
|
import {ReportRenderer} from '../renderer/report-renderer.js';
|