@browserless.io/browserless 2.2.0 → 2.3.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.
Files changed (80) hide show
  1. package/bin/browserless.js +25 -14
  2. package/build/browserless.d.ts +6 -1
  3. package/build/browserless.js +38 -20
  4. package/build/exports.core.d.ts +24 -0
  5. package/build/exports.core.js +26 -0
  6. package/build/exports.d.ts +38 -24
  7. package/build/exports.js +44 -26
  8. package/build/routes/chrome/http/content.post.body.json +8 -8
  9. package/build/routes/chrome/http/download.post.body.json +489 -11
  10. package/build/routes/chrome/http/download.post.query.json +69 -6
  11. package/build/routes/chrome/http/download.post.response.json +1 -0
  12. package/build/routes/chrome/http/function.post.body.json +489 -11
  13. package/build/routes/chrome/http/function.post.query.json +69 -6
  14. package/build/routes/chrome/http/function.post.response.json +1 -0
  15. package/build/routes/chrome/http/json-list.get.response.json +1 -49
  16. package/build/routes/chrome/http/json-new.put.response.json +1 -41
  17. package/build/routes/chrome/http/json-protocol.get.response.json +1 -3
  18. package/build/routes/chrome/http/json-version.get.response.json +1 -41
  19. package/build/routes/chrome/http/pdf.post.body.json +9 -153
  20. package/build/routes/chrome/http/pdf.post.query.json +69 -6
  21. package/build/routes/chrome/http/performance.post.body.json +494 -10
  22. package/build/routes/chrome/http/performance.post.query.json +69 -6
  23. package/build/routes/chrome/http/performance.post.response.json +1 -3
  24. package/build/routes/chrome/http/scrape.post.body.json +9 -56
  25. package/build/routes/chrome/http/scrape.post.response.json +1 -305
  26. package/build/routes/chrome/http/screenshot.post.body.json +9 -99
  27. package/build/routes/chrome/http/screenshot.post.query.json +69 -6
  28. package/build/routes/chrome/ws/browser.query.json +69 -6
  29. package/build/routes/chrome/ws/cdp.query.json +69 -6
  30. package/build/routes/chrome/ws/page.query.json +69 -6
  31. package/build/routes/chrome/ws/playwright.query.json +90 -7
  32. package/build/routes/chromium/http/content.post.body.json +8 -8
  33. package/build/routes/chromium/http/download.post.body.json +489 -11
  34. package/build/routes/chromium/http/download.post.query.json +69 -6
  35. package/build/routes/chromium/http/download.post.response.json +1 -0
  36. package/build/routes/chromium/http/function.post.body.json +489 -11
  37. package/build/routes/chromium/http/function.post.query.json +69 -6
  38. package/build/routes/chromium/http/function.post.response.json +1 -0
  39. package/build/routes/chromium/http/json-list.get.response.json +1 -49
  40. package/build/routes/chromium/http/json-new.put.response.json +1 -41
  41. package/build/routes/chromium/http/json-protocol.get.response.json +1 -3
  42. package/build/routes/chromium/http/json-version.get.response.json +1 -41
  43. package/build/routes/chromium/http/pdf.post.body.json +9 -153
  44. package/build/routes/chromium/http/pdf.post.query.json +69 -6
  45. package/build/routes/chromium/http/performance.post.body.json +494 -10
  46. package/build/routes/chromium/http/performance.post.query.json +69 -6
  47. package/build/routes/chromium/http/performance.post.response.json +1 -3
  48. package/build/routes/chromium/http/scrape.post.body.json +9 -56
  49. package/build/routes/chromium/http/scrape.post.response.json +1 -305
  50. package/build/routes/chromium/http/screenshot.post.body.json +9 -99
  51. package/build/routes/chromium/http/screenshot.post.query.json +69 -6
  52. package/build/routes/chromium/ws/browser.query.json +69 -6
  53. package/build/routes/chromium/ws/cdp.query.json +69 -6
  54. package/build/routes/chromium/ws/page.query.json +69 -6
  55. package/build/routes/chromium/ws/playwright.query.json +90 -7
  56. package/build/routes/firefox/ws/playwright.d.ts +5 -1
  57. package/build/routes/firefox/ws/playwright.query.json +90 -7
  58. package/build/routes/management/http/config.get.response.json +1 -104
  59. package/build/routes/management/http/metrics-total.get.response.json +1 -69
  60. package/build/routes/management/http/metrics.get.response.json +1 -91
  61. package/build/routes/management/http/sessions.get.response.json +1 -232
  62. package/build/routes/management/http/static.get.js +7 -7
  63. package/build/routes/webkit/ws/playwright.query.json +90 -7
  64. package/build/shared/utils/performance/main.js +1 -1
  65. package/docker/chrome/Dockerfile +2 -0
  66. package/docker/chromium/Dockerfile +2 -0
  67. package/docker/firefox/Dockerfile +2 -0
  68. package/docker/multi/Dockerfile +2 -0
  69. package/docker/webkit/Dockerfile +2 -0
  70. package/package.json +1 -2
  71. package/scripts/build-open-api.js +18 -9
  72. package/scripts/build-schemas.js +2 -3
  73. package/src/browserless.ts +61 -36
  74. package/src/exports.core.ts +26 -0
  75. package/src/exports.ts +48 -26
  76. package/src/router.ts +6 -2
  77. package/src/routes/firefox/ws/playwright.ts +3 -1
  78. package/src/routes/management/http/static.get.ts +14 -9
  79. package/src/shared/utils/performance/main.ts +1 -2
  80. package/static/docs/swagger.json +1338 -2287
