lighthouse 12.4.0-dev.20250319 → 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.
- package/core/audits/audit.js +2 -1
- package/core/audits/byte-efficiency/offscreen-images.js +2 -1
- package/core/audits/byte-efficiency/unused-javascript.js +1 -1
- package/core/audits/insights/use-cache-insight.js +16 -9
- package/core/audits/largest-contentful-paint-element.js +5 -2
- package/core/audits/long-tasks.js +2 -1
- package/core/audits/metrics/first-contentful-paint.js +3 -1
- package/core/audits/metrics/interactive.js +5 -2
- package/core/audits/metrics/largest-contentful-paint.js +5 -2
- package/core/audits/metrics/max-potential-fid.js +5 -2
- package/core/audits/metrics/speed-index.js +5 -2
- package/core/audits/metrics/total-blocking-time.js +5 -2
- package/core/audits/predictive-perf.js +2 -1
- package/core/audits/prioritize-lcp-image.js +2 -1
- package/core/audits/redirects.js +2 -1
- package/core/audits/script-treemap-data.js +1 -1
- package/core/audits/uses-rel-preconnect.js +3 -2
- package/core/audits/uses-rel-preload.js +2 -1
- package/core/computed/computed-artifact.d.ts +5 -1
- package/core/computed/computed-artifact.js +23 -2
- package/core/computed/critical-request-chains.js +1 -1
- package/core/computed/metrics/lantern-metric.js +1 -1
- package/core/computed/metrics/metric.js +1 -0
- package/core/computed/metrics/timing-summary.js +3 -1
- package/core/computed/page-dependency-graph.d.ts +3 -3
- package/core/computed/page-dependency-graph.js +1 -1
- package/core/computed/unused-javascript-summary.d.ts +2 -2
- package/core/computed/unused-javascript-summary.js +1 -1
- package/package.json +1 -1
- package/types/artifacts.d.ts +1 -1
package/core/audits/audit.js
CHANGED
|
@@ -492,7 +492,8 @@ class Audit {
|
|
|
492
492
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
493
493
|
const gatherContext = artifacts.GatherContext;
|
|
494
494
|
const {URL, SourceMaps} = artifacts;
|
|
495
|
-
|
|
495
|
+
// eslint-disable-next-line max-len
|
|
496
|
+
return {trace, devtoolsLog, gatherContext, settings: context.settings, URL, SourceMaps, simulator: null};
|
|
496
497
|
}
|
|
497
498
|
}
|
|
498
499
|
|
|
@@ -199,7 +199,8 @@ class OffscreenImages extends ByteEfficiencyAudit {
|
|
|
199
199
|
const unfilteredResults = Array.from(resultsMap.values());
|
|
200
200
|
// get the interactive time or fallback to getting the end of trace time
|
|
201
201
|
try {
|
|
202
|
-
const metricComputationData =
|
|
202
|
+
const metricComputationData =
|
|
203
|
+
{trace, devtoolsLog, gatherContext, settings, URL, SourceMaps, simulator: null};
|
|
203
204
|
const interactive = await Interactive.request(metricComputationData, context);
|
|
204
205
|
|
|
205
206
|
// use interactive to generate items
|
|
@@ -94,7 +94,7 @@ class UnusedJavaScript extends ByteEfficiencyAudit {
|
|
|
94
94
|
const script = artifacts.Scripts.find(s => s.scriptId === scriptId);
|
|
95
95
|
if (!script) continue; // This should never happen.
|
|
96
96
|
|
|
97
|
-
const bundle = bundles.find(b => b.script.scriptId === scriptId);
|
|
97
|
+
const bundle = bundles.find(b => b.script.scriptId === scriptId) ?? null;
|
|
98
98
|
const unusedJsSummary =
|
|
99
99
|
await UnusedJavascriptSummary.request({scriptId, scriptCoverage, bundle}, context);
|
|
100
100
|
if (unusedJsSummary.wastedBytes === 0 || unusedJsSummary.totalBytes === 0) continue;
|
|
@@ -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
|
}
|
|
@@ -123,8 +123,11 @@ class LargestContentfulPaintElement extends Audit {
|
|
|
123
123
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
124
124
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
125
125
|
const gatherContext = artifacts.GatherContext;
|
|
126
|
-
const metricComputationData = {
|
|
127
|
-
|
|
126
|
+
const metricComputationData = {
|
|
127
|
+
trace, devtoolsLog, gatherContext,
|
|
128
|
+
settings: context.settings, URL: artifacts.URL,
|
|
129
|
+
SourceMaps: artifacts.SourceMaps, simulator: null,
|
|
130
|
+
};
|
|
128
131
|
|
|
129
132
|
const elementTable = this.makeElementTable(artifacts);
|
|
130
133
|
if (!elementTable) {
|
|
@@ -193,7 +193,8 @@ class LongTasks extends Audit {
|
|
|
193
193
|
|
|
194
194
|
const simulatorOptions = {devtoolsLog, settings: context.settings};
|
|
195
195
|
const pageGraph =
|
|
196
|
-
|
|
196
|
+
// eslint-disable-next-line max-len
|
|
197
|
+
await PageDependencyGraph.request({settings, trace, devtoolsLog, URL, SourceMaps, fromTrace: false}, context);
|
|
197
198
|
const simulator = await LoadSimulator.request(simulatorOptions, context);
|
|
198
199
|
const simulation = simulator.simulate(pageGraph, {label: 'long-tasks-diagnostic'});
|
|
199
200
|
for (const [node, timing] of simulation.nodeTimings.entries()) {
|
|
@@ -65,7 +65,9 @@ class FirstContentfulPaint extends Audit {
|
|
|
65
65
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
66
66
|
const gatherContext = artifacts.GatherContext;
|
|
67
67
|
const metricComputationData = {trace, devtoolsLog, gatherContext,
|
|
68
|
-
settings: context.settings, URL: artifacts.URL,
|
|
68
|
+
settings: context.settings, URL: artifacts.URL,
|
|
69
|
+
SourceMaps: artifacts.SourceMaps, simulator: null,
|
|
70
|
+
};
|
|
69
71
|
const metricResult = await ComputedFcp.request(metricComputationData, context);
|
|
70
72
|
const options = context.options[context.settings.formFactor];
|
|
71
73
|
|
|
@@ -70,8 +70,11 @@ class InteractiveMetric extends Audit {
|
|
|
70
70
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
71
71
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
72
72
|
const gatherContext = artifacts.GatherContext;
|
|
73
|
-
const metricComputationData = {
|
|
74
|
-
|
|
73
|
+
const metricComputationData = {
|
|
74
|
+
trace, devtoolsLog, gatherContext,
|
|
75
|
+
settings: context.settings, URL: artifacts.URL,
|
|
76
|
+
SourceMaps: artifacts.SourceMaps, simulator: null,
|
|
77
|
+
};
|
|
75
78
|
const metricResult = await Interactive.request(metricComputationData, context);
|
|
76
79
|
const timeInMs = metricResult.timing;
|
|
77
80
|
const options = context.options[context.settings.formFactor];
|
|
@@ -73,8 +73,11 @@ class LargestContentfulPaint extends Audit {
|
|
|
73
73
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
74
74
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
75
75
|
const gatherContext = artifacts.GatherContext;
|
|
76
|
-
const metricComputationData = {
|
|
77
|
-
|
|
76
|
+
const metricComputationData = {
|
|
77
|
+
trace, devtoolsLog, gatherContext,
|
|
78
|
+
settings: context.settings, URL: artifacts.URL,
|
|
79
|
+
SourceMaps: artifacts.SourceMaps, simulator: null,
|
|
80
|
+
};
|
|
78
81
|
|
|
79
82
|
const metricResult = await ComputedLcp.request(metricComputationData, context);
|
|
80
83
|
const options = context.options[context.settings.formFactor];
|
|
@@ -120,8 +120,11 @@ class MaxPotentialFID extends Audit {
|
|
|
120
120
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
121
121
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
122
122
|
const gatherContext = artifacts.GatherContext;
|
|
123
|
-
const metricComputationData = {
|
|
124
|
-
|
|
123
|
+
const metricComputationData = {
|
|
124
|
+
trace, devtoolsLog, gatherContext,
|
|
125
|
+
settings: context.settings, URL: artifacts.URL,
|
|
126
|
+
SourceMaps: artifacts.SourceMaps, simulator: null,
|
|
127
|
+
};
|
|
125
128
|
const metricResult = await ComputedFid.request(metricComputationData, context);
|
|
126
129
|
|
|
127
130
|
const processedTrace = await ProcessedTrace.request(trace, context);
|
|
@@ -66,8 +66,11 @@ class SpeedIndex extends Audit {
|
|
|
66
66
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
67
67
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
68
68
|
const gatherContext = artifacts.GatherContext;
|
|
69
|
-
const metricComputationData = {
|
|
70
|
-
|
|
69
|
+
const metricComputationData = {
|
|
70
|
+
trace, devtoolsLog, gatherContext,
|
|
71
|
+
settings: context.settings, URL: artifacts.URL,
|
|
72
|
+
SourceMaps: artifacts.SourceMaps, simulator: null,
|
|
73
|
+
};
|
|
71
74
|
const metricResult = await ComputedSi.request(metricComputationData, context);
|
|
72
75
|
const options = context.options[context.settings.formFactor];
|
|
73
76
|
|
|
@@ -88,8 +88,11 @@ class TotalBlockingTime extends Audit {
|
|
|
88
88
|
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
89
89
|
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
90
90
|
const gatherContext = artifacts.GatherContext;
|
|
91
|
-
const metricComputationData = {
|
|
92
|
-
|
|
91
|
+
const metricComputationData = {
|
|
92
|
+
trace, devtoolsLog, gatherContext,
|
|
93
|
+
settings: context.settings, URL: artifacts.URL,
|
|
94
|
+
SourceMaps: artifacts.SourceMaps, simulator: null,
|
|
95
|
+
};
|
|
93
96
|
if (
|
|
94
97
|
gatherContext.gatherMode === 'timespan' &&
|
|
95
98
|
context.settings.throttlingMethod === 'simulate'
|
|
@@ -49,7 +49,8 @@ class PredictivePerf extends Audit {
|
|
|
49
49
|
const {URL, SourceMaps} = artifacts;
|
|
50
50
|
/** @type {LH.Config.Settings} */
|
|
51
51
|
const settings = JSON.parse(JSON.stringify(defaultSettings)); // Use default settings.
|
|
52
|
-
const computationData =
|
|
52
|
+
const computationData =
|
|
53
|
+
{trace, devtoolsLog, gatherContext, settings, URL, SourceMaps, simulator: null};
|
|
53
54
|
const fcp = await LanternFirstContentfulPaint.request(computationData, context);
|
|
54
55
|
const tti = await LanternInteractive.request(computationData, context);
|
|
55
56
|
const si = await LanternSpeedIndex.request(computationData, context);
|
|
@@ -240,7 +240,8 @@ class PrioritizeLcpImage extends Audit {
|
|
|
240
240
|
const devtoolsLog = artifacts.devtoolsLogs[PrioritizeLcpImage.DEFAULT_PASS];
|
|
241
241
|
const {URL, SourceMaps} = artifacts;
|
|
242
242
|
const settings = context.settings;
|
|
243
|
-
const metricData =
|
|
243
|
+
const metricData =
|
|
244
|
+
{trace, devtoolsLog, gatherContext, settings, URL, SourceMaps, simulator: null};
|
|
244
245
|
const lcpElement = artifacts.TraceElements
|
|
245
246
|
.find(element => element.traceEventType === 'largest-contentful-paint');
|
|
246
247
|
|
package/core/audits/redirects.js
CHANGED
|
@@ -93,7 +93,8 @@ class Redirects extends Audit {
|
|
|
93
93
|
const networkRecords = await NetworkRecords.request(devtoolsLog, context);
|
|
94
94
|
const documentRequests = Redirects.getDocumentRequestChain(networkRecords, processedTrace);
|
|
95
95
|
|
|
96
|
-
const metricComputationData =
|
|
96
|
+
const metricComputationData =
|
|
97
|
+
{trace, devtoolsLog, gatherContext, settings, URL, SourceMaps, simulator: null};
|
|
97
98
|
const metricResult = await LanternInteractive.request(metricComputationData, context);
|
|
98
99
|
|
|
99
100
|
/** @type {Map<string, LH.Gatherer.Simulation.NodeTiming>} */
|
|
@@ -178,7 +178,7 @@ class ScriptTreemapDataAudit extends Audit {
|
|
|
178
178
|
if (script.scriptLanguage !== 'JavaScript') continue;
|
|
179
179
|
|
|
180
180
|
const name = script.url;
|
|
181
|
-
const bundle = bundles.find(bundle => script.scriptId === bundle.script.scriptId);
|
|
181
|
+
const bundle = bundles.find(bundle => script.scriptId === bundle.script.scriptId) ?? null;
|
|
182
182
|
const scriptCoverage = /** @type {LH.Artifacts['JsUsage'][string] | undefined} */
|
|
183
183
|
(artifacts.JsUsage[script.scriptId]);
|
|
184
184
|
const unusedJavascriptSummary = scriptCoverage ?
|
|
@@ -124,8 +124,8 @@ class UsesRelPreconnectAudit extends Audit {
|
|
|
124
124
|
static async audit(artifacts, context) {
|
|
125
125
|
const trace = artifacts.traces[UsesRelPreconnectAudit.DEFAULT_PASS];
|
|
126
126
|
const devtoolsLog = artifacts.devtoolsLogs[UsesRelPreconnectAudit.DEFAULT_PASS];
|
|
127
|
-
const settings = context.settings;
|
|
128
127
|
const {URL, SourceMaps} = artifacts;
|
|
128
|
+
const settings = context.settings;
|
|
129
129
|
|
|
130
130
|
let maxWastedLcp = 0;
|
|
131
131
|
let maxWastedFcp = 0;
|
|
@@ -138,7 +138,8 @@ class UsesRelPreconnectAudit extends Audit {
|
|
|
138
138
|
MainResource.request({devtoolsLog, URL}, context),
|
|
139
139
|
LoadSimulator.request({devtoolsLog, settings}, context),
|
|
140
140
|
ProcessedNavigation.request(trace, context),
|
|
141
|
-
PageDependencyGraph.request(
|
|
141
|
+
PageDependencyGraph.request(
|
|
142
|
+
{settings, trace, devtoolsLog, URL, SourceMaps, fromTrace: false}, context),
|
|
142
143
|
]);
|
|
143
144
|
|
|
144
145
|
const {rtt, additionalRttByOrigin} = loadSimulator.getOptions();
|
|
@@ -220,7 +220,8 @@ class UsesRelPreloadAudit extends Audit {
|
|
|
220
220
|
|
|
221
221
|
const [mainResource, graph, simulator] = await Promise.all([
|
|
222
222
|
MainResource.request({devtoolsLog, URL}, context),
|
|
223
|
-
PageDependencyGraph.request(
|
|
223
|
+
PageDependencyGraph.request(
|
|
224
|
+
{settings, trace, devtoolsLog, URL, SourceMaps, fromTrace: false}, context),
|
|
224
225
|
LoadSimulator.request(simulatorOptions, context),
|
|
225
226
|
]);
|
|
226
227
|
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
* @template {{name: string, compute_(dependencies: unknown, context: LH.Artifacts.ComputedContext): Promise<unknown>}} C
|
|
5
5
|
* @template {Array<keyof LH.Util.FirstParamType<C['compute_']>>} K
|
|
6
6
|
* @param {C} computableArtifact
|
|
7
|
-
* @param {(K & ([keyof LH.Util.FirstParamType<C['compute_']>] extends [K[number]] ? unknown : never)) | null} keys
|
|
7
|
+
* @param {(K & ([keyof LH.Util.FirstParamType<C['compute_']>] extends [K[number]] ? unknown : never)) | null} keys
|
|
8
|
+
* List of properties of `dependencies` used by `compute_`; other properties are filtered out.
|
|
9
|
+
* Use `null` to allow all properties. Ensures that only required properties are used for caching result.
|
|
10
|
+
* For optional properties of `dependencies`, undefined cannot be used and if found is treated as an error.
|
|
11
|
+
* This is to guard against developer mistakes. For optional properties, make it nullable instead.
|
|
8
12
|
*/
|
|
9
13
|
export function makeComputedArtifact<C extends {
|
|
10
14
|
name: string;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import log from 'lighthouse-logger';
|
|
8
8
|
|
|
9
9
|
import {ArbitraryEqualityMap} from '../lib/arbitrary-equality-map.js';
|
|
10
|
+
import {isUnderTest} from '../lib/lh-env.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Decorate computableArtifact with a caching `request()` method which will
|
|
@@ -14,7 +15,11 @@ import {ArbitraryEqualityMap} from '../lib/arbitrary-equality-map.js';
|
|
|
14
15
|
* @template {{name: string, compute_(dependencies: unknown, context: LH.Artifacts.ComputedContext): Promise<unknown>}} C
|
|
15
16
|
* @template {Array<keyof LH.Util.FirstParamType<C['compute_']>>} K
|
|
16
17
|
* @param {C} computableArtifact
|
|
17
|
-
* @param {(K & ([keyof LH.Util.FirstParamType<C['compute_']>] extends [K[number]] ? unknown : never)) | null} keys
|
|
18
|
+
* @param {(K & ([keyof LH.Util.FirstParamType<C['compute_']>] extends [K[number]] ? unknown : never)) | null} keys
|
|
19
|
+
* List of properties of `dependencies` used by `compute_`; other properties are filtered out.
|
|
20
|
+
* Use `null` to allow all properties. Ensures that only required properties are used for caching result.
|
|
21
|
+
* For optional properties of `dependencies`, undefined cannot be used and if found is treated as an error.
|
|
22
|
+
* This is to guard against developer mistakes. For optional properties, make it nullable instead.
|
|
18
23
|
*/
|
|
19
24
|
function makeComputedArtifact(computableArtifact, keys) {
|
|
20
25
|
// tsc (3.1) has more difficulty with template inter-references in jsdoc, so
|
|
@@ -27,13 +32,29 @@ function makeComputedArtifact(computableArtifact, keys) {
|
|
|
27
32
|
* @return {ReturnType<C['compute_']>}
|
|
28
33
|
*/
|
|
29
34
|
const request = (dependencies, context) => {
|
|
35
|
+
const computedName = computableArtifact.name;
|
|
36
|
+
|
|
37
|
+
// Guard against missing properties. Optional properties must be passed as null - if missing or
|
|
38
|
+
// undefined, throw an error.
|
|
39
|
+
for (const key of keys || []) {
|
|
40
|
+
if (dependencies && typeof dependencies === 'object' && dependencies[key] === undefined) {
|
|
41
|
+
// eslint-disable-next-line max-len
|
|
42
|
+
const err = new Error(`missing required key "${String(key)}" for computed artifact ${computableArtifact.name}`);
|
|
43
|
+
if (isUnderTest) {
|
|
44
|
+
throw err;
|
|
45
|
+
} else {
|
|
46
|
+
// For now, simply log in production.
|
|
47
|
+
log.error(`lh:computed:${computedName}`, err);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
30
52
|
const pickedDependencies = keys ?
|
|
31
53
|
Object.fromEntries(keys.map(key => [key, dependencies[key]])) :
|
|
32
54
|
dependencies;
|
|
33
55
|
|
|
34
56
|
// NOTE: break immutability solely for this caching-controller function.
|
|
35
57
|
const computedCache = /** @type {Map<string, ArbitraryEqualityMap>} */ (context.computedCache);
|
|
36
|
-
const computedName = computableArtifact.name;
|
|
37
58
|
|
|
38
59
|
const cache = computedCache.get(computedName) || new ArbitraryEqualityMap();
|
|
39
60
|
computedCache.set(computedName, cache);
|
|
@@ -132,7 +132,7 @@ class CriticalRequestChains {
|
|
|
132
132
|
*/
|
|
133
133
|
static async compute_(data, context) {
|
|
134
134
|
const mainResource = await MainResource.request(data, context);
|
|
135
|
-
const graph = await PageDependencyGraph.request(data, context);
|
|
135
|
+
const graph = await PageDependencyGraph.request({...data, fromTrace: false}, context);
|
|
136
136
|
|
|
137
137
|
return CriticalRequestChains.extractChainsFromGraph(mainResource, graph);
|
|
138
138
|
}
|
|
@@ -20,7 +20,7 @@ async function getComputationDataParamsFromDevtoolsLog(data, context) {
|
|
|
20
20
|
throw new Error(`Lantern metrics can only be computed on navigations`);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const graph = await PageDependencyGraph.request(data, context);
|
|
23
|
+
const graph = await PageDependencyGraph.request({...data, fromTrace: false}, context);
|
|
24
24
|
const processedNavigation = await ProcessedNavigation.request(data.trace, context);
|
|
25
25
|
const simulator = data.simulator || (await LoadSimulator.request(data, context));
|
|
26
26
|
|
|
@@ -32,7 +32,9 @@ class TimingSummary {
|
|
|
32
32
|
* @return {Promise<{metrics: LH.Artifacts.TimingSummary, debugInfo: Record<string,boolean>}>}
|
|
33
33
|
*/
|
|
34
34
|
static async summarize(trace, devtoolsLog, gatherContext, settings, URL, SourceMaps, context) {
|
|
35
|
-
const metricComputationData =
|
|
35
|
+
const metricComputationData =
|
|
36
|
+
{trace, devtoolsLog, gatherContext, settings, URL, SourceMaps, simulator: null};
|
|
37
|
+
|
|
36
38
|
/**
|
|
37
39
|
* @template TArtifacts
|
|
38
40
|
* @template TReturn
|
|
@@ -6,12 +6,12 @@ declare const PageDependencyGraphComputed: typeof PageDependencyGraph & {
|
|
|
6
6
|
settings: LH.Audit.Context["settings"];
|
|
7
7
|
URL: LH.Artifacts["URL"];
|
|
8
8
|
SourceMaps: LH.Artifacts["SourceMaps"];
|
|
9
|
-
fromTrace
|
|
9
|
+
fromTrace: boolean;
|
|
10
10
|
}, context: LH.Artifacts.ComputedContext) => ReturnType<typeof PageDependencyGraph.compute_>;
|
|
11
11
|
};
|
|
12
12
|
declare class PageDependencyGraph {
|
|
13
13
|
/**
|
|
14
|
-
* @param {{trace: LH.Trace, devtoolsLog: LH.DevtoolsLog, settings: LH.Audit.Context['settings'], URL: LH.Artifacts['URL'], SourceMaps: LH.Artifacts['SourceMaps'], fromTrace
|
|
14
|
+
* @param {{trace: LH.Trace, devtoolsLog: LH.DevtoolsLog, settings: LH.Audit.Context['settings'], URL: LH.Artifacts['URL'], SourceMaps: LH.Artifacts['SourceMaps'], fromTrace: boolean}} data
|
|
15
15
|
* @param {LH.Artifacts.ComputedContext} context
|
|
16
16
|
* @return {Promise<LH.Gatherer.Simulation.GraphNode>}
|
|
17
17
|
*/
|
|
@@ -21,7 +21,7 @@ declare class PageDependencyGraph {
|
|
|
21
21
|
settings: LH.Audit.Context["settings"];
|
|
22
22
|
URL: LH.Artifacts["URL"];
|
|
23
23
|
SourceMaps: LH.Artifacts["SourceMaps"];
|
|
24
|
-
fromTrace
|
|
24
|
+
fromTrace: boolean;
|
|
25
25
|
}, context: LH.Artifacts.ComputedContext): Promise<LH.Gatherer.Simulation.GraphNode>;
|
|
26
26
|
}
|
|
27
27
|
//# sourceMappingURL=page-dependency-graph.d.ts.map
|
|
@@ -13,7 +13,7 @@ import {TraceEngineResult} from './trace-engine-result.js';
|
|
|
13
13
|
|
|
14
14
|
class PageDependencyGraph {
|
|
15
15
|
/**
|
|
16
|
-
* @param {{trace: LH.Trace, devtoolsLog: LH.DevtoolsLog, settings: LH.Audit.Context['settings'], URL: LH.Artifacts['URL'], SourceMaps: LH.Artifacts['SourceMaps'], fromTrace
|
|
16
|
+
* @param {{trace: LH.Trace, devtoolsLog: LH.DevtoolsLog, settings: LH.Audit.Context['settings'], URL: LH.Artifacts['URL'], SourceMaps: LH.Artifacts['SourceMaps'], fromTrace: boolean}} data
|
|
17
17
|
* @param {LH.Artifacts.ComputedContext} context
|
|
18
18
|
* @return {Promise<LH.Gatherer.Simulation.GraphNode>}
|
|
19
19
|
*/
|
|
@@ -7,7 +7,7 @@ export type WasteData = {
|
|
|
7
7
|
export type ComputeInput = {
|
|
8
8
|
scriptId: string;
|
|
9
9
|
scriptCoverage: Omit<LH.Crdp.Profiler.ScriptCoverage, "url">;
|
|
10
|
-
bundle
|
|
10
|
+
bundle: LH.Artifacts.Bundle | null;
|
|
11
11
|
};
|
|
12
12
|
export type Summary = {
|
|
13
13
|
scriptId: string;
|
|
@@ -32,7 +32,7 @@ declare const UnusedJavascriptSummaryComputed: typeof UnusedJavascriptSummary &
|
|
|
32
32
|
* @typedef ComputeInput
|
|
33
33
|
* @property {string} scriptId
|
|
34
34
|
* @property {Omit<LH.Crdp.Profiler.ScriptCoverage, 'url'>} scriptCoverage
|
|
35
|
-
* @property {LH.Artifacts.Bundle
|
|
35
|
+
* @property {LH.Artifacts.Bundle|null} bundle
|
|
36
36
|
*/
|
|
37
37
|
/**
|
|
38
38
|
* @typedef Summary
|
|
@@ -16,7 +16,7 @@ import {makeComputedArtifact} from './computed-artifact.js';
|
|
|
16
16
|
* @typedef ComputeInput
|
|
17
17
|
* @property {string} scriptId
|
|
18
18
|
* @property {Omit<LH.Crdp.Profiler.ScriptCoverage, 'url'>} scriptCoverage
|
|
19
|
-
* @property {LH.Artifacts.Bundle
|
|
19
|
+
* @property {LH.Artifacts.Bundle|null} bundle
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
/**
|
package/package.json
CHANGED
package/types/artifacts.d.ts
CHANGED
|
@@ -567,7 +567,7 @@ declare module Artifacts {
|
|
|
567
567
|
trace: Trace;
|
|
568
568
|
settings: Audit.Context['settings'];
|
|
569
569
|
gatherContext: Artifacts['GatherContext'];
|
|
570
|
-
simulator
|
|
570
|
+
simulator: Gatherer.Simulation.Simulator | null;
|
|
571
571
|
URL: Artifacts['URL'];
|
|
572
572
|
SourceMaps: Artifacts['SourceMaps'];
|
|
573
573
|
}
|