lighthouse 11.7.0 → 12.0.0-dev.20240422
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/CONTRIBUTING.md +2 -2
- package/cli/bin.js +0 -7
- package/cli/cli-flags.d.ts +1 -5
- package/cli/cli-flags.js +4 -8
- package/cli/test/smokehouse/__snapshots__/report-assert-test.js.snap +14 -14
- package/cli/test/smokehouse/config/exclusions.js +3 -0
- package/cli/test/smokehouse/core-tests.js +6 -20
- package/cli/test/smokehouse/frontends/smokehouse-bin.js +2 -2
- package/core/audits/accessibility/accesskeys.js +1 -1
- package/core/audits/accessibility/aria-allowed-attr.js +1 -1
- package/core/audits/accessibility/aria-allowed-role.js +1 -1
- package/core/audits/accessibility/aria-command-name.js +1 -1
- package/core/audits/accessibility/aria-conditional-attr.d.ts +10 -0
- package/core/audits/accessibility/aria-conditional-attr.js +43 -0
- package/core/audits/accessibility/{duplicate-id-active.d.ts → aria-deprecated-role.d.ts} +3 -3
- package/core/audits/accessibility/aria-deprecated-role.js +43 -0
- package/core/audits/accessibility/aria-dialog-name.js +1 -1
- package/core/audits/accessibility/aria-hidden-body.js +1 -1
- package/core/audits/accessibility/aria-hidden-focus.js +1 -1
- package/core/audits/accessibility/aria-input-field-name.js +1 -1
- package/core/audits/accessibility/aria-meter-name.js +1 -1
- package/core/audits/accessibility/aria-progressbar-name.js +1 -1
- package/core/audits/accessibility/aria-prohibited-attr.d.ts +10 -0
- package/core/audits/accessibility/aria-prohibited-attr.js +44 -0
- package/core/audits/accessibility/aria-required-attr.js +1 -1
- package/core/audits/accessibility/aria-required-children.js +1 -1
- package/core/audits/accessibility/aria-required-parent.js +1 -1
- package/core/audits/accessibility/aria-roles.js +1 -1
- package/core/audits/accessibility/aria-text.js +1 -1
- package/core/audits/accessibility/aria-toggle-field-name.js +1 -1
- package/core/audits/accessibility/aria-tooltip-name.js +1 -1
- package/core/audits/accessibility/aria-treeitem-name.js +1 -1
- package/core/audits/accessibility/aria-valid-attr-value.js +1 -1
- package/core/audits/accessibility/aria-valid-attr.js +1 -1
- package/core/audits/accessibility/button-name.js +1 -1
- package/core/audits/accessibility/bypass.js +1 -1
- package/core/audits/accessibility/color-contrast.js +1 -1
- package/core/audits/accessibility/definition-list.js +1 -1
- package/core/audits/accessibility/dlitem.js +1 -1
- package/core/audits/accessibility/document-title.js +1 -1
- package/core/audits/accessibility/duplicate-id-aria.js +1 -1
- package/core/audits/accessibility/empty-heading.js +1 -1
- package/core/audits/accessibility/form-field-multiple-labels.js +1 -1
- package/core/audits/accessibility/frame-title.js +1 -1
- package/core/audits/accessibility/heading-order.js +1 -1
- package/core/audits/accessibility/html-has-lang.js +1 -1
- package/core/audits/accessibility/html-lang-valid.js +1 -1
- package/core/audits/accessibility/html-xml-lang-mismatch.js +1 -1
- package/core/audits/accessibility/identical-links-same-purpose.js +1 -1
- package/core/audits/accessibility/image-alt.js +1 -1
- package/core/audits/accessibility/image-redundant-alt.js +1 -1
- package/core/audits/accessibility/input-button-name.js +1 -1
- package/core/audits/accessibility/input-image-alt.js +1 -1
- package/core/audits/accessibility/label-content-name-mismatch.js +1 -1
- package/core/audits/accessibility/label.js +1 -1
- package/core/audits/accessibility/landmark-one-main.js +1 -1
- package/core/audits/accessibility/link-in-text-block.js +1 -1
- package/core/audits/accessibility/link-name.js +1 -1
- package/core/audits/accessibility/list.js +1 -1
- package/core/audits/accessibility/listitem.js +1 -1
- package/core/audits/accessibility/meta-refresh.js +1 -1
- package/core/audits/accessibility/meta-viewport.js +1 -1
- package/core/audits/accessibility/object-alt.js +1 -1
- package/core/audits/accessibility/select-name.js +1 -1
- package/core/audits/accessibility/skip-link.js +1 -1
- package/core/audits/accessibility/tabindex.js +1 -1
- package/core/audits/accessibility/table-duplicate-name.js +1 -1
- package/core/audits/accessibility/table-fake-caption.js +1 -1
- package/core/audits/accessibility/target-size.js +1 -2
- package/core/audits/accessibility/td-has-header.js +1 -1
- package/core/audits/accessibility/td-headers-attr.js +1 -1
- package/core/audits/accessibility/th-has-data-cells.js +1 -1
- package/core/audits/accessibility/valid-lang.js +1 -1
- package/core/audits/accessibility/video-caption.js +1 -1
- package/core/audits/byte-efficiency/byte-efficiency-audit.d.ts +0 -16
- package/core/audits/byte-efficiency/byte-efficiency-audit.js +1 -38
- package/core/audits/byte-efficiency/offscreen-images.d.ts +0 -11
- package/core/audits/byte-efficiency/offscreen-images.js +0 -15
- package/core/audits/byte-efficiency/render-blocking-resources.js +27 -26
- package/core/audits/byte-efficiency/unminified-css.js +2 -2
- package/core/audits/byte-efficiency/unused-css-rules.js +3 -1
- package/core/audits/dobetterweb/uses-http2.d.ts +0 -13
- package/core/audits/dobetterweb/uses-http2.js +4 -38
- package/core/audits/font-display.js +2 -2
- package/core/audits/layout-shifts.js +2 -2
- package/core/audits/preload-fonts.d.ts +1 -5
- package/core/audits/preload-fonts.js +1 -10
- package/core/audits/prioritize-lcp-image.js +2 -2
- package/core/audits/redirects-http.d.ts +19 -0
- package/core/audits/redirects-http.js +75 -0
- package/core/audits/resource-summary.d.ts +2 -0
- package/core/audits/resource-summary.js +5 -4
- package/core/audits/seo/is-crawlable.d.ts +2 -1
- package/core/audits/seo/link-text.js +12 -0
- package/core/audits/uses-rel-preload.d.ts +1 -5
- package/core/audits/uses-rel-preload.js +5 -15
- package/core/audits/work-during-interaction.d.ts +2 -2
- package/core/audits/work-during-interaction.js +2 -2
- package/core/computed/js-bundles.d.ts +1 -1
- package/core/computed/metrics/cumulative-layout-shift.js +2 -2
- package/core/computed/metrics/lantern-first-contentful-paint.d.ts +13 -82
- package/core/computed/metrics/lantern-first-contentful-paint.js +16 -178
- package/core/computed/metrics/lantern-first-meaningful-paint.d.ts +13 -12
- package/core/computed/metrics/lantern-first-meaningful-paint.js +11 -49
- package/core/computed/metrics/lantern-interactive.d.ts +13 -21
- package/core/computed/metrics/lantern-interactive.js +12 -84
- package/core/computed/metrics/lantern-largest-contentful-paint.d.ts +13 -25
- package/core/computed/metrics/lantern-largest-contentful-paint.js +13 -80
- package/core/computed/metrics/lantern-max-potential-fid.d.ts +13 -24
- package/core/computed/metrics/lantern-max-potential-fid.js +12 -64
- package/core/computed/metrics/lantern-metric.d.ts +14 -18
- package/core/computed/metrics/lantern-metric.js +34 -30
- package/core/computed/metrics/lantern-speed-index.d.ts +13 -32
- package/core/computed/metrics/lantern-speed-index.js +13 -116
- package/core/computed/metrics/lantern-total-blocking-time.d.ts +13 -25
- package/core/computed/metrics/lantern-total-blocking-time.js +10 -94
- package/core/computed/metrics/metric.js +1 -3
- package/core/computed/module-duplication.d.ts +1 -1
- package/core/computed/navigation-insights.d.ts +36 -0
- package/core/computed/navigation-insights.js +35 -0
- package/core/computed/page-dependency-graph.js +3 -7
- package/core/computed/resource-summary.d.ts +10 -12
- package/core/computed/resource-summary.js +12 -19
- package/core/computed/trace-engine-result.d.ts +16 -3
- package/core/computed/trace-engine-result.js +19 -14
- package/core/computed/unused-css.d.ts +3 -1
- package/core/computed/unused-css.js +6 -5
- package/core/config/config-helpers.js +0 -4
- package/core/config/constants.js +0 -1
- package/core/config/default-config.js +63 -142
- package/core/config/experimental-config.js +11 -0
- package/core/config/filters.js +0 -1
- package/core/gather/driver/navigation.js +4 -1
- package/core/gather/driver/prepare.js +1 -1
- package/core/gather/driver/target-manager.js +4 -3
- package/core/gather/driver/wait-for-condition.js +2 -3
- package/core/gather/driver.d.ts +12 -0
- package/core/gather/driver.js +27 -0
- package/core/gather/gatherers/accessibility.js +4 -6
- package/core/gather/gatherers/css-usage.d.ts +0 -21
- package/core/gather/gatherers/css-usage.js +9 -119
- package/core/gather/gatherers/root-causes.d.ts +2 -2
- package/core/gather/gatherers/root-causes.js +6 -5
- package/core/gather/gatherers/stylesheets.d.ts +26 -0
- package/core/gather/gatherers/stylesheets.js +138 -0
- package/core/gather/gatherers/trace-elements.d.ts +4 -13
- package/core/gather/gatherers/trace-elements.js +42 -31
- package/core/gather/navigation-runner.js +3 -1
- package/core/gather/session.d.ts +8 -0
- package/core/gather/session.js +14 -1
- package/core/lib/emulation.js +2 -2
- package/core/lib/i18n/i18n.d.ts +0 -1
- package/core/lib/i18n/i18n.js +0 -2
- package/core/lib/lantern/cpu-node.d.ts +7 -1
- package/core/lib/lantern/cpu-node.js +12 -2
- package/core/lib/lantern/lantern-error.d.ts +8 -0
- package/core/lib/lantern/lantern-error.js +9 -0
- package/core/lib/lantern/metric.js +2 -6
- package/core/lib/lantern/metrics/first-contentful-paint.d.ts +79 -0
- package/core/lib/lantern/metrics/first-contentful-paint.js +200 -0
- package/core/lib/lantern/metrics/first-meaningful-paint.d.ts +6 -0
- package/core/lib/lantern/metrics/first-meaningful-paint.js +64 -0
- package/core/lib/lantern/metrics/interactive.d.ts +26 -0
- package/core/lib/lantern/metrics/interactive.js +112 -0
- package/core/lib/lantern/metrics/largest-contentful-paint.d.ts +19 -0
- package/core/lib/lantern/metrics/largest-contentful-paint.js +108 -0
- package/core/lib/lantern/metrics/max-potential-fid.d.ts +30 -0
- package/core/lib/lantern/metrics/max-potential-fid.js +92 -0
- package/core/lib/lantern/metrics/speed-index.d.ts +38 -0
- package/core/lib/lantern/metrics/speed-index.js +144 -0
- package/core/lib/lantern/metrics/total-blocking-time.d.ts +31 -0
- package/core/lib/lantern/metrics/total-blocking-time.js +128 -0
- package/core/lib/lantern/network-node.js +28 -4
- package/core/lib/lantern/page-dependency-graph.d.ts +4 -4
- package/core/lib/lantern/page-dependency-graph.js +19 -7
- package/core/lib/lantern/simulator/connection-pool.d.ts +2 -12
- package/core/lib/lantern/simulator/connection-pool.js +3 -22
- package/core/lib/lantern/simulator/network-analyzer.js +1 -12
- package/core/lib/lantern/simulator/simulator.d.ts +2 -4
- package/core/lib/lantern/simulator/simulator.js +7 -14
- package/core/lib/lantern/types/lantern.d.ts +5 -3
- package/core/lib/lantern-trace-saver.js +0 -1
- package/core/lib/lh-error.d.ts +9 -0
- package/core/lib/lh-error.js +13 -3
- package/core/lib/lighthouse-compatibility.js +53 -10
- package/core/lib/navigation-error.js +3 -0
- package/core/lib/network-request.d.ts +1 -0
- package/core/lib/network-request.js +29 -1
- package/core/lib/proto-preprocessor.js +24 -8
- package/core/lib/tracehouse/trace-processor.js +15 -2
- package/core/runner.js +18 -25
- package/dist/report/bundle.esm.js +11 -112
- package/dist/report/flow.js +16 -117
- package/dist/report/standalone.js +12 -113
- package/flow-report/src/help-dialog.tsx +0 -1
- package/flow-report/src/i18n/i18n.d.ts +0 -4
- package/flow-report/src/i18n/ui-strings.d.ts +0 -1
- package/flow-report/src/i18n/ui-strings.js +0 -2
- package/flow-report/src/summary/category.tsx +10 -12
- package/package.json +7 -7
- package/readme.md +4 -4
- package/report/assets/styles.css +1 -60
- package/report/assets/templates.html +0 -95
- package/report/renderer/category-renderer.js +1 -1
- package/report/renderer/components.d.ts +2 -2
- package/report/renderer/components.js +2 -103
- package/report/renderer/dom.d.ts +1 -1
- package/report/renderer/dom.js +1 -1
- package/report/renderer/performance-category-renderer.d.ts +0 -7
- package/report/renderer/performance-category-renderer.js +1 -32
- package/report/renderer/report-renderer.js +3 -13
- package/report/renderer/report-ui-features.js +1 -1
- package/report/renderer/report-utils.d.ts +0 -1
- package/report/renderer/report-utils.js +13 -13
- package/shared/localization/locales/ar-XB.json +62 -329
- package/shared/localization/locales/ar.json +62 -329
- package/shared/localization/locales/bg.json +62 -329
- package/shared/localization/locales/ca.json +62 -329
- package/shared/localization/locales/cs.json +62 -329
- package/shared/localization/locales/da.json +62 -329
- package/shared/localization/locales/de.json +62 -329
- package/shared/localization/locales/el.json +62 -329
- package/shared/localization/locales/en-GB.json +62 -329
- package/shared/localization/locales/en-US.json +101 -332
- package/shared/localization/locales/en-XA.json +62 -329
- package/shared/localization/locales/en-XL.json +101 -332
- package/shared/localization/locales/es-419.json +62 -329
- package/shared/localization/locales/es.json +62 -329
- package/shared/localization/locales/fi.json +62 -329
- package/shared/localization/locales/fil.json +61 -328
- package/shared/localization/locales/fr.json +62 -329
- package/shared/localization/locales/he.json +62 -329
- package/shared/localization/locales/hi.json +62 -329
- package/shared/localization/locales/hr.json +63 -330
- package/shared/localization/locales/hu.json +62 -329
- package/shared/localization/locales/id.json +62 -329
- package/shared/localization/locales/it.json +62 -329
- package/shared/localization/locales/ja.json +62 -329
- package/shared/localization/locales/ko.json +62 -329
- package/shared/localization/locales/lt.json +62 -329
- package/shared/localization/locales/lv.json +62 -329
- package/shared/localization/locales/nl.json +62 -329
- package/shared/localization/locales/no.json +62 -329
- package/shared/localization/locales/pl.json +61 -328
- package/shared/localization/locales/pt-PT.json +62 -329
- package/shared/localization/locales/pt.json +64 -331
- package/shared/localization/locales/ro.json +62 -329
- package/shared/localization/locales/ru.json +62 -329
- package/shared/localization/locales/sk.json +62 -329
- package/shared/localization/locales/sl.json +62 -329
- package/shared/localization/locales/sr-Latn.json +62 -329
- package/shared/localization/locales/sr.json +62 -329
- package/shared/localization/locales/sv.json +62 -329
- package/shared/localization/locales/ta.json +61 -328
- package/shared/localization/locales/te.json +62 -329
- package/shared/localization/locales/th.json +62 -329
- package/shared/localization/locales/tr.json +62 -329
- package/shared/localization/locales/uk.json +62 -329
- package/shared/localization/locales/vi.json +61 -328
- package/shared/localization/locales/zh-HK.json +62 -329
- package/shared/localization/locales/zh-TW.json +61 -328
- package/shared/localization/locales/zh.json +62 -329
- package/tsconfig.json +1 -3
- package/types/artifacts.d.ts +21 -110
- package/types/audit.d.ts +0 -10
- package/types/config.d.ts +0 -1
- package/types/externs.d.ts +0 -2
- package/types/gatherer.d.ts +3 -0
- package/types/internal/smokehouse.d.ts +1 -1
- package/types/lh.d.ts +0 -2
- package/types/lhr/audit-details.d.ts +9 -4
- package/types/lhr/lhr.d.ts +0 -4
- package/types/lhr/settings.d.ts +0 -4
- package/core/audits/accessibility/duplicate-id-active.js +0 -42
- package/core/audits/content-width.d.ts +0 -17
- package/core/audits/content-width.js +0 -76
- package/core/audits/installable-manifest.d.ts +0 -111
- package/core/audits/installable-manifest.js +0 -248
- package/core/audits/layout-shift-elements.d.ts +0 -16
- package/core/audits/layout-shift-elements.js +0 -101
- package/core/audits/manual/pwa-cross-browser.d.ts +0 -12
- package/core/audits/manual/pwa-cross-browser.js +0 -40
- package/core/audits/manual/pwa-each-page-has-url.d.ts +0 -12
- package/core/audits/manual/pwa-each-page-has-url.js +0 -38
- package/core/audits/manual/pwa-page-transitions.d.ts +0 -12
- package/core/audits/manual/pwa-page-transitions.js +0 -38
- package/core/audits/maskable-icon.d.ts +0 -25
- package/core/audits/maskable-icon.js +0 -70
- package/core/audits/multi-check-audit.d.ts +0 -28
- package/core/audits/multi-check-audit.js +0 -82
- package/core/audits/no-unload-listeners.d.ts +0 -16
- package/core/audits/no-unload-listeners.js +0 -86
- package/core/audits/performance-budget.d.ts +0 -39
- package/core/audits/performance-budget.js +0 -154
- package/core/audits/script-elements-test-audit.d.ts +0 -14
- package/core/audits/script-elements-test-audit.js +0 -29
- package/core/audits/seo/plugins.d.ts +0 -15
- package/core/audits/seo/plugins.js +0 -150
- package/core/audits/seo/tap-targets.d.ts +0 -50
- package/core/audits/seo/tap-targets.js +0 -352
- package/core/audits/splash-screen.d.ts +0 -37
- package/core/audits/splash-screen.js +0 -98
- package/core/audits/themed-omnibox.d.ts +0 -42
- package/core/audits/themed-omnibox.js +0 -102
- package/core/audits/timing-budget.d.ts +0 -43
- package/core/audits/timing-budget.js +0 -175
- package/core/computed/manifest-values.d.ts +0 -24
- package/core/computed/manifest-values.js +0 -136
- package/core/config/budget.d.ts +0 -74
- package/core/config/budget.js +0 -340
- package/core/config/metrics-to-audits.d.ts +0 -19
- package/core/config/metrics-to-audits.js +0 -62
- package/core/gather/driver/service-workers.d.ts +0 -16
- package/core/gather/driver/service-workers.js +0 -52
- package/core/gather/gatherers/dobetterweb/tags-blocking-first-paint.d.ts +0 -47
- package/core/gather/gatherers/dobetterweb/tags-blocking-first-paint.js +0 -233
- package/core/gather/gatherers/global-listeners.d.ts +0 -27
- package/core/gather/gatherers/global-listeners.js +0 -108
- package/core/gather/gatherers/installability-errors.d.ts +0 -17
- package/core/gather/gatherers/installability-errors.js +0 -56
- package/core/gather/gatherers/script-elements.d.ts +0 -21
- package/core/gather/gatherers/script-elements.js +0 -100
- package/core/gather/gatherers/seo/embedded-content.d.ts +0 -10
- package/core/gather/gatherers/seo/embedded-content.js +0 -63
- package/core/gather/gatherers/seo/tap-targets.d.ts +0 -21
- package/core/gather/gatherers/seo/tap-targets.js +0 -389
- package/core/gather/gatherers/service-worker.d.ts +0 -10
- package/core/gather/gatherers/service-worker.js +0 -32
- package/core/gather/gatherers/web-app-manifest.d.ts +0 -32
- package/core/gather/gatherers/web-app-manifest.js +0 -106
- package/report/renderer/pwa-category-renderer.d.ts +0 -55
- package/report/renderer/pwa-category-renderer.js +0 -184
- package/third-party/chromium-synchronization/installability-errors-test.js +0 -79
- package/types/lhr/budget.d.ts +0 -60
|
@@ -5,78 +5,22 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {makeComputedArtifact} from '../computed-artifact.js';
|
|
8
|
-
import {LanternMetric} from './lantern-metric.js';
|
|
9
|
-
import {BaseNode} from '../../lib/lantern/base-node.js';
|
|
10
|
-
import {NetworkRequest} from '../../lib/network-request.js';
|
|
11
8
|
import {LanternFirstMeaningfulPaint} from './lantern-first-meaningful-paint.js';
|
|
9
|
+
import {Interactive} from '../../lib/lantern/metrics/interactive.js';
|
|
10
|
+
import {getComputationDataParams, lanternErrorAdapter} from './lantern-metric.js';
|
|
12
11
|
|
|
13
|
-
/** @typedef {import('../../lib/lantern/
|
|
14
|
-
|
|
15
|
-
// Any CPU task of 20 ms or more will end up being a critical long task on mobile
|
|
16
|
-
const CRITICAL_LONG_TASK_THRESHOLD = 20;
|
|
17
|
-
|
|
18
|
-
class LanternInteractive extends LanternMetric {
|
|
19
|
-
/**
|
|
20
|
-
* @return {LH.Gatherer.Simulation.MetricCoefficients}
|
|
21
|
-
*/
|
|
22
|
-
static get COEFFICIENTS() {
|
|
23
|
-
return {
|
|
24
|
-
intercept: 0,
|
|
25
|
-
optimistic: 0.5,
|
|
26
|
-
pessimistic: 0.5,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @param {Node} dependencyGraph
|
|
32
|
-
* @return {Node}
|
|
33
|
-
*/
|
|
34
|
-
static getOptimisticGraph(dependencyGraph) {
|
|
35
|
-
// Adjust the critical long task threshold for microseconds
|
|
36
|
-
const minimumCpuTaskDuration = CRITICAL_LONG_TASK_THRESHOLD * 1000;
|
|
37
|
-
|
|
38
|
-
return dependencyGraph.cloneWithRelationships(node => {
|
|
39
|
-
// Include everything that might be a long task
|
|
40
|
-
if (node.type === BaseNode.TYPES.CPU) {
|
|
41
|
-
return node.event.dur > minimumCpuTaskDuration;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Include all scripts and high priority requests, exclude all images
|
|
45
|
-
const isImage = node.record.resourceType === NetworkRequest.TYPES.Image;
|
|
46
|
-
const isScript = node.record.resourceType === NetworkRequest.TYPES.Script;
|
|
47
|
-
return (
|
|
48
|
-
!isImage &&
|
|
49
|
-
(isScript ||
|
|
50
|
-
node.record.priority === 'High' ||
|
|
51
|
-
node.record.priority === 'VeryHigh')
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
12
|
+
/** @typedef {import('../../lib/lantern/metric.js').Extras} Extras */
|
|
55
13
|
|
|
14
|
+
class LanternInteractive extends Interactive {
|
|
56
15
|
/**
|
|
57
|
-
* @param {
|
|
58
|
-
* @
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return dependencyGraph;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {LH.Gatherer.Simulation.Result} simulationResult
|
|
66
|
-
* @param {import('../../lib/lantern/metric.js').Extras} extras
|
|
67
|
-
* @return {LH.Gatherer.Simulation.Result}
|
|
16
|
+
* @param {LH.Artifacts.MetricComputationDataInput} data
|
|
17
|
+
* @param {LH.Artifacts.ComputedContext} context
|
|
18
|
+
* @param {Omit<Extras, 'optimistic'>=} extras
|
|
19
|
+
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
68
20
|
*/
|
|
69
|
-
static
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const lastTaskAt = LanternInteractive.getLastLongTaskEndTime(simulationResult.nodeTimings);
|
|
73
|
-
const minimumTime = extras.optimistic
|
|
74
|
-
? extras.fmpResult.optimisticEstimate.timeInMs
|
|
75
|
-
: extras.fmpResult.pessimisticEstimate.timeInMs;
|
|
76
|
-
return {
|
|
77
|
-
timeInMs: Math.max(minimumTime, lastTaskAt),
|
|
78
|
-
nodeTimings: simulationResult.nodeTimings,
|
|
79
|
-
};
|
|
21
|
+
static async computeMetricWithGraphs(data, context, extras) {
|
|
22
|
+
return this.compute(await getComputationDataParams(data, context), extras)
|
|
23
|
+
.catch(lanternErrorAdapter);
|
|
80
24
|
}
|
|
81
25
|
|
|
82
26
|
/**
|
|
@@ -86,23 +30,7 @@ class LanternInteractive extends LanternMetric {
|
|
|
86
30
|
*/
|
|
87
31
|
static async compute_(data, context) {
|
|
88
32
|
const fmpResult = await LanternFirstMeaningfulPaint.request(data, context);
|
|
89
|
-
|
|
90
|
-
metricResult.timing = Math.max(metricResult.timing, fmpResult.timing);
|
|
91
|
-
return metricResult;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
|
|
96
|
-
* @return {number}
|
|
97
|
-
*/
|
|
98
|
-
static getLastLongTaskEndTime(nodeTimings, duration = 50) {
|
|
99
|
-
return Array.from(nodeTimings.entries())
|
|
100
|
-
.filter(([node, timing]) => {
|
|
101
|
-
if (node.type !== BaseNode.TYPES.CPU) return false;
|
|
102
|
-
return timing.duration > duration;
|
|
103
|
-
})
|
|
104
|
-
.map(([_, timing]) => timing.endTime)
|
|
105
|
-
.reduce((max, x) => Math.max(max || 0, x || 0), 0);
|
|
33
|
+
return this.computeMetricWithGraphs(data, context, {fmpResult});
|
|
106
34
|
}
|
|
107
35
|
}
|
|
108
36
|
|
|
@@ -1,37 +1,25 @@
|
|
|
1
1
|
export { LanternLargestContentfulPaintComputed as LanternLargestContentfulPaint };
|
|
2
|
-
export type
|
|
2
|
+
export type Extras = import('../../lib/lantern/metric.js').Extras;
|
|
3
3
|
declare const LanternLargestContentfulPaintComputed: typeof LanternLargestContentfulPaint & {
|
|
4
4
|
request: (dependencies: import("../../index.js").Artifacts.MetricComputationDataInput, context: import("../../../types/utility-types.js").default.ImmutableObject<{
|
|
5
5
|
computedCache: Map<string, import("../../lib/arbitrary-equality-map.js").ArbitraryEqualityMap>;
|
|
6
6
|
}>) => Promise<import("../../index.js").Artifacts.LanternMetric>;
|
|
7
7
|
};
|
|
8
|
-
/** @typedef {import('../../lib/lantern/
|
|
9
|
-
declare class LanternLargestContentfulPaint extends
|
|
8
|
+
/** @typedef {import('../../lib/lantern/metric.js').Extras} Extras */
|
|
9
|
+
declare class LanternLargestContentfulPaint extends LargestContentfulPaint {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
15
|
-
* @return {boolean}
|
|
11
|
+
* @param {LH.Artifacts.MetricComputationDataInput} data
|
|
12
|
+
* @param {LH.Artifacts.ComputedContext} context
|
|
13
|
+
* @param {Omit<Extras, 'optimistic'>=} extras
|
|
14
|
+
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
16
15
|
*/
|
|
17
|
-
static
|
|
16
|
+
static computeMetricWithGraphs(data: LH.Artifacts.MetricComputationDataInput, context: LH.Artifacts.ComputedContext, extras?: Omit<Extras, 'optimistic'> | undefined): Promise<LH.Artifacts.LanternMetric>;
|
|
18
17
|
/**
|
|
19
|
-
* @param {
|
|
20
|
-
* @param {LH.Artifacts.
|
|
21
|
-
* @return {
|
|
18
|
+
* @param {LH.Artifacts.MetricComputationDataInput} data
|
|
19
|
+
* @param {LH.Artifacts.ComputedContext} context
|
|
20
|
+
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
22
21
|
*/
|
|
23
|
-
static
|
|
24
|
-
/**
|
|
25
|
-
* @param {Node} dependencyGraph
|
|
26
|
-
* @param {LH.Artifacts.ProcessedNavigation} processedNavigation
|
|
27
|
-
* @return {Node}
|
|
28
|
-
*/
|
|
29
|
-
static getPessimisticGraph(dependencyGraph: Node, processedNavigation: LH.Artifacts.ProcessedNavigation): Node;
|
|
30
|
-
/**
|
|
31
|
-
* @param {LH.Gatherer.Simulation.Result} simulationResult
|
|
32
|
-
* @return {LH.Gatherer.Simulation.Result}
|
|
33
|
-
*/
|
|
34
|
-
static getEstimateFromSimulation(simulationResult: LH.Gatherer.Simulation.Result): LH.Gatherer.Simulation.Result;
|
|
22
|
+
static compute_(data: LH.Artifacts.MetricComputationDataInput, context: LH.Artifacts.ComputedContext): Promise<LH.Artifacts.LanternMetric>;
|
|
35
23
|
}
|
|
36
|
-
import {
|
|
24
|
+
import { LargestContentfulPaint } from '../../lib/lantern/metrics/largest-contentful-paint.js';
|
|
37
25
|
//# sourceMappingURL=lantern-largest-contentful-paint.d.ts.map
|
|
@@ -1,91 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright
|
|
3
|
+
* Copyright 2018 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {makeComputedArtifact} from '../computed-artifact.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import {LargestContentfulPaint} from '../../lib/lantern/metrics/largest-contentful-paint.js';
|
|
9
|
+
import {getComputationDataParams, lanternErrorAdapter} from './lantern-metric.js';
|
|
10
10
|
import {LanternFirstContentfulPaint} from './lantern-first-contentful-paint.js';
|
|
11
11
|
|
|
12
|
-
/** @typedef {import('../../lib/lantern/
|
|
12
|
+
/** @typedef {import('../../lib/lantern/metric.js').Extras} Extras */
|
|
13
13
|
|
|
14
|
-
class LanternLargestContentfulPaint extends
|
|
14
|
+
class LanternLargestContentfulPaint extends LargestContentfulPaint {
|
|
15
15
|
/**
|
|
16
|
-
* @
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
intercept: 0,
|
|
21
|
-
optimistic: 0.5,
|
|
22
|
-
pessimistic: 0.5,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Low priority image nodes are usually offscreen and very unlikely to be the
|
|
28
|
-
* resource that is required for LCP. Our LCP graphs include everything except for these images.
|
|
29
|
-
*
|
|
30
|
-
* @param {Node} node
|
|
31
|
-
* @return {boolean}
|
|
32
|
-
*/
|
|
33
|
-
static isNotLowPriorityImageNode(node) {
|
|
34
|
-
if (node.type !== 'network') return true;
|
|
35
|
-
const isImage = node.record.resourceType === 'Image';
|
|
36
|
-
const isLowPriority = node.record.priority === 'Low' || node.record.priority === 'VeryLow';
|
|
37
|
-
return !isImage || !isLowPriority;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @param {Node} dependencyGraph
|
|
42
|
-
* @param {LH.Artifacts.ProcessedNavigation} processedNavigation
|
|
43
|
-
* @return {Node}
|
|
44
|
-
*/
|
|
45
|
-
static getOptimisticGraph(dependencyGraph, processedNavigation) {
|
|
46
|
-
const lcp = processedNavigation.timestamps.largestContentfulPaint;
|
|
47
|
-
if (!lcp) {
|
|
48
|
-
throw new LighthouseError(LighthouseError.errors.NO_LCP);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return LanternFirstContentfulPaint.getFirstPaintBasedGraph(dependencyGraph, {
|
|
52
|
-
cutoffTimestamp: lcp,
|
|
53
|
-
treatNodeAsRenderBlocking: LanternLargestContentfulPaint.isNotLowPriorityImageNode,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* @param {Node} dependencyGraph
|
|
59
|
-
* @param {LH.Artifacts.ProcessedNavigation} processedNavigation
|
|
60
|
-
* @return {Node}
|
|
61
|
-
*/
|
|
62
|
-
static getPessimisticGraph(dependencyGraph, processedNavigation) {
|
|
63
|
-
const lcp = processedNavigation.timestamps.largestContentfulPaint;
|
|
64
|
-
if (!lcp) {
|
|
65
|
-
throw new LighthouseError(LighthouseError.errors.NO_LCP);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return LanternFirstContentfulPaint.getFirstPaintBasedGraph(dependencyGraph, {
|
|
69
|
-
cutoffTimestamp: lcp,
|
|
70
|
-
treatNodeAsRenderBlocking: _ => true,
|
|
71
|
-
// For pessimistic LCP we'll include *all* layout nodes
|
|
72
|
-
additionalCpuNodesToTreatAsRenderBlocking: node => node.didPerformLayout(),
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* @param {LH.Gatherer.Simulation.Result} simulationResult
|
|
78
|
-
* @return {LH.Gatherer.Simulation.Result}
|
|
16
|
+
* @param {LH.Artifacts.MetricComputationDataInput} data
|
|
17
|
+
* @param {LH.Artifacts.ComputedContext} context
|
|
18
|
+
* @param {Omit<Extras, 'optimistic'>=} extras
|
|
19
|
+
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
79
20
|
*/
|
|
80
|
-
static
|
|
81
|
-
|
|
82
|
-
.
|
|
83
|
-
.map(entry => entry[1].endTime);
|
|
84
|
-
|
|
85
|
-
return {
|
|
86
|
-
timeInMs: Math.max(...nodeTimesNotOffscreenImages),
|
|
87
|
-
nodeTimings: simulationResult.nodeTimings,
|
|
88
|
-
};
|
|
21
|
+
static async computeMetricWithGraphs(data, context, extras) {
|
|
22
|
+
return this.compute(await getComputationDataParams(data, context), extras)
|
|
23
|
+
.catch(lanternErrorAdapter);
|
|
89
24
|
}
|
|
90
25
|
|
|
91
26
|
/**
|
|
@@ -95,9 +30,7 @@ class LanternLargestContentfulPaint extends LanternMetric {
|
|
|
95
30
|
*/
|
|
96
31
|
static async compute_(data, context) {
|
|
97
32
|
const fcpResult = await LanternFirstContentfulPaint.request(data, context);
|
|
98
|
-
|
|
99
|
-
metricResult.timing = Math.max(metricResult.timing, fcpResult.timing);
|
|
100
|
-
return metricResult;
|
|
33
|
+
return this.computeMetricWithGraphs(data, context, {fcpResult});
|
|
101
34
|
}
|
|
102
35
|
}
|
|
103
36
|
|
|
@@ -1,36 +1,25 @@
|
|
|
1
1
|
export { LanternMaxPotentialFIDComputed as LanternMaxPotentialFID };
|
|
2
|
-
export type
|
|
2
|
+
export type Extras = import('../../lib/lantern/metric.js').Extras;
|
|
3
3
|
declare const LanternMaxPotentialFIDComputed: typeof LanternMaxPotentialFID & {
|
|
4
4
|
request: (dependencies: import("../../index.js").Artifacts.MetricComputationDataInput, context: import("../../../types/utility-types.js").default.ImmutableObject<{
|
|
5
5
|
computedCache: Map<string, import("../../lib/arbitrary-equality-map.js").ArbitraryEqualityMap>;
|
|
6
6
|
}>) => Promise<import("../../index.js").Artifacts.LanternMetric>;
|
|
7
7
|
};
|
|
8
|
-
/** @typedef {import('../../lib/lantern/
|
|
9
|
-
declare class LanternMaxPotentialFID extends
|
|
8
|
+
/** @typedef {import('../../lib/lantern/metric.js').Extras} Extras */
|
|
9
|
+
declare class LanternMaxPotentialFID extends MaxPotentialFID {
|
|
10
10
|
/**
|
|
11
|
-
* @param {
|
|
12
|
-
* @
|
|
11
|
+
* @param {LH.Artifacts.MetricComputationDataInput} data
|
|
12
|
+
* @param {LH.Artifacts.ComputedContext} context
|
|
13
|
+
* @param {Omit<Extras, 'optimistic'>=} extras
|
|
14
|
+
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
13
15
|
*/
|
|
14
|
-
static
|
|
16
|
+
static computeMetricWithGraphs(data: LH.Artifacts.MetricComputationDataInput, context: LH.Artifacts.ComputedContext, extras?: Omit<Extras, 'optimistic'> | undefined): Promise<LH.Artifacts.LanternMetric>;
|
|
15
17
|
/**
|
|
16
|
-
* @param {
|
|
17
|
-
* @
|
|
18
|
+
* @param {LH.Artifacts.MetricComputationDataInput} data
|
|
19
|
+
* @param {LH.Artifacts.ComputedContext} context
|
|
20
|
+
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
18
21
|
*/
|
|
19
|
-
static
|
|
20
|
-
/**
|
|
21
|
-
* @param {LH.Gatherer.Simulation.Result} simulation
|
|
22
|
-
* @param {import('../../lib/lantern/metric.js').Extras} extras
|
|
23
|
-
* @return {LH.Gatherer.Simulation.Result}
|
|
24
|
-
*/
|
|
25
|
-
static getEstimateFromSimulation(simulation: LH.Gatherer.Simulation.Result, extras: import('../../lib/lantern/metric.js').Extras): LH.Gatherer.Simulation.Result;
|
|
26
|
-
/**
|
|
27
|
-
* @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
|
|
28
|
-
* @param {number} fcpTimeInMs
|
|
29
|
-
* @return {Array<{duration: number}>}
|
|
30
|
-
*/
|
|
31
|
-
static getTimingsAfterFCP(nodeTimings: LH.Gatherer.Simulation.Result['nodeTimings'], fcpTimeInMs: number): Array<{
|
|
32
|
-
duration: number;
|
|
33
|
-
}>;
|
|
22
|
+
static compute_(data: LH.Artifacts.MetricComputationDataInput, context: LH.Artifacts.ComputedContext): Promise<LH.Artifacts.LanternMetric>;
|
|
34
23
|
}
|
|
35
|
-
import {
|
|
24
|
+
import { MaxPotentialFID } from '../../lib/lantern/metrics/max-potential-fid.js';
|
|
36
25
|
//# sourceMappingURL=lantern-max-potential-fid.d.ts.map
|
|
@@ -5,63 +5,22 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {makeComputedArtifact} from '../computed-artifact.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import {MaxPotentialFID} from '../../lib/lantern/metrics/max-potential-fid.js';
|
|
9
|
+
import {getComputationDataParams, lanternErrorAdapter} from './lantern-metric.js';
|
|
10
10
|
import {LanternFirstContentfulPaint} from './lantern-first-contentful-paint.js';
|
|
11
11
|
|
|
12
|
-
/** @typedef {import('../../lib/lantern/
|
|
12
|
+
/** @typedef {import('../../lib/lantern/metric.js').Extras} Extras */
|
|
13
13
|
|
|
14
|
-
class LanternMaxPotentialFID extends
|
|
14
|
+
class LanternMaxPotentialFID extends MaxPotentialFID {
|
|
15
15
|
/**
|
|
16
|
-
* @
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
intercept: 0,
|
|
21
|
-
optimistic: 0.5,
|
|
22
|
-
pessimistic: 0.5,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @param {Node} dependencyGraph
|
|
28
|
-
* @return {Node}
|
|
29
|
-
*/
|
|
30
|
-
static getOptimisticGraph(dependencyGraph) {
|
|
31
|
-
return dependencyGraph;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @param {Node} dependencyGraph
|
|
36
|
-
* @return {Node}
|
|
37
|
-
*/
|
|
38
|
-
static getPessimisticGraph(dependencyGraph) {
|
|
39
|
-
return dependencyGraph;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @param {LH.Gatherer.Simulation.Result} simulation
|
|
44
|
-
* @param {import('../../lib/lantern/metric.js').Extras} extras
|
|
45
|
-
* @return {LH.Gatherer.Simulation.Result}
|
|
16
|
+
* @param {LH.Artifacts.MetricComputationDataInput} data
|
|
17
|
+
* @param {LH.Artifacts.ComputedContext} context
|
|
18
|
+
* @param {Omit<Extras, 'optimistic'>=} extras
|
|
19
|
+
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
46
20
|
*/
|
|
47
|
-
static
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// Intentionally use the opposite FCP estimate, a more pessimistic FCP means that more tasks
|
|
51
|
-
// are excluded from the FID computation, so a higher FCP means lower FID for same work.
|
|
52
|
-
const fcpTimeInMs = extras.optimistic
|
|
53
|
-
? extras.fcpResult.pessimisticEstimate.timeInMs
|
|
54
|
-
: extras.fcpResult.optimisticEstimate.timeInMs;
|
|
55
|
-
|
|
56
|
-
const timings = LanternMaxPotentialFID.getTimingsAfterFCP(
|
|
57
|
-
simulation.nodeTimings,
|
|
58
|
-
fcpTimeInMs
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
timeInMs: Math.max(...timings.map(timing => timing.duration), 16),
|
|
63
|
-
nodeTimings: simulation.nodeTimings,
|
|
64
|
-
};
|
|
21
|
+
static async computeMetricWithGraphs(data, context, extras) {
|
|
22
|
+
return this.compute(await getComputationDataParams(data, context), extras)
|
|
23
|
+
.catch(lanternErrorAdapter);
|
|
65
24
|
}
|
|
66
25
|
|
|
67
26
|
/**
|
|
@@ -71,18 +30,7 @@ class LanternMaxPotentialFID extends LanternMetric {
|
|
|
71
30
|
*/
|
|
72
31
|
static async compute_(data, context) {
|
|
73
32
|
const fcpResult = await LanternFirstContentfulPaint.request(data, context);
|
|
74
|
-
return
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
|
|
79
|
-
* @param {number} fcpTimeInMs
|
|
80
|
-
* @return {Array<{duration: number}>}
|
|
81
|
-
*/
|
|
82
|
-
static getTimingsAfterFCP(nodeTimings, fcpTimeInMs) {
|
|
83
|
-
return Array.from(nodeTimings.entries())
|
|
84
|
-
.filter(([node, timing]) => node.type === BaseNode.TYPES.CPU && timing.endTime > fcpTimeInMs)
|
|
85
|
-
.map(([_, timing]) => timing);
|
|
33
|
+
return this.computeMetricWithGraphs(data, context, {fcpResult});
|
|
86
34
|
}
|
|
87
35
|
}
|
|
88
36
|
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*/
|
|
16
|
-
static compute_(data: LH.Artifacts.MetricComputationDataInput, context: LH.Artifacts.ComputedContext): Promise<LH.Artifacts.LanternMetric>;
|
|
17
|
-
}
|
|
18
|
-
import { Metric } from '../../lib/lantern/metric.js';
|
|
1
|
+
/**
|
|
2
|
+
* @param {LH.Artifacts.MetricComputationDataInput} data
|
|
3
|
+
* @param {LH.Artifacts.ComputedContext} context
|
|
4
|
+
*/
|
|
5
|
+
export function getComputationDataParams(data: LH.Artifacts.MetricComputationDataInput, context: LH.Artifacts.ComputedContext): Promise<{
|
|
6
|
+
simulator: import("../../lib/lantern/simulator/simulator.js").Simulator<any>;
|
|
7
|
+
graph: import("../page-dependency-graph.js").Node;
|
|
8
|
+
processedNavigation: import("../../index.js").Artifacts.ProcessedNavigation;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* @param {unknown} err
|
|
12
|
+
* @return {never}
|
|
13
|
+
*/
|
|
14
|
+
export function lanternErrorAdapter(err: unknown): never;
|
|
19
15
|
//# sourceMappingURL=lantern-metric.d.ts.map
|
|
@@ -4,42 +4,46 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {LanternError} from '../../lib/lantern/lantern-error.js';
|
|
8
|
+
import {LighthouseError} from '../../lib/lh-error.js';
|
|
8
9
|
import {LoadSimulator} from '../load-simulator.js';
|
|
9
10
|
import {PageDependencyGraph} from '../page-dependency-graph.js';
|
|
10
11
|
import {ProcessedNavigation} from '../processed-navigation.js';
|
|
11
12
|
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
/**
|
|
14
|
+
* @param {LH.Artifacts.MetricComputationDataInput} data
|
|
15
|
+
* @param {LH.Artifacts.ComputedContext} context
|
|
16
|
+
*/
|
|
17
|
+
async function getComputationDataParams(data, context) {
|
|
18
|
+
if (data.gatherContext.gatherMode !== 'navigation') {
|
|
19
|
+
throw new Error(`Lantern metrics can only be computed on navigations`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const graph = await PageDependencyGraph.request(data, context);
|
|
23
|
+
const processedNavigation = await ProcessedNavigation.request(data.trace, context);
|
|
24
|
+
const simulator = data.simulator || (await LoadSimulator.request(data, context));
|
|
25
|
+
|
|
26
|
+
return {simulator, graph, processedNavigation};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {unknown} err
|
|
31
|
+
* @return {never}
|
|
32
|
+
*/
|
|
33
|
+
function lanternErrorAdapter(err) {
|
|
34
|
+
if (!(err instanceof LanternError)) {
|
|
35
|
+
throw err;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
39
|
-
*/
|
|
40
|
-
static async compute_(data, context) {
|
|
41
|
-
return this.computeMetricWithGraphs(data, context);
|
|
38
|
+
const code = /** @type {keyof LighthouseError.errors} */ (err.message);
|
|
39
|
+
if (LighthouseError.errors[code]) {
|
|
40
|
+
throw new LighthouseError(LighthouseError.errors[code]);
|
|
42
41
|
}
|
|
42
|
+
|
|
43
|
+
throw err;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
export {
|
|
46
|
+
export {
|
|
47
|
+
getComputationDataParams,
|
|
48
|
+
lanternErrorAdapter,
|
|
49
|
+
};
|
|
@@ -1,44 +1,25 @@
|
|
|
1
1
|
export { LanternSpeedIndexComputed as LanternSpeedIndex };
|
|
2
|
-
export type
|
|
2
|
+
export type Extras = import('../../lib/lantern/metric.js').Extras;
|
|
3
3
|
declare const LanternSpeedIndexComputed: typeof LanternSpeedIndex & {
|
|
4
4
|
request: (dependencies: import("../../index.js").Artifacts.MetricComputationDataInput, context: import("../../../types/utility-types.js").default.ImmutableObject<{
|
|
5
5
|
computedCache: Map<string, import("../../lib/arbitrary-equality-map.js").ArbitraryEqualityMap>;
|
|
6
6
|
}>) => Promise<import("../../index.js").Artifacts.LanternMetric>;
|
|
7
7
|
};
|
|
8
|
-
/** @typedef {import('../../lib/lantern/
|
|
9
|
-
declare class LanternSpeedIndex extends
|
|
8
|
+
/** @typedef {import('../../lib/lantern/metric.js').Extras} Extras */
|
|
9
|
+
declare class LanternSpeedIndex extends SpeedIndex {
|
|
10
10
|
/**
|
|
11
|
-
* @param {
|
|
12
|
-
* @
|
|
11
|
+
* @param {LH.Artifacts.MetricComputationDataInput} data
|
|
12
|
+
* @param {LH.Artifacts.ComputedContext} context
|
|
13
|
+
* @param {Omit<Extras, 'optimistic'>=} extras
|
|
14
|
+
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
13
15
|
*/
|
|
14
|
-
static
|
|
16
|
+
static computeMetricWithGraphs(data: LH.Artifacts.MetricComputationDataInput, context: LH.Artifacts.ComputedContext, extras?: Omit<Extras, 'optimistic'> | undefined): Promise<LH.Artifacts.LanternMetric>;
|
|
15
17
|
/**
|
|
16
|
-
* @param {
|
|
17
|
-
* @
|
|
18
|
+
* @param {LH.Artifacts.MetricComputationDataInput} data
|
|
19
|
+
* @param {LH.Artifacts.ComputedContext} context
|
|
20
|
+
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
18
21
|
*/
|
|
19
|
-
static
|
|
20
|
-
/**
|
|
21
|
-
* @param {LH.Gatherer.Simulation.Result} simulationResult
|
|
22
|
-
* @param {import('../../lib/lantern/metric.js').Extras} extras
|
|
23
|
-
* @return {LH.Gatherer.Simulation.Result}
|
|
24
|
-
*/
|
|
25
|
-
static getEstimateFromSimulation(simulationResult: LH.Gatherer.Simulation.Result, extras: import('../../lib/lantern/metric.js').Extras): LH.Gatherer.Simulation.Result;
|
|
26
|
-
/**
|
|
27
|
-
* Approximate speed index using layout events from the simulated node timings.
|
|
28
|
-
* The layout-based speed index is the weighted average of the endTime of CPU nodes that contained
|
|
29
|
-
* a 'Layout' task. log(duration) is used as the weight to stand for "significance" to the page.
|
|
30
|
-
*
|
|
31
|
-
* If no layout events can be found or the endTime of a CPU task is too early, FCP is used instead.
|
|
32
|
-
*
|
|
33
|
-
* This approach was determined after evaluating the accuracy/complexity tradeoff of many
|
|
34
|
-
* different methods. Read more in the evaluation doc.
|
|
35
|
-
*
|
|
36
|
-
* @see https://docs.google.com/document/d/1qJWXwxoyVLVadezIp_Tgdk867G3tDNkkVRvUJSH3K1E/edit#
|
|
37
|
-
* @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
|
|
38
|
-
* @param {number} fcpTimeInMs
|
|
39
|
-
* @return {number}
|
|
40
|
-
*/
|
|
41
|
-
static computeLayoutBasedSpeedIndex(nodeTimings: LH.Gatherer.Simulation.Result['nodeTimings'], fcpTimeInMs: number): number;
|
|
22
|
+
static compute_(data: LH.Artifacts.MetricComputationDataInput, context: LH.Artifacts.ComputedContext): Promise<LH.Artifacts.LanternMetric>;
|
|
42
23
|
}
|
|
43
|
-
import {
|
|
24
|
+
import { SpeedIndex } from '../../lib/lantern/metrics/speed-index.js';
|
|
44
25
|
//# sourceMappingURL=lantern-speed-index.d.ts.map
|