lighthouse 13.6.0-dev.20261112 → 13.6.0-dev.20261117
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/.agents/skills/update-ard-port/SKILL.md +1 -1
- package/cli/bin.js +8 -3
- package/cli/open-file.js +1 -1
- package/cli/printer.js +1 -1
- package/cli/run.d.ts +7 -0
- package/cli/run.js +42 -5
- package/cli/sentry-prompt.js +2 -1
- package/cli/test/smokehouse/frontends/smokehouse-bin.js +1 -1
- package/cli/test/smokehouse/lighthouse-runners/cli.js +1 -2
- package/cli/test/smokehouse/report-assert.js +1 -2
- package/cli/test/smokehouse/smokehouse.js +1 -2
- package/core/audits/autocomplete.js +1 -2
- package/core/audits/baseline.d.ts +3 -0
- package/core/audits/bootup-time.js +1 -2
- package/core/audits/errors-in-console.js +1 -2
- package/core/audits/mainthread-work-breakdown.js +1 -2
- package/core/audits/metrics.d.ts +2 -2
- package/core/audits/metrics.js +1 -1
- package/core/computed/computed-artifact.js +1 -2
- package/core/computed/entity-classification.d.ts +3 -3
- package/core/computed/entity-classification.js +5 -3
- package/core/computed/js-bundles.js +1 -2
- package/core/computed/lcp-network-record.js +1 -1
- package/core/computed/load-simulator.d.ts +5 -3
- package/core/computed/load-simulator.js +9 -2
- package/core/computed/metrics/lcp-breakdown.d.ts +19 -0
- package/core/computed/metrics/lcp-breakdown.js +71 -8
- package/core/computed/metrics/responsiveness.d.ts +5 -3
- package/core/computed/metrics/responsiveness.js +1 -1
- package/core/computed/metrics/time-to-first-byte.js +3 -1
- package/core/computed/metrics/timing-summary.d.ts +7 -5
- package/core/computed/metrics/timing-summary.js +3 -4
- package/core/computed/navigation-insights.d.ts +5 -3
- package/core/computed/navigation-insights.js +1 -1
- package/core/computed/network-analysis.js +1 -2
- package/core/computed/page-dependency-graph.d.ts +5 -3
- package/core/computed/page-dependency-graph.js +5 -2
- package/core/computed/trace-engine-result.d.ts +7 -5
- package/core/computed/trace-engine-result.js +9 -14
- package/core/computed/unused-css.d.ts +2 -2
- package/core/computed/unused-css.js +1 -1
- package/core/config/config.js +1 -2
- package/core/gather/base-artifacts.js +1 -2
- package/core/gather/driver/environment.js +1 -2
- package/core/gather/driver/navigation.js +1 -2
- package/core/gather/driver/network-monitor.js +1 -2
- package/core/gather/driver/prepare.js +1 -2
- package/core/gather/driver/storage.js +1 -2
- package/core/gather/driver/target-manager.js +1 -2
- package/core/gather/driver/wait-for-condition.js +1 -2
- package/core/gather/driver.js +1 -2
- package/core/gather/gatherers/agentic/ard.js +1 -1
- package/core/gather/gatherers/agentic/llms-txt.js +1 -2
- package/core/gather/gatherers/image-elements.js +1 -2
- package/core/gather/gatherers/seo/robots-txt.js +1 -2
- package/core/gather/gatherers/stacks.js +1 -2
- package/core/gather/gatherers/stylesheets.js +1 -2
- package/core/gather/navigation-runner.js +1 -1
- package/core/gather/runner-helpers.js +1 -2
- package/core/gather/session.js +1 -2
- package/core/gather/snapshot-runner.js +1 -2
- package/core/gather/timespan-runner.js +1 -2
- package/core/lib/asset-saver.js +1 -2
- package/core/lib/baseline/web-features-data.json +12 -3
- package/core/lib/baseline/web-features-metadata.json +1 -1
- package/core/lib/csp-evaluator.js +1 -1
- package/core/lib/deprecations-strings.d.ts +0 -2
- package/core/lib/deprecations-strings.js +1 -18
- package/core/lib/i18n/i18n.js +1 -2
- package/core/lib/lighthouse-logger.d.ts +127 -0
- package/core/lib/lighthouse-logger.js +319 -0
- package/core/lib/median-run.d.ts +16 -6
- package/core/lib/median-run.js +13 -6
- package/core/lib/network-recorder.js +1 -2
- package/core/lib/network-request.d.ts +2 -2
- package/core/lib/network-request.js +1 -1
- package/core/lib/page-functions.js +2 -2
- package/core/lib/script-helpers.d.ts +23 -8
- package/core/lib/script-helpers.js +7 -6
- package/core/lib/sentry-reporter.d.ts +59 -0
- package/core/lib/sentry-reporter.js +281 -0
- package/core/lib/sentry.d.ts +7 -7
- package/core/lib/sentry.js +23 -40
- package/core/lib/stack-packs.js +1 -1
- package/core/lib/timing-trace-saver.d.ts +2 -2
- package/core/lib/timing-trace-saver.js +1 -1
- package/core/lib/tracehouse/task-summary.d.ts +16 -4
- package/core/lib/tracehouse/task-summary.js +6 -5
- package/core/lib/tracehouse/trace-processor.d.ts +6 -6
- package/core/lib/tracehouse/trace-processor.js +1 -1
- package/core/lib/traces/metric-trace-events.js +1 -2
- package/core/lib/url-utils.d.ts +4 -4
- package/core/lib/url-utils.js +1 -1
- package/core/runner.js +1 -2
- package/dist/report/bundle.esm.js +10 -10
- package/dist/report/flow.js +12 -12
- package/dist/report/standalone.js +11 -11
- package/package.json +19 -21
- package/report/renderer/text-encoding.d.ts +3 -5
- package/report/renderer/text-encoding.js +19 -33
- package/report/types/augment-dom.d.ts +0 -4
- package/shared/localization/locales/ar-XB.json +3 -0
- package/shared/localization/locales/ar.json +3 -0
- package/shared/localization/locales/bg.json +3 -0
- package/shared/localization/locales/ca.json +75 -72
- package/shared/localization/locales/cs.json +3 -0
- package/shared/localization/locales/da.json +3 -0
- package/shared/localization/locales/de.json +3 -0
- package/shared/localization/locales/el.json +3 -0
- package/shared/localization/locales/en-GB.json +3 -0
- package/shared/localization/locales/es-419.json +3 -0
- package/shared/localization/locales/es.json +3 -0
- package/shared/localization/locales/fi.json +3 -0
- package/shared/localization/locales/fil.json +3 -0
- package/shared/localization/locales/fr.json +3 -0
- package/shared/localization/locales/he.json +3 -0
- package/shared/localization/locales/hi.json +11 -8
- package/shared/localization/locales/hr.json +3 -0
- package/shared/localization/locales/hu.json +3 -0
- package/shared/localization/locales/id.json +3 -0
- package/shared/localization/locales/it.json +3 -0
- package/shared/localization/locales/ja.json +3 -0
- package/shared/localization/locales/ko.json +3 -0
- package/shared/localization/locales/lt.json +3 -0
- package/shared/localization/locales/lv.json +5 -2
- package/shared/localization/locales/nl.json +3 -0
- package/shared/localization/locales/no.json +3 -0
- package/shared/localization/locales/pl.json +3 -0
- package/shared/localization/locales/pt-PT.json +3 -0
- package/shared/localization/locales/pt.json +32 -29
- package/shared/localization/locales/ro.json +3 -0
- package/shared/localization/locales/ru.json +3 -0
- package/shared/localization/locales/sk.json +3 -0
- package/shared/localization/locales/sl.json +3 -0
- package/shared/localization/locales/sr-Latn.json +3 -0
- package/shared/localization/locales/sr.json +3 -0
- package/shared/localization/locales/sv.json +3 -0
- package/shared/localization/locales/ta.json +3 -0
- package/shared/localization/locales/te.json +3 -0
- package/shared/localization/locales/th.json +3 -0
- package/shared/localization/locales/tr.json +3 -0
- package/shared/localization/locales/uk.json +3 -0
- package/shared/localization/locales/vi.json +3 -0
- package/shared/localization/locales/zh-HK.json +3 -0
- package/shared/localization/locales/zh-TW.json +3 -0
- package/shared/localization/locales/zh.json +3 -0
- package/third-party/ard/README.md +1 -1
- package/third-party/ard/ard.js +1 -1
- package/tsconfig.json +2 -42
- package/types/artifacts.d.ts +7 -1
- package/types/internal/test.d.ts +5 -0
- package/report/types/buffer.d.ts +0 -19
|
@@ -79,7 +79,7 @@ For every hunk in the upstream `conformance-test` diff decide whether it touches
|
|
|
79
79
|
Rules to preserve:
|
|
80
80
|
- Treat non-object roots/entries as empty instead of throwing.
|
|
81
81
|
- Push `{element, message}` objects; never return formatted strings.
|
|
82
|
-
- Log through `lighthouse-logger`, not `console`.
|
|
82
|
+
- Log through `core/lib/lighthouse-logger.js`, not `console`.
|
|
83
83
|
- Only `ARD_VERSION`, `ConformanceTester` and `classify_media_type` are exported; add exports only if
|
|
84
84
|
tests need them.
|
|
85
85
|
|
package/cli/bin.js
CHANGED
|
@@ -21,8 +21,7 @@ import fs from 'fs';
|
|
|
21
21
|
import path from 'path';
|
|
22
22
|
import url from 'url';
|
|
23
23
|
|
|
24
|
-
import log from 'lighthouse-logger';
|
|
25
|
-
|
|
24
|
+
import log from '../core/lib/lighthouse-logger.js';
|
|
26
25
|
import * as commands from './commands/commands.js';
|
|
27
26
|
import * as Printer from './printer.js';
|
|
28
27
|
import {getFlags} from './cli-flags.js';
|
|
@@ -132,7 +131,13 @@ async function begin() {
|
|
|
132
131
|
});
|
|
133
132
|
}
|
|
134
133
|
|
|
135
|
-
|
|
134
|
+
try {
|
|
135
|
+
return await runLighthouse(urlsUnderTest, cliFlags, config);
|
|
136
|
+
} catch (err) {
|
|
137
|
+
// Report fatal CLI errors before Node exits (unhandled rejections are reported in run.js).
|
|
138
|
+
await Sentry.captureException(err, {level: 'fatal'});
|
|
139
|
+
throw err;
|
|
140
|
+
}
|
|
136
141
|
}
|
|
137
142
|
|
|
138
143
|
export {
|
package/cli/open-file.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import {spawn} from 'child_process';
|
|
12
12
|
import path from 'path';
|
|
13
13
|
|
|
14
|
-
import log from 'lighthouse-logger';
|
|
14
|
+
import log from '../core/lib/lighthouse-logger.js';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Opens a file with its default application, without waiting for it. Failures are logged, not
|
package/cli/printer.js
CHANGED
package/cli/run.d.ts
CHANGED
|
@@ -2,6 +2,13 @@ export type ExitError = Error & {
|
|
|
2
2
|
code: string;
|
|
3
3
|
friendlyMessage?: string;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* Logs a warning on Linux when `/dev/shm` is small (e.g. default 64MB in Docker/CI containers)
|
|
7
|
+
* and `--disable-dev-shm-usage` was not passed, as Chrome may crash or hang (`PROTOCOL_TIMEOUT`).
|
|
8
|
+
* @param {Array<string>} chromeFlags
|
|
9
|
+
* @param {NodeJS.Platform} [platform]
|
|
10
|
+
*/
|
|
11
|
+
export function checkDevShmUsage(chromeFlags: Array<string>, platform?: NodeJS.Platform): void;
|
|
5
12
|
/**
|
|
6
13
|
* exported for testing
|
|
7
14
|
* @param {string|Array<string>} flags
|
package/cli/run.js
CHANGED
|
@@ -12,19 +12,21 @@ import os from 'os';
|
|
|
12
12
|
|
|
13
13
|
import * as ChromeLauncher from 'chrome-launcher';
|
|
14
14
|
import yargsParser from 'yargs-parser';
|
|
15
|
-
import log from 'lighthouse-logger';
|
|
16
15
|
|
|
16
|
+
import log from '../core/lib/lighthouse-logger.js';
|
|
17
17
|
import * as Printer from './printer.js';
|
|
18
18
|
import {openFile} from './open-file.js';
|
|
19
19
|
import lighthouse from '../core/index.js';
|
|
20
20
|
import {getLhrFilenamePrefix} from '../report/generator/file-namer.js';
|
|
21
21
|
import * as assetSaver from '../core/lib/asset-saver.js';
|
|
22
22
|
import UrlUtils from '../core/lib/url-utils.js';
|
|
23
|
+
import {Sentry} from '../core/lib/sentry.js';
|
|
23
24
|
|
|
24
25
|
/** @typedef {Error & {code: string, friendlyMessage?: string}} ExitError */
|
|
25
26
|
|
|
26
27
|
const _RUNTIME_ERROR_CODE = 1;
|
|
27
28
|
const _PROTOCOL_TIMEOUT_EXIT_CODE = 67;
|
|
29
|
+
const _SHM_SIZE_THRESHOLD_BYTES = 64 * 1024 * 1024;
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* exported for testing
|
|
@@ -64,13 +66,39 @@ function parseChromeFlags(flags = '') {
|
|
|
64
66
|
});
|
|
65
67
|
}
|
|
66
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Logs a warning on Linux when `/dev/shm` is small (e.g. default 64MB in Docker/CI containers)
|
|
71
|
+
* and `--disable-dev-shm-usage` was not passed, as Chrome may crash or hang (`PROTOCOL_TIMEOUT`).
|
|
72
|
+
* @param {Array<string>} chromeFlags
|
|
73
|
+
* @param {NodeJS.Platform} [platform]
|
|
74
|
+
*/
|
|
75
|
+
function checkDevShmUsage(chromeFlags, platform = process.platform) {
|
|
76
|
+
if (platform !== 'linux') return;
|
|
77
|
+
if (chromeFlags.includes('--disable-dev-shm-usage')) return;
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
const {bsize, blocks} = fs.statfsSync('/dev/shm');
|
|
81
|
+
const totalBytes = bsize * blocks;
|
|
82
|
+
if (totalBytes > 0 && totalBytes <= _SHM_SIZE_THRESHOLD_BYTES) {
|
|
83
|
+
const sizeMb = Math.round(totalBytes / (1024 * 1024));
|
|
84
|
+
log.warn(
|
|
85
|
+
'CLI',
|
|
86
|
+
`Detected small /dev/shm (${sizeMb}MB). Pass --chrome-flags="--disable-dev-shm-usage" ` +
|
|
87
|
+
'or increase shared memory size to avoid Chrome crashes and PROTOCOL_TIMEOUT errors.'
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
} catch {
|
|
91
|
+
// Ignore if /dev/shm does not exist or cannot be inspected.
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
67
95
|
/**
|
|
68
96
|
* Attempts to connect to an instance of Chrome with an open remote-debugging
|
|
69
97
|
* port. If none is found, launches a debuggable instance.
|
|
70
98
|
* @param {LH.CliFlags} flags
|
|
71
99
|
* @return {Promise<ChromeLauncher.LaunchedChrome>}
|
|
72
100
|
*/
|
|
73
|
-
function getDebuggableChrome(flags) {
|
|
101
|
+
async function getDebuggableChrome(flags) {
|
|
74
102
|
if (process.platform === 'darwin' && process.arch === 'x64') {
|
|
75
103
|
const cpus = os.cpus();
|
|
76
104
|
if (cpus[0].model.includes('Apple')) {
|
|
@@ -83,12 +111,19 @@ function getDebuggableChrome(flags) {
|
|
|
83
111
|
}
|
|
84
112
|
}
|
|
85
113
|
|
|
86
|
-
|
|
114
|
+
const chromeFlags = parseChromeFlags(flags.chromeFlags);
|
|
115
|
+
const launchedChrome = await ChromeLauncher.launch({
|
|
87
116
|
port: flags.port,
|
|
88
117
|
ignoreDefaultFlags: flags.chromeIgnoreDefaultFlags,
|
|
89
|
-
chromeFlags
|
|
118
|
+
chromeFlags,
|
|
90
119
|
logLevel: flags.logLevel,
|
|
91
120
|
});
|
|
121
|
+
|
|
122
|
+
if (launchedChrome.pid) {
|
|
123
|
+
checkDevShmUsage(chromeFlags);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return launchedChrome;
|
|
92
127
|
}
|
|
93
128
|
|
|
94
129
|
/** @return {never} */
|
|
@@ -196,9 +231,10 @@ async function saveResults(runnerResult, flags) {
|
|
|
196
231
|
*/
|
|
197
232
|
async function runLighthouse(urlOrUrls, flags, config) {
|
|
198
233
|
/** @param {any} reason */
|
|
199
|
-
function handleTheUnhandled(reason) {
|
|
234
|
+
async function handleTheUnhandled(reason) {
|
|
200
235
|
process.stderr.write(`Unhandled Rejection. Reason: ${reason}\n`);
|
|
201
236
|
launchedChrome?.kill();
|
|
237
|
+
await Sentry.captureException(reason, {level: 'fatal'});
|
|
202
238
|
process.exit(1);
|
|
203
239
|
}
|
|
204
240
|
process.on('unhandledRejection', handleTheUnhandled);
|
|
@@ -288,6 +324,7 @@ async function runLighthouse(urlOrUrls, flags, config) {
|
|
|
288
324
|
}
|
|
289
325
|
|
|
290
326
|
export {
|
|
327
|
+
checkDevShmUsage,
|
|
291
328
|
parseChromeFlags,
|
|
292
329
|
saveResults,
|
|
293
330
|
runLighthouse,
|
package/cli/sentry-prompt.js
CHANGED
|
@@ -16,8 +16,8 @@ import url from 'url';
|
|
|
16
16
|
|
|
17
17
|
import yargs from 'yargs';
|
|
18
18
|
import * as yargsHelpers from 'yargs/helpers';
|
|
19
|
-
import log from 'lighthouse-logger';
|
|
20
19
|
|
|
20
|
+
import log from '../../../../core/lib/lighthouse-logger.js';
|
|
21
21
|
import {runSmokehouse, getShardedDefinitions, DEFAULT_RETRIES, DEFAULT_CONCURRENT_RUNS} from '../smokehouse.js';
|
|
22
22
|
import {updateTestDefnFormat} from './back-compat-util.js';
|
|
23
23
|
import {LH_ROOT} from '../../../../shared/root.js';
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
import {promises as fs} from 'fs';
|
|
15
15
|
import {spawn} from 'child_process';
|
|
16
16
|
|
|
17
|
-
import log from 'lighthouse-logger';
|
|
18
|
-
|
|
17
|
+
import log from '../../../../core/lib/lighthouse-logger.js';
|
|
19
18
|
import * as assetSaver from '../../../../core/lib/asset-saver.js';
|
|
20
19
|
import {LocalConsole} from '../lib/local-console.js';
|
|
21
20
|
import {ChildProcessError} from '../lib/child-process-error.js';
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
* against the results actually collected from Lighthouse.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import log from 'lighthouse-logger';
|
|
13
|
-
|
|
12
|
+
import log from '../../../core/lib/lighthouse-logger.js';
|
|
14
13
|
import {LocalConsole} from './lib/local-console.js';
|
|
15
14
|
import {chromiumVersionCheck} from './version-check.js';
|
|
16
15
|
|
|
@@ -29,8 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
import assert from 'assert/strict';
|
|
31
31
|
|
|
32
|
-
import log from 'lighthouse-logger';
|
|
33
|
-
|
|
32
|
+
import log from '../../../core/lib/lighthouse-logger.js';
|
|
34
33
|
import {runLighthouse as cliLighthouseRunner} from './lighthouse-runners/cli.js';
|
|
35
34
|
import {getAssertionReport} from './report-assert.js';
|
|
36
35
|
import {LocalConsole} from './lib/local-console.js';
|
|
@@ -696,6 +696,7 @@ declare class Baseline extends Audit {
|
|
|
696
696
|
"document-caretpositionfrompoint": string;
|
|
697
697
|
"event-timing": string;
|
|
698
698
|
"ext-texture-compression-rgtc": string;
|
|
699
|
+
"ext-texture-norm16": string;
|
|
699
700
|
"fetch-priority": string;
|
|
700
701
|
"field-sizing": string;
|
|
701
702
|
float16array: string;
|
|
@@ -748,7 +749,9 @@ declare class Baseline extends Audit {
|
|
|
748
749
|
"ruby-align": string;
|
|
749
750
|
"ruby-position": string;
|
|
750
751
|
scope: string;
|
|
752
|
+
"scoped-custom-element-registries": string;
|
|
751
753
|
"screen-wake-lock": string;
|
|
754
|
+
"scroll-driven-animations": string;
|
|
752
755
|
"scroll-to-text-fragment": string;
|
|
753
756
|
"scrollbar-color": string;
|
|
754
757
|
"scrollbar-gutter": string;
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import log from 'lighthouse-logger';
|
|
8
|
-
|
|
7
|
+
import log from '../lib/lighthouse-logger.js';
|
|
9
8
|
import {Audit} from './audit.js';
|
|
10
9
|
import {taskGroups} from '../lib/tracehouse/task-groups.js';
|
|
11
10
|
import * as i18n from '../lib/i18n/i18n.js';
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
* This is done by collecting Chrome console log messages and filtering out the non-error ones.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import log from 'lighthouse-logger';
|
|
13
|
-
|
|
12
|
+
import log from '../lib/lighthouse-logger.js';
|
|
14
13
|
import {Audit} from './audit.js';
|
|
15
14
|
import {JSBundles} from '../computed/js-bundles.js';
|
|
16
15
|
import * as i18n from '../lib/i18n/i18n.js';
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
* @fileoverview Audit a page to show a breakdown of execution timings on the main thread
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import log from 'lighthouse-logger';
|
|
12
|
-
|
|
11
|
+
import log from '../lib/lighthouse-logger.js';
|
|
13
12
|
import {Audit} from './audit.js';
|
|
14
13
|
import {taskGroups} from '../lib/tracehouse/task-groups.js';
|
|
15
14
|
import * as i18n from '../lib/i18n/i18n.js';
|
package/core/audits/metrics.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export default Metrics;
|
|
2
2
|
declare class Metrics extends Audit {
|
|
3
3
|
/**
|
|
4
|
-
* @param {LH.Artifacts} artifacts
|
|
4
|
+
* @param {Pick<LH.Artifacts, 'GatherContext'|'Trace'|'DevtoolsLog'|'URL'|'SourceMaps'|'HostDPR'>} artifacts
|
|
5
5
|
* @param {LH.Audit.Context} context
|
|
6
6
|
* @return {Promise<LH.Audit.Product>}
|
|
7
7
|
*/
|
|
8
|
-
static audit(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<LH.Audit.Product>;
|
|
8
|
+
static audit(artifacts: Pick<LH.Artifacts, "GatherContext" | "Trace" | "DevtoolsLog" | "URL" | "SourceMaps" | "HostDPR">, context: LH.Audit.Context): Promise<LH.Audit.Product>;
|
|
9
9
|
}
|
|
10
10
|
import { Audit } from './audit.js';
|
|
11
11
|
//# sourceMappingURL=metrics.d.ts.map
|
package/core/audits/metrics.js
CHANGED
|
@@ -31,7 +31,7 @@ class Metrics extends Audit {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* @param {LH.Artifacts} artifacts
|
|
34
|
+
* @param {Pick<LH.Artifacts, 'GatherContext'|'Trace'|'DevtoolsLog'|'URL'|'SourceMaps'|'HostDPR'>} artifacts
|
|
35
35
|
* @param {LH.Audit.Context} context
|
|
36
36
|
* @return {Promise<LH.Audit.Product>}
|
|
37
37
|
*/
|
|
@@ -2,7 +2,7 @@ export { EntityClassificationComputed as EntityClassification };
|
|
|
2
2
|
export type EntityCache = Map<string, LH.Artifacts.Entity>;
|
|
3
3
|
declare const EntityClassificationComputed: typeof EntityClassification & {
|
|
4
4
|
request: (dependencies: {
|
|
5
|
-
URL: LH.Artifacts["URL"]
|
|
5
|
+
URL: Partial<LH.Artifacts["URL"]>;
|
|
6
6
|
devtoolsLog: LH.DevtoolsLog;
|
|
7
7
|
}, context: LH.Artifacts.ComputedContext) => Promise<import("../index.js").Artifacts.EntityClassification>;
|
|
8
8
|
};
|
|
@@ -28,12 +28,12 @@ declare class EntityClassification {
|
|
|
28
28
|
*/
|
|
29
29
|
static _preloadChromeExtensionsToCache(entityCache: EntityCache, devtoolsLog: LH.DevtoolsLog): void;
|
|
30
30
|
/**
|
|
31
|
-
* @param {{URL: LH.Artifacts['URL']
|
|
31
|
+
* @param {{URL: Partial<LH.Artifacts['URL']>, devtoolsLog: LH.DevtoolsLog}} data
|
|
32
32
|
* @param {LH.Artifacts.ComputedContext} context
|
|
33
33
|
* @return {Promise<LH.Artifacts.EntityClassification>}
|
|
34
34
|
*/
|
|
35
35
|
static compute_(data: {
|
|
36
|
-
URL: LH.Artifacts["URL"]
|
|
36
|
+
URL: Partial<LH.Artifacts["URL"]>;
|
|
37
37
|
devtoolsLog: LH.DevtoolsLog;
|
|
38
38
|
}, context: LH.Artifacts.ComputedContext): Promise<LH.Artifacts.EntityClassification>;
|
|
39
39
|
}
|
|
@@ -97,7 +97,7 @@ class EntityClassification {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
|
-
* @param {{URL: LH.Artifacts['URL']
|
|
100
|
+
* @param {{URL: Partial<LH.Artifacts['URL']>, devtoolsLog: LH.DevtoolsLog}} data
|
|
101
101
|
* @param {LH.Artifacts.ComputedContext} context
|
|
102
102
|
* @return {Promise<LH.Artifacts.EntityClassification>}
|
|
103
103
|
*/
|
|
@@ -130,8 +130,10 @@ class EntityClassification {
|
|
|
130
130
|
// `mainDocumentUrl` (for navigations), and falls back to `finalDisplayedUrl` (for timespan/snapshot).
|
|
131
131
|
// See https://github.com/GoogleChrome/lighthouse/issues/13706
|
|
132
132
|
const firstPartyUrl = data.URL.mainDocumentUrl || data.URL.finalDisplayedUrl;
|
|
133
|
-
const firstParty =
|
|
134
|
-
|
|
133
|
+
const firstParty = firstPartyUrl ?
|
|
134
|
+
(thirdPartyWeb.getEntity(firstPartyUrl) ||
|
|
135
|
+
EntityClassification._makeUpAnEntity(madeUpEntityCache, firstPartyUrl)) :
|
|
136
|
+
undefined;
|
|
135
137
|
|
|
136
138
|
/**
|
|
137
139
|
* Convenience function to check if a URL belongs to first party.
|
|
@@ -42,7 +42,7 @@ class LCPNetworkRecord {
|
|
|
42
42
|
}).sort((a, b) => b.ts - a.ts)[0];
|
|
43
43
|
|
|
44
44
|
const lcpUrl = lcpImagePaintEvent?.args.data?.imageUrl;
|
|
45
|
-
if (!lcpUrl) return;
|
|
45
|
+
if (!lcpUrl || lcpUrl.startsWith('data:')) return;
|
|
46
46
|
|
|
47
47
|
const candidates = networkRecords.filter(record => {
|
|
48
48
|
return record.url === lcpUrl &&
|
|
@@ -2,18 +2,20 @@ export { LoadSimulatorComputed as LoadSimulator };
|
|
|
2
2
|
declare const LoadSimulatorComputed: typeof LoadSimulator & {
|
|
3
3
|
request: (dependencies: {
|
|
4
4
|
devtoolsLog: LH.DevtoolsLog;
|
|
5
|
-
settings:
|
|
5
|
+
settings: import("../index.js").Util.ImmutableObject<Pick<import("../../types/lhr/settings.js").ConfigSettings, "throttlingMethod"> & Partial<Omit<import("../../types/lhr/settings.js").ConfigSettings, "throttling">> & {
|
|
6
|
+
throttling?: Partial<import("../index.js").Config.Settings["throttling"]>;
|
|
7
|
+
}>;
|
|
6
8
|
}, context: LH.Artifacts.ComputedContext) => Promise<import("../../types.js").Gatherer.Simulation.Simulator>;
|
|
7
9
|
};
|
|
8
10
|
declare class LoadSimulator {
|
|
9
11
|
/**
|
|
10
|
-
* @param {{devtoolsLog: LH.DevtoolsLog, settings: LH.
|
|
12
|
+
* @param {{devtoolsLog: LH.DevtoolsLog, settings: LH.Artifacts.ComputedSettings}} data
|
|
11
13
|
* @param {LH.Artifacts.ComputedContext} context
|
|
12
14
|
* @return {Promise<LH.Gatherer.Simulation.Simulator>}
|
|
13
15
|
*/
|
|
14
16
|
static compute_(data: {
|
|
15
17
|
devtoolsLog: LH.DevtoolsLog;
|
|
16
|
-
settings: LH.
|
|
18
|
+
settings: LH.Artifacts.ComputedSettings;
|
|
17
19
|
}, context: LH.Artifacts.ComputedContext): Promise<LH.Gatherer.Simulation.Simulator>;
|
|
18
20
|
/**
|
|
19
21
|
* @param {LH.Artifacts.NetworkAnalysis} networkAnalysis
|
|
@@ -10,13 +10,20 @@ import {NetworkAnalysis} from './network-analysis.js';
|
|
|
10
10
|
|
|
11
11
|
class LoadSimulator {
|
|
12
12
|
/**
|
|
13
|
-
* @param {{devtoolsLog: LH.DevtoolsLog, settings: LH.
|
|
13
|
+
* @param {{devtoolsLog: LH.DevtoolsLog, settings: LH.Artifacts.ComputedSettings}} data
|
|
14
14
|
* @param {LH.Artifacts.ComputedContext} context
|
|
15
15
|
* @return {Promise<LH.Gatherer.Simulation.Simulator>}
|
|
16
16
|
*/
|
|
17
17
|
static async compute_(data, context) {
|
|
18
18
|
const networkAnalysis = await NetworkAnalysis.request(data.devtoolsLog, context);
|
|
19
|
-
|
|
19
|
+
const throttling = data.settings.throttling ?
|
|
20
|
+
{...Lantern.Simulation.Constants.throttling.mobileSlow4G, ...data.settings.throttling} :
|
|
21
|
+
undefined;
|
|
22
|
+
return Lantern.Simulation.Simulator.createSimulator({
|
|
23
|
+
...data.settings,
|
|
24
|
+
throttling,
|
|
25
|
+
networkAnalysis,
|
|
26
|
+
});
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
/**
|
|
@@ -11,6 +11,25 @@ declare const LCPBreakdownComputed: typeof LCPBreakdown & {
|
|
|
11
11
|
* Note: this omits renderDelay for simulated throttling.
|
|
12
12
|
*/
|
|
13
13
|
declare class LCPBreakdown {
|
|
14
|
+
/**
|
|
15
|
+
* @param {Map<LH.Gatherer.Simulation.GraphNode, LH.Gatherer.Simulation.NodeTiming>} nodeTimings
|
|
16
|
+
* @param {LH.Artifacts.NetworkRequest} lcpRecord
|
|
17
|
+
* @return {LH.Gatherer.Simulation.NodeTiming|undefined}
|
|
18
|
+
*/
|
|
19
|
+
static findLcpNodeTiming(nodeTimings: Map<LH.Gatherer.Simulation.GraphNode, LH.Gatherer.Simulation.NodeTiming>, lcpRecord: LH.Artifacts.NetworkRequest): LH.Gatherer.Simulation.NodeTiming | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Returns simulated [loadStart, loadEnd] for `lcpRecord` from Lantern's nodeTimings,
|
|
22
|
+
* or undefined if the record is non-network or absent from both graphs.
|
|
23
|
+
* Uses `queuedTime` (when Chrome enqueues the request) rather than `startTime`
|
|
24
|
+
* (when a connection slot opens), matching how observed LCPBreakdown defines loadDelay.
|
|
25
|
+
* @param {LH.Artifacts.LanternMetric} lanternLcp
|
|
26
|
+
* @param {LH.Artifacts.NetworkRequest} lcpRecord
|
|
27
|
+
* @return {{loadStart: number, loadEnd: number}|undefined}
|
|
28
|
+
*/
|
|
29
|
+
static getSimulatedLcpLoadBounds(lanternLcp: LH.Artifacts.LanternMetric, lcpRecord: LH.Artifacts.NetworkRequest): {
|
|
30
|
+
loadStart: number;
|
|
31
|
+
loadEnd: number;
|
|
32
|
+
} | undefined;
|
|
14
33
|
/**
|
|
15
34
|
* @param {LH.Artifacts.MetricComputationDataInput} data
|
|
16
35
|
* @param {LH.Artifacts.ComputedContext} context
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import * as Lantern from '../../lib/lantern/lantern.js';
|
|
8
|
+
import {NetworkRequest} from '../../lib/network-request.js';
|
|
7
9
|
import {makeComputedArtifact} from '../computed-artifact.js';
|
|
8
10
|
import {LighthouseError} from '../../lib/lh-error.js';
|
|
9
|
-
import {
|
|
11
|
+
import {LanternLargestContentfulPaint} from './lantern-largest-contentful-paint.js';
|
|
10
12
|
import {ProcessedNavigation} from '../processed-navigation.js';
|
|
11
13
|
import {TimeToFirstByte} from './time-to-first-byte.js';
|
|
12
14
|
import {LCPNetworkRecord} from '../lcp-network-record.js';
|
|
@@ -16,6 +18,59 @@ import {NavigationInsights} from '../navigation-insights.js';
|
|
|
16
18
|
* Note: this omits renderDelay for simulated throttling.
|
|
17
19
|
*/
|
|
18
20
|
class LCPBreakdown {
|
|
21
|
+
/**
|
|
22
|
+
* @param {Map<LH.Gatherer.Simulation.GraphNode, LH.Gatherer.Simulation.NodeTiming>} nodeTimings
|
|
23
|
+
* @param {LH.Artifacts.NetworkRequest} lcpRecord
|
|
24
|
+
* @return {LH.Gatherer.Simulation.NodeTiming|undefined}
|
|
25
|
+
*/
|
|
26
|
+
static findLcpNodeTiming(nodeTimings, lcpRecord) {
|
|
27
|
+
for (const [node, timing] of nodeTimings) {
|
|
28
|
+
if (node.type === 'network' && node.id === lcpRecord.requestId) {
|
|
29
|
+
return timing;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns simulated [loadStart, loadEnd] for `lcpRecord` from Lantern's nodeTimings,
|
|
37
|
+
* or undefined if the record is non-network or absent from both graphs.
|
|
38
|
+
* Uses `queuedTime` (when Chrome enqueues the request) rather than `startTime`
|
|
39
|
+
* (when a connection slot opens), matching how observed LCPBreakdown defines loadDelay.
|
|
40
|
+
* @param {LH.Artifacts.LanternMetric} lanternLcp
|
|
41
|
+
* @param {LH.Artifacts.NetworkRequest} lcpRecord
|
|
42
|
+
* @return {{loadStart: number, loadEnd: number}|undefined}
|
|
43
|
+
*/
|
|
44
|
+
static getSimulatedLcpLoadBounds(lanternLcp, lcpRecord) {
|
|
45
|
+
if (NetworkRequest.isNonNetworkRequest(lcpRecord)) return undefined;
|
|
46
|
+
|
|
47
|
+
const optimisticTiming =
|
|
48
|
+
this.findLcpNodeTiming(lanternLcp.optimisticEstimate.nodeTimings, lcpRecord);
|
|
49
|
+
const pessimisticTiming =
|
|
50
|
+
this.findLcpNodeTiming(lanternLcp.pessimisticEstimate.nodeTimings, lcpRecord);
|
|
51
|
+
|
|
52
|
+
if (optimisticTiming && pessimisticTiming) {
|
|
53
|
+
const {optimistic, pessimistic} = Lantern.Metrics.LargestContentfulPaint.coefficients;
|
|
54
|
+
const weightSum = optimistic + pessimistic;
|
|
55
|
+
/** @param {number} o @param {number} p */
|
|
56
|
+
const blend = (o, p) => (optimistic * o + pessimistic * p) / weightSum;
|
|
57
|
+
return {
|
|
58
|
+
loadStart: blend(optimisticTiming.queuedTime, pessimisticTiming.queuedTime),
|
|
59
|
+
loadEnd: blend(optimisticTiming.endTime, pessimisticTiming.endTime),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const singleTiming = optimisticTiming || pessimisticTiming;
|
|
64
|
+
if (singleTiming) {
|
|
65
|
+
return {
|
|
66
|
+
loadStart: singleTiming.queuedTime,
|
|
67
|
+
loadEnd: singleTiming.endTime,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
19
74
|
/**
|
|
20
75
|
* @param {LH.Artifacts.MetricComputationDataInput} data
|
|
21
76
|
* @param {LH.Artifacts.ComputedContext} context
|
|
@@ -28,7 +83,6 @@ class LCPBreakdown {
|
|
|
28
83
|
if (observedLcp === undefined) {
|
|
29
84
|
throw new LighthouseError(LighthouseError.errors.NO_LCP);
|
|
30
85
|
}
|
|
31
|
-
const timeOrigin = processedNavigation.timestamps.timeOrigin / 1000;
|
|
32
86
|
|
|
33
87
|
const {timing: ttfb} = await TimeToFirstByte.request(data, context);
|
|
34
88
|
|
|
@@ -37,14 +91,23 @@ class LCPBreakdown {
|
|
|
37
91
|
return {ttfb};
|
|
38
92
|
}
|
|
39
93
|
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
const throttleRatio = metricLcp / observedLcp;
|
|
94
|
+
const lanternLcp = await LanternLargestContentfulPaint.request(data, context);
|
|
95
|
+
const metricLcp = lanternLcp.timing;
|
|
43
96
|
|
|
44
|
-
|
|
45
|
-
|
|
97
|
+
let {loadStart: unclampedLoadStart, loadEnd: unclampedLoadEnd} =
|
|
98
|
+
this.getSimulatedLcpLoadBounds(lanternLcp, lcpRecord) || {};
|
|
46
99
|
|
|
47
|
-
|
|
100
|
+
if (unclampedLoadStart === undefined || unclampedLoadEnd === undefined) {
|
|
101
|
+
const timeOrigin = processedNavigation.timestamps.timeOrigin / 1000;
|
|
102
|
+
const throttleRatio = metricLcp / observedLcp;
|
|
103
|
+
unclampedLoadStart = (lcpRecord.networkRequestTime - timeOrigin) * throttleRatio;
|
|
104
|
+
unclampedLoadEnd = (lcpRecord.networkEndTime - timeOrigin) * throttleRatio;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Clamp to [ttfb, metricLcp]. `unclampedLoadStart` can be below `ttfb` when
|
|
108
|
+
// observed TTFB exceeds Lantern's simulated main-document finish time (yielding loadDelay=0),
|
|
109
|
+
// and `unclampedLoadEnd` can exceed `metricLcp` for low-priority LCP images.
|
|
110
|
+
const loadStart = Math.max(ttfb, Math.min(unclampedLoadStart, metricLcp));
|
|
48
111
|
const loadEnd = Math.max(loadStart, Math.min(unclampedLoadEnd, metricLcp));
|
|
49
112
|
|
|
50
113
|
return {
|
|
@@ -41,7 +41,9 @@ export type EventTimingEvent = LH.Trace.AsyncEvent & {
|
|
|
41
41
|
declare const ResponsivenessComputed: typeof Responsiveness & {
|
|
42
42
|
request: (dependencies: {
|
|
43
43
|
trace: LH.Trace;
|
|
44
|
-
settings:
|
|
44
|
+
settings: import("../../index.js").Util.ImmutableObject<Pick<import("../../../types/lhr/settings.js").ConfigSettings, "throttlingMethod"> & Partial<Omit<import("../../../types/lhr/settings.js").ConfigSettings, "throttling">> & {
|
|
45
|
+
throttling?: Partial<import("../../index.js").Config.Settings["throttling"]>;
|
|
46
|
+
}>;
|
|
45
47
|
}, context: LH.Artifacts.ComputedContext) => Promise<EventTimingEvent | null>;
|
|
46
48
|
};
|
|
47
49
|
declare class Responsiveness {
|
|
@@ -64,13 +66,13 @@ declare class Responsiveness {
|
|
|
64
66
|
*/
|
|
65
67
|
static findInteractionEvent(responsivenessEvent: ResponsivenessEvent, { traceEvents }: LH.Trace): EventTimingEvent;
|
|
66
68
|
/**
|
|
67
|
-
* @param {{trace: LH.Trace, settings: LH.
|
|
69
|
+
* @param {{trace: LH.Trace, settings: LH.Artifacts.ComputedSettings}} data
|
|
68
70
|
* @param {LH.Artifacts.ComputedContext} context
|
|
69
71
|
* @return {Promise<EventTimingEvent|null>}
|
|
70
72
|
*/
|
|
71
73
|
static compute_(data: {
|
|
72
74
|
trace: LH.Trace;
|
|
73
|
-
settings: LH.
|
|
75
|
+
settings: LH.Artifacts.ComputedSettings;
|
|
74
76
|
}, context: LH.Artifacts.ComputedContext): Promise<EventTimingEvent | null>;
|
|
75
77
|
}
|
|
76
78
|
//# sourceMappingURL=responsiveness.d.ts.map
|
|
@@ -130,7 +130,7 @@ class Responsiveness {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
|
-
* @param {{trace: LH.Trace, settings: LH.
|
|
133
|
+
* @param {{trace: LH.Trace, settings: LH.Artifacts.ComputedSettings}} data
|
|
134
134
|
* @param {LH.Artifacts.ComputedContext} context
|
|
135
135
|
* @return {Promise<EventTimingEvent|null>}
|
|
136
136
|
*/
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import {calculateDocFirstByteTs} from '@paulirish/trace_engine/models/trace/insights/Common.js';
|
|
8
8
|
|
|
9
9
|
import {Helpers} from '../../lib/trace-engine.js';
|
|
10
|
+
import {throttling} from '../../config/constants.js';
|
|
10
11
|
import {makeComputedArtifact} from '../computed-artifact.js';
|
|
11
12
|
import {NavigationMetric} from './navigation-metric.js';
|
|
12
13
|
import {MainResource} from '../main-resource.js';
|
|
@@ -34,7 +35,8 @@ class TimeToFirstByte extends NavigationMetric {
|
|
|
34
35
|
let roundTrips = 2;
|
|
35
36
|
if (!mainResource.protocol.startsWith('h3')) roundTrips += 1; // TCP
|
|
36
37
|
if (mainResource.parsedURL.scheme === 'https') roundTrips += 1;
|
|
37
|
-
const
|
|
38
|
+
const rttMs = data.settings.throttling?.rttMs ?? throttling.mobileSlow4G.rttMs;
|
|
39
|
+
const estimatedTTFB = rttMs * roundTrips + observedResponseTime;
|
|
38
40
|
|
|
39
41
|
const timing = Math.max(observedTTFB, estimatedTTFB);
|
|
40
42
|
return {timing};
|