@paulirish/trace_engine 0.0.54 → 0.0.56
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/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts +4 -0
- package/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts.map +1 -0
- package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
- package/core/platform/MimeType.d.ts +3 -2
- package/core/platform/MimeType.js +4 -3
- package/core/platform/MimeType.js.map +1 -1
- package/core/platform/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
- package/core/platform/platform.prebundle.d.ts +18 -0
- package/core/platform/platform.prebundle.js +53 -0
- package/core/platform/platform.prebundle.js.map +1 -0
- package/core/platform/platform.prebundle.ts +71 -0
- package/generated/protocol.d.ts +115 -16
- package/locales/af.json +52 -10
- package/locales/am.json +52 -10
- package/locales/ar.json +51 -9
- package/locales/as.json +52 -10
- package/locales/az.json +52 -10
- package/locales/be.json +52 -10
- package/locales/bg.json +52 -10
- package/locales/bn.json +52 -10
- package/locales/bs.json +52 -10
- package/locales/ca.json +52 -10
- package/locales/cs.json +52 -10
- package/locales/cy.json +52 -10
- package/locales/da.json +52 -10
- package/locales/de.json +52 -10
- package/locales/el.json +52 -10
- package/locales/en-GB.json +52 -10
- package/locales/en-US.json +70 -58
- package/locales/en-XL.json +70 -58
- package/locales/es-419.json +52 -10
- package/locales/es.json +50 -8
- package/locales/et.json +52 -10
- package/locales/eu.json +52 -10
- package/locales/fa.json +51 -9
- package/locales/fi.json +52 -10
- package/locales/fil.json +52 -10
- package/locales/fr-CA.json +52 -10
- package/locales/fr.json +52 -10
- package/locales/gl.json +52 -10
- package/locales/gu.json +52 -10
- package/locales/he.json +52 -10
- package/locales/hi.json +52 -10
- package/locales/hr.json +52 -10
- package/locales/hu.json +51 -9
- package/locales/hy.json +51 -9
- package/locales/id.json +52 -10
- package/locales/is.json +53 -11
- package/locales/it.json +51 -9
- package/locales/ja.json +52 -10
- package/locales/ka.json +53 -11
- package/locales/kk.json +51 -9
- package/locales/km.json +52 -10
- package/locales/kn.json +52 -10
- package/locales/ko.json +52 -10
- package/locales/ky.json +51 -9
- package/locales/lo.json +52 -10
- package/locales/lt.json +52 -10
- package/locales/lv.json +51 -9
- package/locales/mk.json +52 -10
- package/locales/ml.json +53 -11
- package/locales/mn.json +52 -10
- package/locales/mr.json +52 -10
- package/locales/ms.json +52 -10
- package/locales/my.json +51 -9
- package/locales/ne.json +52 -10
- package/locales/nl.json +52 -10
- package/locales/no.json +52 -10
- package/locales/or.json +53 -11
- package/locales/pa.json +53 -11
- package/locales/pl.json +51 -9
- package/locales/pt-PT.json +52 -10
- package/locales/pt.json +52 -10
- package/locales/ro.json +52 -10
- package/locales/ru.json +53 -11
- package/locales/si.json +52 -10
- package/locales/sk.json +51 -9
- package/locales/sl.json +51 -9
- package/locales/sq.json +52 -10
- package/locales/sr-Latn.json +52 -10
- package/locales/sr.json +52 -10
- package/locales/sv.json +52 -10
- package/locales/sw.json +51 -9
- package/locales/ta.json +52 -10
- package/locales/te.json +52 -10
- package/locales/th.json +51 -9
- package/locales/tr.json +52 -10
- package/locales/uk.json +52 -10
- package/locales/ur.json +52 -10
- package/locales/uz.json +51 -9
- package/locales/vi.json +52 -10
- package/locales/zh-HK.json +52 -10
- package/locales/zh-TW.json +51 -9
- package/locales/zh.json +52 -10
- package/locales/zu.json +52 -10
- package/models/cpu_profile/CPUProfileDataModel.d.ts +4 -2
- package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
- package/models/cpu_profile/ProfileTreeModel.d.ts +0 -1
- package/models/cpu_profile/ProfileTreeModel.js +0 -2
- package/models/cpu_profile/ProfileTreeModel.js.map +1 -1
- package/models/cpu_profile/cpu_profile.prebundle.d.ts +3 -0
- package/models/cpu_profile/cpu_profile.prebundle.js +7 -0
- package/models/cpu_profile/cpu_profile.prebundle.js.map +1 -0
- package/models/cpu_profile/cpu_profile.prebundle.ts +11 -0
- package/models/cpu_profile/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
- package/models/trace/LanternComputationData.js +7 -6
- package/models/trace/LanternComputationData.js.map +1 -1
- package/models/trace/Processor.js +25 -18
- package/models/trace/Processor.js.map +1 -1
- package/models/trace/devtools_entrypoint-bundle-tsconfig-tsconfig.json +61 -0
- package/models/trace/{root-causes/devtools_entrypoint-bundle-typescript-tsconfig.json → extras/devtools_entrypoint-bundle-tsconfig-tsconfig.json} +5 -4
- package/models/trace/extras/extras-tsconfig.json +0 -2
- package/models/trace/extras/extras.js.map +1 -1
- package/models/trace/extras/extras.prebundle.d.ts +7 -0
- package/models/trace/extras/extras.prebundle.js +11 -0
- package/models/trace/extras/extras.prebundle.js.map +1 -0
- package/models/trace/extras/extras.prebundle.ts +11 -0
- package/models/trace/handlers/ImagePaintingHandler.d.ts +7 -1
- package/models/trace/handlers/ImagePaintingHandler.js +33 -1
- package/models/trace/handlers/ImagePaintingHandler.js.map +1 -1
- package/models/trace/handlers/MetaHandler.js +2 -0
- package/models/trace/handlers/MetaHandler.js.map +1 -1
- package/models/trace/handlers/NetworkRequestsHandler.d.ts +0 -5
- package/models/trace/handlers/NetworkRequestsHandler.js +61 -20
- package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
- package/models/trace/handlers/SamplesHandler.js +7 -2
- package/models/trace/handlers/SamplesHandler.js.map +1 -1
- package/models/trace/handlers/ScriptsHandler.js.map +1 -1
- package/models/trace/{root-causes/root-causes-tsconfig.json → handlers/devtools_entrypoint-bundle-tsconfig-tsconfig.json} +5 -17
- package/models/trace/handlers/handlers.prebundle.d.ts +4 -0
- package/models/trace/handlers/handlers.prebundle.js +8 -0
- package/models/trace/handlers/handlers.prebundle.js.map +1 -0
- package/models/trace/handlers/handlers.prebundle.ts +8 -0
- package/models/trace/helpers/SamplesIntegrator.js +8 -13
- package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
- package/models/trace/helpers/Trace.js +0 -7
- package/models/trace/helpers/Trace.js.map +1 -1
- package/models/trace/helpers/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
- package/models/trace/helpers/helpers.prebundle.d.ts +7 -0
- package/models/trace/helpers/helpers.prebundle.js +11 -0
- package/models/trace/helpers/helpers.prebundle.js.map +1 -0
- package/models/trace/helpers/helpers.prebundle.ts +11 -0
- package/models/trace/insights/CLSCulprits.d.ts +27 -7
- package/models/trace/insights/CLSCulprits.js +34 -15
- package/models/trace/insights/CLSCulprits.js.map +1 -1
- package/models/trace/insights/Common.d.ts +1 -1
- package/models/trace/insights/Common.js +3 -3
- package/models/trace/insights/Common.js.map +1 -1
- package/models/trace/insights/DOMSize.d.ts +26 -1
- package/models/trace/insights/DOMSize.js +34 -1
- package/models/trace/insights/DOMSize.js.map +1 -1
- package/models/trace/insights/DocumentLatency.d.ts +2 -2
- package/models/trace/insights/DocumentLatency.js +3 -3
- package/models/trace/insights/DocumentLatency.js.map +1 -1
- package/models/trace/insights/ForcedReflow.d.ts +1 -1
- package/models/trace/insights/ForcedReflow.js +1 -1
- package/models/trace/insights/ForcedReflow.js.map +1 -1
- package/models/trace/insights/{InteractionToNextPaint.d.ts → INPBreakdown.d.ts} +8 -8
- package/models/trace/insights/{InteractionToNextPaint.js → INPBreakdown.js} +10 -10
- package/models/trace/insights/INPBreakdown.js.map +1 -0
- package/models/trace/insights/ImageDelivery.js +18 -7
- package/models/trace/insights/ImageDelivery.js.map +1 -1
- package/models/trace/insights/{LCPPhases.d.ts → LCPBreakdown.d.ts} +26 -22
- package/models/trace/insights/{LCPPhases.js → LCPBreakdown.js} +56 -46
- package/models/trace/insights/LCPBreakdown.js.map +1 -0
- package/models/trace/insights/LCPDiscovery.js +1 -1
- package/models/trace/insights/LCPDiscovery.js.map +1 -1
- package/models/trace/insights/Models.d.ts +2 -2
- package/models/trace/insights/Models.js +2 -2
- package/models/trace/insights/Models.js.map +1 -1
- package/models/trace/insights/NetworkDependencyTree.d.ts +34 -8
- package/models/trace/insights/NetworkDependencyTree.js +144 -18
- package/models/trace/insights/NetworkDependencyTree.js.map +1 -1
- package/models/trace/insights/Viewport.d.ts +8 -2
- package/models/trace/insights/Viewport.js +16 -1
- package/models/trace/insights/Viewport.js.map +1 -1
- package/models/trace/insights/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
- package/models/trace/insights/insights-tsconfig.json +2 -2
- package/models/trace/insights/insights.prebundle.d.ts +4 -0
- package/models/trace/insights/insights.prebundle.js +8 -0
- package/models/trace/insights/insights.prebundle.js.map +1 -0
- package/models/trace/insights/insights.prebundle.ts +8 -0
- package/models/trace/insights/types.d.ts +2 -2
- package/models/trace/insights/types.js +2 -2
- package/models/trace/insights/types.js.map +1 -1
- package/models/trace/lantern/core/core.prebundle.d.ts +2 -0
- package/models/trace/lantern/core/core.prebundle.js +6 -0
- package/models/trace/lantern/core/core.prebundle.js.map +1 -0
- package/models/trace/lantern/core/core.prebundle.ts +6 -0
- package/models/trace/lantern/core/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
- package/models/trace/lantern/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
- package/models/trace/lantern/graph/BaseNode.d.ts +5 -2
- package/models/trace/lantern/graph/BaseNode.js +8 -5
- package/models/trace/lantern/graph/BaseNode.js.map +1 -1
- package/models/trace/lantern/graph/PageDependencyGraph.js +46 -3
- package/models/trace/lantern/graph/PageDependencyGraph.js.map +1 -1
- package/models/trace/lantern/graph/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
- package/models/trace/lantern/graph/graph.prebundle.d.ts +4 -0
- package/models/trace/lantern/graph/graph.prebundle.js +8 -0
- package/models/trace/lantern/graph/graph.prebundle.js.map +1 -0
- package/models/trace/lantern/graph/graph.prebundle.ts +8 -0
- package/models/trace/lantern/lantern.prebundle.d.ts +6 -0
- package/models/trace/lantern/lantern.prebundle.js +10 -0
- package/models/trace/lantern/lantern.prebundle.js.map +1 -0
- package/models/trace/lantern/lantern.prebundle.ts +17 -0
- package/models/trace/lantern/metrics/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
- package/models/trace/lantern/metrics/metrics.prebundle.d.ts +8 -0
- package/models/trace/lantern/metrics/metrics.prebundle.js +12 -0
- package/models/trace/lantern/metrics/metrics.prebundle.js.map +1 -0
- package/models/trace/lantern/metrics/metrics.prebundle.ts +12 -0
- package/models/trace/lantern/simulation/Simulator.js +1 -1
- package/models/trace/lantern/simulation/Simulator.js.map +1 -1
- package/models/trace/lantern/simulation/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
- package/models/trace/lantern/simulation/simulation.prebundle.d.ts +6 -0
- package/models/trace/lantern/simulation/simulation.prebundle.js +10 -0
- package/models/trace/lantern/simulation/simulation.prebundle.js.map +1 -0
- package/models/trace/lantern/simulation/simulation.prebundle.ts +10 -0
- package/models/trace/lantern/types/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
- package/models/trace/lantern/types/types.prebundle.d.ts +1 -0
- package/models/trace/lantern/types/types.prebundle.js +5 -0
- package/models/trace/lantern/types/types.prebundle.js.map +1 -0
- package/models/trace/lantern/types/types.prebundle.ts +5 -0
- package/models/trace/trace-tsconfig.json +0 -1
- package/models/trace/trace.d.ts +1 -2
- package/models/trace/trace.js +1 -2
- package/models/trace/trace.js.map +1 -1
- package/models/trace/trace.prebundle.d.ts +10 -0
- package/models/trace/trace.prebundle.js +14 -0
- package/models/trace/trace.prebundle.js.map +1 -0
- package/models/trace/trace.prebundle.ts +25 -0
- package/models/trace/types/Extensions.d.ts +6 -1
- package/models/trace/types/Extensions.js.map +1 -1
- package/models/trace/types/File.d.ts +16 -1
- package/models/trace/types/File.js.map +1 -1
- package/models/trace/types/Timing.js.map +1 -1
- package/models/trace/types/TraceEvents.d.ts +7 -4
- package/models/trace/types/TraceEvents.js +4 -3
- package/models/trace/types/TraceEvents.js.map +1 -1
- package/models/trace/types/devtools_entrypoint-bundle-tsconfig-tsconfig.json +43 -0
- package/models/trace/types/types.prebundle.d.ts +5 -0
- package/models/trace/types/types.prebundle.js +9 -0
- package/models/trace/types/types.prebundle.js.map +1 -0
- package/models/trace/types/types.prebundle.ts +9 -0
- package/package.json +1 -1
- package/test/test-trace-engine.mjs +2 -2
- package/core/platform/ServerTiming.d.ts +0 -31
- package/core/platform/ServerTiming.js +0 -212
- package/core/platform/ServerTiming.js.map +0 -1
- package/models/trace/TracingManager.js.map +0 -1
- package/models/trace/extras/FetchNodes.d.ts +0 -61
- package/models/trace/extras/FetchNodes.js +0 -214
- package/models/trace/extras/FetchNodes.js.map +0 -1
- package/models/trace/extras/Metadata.d.ts +0 -3
- package/models/trace/extras/Metadata.js +0 -71
- package/models/trace/extras/Metadata.js.map +0 -1
- package/models/trace/extras/TimelineJSProfile.d.ts +0 -13
- package/models/trace/extras/TimelineJSProfile.js +0 -55
- package/models/trace/extras/TimelineJSProfile.js.map +0 -1
- package/models/trace/extras/URLForEntry.d.ts +0 -12
- package/models/trace/extras/URLForEntry.js +0 -43
- package/models/trace/extras/URLForEntry.js.map +0 -1
- package/models/trace/handlers/ServerTimingsHandler.d.ts +0 -9
- package/models/trace/handlers/ServerTimingsHandler.js +0 -106
- package/models/trace/handlers/ServerTimingsHandler.js.map +0 -1
- package/models/trace/insights/CumulativeLayoutShift.d.ts +0 -57
- package/models/trace/insights/CumulativeLayoutShift.js +0 -335
- package/models/trace/insights/CumulativeLayoutShift.js.map +0 -1
- package/models/trace/insights/InsightRunners.d.ts +0 -9
- package/models/trace/insights/InsightRunners.js +0 -13
- package/models/trace/insights/InsightRunners.js.map +0 -1
- package/models/trace/insights/InteractionToNextPaint.js.map +0 -1
- package/models/trace/insights/LCPPhases.js.map +0 -1
- package/models/trace/insights/LargestContentfulPaint.d.ts +0 -38
- package/models/trace/insights/LargestContentfulPaint.js +0 -113
- package/models/trace/insights/LargestContentfulPaint.js.map +0 -1
- package/models/trace/insights/ThirdPartyWeb.d.ts +0 -13
- package/models/trace/insights/ThirdPartyWeb.js +0 -42
- package/models/trace/insights/ThirdPartyWeb.js.map +0 -1
- package/models/trace/root-causes/LayoutShift.d.ts +0 -125
- package/models/trace/root-causes/LayoutShift.js +0 -519
- package/models/trace/root-causes/LayoutShift.js.map +0 -1
- package/models/trace/root-causes/RootCauses.d.ts +0 -15
- package/models/trace/root-causes/RootCauses.js +0 -12
- package/models/trace/root-causes/RootCauses.js.map +0 -1
- package/models/trace/root-causes/bundle-tsconfig.json +0 -1
- package/models/trace/root-causes/root-causes.d.ts +0 -1
- package/models/trace/root-causes/root-causes.js +0 -5
- package/models/trace/root-causes/root-causes.js.map +0 -1
|
@@ -1,42 +1,43 @@
|
|
|
1
|
+
// import type * as Common from '../../../core/common/common.js';
|
|
1
2
|
import * as Handlers from '../handlers/handlers.js';
|
|
2
3
|
import * as Types from '../types/types.js';
|
|
3
4
|
import { type InsightModel, type InsightSetContext } from './types.js';
|
|
4
5
|
export declare const UIStrings: {
|
|
5
6
|
/**
|
|
6
|
-
*@description Title of an insight that provides details about the LCP metric, broken down by
|
|
7
|
+
*@description Title of an insight that provides details about the LCP metric, broken down by parts.
|
|
7
8
|
*/
|
|
8
|
-
readonly title: "LCP
|
|
9
|
+
readonly title: "LCP breakdown";
|
|
9
10
|
/**
|
|
10
|
-
* @description Description of a DevTools insight that presents a breakdown for the LCP metric by
|
|
11
|
+
* @description Description of a DevTools insight that presents a breakdown for the LCP metric by subparts.
|
|
11
12
|
* This is displayed after a user expands the section to see more. No character length limits.
|
|
12
13
|
*/
|
|
13
|
-
readonly description: "Each [
|
|
14
|
+
readonly description: "Each [subpart has specific improvement strategies](https://web.dev/articles/optimize-lcp#lcp-breakdown). Ideally, most of the LCP time should be spent on loading the resources, not within delays.";
|
|
14
15
|
/**
|
|
15
|
-
*@description Time to first byte title for the Largest Contentful Paint's
|
|
16
|
+
*@description Time to first byte title for the Largest Contentful Paint's subparts timespan breakdown.
|
|
16
17
|
*/
|
|
17
18
|
readonly timeToFirstByte: "Time to first byte";
|
|
18
19
|
/**
|
|
19
|
-
*@description Resource load delay title for the Largest Contentful Paint
|
|
20
|
+
*@description Resource load delay title for the Largest Contentful Paint subparts timespan breakdown.
|
|
20
21
|
*/
|
|
21
22
|
readonly resourceLoadDelay: "Resource load delay";
|
|
22
23
|
/**
|
|
23
|
-
*@description Resource load duration title for the Largest Contentful Paint
|
|
24
|
+
*@description Resource load duration title for the Largest Contentful Paint subparts timespan breakdown.
|
|
24
25
|
*/
|
|
25
26
|
readonly resourceLoadDuration: "Resource load duration";
|
|
26
27
|
/**
|
|
27
|
-
*@description Element render delay title for the Largest Contentful Paint
|
|
28
|
+
*@description Element render delay title for the Largest Contentful Paint subparts timespan breakdown.
|
|
28
29
|
*/
|
|
29
30
|
readonly elementRenderDelay: "Element render delay";
|
|
30
31
|
/**
|
|
31
|
-
*@description Label used for the
|
|
32
|
+
*@description Label used for the subpart (section) of a larger duration.
|
|
32
33
|
*/
|
|
33
|
-
readonly
|
|
34
|
+
readonly subpart: "Subpart";
|
|
34
35
|
/**
|
|
35
|
-
* @description Label used for the duration a single
|
|
36
|
+
* @description Label used for the duration a single subpart (section) takes up of a larger duration.
|
|
36
37
|
*/
|
|
37
38
|
readonly duration: "Duration";
|
|
38
39
|
/**
|
|
39
|
-
* @description Label used for the duration a single
|
|
40
|
+
* @description Label used for the duration a single subpart (section) takes up of a larger duration. The value will be the 75th percentile of aggregate data. "Field" means that the data was collected from real users in the field as opposed to the developers local environment. "Field" is synonymous with "Real user data".
|
|
40
41
|
*/
|
|
41
42
|
readonly fieldDuration: "Field p75";
|
|
42
43
|
/**
|
|
@@ -44,36 +45,39 @@ export declare const UIStrings: {
|
|
|
44
45
|
*/
|
|
45
46
|
readonly noLcp: "No LCP detected";
|
|
46
47
|
};
|
|
47
|
-
export declare const i18nString: (id: string, values?: Record<string, string> | undefined) => Record<string, string
|
|
48
|
-
|
|
48
|
+
export declare const i18nString: (id: string, values?: Record<string, string> | undefined) => {i18nId: string, values: Record<string, string|number>, formattedDefault: string};
|
|
49
|
+
export type Subpart = Types.Timing.TraceWindowMicro & {
|
|
50
|
+
label: {i18nId: string, values: Record<string, string|number>, formattedDefault: string};
|
|
51
|
+
};
|
|
52
|
+
interface LCPSubparts {
|
|
49
53
|
/**
|
|
50
54
|
* The time between when the user initiates loading the page until when
|
|
51
55
|
* the browser receives the first byte of the html response.
|
|
52
56
|
*/
|
|
53
|
-
ttfb:
|
|
57
|
+
ttfb: Subpart;
|
|
54
58
|
/**
|
|
55
59
|
* The time between ttfb and the LCP request request being started.
|
|
56
60
|
* For a text LCP, this is undefined given no request is loaded.
|
|
57
61
|
*/
|
|
58
|
-
loadDelay?:
|
|
62
|
+
loadDelay?: Subpart;
|
|
59
63
|
/**
|
|
60
64
|
* The time it takes to load the LCP request.
|
|
61
65
|
*/
|
|
62
|
-
|
|
66
|
+
loadDuration?: Subpart;
|
|
63
67
|
/**
|
|
64
68
|
* The time between when the LCP request finishes loading and when
|
|
65
69
|
* the LCP element is rendered.
|
|
66
70
|
*/
|
|
67
|
-
renderDelay:
|
|
71
|
+
renderDelay: Subpart;
|
|
68
72
|
}
|
|
69
|
-
export declare function
|
|
70
|
-
export type
|
|
73
|
+
export declare function isLCPBreakdown(model: InsightModel): model is LCPBreakdownInsightModel;
|
|
74
|
+
export type LCPBreakdownInsightModel = InsightModel<typeof UIStrings, {
|
|
71
75
|
lcpMs?: Types.Timing.Milli;
|
|
72
76
|
lcpTs?: Types.Timing.Milli;
|
|
73
77
|
lcpEvent?: Types.Events.LargestContentfulPaintCandidate;
|
|
74
78
|
/** The network request for the LCP image, if there was one. */
|
|
75
79
|
lcpRequest?: Types.Events.SyntheticNetworkRequest;
|
|
76
|
-
|
|
80
|
+
subparts?: LCPSubparts;
|
|
77
81
|
}>;
|
|
78
|
-
export declare function generateInsight(parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext):
|
|
82
|
+
export declare function generateInsight(parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): LCPBreakdownInsightModel;
|
|
79
83
|
export {};
|
|
@@ -8,40 +8,40 @@ import * as Types from '../types/types.js';
|
|
|
8
8
|
import { InsightCategory, InsightKeys, InsightWarning, } from './types.js';
|
|
9
9
|
export const UIStrings = {
|
|
10
10
|
/**
|
|
11
|
-
*@description Title of an insight that provides details about the LCP metric, broken down by
|
|
11
|
+
*@description Title of an insight that provides details about the LCP metric, broken down by parts.
|
|
12
12
|
*/
|
|
13
|
-
title: 'LCP
|
|
13
|
+
title: 'LCP breakdown',
|
|
14
14
|
/**
|
|
15
|
-
* @description Description of a DevTools insight that presents a breakdown for the LCP metric by
|
|
15
|
+
* @description Description of a DevTools insight that presents a breakdown for the LCP metric by subparts.
|
|
16
16
|
* This is displayed after a user expands the section to see more. No character length limits.
|
|
17
17
|
*/
|
|
18
|
-
description: 'Each [
|
|
18
|
+
description: 'Each [subpart has specific improvement strategies](https://web.dev/articles/optimize-lcp#lcp-breakdown). Ideally, most of the LCP time should be spent on loading the resources, not within delays.',
|
|
19
19
|
/**
|
|
20
|
-
*@description Time to first byte title for the Largest Contentful Paint's
|
|
20
|
+
*@description Time to first byte title for the Largest Contentful Paint's subparts timespan breakdown.
|
|
21
21
|
*/
|
|
22
22
|
timeToFirstByte: 'Time to first byte',
|
|
23
23
|
/**
|
|
24
|
-
*@description Resource load delay title for the Largest Contentful Paint
|
|
24
|
+
*@description Resource load delay title for the Largest Contentful Paint subparts timespan breakdown.
|
|
25
25
|
*/
|
|
26
26
|
resourceLoadDelay: 'Resource load delay',
|
|
27
27
|
/**
|
|
28
|
-
*@description Resource load duration title for the Largest Contentful Paint
|
|
28
|
+
*@description Resource load duration title for the Largest Contentful Paint subparts timespan breakdown.
|
|
29
29
|
*/
|
|
30
30
|
resourceLoadDuration: 'Resource load duration',
|
|
31
31
|
/**
|
|
32
|
-
*@description Element render delay title for the Largest Contentful Paint
|
|
32
|
+
*@description Element render delay title for the Largest Contentful Paint subparts timespan breakdown.
|
|
33
33
|
*/
|
|
34
34
|
elementRenderDelay: 'Element render delay',
|
|
35
35
|
/**
|
|
36
|
-
*@description Label used for the
|
|
36
|
+
*@description Label used for the subpart (section) of a larger duration.
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
subpart: 'Subpart',
|
|
39
39
|
/**
|
|
40
|
-
* @description Label used for the duration a single
|
|
40
|
+
* @description Label used for the duration a single subpart (section) takes up of a larger duration.
|
|
41
41
|
*/
|
|
42
42
|
duration: 'Duration',
|
|
43
43
|
/**
|
|
44
|
-
* @description Label used for the duration a single
|
|
44
|
+
* @description Label used for the duration a single subpart (section) takes up of a larger duration. The value will be the 75th percentile of aggregate data. "Field" means that the data was collected from real users in the field as opposed to the developers local environment. "Field" is synonymous with "Real user data".
|
|
45
45
|
*/
|
|
46
46
|
fieldDuration: 'Field p75',
|
|
47
47
|
/**
|
|
@@ -49,50 +49,69 @@ export const UIStrings = {
|
|
|
49
49
|
*/
|
|
50
50
|
noLcp: 'No LCP detected',
|
|
51
51
|
};
|
|
52
|
-
// const str_ = i18n.i18n.registerUIStrings('models/trace/insights/
|
|
52
|
+
// const str_ = i18n.i18n.registerUIStrings('models/trace/insights/LCPBreakdown.ts', UIStrings);
|
|
53
53
|
export const i18nString = (i18nId, values) => ({i18nId, values}); // i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
54
|
-
export function
|
|
55
|
-
return model.insightKey === '
|
|
54
|
+
export function isLCPBreakdown(model) {
|
|
55
|
+
return model.insightKey === 'LCPBreakdown';
|
|
56
56
|
}
|
|
57
57
|
function anyValuesNaN(...values) {
|
|
58
58
|
return values.some(v => Number.isNaN(v));
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
* Calculates the 4
|
|
61
|
+
* Calculates the 2–4 subparts of an LCP as bounds.
|
|
62
62
|
* Will return `null` if any required values were missing. We don't ever expect
|
|
63
63
|
* them to be missing on newer traces, but old trace files may lack some of the
|
|
64
64
|
* data we rely on, so we want to handle that case.
|
|
65
65
|
*/
|
|
66
|
-
function
|
|
66
|
+
function determineSubparts(nav, docRequest, lcpEvent, lcpRequest) {
|
|
67
67
|
const docReqTiming = docRequest.args.data.timing;
|
|
68
68
|
if (!docReqTiming) {
|
|
69
69
|
throw new Error('no timing for document request');
|
|
70
70
|
}
|
|
71
|
-
const firstDocByteTs = Helpers.Timing.secondsToMicro(docReqTiming.requestTime) +
|
|
72
|
-
Helpers.Timing.milliToMicro(docReqTiming.receiveHeadersStart);
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
let renderDelay =
|
|
71
|
+
const firstDocByteTs = Types.Timing.Micro(Helpers.Timing.secondsToMicro(docReqTiming.requestTime) +
|
|
72
|
+
Helpers.Timing.milliToMicro(docReqTiming.receiveHeadersStart));
|
|
73
|
+
const ttfb = Helpers.Timing.traceWindowFromMicroSeconds(nav.ts, firstDocByteTs);
|
|
74
|
+
ttfb.label = i18nString(UIStrings.timeToFirstByte);
|
|
75
|
+
let renderDelay = Helpers.Timing.traceWindowFromMicroSeconds(ttfb.max, lcpEvent.ts);
|
|
76
|
+
renderDelay.label = i18nString(UIStrings.elementRenderDelay);
|
|
77
|
+
// If the LCP is text, we don't have a request, so just 2 subparts.
|
|
76
78
|
if (!lcpRequest) {
|
|
77
|
-
|
|
79
|
+
/** Text LCP. 2 subparts, thus 3 timestamps
|
|
80
|
+
*
|
|
81
|
+
* | ttfb | renderDelay |
|
|
82
|
+
* ^ lcpEvent.ts
|
|
83
|
+
* ^ firstDocByteTs
|
|
84
|
+
* ^ navStartTs
|
|
85
|
+
*/
|
|
86
|
+
if (anyValuesNaN(ttfb.range, renderDelay.range)) {
|
|
78
87
|
return null;
|
|
79
88
|
}
|
|
80
89
|
return { ttfb, renderDelay };
|
|
81
90
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
/** Image LCP. 4 subparts means 5 timestamps
|
|
92
|
+
*
|
|
93
|
+
* | ttfb | loadDelay | loadTime | renderDelay |
|
|
94
|
+
* ^ lcpEvent.ts
|
|
95
|
+
* ^ lcpReqEndTs
|
|
96
|
+
* ^ lcpStartTs
|
|
97
|
+
* ^ ttfbTs
|
|
98
|
+
* ^ navStartTs
|
|
99
|
+
*/
|
|
100
|
+
const lcpStartTs = lcpRequest.ts;
|
|
101
|
+
const lcpReqEndTs = lcpRequest.args.data.syntheticData.finishTime;
|
|
102
|
+
const loadDelay = Helpers.Timing.traceWindowFromMicroSeconds(ttfb.max, lcpStartTs);
|
|
103
|
+
const loadDuration = Helpers.Timing.traceWindowFromMicroSeconds(lcpStartTs, lcpReqEndTs);
|
|
104
|
+
renderDelay = Helpers.Timing.traceWindowFromMicroSeconds(lcpReqEndTs, lcpEvent.ts);
|
|
105
|
+
loadDelay.label = i18nString(UIStrings.resourceLoadDelay);
|
|
106
|
+
loadDuration.label = i18nString(UIStrings.resourceLoadDuration);
|
|
107
|
+
renderDelay.label = i18nString(UIStrings.elementRenderDelay);
|
|
108
|
+
if (anyValuesNaN(ttfb.range, loadDelay.range, loadDuration.range, renderDelay.range)) {
|
|
90
109
|
return null;
|
|
91
110
|
}
|
|
92
111
|
return {
|
|
93
112
|
ttfb,
|
|
94
113
|
loadDelay,
|
|
95
|
-
|
|
114
|
+
loadDuration,
|
|
96
115
|
renderDelay,
|
|
97
116
|
};
|
|
98
117
|
}
|
|
@@ -105,7 +124,7 @@ function finalize(partialModel) {
|
|
|
105
124
|
relatedEvents.push(partialModel.lcpRequest);
|
|
106
125
|
}
|
|
107
126
|
return {
|
|
108
|
-
insightKey: InsightKeys.
|
|
127
|
+
insightKey: InsightKeys.LCP_BREAKDOWN,
|
|
109
128
|
strings: UIStrings,
|
|
110
129
|
title: i18nString(UIStrings.title),
|
|
111
130
|
description: i18nString(UIStrings.description),
|
|
@@ -133,30 +152,21 @@ export function generateInsight(parsedTrace, context) {
|
|
|
133
152
|
if (!lcpEvent || !Types.Events.isLargestContentfulPaintCandidate(lcpEvent)) {
|
|
134
153
|
return finalize({ warnings: [InsightWarning.NO_LCP] });
|
|
135
154
|
}
|
|
136
|
-
// This helps calculate the
|
|
155
|
+
// This helps calculate the subparts.
|
|
137
156
|
const lcpMs = Helpers.Timing.microToMilli(metricScore.timing);
|
|
138
157
|
// This helps position things on the timeline's UI accurately for a trace.
|
|
139
158
|
const lcpTs = metricScore.event?.ts ? Helpers.Timing.microToMilli(metricScore.event?.ts) : undefined;
|
|
140
159
|
const lcpRequest = parsedTrace.LargestImagePaint.lcpRequestByNavigationId.get(context.navigationId);
|
|
141
|
-
const docRequest = networkRequests.
|
|
160
|
+
const docRequest = networkRequests.byId.get(context.navigationId);
|
|
142
161
|
if (!docRequest) {
|
|
143
162
|
return finalize({ lcpMs, lcpTs, lcpEvent, lcpRequest, warnings: [InsightWarning.NO_DOCUMENT_REQUEST] });
|
|
144
163
|
}
|
|
145
|
-
if (!lcpRequest) {
|
|
146
|
-
return finalize({
|
|
147
|
-
lcpMs,
|
|
148
|
-
lcpTs,
|
|
149
|
-
lcpEvent,
|
|
150
|
-
lcpRequest,
|
|
151
|
-
phases: breakdownPhases(context.navigation, docRequest, lcpMs, lcpRequest) ?? undefined,
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
164
|
return finalize({
|
|
155
165
|
lcpMs,
|
|
156
166
|
lcpTs,
|
|
157
167
|
lcpEvent,
|
|
158
168
|
lcpRequest,
|
|
159
|
-
|
|
169
|
+
subparts: determineSubparts(context.navigation, docRequest, lcpEvent, lcpRequest) ?? undefined,
|
|
160
170
|
});
|
|
161
171
|
}
|
|
162
|
-
//# sourceMappingURL=
|
|
172
|
+
//# sourceMappingURL=LCPBreakdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LCPBreakdown.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/LCPBreakdown.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAG7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KA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C,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACrG,MAAM,UAAU,GAAG,WAAW,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAEpG,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAClE,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,QAAQ,CAAC,EAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,cAAc,CAAC,mBAAmB,CAAC,EAAC,CAAC,CAAC;IACxG,CAAC;IAED,OAAO,QAAQ,CAAC;QACd,KAAK;QACL,KAAK;QACL,QAAQ;QACR,UAAU;QACV,QAAQ,EAAE,iBAAiB,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,IAAI,SAAS;KAC/F,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Common from '../../../core/common/common.js';\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n InsightWarning,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n *@description Title of an insight that provides details about the LCP metric, broken down by parts.\n */\n title: 'LCP breakdown',\n /**\n * @description Description of a DevTools insight that presents a breakdown for the LCP metric by subparts.\n * This is displayed after a user expands the section to see more. No character length limits.\n */\n description:\n 'Each [subpart has specific improvement strategies](https://web.dev/articles/optimize-lcp#lcp-breakdown). Ideally, most of the LCP time should be spent on loading the resources, not within delays.',\n /**\n *@description Time to first byte title for the Largest Contentful Paint's subparts timespan breakdown.\n */\n timeToFirstByte: 'Time to first byte',\n /**\n *@description Resource load delay title for the Largest Contentful Paint subparts timespan breakdown.\n */\n resourceLoadDelay: 'Resource load delay',\n /**\n *@description Resource load duration title for the Largest Contentful Paint subparts timespan breakdown.\n */\n resourceLoadDuration: 'Resource load duration',\n /**\n *@description Element render delay title for the Largest Contentful Paint subparts timespan breakdown.\n */\n elementRenderDelay: 'Element render delay',\n /**\n *@description Label used for the subpart (section) of a larger duration.\n */\n subpart: 'Subpart',\n /**\n * @description Label used for the duration a single subpart (section) takes up of a larger duration.\n */\n duration: 'Duration',\n /**\n * @description Label used for the duration a single subpart (section) takes up of a larger duration. The value will be the 75th percentile of aggregate data. \"Field\" means that the data was collected from real users in the field as opposed to the developers local environment. \"Field\" is synonymous with \"Real user data\".\n */\n fieldDuration: 'Field p75',\n /**\n * @description Text status indicating that the the Largest Contentful Paint (LCP) metric timing was not found. \"LCP\" is an acronym and should not be translated.\n */\n noLcp: 'No LCP detected',\n} as const;\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/LCPBreakdown.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\n// A TraceWindow plus its UIString.\nexport type Subpart = Types.Timing.TraceWindowMicro&{label: Common.UIString.LocalizedString};\ninterface LCPSubparts {\n /**\n * The time between when the user initiates loading the page until when\n * the browser receives the first byte of the html response.\n */\n ttfb: Subpart;\n /**\n * The time between ttfb and the LCP request request being started.\n * For a text LCP, this is undefined given no request is loaded.\n */\n loadDelay?: Subpart;\n /**\n * The time it takes to load the LCP request.\n */\n loadDuration?: Subpart;\n /**\n * The time between when the LCP request finishes loading and when\n * the LCP element is rendered.\n */\n renderDelay: Subpart;\n}\n\nexport function isLCPBreakdown(model: InsightModel): model is LCPBreakdownInsightModel {\n return model.insightKey === 'LCPBreakdown';\n}\nexport type LCPBreakdownInsightModel = InsightModel<typeof UIStrings, {\n lcpMs?: Types.Timing.Milli,\n lcpTs?: Types.Timing.Milli,\n lcpEvent?: Types.Events.LargestContentfulPaintCandidate,\n /** The network request for the LCP image, if there was one. */\n lcpRequest?: Types.Events.SyntheticNetworkRequest,\n subparts?: LCPSubparts,\n}>;\n\nfunction anyValuesNaN(...values: number[]): boolean {\n return values.some(v => Number.isNaN(v));\n}\n/**\n * Calculates the 2–4 subparts of an LCP as bounds.\n * Will return `null` if any required values were missing. We don't ever expect\n * them to be missing on newer traces, but old trace files may lack some of the\n * data we rely on, so we want to handle that case.\n */\nfunction determineSubparts(\n nav: Types.Events.NavigationStart, docRequest: Types.Events.SyntheticNetworkRequest,\n lcpEvent: Types.Events.LargestContentfulPaintCandidate,\n lcpRequest: Types.Events.SyntheticNetworkRequest|undefined): LCPSubparts|null {\n const docReqTiming = docRequest.args.data.timing;\n if (!docReqTiming) {\n throw new Error('no timing for document request');\n }\n const firstDocByteTs = Types.Timing.Micro(\n Helpers.Timing.secondsToMicro(docReqTiming.requestTime) +\n Helpers.Timing.milliToMicro(docReqTiming.receiveHeadersStart));\n\n const ttfb = Helpers.Timing.traceWindowFromMicroSeconds(nav.ts, firstDocByteTs) as Subpart;\n ttfb.label = i18nString(UIStrings.timeToFirstByte);\n\n let renderDelay = Helpers.Timing.traceWindowFromMicroSeconds(ttfb.max, lcpEvent.ts) as Subpart;\n renderDelay.label = i18nString(UIStrings.elementRenderDelay);\n\n // If the LCP is text, we don't have a request, so just 2 subparts.\n if (!lcpRequest) {\n /** Text LCP. 2 subparts, thus 3 timestamps\n *\n * | ttfb | renderDelay |\n * ^ lcpEvent.ts\n * ^ firstDocByteTs\n * ^ navStartTs\n */\n if (anyValuesNaN(ttfb.range, renderDelay.range)) {\n return null;\n }\n return {ttfb, renderDelay};\n }\n\n /** Image LCP. 4 subparts means 5 timestamps\n *\n * | ttfb | loadDelay | loadTime | renderDelay |\n * ^ lcpEvent.ts\n * ^ lcpReqEndTs\n * ^ lcpStartTs\n * ^ ttfbTs\n * ^ navStartTs\n */\n const lcpStartTs = lcpRequest.ts;\n const lcpReqEndTs = lcpRequest.args.data.syntheticData.finishTime;\n\n const loadDelay = Helpers.Timing.traceWindowFromMicroSeconds(ttfb.max, lcpStartTs) as Subpart;\n const loadDuration = Helpers.Timing.traceWindowFromMicroSeconds(lcpStartTs, lcpReqEndTs) as Subpart;\n renderDelay = Helpers.Timing.traceWindowFromMicroSeconds(lcpReqEndTs, lcpEvent.ts) as Subpart;\n loadDelay.label = i18nString(UIStrings.resourceLoadDelay);\n loadDuration.label = i18nString(UIStrings.resourceLoadDuration);\n renderDelay.label = i18nString(UIStrings.elementRenderDelay);\n if (anyValuesNaN(ttfb.range, loadDelay.range, loadDuration.range, renderDelay.range)) {\n return null;\n }\n\n return {\n ttfb,\n loadDelay,\n loadDuration,\n renderDelay,\n };\n}\n\nfunction finalize(partialModel: PartialInsightModel<LCPBreakdownInsightModel>): LCPBreakdownInsightModel {\n const relatedEvents = [];\n if (partialModel.lcpEvent) {\n relatedEvents.push(partialModel.lcpEvent);\n }\n if (partialModel.lcpRequest) {\n relatedEvents.push(partialModel.lcpRequest);\n }\n return {\n insightKey: InsightKeys.LCP_BREAKDOWN,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.LCP,\n state: partialModel.lcpEvent || partialModel.lcpRequest ? 'informative' : 'pass',\n ...partialModel,\n relatedEvents,\n };\n}\n\nexport function generateInsight(\n parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): LCPBreakdownInsightModel {\n if (!context.navigation) {\n return finalize({});\n }\n\n const networkRequests = parsedTrace.NetworkRequests;\n\n const frameMetrics = parsedTrace.PageLoadMetrics.metricScoresByFrameId.get(context.frameId);\n if (!frameMetrics) {\n throw new Error('no frame metrics');\n }\n\n const navMetrics = frameMetrics.get(context.navigationId);\n if (!navMetrics) {\n throw new Error('no navigation metrics');\n }\n const metricScore = navMetrics.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.LCP);\n const lcpEvent = metricScore?.event;\n if (!lcpEvent || !Types.Events.isLargestContentfulPaintCandidate(lcpEvent)) {\n return finalize({warnings: [InsightWarning.NO_LCP]});\n }\n\n // This helps calculate the subparts.\n const lcpMs = Helpers.Timing.microToMilli(metricScore.timing);\n // This helps position things on the timeline's UI accurately for a trace.\n const lcpTs = metricScore.event?.ts ? Helpers.Timing.microToMilli(metricScore.event?.ts) : undefined;\n const lcpRequest = parsedTrace.LargestImagePaint.lcpRequestByNavigationId.get(context.navigationId);\n\n const docRequest = networkRequests.byId.get(context.navigationId);\n if (!docRequest) {\n return finalize({lcpMs, lcpTs, lcpEvent, lcpRequest, warnings: [InsightWarning.NO_DOCUMENT_REQUEST]});\n }\n\n return finalize({\n lcpMs,\n lcpTs,\n lcpEvent,\n lcpRequest,\n subparts: determineSubparts(context.navigation, docRequest, lcpEvent, lcpRequest) ?? undefined,\n });\n}\n"]}
|
|
@@ -88,7 +88,7 @@ export function generateInsight(parsedTrace, context) {
|
|
|
88
88
|
if (!lcpEvent || !Types.Events.isLargestContentfulPaintCandidate(lcpEvent)) {
|
|
89
89
|
return finalize({ warnings: [InsightWarning.NO_LCP] });
|
|
90
90
|
}
|
|
91
|
-
const docRequest = networkRequests.
|
|
91
|
+
const docRequest = networkRequests.byId.get(context.navigationId);
|
|
92
92
|
if (!docRequest) {
|
|
93
93
|
return finalize({ warnings: [InsightWarning.NO_DOCUMENT_REQUEST] });
|
|
94
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LCPDiscovery.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/LCPDiscovery.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,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MAAM,CAAC,CAAC;QACxD,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;YAClE,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAClF,SAAS,CAAC;IAEd,MAAM,iBAAiB,GAAG,sBAAsB,KAAK,MAAM,CAAC;IAE5D,OAAO,QAAQ,CAAC;QACd,QAAQ;QACR,UAAU;QACV,uBAAuB,EAAE,qBAAqB,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,SAAS;QACtG,SAAS,EAAE;YACT,cAAc,EAAE;gBACd,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC;oBAC5C,UAAU,CAAC,SAAS,CAAC,4BAA4B,CAAC;gBAC7E,KAAK,EAAE,iBAAiB;aACzB;YACD,mBAAmB,EAAE,EAAC,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,mBAAmB,CAAC,EAAE,KAAK,EAAE,yBAAyB,EAAC;YACzG,aAAa,EAAE,EAAC,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE,KAAK,EAAE,gBAAgB,KAAK,MAAM,EAAC;SACrG;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {\n type Checklist,\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n InsightWarning,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n *@description Title of an insight that provides details about the LCP metric, and the network requests necessary to load it. Details how the LCP request was discoverable - in other words, the path necessary to load it (ex: network requests, JavaScript)\n */\n title: 'LCP request discovery',\n /**\n *@description Description of an insight that provides details about the LCP metric, and the network requests necessary to load it.\n */\n description:\n 'Optimize LCP by making the LCP image [discoverable](https://web.dev/articles/optimize-lcp#1_eliminate_resource_load_delay) from the HTML immediately, and [avoiding lazy-loading](https://web.dev/articles/lcp-lazy-loading)',\n /**\n * @description Text to tell the user how long after the earliest discovery time their LCP element loaded.\n * @example {401ms} PH1\n */\n lcpLoadDelay: 'LCP image loaded {PH1} after earliest start point.',\n /**\n * @description Text to tell the user that a fetchpriority property value of \"high\" is applied to the LCP request.\n */\n fetchPriorityApplied: 'fetchpriority=high applied',\n /**\n * @description Text to tell the user that a fetchpriority property value of \"high\" should be applied to the LCP request.\n */\n fetchPriorityShouldBeApplied: 'fetchpriority=high should be applied',\n /**\n * @description Text to tell the user that the LCP request is discoverable in the initial document.\n */\n requestDiscoverable: 'Request is discoverable in initial document',\n /**\n * @description Text to tell the user that the LCP request does not have the lazy load property applied.\n */\n lazyLoadNotApplied: 'lazy load not applied',\n /**\n * @description Text status indicating that the the Largest Contentful Paint (LCP) metric timing was not found. \"LCP\" is an acronym and should not be translated.\n */\n noLcp: 'No LCP detected',\n /**\n * @description Text status indicating that the Largest Contentful Paint (LCP) metric was text rather than an image. \"LCP\" is an acronym and should not be translated.\n */\n noLcpResource: 'No LCP resource detected because the LCP is not an image',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/LCPDiscovery.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport function isLCPDiscovery(model: InsightModel): model is LCPDiscoveryInsightModel {\n return model.insightKey === 'LCPDiscovery';\n}\nexport type LCPDiscoveryInsightModel = InsightModel<typeof UIStrings, {\n lcpEvent?: Types.Events.LargestContentfulPaintCandidate,\n /** The network request for the LCP image, if there was one. */\n lcpRequest?: Types.Events.SyntheticNetworkRequest,\n earliestDiscoveryTimeTs?: Types.Timing.Micro,\n checklist?: Checklist<'priorityHinted'|'requestDiscoverable'|'eagerlyLoaded'>,\n}>;\n\nfunction finalize(partialModel: PartialInsightModel<LCPDiscoveryInsightModel>): LCPDiscoveryInsightModel {\n const relatedEvents = partialModel.lcpEvent && partialModel.lcpRequest ?\n // TODO: add entire request initiator chain?\n [partialModel.lcpEvent, partialModel.lcpRequest] :\n [];\n return {\n insightKey: InsightKeys.LCP_DISCOVERY,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.LCP,\n state: partialModel.lcpRequest && partialModel.checklist &&\n (!partialModel.checklist.eagerlyLoaded.value || !partialModel.checklist.requestDiscoverable.value ||\n !partialModel.checklist.priorityHinted.value) ?\n 'fail' :\n 'pass',\n ...partialModel,\n relatedEvents,\n };\n}\n\nexport function generateInsight(\n parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): LCPDiscoveryInsightModel {\n if (!context.navigation) {\n return finalize({});\n }\n\n const networkRequests = parsedTrace.NetworkRequests;\n\n const frameMetrics = parsedTrace.PageLoadMetrics.metricScoresByFrameId.get(context.frameId);\n if (!frameMetrics) {\n throw new Error('no frame metrics');\n }\n\n const navMetrics = frameMetrics.get(context.navigationId);\n if (!navMetrics) {\n throw new Error('no navigation metrics');\n }\n const metricScore = navMetrics.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.LCP);\n const lcpEvent = metricScore?.event;\n if (!lcpEvent || !Types.Events.isLargestContentfulPaintCandidate(lcpEvent)) {\n return finalize({warnings: [InsightWarning.NO_LCP]});\n }\n\n const docRequest = networkRequests.byTime.find(req => req.args.data.requestId === context.navigationId);\n if (!docRequest) {\n return finalize({warnings: [InsightWarning.NO_DOCUMENT_REQUEST]});\n }\n\n const lcpRequest = parsedTrace.LargestImagePaint.lcpRequestByNavigationId.get(context.navigationId);\n if (!lcpRequest) {\n return finalize({lcpEvent});\n }\n\n const initiatorUrl = lcpRequest.args.data.initiator?.url;\n // TODO(b/372319476): Explore using trace event HTMLDocumentParser::FetchQueuedPreloads to determine if the request\n // is discovered by the preload scanner.\n const initiatedByMainDoc =\n lcpRequest?.args.data.initiator?.type === 'parser' && docRequest.args.data.url === initiatorUrl;\n const imgPreloadedOrFoundInHTML = lcpRequest?.args.data.isLinkPreload || initiatedByMainDoc;\n\n const imageLoadingAttr = lcpEvent.args.data?.loadingAttr;\n const imageFetchPriorityHint = lcpRequest?.args.data.fetchPriorityHint;\n // This is the earliest discovery time an LCP request could have - it's TTFB.\n const earliestDiscoveryTime = docRequest?.args.data.timing ?\n Helpers.Timing.secondsToMicro(docRequest.args.data.timing.requestTime) +\n Helpers.Timing.milliToMicro(docRequest.args.data.timing.receiveHeadersStart) :\n undefined;\n\n const priorityHintFound = imageFetchPriorityHint === 'high';\n\n return finalize({\n lcpEvent,\n lcpRequest,\n earliestDiscoveryTimeTs: earliestDiscoveryTime ? Types.Timing.Micro(earliestDiscoveryTime) : undefined,\n checklist: {\n priorityHinted: {\n label: priorityHintFound ? i18nString(UIStrings.fetchPriorityApplied) :\n i18nString(UIStrings.fetchPriorityShouldBeApplied),\n value: priorityHintFound\n },\n requestDiscoverable: {label: i18nString(UIStrings.requestDiscoverable), value: imgPreloadedOrFoundInHTML},\n eagerlyLoaded: {label: i18nString(UIStrings.lazyLoadNotApplied), value: imageLoadingAttr !== 'lazy'},\n },\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"LCPDiscovery.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/LCPDiscovery.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,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AM,CAAC,WAAW,CAAC;YAClE,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAClF,SAAS,CAAC;IAEd,MAAM,iBAAiB,GAAG,sBAAsB,KAAK,MAAM,CAAC;IAE5D,OAAO,QAAQ,CAAC;QACd,QAAQ;QACR,UAAU;QACV,uBAAuB,EAAE,qBAAqB,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,SAAS;QACtG,SAAS,EAAE;YACT,cAAc,EAAE;gBACd,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC;oBAC5C,UAAU,CAAC,SAAS,CAAC,4BAA4B,CAAC;gBAC7E,KAAK,EAAE,iBAAiB;aACzB;YACD,mBAAmB,EAAE,EAAC,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,mBAAmB,CAAC,EAAE,KAAK,EAAE,yBAAyB,EAAC;YACzG,aAAa,EAAE,EAAC,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE,KAAK,EAAE,gBAAgB,KAAK,MAAM,EAAC;SACrG;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {\n type Checklist,\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n InsightWarning,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n *@description Title of an insight that provides details about the LCP metric, and the network requests necessary to load it. Details how the LCP request was discoverable - in other words, the path necessary to load it (ex: network requests, JavaScript)\n */\n title: 'LCP request discovery',\n /**\n *@description Description of an insight that provides details about the LCP metric, and the network requests necessary to load it.\n */\n description:\n 'Optimize LCP by making the LCP image [discoverable](https://web.dev/articles/optimize-lcp#1_eliminate_resource_load_delay) from the HTML immediately, and [avoiding lazy-loading](https://web.dev/articles/lcp-lazy-loading)',\n /**\n * @description Text to tell the user how long after the earliest discovery time their LCP element loaded.\n * @example {401ms} PH1\n */\n lcpLoadDelay: 'LCP image loaded {PH1} after earliest start point.',\n /**\n * @description Text to tell the user that a fetchpriority property value of \"high\" is applied to the LCP request.\n */\n fetchPriorityApplied: 'fetchpriority=high applied',\n /**\n * @description Text to tell the user that a fetchpriority property value of \"high\" should be applied to the LCP request.\n */\n fetchPriorityShouldBeApplied: 'fetchpriority=high should be applied',\n /**\n * @description Text to tell the user that the LCP request is discoverable in the initial document.\n */\n requestDiscoverable: 'Request is discoverable in initial document',\n /**\n * @description Text to tell the user that the LCP request does not have the lazy load property applied.\n */\n lazyLoadNotApplied: 'lazy load not applied',\n /**\n * @description Text status indicating that the the Largest Contentful Paint (LCP) metric timing was not found. \"LCP\" is an acronym and should not be translated.\n */\n noLcp: 'No LCP detected',\n /**\n * @description Text status indicating that the Largest Contentful Paint (LCP) metric was text rather than an image. \"LCP\" is an acronym and should not be translated.\n */\n noLcpResource: 'No LCP resource detected because the LCP is not an image',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/LCPDiscovery.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport function isLCPDiscovery(model: InsightModel): model is LCPDiscoveryInsightModel {\n return model.insightKey === 'LCPDiscovery';\n}\nexport type LCPDiscoveryInsightModel = InsightModel<typeof UIStrings, {\n lcpEvent?: Types.Events.LargestContentfulPaintCandidate,\n /** The network request for the LCP image, if there was one. */\n lcpRequest?: Types.Events.SyntheticNetworkRequest,\n earliestDiscoveryTimeTs?: Types.Timing.Micro,\n checklist?: Checklist<'priorityHinted'|'requestDiscoverable'|'eagerlyLoaded'>,\n}>;\n\nfunction finalize(partialModel: PartialInsightModel<LCPDiscoveryInsightModel>): LCPDiscoveryInsightModel {\n const relatedEvents = partialModel.lcpEvent && partialModel.lcpRequest ?\n // TODO: add entire request initiator chain?\n [partialModel.lcpEvent, partialModel.lcpRequest] :\n [];\n return {\n insightKey: InsightKeys.LCP_DISCOVERY,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.LCP,\n state: partialModel.lcpRequest && partialModel.checklist &&\n (!partialModel.checklist.eagerlyLoaded.value || !partialModel.checklist.requestDiscoverable.value ||\n !partialModel.checklist.priorityHinted.value) ?\n 'fail' :\n 'pass',\n ...partialModel,\n relatedEvents,\n };\n}\n\nexport function generateInsight(\n parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): LCPDiscoveryInsightModel {\n if (!context.navigation) {\n return finalize({});\n }\n\n const networkRequests = parsedTrace.NetworkRequests;\n\n const frameMetrics = parsedTrace.PageLoadMetrics.metricScoresByFrameId.get(context.frameId);\n if (!frameMetrics) {\n throw new Error('no frame metrics');\n }\n\n const navMetrics = frameMetrics.get(context.navigationId);\n if (!navMetrics) {\n throw new Error('no navigation metrics');\n }\n const metricScore = navMetrics.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.LCP);\n const lcpEvent = metricScore?.event;\n if (!lcpEvent || !Types.Events.isLargestContentfulPaintCandidate(lcpEvent)) {\n return finalize({warnings: [InsightWarning.NO_LCP]});\n }\n\n const docRequest = networkRequests.byId.get(context.navigationId);\n if (!docRequest) {\n return finalize({warnings: [InsightWarning.NO_DOCUMENT_REQUEST]});\n }\n\n const lcpRequest = parsedTrace.LargestImagePaint.lcpRequestByNavigationId.get(context.navigationId);\n if (!lcpRequest) {\n return finalize({lcpEvent});\n }\n\n const initiatorUrl = lcpRequest.args.data.initiator?.url;\n // TODO(b/372319476): Explore using trace event HTMLDocumentParser::FetchQueuedPreloads to determine if the request\n // is discovered by the preload scanner.\n const initiatedByMainDoc =\n lcpRequest?.args.data.initiator?.type === 'parser' && docRequest.args.data.url === initiatorUrl;\n const imgPreloadedOrFoundInHTML = lcpRequest?.args.data.isLinkPreload || initiatedByMainDoc;\n\n const imageLoadingAttr = lcpEvent.args.data?.loadingAttr;\n const imageFetchPriorityHint = lcpRequest?.args.data.fetchPriorityHint;\n // This is the earliest discovery time an LCP request could have - it's TTFB.\n const earliestDiscoveryTime = docRequest?.args.data.timing ?\n Helpers.Timing.secondsToMicro(docRequest.args.data.timing.requestTime) +\n Helpers.Timing.milliToMicro(docRequest.args.data.timing.receiveHeadersStart) :\n undefined;\n\n const priorityHintFound = imageFetchPriorityHint === 'high';\n\n return finalize({\n lcpEvent,\n lcpRequest,\n earliestDiscoveryTimeTs: earliestDiscoveryTime ? Types.Timing.Micro(earliestDiscoveryTime) : undefined,\n checklist: {\n priorityHinted: {\n label: priorityHintFound ? i18nString(UIStrings.fetchPriorityApplied) :\n i18nString(UIStrings.fetchPriorityShouldBeApplied),\n value: priorityHintFound\n },\n requestDiscoverable: {label: i18nString(UIStrings.requestDiscoverable), value: imgPreloadedOrFoundInHTML},\n eagerlyLoaded: {label: i18nString(UIStrings.lazyLoadNotApplied), value: imageLoadingAttr !== 'lazy'},\n },\n });\n}\n"]}
|
|
@@ -6,9 +6,9 @@ export * as DuplicatedJavaScript from './DuplicatedJavaScript.js';
|
|
|
6
6
|
export * as FontDisplay from './FontDisplay.js';
|
|
7
7
|
export * as ForcedReflow from './ForcedReflow.js';
|
|
8
8
|
export * as ImageDelivery from './ImageDelivery.js';
|
|
9
|
-
export * as
|
|
9
|
+
export * as INPBreakdown from './INPBreakdown.js';
|
|
10
|
+
export * as LCPBreakdown from './LCPBreakdown.js';
|
|
10
11
|
export * as LCPDiscovery from './LCPDiscovery.js';
|
|
11
|
-
export * as LCPPhases from './LCPPhases.js';
|
|
12
12
|
export * as LegacyJavaScript from './LegacyJavaScript.js';
|
|
13
13
|
export * as ModernHTTP from './ModernHTTP.js';
|
|
14
14
|
export * as NetworkDependencyTree from './NetworkDependencyTree.js';
|
|
@@ -9,9 +9,9 @@ export * as DuplicatedJavaScript from './DuplicatedJavaScript.js';
|
|
|
9
9
|
export * as FontDisplay from './FontDisplay.js';
|
|
10
10
|
export * as ForcedReflow from './ForcedReflow.js';
|
|
11
11
|
export * as ImageDelivery from './ImageDelivery.js';
|
|
12
|
-
export * as
|
|
12
|
+
export * as INPBreakdown from './INPBreakdown.js';
|
|
13
|
+
export * as LCPBreakdown from './LCPBreakdown.js';
|
|
13
14
|
export * as LCPDiscovery from './LCPDiscovery.js';
|
|
14
|
-
export * as LCPPhases from './LCPPhases.js';
|
|
15
15
|
export * as LegacyJavaScript from './LegacyJavaScript.js';
|
|
16
16
|
export * as ModernHTTP from './ModernHTTP.js';
|
|
17
17
|
export * as NetworkDependencyTree from './NetworkDependencyTree.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Models.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/Models.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,oBAAoB,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Models.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/Models.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,oBAAoB,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nexport * as Cache from './Cache.js';\nexport * as CLSCulprits from './CLSCulprits.js';\nexport * as DocumentLatency from './DocumentLatency.js';\nexport * as DOMSize from './DOMSize.js';\nexport * as DuplicatedJavaScript from './DuplicatedJavaScript.js';\nexport * as FontDisplay from './FontDisplay.js';\nexport * as ForcedReflow from './ForcedReflow.js';\nexport * as ImageDelivery from './ImageDelivery.js';\nexport * as INPBreakdown from './INPBreakdown.js';\nexport * as LCPBreakdown from './LCPBreakdown.js';\nexport * as LCPDiscovery from './LCPDiscovery.js';\nexport * as LegacyJavaScript from './LegacyJavaScript.js';\nexport * as ModernHTTP from './ModernHTTP.js';\nexport * as NetworkDependencyTree from './NetworkDependencyTree.js';\nexport * as RenderBlocking from './RenderBlocking.js';\nexport * as SlowCSSSelector from './SlowCSSSelector.js';\nexport * as ThirdParties from './ThirdParties.js';\nexport * as Viewport from './Viewport.js';\n"]}
|
|
@@ -32,7 +32,7 @@ export declare const UIStrings: {
|
|
|
32
32
|
/**
|
|
33
33
|
* @description Title of the table of the detected preconnect origins.
|
|
34
34
|
*/
|
|
35
|
-
readonly preconnectOriginsTableTitle: "
|
|
35
|
+
readonly preconnectOriginsTableTitle: "Preconnected origins";
|
|
36
36
|
/**
|
|
37
37
|
* @description Description of the table of the detected preconnect origins.
|
|
38
38
|
*/
|
|
@@ -42,13 +42,17 @@ export declare const UIStrings: {
|
|
|
42
42
|
*/
|
|
43
43
|
readonly noPreconnectOrigins: "no origins were preconnected";
|
|
44
44
|
/**
|
|
45
|
-
* @description A warning message that is shown when found more than 4 preconnected links
|
|
45
|
+
* @description A warning message that is shown when found more than 4 preconnected links. "preconnect" should not be translated.
|
|
46
46
|
*/
|
|
47
47
|
readonly tooManyPreconnectLinksWarning: "More than 4 `preconnect` connections were found. These should be used sparingly and only to the most important origins.";
|
|
48
48
|
/**
|
|
49
|
-
* @description A warning message that is shown when the user added preconnect for some unnecessary origins.
|
|
49
|
+
* @description A warning message that is shown when the user added preconnect for some unnecessary origins. "preconnect" should not be translated.
|
|
50
50
|
*/
|
|
51
51
|
readonly unusedWarning: "Unused preconnect. Only use `preconnect` for origins that the page is likely to request.";
|
|
52
|
+
/**
|
|
53
|
+
* @description A warning message that is shown when the user forget to set the `crossorigin` HTML attribute, or setting it to an incorrect value, on the link is a common mistake when adding preconnect links. "preconnect" should not be translated.
|
|
54
|
+
* */
|
|
55
|
+
readonly crossoriginWarning: "Unused preconnect. Check that the `crossorigin` attribute is used properly.";
|
|
52
56
|
/**
|
|
53
57
|
* @description Label for a column in a data table; entries will be the source of the origin.
|
|
54
58
|
*/
|
|
@@ -62,9 +66,9 @@ export declare const UIStrings: {
|
|
|
62
66
|
*/
|
|
63
67
|
readonly estSavingTableTitle: "Preconnect candidates";
|
|
64
68
|
/**
|
|
65
|
-
* @description Description of the table that recommends preconnecting to the origins to save time.
|
|
69
|
+
* @description Description of the table that recommends preconnecting to the origins to save time. "preconnect" should not be translated.
|
|
66
70
|
*/
|
|
67
|
-
readonly estSavingTableDescription: "Add [preconnect](https://developer.chrome.com/docs/lighthouse/performance/uses-rel-preconnect/) hints to your most important origins, but try to use
|
|
71
|
+
readonly estSavingTableDescription: "Add [preconnect](https://developer.chrome.com/docs/lighthouse/performance/uses-rel-preconnect/) hints to your most important origins, but try to use no more than 4.";
|
|
68
72
|
/**
|
|
69
73
|
* @description Label for a column in a data table; entries will be the origin of a web resource
|
|
70
74
|
*/
|
|
@@ -83,11 +87,22 @@ export interface CriticalRequestNode {
|
|
|
83
87
|
isLongest?: boolean;
|
|
84
88
|
relatedRequests: Set<Types.Events.SyntheticNetworkRequest>;
|
|
85
89
|
}
|
|
86
|
-
export
|
|
90
|
+
export type PreconnectedOrigin = PreconnectedOriginFromDom | PreconnectedOriginFromResponseHeader;
|
|
91
|
+
export interface PreconnectedOriginFromDom {
|
|
87
92
|
node_id: Protocol.DOM.BackendNodeId;
|
|
88
93
|
frame?: string;
|
|
89
94
|
url: string;
|
|
90
95
|
unused: boolean;
|
|
96
|
+
crossorigin: boolean;
|
|
97
|
+
source: 'DOM';
|
|
98
|
+
}
|
|
99
|
+
export interface PreconnectedOriginFromResponseHeader {
|
|
100
|
+
url: string;
|
|
101
|
+
headerText: string;
|
|
102
|
+
request: Types.Events.SyntheticNetworkRequest;
|
|
103
|
+
unused: boolean;
|
|
104
|
+
crossorigin: boolean;
|
|
105
|
+
source: 'ResponseHeader';
|
|
91
106
|
}
|
|
92
107
|
export interface PreconnectCandidate {
|
|
93
108
|
origin: Platform.DevToolsPath.UrlString;
|
|
@@ -97,10 +112,21 @@ export type NetworkDependencyTreeInsightModel = InsightModel<typeof UIStrings, {
|
|
|
97
112
|
rootNodes: CriticalRequestNode[];
|
|
98
113
|
maxTime: Types.Timing.Micro;
|
|
99
114
|
fail: boolean;
|
|
100
|
-
|
|
115
|
+
preconnectedOrigins: PreconnectedOrigin[];
|
|
101
116
|
preconnectCandidates: PreconnectCandidate[];
|
|
102
117
|
}>;
|
|
103
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Parses an HTTP Link header string into an array of url and related header text.
|
|
120
|
+
*
|
|
121
|
+
* Export the function for test purpose.
|
|
122
|
+
* @param linkHeaderValue The value of the HTTP Link header (e.g., '</style.css>; rel=preload; as=style, <https://example.com>; rel="preconnect"').
|
|
123
|
+
* @returns An array of url and header text objects if it contains `rel=preconnect`.
|
|
124
|
+
*/
|
|
125
|
+
export declare function handleLinkResponseHeader(linkHeaderValue: string): Array<{
|
|
126
|
+
url: string;
|
|
127
|
+
headerText: string;
|
|
128
|
+
}>;
|
|
129
|
+
export declare function generatePreconnectedOrigins(parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContextWithNavigation, contextRequests: Types.Events.SyntheticNetworkRequest[], preconnectCandidates: PreconnectCandidate[]): PreconnectedOrigin[];
|
|
104
130
|
export declare function generatePreconnectCandidates(parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContextWithNavigation, contextRequests: Types.Events.SyntheticNetworkRequest[]): PreconnectCandidate[];
|
|
105
131
|
export declare function generateInsight(parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): NetworkDependencyTreeInsightModel;
|
|
106
132
|
/**
|