UNPKG

3.14 kBPlain TextView Raw
1/*
2 * Copyright 2020 Google LLC
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17export * from './types/base.js';
18export * from './types/polyfills.js';
19
20export * from './types/cls.js';
21export * from './types/fcp.js';
22export * from './types/fid.js';
23export * from './types/inp.js';
24export * from './types/lcp.js';
25export * from './types/ttfb.js';
26
27// --------------------------------------------------------------------------
28// Everything below is modifications to built-in modules.
29// --------------------------------------------------------------------------
30
31interface PerformanceEntryMap {
32 navigation: PerformanceNavigationTiming;
33 resource: PerformanceResourceTiming;
34 paint: PerformancePaintTiming;
35}
36
37// Update built-in types to be more accurate.
38declare global {
39 interface Document {
40 // https://wicg.github.io/nav-speculation/prerendering.html#document-prerendering
41 prerendering?: boolean;
42 // https://wicg.github.io/page-lifecycle/#sec-api
43 wasDiscarded?: boolean;
44 }
45
46 interface Performance {
47 getEntriesByType<K extends keyof PerformanceEntryMap>(
48 type: K,
49 ): PerformanceEntryMap[K][];
50 }
51
52 // https://w3c.github.io/event-timing/#sec-modifications-perf-timeline
53 interface PerformanceObserverInit {
54 durationThreshold?: number;
55 }
56
57 // https://wicg.github.io/nav-speculation/prerendering.html#performance-navigation-timing-extension
58 interface PerformanceNavigationTiming {
59 activationStart?: number;
60 }
61
62 // https://wicg.github.io/event-timing/#sec-performance-event-timing
63 interface PerformanceEventTiming extends PerformanceEntry {
64 duration: DOMHighResTimeStamp;
65 interactionId: number;
66 }
67
68 // https://wicg.github.io/layout-instability/#sec-layout-shift-attribution
69 interface LayoutShiftAttribution {
70 node?: Node;
71 previousRect: DOMRectReadOnly;
72 currentRect: DOMRectReadOnly;
73 }
74
75 // https://wicg.github.io/layout-instability/#sec-layout-shift
76 interface LayoutShift extends PerformanceEntry {
77 value: number;
78 sources: LayoutShiftAttribution[];
79 hadRecentInput: boolean;
80 }
81
82 // https://w3c.github.io/largest-contentful-paint/#sec-largest-contentful-paint-interface
83 interface LargestContentfulPaint extends PerformanceEntry {
84 renderTime: DOMHighResTimeStamp;
85 loadTime: DOMHighResTimeStamp;
86 size: number;
87 id: string;
88 url: string;
89 element?: Element;
90 }
91
92 // https://w3c.github.io/long-animation-frame/#sec-PerformanceLongAnimationFrameTiming
93 interface PerformanceLongAnimationFrameTiming extends PerformanceEntry {
94 renderStart: DOMHighResTimeStamp;
95 duration: DOMHighResTimeStamp;
96 }
97}