UNPKG

1.98 kBTypeScriptView Raw
1import type { LoadState, Metric } from './base.js';
2/**
3 * A CLS-specific version of the Metric object.
4 */
5export interface CLSMetric extends Metric {
6 name: 'CLS';
7 entries: LayoutShift[];
8}
9/**
10 * An object containing potentially-helpful debugging information that
11 * can be sent along with the CLS value for the current page visit in order
12 * to help identify issues happening to real-users in the field.
13 */
14export interface CLSAttribution {
15 /**
16 * A selector identifying the first element (in document order) that
17 * shifted when the single largest layout shift contributing to the page's
18 * CLS score occurred.
19 */
20 largestShiftTarget?: string;
21 /**
22 * The time when the single largest layout shift contributing to the page's
23 * CLS score occurred.
24 */
25 largestShiftTime?: DOMHighResTimeStamp;
26 /**
27 * The layout shift score of the single largest layout shift contributing to
28 * the page's CLS score.
29 */
30 largestShiftValue?: number;
31 /**
32 * The `LayoutShiftEntry` representing the single largest layout shift
33 * contributing to the page's CLS score. (Useful when you need more than just
34 * `largestShiftTarget`, `largestShiftTime`, and `largestShiftValue`).
35 */
36 largestShiftEntry?: LayoutShift;
37 /**
38 * The first element source (in document order) among the `sources` list
39 * of the `largestShiftEntry` object. (Also useful when you need more than
40 * just `largestShiftTarget`, `largestShiftTime`, and `largestShiftValue`).
41 */
42 largestShiftSource?: LayoutShiftAttribution;
43 /**
44 * The loading state of the document at the time when the largest layout
45 * shift contribution to the page's CLS score occurred (see `LoadState`
46 * for details).
47 */
48 loadState?: LoadState;
49}
50/**
51 * A CLS-specific version of the Metric object with attribution.
52 */
53export interface CLSMetricWithAttribution extends CLSMetric {
54 attribution: CLSAttribution;
55}