@@ -1,107 +1,4 @@
1
1
  {
2
- "type": "object",
3
- "properties": {
4
- "allowCORS": {
5
- "type": "boolean"
6
- },
7
- "allowFileProtocol": {
8
- "type": "boolean"
9
- },
10
- "allowGetCalls": {
11
- "type": "boolean"
12
- },
13
- "concurrent": {
14
- "type": "number"
15
- },
16
- "data": {
17
- "type": "string"
18
- },
19
- "debug": {
20
- "type": "string"
21
- },
22
- "errorAlertURL": {
23
- "type": [
24
- "null",
25
- "string"
26
- ]
27
- },
28
- "healthFailureURL": {
29
- "type": [
30
- "null",
31
- "string"
32
- ]
33
- },
34
- "host": {
35
- "type": "string"
36
- },
37
- "maxCPU": {
38
- "type": "number"
39
- },
40
- "maxMemory": {
41
- "type": "number"
42
- },
43
- "metricsJSONPath": {
44
- "type": "string"
45
- },
46
- "port": {
47
- "type": "number"
48
- },
49
- "queued": {
50
- "type": "number"
51
- },
52
- "queuedAlertURL": {
53
- "type": [
54
- "null",
55
- "string"
56
- ]
57
- },
58
- "rejectAlertURL": {
59
- "type": [
60
- "null",
61
- "string"
62
- ]
63
- },
64
- "retries": {
65
- "type": "number"
66
- },
67
- "timeout": {
68
- "type": "number"
69
- },
70
- "timeoutAlertURL": {
71
- "type": [
72
- "null",
73
- "string"
74
- ]
75
- },
76
- "token": {
77
- "type": [
78
- "null",
79
- "string"
80
- ]
81
- }
82
- },
83
- "additionalProperties": false,
84
- "required": [
85
- "allowCORS",
86
- "allowFileProtocol",
87
- "allowGetCalls",
88
- "concurrent",
89
- "data",
90
- "debug",
91
- "errorAlertURL",
92
- "healthFailureURL",
93
- "host",
94
- "maxCPU",
95
- "maxMemory",
96
- "metricsJSONPath",
97
- "port",
98
- "queued",
99
- "queuedAlertURL",
100
- "rejectAlertURL",
101
- "retries",
102
- "timeout",
103
- "timeoutAlertURL",
104
- "token"
105
- ],
2
+ "type": "string",
106
3
  "$schema": "http://json-schema.org/draft-07/schema#"
107
4
  }
