lighthouse 12.0.0-dev.20240609 → 12.0.0-dev.20240610
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/computed/metrics/lantern-metric.js +2 -2
- package/core/computed/metrics/lantern-speed-index.js +1 -1
- package/core/computed/metrics/total-blocking-time.js +1 -1
- package/core/computed/navigation-insights.d.ts +2 -22
- package/core/computed/page-dependency-graph.js +5 -2
- package/core/computed/tbt-impact-tasks.js +1 -1
- package/core/computed/trace-engine-result.d.ts +0 -12
- package/core/computed/trace-engine-result.js +5 -20
- package/core/gather/driver/target-manager.d.ts +1 -1
- package/core/gather/gatherers/root-causes.js +0 -1
- package/core/gather/session.d.ts +3 -3
- package/core/lib/lantern/lantern.d.ts +5 -10
- package/core/lib/lantern/lantern.js +0 -47
- package/core/lib/lantern/metric.d.ts +2 -4
- package/core/lib/lantern/metric.js +1 -1
- package/core/lib/lantern/metrics/speed-index.js +2 -2
- package/core/lib/lantern/metrics/total-blocking-time.js +1 -1
- package/core/lib/lantern/page-dependency-graph.d.ts +0 -43
- package/core/lib/lantern/page-dependency-graph.js +0 -342
- package/core/lib/lantern/trace-engine-computation-data.d.ts +25 -0
- package/core/lib/lantern/trace-engine-computation-data.js +464 -0
- package/package.json +5 -5
- package/types/artifacts.d.ts +2 -3
- /package/core/{computed/metrics → lib/lantern}/tbt-utils.d.ts +0 -0
- /package/core/{computed/metrics → lib/lantern}/tbt-utils.js +0 -0
|
@@ -10,7 +10,7 @@ import {LoadSimulator} from '../load-simulator.js';
|
|
|
10
10
|
import {ProcessedNavigation} from '../processed-navigation.js';
|
|
11
11
|
import {PageDependencyGraph} from '../page-dependency-graph.js';
|
|
12
12
|
import {TraceEngineResult} from '../trace-engine-result.js';
|
|
13
|
-
import {createProcessedNavigation} from '../../lib/lantern/
|
|
13
|
+
import {createProcessedNavigation} from '../../lib/lantern/trace-engine-computation-data.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @param {LH.Artifacts.MetricComputationDataInput} data
|
|
@@ -39,7 +39,7 @@ async function getComputationDataParamsFromTrace(data, context) {
|
|
|
39
39
|
|
|
40
40
|
const graph = await PageDependencyGraph.request({...data, fromTrace: true}, context);
|
|
41
41
|
const traceEngineResult = await TraceEngineResult.request(data, context);
|
|
42
|
-
const processedNavigation = createProcessedNavigation(traceEngineResult);
|
|
42
|
+
const processedNavigation = createProcessedNavigation(traceEngineResult.data);
|
|
43
43
|
const simulator = data.simulator || (await LoadSimulator.request(data, context));
|
|
44
44
|
|
|
45
45
|
return {simulator, graph, processedNavigation};
|
|
@@ -34,7 +34,7 @@ class LanternSpeedIndex extends SpeedIndex {
|
|
|
34
34
|
const speedline = await Speedline.request(data.trace, context);
|
|
35
35
|
const fcpResult = await LanternFirstContentfulPaint.request(data, context);
|
|
36
36
|
return this.computeMetricWithGraphs(data, context, {
|
|
37
|
-
speedline,
|
|
37
|
+
observedSpeedIndex: speedline.speedIndex,
|
|
38
38
|
fcpResult,
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -9,7 +9,7 @@ import ComputedMetric from './metric.js';
|
|
|
9
9
|
import {TraceProcessor} from '../../lib/tracehouse/trace-processor.js';
|
|
10
10
|
import {LanternTotalBlockingTime} from './lantern-total-blocking-time.js';
|
|
11
11
|
import {Interactive} from './interactive.js';
|
|
12
|
-
import {calculateSumOfBlockingTime} from '
|
|
12
|
+
import {calculateSumOfBlockingTime} from '../../lib/lantern/tbt-utils.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @fileoverview This audit determines Total Blocking Time.
|
|
@@ -2,17 +2,7 @@ export { NavigationInsightsComputed as NavigationInsights };
|
|
|
2
2
|
declare const NavigationInsightsComputed: typeof NavigationInsights & {
|
|
3
3
|
request: (dependencies: import("../index.js").Trace, context: import("../../types/utility-types.js").default.ImmutableObject<{
|
|
4
4
|
computedCache: Map<string, import("../lib/arbitrary-equality-map.js").ArbitraryEqualityMap>;
|
|
5
|
-
}>) => Promise<import("@paulirish/trace_engine/models/trace/insights/types.js").NavigationInsightData<
|
|
6
|
-
AuctionWorklets: typeof import("@paulirish/trace_engine/models/trace/handlers/AuctionWorkletsHandler.js");
|
|
7
|
-
Initiators: typeof import("@paulirish/trace_engine/models/trace/handlers/InitiatorsHandler.js");
|
|
8
|
-
LayoutShifts: typeof import("@paulirish/trace_engine/models/trace/handlers/LayoutShiftsHandler.js");
|
|
9
|
-
NetworkRequests: typeof import("@paulirish/trace_engine/models/trace/handlers/NetworkRequestsHandler.js");
|
|
10
|
-
Renderer: typeof import("@paulirish/trace_engine/models/trace/handlers/RendererHandler.js");
|
|
11
|
-
Samples: typeof import("@paulirish/trace_engine/models/trace/handlers/SamplesHandler.js");
|
|
12
|
-
Screenshots: typeof import("@paulirish/trace_engine/models/trace/handlers/ScreenshotsHandler.js");
|
|
13
|
-
PageLoadMetrics: typeof import("@paulirish/trace_engine/models/trace/handlers/PageLoadMetricsHandler.js");
|
|
14
|
-
Workers: typeof import("@paulirish/trace_engine/models/trace/handlers/WorkersHandler.js");
|
|
15
|
-
}>>;
|
|
5
|
+
}>) => Promise<import("@paulirish/trace_engine/models/trace/insights/types.js").NavigationInsightData<typeof import("@paulirish/trace_engine/models/trace/handlers/ModelHandlers.js")>>;
|
|
16
6
|
};
|
|
17
7
|
/**
|
|
18
8
|
* @fileoverview Gets insights from the shared trace engine for the navigation audited by Lighthouse.
|
|
@@ -23,16 +13,6 @@ declare class NavigationInsights {
|
|
|
23
13
|
* @param {LH.Trace} trace
|
|
24
14
|
* @param {LH.Artifacts.ComputedContext} context
|
|
25
15
|
*/
|
|
26
|
-
static compute_(trace: LH.Trace, context: LH.Artifacts.ComputedContext): Promise<import("@paulirish/trace_engine/models/trace/insights/types.js").NavigationInsightData<
|
|
27
|
-
AuctionWorklets: typeof import("@paulirish/trace_engine/models/trace/handlers/AuctionWorkletsHandler.js");
|
|
28
|
-
Initiators: typeof import("@paulirish/trace_engine/models/trace/handlers/InitiatorsHandler.js");
|
|
29
|
-
LayoutShifts: typeof import("@paulirish/trace_engine/models/trace/handlers/LayoutShiftsHandler.js");
|
|
30
|
-
NetworkRequests: typeof import("@paulirish/trace_engine/models/trace/handlers/NetworkRequestsHandler.js");
|
|
31
|
-
Renderer: typeof import("@paulirish/trace_engine/models/trace/handlers/RendererHandler.js");
|
|
32
|
-
Samples: typeof import("@paulirish/trace_engine/models/trace/handlers/SamplesHandler.js");
|
|
33
|
-
Screenshots: typeof import("@paulirish/trace_engine/models/trace/handlers/ScreenshotsHandler.js");
|
|
34
|
-
PageLoadMetrics: typeof import("@paulirish/trace_engine/models/trace/handlers/PageLoadMetricsHandler.js");
|
|
35
|
-
Workers: typeof import("@paulirish/trace_engine/models/trace/handlers/WorkersHandler.js");
|
|
36
|
-
}>>;
|
|
16
|
+
static compute_(trace: LH.Trace, context: LH.Artifacts.ComputedContext): Promise<import("@paulirish/trace_engine/models/trace/insights/types.js").NavigationInsightData<typeof import("@paulirish/trace_engine/models/trace/handlers/ModelHandlers.js")>>;
|
|
37
17
|
}
|
|
38
18
|
//# sourceMappingURL=navigation-insights.d.ts.map
|
|
@@ -10,6 +10,7 @@ import {NetworkRequest} from '../lib/network-request.js';
|
|
|
10
10
|
import {ProcessedTrace} from './processed-trace.js';
|
|
11
11
|
import {NetworkRecords} from './network-records.js';
|
|
12
12
|
import {TraceEngineResult} from './trace-engine-result.js';
|
|
13
|
+
import * as TraceEngineComputationData from '../lib/lantern/trace-engine-computation-data.js';
|
|
13
14
|
|
|
14
15
|
/** @typedef {import('../lib/lantern/base-node.js').Node<LH.Artifacts.NetworkRequest>} Node */
|
|
15
16
|
|
|
@@ -28,8 +29,10 @@ class PageDependencyGraph {
|
|
|
28
29
|
|
|
29
30
|
if (data.fromTrace) {
|
|
30
31
|
const traceEngineResult = await TraceEngineResult.request({trace}, context);
|
|
31
|
-
const
|
|
32
|
-
|
|
32
|
+
const traceEngineData = traceEngineResult.data;
|
|
33
|
+
const requests = TraceEngineComputationData.createNetworkRequests(trace, traceEngineData);
|
|
34
|
+
const graph =
|
|
35
|
+
TraceEngineComputationData.createGraph(requests, trace, traceEngineData, URL);
|
|
33
36
|
return graph;
|
|
34
37
|
}
|
|
35
38
|
|
|
@@ -10,7 +10,7 @@ import {FirstContentfulPaint} from './metrics/first-contentful-paint.js';
|
|
|
10
10
|
import {Interactive} from './metrics/interactive.js';
|
|
11
11
|
import {TotalBlockingTime} from './metrics/total-blocking-time.js';
|
|
12
12
|
import {ProcessedTrace} from './processed-trace.js';
|
|
13
|
-
import {calculateTbtImpactForEvent} from '
|
|
13
|
+
import {calculateTbtImpactForEvent} from '../lib/lantern/tbt-utils.js';
|
|
14
14
|
|
|
15
15
|
class TBTImpactTasks {
|
|
16
16
|
/**
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { TraceEngineResultComputed as TraceEngineResult };
|
|
2
|
-
export type EnabledHandlers = typeof ENABLED_HANDLERS;
|
|
3
2
|
declare const TraceEngineResultComputed: typeof TraceEngineResult & {
|
|
4
3
|
request: (dependencies: {
|
|
5
4
|
trace: LH.Trace;
|
|
@@ -7,17 +6,6 @@ declare const TraceEngineResultComputed: typeof TraceEngineResult & {
|
|
|
7
6
|
computedCache: Map<string, import("../lib/arbitrary-equality-map.js").ArbitraryEqualityMap>;
|
|
8
7
|
}>) => Promise<LH.Artifacts.TraceEngineResult>;
|
|
9
8
|
};
|
|
10
|
-
declare namespace ENABLED_HANDLERS {
|
|
11
|
-
const AuctionWorklets: typeof import("@paulirish/trace_engine/models/trace/handlers/AuctionWorkletsHandler.js");
|
|
12
|
-
const Initiators: typeof import("@paulirish/trace_engine/models/trace/handlers/InitiatorsHandler.js");
|
|
13
|
-
const LayoutShifts: typeof import("@paulirish/trace_engine/models/trace/handlers/LayoutShiftsHandler.js");
|
|
14
|
-
const NetworkRequests: typeof import("@paulirish/trace_engine/models/trace/handlers/NetworkRequestsHandler.js");
|
|
15
|
-
const Renderer: typeof import("@paulirish/trace_engine/models/trace/handlers/RendererHandler.js");
|
|
16
|
-
const Samples: typeof import("@paulirish/trace_engine/models/trace/handlers/SamplesHandler.js");
|
|
17
|
-
const Screenshots: typeof import("@paulirish/trace_engine/models/trace/handlers/ScreenshotsHandler.js");
|
|
18
|
-
const PageLoadMetrics: typeof import("@paulirish/trace_engine/models/trace/handlers/PageLoadMetricsHandler.js");
|
|
19
|
-
const Workers: typeof import("@paulirish/trace_engine/models/trace/handlers/WorkersHandler.js");
|
|
20
|
-
}
|
|
21
9
|
/**
|
|
22
10
|
* @fileoverview Processes trace with the shared trace engine.
|
|
23
11
|
*/
|
|
@@ -10,20 +10,6 @@ import {CumulativeLayoutShift} from './metrics/cumulative-layout-shift.js';
|
|
|
10
10
|
import {ProcessedTrace} from './processed-trace.js';
|
|
11
11
|
import * as LH from '../../types/lh.js';
|
|
12
12
|
|
|
13
|
-
/** @typedef {typeof ENABLED_HANDLERS} EnabledHandlers */
|
|
14
|
-
|
|
15
|
-
const ENABLED_HANDLERS = {
|
|
16
|
-
AuctionWorklets: TraceEngine.TraceHandlers.AuctionWorklets,
|
|
17
|
-
Initiators: TraceEngine.TraceHandlers.Initiators,
|
|
18
|
-
LayoutShifts: TraceEngine.TraceHandlers.LayoutShifts,
|
|
19
|
-
NetworkRequests: TraceEngine.TraceHandlers.NetworkRequests,
|
|
20
|
-
Renderer: TraceEngine.TraceHandlers.Renderer,
|
|
21
|
-
Samples: TraceEngine.TraceHandlers.Samples,
|
|
22
|
-
Screenshots: TraceEngine.TraceHandlers.Screenshots,
|
|
23
|
-
PageLoadMetrics: TraceEngine.TraceHandlers.PageLoadMetrics,
|
|
24
|
-
Workers: TraceEngine.TraceHandlers.Workers,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
13
|
/**
|
|
28
14
|
* @fileoverview Processes trace with the shared trace engine.
|
|
29
15
|
*/
|
|
@@ -33,15 +19,14 @@ class TraceEngineResult {
|
|
|
33
19
|
* @return {Promise<LH.Artifacts.TraceEngineResult>}
|
|
34
20
|
*/
|
|
35
21
|
static async runTraceEngine(traceEvents) {
|
|
36
|
-
const
|
|
22
|
+
const processor = TraceEngine.TraceProcessor.createWithAllHandlers();
|
|
37
23
|
// eslint-disable-next-line max-len
|
|
38
|
-
await
|
|
24
|
+
await processor.parse(/** @type {import('@paulirish/trace_engine').Types.TraceEvents.TraceEventData[]} */ (
|
|
39
25
|
traceEvents
|
|
40
26
|
));
|
|
41
|
-
|
|
42
|
-
if (!
|
|
43
|
-
|
|
44
|
-
return {data: engine.traceParsedData, insights: engine.insights};
|
|
27
|
+
if (!processor.traceParsedData) throw new Error('No data');
|
|
28
|
+
if (!processor.insights) throw new Error('No insights');
|
|
29
|
+
return {data: processor.traceParsedData, insights: processor.insights};
|
|
45
30
|
}
|
|
46
31
|
|
|
47
32
|
/**
|
|
@@ -66,7 +66,7 @@ export class TargetManager extends TargetManager_base {
|
|
|
66
66
|
* @param {LH.Protocol.TargetType} targetType
|
|
67
67
|
* @param {string} sessionId
|
|
68
68
|
*/
|
|
69
|
-
_getProtocolEventListener(targetType: LH.Protocol.TargetType, sessionId: string): <EventName extends keyof import("
|
|
69
|
+
_getProtocolEventListener(targetType: LH.Protocol.TargetType, sessionId: string): <EventName extends keyof import("devtools-protocol/types/protocol-mapping.js").ProtocolMapping.Events>(method: EventName, params: import("../../../types/protocol.js").default.RawEventMessageRecord[EventName]["params"]) => void;
|
|
70
70
|
/**
|
|
71
71
|
* @return {Promise<void>}
|
|
72
72
|
*/
|
|
@@ -114,7 +114,6 @@ class RootCauses extends BaseGatherer {
|
|
|
114
114
|
const rootCausesEngine = new TraceEngine.RootCauses(protocolInterface);
|
|
115
115
|
const layoutShiftEvents = traceParsedData.LayoutShifts.clusters.flatMap(c => c.events);
|
|
116
116
|
for (const event of layoutShiftEvents) {
|
|
117
|
-
// @ts-expect-error The data we do get in the trace processor is still enough here
|
|
118
117
|
const r = await rootCausesEngine.layoutShifts.rootCausesForEvent(traceParsedData, event);
|
|
119
118
|
if (!r) continue;
|
|
120
119
|
|
package/core/gather/session.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export class ProtocolSession extends ProtocolSession_base implements LH.Gatherer
|
|
|
17
17
|
* @param {E} method
|
|
18
18
|
* @param {LH.CrdpEvents[E]} params
|
|
19
19
|
*/
|
|
20
|
-
_handleProtocolEvent<E extends keyof import("
|
|
20
|
+
_handleProtocolEvent<E extends keyof import("devtools-protocol/types/protocol-mapping.js").ProtocolMapping.Events>(method: E, ...params: import("devtools-protocol/types/protocol-mapping.js").ProtocolMapping.Events[E]): void;
|
|
21
21
|
_targetCrashedPromise: Promise<never>;
|
|
22
22
|
id(): string;
|
|
23
23
|
/** @param {LH.Crdp.Target.TargetInfo} targetInfo */
|
|
@@ -40,7 +40,7 @@ export class ProtocolSession extends ProtocolSession_base implements LH.Gatherer
|
|
|
40
40
|
* @param {LH.CrdpCommands[C]['paramsType']} params
|
|
41
41
|
* @return {Promise<LH.CrdpCommands[C]['returnType']>}
|
|
42
42
|
*/
|
|
43
|
-
sendCommand<C extends keyof import("
|
|
43
|
+
sendCommand<C extends keyof import("devtools-protocol/types/protocol-mapping.js").ProtocolMapping.Commands>(method: C, ...params: import("devtools-protocol/types/protocol-mapping.js").ProtocolMapping.Commands[C]["paramsType"]): Promise<import("devtools-protocol/types/protocol-mapping.js").ProtocolMapping.Commands[C]["returnType"]>;
|
|
44
44
|
/**
|
|
45
45
|
* Send and if there's an error response, do not reject.
|
|
46
46
|
* @template {keyof LH.CrdpCommands} C
|
|
@@ -48,7 +48,7 @@ export class ProtocolSession extends ProtocolSession_base implements LH.Gatherer
|
|
|
48
48
|
* @param {LH.CrdpCommands[C]['paramsType']} params
|
|
49
49
|
* @return {Promise<void>}
|
|
50
50
|
*/
|
|
51
|
-
sendCommandAndIgnore<C_1 extends keyof import("
|
|
51
|
+
sendCommandAndIgnore<C_1 extends keyof import("devtools-protocol/types/protocol-mapping.js").ProtocolMapping.Commands>(method: C_1, ...params: import("devtools-protocol/types/protocol-mapping.js").ProtocolMapping.Commands[C_1]["paramsType"]): Promise<void>;
|
|
52
52
|
/**
|
|
53
53
|
* Disposes of a session so that it can no longer talk to Chrome.
|
|
54
54
|
* @return {Promise<void>}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
export type MetricName = import('@paulirish/trace_engine/models/trace/handlers/PageLoadMetricsHandler.js').MetricName;
|
|
2
|
-
export type MetricScore = import('@paulirish/trace_engine/models/trace/handlers/PageLoadMetricsHandler.js').MetricScore;
|
|
3
|
-
/** @typedef {import('@paulirish/trace_engine/models/trace/handlers/PageLoadMetricsHandler.js').MetricName} MetricName */
|
|
4
|
-
/** @typedef {import('@paulirish/trace_engine/models/trace/handlers/PageLoadMetricsHandler.js').MetricScore} MetricScore */
|
|
5
|
-
/** @type {LH.Util.SelfMap<LH.Crdp.Network.ResourceType>} */
|
|
6
|
-
export const NetworkRequestTypes: LH.Util.SelfMap<LH.Crdp.Network.ResourceType>;
|
|
7
1
|
/**
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
10
5
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
/** @type {LH.Util.SelfMap<LH.Crdp.Network.ResourceType>} */
|
|
7
|
+
export const NetworkRequestTypes: LH.Util.SelfMap<LH.Crdp.Network.ResourceType>;
|
|
13
8
|
//# sourceMappingURL=lantern.d.ts.map
|
|
@@ -4,11 +4,6 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import * as Lantern from './types/lantern.js';
|
|
8
|
-
|
|
9
|
-
/** @typedef {import('@paulirish/trace_engine/models/trace/handlers/PageLoadMetricsHandler.js').MetricName} MetricName */
|
|
10
|
-
/** @typedef {import('@paulirish/trace_engine/models/trace/handlers/PageLoadMetricsHandler.js').MetricScore} MetricScore */
|
|
11
|
-
|
|
12
7
|
/** @type {LH.Util.SelfMap<LH.Crdp.Network.ResourceType>} */
|
|
13
8
|
const NetworkRequestTypes = {
|
|
14
9
|
XHR: 'XHR',
|
|
@@ -31,48 +26,6 @@ const NetworkRequestTypes = {
|
|
|
31
26
|
Prefetch: 'Prefetch',
|
|
32
27
|
};
|
|
33
28
|
|
|
34
|
-
/**
|
|
35
|
-
* @param {LH.Artifacts.TraceEngineResult} traceEngineResult
|
|
36
|
-
* @return {Lantern.Simulation.ProcessedNavigation}
|
|
37
|
-
*/
|
|
38
|
-
function createProcessedNavigation(traceEngineResult) {
|
|
39
|
-
const Meta = traceEngineResult.data.Meta;
|
|
40
|
-
const frameId = Meta.mainFrameId;
|
|
41
|
-
const scoresByNav = traceEngineResult.data.PageLoadMetrics.metricScoresByFrameId.get(frameId);
|
|
42
|
-
if (!scoresByNav) {
|
|
43
|
-
throw new Error('missing metric scores for main frame');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const lastNavigationId = Meta.mainFrameNavigations.at(-1)?.args.data?.navigationId;
|
|
47
|
-
const scores = lastNavigationId && scoresByNav.get(lastNavigationId);
|
|
48
|
-
if (!scores) {
|
|
49
|
-
throw new Error('missing metric scores for specified navigation');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** @param {MetricName} metric */
|
|
53
|
-
const getTimestampOrUndefined = metric => {
|
|
54
|
-
const metricScore = scores.get(metric);
|
|
55
|
-
if (!metricScore?.event) return;
|
|
56
|
-
return metricScore.event.ts;
|
|
57
|
-
};
|
|
58
|
-
/** @param {MetricName} metric */
|
|
59
|
-
const getTimestamp = metric => {
|
|
60
|
-
const metricScore = scores.get(metric);
|
|
61
|
-
if (!metricScore?.event) throw new Error(`missing metric: ${metric}`);
|
|
62
|
-
return metricScore.event.ts;
|
|
63
|
-
};
|
|
64
|
-
// TODO: should use `MetricName.LCP`, but it is a const enum.
|
|
65
|
-
const FCP = /** @type {MetricName} */('FCP');
|
|
66
|
-
const LCP = /** @type {MetricName} */('LCP');
|
|
67
|
-
return {
|
|
68
|
-
timestamps: {
|
|
69
|
-
firstContentfulPaint: getTimestamp(FCP),
|
|
70
|
-
largestContentfulPaint: getTimestampOrUndefined(LCP),
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
29
|
export {
|
|
76
30
|
NetworkRequestTypes,
|
|
77
|
-
createProcessedNavigation,
|
|
78
31
|
};
|
|
@@ -6,9 +6,7 @@ export type Extras = {
|
|
|
6
6
|
fcpResult?: LH.Artifacts.LanternMetric | undefined;
|
|
7
7
|
lcpResult?: LH.Artifacts.LanternMetric | undefined;
|
|
8
8
|
interactiveResult?: LH.Artifacts.LanternMetric | undefined;
|
|
9
|
-
|
|
10
|
-
speedIndex: number;
|
|
11
|
-
} | undefined;
|
|
9
|
+
observedSpeedIndex?: number | undefined;
|
|
12
10
|
};
|
|
13
11
|
/** @typedef {import('./base-node.js').Node} Node */
|
|
14
12
|
/** @typedef {import('./network-node.js').NetworkNode} NetworkNode */
|
|
@@ -19,7 +17,7 @@ export type Extras = {
|
|
|
19
17
|
* @property {LH.Artifacts.LanternMetric=} fcpResult
|
|
20
18
|
* @property {LH.Artifacts.LanternMetric=} lcpResult
|
|
21
19
|
* @property {LH.Artifacts.LanternMetric=} interactiveResult
|
|
22
|
-
* @property {
|
|
20
|
+
* @property {number=} observedSpeedIndex
|
|
23
21
|
*/
|
|
24
22
|
export class Metric {
|
|
25
23
|
/**
|
|
@@ -18,7 +18,7 @@ import {RESOURCE_TYPES} from '../../lib/network-request.js';
|
|
|
18
18
|
* @property {LH.Artifacts.LanternMetric=} fcpResult
|
|
19
19
|
* @property {LH.Artifacts.LanternMetric=} lcpResult
|
|
20
20
|
* @property {LH.Artifacts.LanternMetric=} interactiveResult
|
|
21
|
-
* @property {
|
|
21
|
+
* @property {number=} observedSpeedIndex
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
class Metric {
|
|
@@ -76,11 +76,11 @@ class SpeedIndex extends Metric {
|
|
|
76
76
|
*/
|
|
77
77
|
static getEstimateFromSimulation(simulationResult, extras) {
|
|
78
78
|
if (!extras.fcpResult) throw new Error('missing fcpResult');
|
|
79
|
-
if (
|
|
79
|
+
if (extras.observedSpeedIndex === undefined) throw new Error('missing observedSpeedIndex');
|
|
80
80
|
|
|
81
81
|
const fcpTimeInMs = extras.fcpResult.pessimisticEstimate.timeInMs;
|
|
82
82
|
const estimate = extras.optimistic
|
|
83
|
-
? extras.
|
|
83
|
+
? extras.observedSpeedIndex
|
|
84
84
|
: SpeedIndex.computeLayoutBasedSpeedIndex(simulationResult.nodeTimings, fcpTimeInMs);
|
|
85
85
|
return {
|
|
86
86
|
timeInMs: estimate,
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import * as Lantern from '../types/lantern.js';
|
|
8
8
|
import {Metric} from '../metric.js';
|
|
9
9
|
import {BaseNode} from '../base-node.js';
|
|
10
|
-
import {BLOCKING_TIME_THRESHOLD, calculateSumOfBlockingTime} from '
|
|
10
|
+
import {BLOCKING_TIME_THRESHOLD, calculateSumOfBlockingTime} from '../tbt-utils.js';
|
|
11
11
|
|
|
12
12
|
/** @typedef {import('../base-node.js').Node} Node */
|
|
13
13
|
|
|
@@ -61,49 +61,6 @@ export class PageDependencyGraph {
|
|
|
61
61
|
*/
|
|
62
62
|
static createGraph(mainThreadEvents: LH.TraceEvent[], networkRequests: Lantern.NetworkRequest[], URL: URLArtifact): Node;
|
|
63
63
|
/**
|
|
64
|
-
* @param {Lantern.NetworkRequest} request The request to find the initiator of
|
|
65
|
-
* @param {Map<string, Lantern.NetworkRequest[]>} requestsByURL
|
|
66
|
-
* @return {Lantern.NetworkRequest|null}
|
|
67
|
-
*/
|
|
68
|
-
static chooseInitiatorRequest(request: Lantern.NetworkRequest, requestsByURL: Map<string, Lantern.NetworkRequest[]>): Lantern.NetworkRequest | null;
|
|
69
|
-
/**
|
|
70
|
-
* Returns a map of `pid` -> `tid[]`.
|
|
71
|
-
* @param {LH.Trace} trace
|
|
72
|
-
* @return {Map<number, number[]>}
|
|
73
|
-
*/
|
|
74
|
-
static _findWorkerThreads(trace: LH.Trace): Map<number, number[]>;
|
|
75
|
-
/**
|
|
76
|
-
* @param {URL|string} url
|
|
77
|
-
*/
|
|
78
|
-
static _createParsedUrl(url: URL | string): {
|
|
79
|
-
scheme: string;
|
|
80
|
-
host: string;
|
|
81
|
-
securityOrigin: string;
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* @param {LH.Artifacts.TraceEngineResult} traceEngineResult
|
|
85
|
-
* @param {Map<number, number[]>} workerThreads
|
|
86
|
-
* @param {import('@paulirish/trace_engine/models/trace/types/TraceEvents.js').SyntheticNetworkRequest} request
|
|
87
|
-
* @return {Lantern.NetworkRequest=}
|
|
88
|
-
*/
|
|
89
|
-
static _createLanternRequest(traceEngineResult: LH.Artifacts.TraceEngineResult, workerThreads: Map<number, number[]>, request: import('@paulirish/trace_engine/models/trace/types/TraceEvents.js').SyntheticNetworkRequest): Lantern.NetworkRequest | undefined;
|
|
90
|
-
/**
|
|
91
|
-
*
|
|
92
|
-
* @param {Lantern.NetworkRequest[]} lanternRequests
|
|
93
|
-
*/
|
|
94
|
-
static _linkInitiators(lanternRequests: Lantern.NetworkRequest[]): void;
|
|
95
|
-
/**
|
|
96
|
-
* @param {LH.TraceEvent[]} mainThreadEvents
|
|
97
|
-
* @param {LH.Trace} trace
|
|
98
|
-
* @param {LH.Artifacts.TraceEngineResult} traceEngineResult
|
|
99
|
-
* @param {LH.Artifacts.URL} URL
|
|
100
|
-
*/
|
|
101
|
-
static createGraphFromTrace(mainThreadEvents: LH.TraceEvent[], trace: LH.Trace, traceEngineResult: LH.Artifacts.TraceEngineResult, URL: LH.Artifacts.URL): Promise<{
|
|
102
|
-
graph: Node;
|
|
103
|
-
records: Lantern.NetworkRequest<any>[];
|
|
104
|
-
}>;
|
|
105
|
-
/**
|
|
106
|
-
*
|
|
107
64
|
* @param {Node} rootNode
|
|
108
65
|
*/
|
|
109
66
|
static printGraph(rootNode: Node, widthInCharacters?: number): void;
|