lighthouse 9.5.0-dev.20230123 → 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/.codecov.yml +0 -5
- 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/audit.js +1 -1
- package/core/audits/byte-efficiency/legacy-javascript.d.ts +1 -0
- package/core/audits/byte-efficiency/legacy-javascript.js +7 -3
- package/core/audits/dobetterweb/uses-http2.d.ts +5 -2
- package/core/audits/dobetterweb/uses-http2.js +12 -7
- package/core/audits/network-requests.js +7 -6
- package/core/audits/third-party-facades.d.ts +3 -2
- package/core/audits/third-party-facades.js +12 -9
- package/core/audits/third-party-summary.d.ts +7 -6
- package/core/audits/third-party-summary.js +16 -14
- package/core/audits/valid-source-maps.d.ts +5 -3
- package/core/audits/valid-source-maps.js +11 -9
- package/core/computed/entity-classification.d.ts +29 -0
- package/core/computed/entity-classification.js +102 -0
- package/core/computed/metrics/responsiveness.js +5 -2
- package/core/computed/page-dependency-graph.js +1 -1
- package/core/computed/resource-summary.d.ts +4 -2
- package/core/computed/resource-summary.js +8 -5
- 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/core/lib/url-utils.js +1 -1
- package/core/runner.d.ts +10 -0
- package/core/runner.js +48 -0
- package/dist/report/bundle.esm.js +724 -687
- package/dist/report/flow.js +25 -15
- package/dist/report/standalone.js +25 -15
- package/flow-report/src/common.tsx +1 -1
- package/flow-report/src/i18n/i18n.tsx +17 -16
- package/flow-report/src/sidebar/sidebar.tsx +2 -2
- package/flow-report/src/summary/category.tsx +6 -6
- package/flow-report/src/summary/summary.tsx +2 -2
- package/package.json +7 -8
- package/report/renderer/category-renderer.js +19 -17
- package/report/renderer/crc-details-renderer.js +6 -6
- package/report/renderer/details-renderer.js +7 -6
- package/report/renderer/dom.js +1 -1
- package/report/renderer/element-screenshot-renderer.js +3 -3
- package/report/renderer/performance-category-renderer.js +17 -15
- package/report/renderer/pwa-category-renderer.js +5 -4
- package/report/renderer/report-globals.d.ts +21 -0
- package/report/renderer/report-globals.js +49 -0
- package/report/renderer/report-renderer.js +22 -20
- package/report/renderer/report-ui-features.js +9 -8
- package/report/renderer/report-utils.d.ts +116 -0
- package/report/renderer/{util.js → report-utils.js} +81 -429
- package/report/renderer/snippet-renderer.js +3 -2
- package/report/test/renderer/category-renderer-test.js +9 -4
- package/report/test/renderer/crc-details-renderer-test.js +7 -3
- package/report/test/renderer/details-renderer-test.js +7 -3
- package/report/test/renderer/dom-test.js +7 -3
- package/report/test/renderer/element-screenshot-renderer-test.js +8 -4
- package/report/test/renderer/performance-category-renderer-test.js +14 -9
- package/report/test/renderer/pwa-category-renderer-test.js +10 -5
- package/report/test/renderer/report-renderer-test.js +2 -2
- package/report/test/renderer/report-ui-features-test.js +3 -3
- package/report/test/renderer/{util-test.js → report-utils-test.js} +36 -234
- package/report/test/renderer/snippet-renderer-test.js +7 -3
- package/shared/localization/format.js +5 -2
- package/shared/localization/locales/ar-XB.json +50 -50
- package/shared/localization/locales/ar.json +50 -50
- package/shared/localization/locales/bg.json +50 -50
- package/shared/localization/locales/ca.json +50 -50
- package/shared/localization/locales/cs.json +50 -50
- package/shared/localization/locales/da.json +50 -50
- package/shared/localization/locales/de.json +50 -50
- package/shared/localization/locales/el.json +50 -50
- package/shared/localization/locales/en-GB.json +50 -50
- package/shared/localization/locales/en-US.json +128 -98
- package/shared/localization/locales/en-XA.json +50 -50
- package/shared/localization/locales/en-XL.json +128 -98
- package/shared/localization/locales/es-419.json +50 -50
- package/shared/localization/locales/es.json +50 -50
- package/shared/localization/locales/fi.json +50 -50
- package/shared/localization/locales/fil.json +50 -50
- package/shared/localization/locales/fr.json +50 -50
- package/shared/localization/locales/he.json +50 -50
- package/shared/localization/locales/hi.json +50 -50
- package/shared/localization/locales/hr.json +50 -50
- package/shared/localization/locales/hu.json +50 -50
- package/shared/localization/locales/id.json +50 -50
- package/shared/localization/locales/it.json +50 -50
- package/shared/localization/locales/ja.json +50 -50
- package/shared/localization/locales/ko.json +50 -50
- package/shared/localization/locales/lt.json +50 -50
- package/shared/localization/locales/lv.json +50 -50
- package/shared/localization/locales/nl.json +50 -50
- package/shared/localization/locales/no.json +50 -50
- package/shared/localization/locales/pl.json +50 -50
- package/shared/localization/locales/pt-PT.json +50 -50
- package/shared/localization/locales/pt.json +50 -50
- package/shared/localization/locales/ro.json +50 -50
- package/shared/localization/locales/ru.json +50 -50
- package/shared/localization/locales/sk.json +50 -50
- package/shared/localization/locales/sl.json +50 -50
- package/shared/localization/locales/sr-Latn.json +50 -50
- package/shared/localization/locales/sr.json +50 -50
- package/shared/localization/locales/sv.json +50 -50
- package/shared/localization/locales/ta.json +50 -50
- package/shared/localization/locales/te.json +50 -50
- package/shared/localization/locales/th.json +50 -50
- package/shared/localization/locales/tr.json +50 -50
- package/shared/localization/locales/uk.json +50 -50
- package/shared/localization/locales/vi.json +50 -50
- package/shared/localization/locales/zh-HK.json +50 -50
- package/shared/localization/locales/zh-TW.json +50 -50
- package/shared/localization/locales/zh.json +50 -50
- package/shared/test/util-test.js +214 -0
- package/shared/util.d.ts +122 -0
- package/shared/util.js +332 -0
- package/tsconfig.json +0 -2
- package/types/artifacts.d.ts +21 -2
- package/types/lhr/lhr.d.ts +33 -0
- 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/report/renderer/util.d.ts +0 -342
package/types/artifacts.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type { TaskNode as _TaskNode } from '../core/lib/tracehouse/main-thread-t
|
|
|
17
17
|
import AuditDetails from './lhr/audit-details.js'
|
|
18
18
|
import Config from './config.js';
|
|
19
19
|
import Gatherer from './gatherer.js';
|
|
20
|
+
import {IEntity} from 'third-party-web';
|
|
20
21
|
import {IcuMessage} from './lhr/i18n.js';
|
|
21
22
|
import LHResult from './lhr/lhr.js'
|
|
22
23
|
import Protocol from './protocol.js';
|
|
@@ -720,12 +721,16 @@ declare module Artifacts {
|
|
|
720
721
|
frameEvents: Array<TraceEvent>;
|
|
721
722
|
/** The subset of trace events from the main frame and any child frames, sorted by timestamp. */
|
|
722
723
|
frameTreeEvents: Array<TraceEvent>;
|
|
723
|
-
/** IDs for the trace's main frame, process,
|
|
724
|
-
|
|
724
|
+
/** IDs for the trace's main frame, and process. The startingPid is the initial process id, however cross-origin navigations may incur changes to the pid while the frame ID remains identical. */
|
|
725
|
+
mainFrameInfo: {startingPid: number, frameId: string};
|
|
725
726
|
/** The list of frames committed in the trace. */
|
|
726
727
|
frames: Array<{id: string, url: string}>;
|
|
727
728
|
/** The trace event marking the time at which the run should consider to have begun. Typically the same as the navigationStart but might differ due to SPA navigations, client-side redirects, etc. In the FR timespan case, this event is injected by Lighthouse itself. */
|
|
728
729
|
timeOriginEvt: TraceEvent;
|
|
730
|
+
/** All received trace events subsetted to important categories. */
|
|
731
|
+
_keyEvents: Array<TraceEvent>;
|
|
732
|
+
/** Map where keys are process IDs and their values are thread IDs */
|
|
733
|
+
_rendererPidToTid: Map<number, number>;
|
|
729
734
|
}
|
|
730
735
|
|
|
731
736
|
interface ProcessedNavigation {
|
|
@@ -925,6 +930,19 @@ declare module Artifacts {
|
|
|
925
930
|
/** The MIME type of the underlying image file. */
|
|
926
931
|
mimeType?: string;
|
|
927
932
|
}
|
|
933
|
+
|
|
934
|
+
interface Entity extends IEntity {
|
|
935
|
+
isUnrecognized?: boolean;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
interface EntityClassification {
|
|
939
|
+
urlsByEntity: Map<Entity, Set<string>>;
|
|
940
|
+
entityByUrl: Map<string, Entity>;
|
|
941
|
+
firstParty?: Entity;
|
|
942
|
+
|
|
943
|
+
// Convenience methods.
|
|
944
|
+
isFirstParty: (url: string) => boolean;
|
|
945
|
+
}
|
|
928
946
|
}
|
|
929
947
|
|
|
930
948
|
export interface Trace {
|
|
@@ -959,6 +977,7 @@ export interface TraceEvent {
|
|
|
959
977
|
};
|
|
960
978
|
data?: {
|
|
961
979
|
frame?: string;
|
|
980
|
+
processId?: number;
|
|
962
981
|
isLoadingMainFrame?: boolean;
|
|
963
982
|
documentLoaderURL?: string;
|
|
964
983
|
frames?: {
|
package/types/lhr/lhr.d.ts
CHANGED
|
@@ -56,6 +56,8 @@ interface Result {
|
|
|
56
56
|
};
|
|
57
57
|
/** An array containing the result of all stack packs. */
|
|
58
58
|
stackPacks?: Result.StackPack[];
|
|
59
|
+
/** All the origins encountered during this Lighthouse run, and information about what web property (aka "entity") they belong to. Won't be present for snapshot mode. */
|
|
60
|
+
entities?: Result.Entities;
|
|
59
61
|
/** Screenshot taken of the full page, with node rects referencing audit results. If there was an error with collection, this is null. If disabled via the disableFullPageScreenshot setting, this is undefined. */
|
|
60
62
|
fullPageScreenshot?: Result.FullPageScreenshot | null;
|
|
61
63
|
}
|
|
@@ -151,6 +153,37 @@ declare module Result {
|
|
|
151
153
|
nodes: Record<string, AuditDetails.Rect>;
|
|
152
154
|
}
|
|
153
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Entity classification for the run, for resolving URLs/items to entities in report.
|
|
158
|
+
* The two lookup tables (LUT) below provide space-optimized, O(1) index lookup into entities.list.
|
|
159
|
+
*/
|
|
160
|
+
interface Entities {
|
|
161
|
+
/** All entities (1st and 3rd party) discovered during the run */
|
|
162
|
+
list: Array<LhrEntity>;
|
|
163
|
+
/** Name of the first-party entity */
|
|
164
|
+
firstParty?: string;
|
|
165
|
+
/** Entity-name to entity index lookup table */
|
|
166
|
+
entityIndexByName: Record<string, number>;
|
|
167
|
+
/** URL origin to entity index lookup table */
|
|
168
|
+
entityIndexByOrigin: Record<string, number>;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* An entity that's either recognized by third-party-web or made up by Lighthouse.
|
|
173
|
+
*/
|
|
174
|
+
interface LhrEntity {
|
|
175
|
+
/** Name of the entity. Maps to third-party-web unique name for recognized entities and a root domain name for the unrecognized. */
|
|
176
|
+
name: string;
|
|
177
|
+
/** Homepage URL for a recognized entity, if available in third-party-web. */
|
|
178
|
+
homepage?: string;
|
|
179
|
+
/** Category name that the entity belongs to, if available. */
|
|
180
|
+
category?: string;
|
|
181
|
+
/** Is this entity the first party? */
|
|
182
|
+
isFirstParty?: boolean;
|
|
183
|
+
/** Is this entity recognized by third-party-web? */
|
|
184
|
+
isUnrecognized?: boolean;
|
|
185
|
+
}
|
|
186
|
+
|
|
154
187
|
/**
|
|
155
188
|
* Info about an `LH.IcuMessage` value that was localized to a string when
|
|
156
189
|
* included in the LHR. Value is either a
|
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};
|