lighthouse 9.5.0-dev.20230124 → 9.5.0-dev.20230125
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/core/audits/accessibility/accesskeys.js +1 -1
- package/core/audits/accessibility/aria-allowed-attr.js +1 -1
- package/core/audits/accessibility/aria-command-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-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-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-active.js +1 -1
- package/core/audits/accessibility/duplicate-id-aria.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/image-alt.js +1 -1
- package/core/audits/accessibility/input-image-alt.js +1 -1
- package/core/audits/accessibility/label.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/tabindex.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/network-requests.js +7 -6
- package/core/computed/entity-classification.js +1 -1
- package/core/computed/metrics/responsiveness.js +5 -2
- package/core/computed/page-dependency-graph.js +1 -1
- package/core/gather/gatherers/accessibility.js +3 -1
- package/core/lib/network-request.d.ts +2 -0
- package/core/lib/network-request.js +3 -0
- package/core/lib/stack-packs.js +4 -0
- package/core/lib/tracehouse/trace-processor.d.ts +14 -5
- package/core/lib/tracehouse/trace-processor.js +85 -30
- package/core/lib/traces/metric-trace-events.js +1 -1
- package/package.json +4 -5
- package/shared/localization/locales/en-US.json +74 -44
- package/shared/localization/locales/en-XL.json +74 -44
- package/tsconfig.json +0 -2
- package/types/artifacts.d.ts +7 -2
- package/core/lib/minify-trace.d.ts +0 -6
- package/core/lib/minify-trace.js +0 -172
- package/core/util.cjs +0 -845
- package/core/util.d.cts +0 -342
package/core/lib/minify-trace.js
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright 2019 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
4
|
-
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/* eslint-disable no-console */
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @fileoverview Minifies a trace by removing unnecessary events, throttling screenshots, etc.
|
|
11
|
-
* See the following files for necessary events:
|
|
12
|
-
* - core/computed/page-dependency-graph.js
|
|
13
|
-
* - core/lib/dependency-graph/cpu-node.js
|
|
14
|
-
* - core/lib/tracehouse/trace-processor.js
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import {TraceProcessor} from './tracehouse/trace-processor.js';
|
|
18
|
-
|
|
19
|
-
const toplevelTaskNames = new Set([
|
|
20
|
-
'RunTask', // m71+
|
|
21
|
-
'ThreadControllerImpl::RunTask', // m69-70
|
|
22
|
-
'ThreadControllerImpl::DoWork', // m66-68
|
|
23
|
-
'TaskQueueManager::ProcessTaskFromWorkQueue', // m65 and below
|
|
24
|
-
]);
|
|
25
|
-
|
|
26
|
-
const traceCategoriesToAlwaysKeep = new Set([
|
|
27
|
-
// Labels the threads correctly in DevTools Performance panel
|
|
28
|
-
'__metadata',
|
|
29
|
-
]);
|
|
30
|
-
|
|
31
|
-
const traceEventsToAlwaysKeep = new Set([
|
|
32
|
-
'Screenshot',
|
|
33
|
-
'TracingStartedInBrowser',
|
|
34
|
-
'TracingStartedInPage',
|
|
35
|
-
'navigationStart',
|
|
36
|
-
'ParseAuthorStyleSheet',
|
|
37
|
-
'ParseHTML',
|
|
38
|
-
'PlatformResourceSendRequest',
|
|
39
|
-
'ResourceSendRequest',
|
|
40
|
-
'ResourceReceiveResponse',
|
|
41
|
-
'ResourceFinish',
|
|
42
|
-
'ResourceReceivedData',
|
|
43
|
-
'EventDispatch',
|
|
44
|
-
'LayoutShift',
|
|
45
|
-
'FrameCommittedInBrowser',
|
|
46
|
-
'EventTiming',
|
|
47
|
-
'Responsiveness.Renderer.UserInteraction',
|
|
48
|
-
// Not currently used by Lighthouse but might be used in the future for cross-frame LCP
|
|
49
|
-
'NavStartToLargestContentfulPaint::Invalidate::AllFrames::UKM',
|
|
50
|
-
'NavStartToLargestContentfulPaint::Candidate::AllFrames::UKM',
|
|
51
|
-
// Needed for CPU profiler task attribution
|
|
52
|
-
'Profile',
|
|
53
|
-
'ProfileChunk',
|
|
54
|
-
]);
|
|
55
|
-
|
|
56
|
-
const traceEventsToKeepInToplevelTask = new Set([
|
|
57
|
-
// Needed for CPU node timing simulations
|
|
58
|
-
'Layout',
|
|
59
|
-
'RunMicrotasks',
|
|
60
|
-
// All of these are needed to create graph relationships
|
|
61
|
-
'TimerInstall',
|
|
62
|
-
'TimerFire',
|
|
63
|
-
'InvalidateLayout',
|
|
64
|
-
'ScheduleStyleRecalculation',
|
|
65
|
-
'EvaluateScript',
|
|
66
|
-
'XHRReadyStateChange',
|
|
67
|
-
'FunctionCall',
|
|
68
|
-
'v8.compile',
|
|
69
|
-
'ParseAuthorStyleSheet',
|
|
70
|
-
'ResourceSendRequest',
|
|
71
|
-
]);
|
|
72
|
-
|
|
73
|
-
const traceEventsToKeepInProcess = new Set([
|
|
74
|
-
...toplevelTaskNames,
|
|
75
|
-
...traceEventsToKeepInToplevelTask,
|
|
76
|
-
|
|
77
|
-
// See the DevTools marker events
|
|
78
|
-
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/front_end/timeline_model/TimelineModel.js?q=-f:out%20f:TimelineModel%20%22MarkLoad:%20%27%22&ss=chromium
|
|
79
|
-
'firstPaint',
|
|
80
|
-
'firstContentfulPaint',
|
|
81
|
-
'firstMeaningfulPaint',
|
|
82
|
-
'firstMeaningfulPaintCandidate',
|
|
83
|
-
'loadEventEnd',
|
|
84
|
-
'MarkLoad',
|
|
85
|
-
'domContentLoadedEventEnd',
|
|
86
|
-
'MarkDOMContent',
|
|
87
|
-
'largestContentfulPaint::Invalidate',
|
|
88
|
-
'largestContentfulPaint::Candidate',
|
|
89
|
-
'Animation',
|
|
90
|
-
]);
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* @param {LH.TraceEvent[]} events
|
|
94
|
-
*/
|
|
95
|
-
function filterOutUnnecessaryTasksByNameAndDuration(events) {
|
|
96
|
-
const {pid} = TraceProcessor.findMainFrameIds(events);
|
|
97
|
-
|
|
98
|
-
return events.filter(evt => {
|
|
99
|
-
if (toplevelTaskNames.has(evt.name) && evt.dur < 1000) return false;
|
|
100
|
-
if (evt.pid === pid && traceEventsToKeepInProcess.has(evt.name)) return true;
|
|
101
|
-
if (traceCategoriesToAlwaysKeep.has(evt.cat)) return true;
|
|
102
|
-
return traceEventsToAlwaysKeep.has(evt.name);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Filters out tasks that are not within a toplevel task.
|
|
108
|
-
* @param {LH.TraceEvent[]} events
|
|
109
|
-
*/
|
|
110
|
-
function filterOutOrphanedTasks(events) {
|
|
111
|
-
const toplevelRanges = events
|
|
112
|
-
.filter(evt => toplevelTaskNames.has(evt.name))
|
|
113
|
-
.map(evt => [evt.ts, evt.ts + evt.dur]);
|
|
114
|
-
|
|
115
|
-
/** @param {LH.TraceEvent} e */
|
|
116
|
-
const isInToplevelTask = e => toplevelRanges.some(([start, end]) => e.ts >= start && e.ts <= end);
|
|
117
|
-
|
|
118
|
-
return events.filter((evt, index) => {
|
|
119
|
-
if (!traceEventsToKeepInToplevelTask.has(evt.name)) return true;
|
|
120
|
-
if (!isInToplevelTask(evt)) return false;
|
|
121
|
-
|
|
122
|
-
if (evt.ph === 'B') {
|
|
123
|
-
const endEvent = events.slice(index).find(e => e.name === evt.name && e.ph === 'E');
|
|
124
|
-
return endEvent && isInToplevelTask(endEvent);
|
|
125
|
-
} else {
|
|
126
|
-
return true;
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Throttles screenshot events in the trace to 2fps.
|
|
133
|
-
* @param {LH.TraceEvent[]} events
|
|
134
|
-
*/
|
|
135
|
-
function filterOutExcessiveScreenshots(events) {
|
|
136
|
-
const screenshotTimestamps = events.filter(evt => evt.name === 'Screenshot').map(evt => evt.ts);
|
|
137
|
-
|
|
138
|
-
let lastScreenshotTs = -Infinity;
|
|
139
|
-
return events.filter(evt => {
|
|
140
|
-
if (evt.name !== 'Screenshot') return true;
|
|
141
|
-
const timeSinceLastScreenshot = evt.ts - lastScreenshotTs;
|
|
142
|
-
const nextScreenshotTs = screenshotTimestamps.find(ts => ts > evt.ts);
|
|
143
|
-
const timeUntilNextScreenshot = nextScreenshotTs ? nextScreenshotTs - evt.ts : Infinity;
|
|
144
|
-
const threshold = 500 * 1000; // Throttle to ~2fps
|
|
145
|
-
// Keep the frame if it's been more than 500ms since the last frame we kept or the next frame won't happen for at least 500ms
|
|
146
|
-
const shouldKeep = timeUntilNextScreenshot > threshold || timeSinceLastScreenshot > threshold;
|
|
147
|
-
if (shouldKeep) lastScreenshotTs = evt.ts;
|
|
148
|
-
return shouldKeep;
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* @param {LH.TraceEvent[]} events
|
|
154
|
-
*/
|
|
155
|
-
function filterTraceEvents(events) {
|
|
156
|
-
// Filter out event names we don't care about and tasks <1ms
|
|
157
|
-
let filtered = filterOutUnnecessaryTasksByNameAndDuration(events);
|
|
158
|
-
// Filter out events not inside a toplevel task
|
|
159
|
-
filtered = filterOutOrphanedTasks(filtered);
|
|
160
|
-
// Filter down the screenshots to key moments + 2fps animations
|
|
161
|
-
return filterOutExcessiveScreenshots(filtered);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* @param {LH.Trace} inputTrace
|
|
166
|
-
* @return {LH.Trace}
|
|
167
|
-
*/
|
|
168
|
-
function minifyTrace(inputTrace) {
|
|
169
|
-
return {traceEvents: filterTraceEvents(inputTrace.traceEvents)};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export {minifyTrace};
|