lighthouse 12.4.0-dev.20250320 → 12.4.0-dev.20250321
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.
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */ // TODO: remove once implemented.
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* @license
|
|
5
3
|
* Copyright 2025 Google LLC
|
|
@@ -10,7 +8,7 @@ import {UIStrings} from '@paulirish/trace_engine/models/trace/insights/UseCache.
|
|
|
10
8
|
|
|
11
9
|
import {Audit} from '../audit.js';
|
|
12
10
|
import * as i18n from '../../lib/i18n/i18n.js';
|
|
13
|
-
import {adaptInsightToAuditProduct
|
|
11
|
+
import {adaptInsightToAuditProduct} from './insight-audit.js';
|
|
14
12
|
|
|
15
13
|
// eslint-disable-next-line max-len
|
|
16
14
|
const str_ = i18n.createIcuMessageFn('node_modules/@paulirish/trace_engine/models/trace/insights/UseCache.js', UIStrings);
|
|
@@ -25,8 +23,9 @@ class UseCacheInsight extends Audit {
|
|
|
25
23
|
title: str_(UIStrings.title),
|
|
26
24
|
failureTitle: str_(UIStrings.title),
|
|
27
25
|
description: str_(UIStrings.description),
|
|
28
|
-
guidanceLevel: 3,
|
|
29
|
-
requiredArtifacts: ['traces', '
|
|
26
|
+
guidanceLevel: 3,
|
|
27
|
+
requiredArtifacts: ['traces', 'SourceMaps'],
|
|
28
|
+
replacesAudits: ['uses-long-cache-ttl'],
|
|
30
29
|
};
|
|
31
30
|
}
|
|
32
31
|
|
|
@@ -36,17 +35,25 @@ class UseCacheInsight extends Audit {
|
|
|
36
35
|
* @return {Promise<LH.Audit.Product>}
|
|
37
36
|
*/
|
|
38
37
|
static async audit(artifacts, context) {
|
|
39
|
-
// TODO: implement.
|
|
40
38
|
return adaptInsightToAuditProduct(artifacts, context, 'UseCache', (insight) => {
|
|
41
39
|
/** @type {LH.Audit.Details.Table['headings']} */
|
|
42
40
|
const headings = [
|
|
43
41
|
/* eslint-disable max-len */
|
|
42
|
+
{key: 'url', valueType: 'url', label: str_(UIStrings.requestColumn)},
|
|
43
|
+
{key: 'cacheLifetimeMs', valueType: 'ms', label: str_(UIStrings.cacheTTL), displayUnit: 'duration'},
|
|
44
|
+
{key: 'totalBytes', valueType: 'bytes', label: str_(i18n.UIStrings.columnTransferSize), displayUnit: 'kb', granularity: 1},
|
|
44
45
|
/* eslint-enable max-len */
|
|
45
46
|
];
|
|
46
47
|
/** @type {LH.Audit.Details.Table['items']} */
|
|
47
|
-
const items =
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const items = insight.requests.map(request => ({
|
|
49
|
+
url: request.request.args.data.url,
|
|
50
|
+
cacheLifetimeMs: request.ttl * 1000,
|
|
51
|
+
totalBytes: request.request.args.data.encodedDataLength,
|
|
52
|
+
}));
|
|
53
|
+
return Audit.makeTableDetails(headings, items, {
|
|
54
|
+
sortedBy: ['totalBytes'],
|
|
55
|
+
skipSumming: ['cacheLifetimeMs'],
|
|
56
|
+
});
|
|
50
57
|
});
|
|
51
58
|
}
|
|
52
59
|
}
|
package/package.json
CHANGED