2018-04-10 04:05:30 +03:00
|
|
|
/**
|
2020-03-18 19:21:54 +03:00
|
|
|
* @license Copyright 2018 The Lighthouse Authors. All Rights Reserved.
|
2018-04-10 04:05:30 +03:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2018-05-17 22:09:48 +03:00
|
|
|
import Gatherer = require('../lighthouse-core/gather/gatherers/gatherer.js');
|
|
|
|
import Audit = require('../lighthouse-core/audits/audit.js');
|
|
|
|
|
2018-04-10 04:05:30 +03:00
|
|
|
declare global {
|
|
|
|
module LH {
|
|
|
|
module Config {
|
|
|
|
/**
|
|
|
|
* The pre-normalization Lighthouse Config format.
|
|
|
|
*/
|
|
|
|
export interface Json {
|
2019-11-07 00:49:28 +03:00
|
|
|
extends?: 'lighthouse:default' | string | boolean;
|
2019-04-26 22:35:27 +03:00
|
|
|
settings?: SharedFlagsSettings;
|
2018-06-13 03:54:39 +03:00
|
|
|
passes?: PassJson[] | null;
|
|
|
|
audits?: Config.AuditJson[] | null;
|
|
|
|
categories?: Record<string, CategoryJson> | null;
|
|
|
|
groups?: Record<string, Config.GroupJson> | null;
|
2019-01-25 00:00:05 +03:00
|
|
|
plugins?: Array<string>,
|
2018-04-10 04:05:30 +03:00
|
|
|
}
|
2018-04-13 20:15:57 +03:00
|
|
|
|
2018-04-10 04:05:30 +03:00
|
|
|
export interface PassJson {
|
|
|
|
passName: string;
|
2020-01-07 00:32:41 +03:00
|
|
|
loadFailureMode?: 'fatal'|'warn'|'ignore';
|
2018-04-10 04:05:30 +03:00
|
|
|
recordTrace?: boolean;
|
|
|
|
useThrottling?: boolean;
|
2020-03-27 18:02:16 +03:00
|
|
|
pauseAfterFcpMs?: number;
|
2018-04-10 04:05:30 +03:00
|
|
|
pauseAfterLoadMs?: number;
|
|
|
|
networkQuietThresholdMs?: number;
|
|
|
|
cpuQuietThresholdMs?: number;
|
|
|
|
blockedUrlPatterns?: string[];
|
|
|
|
blankPage?: string;
|
2018-05-04 00:36:13 +03:00
|
|
|
gatherers?: GathererJson[];
|
2018-04-10 04:05:30 +03:00
|
|
|
}
|
2018-04-13 20:15:57 +03:00
|
|
|
|
2018-04-10 04:05:30 +03:00
|
|
|
export type GathererJson = {
|
|
|
|
path: string;
|
|
|
|
options?: {};
|
|
|
|
} | {
|
|
|
|
implementation: typeof Gatherer;
|
|
|
|
options?: {};
|
|
|
|
} | {
|
|
|
|
instance: InstanceType<typeof Gatherer>;
|
|
|
|
options?: {};
|
2018-06-13 03:54:39 +03:00
|
|
|
} | Gatherer | typeof Gatherer | string;
|
2018-04-13 20:15:57 +03:00
|
|
|
|
2018-04-13 20:56:21 +03:00
|
|
|
export interface CategoryJson {
|
2018-05-09 20:41:24 +03:00
|
|
|
title: string;
|
|
|
|
auditRefs: AuditRefJson[];
|
2018-08-20 20:42:33 +03:00
|
|
|
description?: string;
|
|
|
|
manualDescription?: string;
|
2018-04-13 20:56:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface GroupJson {
|
|
|
|
title: string;
|
2018-08-20 20:42:33 +03:00
|
|
|
description?: string;
|
2018-04-13 20:56:21 +03:00
|
|
|
}
|
|
|
|
|
2018-06-13 03:54:39 +03:00
|
|
|
export type AuditJson = {
|
|
|
|
path: string,
|
|
|
|
options?: {};
|
|
|
|
} | {
|
|
|
|
implementation: typeof Audit;
|
|
|
|
options?: {};
|
|
|
|
} | typeof Audit | string;
|
|
|
|
|
2018-04-13 20:56:21 +03:00
|
|
|
/**
|
|
|
|
* Reference to an audit member of a category and how its score should be
|
|
|
|
* weighted and how its results grouped with other members.
|
|
|
|
*/
|
2018-05-09 20:41:24 +03:00
|
|
|
export interface AuditRefJson {
|
2018-04-13 20:56:21 +03:00
|
|
|
id: string;
|
|
|
|
weight: number;
|
|
|
|
group?: string;
|
|
|
|
}
|
|
|
|
|
2019-04-26 22:35:27 +03:00
|
|
|
export interface Settings extends Required<SharedFlagsSettings> {
|
2018-04-28 04:48:57 +03:00
|
|
|
throttling: Required<ThrottlingSettings>;
|
|
|
|
}
|
2018-04-13 20:15:57 +03:00
|
|
|
|
2018-04-10 04:05:30 +03:00
|
|
|
export interface Pass extends Required<PassJson> {
|
|
|
|
gatherers: GathererDefn[];
|
|
|
|
}
|
2018-04-13 20:15:57 +03:00
|
|
|
|
2018-04-10 04:05:30 +03:00
|
|
|
export interface GathererDefn {
|
2018-06-13 03:54:39 +03:00
|
|
|
implementation?: typeof Gatherer;
|
2018-04-10 04:05:30 +03:00
|
|
|
instance: InstanceType<typeof Gatherer>;
|
2018-06-13 03:54:39 +03:00
|
|
|
path?: string;
|
2018-04-10 04:05:30 +03:00
|
|
|
options: {};
|
|
|
|
}
|
2018-04-13 20:56:21 +03:00
|
|
|
|
|
|
|
export interface AuditDefn {
|
|
|
|
implementation: typeof Audit;
|
2018-06-13 03:54:39 +03:00
|
|
|
path?: string;
|
2018-04-13 20:56:21 +03:00
|
|
|
options: {};
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: For now, these are unchanged from JSON and Result versions. Need to harmonize.
|
2018-05-09 20:41:24 +03:00
|
|
|
export interface AuditRef extends AuditRefJson {}
|
2018-04-13 20:56:21 +03:00
|
|
|
export interface Category extends CategoryJson {
|
2018-05-09 20:41:24 +03:00
|
|
|
auditRefs: AuditRef[];
|
2018-04-13 20:56:21 +03:00
|
|
|
}
|
|
|
|
export interface Group extends GroupJson {}
|
2018-06-13 03:54:39 +03:00
|
|
|
|
2019-01-25 00:00:05 +03:00
|
|
|
export interface Plugin {
|
|
|
|
/** Optionally provide more audits to run in addition to those specified by the base config. */
|
|
|
|
audits?: Array<{path: string}>;
|
|
|
|
/** Provide a category to display the plugin results in the report. */
|
|
|
|
category: LH.Config.Category;
|
2019-03-02 02:41:43 +03:00
|
|
|
/** Optionally provide more groups in addition to those specified by the base config. */
|
|
|
|
groups?: Record<string, LH.Config.GroupJson>;
|
2019-01-25 00:00:05 +03:00
|
|
|
}
|
|
|
|
|
2018-06-13 03:54:39 +03:00
|
|
|
export type MergeOptionsOfItems = <T extends {path?: string, options: Record<string, any>}>(items: T[]) => T[];
|
|
|
|
|
|
|
|
export type Merge = {
|
|
|
|
<T extends Record<string, any>, U extends Record<string, any>>(base: T|null|undefined, extension: U, overwriteArrays?: boolean): T & U;
|
|
|
|
<T extends Array<any>, U extends Array<any>>(base: T|null|undefined, extension: T, overwriteArrays?: boolean): T & U;
|
|
|
|
}
|
2018-04-10 04:05:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// empty export to keep file a module
|
|
|
|
export {}
|