@@ -1,72 +1,4 @@
1
1
  {
2
- "type": "object",
3
- "properties": {
4
- "error": {
5
- "type": "number"
6
- },
7
- "estimatedMonthlyUnits": {
8
- "type": "number"
9
- },
10
- "maxConcurrent": {
11
- "type": "number"
12
- },
13
- "maxTime": {
14
- "type": "number"
15
- },
16
- "meanTime": {
17
- "type": "number"
18
- },
19
- "minTime": {
20
- "type": "number"
21
- },
22
- "minutesOfMetricsAvailable": {
23
- "type": "number"
24
- },
25
- "queued": {
26
- "type": "number"
27
- },
28
- "rejected": {
29
- "type": "number"
30
- },
31
- "sessionTimes": {
32
- "type": "array",
33
- "items": {
34
- "type": "number"
35
- }
36
- },
37
- "successful": {
38
- "type": "number"
39
- },
40
- "timedout": {
41
- "type": "number"
42
- },
43
- "totalTime": {
44
- "type": "number"
45
- },
46
- "unhealthy": {
47
- "type": "number"
48
- },
49
- "units": {
50
- "type": "number"
51
- }
52
- },
53
- "additionalProperties": false,
54
- "required": [
55
- "error",
56
- "estimatedMonthlyUnits",
57
- "maxConcurrent",
58
- "maxTime",
59
- "meanTime",
60
- "minTime",
61
- "minutesOfMetricsAvailable",
62
- "queued",
63
- "rejected",
64
- "sessionTimes",
65
- "successful",
66
- "timedout",
67
- "totalTime",
68
- "unhealthy",
69
- "units"
70
- ],
2
+ "type": "string",
71
3
  "$schema": "http://json-schema.org/draft-07/schema#"
72
4
  }
@@ -1,94 +1,4 @@
1
1
  {
2
- "type": "array",
3
- "items": {
4
- "$ref": "#/definitions/IBrowserlessStats"
5
- },
6
- "definitions": {
7
- "IBrowserlessStats": {
8
- "type": "object",
9
- "properties": {
10
- "cpu": {
11
- "type": [
12
- "null",
13
- "number"
14
- ]
15
- },
16
- "date": {
17
- "type": "number"
18
- },
19
- "error": {
20
- "type": "number"
21
- },
22
- "maxConcurrent": {
23
- "type": "number"
24
- },
25
- "maxTime": {
26
- "type": "number"
27
- },
28
- "meanTime": {
29
- "type": "number"
30
- },
31
- "memory": {
32
- "type": [
33
- "null",
34
- "number"
35
- ]
36
- },
37
- "minTime": {
38
- "type": "number"
39
- },
40
- "queued": {
41
- "type": "number"
42
- },
43
- "rejected": {
44
- "type": "number"
45
- },
46
- "sessionTimes": {
47
- "type": "array",
48
- "items": {
49
- "type": "number"
50
- }
51
- },
52
- "successful": {
53
- "type": "number"
54
- },
55
- "timedout": {
56
- "type": "number"
57
- },
58
- "totalTime": {
59
- "type": "number"
60
- },
61
- "unauthorized": {
62
- "type": "number"
63
- },
64
- "unhealthy": {
65
- "type": "number"
66
- },
67
- "units": {
68
- "type": "number"
69
- }
70
- },
71
- "additionalProperties": false,
72
- "required": [
73
- "cpu",
74
- "date",
75
- "error",
76
- "maxConcurrent",
77
- "maxTime",
78
- "meanTime",
79
- "memory",
80
- "minTime",
81
- "queued",
82
- "rejected",
83
- "sessionTimes",
84
- "successful",
85
- "timedout",
86
- "totalTime",
87
- "unauthorized",
88
- "unhealthy",
89
- "units"
90
- ]
91
- }
92
- },
2
+ "type": "string",
93
3
  "$schema": "http://json-schema.org/draft-07/schema#"
94
4
  }
