@browserless/cli 10.1.18 → 10.2.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@browserless/cli",
3
3
  "description": "CLI to interact with Browserless capabilities",
4
4
  "homepage": "https://browserless.js.org",
5
- "version": "10.1.18",
5
+ "version": "10.2.1",
6
6
  "bin": {
7
7
  "browserless": "src/index.js"
8
8
  },
@@ -32,7 +32,7 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "beauty-error": "~1.2.17",
35
- "browserless": "^10.1.18",
35
+ "browserless": "^10.2.1",
36
36
  "dark-mode": "~3.0.0",
37
37
  "dset": "~3.1.2",
38
38
  "mri": "~1.2.0",
@@ -53,7 +53,7 @@
53
53
  "src"
54
54
  ],
55
55
  "license": "MIT",
56
- "gitHead": "f8e21e951876d99efcecf7415959aa13488e9c7e",
56
+ "gitHead": "0b578051040d09db17d9f03d49dc713ab70dc886",
57
57
  "scripts": {
58
58
  "coverage": "exit 0",
59
59
  "test": "exit 0"
@@ -0,0 +1,34 @@
1
+ 'use strict'
2
+
3
+ const prettyBytes = require('pretty-bytes')
4
+
5
+ module.exports = async ({ url, browserless, opts }) => {
6
+ const pageResources = browserless.evaluate(async page =>
7
+ page.evaluate(() =>
8
+ window.performance.getEntriesByType('resource').map(resource => ({
9
+ transferredSize: resource.transferSize,
10
+ decodedBodySize: resource.decodedBodySize
11
+ }))
12
+ )
13
+ )
14
+
15
+ const resources = await pageResources(url, opts)
16
+
17
+ const [transferSize, resourcesSize] = resources
18
+ .reduce(
19
+ (acc, { transferredSize, decodedBodySize }) => {
20
+ acc[0] += transferredSize
21
+ acc[1] += decodedBodySize
22
+ return acc
23
+ },
24
+ [0, 0]
25
+ )
26
+ .map(prettyBytes)
27
+
28
+ const resume = `
29
+ ⬩ ${resources.length} network requests
30
+ ⬩ ${transferSize} transferred bytes
31
+ ⬩ ${resourcesSize} resources bytes`
32
+
33
+ return [resume]
34
+ }