lighthouse 11.7.1 → 12.0.0
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/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-prohibited-attr.d.ts +10 -0
- package/core/audits/accessibility/aria-prohibited-attr.js +44 -0
- package/core/audits/accessibility/target-size.js +0 -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 +1 -1
- 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/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 +2 -12
- package/core/gather/gatherers/trace-elements.js +2 -21
- 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 +28 -0
- 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 +5 -5
- 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 +41 -272
- package/shared/localization/locales/en-XA.json +62 -329
- package/shared/localization/locales/en-XL.json +41 -272
- 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
|
@@ -4,83 +4,23 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import {TotalBlockingTime} from '../../lib/lantern/metrics/total-blocking-time.js';
|
|
7
8
|
import {makeComputedArtifact} from '../computed-artifact.js';
|
|
8
|
-
import {LanternMetric} from './lantern-metric.js';
|
|
9
|
-
import {BaseNode} from '../../lib/lantern/base-node.js';
|
|
10
9
|
import {LanternFirstContentfulPaint} from './lantern-first-contentful-paint.js';
|
|
11
10
|
import {LanternInteractive} from './lantern-interactive.js';
|
|
12
|
-
import {
|
|
11
|
+
import {getComputationDataParams} from './lantern-metric.js';
|
|
13
12
|
|
|
14
|
-
/** @typedef {import('../../lib/lantern/
|
|
13
|
+
/** @typedef {import('../../lib/lantern/metric.js').Extras} Extras */
|
|
15
14
|
|
|
16
|
-
class LanternTotalBlockingTime extends
|
|
15
|
+
class LanternTotalBlockingTime extends TotalBlockingTime {
|
|
17
16
|
/**
|
|
18
|
-
* @
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
intercept: 0,
|
|
23
|
-
optimistic: 0.5,
|
|
24
|
-
pessimistic: 0.5,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @param {Node} dependencyGraph
|
|
30
|
-
* @return {Node}
|
|
31
|
-
*/
|
|
32
|
-
static getOptimisticGraph(dependencyGraph) {
|
|
33
|
-
return dependencyGraph;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param {Node} dependencyGraph
|
|
38
|
-
* @return {Node}
|
|
39
|
-
*/
|
|
40
|
-
static getPessimisticGraph(dependencyGraph) {
|
|
41
|
-
return dependencyGraph;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @param {LH.Gatherer.Simulation.Result} simulation
|
|
46
|
-
* @param {import('../../lib/lantern/metric.js').Extras} extras
|
|
47
|
-
* @return {LH.Gatherer.Simulation.Result}
|
|
17
|
+
* @param {LH.Artifacts.MetricComputationDataInput} data
|
|
18
|
+
* @param {LH.Artifacts.ComputedContext} context
|
|
19
|
+
* @param {Omit<Extras, 'optimistic'>=} extras
|
|
20
|
+
* @return {Promise<LH.Artifacts.LanternMetric>}
|
|
48
21
|
*/
|
|
49
|
-
static
|
|
50
|
-
|
|
51
|
-
if (!extras.interactiveResult) throw new Error('missing interactiveResult');
|
|
52
|
-
|
|
53
|
-
// Intentionally use the opposite FCP estimate. A pessimistic FCP is higher than equal to an
|
|
54
|
-
// optimistic FCP, which means potentially more tasks are excluded from the Total Blocking Time
|
|
55
|
-
// computation. So a more pessimistic FCP gives a more optimistic Total Blocking Time for the
|
|
56
|
-
// same work.
|
|
57
|
-
const fcpTimeInMs = extras.optimistic
|
|
58
|
-
? extras.fcpResult.pessimisticEstimate.timeInMs
|
|
59
|
-
: extras.fcpResult.optimisticEstimate.timeInMs;
|
|
60
|
-
|
|
61
|
-
// Similarly, we always have pessimistic TTI >= optimistic TTI. Therefore, picking optimistic
|
|
62
|
-
// TTI means our window of interest is smaller and thus potentially more tasks are excluded from
|
|
63
|
-
// Total Blocking Time computation, yielding a lower (more optimistic) Total Blocking Time value
|
|
64
|
-
// for the same work.
|
|
65
|
-
const interactiveTimeMs = extras.optimistic
|
|
66
|
-
? extras.interactiveResult.optimisticEstimate.timeInMs
|
|
67
|
-
: extras.interactiveResult.pessimisticEstimate.timeInMs;
|
|
68
|
-
|
|
69
|
-
const minDurationMs = BLOCKING_TIME_THRESHOLD;
|
|
70
|
-
|
|
71
|
-
const events = LanternTotalBlockingTime.getTopLevelEvents(
|
|
72
|
-
simulation.nodeTimings,
|
|
73
|
-
minDurationMs
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
timeInMs: calculateSumOfBlockingTime(
|
|
78
|
-
events,
|
|
79
|
-
fcpTimeInMs,
|
|
80
|
-
interactiveTimeMs
|
|
81
|
-
),
|
|
82
|
-
nodeTimings: simulation.nodeTimings,
|
|
83
|
-
};
|
|
22
|
+
static async computeMetricWithGraphs(data, context, extras) {
|
|
23
|
+
return this.compute(await getComputationDataParams(data, context), extras);
|
|
84
24
|
}
|
|
85
25
|
|
|
86
26
|
/**
|
|
@@ -93,30 +33,6 @@ class LanternTotalBlockingTime extends LanternMetric {
|
|
|
93
33
|
const interactiveResult = await LanternInteractive.request(data, context);
|
|
94
34
|
return this.computeMetricWithGraphs(data, context, {fcpResult, interactiveResult});
|
|
95
35
|
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* @param {LH.Gatherer.Simulation.Result['nodeTimings']} nodeTimings
|
|
99
|
-
* @param {number} minDurationMs
|
|
100
|
-
*/
|
|
101
|
-
static getTopLevelEvents(nodeTimings, minDurationMs) {
|
|
102
|
-
/** @type {Array<{start: number, end: number, duration: number}>}
|
|
103
|
-
*/
|
|
104
|
-
const events = [];
|
|
105
|
-
|
|
106
|
-
for (const [node, timing] of nodeTimings.entries()) {
|
|
107
|
-
if (node.type !== BaseNode.TYPES.CPU) continue;
|
|
108
|
-
// Filtering out events below minimum duration.
|
|
109
|
-
if (timing.duration < minDurationMs) continue;
|
|
110
|
-
|
|
111
|
-
events.push({
|
|
112
|
-
start: timing.startTime,
|
|
113
|
-
end: timing.endTime,
|
|
114
|
-
duration: timing.duration,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return events;
|
|
119
|
-
}
|
|
120
36
|
}
|
|
121
37
|
|
|
122
38
|
const LanternTotalBlockingTimeComputed = makeComputedArtifact(
|
|
@@ -61,9 +61,7 @@ class Metric {
|
|
|
61
61
|
* @return {Promise<LH.Artifacts.LanternMetric|LH.Artifacts.Metric>}
|
|
62
62
|
*/
|
|
63
63
|
static async compute_(data, context) {
|
|
64
|
-
|
|
65
|
-
const gatherContext = data.gatherContext || {gatherMode: 'navigation'};
|
|
66
|
-
const {trace, devtoolsLog, settings} = data;
|
|
64
|
+
const {trace, devtoolsLog, settings, gatherContext} = data;
|
|
67
65
|
if (!trace || !devtoolsLog || !settings) {
|
|
68
66
|
throw new Error('Did not provide necessary metric computation data');
|
|
69
67
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ModuleDuplicationComputed as ModuleDuplication };
|
|
2
2
|
declare const ModuleDuplicationComputed: typeof ModuleDuplication & {
|
|
3
|
-
request: (dependencies: Pick<import("../index.js").Artifacts, "
|
|
3
|
+
request: (dependencies: Pick<import("../index.js").Artifacts, "SourceMaps" | "Scripts">, context: import("../../types/utility-types.js").default.ImmutableObject<{
|
|
4
4
|
computedCache: Map<string, import("../lib/arbitrary-equality-map.js").ArbitraryEqualityMap>;
|
|
5
5
|
}>) => Promise<Map<string, {
|
|
6
6
|
scriptId: string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export { NavigationInsightsComputed as NavigationInsights };
|
|
2
|
+
declare const NavigationInsightsComputed: typeof NavigationInsights & {
|
|
3
|
+
request: (dependencies: import("../index.js").Trace, context: import("../../types/utility-types.js").default.ImmutableObject<{
|
|
4
|
+
computedCache: Map<string, import("../lib/arbitrary-equality-map.js").ArbitraryEqualityMap>;
|
|
5
|
+
}>) => Promise<import("@paulirish/trace_engine/models/trace/insights/types.js").NavigationInsightData<{
|
|
6
|
+
AuctionWorklets: typeof import("@paulirish/trace_engine/models/trace/handlers/AuctionWorkletsHandler.js");
|
|
7
|
+
Initiators: typeof import("@paulirish/trace_engine/models/trace/handlers/InitiatorsHandler.js");
|
|
8
|
+
LayoutShifts: typeof import("@paulirish/trace_engine/models/trace/handlers/LayoutShiftsHandler.js");
|
|
9
|
+
NetworkRequests: typeof import("@paulirish/trace_engine/models/trace/handlers/NetworkRequestsHandler.js");
|
|
10
|
+
Renderer: typeof import("@paulirish/trace_engine/models/trace/handlers/RendererHandler.js");
|
|
11
|
+
Samples: typeof import("@paulirish/trace_engine/models/trace/handlers/SamplesHandler.js");
|
|
12
|
+
Screenshots: typeof import("@paulirish/trace_engine/models/trace/handlers/ScreenshotsHandler.js");
|
|
13
|
+
PageLoadMetrics: typeof import("@paulirish/trace_engine/models/trace/handlers/PageLoadMetricsHandler.js");
|
|
14
|
+
}>>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* @fileoverview Gets insights from the shared trace engine for the navigation audited by Lighthouse.
|
|
18
|
+
* Only usable in navigation mode.
|
|
19
|
+
*/
|
|
20
|
+
declare class NavigationInsights {
|
|
21
|
+
/**
|
|
22
|
+
* @param {LH.Trace} trace
|
|
23
|
+
* @param {LH.Artifacts.ComputedContext} context
|
|
24
|
+
*/
|
|
25
|
+
static compute_(trace: LH.Trace, context: LH.Artifacts.ComputedContext): Promise<import("@paulirish/trace_engine/models/trace/insights/types.js").NavigationInsightData<{
|
|
26
|
+
AuctionWorklets: typeof import("@paulirish/trace_engine/models/trace/handlers/AuctionWorkletsHandler.js");
|
|
27
|
+
Initiators: typeof import("@paulirish/trace_engine/models/trace/handlers/InitiatorsHandler.js");
|
|
28
|
+
LayoutShifts: typeof import("@paulirish/trace_engine/models/trace/handlers/LayoutShiftsHandler.js");
|
|
29
|
+
NetworkRequests: typeof import("@paulirish/trace_engine/models/trace/handlers/NetworkRequestsHandler.js");
|
|
30
|
+
Renderer: typeof import("@paulirish/trace_engine/models/trace/handlers/RendererHandler.js");
|
|
31
|
+
Samples: typeof import("@paulirish/trace_engine/models/trace/handlers/SamplesHandler.js");
|
|
32
|
+
Screenshots: typeof import("@paulirish/trace_engine/models/trace/handlers/ScreenshotsHandler.js");
|
|
33
|
+
PageLoadMetrics: typeof import("@paulirish/trace_engine/models/trace/handlers/PageLoadMetricsHandler.js");
|
|
34
|
+
}>>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=navigation-insights.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {makeComputedArtifact} from './computed-artifact.js';
|
|
8
|
+
import {ProcessedTrace} from './processed-trace.js';
|
|
9
|
+
import {TraceEngineResult} from './trace-engine-result.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @fileoverview Gets insights from the shared trace engine for the navigation audited by Lighthouse.
|
|
13
|
+
* Only usable in navigation mode.
|
|
14
|
+
*/
|
|
15
|
+
class NavigationInsights {
|
|
16
|
+
/**
|
|
17
|
+
* @param {LH.Trace} trace
|
|
18
|
+
* @param {LH.Artifacts.ComputedContext} context
|
|
19
|
+
*/
|
|
20
|
+
static async compute_(trace, context) {
|
|
21
|
+
const processedTrace = await ProcessedTrace.request(trace, context);
|
|
22
|
+
const traceEngineResult = await TraceEngineResult.request({trace}, context);
|
|
23
|
+
|
|
24
|
+
const navigationId = processedTrace.timeOriginEvt.args.data?.navigationId;
|
|
25
|
+
if (!navigationId) throw new Error('No navigationId found');
|
|
26
|
+
|
|
27
|
+
const navInsights = traceEngineResult.insights.get(navigationId);
|
|
28
|
+
if (!navInsights) throw new Error('No navigations insights found');
|
|
29
|
+
|
|
30
|
+
return navInsights;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const NavigationInsightsComputed = makeComputedArtifact(NavigationInsights, null);
|
|
35
|
+
export {NavigationInsightsComputed as NavigationInsights};
|
|
@@ -9,7 +9,6 @@ import {PageDependencyGraph as LanternPageDependencyGraph} from '../lib/lantern/
|
|
|
9
9
|
import {NetworkRequest} from '../lib/network-request.js';
|
|
10
10
|
import {ProcessedTrace} from './processed-trace.js';
|
|
11
11
|
import {NetworkRecords} from './network-records.js';
|
|
12
|
-
import {DocumentUrls} from './document-urls.js';
|
|
13
12
|
|
|
14
13
|
/** @typedef {import('../lib/lantern/base-node.js').Node<LH.Artifacts.NetworkRequest>} Node */
|
|
15
14
|
|
|
@@ -20,18 +19,15 @@ class PageDependencyGraph {
|
|
|
20
19
|
* @return {Promise<Node>}
|
|
21
20
|
*/
|
|
22
21
|
static async compute_(data, context) {
|
|
23
|
-
const {trace, devtoolsLog} = data;
|
|
22
|
+
const {trace, devtoolsLog, URL} = data;
|
|
24
23
|
const [processedTrace, networkRecords] = await Promise.all([
|
|
25
24
|
ProcessedTrace.request(trace, context),
|
|
26
25
|
NetworkRecords.request(devtoolsLog, context),
|
|
27
26
|
]);
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
// Calculates the URL artifact from the processed trace and DT log.
|
|
31
|
-
const URL = data.URL || await DocumentUrls.request(data, context);
|
|
32
|
-
|
|
28
|
+
const mainThreadEvents = processedTrace.mainThreadEvents;
|
|
33
29
|
const lanternRequests = networkRecords.map(NetworkRequest.asLanternNetworkRequest);
|
|
34
|
-
return LanternPageDependencyGraph.createGraph(
|
|
30
|
+
return LanternPageDependencyGraph.createGraph(mainThreadEvents, lanternRequests, URL);
|
|
35
31
|
}
|
|
36
32
|
}
|
|
37
33
|
|
|
@@ -4,42 +4,40 @@ export type ResourceEntry = {
|
|
|
4
4
|
resourceSize: number;
|
|
5
5
|
transferSize: number;
|
|
6
6
|
};
|
|
7
|
+
export type ResourceType = 'stylesheet' | 'image' | 'media' | 'font' | 'script' | 'document' | 'other' | 'third-party' | 'total';
|
|
7
8
|
declare const ResourceSummaryComputed: typeof ResourceSummary & {
|
|
8
9
|
request: (dependencies: {
|
|
9
10
|
URL: LH.Artifacts['URL'];
|
|
10
11
|
devtoolsLog: import("../index.js").DevtoolsLog;
|
|
11
|
-
budgets: LH.Util.ImmutableObject<LH.Budget[] | null>;
|
|
12
12
|
}, context: import("../../types/utility-types.js").default.ImmutableObject<{
|
|
13
13
|
computedCache: Map<string, import("../lib/arbitrary-equality-map.js").ArbitraryEqualityMap>;
|
|
14
|
-
}>) => Promise<Record<
|
|
14
|
+
}>) => Promise<Record<ResourceType, ResourceEntry>>;
|
|
15
15
|
};
|
|
16
16
|
/** @typedef {{count: number, resourceSize: number, transferSize: number}} ResourceEntry */
|
|
17
|
+
/** @typedef {'stylesheet'|'image'|'media'|'font'|'script'|'document'|'other'|'third-party'|'total'} ResourceType */
|
|
17
18
|
declare class ResourceSummary {
|
|
18
19
|
/**
|
|
19
20
|
* @param {LH.Artifacts.NetworkRequest} record
|
|
20
|
-
* @return {
|
|
21
|
+
* @return {ResourceType}
|
|
21
22
|
*/
|
|
22
|
-
static determineResourceType(record: LH.Artifacts.NetworkRequest):
|
|
23
|
+
static determineResourceType(record: LH.Artifacts.NetworkRequest): ResourceType;
|
|
23
24
|
/**
|
|
24
25
|
* @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
|
|
25
26
|
* @param {LH.Artifacts.URL} URLArtifact
|
|
26
|
-
* @param {LH.Util.ImmutableObject<LH.Budget[]|null>} budgets
|
|
27
27
|
* @param {LH.Artifacts.EntityClassification} classifiedEntities
|
|
28
|
-
* @return {Record<
|
|
28
|
+
* @return {Record<ResourceType, ResourceEntry>}
|
|
29
29
|
*/
|
|
30
|
-
static summarize(networkRecords: Array<LH.Artifacts.NetworkRequest>, URLArtifact: LH.Artifacts.URL,
|
|
30
|
+
static summarize(networkRecords: Array<LH.Artifacts.NetworkRequest>, URLArtifact: LH.Artifacts.URL, classifiedEntities: LH.Artifacts.EntityClassification): Record<ResourceType, ResourceEntry>;
|
|
31
31
|
/**
|
|
32
|
-
* @param {{URL: LH.Artifacts['URL'], devtoolsLog: LH.DevtoolsLog
|
|
32
|
+
* @param {{URL: LH.Artifacts['URL'], devtoolsLog: LH.DevtoolsLog}} data
|
|
33
33
|
* @param {LH.Artifacts.ComputedContext} context
|
|
34
|
-
* @return {Promise<Record<
|
|
34
|
+
* @return {Promise<Record<ResourceType,ResourceEntry>>}
|
|
35
35
|
*/
|
|
36
36
|
static compute_(data: {
|
|
37
37
|
URL: LH.Artifacts['URL'];
|
|
38
38
|
devtoolsLog: import("../index.js").DevtoolsLog;
|
|
39
|
-
|
|
40
|
-
}, context: LH.Artifacts.ComputedContext): Promise<Record<LH.Budget.ResourceType, ResourceEntry>>;
|
|
39
|
+
}, context: LH.Artifacts.ComputedContext): Promise<Record<ResourceType, ResourceEntry>>;
|
|
41
40
|
}
|
|
42
|
-
import { Budget } from '../config/budget.js';
|
|
43
41
|
import { NetworkRequest } from '../lib/network-request.js';
|
|
44
42
|
import { EntityClassification } from './entity-classification.js';
|
|
45
43
|
//# sourceMappingURL=resource-summary.d.ts.map
|
|
@@ -8,19 +8,19 @@ import {EntityClassification} from './entity-classification.js';
|
|
|
8
8
|
import {makeComputedArtifact} from './computed-artifact.js';
|
|
9
9
|
import {NetworkRecords} from './network-records.js';
|
|
10
10
|
import {NetworkRequest} from '../lib/network-request.js';
|
|
11
|
-
import {Budget} from '../config/budget.js';
|
|
12
11
|
import UrlUtils from '../lib/url-utils.js';
|
|
13
12
|
|
|
14
13
|
/** @typedef {{count: number, resourceSize: number, transferSize: number}} ResourceEntry */
|
|
14
|
+
/** @typedef {'stylesheet'|'image'|'media'|'font'|'script'|'document'|'other'|'third-party'|'total'} ResourceType */
|
|
15
15
|
|
|
16
16
|
class ResourceSummary {
|
|
17
17
|
/**
|
|
18
18
|
* @param {LH.Artifacts.NetworkRequest} record
|
|
19
|
-
* @return {
|
|
19
|
+
* @return {ResourceType}
|
|
20
20
|
*/
|
|
21
21
|
static determineResourceType(record) {
|
|
22
22
|
if (!record.resourceType) return 'other';
|
|
23
|
-
/** @type {Partial<Record<LH.Crdp.Network.ResourceType,
|
|
23
|
+
/** @type {Partial<Record<LH.Crdp.Network.ResourceType, ResourceType>>} */
|
|
24
24
|
const requestToResourceType = {
|
|
25
25
|
'Stylesheet': 'stylesheet',
|
|
26
26
|
'Image': 'image',
|
|
@@ -35,12 +35,11 @@ class ResourceSummary {
|
|
|
35
35
|
/**
|
|
36
36
|
* @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
|
|
37
37
|
* @param {LH.Artifacts.URL} URLArtifact
|
|
38
|
-
* @param {LH.Util.ImmutableObject<LH.Budget[]|null>} budgets
|
|
39
38
|
* @param {LH.Artifacts.EntityClassification} classifiedEntities
|
|
40
|
-
* @return {Record<
|
|
39
|
+
* @return {Record<ResourceType, ResourceEntry>}
|
|
41
40
|
*/
|
|
42
|
-
static summarize(networkRecords, URLArtifact,
|
|
43
|
-
/** @type {Record<
|
|
41
|
+
static summarize(networkRecords, URLArtifact, classifiedEntities) {
|
|
42
|
+
/** @type {Record<ResourceType, ResourceEntry>} */
|
|
44
43
|
const resourceSummary = {
|
|
45
44
|
'stylesheet': {count: 0, resourceSize: 0, transferSize: 0},
|
|
46
45
|
'image': {count: 0, resourceSize: 0, transferSize: 0},
|
|
@@ -52,15 +51,9 @@ class ResourceSummary {
|
|
|
52
51
|
'total': {count: 0, resourceSize: 0, transferSize: 0},
|
|
53
52
|
'third-party': {count: 0, resourceSize: 0, transferSize: 0},
|
|
54
53
|
};
|
|
55
|
-
const budget = Budget.getMatchingBudget(budgets, URLArtifact.mainDocumentUrl);
|
|
56
54
|
/** @type {ReadonlyArray<string>} */
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
firstPartyHosts = budget.options.firstPartyHostnames;
|
|
60
|
-
} else {
|
|
61
|
-
firstPartyHosts = classifiedEntities.firstParty?.domains.map(domain => `*.${domain}`) ||
|
|
62
|
-
[`*.${UrlUtils.getRootDomain(URLArtifact.finalDisplayedUrl)}`];
|
|
63
|
-
}
|
|
55
|
+
const firstPartyHosts = classifiedEntities.firstParty?.domains.map(domain => `*.${domain}`) ||
|
|
56
|
+
[`*.${UrlUtils.getRootDomain(URLArtifact.finalDisplayedUrl)}`];
|
|
64
57
|
|
|
65
58
|
networkRecords.filter(record => {
|
|
66
59
|
// Ignore favicon.co
|
|
@@ -101,18 +94,18 @@ class ResourceSummary {
|
|
|
101
94
|
}
|
|
102
95
|
|
|
103
96
|
/**
|
|
104
|
-
* @param {{URL: LH.Artifacts['URL'], devtoolsLog: LH.DevtoolsLog
|
|
97
|
+
* @param {{URL: LH.Artifacts['URL'], devtoolsLog: LH.DevtoolsLog}} data
|
|
105
98
|
* @param {LH.Artifacts.ComputedContext} context
|
|
106
|
-
* @return {Promise<Record<
|
|
99
|
+
* @return {Promise<Record<ResourceType,ResourceEntry>>}
|
|
107
100
|
*/
|
|
108
101
|
static async compute_(data, context) {
|
|
109
102
|
const networkRecords = await NetworkRecords.request(data.devtoolsLog, context);
|
|
110
103
|
const classifiedEntities = await EntityClassification.request(
|
|
111
104
|
{URL: data.URL, devtoolsLog: data.devtoolsLog}, context);
|
|
112
|
-
return ResourceSummary.summarize(networkRecords, data.URL,
|
|
105
|
+
return ResourceSummary.summarize(networkRecords, data.URL, classifiedEntities);
|
|
113
106
|
}
|
|
114
107
|
}
|
|
115
108
|
|
|
116
109
|
const ResourceSummaryComputed =
|
|
117
|
-
makeComputedArtifact(ResourceSummary, ['URL', 'devtoolsLog'
|
|
110
|
+
makeComputedArtifact(ResourceSummary, ['URL', 'devtoolsLog']);
|
|
118
111
|
export {ResourceSummaryComputed as ResourceSummary};
|
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
export { TraceEngineResultComputed as TraceEngineResult };
|
|
2
|
+
export type EnabledHandlers = typeof ENABLED_HANDLERS;
|
|
2
3
|
declare const TraceEngineResultComputed: typeof TraceEngineResult & {
|
|
3
4
|
request: (dependencies: {
|
|
4
5
|
trace: LH.Trace;
|
|
5
|
-
}, context:
|
|
6
|
+
}, context: LH.Util.ImmutableObject<{
|
|
6
7
|
computedCache: Map<string, import("../lib/arbitrary-equality-map.js").ArbitraryEqualityMap>;
|
|
7
|
-
}>) => Promise<
|
|
8
|
+
}>) => Promise<LH.Artifacts.TraceEngineResult>;
|
|
8
9
|
};
|
|
10
|
+
declare namespace ENABLED_HANDLERS {
|
|
11
|
+
const AuctionWorklets: typeof import("@paulirish/trace_engine/models/trace/handlers/AuctionWorkletsHandler.js");
|
|
12
|
+
const Initiators: typeof import("@paulirish/trace_engine/models/trace/handlers/InitiatorsHandler.js");
|
|
13
|
+
const LayoutShifts: typeof import("@paulirish/trace_engine/models/trace/handlers/LayoutShiftsHandler.js");
|
|
14
|
+
const NetworkRequests: typeof import("@paulirish/trace_engine/models/trace/handlers/NetworkRequestsHandler.js");
|
|
15
|
+
const Renderer: typeof import("@paulirish/trace_engine/models/trace/handlers/RendererHandler.js");
|
|
16
|
+
const Samples: typeof import("@paulirish/trace_engine/models/trace/handlers/SamplesHandler.js");
|
|
17
|
+
const Screenshots: typeof import("@paulirish/trace_engine/models/trace/handlers/ScreenshotsHandler.js");
|
|
18
|
+
const PageLoadMetrics: typeof import("@paulirish/trace_engine/models/trace/handlers/PageLoadMetricsHandler.js");
|
|
19
|
+
}
|
|
9
20
|
/**
|
|
10
21
|
* @fileoverview Processes trace with the shared trace engine.
|
|
11
22
|
*/
|
|
12
23
|
declare class TraceEngineResult {
|
|
13
24
|
/**
|
|
14
25
|
* @param {LH.TraceEvent[]} traceEvents
|
|
26
|
+
* @return {Promise<LH.Artifacts.TraceEngineResult>}
|
|
15
27
|
*/
|
|
16
|
-
static runTraceEngine(traceEvents: LH.TraceEvent[]): Promise<
|
|
28
|
+
static runTraceEngine(traceEvents: LH.TraceEvent[]): Promise<LH.Artifacts.TraceEngineResult>;
|
|
17
29
|
/**
|
|
18
30
|
* @param {{trace: LH.Trace}} data
|
|
19
31
|
* @param {LH.Artifacts.ComputedContext} context
|
|
@@ -23,4 +35,5 @@ declare class TraceEngineResult {
|
|
|
23
35
|
trace: LH.Trace;
|
|
24
36
|
}, context: LH.Artifacts.ComputedContext): Promise<LH.Artifacts.TraceEngineResult>;
|
|
25
37
|
}
|
|
38
|
+
import * as LH from '../../types/lh.js';
|
|
26
39
|
//# sourceMappingURL=trace-engine-result.d.ts.map
|
|
@@ -8,6 +8,20 @@ import * as TraceEngine from '../lib/trace-engine.js';
|
|
|
8
8
|
import {makeComputedArtifact} from './computed-artifact.js';
|
|
9
9
|
import {CumulativeLayoutShift} from './metrics/cumulative-layout-shift.js';
|
|
10
10
|
import {ProcessedTrace} from './processed-trace.js';
|
|
11
|
+
import * as LH from '../../types/lh.js';
|
|
12
|
+
|
|
13
|
+
/** @typedef {typeof ENABLED_HANDLERS} EnabledHandlers */
|
|
14
|
+
|
|
15
|
+
const ENABLED_HANDLERS = {
|
|
16
|
+
AuctionWorklets: TraceEngine.TraceHandlers.AuctionWorklets,
|
|
17
|
+
Initiators: TraceEngine.TraceHandlers.Initiators,
|
|
18
|
+
LayoutShifts: TraceEngine.TraceHandlers.LayoutShifts,
|
|
19
|
+
NetworkRequests: TraceEngine.TraceHandlers.NetworkRequests,
|
|
20
|
+
Renderer: TraceEngine.TraceHandlers.Renderer,
|
|
21
|
+
Samples: TraceEngine.TraceHandlers.Samples,
|
|
22
|
+
Screenshots: TraceEngine.TraceHandlers.Screenshots,
|
|
23
|
+
PageLoadMetrics: TraceEngine.TraceHandlers.PageLoadMetrics,
|
|
24
|
+
};
|
|
11
25
|
|
|
12
26
|
/**
|
|
13
27
|
* @fileoverview Processes trace with the shared trace engine.
|
|
@@ -15,24 +29,18 @@ import {ProcessedTrace} from './processed-trace.js';
|
|
|
15
29
|
class TraceEngineResult {
|
|
16
30
|
/**
|
|
17
31
|
* @param {LH.TraceEvent[]} traceEvents
|
|
32
|
+
* @return {Promise<LH.Artifacts.TraceEngineResult>}
|
|
18
33
|
*/
|
|
19
34
|
static async runTraceEngine(traceEvents) {
|
|
20
|
-
const engine = new TraceEngine.TraceProcessor(
|
|
21
|
-
AuctionWorklets: TraceEngine.TraceHandlers.AuctionWorklets,
|
|
22
|
-
Initiators: TraceEngine.TraceHandlers.Initiators,
|
|
23
|
-
LayoutShifts: TraceEngine.TraceHandlers.LayoutShifts,
|
|
24
|
-
NetworkRequests: TraceEngine.TraceHandlers.NetworkRequests,
|
|
25
|
-
Renderer: TraceEngine.TraceHandlers.Renderer,
|
|
26
|
-
Samples: TraceEngine.TraceHandlers.Samples,
|
|
27
|
-
Screenshots: TraceEngine.TraceHandlers.Screenshots,
|
|
28
|
-
});
|
|
35
|
+
const engine = new TraceEngine.TraceProcessor(ENABLED_HANDLERS);
|
|
29
36
|
// eslint-disable-next-line max-len
|
|
30
37
|
await engine.parse(/** @type {import('@paulirish/trace_engine').Types.TraceEvents.TraceEventData[]} */ (
|
|
31
38
|
traceEvents
|
|
32
39
|
));
|
|
33
40
|
// TODO: use TraceEngine.TraceProcessor.createWithAllHandlers above.
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
if (!engine.traceParsedData) throw new Error('No data');
|
|
42
|
+
if (!engine.insights) throw new Error('No insights');
|
|
43
|
+
return {data: engine.traceParsedData, insights: engine.insights};
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
/**
|
|
@@ -67,9 +75,6 @@ class TraceEngineResult {
|
|
|
67
75
|
}
|
|
68
76
|
|
|
69
77
|
const result = await TraceEngineResult.runTraceEngine(traceEvents);
|
|
70
|
-
if (!result) {
|
|
71
|
-
throw new Error('null trace engine result');
|
|
72
|
-
}
|
|
73
78
|
return result;
|
|
74
79
|
}
|
|
75
80
|
}
|
|
@@ -5,6 +5,7 @@ export type StyleSheetInfo = LH.Artifacts.CSSStyleSheetInfo & {
|
|
|
5
5
|
};
|
|
6
6
|
declare const UnusedCSSComputed: typeof UnusedCSS & {
|
|
7
7
|
request: (dependencies: {
|
|
8
|
+
Stylesheets: LH.Artifacts['Stylesheets'];
|
|
8
9
|
CSSUsage: LH.Artifacts['CSSUsage'];
|
|
9
10
|
devtoolsLog: import("../index.js").DevtoolsLog;
|
|
10
11
|
}, context: import("../../types/utility-types.js").default.ImmutableObject<{
|
|
@@ -50,11 +51,12 @@ declare class UnusedCSS {
|
|
|
50
51
|
*/
|
|
51
52
|
static mapSheetToResult(stylesheetInfo: StyleSheetInfo): LH.Audit.ByteEfficiencyItem;
|
|
52
53
|
/**
|
|
53
|
-
* @param {{CSSUsage: LH.Artifacts['CSSUsage'], devtoolsLog: LH.DevtoolsLog}} data
|
|
54
|
+
* @param {{Stylesheets: LH.Artifacts['Stylesheets'], CSSUsage: LH.Artifacts['CSSUsage'], devtoolsLog: LH.DevtoolsLog}} data
|
|
54
55
|
* @param {LH.Artifacts.ComputedContext} context
|
|
55
56
|
* @return {Promise<LH.Audit.ByteEfficiencyItem[]>}
|
|
56
57
|
*/
|
|
57
58
|
static compute_(data: {
|
|
59
|
+
Stylesheets: LH.Artifacts['Stylesheets'];
|
|
58
60
|
CSSUsage: LH.Artifacts['CSSUsage'];
|
|
59
61
|
devtoolsLog: import("../index.js").DevtoolsLog;
|
|
60
62
|
}, context: LH.Artifacts.ComputedContext): Promise<LH.Audit.ByteEfficiencyItem[]>;
|
|
@@ -134,15 +134,15 @@ class UnusedCSS {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
|
-
* @param {{CSSUsage: LH.Artifacts['CSSUsage'], devtoolsLog: LH.DevtoolsLog}} data
|
|
137
|
+
* @param {{Stylesheets: LH.Artifacts['Stylesheets'], CSSUsage: LH.Artifacts['CSSUsage'], devtoolsLog: LH.DevtoolsLog}} data
|
|
138
138
|
* @param {LH.Artifacts.ComputedContext} context
|
|
139
139
|
* @return {Promise<LH.Audit.ByteEfficiencyItem[]>}
|
|
140
140
|
*/
|
|
141
141
|
static async compute_(data, context) {
|
|
142
|
-
const {CSSUsage, devtoolsLog} = data;
|
|
142
|
+
const {CSSUsage, Stylesheets, devtoolsLog} = data;
|
|
143
143
|
const networkRecords = await NetworkRecords.request(devtoolsLog, context);
|
|
144
|
-
const indexedSheets = UnusedCSS.indexStylesheetsById(
|
|
145
|
-
UnusedCSS.indexUsedRules(CSSUsage
|
|
144
|
+
const indexedSheets = UnusedCSS.indexStylesheetsById(Stylesheets, networkRecords);
|
|
145
|
+
UnusedCSS.indexUsedRules(CSSUsage, indexedSheets);
|
|
146
146
|
|
|
147
147
|
const items = Object.keys(indexedSheets)
|
|
148
148
|
.map(sheetId => UnusedCSS.mapSheetToResult(indexedSheets[sheetId]));
|
|
@@ -150,5 +150,6 @@ class UnusedCSS {
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
const UnusedCSSComputed = makeComputedArtifact(UnusedCSS,
|
|
153
|
+
const UnusedCSSComputed = makeComputedArtifact(UnusedCSS,
|
|
154
|
+
['Stylesheets', 'CSSUsage', 'devtoolsLog']);
|
|
154
155
|
export {UnusedCSSComputed as UnusedCSS};
|
|
@@ -11,7 +11,6 @@ import url from 'url';
|
|
|
11
11
|
import isDeepEqual from 'lodash/isEqual.js';
|
|
12
12
|
|
|
13
13
|
import * as constants from './constants.js';
|
|
14
|
-
import {Budget} from './budget.js';
|
|
15
14
|
import ConfigPlugin from './config-plugin.js';
|
|
16
15
|
import {Runner} from '../runner.js';
|
|
17
16
|
import * as i18n from '../lib/i18n/i18n.js';
|
|
@@ -347,9 +346,6 @@ function resolveSettings(settingsJson = {}, overrides = undefined) {
|
|
|
347
346
|
true
|
|
348
347
|
);
|
|
349
348
|
|
|
350
|
-
if (settingsWithFlags.budgets) {
|
|
351
|
-
settingsWithFlags.budgets = Budget.initializeBudget(settingsWithFlags.budgets);
|
|
352
|
-
}
|
|
353
349
|
// Locale is special and comes only from flags/settings/lookupLocale.
|
|
354
350
|
settingsWithFlags.locale = locale;
|
|
355
351
|
|
package/core/config/constants.js
CHANGED
|
@@ -118,7 +118,6 @@ const defaultSettings = {
|
|
|
118
118
|
|
|
119
119
|
// the following settings have no defaults but we still want ensure that `key in settings`
|
|
120
120
|
// in config will work in a typechecked way
|
|
121
|
-
budgets: null,
|
|
122
121
|
locale: 'en-US', // actual default determined by Config using lib/i18n
|
|
123
122
|
blockedUrlPatterns: null,
|
|
124
123
|
additionalTraceCategories: null,
|