lighthouse 9.5.0-dev.20220607 → 9.5.0-dev.20220610
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/dist/report/flow.js +3 -3
- package/esm-utils.mjs +40 -0
- package/flow-report/tsconfig.json +0 -2
- package/lighthouse-cli/bin.js +1 -1
- package/lighthouse-cli/index.js +1 -4
- package/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +1 -4
- package/lighthouse-core/config/config-helpers.js +16 -14
- package/lighthouse-core/config/config.js +37 -19
- package/lighthouse-core/fraggle-rock/config/config.js +10 -9
- package/lighthouse-core/fraggle-rock/config/filters.js +1 -0
- package/lighthouse-core/fraggle-rock/gather/driver.js +8 -12
- package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +2 -1
- package/lighthouse-core/fraggle-rock/gather/session.js +12 -38
- package/lighthouse-core/fraggle-rock/gather/snapshot-runner.js +2 -1
- package/lighthouse-core/fraggle-rock/gather/timespan-runner.js +2 -1
- package/lighthouse-core/fraggle-rock/user-flow.js +1 -1
- package/lighthouse-core/gather/connections/cri.js +3 -17
- package/lighthouse-core/gather/driver/network-monitor.js +28 -10
- package/lighthouse-core/gather/driver/target-manager.js +29 -17
- package/lighthouse-core/gather/driver/wait-for-condition.js +4 -3
- package/lighthouse-core/gather/driver.js +2 -12
- package/lighthouse-core/gather/gather-runner.js +15 -0
- package/lighthouse-core/gather/gatherers/devtools-log.js +56 -2
- package/lighthouse-core/index.js +3 -3
- package/lighthouse-core/lib/asset-saver.js +3 -4
- package/lighthouse-core/lib/network-recorder.js +2 -2
- package/lighthouse-core/runner.js +1 -0
- package/package.json +4 -4
- package/report/generator/tsconfig.json +0 -2
- package/report/renderer/swap-locale-feature.js +2 -2
- package/report/tsconfig.json +0 -2
- package/shared/tsconfig.json +0 -2
- package/tsconfig-base.json +6 -1
- package/tsconfig.json +2 -3
- package/types/artifacts.d.ts +2 -0
- package/types/gatherer.d.ts +0 -2
- package/types/lhr/lhr.d.ts +2 -0
- package/types/lhr/tsconfig.json +0 -2
- package/types/lighthouse-logger/index.d.ts +1 -0
- package/lighthouse-core/gather/devtools-log.js +0 -61
|
@@ -90,7 +90,10 @@ class NetworkMonitor {
|
|
|
90
90
|
this._frameNavigations = [];
|
|
91
91
|
this._sessions = new Map();
|
|
92
92
|
this._networkRecorder = new NetworkRecorder();
|
|
93
|
-
|
|
93
|
+
/** @type {LH.Puppeteer.CDPSession} */
|
|
94
|
+
// @ts-expect-error - temporarily reach in to get CDPSession
|
|
95
|
+
const rootCdpSession = this._session._cdpSession;
|
|
96
|
+
this._targetManager = new TargetManager(rootCdpSession);
|
|
94
97
|
|
|
95
98
|
/**
|
|
96
99
|
* Reemit the same network recorder events.
|
|
@@ -103,13 +106,20 @@ class NetworkMonitor {
|
|
|
103
106
|
};
|
|
104
107
|
|
|
105
108
|
this._networkRecorder.on('requeststarted', reEmit('requeststarted'));
|
|
106
|
-
this._networkRecorder.on('
|
|
109
|
+
this._networkRecorder.on('requestfinished', reEmit('requestfinished'));
|
|
107
110
|
|
|
108
111
|
this._session.on('Page.frameNavigated', this._onFrameNavigated);
|
|
109
|
-
this._targetManager.addTargetAttachedListener(this._onTargetAttached);
|
|
110
|
-
|
|
111
112
|
await this._session.sendCommand('Page.enable');
|
|
112
|
-
|
|
113
|
+
|
|
114
|
+
// Legacy driver does its own target management.
|
|
115
|
+
// @ts-expect-error
|
|
116
|
+
const isLegacyRunner = Boolean(this._session._domainEnabledCounts);
|
|
117
|
+
if (isLegacyRunner) {
|
|
118
|
+
this._session.addProtocolMessageListener(this._onProtocolMessage);
|
|
119
|
+
} else {
|
|
120
|
+
this._targetManager.addTargetAttachedListener(this._onTargetAttached);
|
|
121
|
+
await this._targetManager.enable();
|
|
122
|
+
}
|
|
113
123
|
}
|
|
114
124
|
|
|
115
125
|
/**
|
|
@@ -119,13 +129,21 @@ class NetworkMonitor {
|
|
|
119
129
|
if (!this._targetManager) return;
|
|
120
130
|
|
|
121
131
|
this._session.off('Page.frameNavigated', this._onFrameNavigated);
|
|
122
|
-
this._targetManager.removeTargetAttachedListener(this._onTargetAttached);
|
|
123
132
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
133
|
+
// Legacy driver does its own target management.
|
|
134
|
+
// @ts-expect-error
|
|
135
|
+
const isLegacyRunner = Boolean(this._session._domainEnabledCounts);
|
|
136
|
+
if (isLegacyRunner) {
|
|
137
|
+
this._session.removeProtocolMessageListener(this._onProtocolMessage);
|
|
138
|
+
} else {
|
|
139
|
+
this._targetManager.removeTargetAttachedListener(this._onTargetAttached);
|
|
127
140
|
|
|
128
|
-
|
|
141
|
+
for (const session of this._sessions.values()) {
|
|
142
|
+
session.removeProtocolMessageListener(this._onProtocolMessage);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
await this._targetManager.disable();
|
|
146
|
+
}
|
|
129
147
|
|
|
130
148
|
this._frameNavigations = [];
|
|
131
149
|
this._networkRecorder = undefined;
|
|
@@ -11,21 +11,23 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
const log = require('lighthouse-logger');
|
|
14
|
+
const ProtocolSession = require('../../fraggle-rock/gather/session.js');
|
|
14
15
|
|
|
15
16
|
/** @typedef {{target: LH.Crdp.Target.TargetInfo, session: LH.Gatherer.FRProtocolSession}} TargetWithSession */
|
|
16
17
|
|
|
17
18
|
class TargetManager {
|
|
18
|
-
/** @param {LH.
|
|
19
|
-
constructor(
|
|
19
|
+
/** @param {LH.Puppeteer.CDPSession} cdpSession */
|
|
20
|
+
constructor(cdpSession) {
|
|
20
21
|
this._enabled = false;
|
|
21
|
-
this.
|
|
22
|
+
this._rootCdpSession = cdpSession;
|
|
23
|
+
|
|
22
24
|
/** @type {Array<(targetWithSession: TargetWithSession) => Promise<void>|void>} */
|
|
23
25
|
this._listeners = [];
|
|
24
26
|
|
|
25
27
|
this._onSessionAttached = this._onSessionAttached.bind(this);
|
|
26
28
|
|
|
27
29
|
/** @type {Map<string, TargetWithSession>} */
|
|
28
|
-
this.
|
|
30
|
+
this._targetIdToTargets = new Map();
|
|
29
31
|
|
|
30
32
|
/** @param {LH.Crdp.Page.FrameNavigatedEvent} event */
|
|
31
33
|
this._onFrameNavigated = async event => {
|
|
@@ -35,7 +37,7 @@ class TargetManager {
|
|
|
35
37
|
// It's not entirely clear when this is necessary, but when the page switches processes on
|
|
36
38
|
// navigating from about:blank to the `requestedUrl`, resetting `setAutoAttach` has been
|
|
37
39
|
// necessary in the past.
|
|
38
|
-
await this.
|
|
40
|
+
await this._rootCdpSession.send('Target.setAutoAttach', {
|
|
39
41
|
autoAttach: true,
|
|
40
42
|
flatten: true,
|
|
41
43
|
waitForDebuggerOnStart: true,
|
|
@@ -44,9 +46,11 @@ class TargetManager {
|
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
/**
|
|
47
|
-
* @param {LH.
|
|
49
|
+
* @param {LH.Puppeteer.CDPSession} cdpSession
|
|
48
50
|
*/
|
|
49
|
-
async _onSessionAttached(
|
|
51
|
+
async _onSessionAttached(cdpSession) {
|
|
52
|
+
const session = new ProtocolSession(cdpSession);
|
|
53
|
+
|
|
50
54
|
try {
|
|
51
55
|
const target = await session.sendCommand('Target.getTargetInfo').catch(() => null);
|
|
52
56
|
const targetType = target?.targetInfo?.type;
|
|
@@ -55,13 +59,13 @@ class TargetManager {
|
|
|
55
59
|
|
|
56
60
|
const targetId = target.targetInfo.targetId;
|
|
57
61
|
session.setTargetInfo(target.targetInfo);
|
|
58
|
-
if (this.
|
|
62
|
+
if (this._targetIdToTargets.has(targetId)) return;
|
|
59
63
|
|
|
60
64
|
const targetName = target.targetInfo.url || target.targetInfo.targetId;
|
|
61
65
|
log.verbose('target-manager', `target ${targetName} attached`);
|
|
62
66
|
|
|
63
67
|
const targetWithSession = {target: target.targetInfo, session};
|
|
64
|
-
this.
|
|
68
|
+
this._targetIdToTargets.set(targetId, targetWithSession);
|
|
65
69
|
for (const listener of this._listeners) await listener(targetWithSession);
|
|
66
70
|
|
|
67
71
|
await session.sendCommand('Target.setAutoAttach', {
|
|
@@ -87,24 +91,32 @@ class TargetManager {
|
|
|
87
91
|
if (this._enabled) return;
|
|
88
92
|
|
|
89
93
|
this._enabled = true;
|
|
90
|
-
this.
|
|
94
|
+
this._targetIdToTargets = new Map();
|
|
95
|
+
|
|
96
|
+
this._rootCdpSession.on('Page.frameNavigated', this._onFrameNavigated);
|
|
97
|
+
|
|
98
|
+
const rootConnection = this._rootCdpSession.connection();
|
|
99
|
+
if (!rootConnection) {
|
|
100
|
+
throw new Error('Connection has been closed.');
|
|
101
|
+
}
|
|
102
|
+
rootConnection.on('sessionattached', this._onSessionAttached);
|
|
91
103
|
|
|
92
|
-
this.
|
|
93
|
-
this._session.addSessionAttachedListener(this._onSessionAttached);
|
|
104
|
+
await this._rootCdpSession.send('Page.enable');
|
|
94
105
|
|
|
95
|
-
|
|
96
|
-
await this._onSessionAttached(this.
|
|
106
|
+
// Start with the already attached root session.
|
|
107
|
+
await this._onSessionAttached(this._rootCdpSession);
|
|
97
108
|
}
|
|
98
109
|
|
|
99
110
|
/**
|
|
100
111
|
* @return {Promise<void>}
|
|
101
112
|
*/
|
|
102
113
|
async disable() {
|
|
103
|
-
this.
|
|
104
|
-
|
|
114
|
+
this._rootCdpSession.off('Page.frameNavigated', this._onFrameNavigated);
|
|
115
|
+
// No need to remove listener if connection is already closed.
|
|
116
|
+
this._rootCdpSession.connection()?.off('sessionattached', this._onSessionAttached);
|
|
105
117
|
|
|
106
118
|
this._enabled = false;
|
|
107
|
-
this.
|
|
119
|
+
this._targetIdToTargets = new Map();
|
|
108
120
|
}
|
|
109
121
|
|
|
110
122
|
/**
|
|
@@ -164,7 +164,8 @@ function waitForNetworkIdle(session, networkMonitor, networkQuietOptions) {
|
|
|
164
164
|
const inflightRecords = networkMonitor.getInflightRequests();
|
|
165
165
|
// If there are more than 20 inflight requests, load is still in full swing.
|
|
166
166
|
// Wait until it calms down a bit to be a little less spammy.
|
|
167
|
-
if (inflightRecords.length < 20) {
|
|
167
|
+
if (log.isVerbose() && inflightRecords.length < 20 && inflightRecords.length > 0) {
|
|
168
|
+
log.verbose('waitFor', `=== Waiting on ${inflightRecords.length} requests to finish`);
|
|
168
169
|
for (const record of inflightRecords) {
|
|
169
170
|
log.verbose('waitFor', `Waiting on ${record.url.slice(0, 120)} to finish`);
|
|
170
171
|
}
|
|
@@ -172,7 +173,7 @@ function waitForNetworkIdle(session, networkMonitor, networkQuietOptions) {
|
|
|
172
173
|
};
|
|
173
174
|
|
|
174
175
|
networkMonitor.on('requeststarted', logStatus);
|
|
175
|
-
networkMonitor.on('
|
|
176
|
+
networkMonitor.on('requestfinished', logStatus);
|
|
176
177
|
networkMonitor.on(busyEvent, logStatus);
|
|
177
178
|
|
|
178
179
|
if (!networkQuietOptions.pretendDCLAlreadyFired) {
|
|
@@ -192,7 +193,7 @@ function waitForNetworkIdle(session, networkMonitor, networkQuietOptions) {
|
|
|
192
193
|
networkMonitor.removeListener(busyEvent, onBusy);
|
|
193
194
|
networkMonitor.removeListener(idleEvent, onIdle);
|
|
194
195
|
networkMonitor.removeListener('requeststarted', logStatus);
|
|
195
|
-
networkMonitor.removeListener('
|
|
196
|
+
networkMonitor.removeListener('requestfinished', logStatus);
|
|
196
197
|
networkMonitor.removeListener(busyEvent, logStatus);
|
|
197
198
|
};
|
|
198
199
|
});
|
|
@@ -12,7 +12,7 @@ const {fetchResponseBodyFromCache} = require('../gather/driver/network.js');
|
|
|
12
12
|
const EventEmitter = require('events').EventEmitter;
|
|
13
13
|
|
|
14
14
|
const log = require('lighthouse-logger');
|
|
15
|
-
const
|
|
15
|
+
const DevtoolsMessageLog = require('./gatherers/devtools-log.js').DevtoolsMessageLog;
|
|
16
16
|
const TraceGatherer = require('./gatherers/trace.js');
|
|
17
17
|
|
|
18
18
|
// Pulled in for Connection type checking.
|
|
@@ -41,7 +41,7 @@ class Driver {
|
|
|
41
41
|
* @private
|
|
42
42
|
* Used to save network and lifecycle protocol traffic. Just Page and Network are needed.
|
|
43
43
|
*/
|
|
44
|
-
_devtoolsLog = new
|
|
44
|
+
_devtoolsLog = new DevtoolsMessageLog(/^(Page|Network)\./);
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* @private
|
|
@@ -208,16 +208,6 @@ class Driver {
|
|
|
208
208
|
// OOPIF handling in legacy driver is implicit.
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
/** @param {(session: LH.Gatherer.FRProtocolSession) => void} callback */
|
|
212
|
-
addSessionAttachedListener(callback) { // eslint-disable-line no-unused-vars
|
|
213
|
-
// OOPIF handling in legacy driver is implicit.
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/** @param {(session: LH.Gatherer.FRProtocolSession) => void} callback */
|
|
217
|
-
removeSessionAttachedListener(callback) { // eslint-disable-line no-unused-vars
|
|
218
|
-
// OOPIF handling in legacy driver is implicit.
|
|
219
|
-
}
|
|
220
|
-
|
|
221
211
|
/**
|
|
222
212
|
* Debounce enabling or disabling domains to prevent driver users from
|
|
223
213
|
* stomping on each other. Maintains an internal count of the times a domain
|
|
@@ -20,6 +20,7 @@ const WebAppManifest = require('./gatherers/web-app-manifest.js');
|
|
|
20
20
|
const InstallabilityErrors = require('./gatherers/installability-errors.js');
|
|
21
21
|
const NetworkUserAgent = require('./gatherers/network-user-agent.js');
|
|
22
22
|
const Stacks = require('./gatherers/stacks.js');
|
|
23
|
+
const URL = require('../lib/url-shim.js');
|
|
23
24
|
const {finalizeArtifacts} = require('../fraggle-rock/gather/base-artifacts.js');
|
|
24
25
|
|
|
25
26
|
/** @typedef {import('../gather/driver.js')} Driver */
|
|
@@ -491,6 +492,20 @@ class GatherRunner {
|
|
|
491
492
|
const baseArtifacts = await GatherRunner.initializeBaseArtifacts(options);
|
|
492
493
|
baseArtifacts.BenchmarkIndex = await getBenchmarkIndex(driver.executionContext);
|
|
493
494
|
|
|
495
|
+
// Hack for running benchmarkIndex extra times.
|
|
496
|
+
// Add a `bidx=20` query param, eg: https://www.example.com/?bidx=50
|
|
497
|
+
const parsedUrl = URL.isValid(options.requestedUrl) && new URL(options.requestedUrl);
|
|
498
|
+
if (options.settings.channel === 'lr' && parsedUrl && parsedUrl.searchParams.has('bidx')) {
|
|
499
|
+
const bidxRunCount = parsedUrl.searchParams.get('bidx') || 0;
|
|
500
|
+
// Add the first bidx into the new set
|
|
501
|
+
const indexes = [baseArtifacts.BenchmarkIndex];
|
|
502
|
+
for (let i = 0; i < bidxRunCount; i++) {
|
|
503
|
+
const bidx = await getBenchmarkIndex(driver.executionContext);
|
|
504
|
+
indexes.push(bidx);
|
|
505
|
+
}
|
|
506
|
+
baseArtifacts.BenchmarkIndexes = indexes;
|
|
507
|
+
}
|
|
508
|
+
|
|
494
509
|
await GatherRunner.setupDriver(driver, options);
|
|
495
510
|
|
|
496
511
|
let isFirstPass = true;
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
const NetworkMonitor = require('../driver/network-monitor.js');
|
|
15
|
-
const MessageLog = require('../devtools-log.js');
|
|
16
15
|
const FRGatherer = require('../../fraggle-rock/gather/base-gatherer.js');
|
|
17
16
|
|
|
18
17
|
class DevtoolsLog extends FRGatherer {
|
|
@@ -30,7 +29,7 @@ class DevtoolsLog extends FRGatherer {
|
|
|
30
29
|
/** @type {NetworkMonitor|undefined} */
|
|
31
30
|
this._networkMonitor = undefined;
|
|
32
31
|
|
|
33
|
-
this._messageLog = new
|
|
32
|
+
this._messageLog = new DevtoolsMessageLog(/^(Page|Network|Target|Runtime)\./);
|
|
34
33
|
|
|
35
34
|
/** @param {LH.Protocol.RawEventMessage} e */
|
|
36
35
|
this._onProtocolMessage = e => this._messageLog.record(e);
|
|
@@ -63,4 +62,59 @@ class DevtoolsLog extends FRGatherer {
|
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* This class saves all protocol messages whose method match a particular
|
|
68
|
+
* regex filter. Used when saving assets for later analysis by another tool such as
|
|
69
|
+
* Webpagetest.
|
|
70
|
+
*/
|
|
71
|
+
class DevtoolsMessageLog {
|
|
72
|
+
/**
|
|
73
|
+
* @param {RegExp=} regexFilter
|
|
74
|
+
*/
|
|
75
|
+
constructor(regexFilter) {
|
|
76
|
+
this._filter = regexFilter;
|
|
77
|
+
|
|
78
|
+
/** @type {LH.DevtoolsLog} */
|
|
79
|
+
this._messages = [];
|
|
80
|
+
this._isRecording = false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @return {LH.DevtoolsLog}
|
|
85
|
+
*/
|
|
86
|
+
get messages() {
|
|
87
|
+
return this._messages;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
reset() {
|
|
91
|
+
this._messages = [];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
beginRecording() {
|
|
95
|
+
this._isRecording = true;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
endRecording() {
|
|
99
|
+
this._isRecording = false;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Records a message if method matches filter and recording has been started.
|
|
104
|
+
* @param {LH.Protocol.RawEventMessage} message
|
|
105
|
+
*/
|
|
106
|
+
record(message) {
|
|
107
|
+
// We're not recording, skip the rest of the checks.
|
|
108
|
+
if (!this._isRecording) return;
|
|
109
|
+
// The event was likely an internal puppeteer method that uses Symbols.
|
|
110
|
+
if (typeof message.method !== 'string') return;
|
|
111
|
+
// The event didn't pass our filter, do not record it.
|
|
112
|
+
if (this._filter && !this._filter.test(message.method)) return;
|
|
113
|
+
|
|
114
|
+
// We passed all the checks, record the message.
|
|
115
|
+
this._messages.push(message);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
66
119
|
module.exports = DevtoolsLog;
|
|
120
|
+
module.exports.DevtoolsMessageLog = DevtoolsMessageLog;
|
package/lighthouse-core/index.js
CHANGED
|
@@ -64,7 +64,7 @@ async function legacyNavigation(url, flags = {}, configJSON, userConnection) {
|
|
|
64
64
|
flags.logLevel = flags.logLevel || 'error';
|
|
65
65
|
log.setLevel(flags.logLevel);
|
|
66
66
|
|
|
67
|
-
const config = generateConfig(configJSON, flags);
|
|
67
|
+
const config = await generateConfig(configJSON, flags);
|
|
68
68
|
const computedCache = new Map();
|
|
69
69
|
const options = {config, computedCache};
|
|
70
70
|
const connection = userConnection || new ChromeProtocol(flags.port, flags.hostname);
|
|
@@ -83,10 +83,10 @@ async function legacyNavigation(url, flags = {}, configJSON, userConnection) {
|
|
|
83
83
|
* not present, the default config is used.
|
|
84
84
|
* @param {LH.Flags=} flags Optional settings for the Lighthouse run. If present,
|
|
85
85
|
* they will override any settings in the config.
|
|
86
|
-
* @return {Config}
|
|
86
|
+
* @return {Promise<Config>}
|
|
87
87
|
*/
|
|
88
88
|
function generateConfig(configJson, flags) {
|
|
89
|
-
return
|
|
89
|
+
return Config.fromJson(configJson, flags);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
lighthouse.legacyNavigation = legacyNavigation;
|
|
@@ -288,10 +288,9 @@ async function saveAssets(artifacts, audits, pathWithBasename) {
|
|
|
288
288
|
fs.writeFileSync(devtoolsLogFilename, JSON.stringify(passAssets.devtoolsLog, null, 2));
|
|
289
289
|
log.log('saveAssets', 'devtools log saved to disk: ' + devtoolsLogFilename);
|
|
290
290
|
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
log.log('saveAssets', 'trace file streamed to disk: ' + streamTraceFilename);
|
|
291
|
+
const traceFilename = `${pathWithBasename}-${index}${traceSuffix}`;
|
|
292
|
+
await saveTrace(passAssets.traceData, traceFilename);
|
|
293
|
+
log.log('saveAssets', 'trace file streamed to disk: ' + traceFilename);
|
|
295
294
|
});
|
|
296
295
|
|
|
297
296
|
await Promise.all(saveAll);
|
|
@@ -9,7 +9,7 @@ const log = require('lighthouse-logger');
|
|
|
9
9
|
const NetworkRequest = require('./network-request.js');
|
|
10
10
|
const EventEmitter = require('events').EventEmitter;
|
|
11
11
|
|
|
12
|
-
/** @typedef {'requeststarted'|'
|
|
12
|
+
/** @typedef {'requeststarted'|'requestfinished'} NetworkRecorderEvent */
|
|
13
13
|
|
|
14
14
|
class NetworkRecorder extends EventEmitter {
|
|
15
15
|
/**
|
|
@@ -71,7 +71,7 @@ class NetworkRecorder extends EventEmitter {
|
|
|
71
71
|
* @private
|
|
72
72
|
*/
|
|
73
73
|
onRequestFinished(request) {
|
|
74
|
-
this.emit('
|
|
74
|
+
this.emit('requestfinished', request);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
// The below methods proxy network data into the NetworkRequest object which mimics the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lighthouse",
|
|
3
|
-
"version": "9.5.0-dev.
|
|
3
|
+
"version": "9.5.0-dev.20220610",
|
|
4
4
|
"description": "Automated auditing, performance metrics, and best practices for the web.",
|
|
5
5
|
"main": "./lighthouse-core/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -125,8 +125,8 @@
|
|
|
125
125
|
"@types/ws": "^7.0.0",
|
|
126
126
|
"@types/yargs": "^17.0.8",
|
|
127
127
|
"@types/yargs-parser": "^20.2.1",
|
|
128
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
129
|
-
"@typescript-eslint/parser": "^5.
|
|
128
|
+
"@typescript-eslint/eslint-plugin": "^5.27.1",
|
|
129
|
+
"@typescript-eslint/parser": "^5.27.1",
|
|
130
130
|
"acorn": "^8.5.0",
|
|
131
131
|
"angular": "^1.7.4",
|
|
132
132
|
"archiver": "^3.0.0",
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
"terser": "^5.3.8",
|
|
176
176
|
"ts-jest": "^27.0.4",
|
|
177
177
|
"typed-query-selector": "^2.6.1",
|
|
178
|
-
"typescript": "^4.
|
|
178
|
+
"typescript": "^4.7.3",
|
|
179
179
|
"wait-for-expect": "^3.0.2",
|
|
180
180
|
"webtreemap-cdt": "^3.2.1"
|
|
181
181
|
},
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../tsconfig-base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"outDir": "../../.tmp/tsbuildinfo/report/generator",
|
|
5
|
-
|
|
6
4
|
// Limit defs to base JS and DOM (for URL: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34960).
|
|
7
5
|
"lib": ["es2020", "dom"],
|
|
8
6
|
// Only include `@types/node` from node_modules/.
|
|
@@ -57,8 +57,8 @@ export class SwapLocaleFeature {
|
|
|
57
57
|
const optionLocaleDisplay = new Intl.DisplayNames([locale], {type: 'language'});
|
|
58
58
|
|
|
59
59
|
const optionLocaleName = optionLocaleDisplay.of(locale);
|
|
60
|
-
const currentLocaleName = currentLocaleDisplay.of(locale);
|
|
61
|
-
if (optionLocaleName !== currentLocaleName) {
|
|
60
|
+
const currentLocaleName = currentLocaleDisplay.of(locale) || locale;
|
|
61
|
+
if (optionLocaleName && optionLocaleName !== currentLocaleName) {
|
|
62
62
|
optionEl.textContent = `${optionLocaleName} – ${currentLocaleName}`;
|
|
63
63
|
} else {
|
|
64
64
|
optionEl.textContent = currentLocaleName;
|
package/report/tsconfig.json
CHANGED
package/shared/tsconfig.json
CHANGED
package/tsconfig-base.json
CHANGED
|
@@ -3,11 +3,16 @@
|
|
|
3
3
|
{
|
|
4
4
|
"compilerOptions": {
|
|
5
5
|
"composite": true,
|
|
6
|
+
|
|
7
|
+
// Set up incremental builds. All sub-projects emit under outDir, maintaining
|
|
8
|
+
// directory structure relative to rootDir. No effect on include, exclude, etc.
|
|
6
9
|
"emitDeclarationOnly": true,
|
|
7
10
|
"declarationMap": true,
|
|
11
|
+
"outDir": ".tmp/tsbuildinfo/",
|
|
12
|
+
"rootDir": ".",
|
|
8
13
|
|
|
9
14
|
"target": "es2020",
|
|
10
|
-
"module": "
|
|
15
|
+
"module": "es2022",
|
|
11
16
|
"moduleResolution": "node",
|
|
12
17
|
"esModuleInterop": true,
|
|
13
18
|
|
package/tsconfig.json
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "./tsconfig-base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"outDir": ".tmp/tsbuildinfo/",
|
|
5
|
-
|
|
6
4
|
// TODO(esmodules): included to support require('file.json'). Remove on the switch to ES Modules.
|
|
7
5
|
"resolveJsonModule": true,
|
|
8
6
|
},
|
|
@@ -32,6 +30,7 @@
|
|
|
32
30
|
"third-party/snyk/snapshot.json",
|
|
33
31
|
"lighthouse-core/audits/byte-efficiency/polyfill-graph-data.json",
|
|
34
32
|
"shared/localization/locales/en-US.json",
|
|
33
|
+
"esm-utils.mjs",
|
|
35
34
|
],
|
|
36
35
|
"exclude": [
|
|
37
36
|
"lighthouse-core/test/audits/**/*.js",
|
|
@@ -48,11 +47,11 @@
|
|
|
48
47
|
"lighthouse-core/test/config/config-test.js",
|
|
49
48
|
"lighthouse-core/test/config/default-config-test.js",
|
|
50
49
|
"lighthouse-core/test/create-test-trace.js",
|
|
51
|
-
"lighthouse-core/test/gather/devtools-log-test.js",
|
|
52
50
|
"lighthouse-core/test/gather/driver/wait-for-condition-test.js",
|
|
53
51
|
"lighthouse-core/test/gather/gatherers/accessibility-test.js",
|
|
54
52
|
"lighthouse-core/test/gather/gatherers/cache-contents-test.js",
|
|
55
53
|
"lighthouse-core/test/gather/gatherers/console-messages-test.js",
|
|
54
|
+
"lighthouse-core/test/gather/gatherers/devtools-log-test.js",
|
|
56
55
|
"lighthouse-core/test/gather/gatherers/dobetterweb/optimized-images-test.js",
|
|
57
56
|
"lighthouse-core/test/gather/gatherers/dobetterweb/password-inputs-with-prevented-paste-test.js",
|
|
58
57
|
"lighthouse-core/test/gather/gatherers/dobetterweb/response-compression-test.js",
|
package/types/artifacts.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ interface UniversalBaseArtifacts {
|
|
|
49
49
|
LighthouseRunWarnings: Array<string | IcuMessage>;
|
|
50
50
|
/** The benchmark index that indicates rough device class. */
|
|
51
51
|
BenchmarkIndex: number;
|
|
52
|
+
/** Many benchmark indexes. Many. */
|
|
53
|
+
BenchmarkIndexes?: number[];
|
|
52
54
|
/** An object containing information about the testing configuration used by Lighthouse. */
|
|
53
55
|
settings: Config.Settings;
|
|
54
56
|
/** The timing instrumentation of the gather portion of a run. */
|
package/types/gatherer.d.ts
CHANGED
|
@@ -30,8 +30,6 @@ declare module Gatherer {
|
|
|
30
30
|
once<TEvent extends keyof LH.CrdpEvents>(event: TEvent, callback: (...args: LH.CrdpEvents[TEvent]) => void): void;
|
|
31
31
|
addProtocolMessageListener(callback: (payload: Protocol.RawEventMessage) => void): void
|
|
32
32
|
removeProtocolMessageListener(callback: (payload: Protocol.RawEventMessage) => void): void
|
|
33
|
-
addSessionAttachedListener(callback: (session: FRProtocolSession) => void): void
|
|
34
|
-
removeSessionAttachedListener(callback: (session: FRProtocolSession) => void): void
|
|
35
33
|
off<TEvent extends keyof LH.CrdpEvents>(event: TEvent, callback: (...args: LH.CrdpEvents[TEvent]) => void): void;
|
|
36
34
|
sendCommand<TMethod extends keyof LH.CrdpCommands>(method: TMethod, ...params: LH.CrdpCommands[TMethod]['paramsType']): Promise<LH.CrdpCommands[TMethod]['returnType']>;
|
|
37
35
|
dispose(): Promise<void>;
|
package/types/lhr/lhr.d.ts
CHANGED
|
@@ -59,6 +59,8 @@ declare module Result {
|
|
|
59
59
|
networkUserAgent: string;
|
|
60
60
|
/** The benchmark index number that indicates rough device class. */
|
|
61
61
|
benchmarkIndex: number;
|
|
62
|
+
/** Many benchmark indexes. */
|
|
63
|
+
benchmarkIndexes?: number[];
|
|
62
64
|
/** The version of libraries with which these results were generated. Ex: axe-core. */
|
|
63
65
|
credits?: Record<string, string|undefined>,
|
|
64
66
|
}
|
package/types/lhr/tsconfig.json
CHANGED
|
@@ -11,6 +11,7 @@ declare module 'lighthouse-logger' {
|
|
|
11
11
|
args?: any[];
|
|
12
12
|
}
|
|
13
13
|
export function setLevel(level: string): void;
|
|
14
|
+
export function isVerbose(): boolean;
|
|
14
15
|
export function formatProtocol(prefix: string, data: Object, level?: string): void;
|
|
15
16
|
export function log(title: string, ...args: any[]): void;
|
|
16
17
|
export function warn(title: string, ...args: any[]): void;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright 2017 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
-
* 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
|
|
4
|
-
* 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.
|
|
5
|
-
*/
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @fileoverview This class saves all protocol messages whose method match a particular
|
|
10
|
-
* regex filter. Used when saving assets for later analysis by another tool such as
|
|
11
|
-
* Webpagetest.
|
|
12
|
-
*/
|
|
13
|
-
class DevtoolsLog {
|
|
14
|
-
/**
|
|
15
|
-
* @param {RegExp=} regexFilter
|
|
16
|
-
*/
|
|
17
|
-
constructor(regexFilter) {
|
|
18
|
-
this._filter = regexFilter;
|
|
19
|
-
|
|
20
|
-
/** @type {LH.DevtoolsLog} */
|
|
21
|
-
this._messages = [];
|
|
22
|
-
this._isRecording = false;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @return {LH.DevtoolsLog}
|
|
27
|
-
*/
|
|
28
|
-
get messages() {
|
|
29
|
-
return this._messages;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
reset() {
|
|
33
|
-
this._messages = [];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
beginRecording() {
|
|
37
|
-
this._isRecording = true;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
endRecording() {
|
|
41
|
-
this._isRecording = false;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Records a message if method matches filter and recording has been started.
|
|
46
|
-
* @param {LH.Protocol.RawEventMessage} message
|
|
47
|
-
*/
|
|
48
|
-
record(message) {
|
|
49
|
-
// We're not recording, skip the rest of the checks.
|
|
50
|
-
if (!this._isRecording) return;
|
|
51
|
-
// The event was likely an internal puppeteer method that uses Symbols.
|
|
52
|
-
if (typeof message.method !== 'string') return;
|
|
53
|
-
// The event didn't pass our filter, do not record it.
|
|
54
|
-
if (this._filter && !this._filter.test(message.method)) return;
|
|
55
|
-
|
|
56
|
-
// We passed all the checks, record the message.
|
|
57
|
-
this._messages.push(message);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
module.exports = DevtoolsLog;
|