lighthouse 10.4.0-dev.20230712 → 10.4.0-dev.20230714
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/cli-flags.d.ts +1 -6
- package/cli/cli-flags.js +0 -5
- package/cli/run.js +3 -10
- package/cli/test/smokehouse/lighthouse-runners/bundle.js +3 -1
- package/core/config/config-helpers.d.ts +3 -3
- package/core/config/config-helpers.js +5 -12
- package/core/config/config.js +1 -7
- package/core/config/constants.d.ts +0 -2
- package/core/config/constants.js +0 -16
- package/core/config/filters.js +1 -1
- package/core/config/validation.d.ts +5 -10
- package/core/config/validation.js +12 -22
- package/core/gather/base-artifacts.d.ts +4 -4
- package/core/gather/base-artifacts.js +2 -6
- package/core/gather/base-gatherer.d.ts +12 -37
- package/core/gather/base-gatherer.js +7 -54
- package/core/gather/driver/dom.d.ts +4 -4
- package/core/gather/driver/dom.js +2 -2
- package/core/gather/driver/environment.d.ts +4 -4
- package/core/gather/driver/environment.js +2 -2
- package/core/gather/driver/execution-context.d.ts +12 -3
- package/core/gather/driver/execution-context.js +27 -3
- package/core/gather/driver/navigation.d.ts +2 -2
- package/core/gather/driver/navigation.js +1 -1
- package/core/gather/driver/network-monitor.d.ts +6 -6
- package/core/gather/driver/network-monitor.js +3 -3
- package/core/gather/driver/network.d.ts +2 -2
- package/core/gather/driver/network.js +1 -1
- package/core/gather/driver/prepare.d.ts +10 -10
- package/core/gather/driver/prepare.js +10 -10
- package/core/gather/driver/service-workers.d.ts +4 -4
- package/core/gather/driver/service-workers.js +2 -2
- package/core/gather/driver/storage.d.ts +6 -6
- package/core/gather/driver/storage.js +3 -3
- package/core/gather/driver/target-manager.d.ts +6 -5
- package/core/gather/driver/target-manager.js +3 -3
- package/core/gather/driver/wait-for-condition.d.ts +14 -14
- package/core/gather/driver/wait-for-condition.js +8 -8
- package/core/gather/driver.d.ts +4 -4
- package/core/gather/driver.js +3 -3
- package/core/gather/fetcher.d.ts +3 -3
- package/core/gather/fetcher.js +1 -1
- package/core/gather/gatherers/accessibility.d.ts +4 -4
- package/core/gather/gatherers/accessibility.js +3 -3
- package/core/gather/gatherers/anchor-elements.d.ts +4 -4
- package/core/gather/gatherers/anchor-elements.js +4 -4
- package/core/gather/gatherers/bf-cache-failures.d.ts +8 -14
- package/core/gather/gatherers/bf-cache-failures.js +5 -14
- package/core/gather/gatherers/cache-contents.d.ts +4 -4
- package/core/gather/gatherers/cache-contents.js +3 -3
- package/core/gather/gatherers/console-messages.d.ts +6 -6
- package/core/gather/gatherers/console-messages.js +4 -4
- package/core/gather/gatherers/css-usage.d.ts +14 -14
- package/core/gather/gatherers/css-usage.js +9 -9
- package/core/gather/gatherers/devtools-log-compat.d.ts +5 -5
- package/core/gather/gatherers/devtools-log-compat.js +4 -4
- package/core/gather/gatherers/devtools-log.d.ts +6 -6
- package/core/gather/gatherers/devtools-log.js +4 -4
- package/core/gather/gatherers/dobetterweb/doctype.d.ts +4 -4
- package/core/gather/gatherers/dobetterweb/doctype.js +3 -3
- package/core/gather/gatherers/dobetterweb/domstats.d.ts +4 -4
- package/core/gather/gatherers/dobetterweb/domstats.js +3 -3
- package/core/gather/gatherers/dobetterweb/optimized-images.d.ts +10 -22
- package/core/gather/gatherers/dobetterweb/optimized-images.js +10 -27
- package/core/gather/gatherers/dobetterweb/response-compression.d.ts +6 -12
- package/core/gather/gatherers/dobetterweb/response-compression.js +6 -15
- package/core/gather/gatherers/dobetterweb/tags-blocking-first-paint.d.ts +8 -14
- package/core/gather/gatherers/dobetterweb/tags-blocking-first-paint.js +5 -14
- package/core/gather/gatherers/full-page-screenshot.d.ts +10 -10
- package/core/gather/gatherers/full-page-screenshot.js +6 -6
- package/core/gather/gatherers/global-listeners.d.ts +4 -4
- package/core/gather/gatherers/global-listeners.js +3 -3
- package/core/gather/gatherers/iframe-elements.d.ts +4 -4
- package/core/gather/gatherers/iframe-elements.js +3 -3
- package/core/gather/gatherers/image-elements.d.ts +10 -10
- package/core/gather/gatherers/image-elements.js +6 -6
- package/core/gather/gatherers/inputs.d.ts +4 -4
- package/core/gather/gatherers/inputs.js +3 -3
- package/core/gather/gatherers/inspector-issues.d.ts +8 -19
- package/core/gather/gatherers/inspector-issues.js +9 -26
- package/core/gather/gatherers/installability-errors.d.ts +6 -6
- package/core/gather/gatherers/installability-errors.js +4 -4
- package/core/gather/gatherers/js-usage.d.ts +6 -6
- package/core/gather/gatherers/js-usage.js +4 -4
- package/core/gather/gatherers/link-elements.d.ts +8 -20
- package/core/gather/gatherers/link-elements.js +7 -24
- package/core/gather/gatherers/main-document-content.d.ts +4 -16
- package/core/gather/gatherers/main-document-content.js +5 -23
- package/core/gather/gatherers/meta-elements.d.ts +4 -4
- package/core/gather/gatherers/meta-elements.js +3 -3
- package/core/gather/gatherers/network-user-agent.d.ts +5 -5
- package/core/gather/gatherers/network-user-agent.js +4 -4
- package/core/gather/gatherers/script-elements.d.ts +6 -11
- package/core/gather/gatherers/script-elements.js +4 -13
- package/core/gather/gatherers/scripts.d.ts +6 -6
- package/core/gather/gatherers/scripts.js +4 -4
- package/core/gather/gatherers/seo/embedded-content.d.ts +4 -4
- package/core/gather/gatherers/seo/embedded-content.js +3 -3
- package/core/gather/gatherers/seo/font-size.d.ts +6 -6
- package/core/gather/gatherers/seo/font-size.js +5 -5
- package/core/gather/gatherers/seo/robots-txt.d.ts +4 -4
- package/core/gather/gatherers/seo/robots-txt.js +3 -3
- package/core/gather/gatherers/seo/tap-targets.d.ts +8 -8
- package/core/gather/gatherers/seo/tap-targets.js +5 -5
- package/core/gather/gatherers/service-worker.d.ts +4 -10
- package/core/gather/gatherers/service-worker.js +3 -15
- package/core/gather/gatherers/source-maps.d.ts +12 -12
- package/core/gather/gatherers/source-maps.js +7 -7
- package/core/gather/gatherers/stacks.d.ts +7 -7
- package/core/gather/gatherers/stacks.js +6 -6
- package/core/gather/gatherers/trace-compat.d.ts +5 -5
- package/core/gather/gatherers/trace-compat.js +4 -4
- package/core/gather/gatherers/trace-elements.d.ts +13 -25
- package/core/gather/gatherers/trace-elements.js +13 -30
- package/core/gather/gatherers/trace.d.ts +8 -8
- package/core/gather/gatherers/trace.js +5 -5
- package/core/gather/gatherers/viewport-dimensions.d.ts +4 -4
- package/core/gather/gatherers/viewport-dimensions.js +3 -3
- package/core/gather/gatherers/web-app-manifest.d.ts +8 -8
- package/core/gather/gatherers/web-app-manifest.js +5 -5
- package/core/gather/navigation-runner.d.ts +9 -9
- package/core/gather/navigation-runner.js +6 -6
- package/core/gather/runner-helpers.d.ts +3 -3
- package/core/gather/runner-helpers.js +12 -4
- package/core/gather/session.d.ts +2 -2
- package/core/gather/session.js +1 -1
- package/core/gather/snapshot-runner.d.ts +2 -2
- package/core/gather/snapshot-runner.js +1 -1
- package/core/gather/timespan-runner.d.ts +2 -2
- package/core/gather/timespan-runner.js +1 -1
- package/core/index.cjs +0 -7
- package/core/index.d.ts +0 -15
- package/core/index.js +2 -40
- package/core/lib/asset-saver.js +8 -4
- package/core/lib/axe.js +1 -1
- package/core/lib/emulation.d.ts +14 -14
- package/core/lib/emulation.js +7 -7
- package/core/lib/page-functions.d.ts +2 -0
- package/core/lib/page-functions.js +10 -0
- package/core/lib/sentry.js +9 -2
- package/core/runner.d.ts +8 -30
- package/core/runner.js +6 -39
- package/core/user-flow.d.ts +4 -4
- package/core/user-flow.js +2 -2
- package/dist/report/bundle.esm.js +2221 -5832
- package/dist/report/flow.js +2631 -235
- package/dist/report/standalone.js +2586 -234
- package/package.json +9 -16
- package/third-party/esbuild-plugins-polyfills/LICENSE +3 -0
- package/third-party/esbuild-plugins-polyfills/README.md +7 -0
- package/third-party/esbuild-plugins-polyfills/esbuild-polyfills.d.ts +9 -0
- package/third-party/esbuild-plugins-polyfills/esbuild-polyfills.js +129 -0
- package/tsconfig.json +1 -0
- package/types/artifacts.d.ts +12 -45
- package/types/config.d.ts +10 -52
- package/types/externs.d.ts +0 -2
- package/types/gatherer.d.ts +20 -45
- package/types/lh.d.ts +0 -2
- package/core/gather/gatherers/gatherer.d.ts +0 -46
- package/core/gather/gatherers/gatherer.js +0 -58
- package/core/legacy/config/config.d.ts +0 -107
- package/core/legacy/config/config.js +0 -566
- package/core/legacy/config/legacy-default-config.d.ts +0 -4
- package/core/legacy/config/legacy-default-config.js +0 -87
- package/core/legacy/gather/connections/connection.d.ts +0 -77
- package/core/legacy/gather/connections/connection.js +0 -196
- package/core/legacy/gather/connections/cri.d.ts +0 -27
- package/core/legacy/gather/connections/cri.js +0 -162
- package/core/legacy/gather/connections/raw.d.ts +0 -20
- package/core/legacy/gather/connections/raw.js +0 -57
- package/core/legacy/gather/driver.d.ts +0 -216
- package/core/legacy/gather/driver.js +0 -480
- package/core/legacy/gather/gather-runner.d.ts +0 -166
- package/core/legacy/gather/gather-runner.js +0 -590
package/core/index.cjs
CHANGED
|
@@ -11,12 +11,6 @@ const lighthouse = async function lighthouse(...args) {
|
|
|
11
11
|
return lighthouse(...args);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
/** @type {import('./index.js')['legacyNavigation']} */
|
|
15
|
-
const legacyNavigation = async function legacyNavigation(...args) {
|
|
16
|
-
const {legacyNavigation} = await import('./index.js');
|
|
17
|
-
return legacyNavigation(...args);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
14
|
/** @type {import('./index.js')['startFlow']} */
|
|
21
15
|
const startFlow = async function startFlow(...args) {
|
|
22
16
|
const {startFlow} = await import('./index.js');
|
|
@@ -42,7 +36,6 @@ const snapshot = async function snapshot(...args) {
|
|
|
42
36
|
};
|
|
43
37
|
|
|
44
38
|
module.exports = lighthouse;
|
|
45
|
-
module.exports.legacyNavigation = legacyNavigation;
|
|
46
39
|
module.exports.startFlow = startFlow;
|
|
47
40
|
module.exports.navigation = navigation;
|
|
48
41
|
module.exports.startTimespan = startTimespan;
|
package/core/index.d.ts
CHANGED
|
@@ -5,8 +5,6 @@ export { NetworkRecords } from "./computed/network-records.js";
|
|
|
5
5
|
export { default as defaultConfig } from "./config/default-config.js";
|
|
6
6
|
export { default as desktopConfig } from "./config/desktop-config.js";
|
|
7
7
|
export * from "../types/lh.js";
|
|
8
|
-
export type Connection = import('./legacy/gather/connections/connection.js').Connection;
|
|
9
|
-
/** @typedef {import('./legacy/gather/connections/connection.js').Connection} Connection */
|
|
10
8
|
/**
|
|
11
9
|
* Run Lighthouse.
|
|
12
10
|
* @param {string=} url The URL to test. Optional if running in auditMode.
|
|
@@ -18,19 +16,6 @@ export type Connection = import('./legacy/gather/connections/connection.js').Con
|
|
|
18
16
|
* @return {Promise<LH.RunnerResult|undefined>}
|
|
19
17
|
*/
|
|
20
18
|
declare function lighthouse(url?: string | undefined, flags?: LH.Flags | undefined, config?: LH.Config | undefined, page?: LH.Puppeteer.Page | undefined): Promise<LH.RunnerResult | undefined>;
|
|
21
|
-
/**
|
|
22
|
-
* Run Lighthouse using the legacy navigation runner.
|
|
23
|
-
* This is left in place for any clients that don't support FR navigations yet (e.g. Lightrider)
|
|
24
|
-
* @deprecated
|
|
25
|
-
* @param {string=} url The URL to test. Optional if running in auditMode.
|
|
26
|
-
* @param {LH.Flags=} flags Optional settings for the Lighthouse run. If present,
|
|
27
|
-
* they will override any settings in the config.
|
|
28
|
-
* @param {LH.Config=} config Configuration for the Lighthouse run. If
|
|
29
|
-
* not present, the default config is used.
|
|
30
|
-
* @param {Connection=} userConnection
|
|
31
|
-
* @return {Promise<LH.RunnerResult|undefined>}
|
|
32
|
-
*/
|
|
33
|
-
export function legacyNavigation(url?: string | undefined, flags?: LH.Flags | undefined, config?: LH.Config | undefined, userConnection?: Connection | undefined): Promise<LH.RunnerResult | undefined>;
|
|
34
19
|
/**
|
|
35
20
|
* @param {LH.Puppeteer.Page} page
|
|
36
21
|
* @param {LH.UserFlow.Options} [options]
|
package/core/index.js
CHANGED
|
@@ -4,13 +4,8 @@
|
|
|
4
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
5
|
*/
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
|
|
7
|
+
import Trace from './gather/gatherers/trace.js';
|
|
9
8
|
import {Runner} from './runner.js';
|
|
10
|
-
import {CriConnection} from './legacy/gather/connections/cri.js';
|
|
11
|
-
import {LegacyResolvedConfig} from './legacy/config/config.js';
|
|
12
|
-
import UrlUtils from './lib/url-utils.js';
|
|
13
|
-
import {Driver} from './legacy/gather/driver.js';
|
|
14
9
|
import {UserFlow, auditGatherSteps} from './user-flow.js';
|
|
15
10
|
import {ReportGenerator} from '../report/generator/report-generator.js';
|
|
16
11
|
import {startTimespanGather} from './gather/timespan-runner.js';
|
|
@@ -18,8 +13,6 @@ import {snapshotGather} from './gather/snapshot-runner.js';
|
|
|
18
13
|
import {navigationGather} from './gather/navigation-runner.js';
|
|
19
14
|
import * as LH from '../types/lh.js';
|
|
20
15
|
|
|
21
|
-
/** @typedef {import('./legacy/gather/connections/connection.js').Connection} Connection */
|
|
22
|
-
|
|
23
16
|
/*
|
|
24
17
|
* The relationship between these root modules:
|
|
25
18
|
*
|
|
@@ -47,36 +40,6 @@ async function lighthouse(url, flags = {}, config, page) {
|
|
|
47
40
|
return navigation(page, url, {config, flags});
|
|
48
41
|
}
|
|
49
42
|
|
|
50
|
-
/**
|
|
51
|
-
* Run Lighthouse using the legacy navigation runner.
|
|
52
|
-
* This is left in place for any clients that don't support FR navigations yet (e.g. Lightrider)
|
|
53
|
-
* @deprecated
|
|
54
|
-
* @param {string=} url The URL to test. Optional if running in auditMode.
|
|
55
|
-
* @param {LH.Flags=} flags Optional settings for the Lighthouse run. If present,
|
|
56
|
-
* they will override any settings in the config.
|
|
57
|
-
* @param {LH.Config=} config Configuration for the Lighthouse run. If
|
|
58
|
-
* not present, the default config is used.
|
|
59
|
-
* @param {Connection=} userConnection
|
|
60
|
-
* @return {Promise<LH.RunnerResult|undefined>}
|
|
61
|
-
*/
|
|
62
|
-
async function legacyNavigation(url, flags = {}, config, userConnection) {
|
|
63
|
-
// set logging preferences, assume quiet
|
|
64
|
-
flags.logLevel = flags.logLevel || 'error';
|
|
65
|
-
log.setLevel(flags.logLevel);
|
|
66
|
-
|
|
67
|
-
const resolvedConfig = await LegacyResolvedConfig.fromJson(config, flags);
|
|
68
|
-
const computedCache = new Map();
|
|
69
|
-
const options = {resolvedConfig, computedCache};
|
|
70
|
-
const connection = userConnection || new CriConnection(flags.port, flags.hostname);
|
|
71
|
-
|
|
72
|
-
// kick off a lighthouse run
|
|
73
|
-
const artifacts = await Runner.gather(() => {
|
|
74
|
-
const requestedUrl = UrlUtils.normalizeUrl(url);
|
|
75
|
-
return Runner._gatherArtifactsFromBrowser(requestedUrl, options, connection);
|
|
76
|
-
}, options);
|
|
77
|
-
return Runner.audit(artifacts, options);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
43
|
/**
|
|
81
44
|
* @param {LH.Puppeteer.Page} page
|
|
82
45
|
* @param {LH.UserFlow.Options} [options]
|
|
@@ -150,7 +113,7 @@ function getAuditList() {
|
|
|
150
113
|
return Runner.getAuditList();
|
|
151
114
|
}
|
|
152
115
|
|
|
153
|
-
const traceCategories =
|
|
116
|
+
const traceCategories = Trace.getDefaultTraceCategories();
|
|
154
117
|
|
|
155
118
|
export default lighthouse;
|
|
156
119
|
export {Audit} from './audits/audit.js';
|
|
@@ -160,7 +123,6 @@ export {default as defaultConfig} from './config/default-config.js';
|
|
|
160
123
|
export {default as desktopConfig} from './config/desktop-config.js';
|
|
161
124
|
export * from '../types/lh.js';
|
|
162
125
|
export {
|
|
163
|
-
legacyNavigation,
|
|
164
126
|
startFlow,
|
|
165
127
|
navigation,
|
|
166
128
|
startTimespan,
|
package/core/lib/asset-saver.js
CHANGED
|
@@ -220,13 +220,17 @@ async function saveArtifacts(artifacts, basePath) {
|
|
|
220
220
|
const {traces, devtoolsLogs, DevtoolsLog, Trace, ...restArtifacts} = artifacts;
|
|
221
221
|
|
|
222
222
|
// save traces
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
if (traces) {
|
|
224
|
+
for (const [passName, trace] of Object.entries(traces)) {
|
|
225
|
+
await saveTrace(trace, `${basePath}/${passName}${traceSuffix}`);
|
|
226
|
+
}
|
|
225
227
|
}
|
|
226
228
|
|
|
227
229
|
// save devtools log
|
|
228
|
-
|
|
229
|
-
|
|
230
|
+
if (devtoolsLogs) {
|
|
231
|
+
for (const [passName, devtoolsLog] of Object.entries(devtoolsLogs)) {
|
|
232
|
+
await saveDevtoolsLog(devtoolsLog, `${basePath}/${passName}${devtoolsLogSuffix}`);
|
|
233
|
+
}
|
|
230
234
|
}
|
|
231
235
|
|
|
232
236
|
// save everything else, using a replacer to serialize LighthouseErrors in the artifacts.
|
package/core/lib/axe.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import fs from 'fs';
|
|
8
8
|
import {createRequire} from 'module';
|
|
9
9
|
|
|
10
|
-
// This is removed by
|
|
10
|
+
// This is removed by esbuild (if minified), because the only usage is to resolve a module path
|
|
11
11
|
// but that is replaced by the inline-fs plugin, leaving `require` unused.
|
|
12
12
|
const require = /* #__PURE__ */ createRequire(import.meta.url);
|
|
13
13
|
const axeSource = fs.readFileSync(require.resolve('axe-core/axe.min.js'), 'utf8');
|
package/core/lib/emulation.d.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {LH.Gatherer.
|
|
2
|
+
* @param {LH.Gatherer.ProtocolSession} session
|
|
3
3
|
* @param {LH.Config.Settings} settings
|
|
4
4
|
* @return {Promise<void>}
|
|
5
5
|
*/
|
|
6
|
-
export function emulate(session: LH.Gatherer.
|
|
6
|
+
export function emulate(session: LH.Gatherer.ProtocolSession, settings: LH.Config.Settings): Promise<void>;
|
|
7
7
|
/**
|
|
8
8
|
* Sets the throttling options specified in config settings, clearing existing network throttling if
|
|
9
9
|
* throttlingMethod is not `devtools` (but not CPU throttling, suspected requirement of WPT-compat).
|
|
10
10
|
*
|
|
11
|
-
* @param {LH.Gatherer.
|
|
11
|
+
* @param {LH.Gatherer.ProtocolSession} session
|
|
12
12
|
* @param {LH.Config.Settings} settings
|
|
13
13
|
* @return {Promise<void>}
|
|
14
14
|
*/
|
|
15
|
-
export function throttle(session: LH.Gatherer.
|
|
15
|
+
export function throttle(session: LH.Gatherer.ProtocolSession, settings: LH.Config.Settings): Promise<void>;
|
|
16
16
|
/**
|
|
17
|
-
* @param {LH.Gatherer.
|
|
17
|
+
* @param {LH.Gatherer.ProtocolSession} session
|
|
18
18
|
* @return {Promise<void>}
|
|
19
19
|
*/
|
|
20
|
-
export function clearThrottling(session: LH.Gatherer.
|
|
20
|
+
export function clearThrottling(session: LH.Gatherer.ProtocolSession): Promise<void>;
|
|
21
21
|
/**
|
|
22
|
-
* @param {LH.Gatherer.
|
|
22
|
+
* @param {LH.Gatherer.ProtocolSession} session
|
|
23
23
|
* @param {Required<LH.ThrottlingSettings>} throttlingSettings
|
|
24
24
|
* @return {Promise<void>}
|
|
25
25
|
*/
|
|
26
|
-
export function enableNetworkThrottling(session: LH.Gatherer.
|
|
26
|
+
export function enableNetworkThrottling(session: LH.Gatherer.ProtocolSession, throttlingSettings: Required<LH.ThrottlingSettings>): Promise<void>;
|
|
27
27
|
/**
|
|
28
|
-
* @param {LH.Gatherer.
|
|
28
|
+
* @param {LH.Gatherer.ProtocolSession} session
|
|
29
29
|
* @return {Promise<void>}
|
|
30
30
|
*/
|
|
31
|
-
export function clearNetworkThrottling(session: LH.Gatherer.
|
|
31
|
+
export function clearNetworkThrottling(session: LH.Gatherer.ProtocolSession): Promise<void>;
|
|
32
32
|
/**
|
|
33
|
-
* @param {LH.Gatherer.
|
|
33
|
+
* @param {LH.Gatherer.ProtocolSession} session
|
|
34
34
|
* @param {Required<LH.ThrottlingSettings>} throttlingSettings
|
|
35
35
|
* @return {Promise<void>}
|
|
36
36
|
*/
|
|
37
|
-
export function enableCPUThrottling(session: LH.Gatherer.
|
|
37
|
+
export function enableCPUThrottling(session: LH.Gatherer.ProtocolSession, throttlingSettings: Required<LH.ThrottlingSettings>): Promise<void>;
|
|
38
38
|
/**
|
|
39
|
-
* @param {LH.Gatherer.
|
|
39
|
+
* @param {LH.Gatherer.ProtocolSession} session
|
|
40
40
|
* @return {Promise<void>}
|
|
41
41
|
*/
|
|
42
|
-
export function clearCPUThrottling(session: LH.Gatherer.
|
|
42
|
+
export function clearCPUThrottling(session: LH.Gatherer.ProtocolSession): Promise<void>;
|
|
43
43
|
//# sourceMappingURL=emulation.d.ts.map
|
package/core/lib/emulation.js
CHANGED
|
@@ -58,7 +58,7 @@ function parseUseragentIntoMetadata(userAgent, formFactor) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* @param {LH.Gatherer.
|
|
61
|
+
* @param {LH.Gatherer.ProtocolSession} session
|
|
62
62
|
* @param {LH.Config.Settings} settings
|
|
63
63
|
* @return {Promise<void>}
|
|
64
64
|
*/
|
|
@@ -85,7 +85,7 @@ async function emulate(session, settings) {
|
|
|
85
85
|
* Sets the throttling options specified in config settings, clearing existing network throttling if
|
|
86
86
|
* throttlingMethod is not `devtools` (but not CPU throttling, suspected requirement of WPT-compat).
|
|
87
87
|
*
|
|
88
|
-
* @param {LH.Gatherer.
|
|
88
|
+
* @param {LH.Gatherer.ProtocolSession} session
|
|
89
89
|
* @param {LH.Config.Settings} settings
|
|
90
90
|
* @return {Promise<void>}
|
|
91
91
|
*/
|
|
@@ -99,7 +99,7 @@ async function throttle(session, settings) {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
|
-
* @param {LH.Gatherer.
|
|
102
|
+
* @param {LH.Gatherer.ProtocolSession} session
|
|
103
103
|
* @return {Promise<void>}
|
|
104
104
|
*/
|
|
105
105
|
async function clearThrottling(session) {
|
|
@@ -107,7 +107,7 @@ async function clearThrottling(session) {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
|
-
* @param {LH.Gatherer.
|
|
110
|
+
* @param {LH.Gatherer.ProtocolSession} session
|
|
111
111
|
* @param {Required<LH.ThrottlingSettings>} throttlingSettings
|
|
112
112
|
* @return {Promise<void>}
|
|
113
113
|
*/
|
|
@@ -127,7 +127,7 @@ function enableNetworkThrottling(session, throttlingSettings) {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
/**
|
|
130
|
-
* @param {LH.Gatherer.
|
|
130
|
+
* @param {LH.Gatherer.ProtocolSession} session
|
|
131
131
|
* @return {Promise<void>}
|
|
132
132
|
*/
|
|
133
133
|
function clearNetworkThrottling(session) {
|
|
@@ -135,7 +135,7 @@ function clearNetworkThrottling(session) {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
|
-
* @param {LH.Gatherer.
|
|
138
|
+
* @param {LH.Gatherer.ProtocolSession} session
|
|
139
139
|
* @param {Required<LH.ThrottlingSettings>} throttlingSettings
|
|
140
140
|
* @return {Promise<void>}
|
|
141
141
|
*/
|
|
@@ -145,7 +145,7 @@ function enableCPUThrottling(session, throttlingSettings) {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
|
-
* @param {LH.Gatherer.
|
|
148
|
+
* @param {LH.Gatherer.ProtocolSession} session
|
|
149
149
|
* @return {Promise<void>}
|
|
150
150
|
*/
|
|
151
151
|
function clearCPUThrottling(session) {
|
|
@@ -11,6 +11,7 @@ export namespace pageFunctions {
|
|
|
11
11
|
export { wrapRequestIdleCallback };
|
|
12
12
|
export { getBoundingClientRect };
|
|
13
13
|
export { truncate };
|
|
14
|
+
export { esbuildFunctionNameStubString };
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* `typed-query-selector`'s CSS selector parser.
|
|
@@ -157,5 +158,6 @@ declare function truncate(string: string, characterLimit: number): string;
|
|
|
157
158
|
declare namespace truncate {
|
|
158
159
|
function toString(): string;
|
|
159
160
|
}
|
|
161
|
+
declare const esbuildFunctionNameStubString: "var __name=(fn)=>fn;";
|
|
160
162
|
export {};
|
|
161
163
|
//# sourceMappingURL=page-functions.d.ts.map
|
|
@@ -513,6 +513,15 @@ function truncate(string, characterLimit) {
|
|
|
513
513
|
return Util.truncate(string, characterLimit);
|
|
514
514
|
}
|
|
515
515
|
|
|
516
|
+
// This is to support bundled lighthouse.
|
|
517
|
+
// esbuild calls every function with a builtin `__name`, whose purpose is to store the
|
|
518
|
+
// real name of the function so that esbuild can rename it to avoid collisions. There is no way to
|
|
519
|
+
// disable this renaming, even if esbuild minification (and thus function name mangling) is disabled.
|
|
520
|
+
// Anywhere we inject dynamically generated code at runtime for the browser to process,
|
|
521
|
+
// we must manually include this function (because esbuild only does so once at the top scope
|
|
522
|
+
// of the bundle, which is irrelevant for code executed in the browser).
|
|
523
|
+
const esbuildFunctionNameStubString = 'var __name=(fn)=>fn;';
|
|
524
|
+
|
|
516
525
|
/** @type {string} */
|
|
517
526
|
const truncateRawString = truncate.toString();
|
|
518
527
|
truncate.toString = () => `function truncate(string, characterLimit) {
|
|
@@ -560,4 +569,5 @@ export const pageFunctions = {
|
|
|
560
569
|
wrapRequestIdleCallback,
|
|
561
570
|
getBoundingClientRect,
|
|
562
571
|
truncate,
|
|
572
|
+
esbuildFunctionNameStubString,
|
|
563
573
|
};
|
package/core/lib/sentry.js
CHANGED
|
@@ -126,9 +126,16 @@ async function init(opts) {
|
|
|
126
126
|
if (opts.tags) {
|
|
127
127
|
scope.setTags(opts.tags);
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
|
|
130
|
+
// Add extra details
|
|
131
|
+
let extra;
|
|
132
|
+
if (opts.extra) extra = {...opts.extra};
|
|
133
|
+
// @ts-expect-error Non-standard property
|
|
134
|
+
if (err.extra) extra = {...extra, ...err.extra};
|
|
135
|
+
if (extra) {
|
|
136
|
+
scope.setExtras(extra);
|
|
131
137
|
}
|
|
138
|
+
|
|
132
139
|
Sentry.captureException(err);
|
|
133
140
|
});
|
|
134
141
|
};
|
package/core/runner.d.ts
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
export type Connection = import('./legacy/gather/connections/connection.js').Connection;
|
|
2
1
|
export type ArbitraryEqualityMap = import('./lib/arbitrary-equality-map.js').ArbitraryEqualityMap;
|
|
3
|
-
export type Config = LH.Config.LegacyResolvedConfig;
|
|
4
|
-
/** @typedef {import('./legacy/gather/connections/connection.js').Connection} Connection */
|
|
5
2
|
/** @typedef {import('./lib/arbitrary-equality-map.js').ArbitraryEqualityMap} ArbitraryEqualityMap */
|
|
6
|
-
/** @typedef {LH.Config.LegacyResolvedConfig} Config */
|
|
7
3
|
export class Runner {
|
|
8
4
|
/**
|
|
9
|
-
* @template {LH.Config.LegacyResolvedConfig | LH.Config.ResolvedConfig} TConfig
|
|
10
5
|
* @param {LH.Artifacts} artifacts
|
|
11
|
-
* @param {{resolvedConfig:
|
|
6
|
+
* @param {{resolvedConfig: LH.Config.ResolvedConfig, computedCache: Map<string, ArbitraryEqualityMap>}} options
|
|
12
7
|
* @return {Promise<LH.RunnerResult|undefined>}
|
|
13
8
|
*/
|
|
14
|
-
static audit
|
|
15
|
-
resolvedConfig:
|
|
16
|
-
driverMock?: Driver | undefined;
|
|
9
|
+
static audit(artifacts: LH.Artifacts, options: {
|
|
10
|
+
resolvedConfig: LH.Config.ResolvedConfig;
|
|
17
11
|
computedCache: Map<string, ArbitraryEqualityMap>;
|
|
18
12
|
}): Promise<LH.RunnerResult | undefined>;
|
|
19
13
|
/**
|
|
@@ -26,17 +20,14 @@ export class Runner {
|
|
|
26
20
|
* -G and -A will run partial lighthouse pipelines,
|
|
27
21
|
* and -GA will run everything plus save artifacts and lhr to disk.
|
|
28
22
|
*
|
|
29
|
-
* @
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {{resolvedConfig: TConfig, driverMock?: Driver, computedCache: Map<string, ArbitraryEqualityMap>}} options
|
|
23
|
+
* @param {(runnerData: {resolvedConfig: LH.Config.ResolvedConfig}) => Promise<LH.Artifacts>} gatherFn
|
|
24
|
+
* @param {{resolvedConfig: LH.Config.ResolvedConfig, computedCache: Map<string, ArbitraryEqualityMap>}} options
|
|
32
25
|
* @return {Promise<LH.Artifacts>}
|
|
33
26
|
*/
|
|
34
|
-
static gather
|
|
35
|
-
resolvedConfig:
|
|
36
|
-
driverMock?: Driver | undefined;
|
|
27
|
+
static gather(gatherFn: (runnerData: {
|
|
28
|
+
resolvedConfig: LH.Config.ResolvedConfig;
|
|
37
29
|
}) => Promise<LH.Artifacts>, options: {
|
|
38
|
-
resolvedConfig:
|
|
39
|
-
driverMock?: Driver | undefined;
|
|
30
|
+
resolvedConfig: LH.Config.ResolvedConfig;
|
|
40
31
|
computedCache: Map<string, ArbitraryEqualityMap>;
|
|
41
32
|
}): Promise<LH.Artifacts>;
|
|
42
33
|
/**
|
|
@@ -52,18 +43,6 @@ export class Runner {
|
|
|
52
43
|
* @return {LH.Result.Timing}
|
|
53
44
|
*/
|
|
54
45
|
static _getTiming(artifacts: LH.Artifacts): LH.Result.Timing;
|
|
55
|
-
/**
|
|
56
|
-
* Establish connection, load page and collect all required artifacts
|
|
57
|
-
* @param {string} requestedUrl
|
|
58
|
-
* @param {{resolvedConfig: Config, computedCache: Map<string, ArbitraryEqualityMap>, driverMock?: Driver}} runnerOpts
|
|
59
|
-
* @param {Connection} connection
|
|
60
|
-
* @return {Promise<LH.Artifacts>}
|
|
61
|
-
*/
|
|
62
|
-
static _gatherArtifactsFromBrowser(requestedUrl: string, runnerOpts: {
|
|
63
|
-
resolvedConfig: Config;
|
|
64
|
-
computedCache: Map<string, ArbitraryEqualityMap>;
|
|
65
|
-
driverMock?: Driver;
|
|
66
|
-
}, connection: Connection): Promise<LH.Artifacts>;
|
|
67
46
|
/**
|
|
68
47
|
* Run all audits with specified settings and artifacts.
|
|
69
48
|
* @param {LH.Config.Settings} settings
|
|
@@ -109,6 +88,5 @@ export class Runner {
|
|
|
109
88
|
*/
|
|
110
89
|
static _getDataSavePath(settings: LH.Config.Settings): string;
|
|
111
90
|
}
|
|
112
|
-
import { Driver } from './legacy/gather/driver.js';
|
|
113
91
|
import { Audit } from './audits/audit.js';
|
|
114
92
|
//# sourceMappingURL=runner.d.ts.map
|
package/core/runner.js
CHANGED
|
@@ -11,8 +11,6 @@ import path from 'path';
|
|
|
11
11
|
import log from 'lighthouse-logger';
|
|
12
12
|
import isDeepEqual from 'lodash/isEqual.js';
|
|
13
13
|
|
|
14
|
-
import {Driver} from './legacy/gather/driver.js';
|
|
15
|
-
import {GatherRunner} from './legacy/gather/gather-runner.js';
|
|
16
14
|
import {ReportScoring} from './scoring.js';
|
|
17
15
|
import {Audit} from './audits/audit.js';
|
|
18
16
|
import * as format from '../shared/localization/format.js';
|
|
@@ -28,15 +26,12 @@ import UrlUtils from './lib/url-utils.js';
|
|
|
28
26
|
|
|
29
27
|
const moduleDir = getModuleDirectory(import.meta);
|
|
30
28
|
|
|
31
|
-
/** @typedef {import('./legacy/gather/connections/connection.js').Connection} Connection */
|
|
32
29
|
/** @typedef {import('./lib/arbitrary-equality-map.js').ArbitraryEqualityMap} ArbitraryEqualityMap */
|
|
33
|
-
/** @typedef {LH.Config.LegacyResolvedConfig} Config */
|
|
34
30
|
|
|
35
31
|
class Runner {
|
|
36
32
|
/**
|
|
37
|
-
* @template {LH.Config.LegacyResolvedConfig | LH.Config.ResolvedConfig} TConfig
|
|
38
33
|
* @param {LH.Artifacts} artifacts
|
|
39
|
-
* @param {{resolvedConfig:
|
|
34
|
+
* @param {{resolvedConfig: LH.Config.ResolvedConfig, computedCache: Map<string, ArbitraryEqualityMap>}} options
|
|
40
35
|
* @return {Promise<LH.RunnerResult|undefined>}
|
|
41
36
|
*/
|
|
42
37
|
static async audit(artifacts, options) {
|
|
@@ -153,7 +148,7 @@ class Runner {
|
|
|
153
148
|
* @param {LH.Artifacts.ComputedContext} context
|
|
154
149
|
*/
|
|
155
150
|
static async getEntityClassification(artifacts, context) {
|
|
156
|
-
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
151
|
+
const devtoolsLog = artifacts.devtoolsLogs?.[Audit.DEFAULT_PASS];
|
|
157
152
|
if (!devtoolsLog) return;
|
|
158
153
|
const classifiedEntities = await EntityClassification.request(
|
|
159
154
|
{URL: artifacts.URL, devtoolsLog}, context);
|
|
@@ -188,9 +183,8 @@ class Runner {
|
|
|
188
183
|
* -G and -A will run partial lighthouse pipelines,
|
|
189
184
|
* and -GA will run everything plus save artifacts and lhr to disk.
|
|
190
185
|
*
|
|
191
|
-
* @
|
|
192
|
-
* @param {
|
|
193
|
-
* @param {{resolvedConfig: TConfig, driverMock?: Driver, computedCache: Map<string, ArbitraryEqualityMap>}} options
|
|
186
|
+
* @param {(runnerData: {resolvedConfig: LH.Config.ResolvedConfig}) => Promise<LH.Artifacts>} gatherFn
|
|
187
|
+
* @param {{resolvedConfig: LH.Config.ResolvedConfig, computedCache: Map<string, ArbitraryEqualityMap>}} options
|
|
194
188
|
* @return {Promise<LH.Artifacts>}
|
|
195
189
|
*/
|
|
196
190
|
static async gather(gatherFn, options) {
|
|
@@ -217,7 +211,6 @@ class Runner {
|
|
|
217
211
|
|
|
218
212
|
artifacts = await gatherFn({
|
|
219
213
|
resolvedConfig: options.resolvedConfig,
|
|
220
|
-
driverMock: options.driverMock,
|
|
221
214
|
});
|
|
222
215
|
|
|
223
216
|
log.timeEnd(runnerStatus);
|
|
@@ -291,28 +284,6 @@ class Runner {
|
|
|
291
284
|
return {entries: timingEntries, total: gatherTiming + auditTiming};
|
|
292
285
|
}
|
|
293
286
|
|
|
294
|
-
/**
|
|
295
|
-
* Establish connection, load page and collect all required artifacts
|
|
296
|
-
* @param {string} requestedUrl
|
|
297
|
-
* @param {{resolvedConfig: Config, computedCache: Map<string, ArbitraryEqualityMap>, driverMock?: Driver}} runnerOpts
|
|
298
|
-
* @param {Connection} connection
|
|
299
|
-
* @return {Promise<LH.Artifacts>}
|
|
300
|
-
*/
|
|
301
|
-
static async _gatherArtifactsFromBrowser(requestedUrl, runnerOpts, connection) {
|
|
302
|
-
if (!runnerOpts.resolvedConfig.passes) {
|
|
303
|
-
throw new Error('No browser artifacts are either provided or requested.');
|
|
304
|
-
}
|
|
305
|
-
const driver = runnerOpts.driverMock || new Driver(connection);
|
|
306
|
-
const gatherOpts = {
|
|
307
|
-
driver,
|
|
308
|
-
requestedUrl,
|
|
309
|
-
settings: runnerOpts.resolvedConfig.settings,
|
|
310
|
-
computedCache: runnerOpts.computedCache,
|
|
311
|
-
};
|
|
312
|
-
const artifacts = await GatherRunner.run(runnerOpts.resolvedConfig.passes, gatherOpts);
|
|
313
|
-
return artifacts;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
287
|
/**
|
|
317
288
|
* Run all audits with specified settings and artifacts.
|
|
318
289
|
* @param {LH.Config.Settings} settings
|
|
@@ -419,15 +390,11 @@ class Runner {
|
|
|
419
390
|
// @ts-expect-error: TODO why is this a type error now?
|
|
420
391
|
const artifactError = artifacts[artifactName];
|
|
421
392
|
|
|
422
|
-
Sentry.captureException(artifactError, {
|
|
423
|
-
tags: {gatherer: artifactName},
|
|
424
|
-
level: 'error',
|
|
425
|
-
});
|
|
426
|
-
|
|
427
393
|
log.warn('Runner', `${artifactName} gatherer, required by audit ${audit.meta.id},` +
|
|
428
394
|
` encountered an error: ${artifactError.message}`);
|
|
429
395
|
|
|
430
|
-
// Create a friendlier display error and mark it as expected to avoid duplicates in Sentry
|
|
396
|
+
// Create a friendlier display error and mark it as expected to avoid duplicates in Sentry.
|
|
397
|
+
// The artifact error was already sent to Sentry in `collectPhaseArtifacts`.
|
|
431
398
|
const error = new LighthouseError(LighthouseError.errors.ERRORED_REQUIRED_ARTIFACT,
|
|
432
399
|
{artifactName, errorMessage: artifactError.message}, {cause: artifactError});
|
|
433
400
|
// @ts-expect-error Non-standard property added to Error
|
package/core/user-flow.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type GatherStepRunnerOptions = WeakMap<LH.UserFlow.GatherStep, LH.Gatherer.
|
|
1
|
+
export type GatherStepRunnerOptions = WeakMap<LH.UserFlow.GatherStep, LH.Gatherer.GatherResult['runnerOptions']>;
|
|
2
2
|
export class UserFlow {
|
|
3
3
|
/**
|
|
4
4
|
* @param {LH.Puppeteer.Page} page
|
|
@@ -24,10 +24,10 @@ export class UserFlow {
|
|
|
24
24
|
*/
|
|
25
25
|
_getNextNavigationFlags(flags: LH.UserFlow.StepFlags | undefined): LH.UserFlow.StepFlags;
|
|
26
26
|
/**
|
|
27
|
-
* @param {LH.Gatherer.
|
|
27
|
+
* @param {LH.Gatherer.GatherResult} gatherResult
|
|
28
28
|
* @param {LH.UserFlow.StepFlags} [flags]
|
|
29
29
|
*/
|
|
30
|
-
_addGatherStep(gatherResult: LH.Gatherer.
|
|
30
|
+
_addGatherStep(gatherResult: LH.Gatherer.GatherResult, flags?: LH.UserFlow.StepFlags | undefined): void;
|
|
31
31
|
/**
|
|
32
32
|
* @param {LH.NavigationRequestor} requestor
|
|
33
33
|
* @param {LH.UserFlow.StepFlags} [flags]
|
|
@@ -50,7 +50,7 @@ export class UserFlow {
|
|
|
50
50
|
startTimespan(flags?: LH.UserFlow.StepFlags | undefined): Promise<void>;
|
|
51
51
|
currentTimespan: {
|
|
52
52
|
timespan: {
|
|
53
|
-
endTimespanGather(): Promise<LH.Gatherer.
|
|
53
|
+
endTimespanGather(): Promise<LH.Gatherer.GatherResult>;
|
|
54
54
|
};
|
|
55
55
|
flags: LH.UserFlow.StepFlags | undefined;
|
|
56
56
|
} | undefined;
|
package/core/user-flow.js
CHANGED
|
@@ -15,7 +15,7 @@ import {mergeConfigFragment, deepClone} from './config/config-helpers.js';
|
|
|
15
15
|
import * as i18n from './lib/i18n/i18n.js';
|
|
16
16
|
import * as LH from '../types/lh.js';
|
|
17
17
|
|
|
18
|
-
/** @typedef {WeakMap<LH.UserFlow.GatherStep, LH.Gatherer.
|
|
18
|
+
/** @typedef {WeakMap<LH.UserFlow.GatherStep, LH.Gatherer.GatherResult['runnerOptions']>} GatherStepRunnerOptions */
|
|
19
19
|
|
|
20
20
|
const UIStrings = {
|
|
21
21
|
/**
|
|
@@ -107,7 +107,7 @@ class UserFlow {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
|
-
* @param {LH.Gatherer.
|
|
110
|
+
* @param {LH.Gatherer.GatherResult} gatherResult
|
|
111
111
|
* @param {LH.UserFlow.StepFlags} [flags]
|
|
112
112
|
*/
|
|
113
113
|
_addGatherStep(gatherResult, flags) {
|