lighthouse 10.0.2-dev.20230320 → 10.0.2-dev.20230322
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/test/smokehouse/lighthouse-runners/bundle.js +1 -1
- package/core/audits/audit.js +1 -1
- package/core/audits/byte-efficiency/byte-efficiency-audit.d.ts +2 -0
- package/core/audits/byte-efficiency/byte-efficiency-audit.js +5 -1
- package/core/audits/byte-efficiency/unminified-javascript.js +2 -1
- package/core/audits/byte-efficiency/uses-responsive-images-snapshot.js +4 -0
- package/core/audits/dobetterweb/doctype.js +3 -2
- package/core/computed/metrics/cumulative-layout-shift.d.ts +3 -3
- package/core/computed/metrics/cumulative-layout-shift.js +21 -9
- package/core/computed/unused-css.js +8 -7
- package/core/config/lr-mobile-config.js +0 -11
- package/core/gather/driver/prepare.js +15 -0
- package/core/lib/asset-saver.js +2 -12
- package/core/lib/page-functions.d.ts +17 -5
- package/core/lib/page-functions.js +41 -22
- package/core/lib/tracehouse/trace-processor.d.ts +8 -0
- package/core/lib/tracehouse/trace-processor.js +15 -2
- package/core/lib/url-utils.js +1 -1
- package/dist/report/bundle.esm.js +36 -3
- package/dist/report/flow.js +3 -3
- package/dist/report/standalone.js +4 -4
- package/flow-report/src/summary/category.tsx +0 -1
- package/package.json +3 -3
- package/report/renderer/performance-category-renderer.js +3 -3
- package/shared/tsconfig.json +1 -1
- package/shared/util.d.ts +6 -0
- package/shared/util.js +33 -0
- package/types/artifacts.d.ts +1 -0
- package/types/lhr/audit-details.d.ts +17 -11
|
@@ -42,7 +42,6 @@ function getScoreToBeGained(audit: ScoredAuditRef): number {
|
|
|
42
42
|
function getOverallSavings(audit: LH.ReportResult.AuditRef): number {
|
|
43
43
|
return (
|
|
44
44
|
audit.result.details &&
|
|
45
|
-
audit.result.details.type === 'opportunity' &&
|
|
46
45
|
audit.result.details.overallSavingsMs
|
|
47
46
|
) || 0;
|
|
48
47
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lighthouse",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "10.0.2-dev.
|
|
4
|
+
"version": "10.0.2-dev.20230322",
|
|
5
5
|
"description": "Automated auditing, performance metrics, and best practices for the web.",
|
|
6
6
|
"main": "./core/index.js",
|
|
7
7
|
"bin": {
|
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
"resolve": "^1.20.0",
|
|
174
174
|
"rollup": "^2.52.7",
|
|
175
175
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
176
|
-
"rollup-plugin-polyfill-node": "^0.
|
|
176
|
+
"rollup-plugin-polyfill-node": "^0.12.0",
|
|
177
177
|
"rollup-plugin-replace": "^2.2.0",
|
|
178
178
|
"rollup-plugin-shim": "^1.0.0",
|
|
179
179
|
"rollup-plugin-terser": "^7.0.2",
|
|
@@ -192,7 +192,7 @@
|
|
|
192
192
|
"configstore": "^5.0.1",
|
|
193
193
|
"csp_evaluator": "1.1.1",
|
|
194
194
|
"enquirer": "^2.3.6",
|
|
195
|
-
"http-link-header": "^
|
|
195
|
+
"http-link-header": "^1.1.0",
|
|
196
196
|
"intl-messageformat": "^4.4.0",
|
|
197
197
|
"jpeg-js": "^0.4.4",
|
|
198
198
|
"js-library-detector": "^6.6.0",
|
|
@@ -68,7 +68,7 @@ export class PerformanceCategoryRenderer extends CategoryRenderer {
|
|
|
68
68
|
return element;
|
|
69
69
|
}
|
|
70
70
|
const details = audit.result.details;
|
|
71
|
-
if (details.
|
|
71
|
+
if (details.overallSavingsMs === undefined) {
|
|
72
72
|
return element;
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -98,7 +98,7 @@ export class PerformanceCategoryRenderer extends CategoryRenderer {
|
|
|
98
98
|
* @return {number}
|
|
99
99
|
*/
|
|
100
100
|
_getWastedMs(audit) {
|
|
101
|
-
if (audit.result.details
|
|
101
|
+
if (audit.result.details) {
|
|
102
102
|
const details = audit.result.details;
|
|
103
103
|
if (typeof details.overallSavingsMs !== 'number') {
|
|
104
104
|
throw new Error('non-opportunity details passed to _getWastedMs');
|
|
@@ -165,7 +165,7 @@ export class PerformanceCategoryRenderer extends CategoryRenderer {
|
|
|
165
165
|
*/
|
|
166
166
|
_classifyPerformanceAudit(audit) {
|
|
167
167
|
if (audit.group) return null;
|
|
168
|
-
if (audit.result.details
|
|
168
|
+
if (audit.result.details?.overallSavingsMs !== undefined) {
|
|
169
169
|
return 'load-opportunity';
|
|
170
170
|
}
|
|
171
171
|
return 'diagnostic';
|
package/shared/tsconfig.json
CHANGED
package/shared/util.d.ts
CHANGED
|
@@ -67,6 +67,12 @@ export class Util {
|
|
|
67
67
|
isLink: false;
|
|
68
68
|
text: string;
|
|
69
69
|
}>;
|
|
70
|
+
/**
|
|
71
|
+
* @param {string} string
|
|
72
|
+
* @param {number} characterLimit
|
|
73
|
+
* @param {string} ellipseSuffix
|
|
74
|
+
*/
|
|
75
|
+
static truncate(string: string, characterLimit: number, ellipseSuffix?: string): string;
|
|
70
76
|
/**
|
|
71
77
|
* @param {URL} parsedUrl
|
|
72
78
|
* @param {{numPathParts?: number, preserveQuery?: boolean, preserveHost?: boolean}=} options
|
package/shared/util.js
CHANGED
|
@@ -153,6 +153,39 @@ class Util {
|
|
|
153
153
|
return segments;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
/**
|
|
157
|
+
* @param {string} string
|
|
158
|
+
* @param {number} characterLimit
|
|
159
|
+
* @param {string} ellipseSuffix
|
|
160
|
+
*/
|
|
161
|
+
static truncate(string, characterLimit, ellipseSuffix = '…') {
|
|
162
|
+
// Early return for the case where there are fewer bytes than the character limit.
|
|
163
|
+
if (string.length <= characterLimit) {
|
|
164
|
+
return string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const segmenter = new Intl.Segmenter(undefined, {granularity: 'grapheme'});
|
|
168
|
+
const iterator = segmenter.segment(string)[Symbol.iterator]();
|
|
169
|
+
|
|
170
|
+
let lastSegmentIndex = 0;
|
|
171
|
+
for (let i = 0; i <= characterLimit - ellipseSuffix.length; i++) {
|
|
172
|
+
const result = iterator.next();
|
|
173
|
+
if (result.done) {
|
|
174
|
+
return string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
lastSegmentIndex = result.value.index;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
for (let i = 0; i < ellipseSuffix.length; i++) {
|
|
181
|
+
if (iterator.next().done) {
|
|
182
|
+
return string;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return string.slice(0, lastSegmentIndex) + ellipseSuffix;
|
|
187
|
+
}
|
|
188
|
+
|
|
156
189
|
/**
|
|
157
190
|
* @param {URL} parsedUrl
|
|
158
191
|
* @param {{numPathParts?: number, preserveQuery?: boolean, preserveHost?: boolean}=} options
|
package/types/artifacts.d.ts
CHANGED
|
@@ -7,6 +7,16 @@
|
|
|
7
7
|
import {IcuMessage} from './i18n.js';
|
|
8
8
|
import Treemap from './treemap.js';
|
|
9
9
|
|
|
10
|
+
/** Common properties for all details types. */
|
|
11
|
+
interface BaseDetails {
|
|
12
|
+
/** If present and audit is part of the performance category, audit is treated as an Opportunity. */
|
|
13
|
+
overallSavingsMs?: number;
|
|
14
|
+
/** Optional additional Opportunity information. */
|
|
15
|
+
overallSavingsBytes?: number;
|
|
16
|
+
/** Additional information, usually used for including debug or meta information in the LHR */
|
|
17
|
+
debugData?: Details.DebugData;
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
type Details =
|
|
11
21
|
Details.CriticalRequestChain |
|
|
12
22
|
Details.DebugData |
|
|
@@ -19,7 +29,7 @@ type Details =
|
|
|
19
29
|
|
|
20
30
|
// Details namespace.
|
|
21
31
|
declare module Details {
|
|
22
|
-
interface CriticalRequestChain {
|
|
32
|
+
interface CriticalRequestChain extends BaseDetails {
|
|
23
33
|
type: 'criticalrequestchain';
|
|
24
34
|
longestChain: {
|
|
25
35
|
duration: number;
|
|
@@ -42,7 +52,7 @@ declare module Details {
|
|
|
42
52
|
}
|
|
43
53
|
}
|
|
44
54
|
|
|
45
|
-
interface Filmstrip {
|
|
55
|
+
interface Filmstrip extends BaseDetails {
|
|
46
56
|
type: 'filmstrip';
|
|
47
57
|
scale: number;
|
|
48
58
|
items: {
|
|
@@ -55,20 +65,17 @@ declare module Details {
|
|
|
55
65
|
}[];
|
|
56
66
|
}
|
|
57
67
|
|
|
58
|
-
interface List {
|
|
68
|
+
interface List extends BaseDetails {
|
|
59
69
|
type: 'list';
|
|
60
70
|
// NOTE: any `Details` type *should* be usable in `items`, but check
|
|
61
71
|
// styles/report-ui-features are good before adding.
|
|
62
72
|
items: Array<Table | DebugData>;
|
|
63
73
|
}
|
|
64
74
|
|
|
65
|
-
interface Opportunity {
|
|
75
|
+
interface Opportunity extends BaseDetails {
|
|
66
76
|
type: 'opportunity';
|
|
67
|
-
overallSavingsMs: number;
|
|
68
|
-
overallSavingsBytes?: number;
|
|
69
77
|
headings: TableColumnHeading[];
|
|
70
78
|
items: OpportunityItem[];
|
|
71
|
-
debugData?: DebugData;
|
|
72
79
|
/**
|
|
73
80
|
* Columns to sort the items by, during grouping.
|
|
74
81
|
* If omitted, entity groups will be sorted by the audit ordering vs. the new totals.
|
|
@@ -80,7 +87,7 @@ declare module Details {
|
|
|
80
87
|
skipSumming?: Array<string>;
|
|
81
88
|
}
|
|
82
89
|
|
|
83
|
-
interface Screenshot {
|
|
90
|
+
interface Screenshot extends BaseDetails {
|
|
84
91
|
type: 'screenshot';
|
|
85
92
|
timing: number;
|
|
86
93
|
timestamp: number;
|
|
@@ -96,7 +103,7 @@ declare module Details {
|
|
|
96
103
|
left: number;
|
|
97
104
|
}
|
|
98
105
|
|
|
99
|
-
interface Table {
|
|
106
|
+
interface Table extends BaseDetails {
|
|
100
107
|
type: 'table';
|
|
101
108
|
headings: TableColumnHeading[];
|
|
102
109
|
items: TableItem[];
|
|
@@ -104,7 +111,6 @@ declare module Details {
|
|
|
104
111
|
wastedMs?: number;
|
|
105
112
|
wastedBytes?: number;
|
|
106
113
|
};
|
|
107
|
-
debugData?: DebugData;
|
|
108
114
|
/**
|
|
109
115
|
* Columns to sort the items by, during grouping.
|
|
110
116
|
* If omitted, entity groups will be sorted by the audit ordering vs. the new totals.
|
|
@@ -131,7 +137,7 @@ declare module Details {
|
|
|
131
137
|
[p: string]: any;
|
|
132
138
|
}
|
|
133
139
|
|
|
134
|
-
interface TreemapData {
|
|
140
|
+
interface TreemapData extends BaseDetails {
|
|
135
141
|
type: 'treemap-data';
|
|
136
142
|
nodes: Treemap.Node[];
|
|
137
143
|
}
|