browsertime 16.17.0 → 17.0.0-beta.1
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/CHANGELOG.md +44 -0
- package/bin/browsertime.js +43 -43
- package/bin/browsertimeWebPageReplay.js +10 -9
- package/browserscripts/pageinfo/generator.js +1 -1
- package/index.js +14 -13
- package/lib/android/gnirehtet.js +14 -15
- package/lib/android/index.js +92 -89
- package/lib/android/root.js +6 -9
- package/lib/chrome/chromeDevtoolsProtocol.js +46 -45
- package/lib/chrome/har.js +12 -13
- package/lib/chrome/longTaskMetrics.js +3 -5
- package/lib/chrome/parseCpuTrace.js +13 -10
- package/lib/chrome/settings/chromeAndroidOptions.js +1 -3
- package/lib/chrome/settings/chromeDesktopOptions.js +1 -3
- package/lib/chrome/settings/traceCategories.js +1 -3
- package/lib/chrome/traceCategoriesParser.js +35 -36
- package/lib/chrome/webdriver/builder.js +18 -26
- package/lib/chrome/webdriver/chromium.js +56 -46
- package/lib/chrome/webdriver/setupChromiumOptions.js +32 -27
- package/lib/connectivity/humble.js +13 -14
- package/lib/connectivity/index.js +74 -77
- package/lib/connectivity/trafficShapeParser.js +31 -35
- package/lib/core/engine/collector.js +22 -22
- package/lib/core/engine/command/addText.js +24 -27
- package/lib/core/engine/command/android.js +7 -11
- package/lib/core/engine/command/cache.js +3 -4
- package/lib/core/engine/command/chromeDevToolsProtocol.js +20 -20
- package/lib/core/engine/command/click.js +48 -49
- package/lib/core/engine/command/debug.js +3 -4
- package/lib/core/engine/command/javaScript.js +18 -19
- package/lib/core/engine/command/measure.js +31 -37
- package/lib/core/engine/command/meta.js +1 -4
- package/lib/core/engine/command/mouse/clickAndHold.js +36 -39
- package/lib/core/engine/command/mouse/contextClick.js +17 -18
- package/lib/core/engine/command/mouse/doubleClick.js +17 -19
- package/lib/core/engine/command/mouse/index.js +5 -9
- package/lib/core/engine/command/mouse/mouseMove.js +19 -23
- package/lib/core/engine/command/mouse/singleClick.js +15 -19
- package/lib/core/engine/command/navigation.js +12 -14
- package/lib/core/engine/command/screenshot.js +1 -4
- package/lib/core/engine/command/scroll.js +4 -7
- package/lib/core/engine/command/select.js +26 -26
- package/lib/core/engine/command/set.js +25 -23
- package/lib/core/engine/command/stopWatch.js +5 -8
- package/lib/core/engine/command/switch.js +18 -20
- package/lib/core/engine/command/util/lcpHighlightScript.js +1 -2
- package/lib/core/engine/command/util/lsHighlightScript.js +1 -2
- package/lib/core/engine/command/wait.js +18 -18
- package/lib/core/engine/index.js +82 -72
- package/lib/core/engine/iteration.js +83 -79
- package/lib/core/engine/run.js +5 -9
- package/lib/core/pageCompleteChecks/defaultPageCompleteCheck.js +1 -2
- package/lib/core/pageCompleteChecks/pageCompleteCheckByInactivity.js +1 -3
- package/lib/core/pageCompleteChecks/spaInactivity.js +1 -3
- package/lib/core/seleniumRunner.js +92 -100
- package/lib/core/webdriver/index.js +24 -21
- package/lib/edge/webdriver/builder.js +21 -26
- package/lib/extensionserver/httpServer.js +17 -21
- package/lib/extensionserver/index.js +8 -12
- package/lib/extensionserver/setup.js +12 -12
- package/lib/firefox/geckoProfiler.js +27 -21
- package/lib/firefox/getHAR.js +7 -8
- package/lib/firefox/memoryReport.js +9 -11
- package/lib/firefox/perfStats.js +5 -7
- package/lib/firefox/settings/disableSafeBrowsingPreferences.js +1 -3
- package/lib/firefox/settings/disableTrackingProtectionPreferences.js +1 -3
- package/lib/firefox/settings/firefoxPreferences.js +2 -4
- package/lib/firefox/settings/geckoProfilerDefaults.js +5 -9
- package/lib/firefox/webdriver/builder.js +66 -63
- package/lib/firefox/webdriver/firefox.js +44 -49
- package/lib/safari/webdriver/builder.js +4 -5
- package/lib/safari/webdriver/safari.js +4 -8
- package/lib/screenshot/defaults.js +1 -3
- package/lib/screenshot/index.js +24 -21
- package/lib/support/browserScript.js +65 -56
- package/lib/support/cli.js +120 -87
- package/lib/support/dns.js +6 -7
- package/lib/support/engineUtils.js +85 -38
- package/lib/support/errors.js +4 -13
- package/lib/support/fileUtil.js +81 -68
- package/lib/support/filters.js +15 -20
- package/lib/support/getViewPort.js +6 -7
- package/lib/support/har/index.js +208 -216
- package/lib/support/images/index.js +54 -26
- package/lib/support/logging.js +20 -17
- package/lib/support/pathToFolder.js +18 -23
- package/lib/support/preURL.js +5 -6
- package/lib/support/processes.js +4 -6
- package/lib/support/setResourceTimingBufferSize.js +2 -4
- package/lib/support/statistics.js +58 -56
- package/lib/support/stop.js +7 -8
- package/lib/support/storageManager.js +44 -44
- package/lib/support/tcpdump.js +22 -16
- package/lib/support/userTiming.js +7 -13
- package/lib/support/util.js +204 -224
- package/lib/support/xvfb.js +11 -13
- package/lib/video/defaults.js +6 -10
- package/lib/video/postprocessing/finetune/addTextToVideo.js +15 -15
- package/lib/video/postprocessing/finetune/convertFps.js +14 -8
- package/lib/video/postprocessing/finetune/getFont.js +7 -9
- package/lib/video/postprocessing/finetune/getTimingMetrics.js +19 -18
- package/lib/video/postprocessing/finetune/index.js +40 -36
- package/lib/video/postprocessing/finetune/removeOrange.js +10 -11
- package/lib/video/postprocessing/visualmetrics/extraMetrics.js +17 -13
- package/lib/video/postprocessing/visualmetrics/getVideoMetrics.js +12 -13
- package/lib/video/postprocessing/visualmetrics/visualMetrics.js +117 -128
- package/lib/video/screenRecording/android/recorder.js +12 -17
- package/lib/video/screenRecording/desktop/convert.js +13 -11
- package/lib/video/screenRecording/desktop/desktopRecorder.js +29 -24
- package/lib/video/screenRecording/desktop/ffmpegRecorder.js +60 -63
- package/lib/video/screenRecording/desktop/osx/getSPDisplaysDataType.js +4 -6
- package/lib/video/screenRecording/desktop/osx/getScreen.js +9 -10
- package/lib/video/screenRecording/firefox/firefoxWindowRecorder.js +54 -54
- package/lib/video/screenRecording/ios/convertToMp4.js +10 -11
- package/lib/video/screenRecording/ios/iosRecorder.js +23 -21
- package/lib/video/screenRecording/iosSimulator/convertToMp4.js +10 -11
- package/lib/video/screenRecording/iosSimulator/recorder.js +10 -9
- package/lib/video/screenRecording/recorder.js +8 -9
- package/lib/video/screenRecording/setOrangeBackground.js +5 -6
- package/lib/video/video.js +28 -34
- package/package.json +19 -17
package/lib/support/har/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import merge from 'lodash.merge';
|
|
3
|
+
import pick from 'lodash.pick';
|
|
4
|
+
import isEmpty from 'lodash.isempty';
|
|
5
|
+
import get from 'lodash.get';
|
|
6
|
+
import dayjs from 'dayjs';
|
|
7
|
+
import pathToFolder from '../pathToFolder.js';
|
|
8
|
+
import intel from 'intel';
|
|
9
|
+
const log = intel.getLogger('browsertime');
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
const version = require('../../../package.json').version;
|
|
11
12
|
|
|
12
13
|
function generateUniquePageId(baseId, existingIdMap) {
|
|
13
14
|
let newId = baseId;
|
|
@@ -19,9 +20,9 @@ function generateUniquePageId(baseId, existingIdMap) {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
function getDocumentRequests(entries, pageId) {
|
|
22
|
-
let pageEntries =
|
|
23
|
+
let pageEntries = [...entries];
|
|
23
24
|
if (pageId) {
|
|
24
|
-
pageEntries =
|
|
25
|
+
pageEntries = [...entries.filter(entry => entry.pageref === pageId)];
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
const requests = [];
|
|
@@ -61,7 +62,7 @@ function addExtrasToHAR(
|
|
|
61
62
|
// We add the timings both as a hidden field and add
|
|
62
63
|
// in pageTimings so we can easily show them in PerfCascade
|
|
63
64
|
if (visualMetricsData) {
|
|
64
|
-
const DO_NOT_INCLUDE_IN_HAR_TIMINGS = [
|
|
65
|
+
const DO_NOT_INCLUDE_IN_HAR_TIMINGS = new Set([
|
|
65
66
|
'VisualReadiness',
|
|
66
67
|
'videoRecordingStart',
|
|
67
68
|
'SpeedIndex',
|
|
@@ -70,10 +71,10 @@ function addExtrasToHAR(
|
|
|
70
71
|
'VisualProgress',
|
|
71
72
|
'ContentfulSpeedIndexProgress',
|
|
72
73
|
'PerceptualSpeedIndexProgress'
|
|
73
|
-
];
|
|
74
|
+
]);
|
|
74
75
|
|
|
75
76
|
for (let key of Object.keys(visualMetricsData)) {
|
|
76
|
-
if (DO_NOT_INCLUDE_IN_HAR_TIMINGS.
|
|
77
|
+
if (!DO_NOT_INCLUDE_IN_HAR_TIMINGS.has(key)) {
|
|
77
78
|
harPageTimings['_' + key.charAt(0).toLowerCase() + key.slice(1)] =
|
|
78
79
|
visualMetricsData[key];
|
|
79
80
|
_visualMetrics[key] = visualMetricsData[key];
|
|
@@ -157,183 +158,214 @@ function jsonifyVisualProgress(visualProgress) {
|
|
|
157
158
|
return visualProgressJSON;
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
comment
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
if (!comment) {
|
|
171
|
-
delete har.log.browser.comment;
|
|
161
|
+
export function addBrowser(har, name, version, comment) {
|
|
162
|
+
merge(har.log, {
|
|
163
|
+
browser: {
|
|
164
|
+
name,
|
|
165
|
+
version,
|
|
166
|
+
comment
|
|
172
167
|
}
|
|
168
|
+
});
|
|
173
169
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
addCreator: function (har, comment) {
|
|
178
|
-
merge(har.log, {
|
|
179
|
-
creator: {
|
|
180
|
-
name: 'Browsertime',
|
|
181
|
-
version: version,
|
|
182
|
-
comment: comment
|
|
183
|
-
}
|
|
184
|
-
});
|
|
170
|
+
if (!comment) {
|
|
171
|
+
delete har.log.browser.comment;
|
|
172
|
+
}
|
|
185
173
|
|
|
186
|
-
|
|
187
|
-
|
|
174
|
+
return har;
|
|
175
|
+
}
|
|
176
|
+
export function addCreator(har, comment) {
|
|
177
|
+
merge(har.log, {
|
|
178
|
+
creator: {
|
|
179
|
+
name: 'Browsertime',
|
|
180
|
+
version: version,
|
|
181
|
+
comment: comment
|
|
188
182
|
}
|
|
183
|
+
});
|
|
189
184
|
|
|
190
|
-
|
|
191
|
-
|
|
185
|
+
if (!comment) {
|
|
186
|
+
delete har.log.creator.comment;
|
|
187
|
+
}
|
|
192
188
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
189
|
+
return har;
|
|
190
|
+
}
|
|
191
|
+
export function getMainDocumentTimings(har) {
|
|
192
|
+
const timings = [];
|
|
193
|
+
const entries = [...har.log.entries];
|
|
196
194
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
195
|
+
for (let page of har.log.pages) {
|
|
196
|
+
const pageId = page.id;
|
|
197
|
+
const url = page._url;
|
|
200
198
|
|
|
201
|
-
|
|
202
|
-
|
|
199
|
+
let pageEntries = [...entries];
|
|
200
|
+
const finalURL = getFinalURL(pageEntries, pageId);
|
|
203
201
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
202
|
+
pageEntries = [
|
|
203
|
+
...pageEntries.filter(
|
|
204
|
+
entry => entry.pageref === pageId && entry.request.url === finalURL
|
|
205
|
+
)
|
|
206
|
+
];
|
|
209
207
|
|
|
210
|
-
|
|
208
|
+
timings.push({ url, timings: pageEntries[0].timings });
|
|
209
|
+
}
|
|
210
|
+
return timings;
|
|
211
|
+
}
|
|
212
|
+
export function getFullyLoaded(har) {
|
|
213
|
+
const fullyLoaded = [];
|
|
214
|
+
const entries = [...har.log.entries];
|
|
215
|
+
|
|
216
|
+
for (let page of har.log.pages) {
|
|
217
|
+
const pageStartDateTime = new Date(page.startedDateTime).getTime();
|
|
218
|
+
const pageId = page.id;
|
|
219
|
+
const url = page._url;
|
|
220
|
+
|
|
221
|
+
let pageEntries = [...entries];
|
|
222
|
+
pageEntries = [...pageEntries.filter(entry => entry.pageref === pageId)];
|
|
223
|
+
|
|
224
|
+
let pageEnd = 0;
|
|
225
|
+
for (let entry of pageEntries) {
|
|
226
|
+
let entryEnd =
|
|
227
|
+
new Date(entry.startedDateTime).getTime() +
|
|
228
|
+
entry.time -
|
|
229
|
+
new Date(pageStartDateTime).getTime();
|
|
230
|
+
if (entryEnd > pageEnd) {
|
|
231
|
+
pageEnd = entryEnd;
|
|
232
|
+
}
|
|
211
233
|
}
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
fullyLoaded.push({ url, fullyLoaded: Number(pageEnd.toFixed(0)) });
|
|
235
|
+
}
|
|
236
|
+
return fullyLoaded;
|
|
237
|
+
}
|
|
238
|
+
export function mergeHars(hars) {
|
|
239
|
+
if (isEmpty(hars)) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (hars.length === 1) {
|
|
243
|
+
return hars[0];
|
|
244
|
+
}
|
|
245
|
+
let firstLog = hars[0].log;
|
|
246
|
+
let combinedHar = {
|
|
247
|
+
log: pick(firstLog, ['version', 'creator', 'browser', 'comment'])
|
|
248
|
+
};
|
|
249
|
+
let pagesById = new Map();
|
|
250
|
+
let allEntries = [];
|
|
251
|
+
|
|
252
|
+
for (const har of hars) {
|
|
253
|
+
let pages = har.log.pages;
|
|
254
|
+
let entries = har.log.entries;
|
|
255
|
+
for (const page of pages) {
|
|
256
|
+
let pageId = page.id;
|
|
257
|
+
if (pagesById.has(pageId)) {
|
|
258
|
+
const oldPageId = pageId;
|
|
259
|
+
pageId = generateUniquePageId(oldPageId, pagesById);
|
|
260
|
+
page.id = pageId;
|
|
261
|
+
entries = entries.map(entry => {
|
|
262
|
+
if (entry.pageref === oldPageId) {
|
|
263
|
+
entry.pageref = pageId;
|
|
264
|
+
}
|
|
265
|
+
return entry;
|
|
266
|
+
});
|
|
237
267
|
}
|
|
238
|
-
|
|
268
|
+
pagesById.set(pageId, page);
|
|
239
269
|
}
|
|
240
|
-
|
|
241
|
-
}
|
|
270
|
+
allEntries = [...allEntries, ...entries];
|
|
271
|
+
}
|
|
242
272
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
let allEntries = [];
|
|
256
|
-
|
|
257
|
-
hars.forEach(har => {
|
|
258
|
-
let pages = har.log.pages;
|
|
259
|
-
let entries = har.log.entries;
|
|
260
|
-
pages.forEach(page => {
|
|
261
|
-
let pageId = page.id;
|
|
262
|
-
if (pagesById.has(pageId)) {
|
|
263
|
-
const oldPageId = pageId;
|
|
264
|
-
pageId = generateUniquePageId(oldPageId, pagesById);
|
|
265
|
-
page.id = pageId;
|
|
266
|
-
entries = entries.map(entry => {
|
|
267
|
-
if (entry.pageref === oldPageId) {
|
|
268
|
-
entry.pageref = pageId;
|
|
269
|
-
}
|
|
270
|
-
return entry;
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
pagesById.set(pageId, page);
|
|
274
|
-
});
|
|
275
|
-
allEntries = allEntries.concat(entries);
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
combinedHar.log.pages = Array.from(pagesById.values());
|
|
279
|
-
combinedHar.log.entries = allEntries;
|
|
280
|
-
|
|
281
|
-
return combinedHar;
|
|
282
|
-
},
|
|
283
|
-
|
|
284
|
-
getEmptyHAR(url, browser) {
|
|
285
|
-
return {
|
|
286
|
-
log: {
|
|
287
|
-
version: '1.2',
|
|
288
|
-
creator: {
|
|
289
|
-
name: 'Browsertime',
|
|
290
|
-
version: version,
|
|
291
|
-
comment: ''
|
|
292
|
-
},
|
|
293
|
-
browser: {
|
|
294
|
-
name: browser,
|
|
295
|
-
version: ''
|
|
296
|
-
},
|
|
297
|
-
pages: [
|
|
298
|
-
{
|
|
299
|
-
startedDateTime: dayjs().format(),
|
|
300
|
-
id: 'failing_page',
|
|
301
|
-
title: url,
|
|
302
|
-
pageTimings: {},
|
|
303
|
-
comment: ''
|
|
304
|
-
}
|
|
305
|
-
],
|
|
306
|
-
entries: [],
|
|
273
|
+
combinedHar.log.pages = [...pagesById.values()];
|
|
274
|
+
combinedHar.log.entries = allEntries;
|
|
275
|
+
|
|
276
|
+
return combinedHar;
|
|
277
|
+
}
|
|
278
|
+
export function getEmptyHAR(url, browser) {
|
|
279
|
+
return {
|
|
280
|
+
log: {
|
|
281
|
+
version: '1.2',
|
|
282
|
+
creator: {
|
|
283
|
+
name: 'Browsertime',
|
|
284
|
+
version: version,
|
|
307
285
|
comment: ''
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
286
|
+
},
|
|
287
|
+
browser: {
|
|
288
|
+
name: browser,
|
|
289
|
+
version: ''
|
|
290
|
+
},
|
|
291
|
+
pages: [
|
|
292
|
+
{
|
|
293
|
+
startedDateTime: dayjs().format(),
|
|
294
|
+
id: 'failing_page',
|
|
295
|
+
title: url,
|
|
296
|
+
pageTimings: {},
|
|
297
|
+
comment: ''
|
|
298
|
+
}
|
|
299
|
+
],
|
|
300
|
+
entries: [],
|
|
301
|
+
comment: ''
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
export function addExtraFieldsToHar(totalResults, har, options) {
|
|
306
|
+
if (har) {
|
|
307
|
+
let harPageNumber = 0;
|
|
308
|
+
// We test one page
|
|
309
|
+
// Let's do a better fix for this later on
|
|
310
|
+
// right now this fixes https://github.com/sitespeedio/browsertime/issues/754
|
|
311
|
+
if (har.log.pages.length === options.iterations) {
|
|
312
|
+
for (let harPage of har.log.pages) {
|
|
313
|
+
let pageNumber = harPageNumber % totalResults.length;
|
|
314
|
+
const visualMetric =
|
|
315
|
+
totalResults[pageNumber].visualMetrics[harPageNumber];
|
|
316
|
+
const browserScript =
|
|
317
|
+
totalResults[pageNumber].browserScripts[harPageNumber];
|
|
318
|
+
const cpu = totalResults[pageNumber].cpu[harPageNumber];
|
|
319
|
+
const googleWebVitals =
|
|
320
|
+
totalResults[pageNumber].googleWebVitals[harPageNumber];
|
|
321
|
+
|
|
322
|
+
addMetaToHAR(
|
|
323
|
+
harPageNumber,
|
|
324
|
+
harPage,
|
|
325
|
+
totalResults[pageNumber].info.url,
|
|
326
|
+
browserScript,
|
|
327
|
+
options
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
if (browserScript) {
|
|
331
|
+
addExtrasToHAR(
|
|
330
332
|
harPage,
|
|
331
|
-
|
|
332
|
-
browserScript,
|
|
333
|
-
|
|
333
|
+
visualMetric,
|
|
334
|
+
browserScript.timings,
|
|
335
|
+
cpu,
|
|
336
|
+
googleWebVitals
|
|
334
337
|
);
|
|
335
|
-
|
|
336
|
-
|
|
338
|
+
}
|
|
339
|
+
harPageNumber++;
|
|
340
|
+
}
|
|
341
|
+
} else {
|
|
342
|
+
const numberOfPages = totalResults.length;
|
|
343
|
+
for (let page = 0; page < numberOfPages; page++) {
|
|
344
|
+
for (let iteration = 0; iteration < options.iterations; iteration++) {
|
|
345
|
+
let harIndex = iteration * totalResults.length;
|
|
346
|
+
harIndex += page;
|
|
347
|
+
|
|
348
|
+
const visualMetric = totalResults[page].visualMetrics[iteration];
|
|
349
|
+
const browserScript = totalResults[page].browserScripts[iteration];
|
|
350
|
+
const cpu = totalResults[page].cpu[iteration];
|
|
351
|
+
const googleWebVitals = totalResults[page].googleWebVitals[iteration];
|
|
352
|
+
const harPage = har.log.pages[harIndex];
|
|
353
|
+
// Only add meta if we have a HAR
|
|
354
|
+
if (harPage) {
|
|
355
|
+
addMetaToHAR(
|
|
356
|
+
iteration,
|
|
357
|
+
harPage,
|
|
358
|
+
totalResults[page].info.url,
|
|
359
|
+
browserScript,
|
|
360
|
+
options
|
|
361
|
+
);
|
|
362
|
+
} else {
|
|
363
|
+
log.error(
|
|
364
|
+
'Could not add meta data to the HAR, miss page ' + harIndex
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
// Only add the metrics if we was able to collect the metrics and have a HAR
|
|
368
|
+
if (browserScript && harPage) {
|
|
337
369
|
addExtrasToHAR(
|
|
338
370
|
harPage,
|
|
339
371
|
visualMetric,
|
|
@@ -342,48 +374,8 @@ module.exports = {
|
|
|
342
374
|
googleWebVitals
|
|
343
375
|
);
|
|
344
376
|
}
|
|
345
|
-
harPageNumber++;
|
|
346
|
-
}
|
|
347
|
-
} else {
|
|
348
|
-
const numberOfPages = totalResults.length;
|
|
349
|
-
for (let page = 0; page < numberOfPages; page++) {
|
|
350
|
-
for (let iteration = 0; iteration < options.iterations; iteration++) {
|
|
351
|
-
let harIndex = iteration * totalResults.length;
|
|
352
|
-
harIndex += page;
|
|
353
|
-
|
|
354
|
-
const visualMetric = totalResults[page].visualMetrics[iteration];
|
|
355
|
-
const browserScript = totalResults[page].browserScripts[iteration];
|
|
356
|
-
const cpu = totalResults[page].cpu[iteration];
|
|
357
|
-
const googleWebVitals =
|
|
358
|
-
totalResults[page].googleWebVitals[iteration];
|
|
359
|
-
const harPage = har.log.pages[harIndex];
|
|
360
|
-
// Only add meta if we have a HAR
|
|
361
|
-
if (harPage) {
|
|
362
|
-
addMetaToHAR(
|
|
363
|
-
iteration,
|
|
364
|
-
harPage,
|
|
365
|
-
totalResults[page].info.url,
|
|
366
|
-
browserScript,
|
|
367
|
-
options
|
|
368
|
-
);
|
|
369
|
-
} else {
|
|
370
|
-
log.error(
|
|
371
|
-
'Could not add meta data to the HAR, miss page ' + harIndex
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
// Only add the metrics if we was able to collect the metrics and have a HAR
|
|
375
|
-
if (browserScript && harPage) {
|
|
376
|
-
addExtrasToHAR(
|
|
377
|
-
harPage,
|
|
378
|
-
visualMetric,
|
|
379
|
-
browserScript.timings,
|
|
380
|
-
cpu,
|
|
381
|
-
googleWebVitals
|
|
382
|
-
);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
377
|
}
|
|
386
378
|
}
|
|
387
379
|
}
|
|
388
380
|
}
|
|
389
|
-
}
|
|
381
|
+
}
|
|
@@ -1,25 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import pathToFolder from '../pathToFolder.js';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
export async function savePngWithoutResize(
|
|
5
|
+
name,
|
|
6
|
+
data,
|
|
7
|
+
url,
|
|
8
|
+
storageManager,
|
|
9
|
+
dir,
|
|
10
|
+
options
|
|
11
|
+
) {
|
|
12
|
+
return storageManager.writeData(
|
|
13
|
+
`${name}.png`,
|
|
14
|
+
data,
|
|
15
|
+
join(pathToFolder(url, options), dir)
|
|
16
|
+
);
|
|
11
17
|
}
|
|
18
|
+
export async function savePng(
|
|
19
|
+
name,
|
|
20
|
+
data,
|
|
21
|
+
url,
|
|
22
|
+
storageManager,
|
|
23
|
+
config,
|
|
24
|
+
dir,
|
|
25
|
+
options
|
|
26
|
+
) {
|
|
27
|
+
let jimp;
|
|
28
|
+
try {
|
|
29
|
+
jimp = await import('jimp');
|
|
30
|
+
} catch {
|
|
31
|
+
jimp = undefined;
|
|
32
|
+
}
|
|
12
33
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return storageManager.writeData(
|
|
16
|
-
`${name}.png`,
|
|
17
|
-
data,
|
|
18
|
-
path.join(pathToFolder(url, options), dir)
|
|
19
|
-
);
|
|
20
|
-
},
|
|
21
|
-
async savePng(name, data, url, storageManager, config, dir, options) {
|
|
22
|
-
const buffer = await jimp.read(data).then(image => {
|
|
34
|
+
if (jimp) {
|
|
35
|
+
const buffer = await jimp.default.read(data).then(image => {
|
|
23
36
|
return image
|
|
24
37
|
.deflateLevel(config.png.compressionLevel)
|
|
25
38
|
.scaleToFit(config.maxSize, config.maxSize)
|
|
@@ -29,12 +42,27 @@ module.exports = {
|
|
|
29
42
|
return storageManager.writeData(
|
|
30
43
|
`${name}.png`,
|
|
31
44
|
buffer,
|
|
32
|
-
|
|
45
|
+
join(pathToFolder(url, options), dir)
|
|
33
46
|
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export async function saveJpg(
|
|
50
|
+
name,
|
|
51
|
+
data,
|
|
52
|
+
url,
|
|
53
|
+
storageManager,
|
|
54
|
+
config,
|
|
55
|
+
dir,
|
|
56
|
+
options
|
|
57
|
+
) {
|
|
58
|
+
let jimp;
|
|
59
|
+
try {
|
|
60
|
+
jimp = await import('jimp');
|
|
61
|
+
} catch {
|
|
62
|
+
jimp = undefined;
|
|
63
|
+
}
|
|
64
|
+
if (jimp) {
|
|
65
|
+
const buffer = await jimp.default.read(data).then(image => {
|
|
38
66
|
return image
|
|
39
67
|
.quality(config.jpg.quality)
|
|
40
68
|
.scaleToFit(config.maxSize, config.maxSize)
|
|
@@ -43,7 +71,7 @@ module.exports = {
|
|
|
43
71
|
return storageManager.writeData(
|
|
44
72
|
`${name}.jpg`,
|
|
45
73
|
buffer,
|
|
46
|
-
|
|
74
|
+
join(pathToFolder(url, options), dir)
|
|
47
75
|
);
|
|
48
76
|
}
|
|
49
|
-
}
|
|
77
|
+
}
|
package/lib/support/logging.js
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
import intel from 'intel';
|
|
2
|
+
const { INFO, DEBUG, VERBOSE, TRACE, NONE, basicConfig } = intel;
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports.configure = function configure(options) {
|
|
4
|
+
export default function configure(options) {
|
|
6
5
|
options = options || {};
|
|
7
6
|
|
|
8
|
-
let level =
|
|
7
|
+
let level = INFO;
|
|
9
8
|
switch (options.verbose) {
|
|
10
|
-
case 1:
|
|
11
|
-
level =
|
|
9
|
+
case 1: {
|
|
10
|
+
level = DEBUG;
|
|
12
11
|
break;
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
}
|
|
13
|
+
case 2: {
|
|
14
|
+
level = VERBOSE;
|
|
15
15
|
break;
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
}
|
|
17
|
+
case 3: {
|
|
18
|
+
level = TRACE;
|
|
18
19
|
break;
|
|
19
|
-
|
|
20
|
+
}
|
|
21
|
+
default: {
|
|
20
22
|
break;
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
if (options.silent) {
|
|
24
|
-
level =
|
|
27
|
+
level = NONE;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
if (level ===
|
|
28
|
-
|
|
30
|
+
if (level === INFO) {
|
|
31
|
+
basicConfig({
|
|
29
32
|
format: '[%(date)s] %(levelname)s: %(message)s',
|
|
30
33
|
level: level
|
|
31
34
|
});
|
|
32
35
|
} else {
|
|
33
|
-
|
|
36
|
+
basicConfig({
|
|
34
37
|
format: '[%(date)s] %(levelname)s: [%(name)s] %(message)s',
|
|
35
38
|
level: level
|
|
36
39
|
});
|
|
37
40
|
}
|
|
38
|
-
}
|
|
41
|
+
}
|