/** * Copyright 2020, SumUp Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ export interface IPerformanceEntry extends PerformanceEntry { entryType: string; name: string; duration: number; startTime: number; } export interface IPerformanceEventTiming extends IPerformanceEntry { processingStart: DOMHighResTimeStamp; } export interface ILayoutShift extends IPerformanceEntry { value: number; hadRecentInput: boolean; } export interface IPerformanceElementTiming extends IPerformanceEntry { identifier: string; } export declare type IMetricName = 'first-contentful-paint' | 'first-paint' | 'first-input-delay' | 'largest-contentful-paint' | 'cumulative-layout-shift' | 'time-to-first-byte' | 'element-timing' | 'navigation-timing' | 'resource-timing' | 'user-timing' | 'longtask'; export declare type IEntryType = 'first-input' | 'measure' | 'element' | 'navigation' | 'paint' | 'largest-contentful-paint' | 'layout-shift' | 'resource' | 'longtask'; export declare type IPerformanceObservers = { [key in IMetricName]?: PerformanceObserver; }; export declare type IMetricNameToEntryTypeMap = { [key in IMetricName]: IEntryType; }; export interface IMetric { name: string; value: number; meta: { entryType: IEntryType; entries: IPerformanceEntry[]; url?: string; createdAt: number; updatedAt?: number; }; } export interface IMetricCallback { (metric: IMetric): void; } export interface IMetricHistory { [index: number]: IMetric; push(metric: IMetric): void; } export interface IEntryHandler { (entry: PerformanceEntry): void; } export interface IMetricReporter { (entryType: IEntryType, metricName: IMetricName, reportMetric: IMetricCallback, reportAllChanges?: boolean): PerformanceObserver | undefined; } export interface IObserveMethod { (metricName: IMetricName, callback: IMetricCallback, reportAllChanges?: boolean): PerformanceObserver | undefined; } export interface IObserveAllMethod { (metricNames: IMetricName[], callback: IMetricCallback, reportAllChanges?: boolean): void; } export interface IDisconnectMethod { (metricName: IMetricName): void; } export interface IDisconnectAllMethod { (metricNames?: IMetricName[]): void; }