browsertime 24.0.0-alpha.1 → 24.0.0-alpha.3

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 CHANGED
@@ -1,6 +1,13 @@
1
1
  # Browsertime changelog (we do [semantic versioning](https://semver.org))
2
2
 
3
- ## 24.0.0-alpha.1 - 2025-01-07
3
+ ## 24.0.0-alpha.3 - 2025-01-10
4
+
5
+ ### Changed
6
+ * Moved usb-power-profiling to be an optional package [#2249](https://github.com/sitespeedio/browsertime/pull/2249).
7
+
8
+ ### Added
9
+ * Edgedriver 131 [#2236](https://github.com/sitespeedio/browsertime/pull/2236).
10
+
4
11
  ### Fixed
5
12
  * Replace dependencies with local implementation:
6
13
  * Replace btoa [#2233](https://github.com/sitespeedio/browsertime/pull/2233).
@@ -15,7 +22,6 @@
15
22
  * Replace @cypress/xvfb [#2245](https://github.com/sitespeedio/browsertime/pull/2245).
16
23
  * Replace intel (log) with sitespeed.io/log [#2246](https://github.com/sitespeedio/browsertime/pull/2246).
17
24
  * Fix Docker file ENV to follow the new standard [#2239](https://github.com/sitespeedio/browsertime/pull/2239).
18
- * Edgedriver 131 [#2236](https://github.com/sitespeedio/browsertime/pull/2236).
19
25
 
20
26
 
21
27
  ## 23.5.0 - 2024-12-23
@@ -25,7 +31,7 @@
25
31
  ### Fixed
26
32
  * Updated to webdriver 4.28 [#2226](https://github.com/sitespeedio/browsertime/pull/2226).
27
33
  * Updated dev dependencies [#2228](https://github.com/sitespeedio/browsertime/pull/2228).
28
- * Fix so the check for gnirehtet always use --android.gnirehtet to fix problens setting it in sitespeed.io [#2229](https://github.com/sitespeedio/browsertime/pull/2229).
34
+ * Fix so the check for gnirehtet always use --android.gnirehtet to fix problems setting it in sitespeed.io [#2229](https://github.com/sitespeedio/browsertime/pull/2229).
29
35
  * Update to execa 9.5.2 [#2231](https://github.com/sitespeedio/browsertime/pull/2231).
30
36
  * Update to adbkit 3.3.8 [#2232](https://github.com/sitespeedio/browsertime/pull/2232).
31
37
  * Fix so you cannot use gnirehtet with webpagereplay [#2230](https://github.com/sitespeedio/browsertime/pull/2230).
@@ -33,7 +39,7 @@
33
39
 
34
40
  ## 23.4.5 - 2024-12-20
35
41
  ### Fixed
36
- * Change bottom margin from 10 to 14 pixel when recoring a video on mobile, se bug [#2224](https://github.com/sitespeedio/browsertime/issues/2224) and PR [#2225](https://github.com/sitespeedio/browsertime/pull/2225).
42
+ * Change bottom margin from 10 to 14 pixel when recording a video on mobile, se bug [#2224](https://github.com/sitespeedio/browsertime/issues/2224) and PR [#2225](https://github.com/sitespeedio/browsertime/pull/2225).
37
43
 
38
44
  ## 23.4.4 - 2024-12-18
39
45
  ### Fixed
@@ -5,10 +5,10 @@ import { EOL as endOfLine } from 'node:os';
5
5
  import { execa } from 'execa';
6
6
  import { getLogger } from '@sitespeed.io/log';
7
7
  import pkg from '@devicefarmer/adbkit';
8
- import usbPowerProfiler from 'usb-power-profiling/usb-power-profiling.js';
9
8
  const { Adb } = pkg;
10
9
  import get from 'lodash.get';
11
10
  import { pathToFolder } from '../support/pathToFolder.js';
11
+ import { loadUsbPowerProfiler } from '../support/usbPower.js';
12
12
  const log = getLogger('browsertime.android');
13
13
  const mkdir = promisify(_mkdir);
14
14
  const delay = ms => new Promise(res => setTimeout(res, ms));
@@ -474,6 +474,11 @@ export class Android {
474
474
  }
475
475
 
476
476
  async getUsbPowerUsageProfile(index, url, result, options, storageManager) {
477
+ const usbPowerProfiler = await loadUsbPowerProfiler();
478
+ if (!usbPowerProfiler) {
479
+ log.info('USB profiler is not installed');
480
+ return;
481
+ }
477
482
  let profileData = await usbPowerProfiler.profileFromData();
478
483
  let destinationFilename = path.join(
479
484
  await pathToFolder(url, options),
@@ -485,6 +490,11 @@ export class Android {
485
490
  }
486
491
 
487
492
  async function getUsbPowerUsage(startTime, endTime) {
493
+ const usbPowerProfiler = await loadUsbPowerProfiler();
494
+ if (!usbPowerProfiler) {
495
+ log.info('USB profiler is not installed');
496
+ return;
497
+ }
488
498
  let baselineUsageData = await usbPowerProfiler.getPowerData(
489
499
  startTime - 2,
490
500
  endTime - 1
@@ -3,7 +3,6 @@ import { unlink as _unlink, rm as _rm } from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import { logging } from 'selenium-webdriver';
5
5
  import { getLogger } from '@sitespeed.io/log';
6
- import usbPowerProfiler from 'usb-power-profiling/usb-power-profiling.js';
7
6
  const log = getLogger('browsertime.chrome');
8
7
  const { Type } = logging;
9
8
  import { longTaskMetrics } from '../longTaskMetrics.js';
@@ -14,6 +13,7 @@ import { toArray } from '../../support/util.js';
14
13
  import { logging as _logging } from 'selenium-webdriver';
15
14
  import { parse } from '../traceCategoriesParser.js';
16
15
  import { pathToFolder } from '../../support/pathToFolder.js';
16
+ import { loadUsbPowerProfiler } from '../../support/usbPower.js';
17
17
  import { ChromeDevtoolsProtocol } from '../chromeDevtoolsProtocol.js';
18
18
  import { NetworkManager } from '../networkManager.js';
19
19
  import { Android, isAndroidConfigured } from '../../android/index.js';
@@ -80,7 +80,10 @@ export class Chromium {
80
80
  await this.android.addDevtoolsFw();
81
81
 
82
82
  if (this.options.androidUsbPower) {
83
- usbPowerProfiler.startSampling();
83
+ const usbPowerProfiler = await loadUsbPowerProfiler();
84
+ if (usbPowerProfiler) {
85
+ usbPowerProfiler.startSampling();
86
+ }
84
87
  }
85
88
  }
86
89
 
@@ -171,7 +174,10 @@ export class Chromium {
171
174
  if (this.options.androidPower) {
172
175
  await this.android.resetPowerUsage();
173
176
  } else if (this.options.androidUsbPower) {
174
- await usbPowerProfiler.resetPowerData();
177
+ const usbPowerProfiler = await loadUsbPowerProfiler();
178
+ if (usbPowerProfiler) {
179
+ await usbPowerProfiler.resetPowerData();
180
+ }
175
181
  }
176
182
  }
177
183
 
@@ -511,7 +517,10 @@ export class Chromium {
511
517
  if (this.options.androidPower) {
512
518
  await this.android.stopPowerTesting();
513
519
  } else if (this.options.androidUsbPower) {
514
- await usbPowerProfiler.stopSampling();
520
+ const usbPowerProfiler = await loadUsbPowerProfiler();
521
+ if (usbPowerProfiler) {
522
+ await usbPowerProfiler.stopSampling();
523
+ }
515
524
  }
516
525
  }
517
526
 
@@ -3,9 +3,9 @@ import { promisify } from 'node:util';
3
3
  import path from 'node:path';
4
4
  import { getLogger } from '@sitespeed.io/log';
5
5
  import get from 'lodash.get';
6
- import usbPowerProfiler from 'usb-power-profiling/usb-power-profiling.js';
7
6
  import { adapters } from 'ff-test-bidi-har-export';
8
7
  import { getEmptyHAR, mergeHars } from '../../support/har/index.js';
8
+ import { loadUsbPowerProfiler } from '../../support/usbPower.js';
9
9
  import { pathToFolder } from '../../support/pathToFolder.js';
10
10
  import { isAndroidConfigured, Android } from '../../android/index.js';
11
11
  import { adjustVisualProgressTimestamps } from '../../support/util.js';
@@ -75,7 +75,10 @@ export class Firefox {
75
75
  );
76
76
 
77
77
  if (isAndroidConfigured(this.options) && this.options.androidUsbPower) {
78
- usbPowerProfiler.startSampling();
78
+ const usbPowerProfiler = await loadUsbPowerProfiler();
79
+ if (usbPowerProfiler) {
80
+ usbPowerProfiler.startSampling();
81
+ }
79
82
  }
80
83
  }
81
84
 
@@ -144,7 +147,10 @@ export class Firefox {
144
147
  if (this.options.androidPower) {
145
148
  await this.android.resetPowerUsage();
146
149
  } else if (this.options.androidUsbPower) {
147
- await usbPowerProfiler.resetPowerData();
150
+ const usbPowerProfiler = await loadUsbPowerProfiler();
151
+ if (usbPowerProfiler) {
152
+ await usbPowerProfiler.resetPowerData();
153
+ }
148
154
  }
149
155
  }
150
156
 
@@ -408,7 +414,10 @@ export class Firefox {
408
414
  if (this.options.androidPower) {
409
415
  await this.android.stopPowerTesting();
410
416
  } else if (this.options.androidUsbPower) {
411
- await usbPowerProfiler.stopSampling();
417
+ const usbPowerProfiler = await loadUsbPowerProfiler();
418
+ if (usbPowerProfiler) {
419
+ await usbPowerProfiler.stopSampling();
420
+ }
412
421
  }
413
422
  }
414
423
  }
@@ -0,0 +1,11 @@
1
+ export async function loadUsbPowerProfiler() {
2
+ try {
3
+ // usb-power-profiling/usb-power-profiling.js exports a default, so we destructure it
4
+ const { default: usbPowerProfiler } = await import(
5
+ 'usb-power-profiling/usb-power-profiling.js'
6
+ );
7
+ return usbPowerProfiler;
8
+ } catch {
9
+ return;
10
+ }
11
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "browsertime",
3
3
  "description": "Get performance metrics from your web page using Browsertime.",
4
- "version": "24.0.0-alpha.1",
4
+ "version": "24.0.0-alpha.3",
5
5
  "bin": "./bin/browsertime.js",
6
6
  "type": "module",
7
7
  "types": "./types/scripting.d.ts",
@@ -10,7 +10,7 @@
10
10
  "@sitespeed.io/chromedriver": "131.0.6778-69",
11
11
  "@sitespeed.io/edgedriver": "131.0.2903-112",
12
12
  "@sitespeed.io/geckodriver": "0.35.0-1",
13
- "@sitespeed.io/log": "0.1.0",
13
+ "@sitespeed.io/log": "0.2.3",
14
14
  "@sitespeed.io/throttle": "5.0.1",
15
15
  "@sitespeed.io/tracium": "0.3.3",
16
16
  "chrome-har": "1.0.1",
@@ -22,7 +22,6 @@
22
22
  "lodash.merge": "4.6.2",
23
23
  "lodash.set": "4.3.2",
24
24
  "selenium-webdriver": "4.27.0",
25
- "usb-power-profiling": "1.5.0",
26
25
  "yargs": "17.7.2"
27
26
  },
28
27
  "optionalDependencies": {
@@ -30,7 +29,8 @@
30
29
  "@jimp/png": "0.22.12",
31
30
  "@jimp/jpeg": "0.22.12",
32
31
  "@jimp/plugin-resize": "0.22.12",
33
- "@jimp/plugin-scale": "0.22.12"
32
+ "@jimp/plugin-scale": "0.22.12",
33
+ "usb-power-profiling": "1.5.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/selenium-webdriver": "4.1.25",
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/android/index.js"],"names":[],"mappings":"AAskBA,2DAWC;AAlkBD;IACE,0BAwBC;IAfC,YAAgC;IAEhC,QAIC;IACD,UAAgC;IAGhC,6BAA6B;IAC7B,yBAA2B;IAC3B,eAAgC;IAKlC,uBAgBC;IALC,YAA4C;IAG1C,YAAoE;IAIxE,wCAEC;IAED,8CAIC;IAED,6CAIC;IAED,2CAUC;IAED,mEAYC;IAED,mEAcC;IAED,uCAEC;IAED,0CAGC;IAED,4CAMC;IAED,4CAMC;IAED,uBAGC;IAED,kCAOC;IAED;;;;;;;OAuBC;IAED,2CAKC;IAED,8BAKC;IAED,oKAuBC;IAED,2BAIC;IAED,qCAGC;IAED,iCAGC;IAED,wBASC;IAED,2CAOC;IAED,gCAEC;IAED,0BAIC;IAED,iCAGC;IAED,8CAIC;IAED,4BAEC;IAED,sCAYC;IAED,mDAsBC;IAED,gDA+CC;IAED;;;;;;;OAqDC;IAED,4DAQC;IAED,mCAcC;IAED,kCAQC;IAED,iCAIC;IAED;;;;OAGC;IAED;;;OAEC;IAED,6GAQC;CACF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/android/index.js"],"names":[],"mappings":"AAglBA,2DAWC;AA5kBD;IACE,0BAwBC;IAfC,YAAgC;IAEhC,QAIC;IACD,UAAgC;IAGhC,6BAA6B;IAC7B,yBAA2B;IAC3B,eAAgC;IAKlC,uBAgBC;IALC,YAA4C;IAG1C,YAAoE;IAIxE,wCAEC;IAED,8CAIC;IAED,6CAIC;IAED,2CAUC;IAED,mEAYC;IAED,mEAcC;IAED,uCAEC;IAED,0CAGC;IAED,4CAMC;IAED,4CAMC;IAED,uBAGC;IAED,kCAOC;IAED;;;;;;;OAuBC;IAED,2CAKC;IAED,8BAKC;IAED,oKAuBC;IAED,2BAIC;IAED,qCAGC;IAED,iCAGC;IAED,wBASC;IAED,2CAOC;IAED,gCAEC;IAED,0BAIC;IAED,iCAGC;IAED,8CAIC;IAED,4BAEC;IAED,sCAYC;IAED,mDAsBC;IAED,gDA+CC;IAED;;;;;;;OAqDC;IAED,4DAQC;IAED,mCAcC;IAED,kCAQC;IAED,iCAIC;IAED;;;;OAGC;IAED;;;OAEC;IAED,6GAaC;CACF"}
@@ -0,0 +1,2 @@
1
+ export function loadUsbPowerProfiler(): Promise<any>;
2
+ //# sourceMappingURL=usbPower.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usbPower.d.ts","sourceRoot":"","sources":["../../lib/support/usbPower.js"],"names":[],"mappings":"AAAA,qDAUC"}