lighthouse 9.5.0-dev.20230124 → 9.5.0-dev.20230126

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.
Files changed (77) hide show
  1. package/core/audits/accessibility/accesskeys.js +1 -1
  2. package/core/audits/accessibility/aria-allowed-attr.js +1 -1
  3. package/core/audits/accessibility/aria-command-name.js +1 -1
  4. package/core/audits/accessibility/aria-hidden-body.js +1 -1
  5. package/core/audits/accessibility/aria-hidden-focus.js +1 -1
  6. package/core/audits/accessibility/aria-input-field-name.js +1 -1
  7. package/core/audits/accessibility/aria-meter-name.js +1 -1
  8. package/core/audits/accessibility/aria-progressbar-name.js +1 -1
  9. package/core/audits/accessibility/aria-required-attr.js +1 -1
  10. package/core/audits/accessibility/aria-required-children.js +1 -1
  11. package/core/audits/accessibility/aria-required-parent.js +1 -1
  12. package/core/audits/accessibility/aria-roles.js +1 -1
  13. package/core/audits/accessibility/aria-toggle-field-name.js +1 -1
  14. package/core/audits/accessibility/aria-tooltip-name.js +1 -1
  15. package/core/audits/accessibility/aria-treeitem-name.js +1 -1
  16. package/core/audits/accessibility/aria-valid-attr-value.js +1 -1
  17. package/core/audits/accessibility/aria-valid-attr.js +1 -1
  18. package/core/audits/accessibility/button-name.js +1 -1
  19. package/core/audits/accessibility/bypass.js +1 -1
  20. package/core/audits/accessibility/color-contrast.js +1 -1
  21. package/core/audits/accessibility/definition-list.js +1 -1
  22. package/core/audits/accessibility/dlitem.js +1 -1
  23. package/core/audits/accessibility/document-title.js +1 -1
  24. package/core/audits/accessibility/duplicate-id-active.js +1 -1
  25. package/core/audits/accessibility/duplicate-id-aria.js +1 -1
  26. package/core/audits/accessibility/form-field-multiple-labels.js +1 -1
  27. package/core/audits/accessibility/frame-title.js +1 -1
  28. package/core/audits/accessibility/heading-order.js +1 -1
  29. package/core/audits/accessibility/html-has-lang.js +1 -1
  30. package/core/audits/accessibility/html-lang-valid.js +1 -1
  31. package/core/audits/accessibility/image-alt.js +1 -1
  32. package/core/audits/accessibility/input-image-alt.js +1 -1
  33. package/core/audits/accessibility/label.js +1 -1
  34. package/core/audits/accessibility/link-name.js +1 -1
  35. package/core/audits/accessibility/list.js +1 -1
  36. package/core/audits/accessibility/listitem.js +1 -1
  37. package/core/audits/accessibility/meta-refresh.js +1 -1
  38. package/core/audits/accessibility/meta-viewport.js +1 -1
  39. package/core/audits/accessibility/object-alt.js +1 -1
  40. package/core/audits/accessibility/tabindex.js +1 -1
  41. package/core/audits/accessibility/td-headers-attr.js +1 -1
  42. package/core/audits/accessibility/th-has-data-cells.js +1 -1
  43. package/core/audits/accessibility/valid-lang.js +1 -1
  44. package/core/audits/accessibility/video-caption.js +1 -1
  45. package/core/audits/byte-efficiency/legacy-javascript.js +1 -2
  46. package/core/audits/network-requests.js +7 -6
  47. package/core/audits/preload-lcp-image.d.ts +12 -3
  48. package/core/audits/preload-lcp-image.js +32 -13
  49. package/core/computed/entity-classification.js +1 -1
  50. package/core/computed/metrics/responsiveness.js +5 -2
  51. package/core/computed/page-dependency-graph.js +1 -1
  52. package/core/config/constants.d.ts +2 -2
  53. package/core/config/constants.js +2 -2
  54. package/core/gather/gatherers/accessibility.js +3 -1
  55. package/core/gather/gatherers/trace-elements.js +1 -1
  56. package/core/lib/network-request.d.ts +2 -0
  57. package/core/lib/network-request.js +3 -0
  58. package/core/lib/stack-packs.js +4 -0
  59. package/core/lib/tracehouse/trace-processor.d.ts +14 -5
  60. package/core/lib/tracehouse/trace-processor.js +85 -30
  61. package/core/lib/traces/metric-trace-events.js +1 -1
  62. package/dist/report/bundle.esm.js +1 -1
  63. package/dist/report/flow.js +1 -1
  64. package/dist/report/standalone.js +1 -1
  65. package/package.json +4 -5
  66. package/report/assets/styles.css +1 -1
  67. package/report/renderer/components.js +1 -1
  68. package/report/test/generator/report-generator-test.js +2 -2
  69. package/report/test/renderer/performance-category-renderer-test.js +2 -2
  70. package/shared/localization/locales/en-US.json +74 -44
  71. package/shared/localization/locales/en-XL.json +74 -44
  72. package/tsconfig.json +0 -2
  73. package/types/artifacts.d.ts +9 -2
  74. package/core/lib/minify-trace.d.ts +0 -6
  75. package/core/lib/minify-trace.js +0 -172
  76. package/core/util.cjs +0 -845
  77. package/core/util.d.cts +0 -342
@@ -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};