@@ -1,235 +1,4 @@
1
1
  {
2
- "type": "array",
3
- "items": {
4
- "$ref": "#/definitions/BrowserlessSessionJSON"
5
- },
6
- "definitions": {
7
- "BrowserlessSessionJSON": {
8
- "type": "object",
9
- "properties": {
10
- "browser": {
11
- "type": "string"
12
- },
13
- "browserId": {
14
- "type": "string"
15
- },
16
- "id": {
17
- "type": [
18
- "null",
19
- "string"
20
- ]
21
- },
22
- "initialConnectURL": {
23
- "type": "string"
24
- },
25
- "killURL": {
26
- "type": [
27
- "null",
28
- "string"
29
- ]
30
- },
31
- "launchOptions": {
32
- "anyOf": [
33
- {
34
- "$ref": "#/definitions/CDPLaunchOptions"
35
- },
36
- {
37
- "$ref": "#/definitions/BrowserServerOptions"
38
- }
39
- ]
40
- },
41
- "numbConnected": {
42
- "type": "number"
43
- },
44
- "routePath": {
45
- "anyOf": [
46
- {
47
- "type": "array",
48
- "items": {
49
- "type": "string"
50
- }
51
- },
52
- {
53
- "type": "string"
54
- }
55
- ]
56
- },
57
- "startedOn": {
58
- "type": "number"
59
- },
60
- "timeAliveMs": {
61
- "type": "number"
62
- },
63
- "userDataDir": {
64
- "type": [
65
- "null",
66
- "string"
67
- ]
68
- }
69
- },
70
- "additionalProperties": false,
71
- "required": [
72
- "browser",
73
- "browserId",
74
- "id",
75
- "initialConnectURL",
76
- "killURL",
77
- "launchOptions",
78
- "numbConnected",
79
- "routePath",
80
- "startedOn",
81
- "timeAliveMs",
82
- "userDataDir"
83
- ]
84
- },
85
- "CDPLaunchOptions": {
86
- "type": "object",
87
- "properties": {
88
- "args": {
89
- "type": "array",
90
- "items": {
91
- "type": "string"
92
- }
93
- },
94
- "defaultViewport": {
95
- "type": "object",
96
- "properties": {
97
- "deviceScaleFactor": {
98
- "type": "number"
99
- },
100
- "hasTouch": {
101
- "type": "boolean"
102
- },
103
- "height": {
104
- "type": "number"
105
- },
106
- "isLandscape": {
107
- "type": "boolean"
108
- },
109
- "isMobile": {
110
- "type": "boolean"
111
- },
112
- "width": {
113
- "type": "number"
114
- }
115
- },
116
- "additionalProperties": false,
117
- "required": [
118
- "height",
119
- "width"
120
- ]
121
- },
122
- "devtools": {
123
- "type": "boolean"
124
- },
125
- "dumpio": {
126
- "type": "boolean"
127
- },
128
- "headless": {
129
- "enum": [
130
- false,
131
- "shell",
132
- true
133
- ]
134
- },
135
- "ignoreDefaultArgs": {
136
- "anyOf": [
137
- {
138
- "type": "array",
139
- "items": {
140
- "type": "string"
141
- }
142
- },
143
- {
144
- "type": "boolean"
145
- }
146
- ]
147
- },
148
- "ignoreHTTPSErrors": {
149
- "type": "boolean"
150
- },
151
- "slowMo": {
152
- "type": "number"
153
- },
154
- "stealth": {
155
- "type": "boolean"
156
- },
157
- "timeout": {
158
- "type": "number"
159
- },
160
- "userDataDir": {
161
- "type": "string"
162
- },
163
- "waitForInitialPage": {
164
- "type": "boolean"
165
- }
166
- },
167
- "additionalProperties": false
168
- },
169
- "BrowserServerOptions": {
170
- "type": "object",
171
- "properties": {
172
- "args": {
173
- "type": "array",
174
- "items": {
175
- "type": "string"
176
- }
177
- },
178
- "chromiumSandbox": {
179
- "type": "boolean"
180
- },
181
- "devtools": {
182
- "type": "boolean"
183
- },
184
- "downloadsPath": {
185
- "type": "string"
186
- },
187
- "headless": {
188
- "type": "boolean"
189
- },
190
- "ignoreDefaultArgs": {
191
- "anyOf": [
192
- {
193
- "type": "array",
194
- "items": {
195
- "type": "string"
196
- }
197
- },
198
- {
199
- "type": "boolean"
200
- }
201
- ]
202
- },
203
- "proxy": {
204
- "type": "object",
205
- "properties": {
206
- "bypass": {
207
- "type": "string"
208
- },
209
- "password": {
210
- "type": "string"
211
- },
212
- "server": {
213
- "type": "string"
214
- },
215
- "username": {
216
- "type": "string"
217
- }
218
- },
219
- "additionalProperties": false,
220
- "required": [
221
- "server"
222
- ]
223
- },
224
- "timeout": {
225
- "type": "number"
226
- },
227
- "tracesDir": {
228
- "type": "string"
229
- }
230
- },
231
- "additionalProperties": false
232
- }
233
- },
2
+ "type": "string",
234
3
  "$schema": "http://json-schema.org/draft-07/schema#"
235
4
  }
