lighthouse 9.5.0-dev.20220329 → 9.5.0-dev.20220330
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 +20 -18
- package/dist/report/flow.js +1 -1
- package/dist/report/standalone.js +1 -1
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/devtools.js +26 -18
- package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +2 -1
- package/lighthouse-core/audits/byte-efficiency/efficient-animated-content.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/offscreen-images.js +3 -2
- package/lighthouse-core/audits/byte-efficiency/render-blocking-resources.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/unused-javascript.js +1 -1
- 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/dobetterweb/uses-http2.js +2 -1
- package/lighthouse-core/audits/long-tasks.js +3 -2
- package/lighthouse-core/audits/metrics/first-contentful-paint-3g.js +2 -2
- package/lighthouse-core/audits/metrics/first-contentful-paint.js +3 -2
- package/lighthouse-core/audits/metrics/first-meaningful-paint.js +3 -2
- package/lighthouse-core/audits/metrics/interactive.js +3 -2
- package/lighthouse-core/audits/metrics/largest-contentful-paint.js +3 -2
- package/lighthouse-core/audits/metrics/max-potential-fid.js +3 -2
- package/lighthouse-core/audits/metrics/speed-index.js +3 -2
- package/lighthouse-core/audits/metrics/total-blocking-time.js +3 -2
- package/lighthouse-core/audits/metrics.js +3 -2
- package/lighthouse-core/audits/predictive-perf.js +2 -1
- package/lighthouse-core/audits/preload-lcp-image.js +1 -1
- package/lighthouse-core/audits/redirects.js +1 -1
- package/lighthouse-core/audits/timing-budget.js +3 -2
- package/lighthouse-core/audits/uses-rel-preconnect.js +1 -1
- package/lighthouse-core/audits/uses-rel-preload.js +1 -1
- package/lighthouse-core/computed/critical-request-chains.js +2 -9
- package/lighthouse-core/computed/main-resource.js +1 -1
- 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 +3 -5
- 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 +1 -0
- package/lighthouse-core/computed/metrics/speed-index.js +1 -1
- package/lighthouse-core/computed/metrics/timing-summary.js +13 -6
- package/lighthouse-core/computed/metrics/total-blocking-time.js +1 -1
- package/lighthouse-core/computed/page-dependency-graph.js +54 -31
- package/lighthouse-core/gather/driver/execution-context.js +4 -2
- package/lighthouse-core/gather/gatherers/js-usage.js +7 -6
- package/lighthouse-core/gather/gatherers/scripts.js +20 -2
- package/lighthouse-core/lib/dependency-graph/simulator/network-analyzer.js +8 -29
- package/lighthouse-core/lib/navigation-error.js +13 -4
- package/lighthouse-core/util-commonjs.js +20 -18
- package/package.json +1 -1
- package/report/renderer/util.js +20 -18
- package/types/artifacts.d.ts +1 -0
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const INITIAL_CWD = 14 * 1024;
|
|
9
|
-
const NetworkRequest = require('../../network-request.js');
|
|
10
9
|
const URL = require('../../url-shim.js');
|
|
11
10
|
|
|
12
11
|
// Assume that 40% of TTFB was server response time by default for static assets
|
|
@@ -434,40 +433,20 @@ class NetworkAnalyzer {
|
|
|
434
433
|
|
|
435
434
|
/**
|
|
436
435
|
* @param {Array<LH.Artifacts.NetworkRequest>} records
|
|
437
|
-
* @param {string}
|
|
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]
|
|
436
|
+
* @param {string} resourceUrl
|
|
449
437
|
* @return {LH.Artifacts.NetworkRequest|undefined}
|
|
450
438
|
*/
|
|
451
|
-
static
|
|
452
|
-
//
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
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));
|
|
439
|
+
static findResourceForUrl(records, resourceUrl) {
|
|
440
|
+
// equalWithExcludedFragments is expensive, so check that the resourceUrl starts with the request url first
|
|
441
|
+
return records.find(request =>
|
|
442
|
+
resourceUrl.startsWith(request.url) &&
|
|
443
|
+
URL.equalWithExcludedFragments(request.url, resourceUrl)
|
|
444
|
+
);
|
|
466
445
|
}
|
|
467
446
|
|
|
468
447
|
/**
|
|
469
448
|
* Resolves redirect chain given a main document.
|
|
470
|
-
* See: {@link NetworkAnalyzer.
|
|
449
|
+
* See: {@link NetworkAnalyzer.findResourceForUrl}) for how to retrieve main document.
|
|
471
450
|
*
|
|
472
451
|
* @param {LH.Artifacts.NetworkRequest} request
|
|
473
452
|
* @return {LH.Artifacts.NetworkRequest}
|
|
@@ -7,6 +7,7 @@
|
|
|
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');
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Returns an error if the original network request failed or wasn't found.
|
|
@@ -100,10 +101,18 @@ function getNonHtmlError(finalRecord) {
|
|
|
100
101
|
function getPageLoadError(navigationError, context) {
|
|
101
102
|
const {url, loadFailureMode, networkRecords} = context;
|
|
102
103
|
/** @type {LH.Artifacts.NetworkRequest|undefined} */
|
|
103
|
-
let mainRecord;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
let mainRecord = NetworkAnalyzer.findResourceForUrl(networkRecords, url);
|
|
105
|
+
|
|
106
|
+
// If the url doesn't give us a network request, it's possible we landed on a chrome-error:// page
|
|
107
|
+
// In this case, just get the first document request.
|
|
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
|
+
}
|
|
107
116
|
|
|
108
117
|
// MIME Type is only set on the final redirected document request. Use this for the HTML check instead of root.
|
|
109
118
|
let finalRecord;
|
|
@@ -318,24 +318,26 @@ class Util {
|
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
const MAX_LENGTH = 64;
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
321
|
+
if (parsedUrl.protocol !== 'data:') {
|
|
322
|
+
// Always elide hexadecimal hash
|
|
323
|
+
name = name.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g, `$1${ELLIPSIS}`);
|
|
324
|
+
// Also elide other hash-like mixed-case strings
|
|
325
|
+
name = name.replace(/([a-zA-Z0-9-_]{9})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9-_]{10,}/g,
|
|
326
|
+
`$1${ELLIPSIS}`);
|
|
327
|
+
// Also elide long number sequences
|
|
328
|
+
name = name.replace(/(\d{3})\d{6,}/g, `$1${ELLIPSIS}`);
|
|
329
|
+
// Merge any adjacent ellipses
|
|
330
|
+
name = name.replace(/\u2026+/g, ELLIPSIS);
|
|
331
|
+
|
|
332
|
+
// Elide query params first
|
|
333
|
+
if (name.length > MAX_LENGTH && name.includes('?')) {
|
|
334
|
+
// Try to leave the first query parameter intact
|
|
335
|
+
name = name.replace(/\?([^=]*)(=)?.*/, `?$1$2${ELLIPSIS}`);
|
|
336
|
+
|
|
337
|
+
// Remove it all if it's still too long
|
|
338
|
+
if (name.length > MAX_LENGTH) {
|
|
339
|
+
name = name.replace(/\?.*/, `?${ELLIPSIS}`);
|
|
340
|
+
}
|
|
339
341
|
}
|
|
340
342
|
}
|
|
341
343
|
|
package/package.json
CHANGED
package/report/renderer/util.js
CHANGED
|
@@ -315,24 +315,26 @@ class Util {
|
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
const MAX_LENGTH = 64;
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
318
|
+
if (parsedUrl.protocol !== 'data:') {
|
|
319
|
+
// Always elide hexadecimal hash
|
|
320
|
+
name = name.replace(/([a-f0-9]{7})[a-f0-9]{13}[a-f0-9]*/g, `$1${ELLIPSIS}`);
|
|
321
|
+
// Also elide other hash-like mixed-case strings
|
|
322
|
+
name = name.replace(/([a-zA-Z0-9-_]{9})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9-_]{10,}/g,
|
|
323
|
+
`$1${ELLIPSIS}`);
|
|
324
|
+
// Also elide long number sequences
|
|
325
|
+
name = name.replace(/(\d{3})\d{6,}/g, `$1${ELLIPSIS}`);
|
|
326
|
+
// Merge any adjacent ellipses
|
|
327
|
+
name = name.replace(/\u2026+/g, ELLIPSIS);
|
|
328
|
+
|
|
329
|
+
// Elide query params first
|
|
330
|
+
if (name.length > MAX_LENGTH && name.includes('?')) {
|
|
331
|
+
// Try to leave the first query parameter intact
|
|
332
|
+
name = name.replace(/\?([^=]*)(=)?.*/, `?$1$2${ELLIPSIS}`);
|
|
333
|
+
|
|
334
|
+
// Remove it all if it's still too long
|
|
335
|
+
if (name.length > MAX_LENGTH) {
|
|
336
|
+
name = name.replace(/\?.*/, `?${ELLIPSIS}`);
|
|
337
|
+
}
|
|
336
338
|
}
|
|
337
339
|
}
|
|
338
340
|
|
package/types/artifacts.d.ts
CHANGED
|
@@ -641,6 +641,7 @@ declare module Artifacts {
|
|
|
641
641
|
settings: Immutable<Config.Settings>;
|
|
642
642
|
gatherContext: Artifacts['GatherContext'];
|
|
643
643
|
simulator?: InstanceType<typeof LanternSimulator>;
|
|
644
|
+
URL: Artifacts['URL'];
|
|
644
645
|
}
|
|
645
646
|
|
|
646
647
|
interface MetricComputationData extends MetricComputationDataInput {
|