lighthouse 11.7.0-dev.20240416 → 11.7.0-dev.20240418
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/cli/bin.js +0 -7
- package/cli/cli-flags.d.ts +1 -5
- package/cli/cli-flags.js +1 -5
- package/cli/test/smokehouse/core-tests.js +0 -2
- package/core/audits/accessibility/aria-conditional-attr.d.ts +10 -0
- package/core/audits/accessibility/aria-conditional-attr.js +43 -0
- package/core/audits/accessibility/aria-deprecated-role.d.ts +10 -0
- package/core/audits/accessibility/aria-deprecated-role.js +43 -0
- package/core/audits/accessibility/aria-prohibited-attr.d.ts +10 -0
- package/core/audits/accessibility/aria-prohibited-attr.js +44 -0
- package/core/audits/byte-efficiency/render-blocking-resources.js +3 -1
- package/core/audits/byte-efficiency/unminified-css.js +2 -2
- package/core/audits/byte-efficiency/unused-css-rules.js +3 -1
- package/core/audits/font-display.js +2 -2
- package/core/audits/resource-summary.d.ts +2 -0
- package/core/audits/resource-summary.js +5 -4
- package/core/computed/resource-summary.d.ts +10 -12
- package/core/computed/resource-summary.js +12 -19
- package/core/computed/unused-css.d.ts +3 -1
- package/core/computed/unused-css.js +6 -5
- package/core/config/config-helpers.js +0 -4
- package/core/config/constants.js +0 -1
- package/core/config/default-config.js +7 -14
- package/core/gather/gatherers/accessibility.js +3 -3
- package/core/gather/gatherers/css-usage.d.ts +0 -21
- package/core/gather/gatherers/css-usage.js +9 -119
- package/core/gather/gatherers/stylesheets.d.ts +26 -0
- package/core/gather/gatherers/stylesheets.js +138 -0
- package/core/lib/i18n/i18n.d.ts +0 -1
- package/core/lib/i18n/i18n.js +0 -2
- package/core/runner.js +0 -1
- package/dist/report/bundle.esm.js +2 -19
- package/dist/report/flow.js +5 -22
- package/dist/report/standalone.js +3 -20
- package/package.json +3 -3
- package/readme.md +2 -2
- package/report/assets/styles.css +0 -17
- package/report/renderer/components.js +1 -1
- package/report/renderer/dom.d.ts +1 -1
- package/report/renderer/dom.js +1 -1
- package/report/renderer/performance-category-renderer.js +0 -21
- package/shared/localization/locales/ar-XB.json +61 -91
- package/shared/localization/locales/ar.json +61 -91
- package/shared/localization/locales/bg.json +61 -91
- package/shared/localization/locales/ca.json +61 -91
- package/shared/localization/locales/cs.json +61 -91
- package/shared/localization/locales/da.json +61 -91
- package/shared/localization/locales/de.json +61 -91
- package/shared/localization/locales/el.json +61 -91
- package/shared/localization/locales/en-GB.json +61 -91
- package/shared/localization/locales/en-US.json +27 -30
- package/shared/localization/locales/en-XA.json +61 -91
- package/shared/localization/locales/en-XL.json +27 -30
- package/shared/localization/locales/es-419.json +61 -91
- package/shared/localization/locales/es.json +61 -91
- package/shared/localization/locales/fi.json +61 -91
- package/shared/localization/locales/fil.json +60 -90
- package/shared/localization/locales/fr.json +61 -91
- package/shared/localization/locales/he.json +61 -91
- package/shared/localization/locales/hi.json +61 -91
- package/shared/localization/locales/hr.json +62 -92
- package/shared/localization/locales/hu.json +61 -91
- package/shared/localization/locales/id.json +61 -91
- package/shared/localization/locales/it.json +61 -91
- package/shared/localization/locales/ja.json +61 -91
- package/shared/localization/locales/ko.json +61 -91
- package/shared/localization/locales/lt.json +61 -91
- package/shared/localization/locales/lv.json +61 -91
- package/shared/localization/locales/nl.json +61 -91
- package/shared/localization/locales/no.json +61 -91
- package/shared/localization/locales/pl.json +60 -90
- package/shared/localization/locales/pt-PT.json +61 -91
- package/shared/localization/locales/pt.json +63 -93
- package/shared/localization/locales/ro.json +61 -91
- package/shared/localization/locales/ru.json +61 -91
- package/shared/localization/locales/sk.json +61 -91
- package/shared/localization/locales/sl.json +61 -91
- package/shared/localization/locales/sr-Latn.json +61 -91
- package/shared/localization/locales/sr.json +61 -91
- package/shared/localization/locales/sv.json +61 -91
- package/shared/localization/locales/ta.json +60 -90
- package/shared/localization/locales/te.json +61 -91
- package/shared/localization/locales/th.json +61 -91
- package/shared/localization/locales/tr.json +61 -91
- package/shared/localization/locales/uk.json +61 -91
- package/shared/localization/locales/vi.json +60 -90
- package/shared/localization/locales/zh-HK.json +61 -91
- package/shared/localization/locales/zh-TW.json +60 -90
- package/shared/localization/locales/zh.json +61 -91
- package/tsconfig.json +0 -1
- package/types/artifacts.d.ts +3 -1
- package/types/externs.d.ts +0 -2
- package/types/lh.d.ts +0 -2
- package/types/lhr/settings.d.ts +0 -4
- package/core/audits/performance-budget.d.ts +0 -39
- package/core/audits/performance-budget.js +0 -154
- package/core/audits/timing-budget.d.ts +0 -43
- package/core/audits/timing-budget.js +0 -175
- package/core/config/budget.d.ts +0 -74
- package/core/config/budget.js +0 -340
- package/types/lhr/budget.d.ts +0 -60
package/core/config/budget.js
DELETED
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2019 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @param {unknown} arr
|
|
9
|
-
* @return {arr is Array<Record<string, unknown>>}
|
|
10
|
-
*/
|
|
11
|
-
function isArrayOfUnknownObjects(arr) {
|
|
12
|
-
return Array.isArray(arr) && arr.every(isObjectOfUnknownProperties);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @param {unknown} val
|
|
17
|
-
* @return {val is Record<string, unknown>}
|
|
18
|
-
*/
|
|
19
|
-
function isObjectOfUnknownProperties(val) {
|
|
20
|
-
return typeof val === 'object' && val !== null && !Array.isArray(val);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Returns whether `val` is numeric. Will not coerce to a number. `NaN` will
|
|
25
|
-
* return false, however ±Infinity will return true.
|
|
26
|
-
* @param {unknown} val
|
|
27
|
-
* @return {val is number}
|
|
28
|
-
*/
|
|
29
|
-
function isNumber(val) {
|
|
30
|
-
return typeof val === 'number' && !isNaN(val);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
class Budget {
|
|
34
|
-
/**
|
|
35
|
-
* Asserts that obj has no own properties, throwing a nice error message if it does.
|
|
36
|
-
* `objectName` is included for nicer logging.
|
|
37
|
-
* @param {Record<string, unknown>} obj
|
|
38
|
-
* @param {string} objectName
|
|
39
|
-
*/
|
|
40
|
-
static assertNoExcessProperties(obj, objectName) {
|
|
41
|
-
const invalidKeys = Object.keys(obj);
|
|
42
|
-
if (invalidKeys.length > 0) {
|
|
43
|
-
const keys = invalidKeys.join(', ');
|
|
44
|
-
throw new Error(`${objectName} has unrecognized properties: [${keys}]`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Asserts that `strings` has no duplicate strings in it, throwing an error if
|
|
50
|
-
* it does. `arrayName` is included for nicer logging.
|
|
51
|
-
* @param {Array<string>} strings
|
|
52
|
-
* @param {string} arrayName
|
|
53
|
-
*/
|
|
54
|
-
static assertNoDuplicateStrings(strings, arrayName) {
|
|
55
|
-
const foundStrings = new Set();
|
|
56
|
-
for (const string of strings) {
|
|
57
|
-
if (foundStrings.has(string)) {
|
|
58
|
-
throw new Error(`${arrayName} has duplicate entry of type '${string}'`);
|
|
59
|
-
}
|
|
60
|
-
foundStrings.add(string);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {Record<string, unknown>} resourceBudget
|
|
66
|
-
* @return {LH.Budget.ResourceBudget}
|
|
67
|
-
*/
|
|
68
|
-
static validateResourceBudget(resourceBudget) {
|
|
69
|
-
const {resourceType, budget, ...invalidRest} = resourceBudget;
|
|
70
|
-
Budget.assertNoExcessProperties(invalidRest, 'Resource Budget');
|
|
71
|
-
|
|
72
|
-
/** @type {Array<LH.Budget.ResourceType>} */
|
|
73
|
-
const validResourceTypes = [
|
|
74
|
-
'total',
|
|
75
|
-
'document',
|
|
76
|
-
'script',
|
|
77
|
-
'stylesheet',
|
|
78
|
-
'image',
|
|
79
|
-
'media',
|
|
80
|
-
'font',
|
|
81
|
-
'other',
|
|
82
|
-
'third-party',
|
|
83
|
-
];
|
|
84
|
-
// Assume resourceType is an allowed string, throw if not.
|
|
85
|
-
if (!validResourceTypes.includes(/** @type {LH.Budget.ResourceType} */ (resourceType))) {
|
|
86
|
-
throw new Error(`Invalid resource type: ${resourceType}. \n` +
|
|
87
|
-
`Valid resource types are: ${validResourceTypes.join(', ') }`);
|
|
88
|
-
}
|
|
89
|
-
if (!isNumber(budget)) {
|
|
90
|
-
throw new Error(`Invalid budget: ${budget}`);
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
resourceType: /** @type {LH.Budget.ResourceType} */ (resourceType),
|
|
94
|
-
budget,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* @param {unknown} path
|
|
100
|
-
* @param {string} error
|
|
101
|
-
*/
|
|
102
|
-
static throwInvalidPathError(path, error) {
|
|
103
|
-
throw new Error(`Invalid path ${path}. ${error}\n` +
|
|
104
|
-
`'Path' should be specified using the 'robots.txt' format.\n` +
|
|
105
|
-
`Learn more about the 'robots.txt' format here:\n` +
|
|
106
|
-
`https://developers.google.com/search/reference/robots_txt#url-matching-based-on-path-values`);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Validates that path is either: a) undefined or ) properly formed.
|
|
112
|
-
* Verifies the quantity and location of the two robot.txt regex characters: $, *
|
|
113
|
-
* @param {unknown} path
|
|
114
|
-
* @return {undefined|string}
|
|
115
|
-
*/
|
|
116
|
-
static validatePath(path) {
|
|
117
|
-
if (path === undefined) {
|
|
118
|
-
return undefined;
|
|
119
|
-
} else if (typeof path !== 'string') {
|
|
120
|
-
this.throwInvalidPathError(path, `Path should be a string.`);
|
|
121
|
-
return;
|
|
122
|
-
} else if (!path.startsWith('/')) {
|
|
123
|
-
this.throwInvalidPathError(path, `Path should start with '/'.`);
|
|
124
|
-
} else if ((path.match(/\*/g) || []).length > 1) {
|
|
125
|
-
this.throwInvalidPathError(path, `Path should only contain one '*'.`);
|
|
126
|
-
} else if ((path.match(/\$/g) || []).length > 1) {
|
|
127
|
-
this.throwInvalidPathError(path, `Path should only contain one '$' character.`);
|
|
128
|
-
} else if (path.includes('$') && !path.endsWith('$')) {
|
|
129
|
-
this.throwInvalidPathError(path, `'$' character should only occur at end of path.`);
|
|
130
|
-
}
|
|
131
|
-
return path;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Returns the budget that applies to a given URL.
|
|
136
|
-
* If multiple budgets match based on thier 'path' property,
|
|
137
|
-
* then the last-listed of those budgets is returned.
|
|
138
|
-
* @param {LH.Util.Immutable<Array<LH.Budget>>|null} budgets
|
|
139
|
-
* @param {string|undefined} url
|
|
140
|
-
* @return {LH.Util.Immutable<LH.Budget> | undefined} budget
|
|
141
|
-
*/
|
|
142
|
-
static getMatchingBudget(budgets, url) {
|
|
143
|
-
if (budgets === null || url === undefined) return;
|
|
144
|
-
|
|
145
|
-
// Applies the LAST matching budget.
|
|
146
|
-
for (let i = budgets.length - 1; i >= 0; i--) {
|
|
147
|
-
const budget = budgets[i];
|
|
148
|
-
if (this.urlMatchesPattern(url, budget.path)) {
|
|
149
|
-
return budget;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Determines whether a URL matches against a robots.txt-style "path".
|
|
156
|
-
* Pattern should use the robots.txt format. E.g. "/*-article.html" or "/". Reference:
|
|
157
|
-
* https://developers.google.com/search/reference/robots_txt#url-matching-based-on-path-values
|
|
158
|
-
* @param {string} url
|
|
159
|
-
* @param {string=} pattern
|
|
160
|
-
* @return {boolean}
|
|
161
|
-
*/
|
|
162
|
-
static urlMatchesPattern(url, pattern = '/') {
|
|
163
|
-
const urlObj = new URL(url);
|
|
164
|
-
const urlPath = urlObj.pathname + urlObj.search;
|
|
165
|
-
|
|
166
|
-
const hasWildcard = pattern.includes('*');
|
|
167
|
-
const hasDollarSign = pattern.includes('$');
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* There are 4 different cases of path strings.
|
|
171
|
-
* Paths should have already been validated with #validatePath.
|
|
172
|
-
*
|
|
173
|
-
* Case #1: No special characters
|
|
174
|
-
* Example: "/cat"
|
|
175
|
-
* Behavior: URL should start with given pattern.
|
|
176
|
-
*/
|
|
177
|
-
if (!hasWildcard && !hasDollarSign) {
|
|
178
|
-
return urlPath.startsWith(pattern);
|
|
179
|
-
/**
|
|
180
|
-
* Case #2: $ only
|
|
181
|
-
* Example: "/js$"
|
|
182
|
-
* Behavior: URL should be identical to pattern.
|
|
183
|
-
*/
|
|
184
|
-
} else if (!hasWildcard && hasDollarSign) {
|
|
185
|
-
return urlPath === pattern.slice(0, -1);
|
|
186
|
-
/**
|
|
187
|
-
* Case #3: * only
|
|
188
|
-
* Example: "/vendor*chunk"
|
|
189
|
-
* Behavior: URL should start with the string pattern that comes before the wildcard
|
|
190
|
-
* & later in the string contain the string pattern that comes after the wildcard.
|
|
191
|
-
*/
|
|
192
|
-
} else if (hasWildcard && !hasDollarSign) {
|
|
193
|
-
const [beforeWildcard, afterWildcard] = pattern.split('*');
|
|
194
|
-
const remainingUrl = urlPath.slice(beforeWildcard.length);
|
|
195
|
-
return urlPath.startsWith(beforeWildcard) && remainingUrl.includes(afterWildcard);
|
|
196
|
-
/**
|
|
197
|
-
* Case #4: $ and *
|
|
198
|
-
* Example: "/vendor*chunk.js$"
|
|
199
|
-
* Behavior: URL should start with the string pattern that comes before the wildcard
|
|
200
|
-
* & later in the string end with the string pattern that comes after the wildcard.
|
|
201
|
-
*/
|
|
202
|
-
} else if (hasWildcard && hasDollarSign) {
|
|
203
|
-
const [beforeWildcard, afterWildcard] = pattern.split('*');
|
|
204
|
-
const urlEnd = urlPath.slice(beforeWildcard.length);
|
|
205
|
-
return urlPath.startsWith(beforeWildcard) && urlEnd.endsWith(afterWildcard.slice(0, -1));
|
|
206
|
-
}
|
|
207
|
-
return false;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* @param {Record<string, unknown>} timingBudget
|
|
212
|
-
* @return {LH.Budget.TimingBudget}
|
|
213
|
-
*/
|
|
214
|
-
static validateTimingBudget(timingBudget) {
|
|
215
|
-
const {metric, budget, ...invalidRest} = timingBudget;
|
|
216
|
-
Budget.assertNoExcessProperties(invalidRest, 'Timing Budget');
|
|
217
|
-
|
|
218
|
-
/** @type {Array<LH.Budget.TimingMetric>} */
|
|
219
|
-
const validTimingMetrics = [
|
|
220
|
-
'first-contentful-paint',
|
|
221
|
-
'interactive',
|
|
222
|
-
'first-meaningful-paint',
|
|
223
|
-
'max-potential-fid',
|
|
224
|
-
'total-blocking-time',
|
|
225
|
-
'speed-index',
|
|
226
|
-
'largest-contentful-paint',
|
|
227
|
-
'cumulative-layout-shift',
|
|
228
|
-
];
|
|
229
|
-
// Assume metric is an allowed string, throw if not.
|
|
230
|
-
if (!validTimingMetrics.includes(/** @type {LH.Budget.TimingMetric} */ (metric))) {
|
|
231
|
-
throw new Error(`Invalid timing metric: ${metric}. \n` +
|
|
232
|
-
`Valid timing metrics are: ${validTimingMetrics.join(', ')}`);
|
|
233
|
-
}
|
|
234
|
-
if (!isNumber(budget)) {
|
|
235
|
-
throw new Error(`Invalid budget: ${budget}`);
|
|
236
|
-
}
|
|
237
|
-
return {
|
|
238
|
-
metric: /** @type {LH.Budget.TimingMetric} */ (metric),
|
|
239
|
-
budget,
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* @param {string} hostname
|
|
245
|
-
* @return {string}
|
|
246
|
-
*/
|
|
247
|
-
static validateHostname(hostname) {
|
|
248
|
-
const errMsg = `${hostname} is not a valid hostname.`;
|
|
249
|
-
if (hostname.length === 0) {
|
|
250
|
-
throw new Error(errMsg);
|
|
251
|
-
}
|
|
252
|
-
if (hostname.includes('/')) {
|
|
253
|
-
throw new Error(errMsg);
|
|
254
|
-
}
|
|
255
|
-
if (hostname.includes(':')) {
|
|
256
|
-
throw new Error(errMsg);
|
|
257
|
-
}
|
|
258
|
-
if (hostname.includes('*')) {
|
|
259
|
-
if (!hostname.startsWith('*.') || hostname.lastIndexOf('*') > 0) {
|
|
260
|
-
throw new Error(errMsg);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return hostname;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* @param {unknown} hostnames
|
|
268
|
-
* @return {undefined|Array<string>}
|
|
269
|
-
*/
|
|
270
|
-
static validateHostnames(hostnames) {
|
|
271
|
-
if (Array.isArray(hostnames) && hostnames.every(host => typeof host === 'string')) {
|
|
272
|
-
return hostnames.map(Budget.validateHostname);
|
|
273
|
-
} else if (hostnames !== undefined) {
|
|
274
|
-
throw new Error(`firstPartyHostnames should be defined as an array of strings.`);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* More info on the Budget format:
|
|
280
|
-
* https://github.com/GoogleChrome/lighthouse/issues/6053#issuecomment-428385930
|
|
281
|
-
* @param {unknown} budgetJson
|
|
282
|
-
* @return {Array<LH.Budget>}
|
|
283
|
-
*/
|
|
284
|
-
static initializeBudget(budgetJson) {
|
|
285
|
-
// Clone to prevent modifications of original and to deactivate any live properties.
|
|
286
|
-
budgetJson = JSON.parse(JSON.stringify(budgetJson));
|
|
287
|
-
if (!isArrayOfUnknownObjects(budgetJson)) {
|
|
288
|
-
throw new Error('Budget file is not defined as an array of budgets.');
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
const budgets = budgetJson.map((b, index) => {
|
|
292
|
-
/** @type {LH.Budget} */
|
|
293
|
-
const budget = {};
|
|
294
|
-
|
|
295
|
-
const {path, options, resourceSizes, resourceCounts, timings, ...invalidRest} = b;
|
|
296
|
-
Budget.assertNoExcessProperties(invalidRest, 'Budget');
|
|
297
|
-
|
|
298
|
-
budget.path = Budget.validatePath(path);
|
|
299
|
-
|
|
300
|
-
if (isObjectOfUnknownProperties(options)) {
|
|
301
|
-
const {firstPartyHostnames, ...invalidRest} = options;
|
|
302
|
-
Budget.assertNoExcessProperties(invalidRest, 'Options property');
|
|
303
|
-
budget.options = {};
|
|
304
|
-
budget.options.firstPartyHostnames = Budget.validateHostnames(firstPartyHostnames);
|
|
305
|
-
} else if (options !== undefined) {
|
|
306
|
-
throw new Error(`Invalid options property in budget at index ${index}`);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (isArrayOfUnknownObjects(resourceSizes)) {
|
|
310
|
-
budget.resourceSizes = resourceSizes.map(Budget.validateResourceBudget);
|
|
311
|
-
Budget.assertNoDuplicateStrings(budget.resourceSizes.map(r => r.resourceType),
|
|
312
|
-
`budgets[${index}].resourceSizes`);
|
|
313
|
-
} else if (resourceSizes !== undefined) {
|
|
314
|
-
throw new Error(`Invalid resourceSizes entry in budget at index ${index}`);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
if (isArrayOfUnknownObjects(resourceCounts)) {
|
|
318
|
-
budget.resourceCounts = resourceCounts.map(Budget.validateResourceBudget);
|
|
319
|
-
Budget.assertNoDuplicateStrings(budget.resourceCounts.map(r => r.resourceType),
|
|
320
|
-
`budgets[${index}].resourceCounts`);
|
|
321
|
-
} else if (resourceCounts !== undefined) {
|
|
322
|
-
throw new Error(`Invalid resourceCounts entry in budget at index ${index}`);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
if (isArrayOfUnknownObjects(timings)) {
|
|
326
|
-
budget.timings = timings.map(Budget.validateTimingBudget);
|
|
327
|
-
Budget.assertNoDuplicateStrings(budget.timings.map(r => r.metric),
|
|
328
|
-
`budgets[${index}].timings`);
|
|
329
|
-
} else if (timings !== undefined) {
|
|
330
|
-
throw new Error(`Invalid timings entry in budget at index ${index}`);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
return budget;
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
return budgets;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
export {Budget};
|
package/types/lhr/budget.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2019 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The performance budget interface.
|
|
9
|
-
* More info: https://github.com/GoogleChrome/budget.json
|
|
10
|
-
*/
|
|
11
|
-
interface Budget {
|
|
12
|
-
/** Budget options */
|
|
13
|
-
options?: Budget.Options;
|
|
14
|
-
/**
|
|
15
|
-
* Indicates which pages a budget applies to. Uses the robots.txt format.
|
|
16
|
-
* If it is not supplied, the budget applies to all pages.
|
|
17
|
-
* More info on robots.txt: https://developers.google.com/search/reference/robots_txt#url-matching-based-on-path-values
|
|
18
|
-
*/
|
|
19
|
-
path?: string;
|
|
20
|
-
/** Budgets based on resource count. */
|
|
21
|
-
resourceCounts?: Array<Budget.ResourceBudget>;
|
|
22
|
-
/** Budgets based on resource size. */
|
|
23
|
-
resourceSizes?: Array<Budget.ResourceBudget>;
|
|
24
|
-
/** Budgets based on timing metrics. */
|
|
25
|
-
timings?: Array<Budget.TimingBudget>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
declare module Budget {
|
|
29
|
-
interface ResourceBudget {
|
|
30
|
-
/** The resource type that a budget applies to. */
|
|
31
|
-
resourceType: ResourceType;
|
|
32
|
-
/** Budget for resource. Depending on context, this is either the count or size (KiB) of a resource. */
|
|
33
|
-
budget: number;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface TimingBudget {
|
|
37
|
-
/** The type of timing metric. */
|
|
38
|
-
metric: TimingMetric;
|
|
39
|
-
/** Budget for timing measurement, in milliseconds. */
|
|
40
|
-
budget: number;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface Options {
|
|
44
|
-
/**
|
|
45
|
-
* List of hostnames used to classify resources as 1st or 3rd party.
|
|
46
|
-
* Wildcards can optionally be used to match a hostname and all of its subdomains.
|
|
47
|
-
* For example e.g.: "*.news.gov.uk" matches both "news.gov.uk" and "en.news.gov.uk"
|
|
48
|
-
* If this property is not set, the root domain and all its subdomains are considered first party.
|
|
49
|
-
*/
|
|
50
|
-
firstPartyHostnames?: Array<string>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** Supported timing metrics. */
|
|
54
|
-
type TimingMetric = 'first-contentful-paint' | 'interactive' | 'first-meaningful-paint' | 'max-potential-fid' | 'total-blocking-time' | 'speed-index' | 'largest-contentful-paint' | 'cumulative-layout-shift';
|
|
55
|
-
|
|
56
|
-
/** Supported values for the resourceType property of a ResourceBudget. */
|
|
57
|
-
type ResourceType = 'stylesheet' | 'image' | 'media' | 'font' | 'script' | 'document' | 'other' | 'total' | 'third-party';
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export default Budget;
|