@@ -1,12 +1,10 @@
1
- import { APITags, HTTPManagementRoutes, HTTPRoute, Methods, NotFound, contentTypes, createLogger, fileExists, mimeTypes, } from '@browserless.io/browserless';
1
+ import { APITags, HTTPManagementRoutes, HTTPRoute, Methods, NotFound, contentTypes, fileExists, mimeTypes, } from '@browserless.io/browserless';
2
2
  import { createReadStream } from 'fs';
3
3
  import path from 'path';
4
- const debug = createLogger('http:static');
5
- const verbose = createLogger('http:static:verbose');
6
4
  const pathMap = new Map();
7
- const streamFile = (res, file, contentType) => new Promise((resolve, reject) => {
5
+ const streamFile = (debug, res, file, contentType) => new Promise((resolve, reject) => {
8
6
  if (contentType) {
9
- verbose(`Setting content-type ${contentType}`);
7
+ debug(`Setting content-type ${contentType}`);
10
8
  res.setHeader('Content-Type', contentType);
11
9
  }
12
10
  return createReadStream(file)
@@ -33,8 +31,10 @@ export default class StaticGetRoute extends HTTPRoute {
33
31
  handler = async (req, res) => {
34
32
  const { pathname } = req.parsed;
35
33
  const fileCache = pathMap.get(pathname);
34
+ const debug = this.debug();
35
+ const verbose = debug.extend('verbose');
36
36
  if (fileCache) {
37
- return streamFile(res, fileCache.path, fileCache.contentType);
37
+ return streamFile(verbose, res, fileCache.path, fileCache.contentType);
38
38
  }
39
39
  const config = this.config();
40
40
  const file = path.join(config.getStatic(), pathname);
@@ -57,6 +57,6 @@ export default class StaticGetRoute extends HTTPRoute {
57
57
  contentType,
58
58
  path: filePath,
59
59
  });
60
- return streamFile(res, filePath, contentType);
60
+ return streamFile(verbose, res, filePath, contentType);
61
61
  };
62
62
  }
@@ -1,21 +1,21 @@
1
1
  {
2
+ "additionalProperties": false,
2
3
  "type": "object",
3
4
  "properties": {
5
+ "blockAds": {
6
+ "description": "Whether or nor to load ad-blocking extensions for the session.\nThis currently uses uBlock Origin and may cause certain sites\nto not load properly.",
7
+ "type": "boolean"
8
+ },
4
9
  "launch": {
5
- "description": "Launch options, which can be either an object\nof puppeteer.launch options or playwright.launchServer\noptions, depending on the API. Must be either JSON\nobject, or a base64-encoded JSON object.",
6
10
  "anyOf": [
7
11
  {
8
- "$ref": "#/definitions/BrowserServerOptions"
12
+ "$ref": "#/definitions/CDPLaunchOptions"
9
13
  },
10
14
  {
11
15
  "type": "string"
12
16
  }
13
17
  ]
14
18
  },
15
- "blockAds": {
16
- "description": "Whether or nor to load ad-blocking extensions for the session.\nThis currently uses uBlock Origin and may cause certain sites\nto not load properly.",
17
- "type": "boolean"
18
- },
19
19
  "record": {
20
20
  "description": "Whether or nor to record the session. The browser will run\nin \"head-full\" mode, and recording is started and closed\nvia the embedded browserless API. Please refer to the \"Recording\"\nsection in the live documentation site for more details.",
21
21
  "type": "boolean"
@@ -29,8 +29,91 @@
29
29
  "type": "string"
30
30
  }
31
31
  },
32
- "additionalProperties": false,
33
32
  "definitions": {
33
+ "CDPLaunchOptions": {
34
+ "type": "object",
35
+ "properties": {
36
+ "args": {
37
+ "type": "array",
38
+ "items": {
39
+ "type": "string"
40
+ }
41
+ },
42
+ "defaultViewport": {
43
+ "type": "object",
44
+ "properties": {
45
+ "deviceScaleFactor": {
46
+ "type": "number"
47
+ },
48
+ "hasTouch": {
49
+ "type": "boolean"
50
+ },
51
+ "height": {
52
+ "type": "number"
53
+ },
54
+ "isLandscape": {
55
+ "type": "boolean"
56
+ },
57
+ "isMobile": {
58
+ "type": "boolean"
59
+ },
60
+ "width": {
61
+ "type": "number"
62
+ }
63
+ },
64
+ "additionalProperties": false,
65
+ "required": [
66
+ "height",
67
+ "width"
68
+ ]
69
+ },
70
+ "devtools": {
71
+ "type": "boolean"
72
+ },
73
+ "dumpio": {
74
+ "type": "boolean"
75
+ },
76
+ "headless": {
77
+ "enum": [
78
+ false,
79
+ "shell",
80
+ true
81
+ ]
82
+ },
83
+ "ignoreDefaultArgs": {
84
+ "anyOf": [
85
+ {
86
+ "type": "array",
87
+ "items": {
88
+ "type": "string"
89
+ }
90
+ },
91
+ {
92
+ "type": "boolean"
93
+ }
94
+ ]
95
+ },
96
+ "ignoreHTTPSErrors": {
97
+ "type": "boolean"
98
+ },
99
+ "slowMo": {
100
+ "type": "number"
101
+ },
102
+ "stealth": {
103
+ "type": "boolean"
104
+ },
105
+ "timeout": {
106
+ "type": "number"
107
+ },
108
+ "userDataDir": {
109
+ "type": "string"
110
+ },
111
+ "waitForInitialPage": {
112
+ "type": "boolean"
113
+ }
114
+ },
115
+ "additionalProperties": false
116
+ },
34
117
  "BrowserServerOptions": {
35
118
  "type": "object",
36
119
  "properties": {
@@ -4,9 +4,9 @@ import path from 'path';
4
4
  const DEFAULT_AUDIT_CONFIG = {
5
5
  extends: 'lighthouse:default',
6
6
  };
7
- const debug = createLogger('http:performance:main');
8
7
  export default async ({ browser, context, timeout, }) => {
9
8
  return new Promise((resolve, reject) => {
9
+ const debug = createLogger('http:performance:main');
10
10
  const childPath = path.join('./', 'build', 'shared', 'utils', 'performance', 'child.js');
11
11
  debug(`Starting up child at ${childPath}`);
12
12
  const child = fork(childPath);
@@ -4,6 +4,8 @@ LABEL org.opencontainers.image.source https://github.com/browserless/browserless
4
4
 
5
5
  COPY fonts/* /usr/share/fonts/truetype/
6
6
  COPY src src/
7
+ # Only use core as exports since routes are lazy loaded and not always present
8
+ COPY src/exports.core.ts src/exports.ts
7
9
  RUN rm -r src/routes/
8
10
  COPY src/routes/management src/routes/management/
9
11
  COPY src/routes/chrome src/routes/chrome/
@@ -4,6 +4,8 @@ LABEL org.opencontainers.image.source https://github.com/browserless/browserless
4
4
 
5
5
  COPY fonts/* /usr/share/fonts/truetype/
6
6
  COPY src src/
7
+ # Only use core as exports since routes are lazy loaded and not always present
8
+ COPY src/exports.core.ts src/exports.ts
7
9
  RUN rm -r src/routes/
8
10
  COPY src/routes/management src/routes/management/
9
11
  COPY src/routes/chromium src/routes/chromium/