@browserless.io/browserless 2.12.0-beta-4 → 2.12.0
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 +9 -1
- package/bin/scaffold/README.md +6 -5
- package/bin/scaffold/src/hello-world.http.ts +3 -3
- package/build/browserless.d.ts +3 -3
- package/build/browserless.js +6 -6
- package/build/browsers/chromium.cdp.d.ts +12 -12
- package/build/browsers/chromium.cdp.js +77 -65
- package/build/browsers/chromium.playwright.d.ts +11 -11
- package/build/browsers/chromium.playwright.js +42 -34
- package/build/browsers/firefox.playwright.d.ts +11 -11
- package/build/browsers/firefox.playwright.js +42 -34
- package/build/browsers/index.d.ts +14 -14
- package/build/browsers/index.js +27 -25
- package/build/browsers/webkit.playwright.d.ts +11 -11
- package/build/browsers/webkit.playwright.js +43 -35
- package/build/config.d.ts +65 -63
- package/build/config.js +162 -102
- package/build/file-system.d.ts +4 -4
- package/build/file-system.js +8 -8
- package/build/hooks.d.ts +2 -2
- package/build/hooks.js +4 -4
- package/build/limiter.d.ts +4 -4
- package/build/limiter.js +10 -10
- package/build/logger.d.ts +6 -6
- package/build/logger.js +12 -12
- package/build/metrics.d.ts +12 -12
- package/build/metrics.js +23 -23
- package/build/monitoring.d.ts +4 -4
- package/build/monitoring.js +8 -8
- package/build/router.d.ts +8 -8
- package/build/router.js +74 -70
- package/build/routes/chrome/http/pdf.post.body.json +8 -8
- package/build/routes/chrome/http/scrape.post.body.json +8 -8
- package/build/routes/chrome/http/screenshot.post.body.json +8 -8
- package/build/routes/chromium/http/content.post.body.json +8 -8
- package/build/routes/chromium/http/pdf.post.body.json +8 -8
- package/build/routes/chromium/http/scrape.post.body.json +8 -8
- package/build/routes/chromium/http/screenshot.post.body.json +8 -8
- package/build/routes/firefox/ws/playwright.d.ts +1 -1
- package/build/routes/firefox/ws/playwright.js +2 -2
- package/build/routes/management/http/active.get.d.ts +1 -1
- package/build/routes/management/http/active.get.js +3 -1
- package/build/routes/management/http/config.get.d.ts +1 -1
- package/build/routes/management/http/config.get.js +2 -2
- package/build/routes/management/http/metrics-total.get.d.ts +1 -1
- package/build/routes/management/http/metrics-total.get.js +2 -2
- package/build/routes/management/http/metrics.get.d.ts +1 -1
- package/build/routes/management/http/metrics.get.js +2 -2
- package/build/routes/management/http/pressure.get.d.ts +1 -1
- package/build/routes/management/http/pressure.get.js +2 -2
- package/build/routes/management/http/sessions.get.d.ts +1 -1
- package/build/routes/management/http/sessions.get.js +2 -2
- package/build/routes/management/http/static.get.d.ts +1 -1
- package/build/routes/management/http/static.get.js +2 -2
- package/build/routes/webkit/ws/playwright.d.ts +1 -1
- package/build/routes/webkit/ws/playwright.js +2 -2
- package/build/server.d.ts +5 -5
- package/build/server.js +11 -11
- package/build/shared/browser.ws.d.ts +1 -1
- package/build/shared/browser.ws.js +3 -1
- package/build/shared/chromium.playwright.ws.d.ts +1 -1
- package/build/shared/chromium.playwright.ws.js +2 -2
- package/build/shared/chromium.ws.d.ts +1 -1
- package/build/shared/chromium.ws.js +3 -1
- package/build/shared/content.http.d.ts +1 -1
- package/build/shared/content.http.js +2 -2
- package/build/shared/download.http.d.ts +1 -1
- package/build/shared/download.http.js +60 -58
- package/build/shared/function.http.d.ts +1 -1
- package/build/shared/function.http.js +2 -2
- package/build/shared/json-list.http.d.ts +1 -1
- package/build/shared/json-list.http.js +2 -2
- package/build/shared/json-new.http.d.ts +1 -1
- package/build/shared/json-new.http.js +2 -2
- package/build/shared/json-protocol.http.d.ts +1 -1
- package/build/shared/json-protocol.http.js +2 -2
- package/build/shared/json-version.http.d.ts +1 -1
- package/build/shared/json-version.http.js +2 -2
- package/build/shared/page.ws.d.ts +1 -1
- package/build/shared/page.ws.js +3 -1
- package/build/shared/pdf.http.d.ts +1 -1
- package/build/shared/pdf.http.js +2 -2
- package/build/shared/performance.http.d.ts +1 -1
- package/build/shared/performance.http.js +2 -2
- package/build/shared/scrape.http.d.ts +1 -1
- package/build/shared/scrape.http.js +2 -2
- package/build/shared/screenshot.http.d.ts +1 -1
- package/build/shared/screenshot.http.js +2 -2
- package/build/shared/utils/function/client.d.ts +1 -1
- package/build/shared/utils/function/client.js +3 -1
- package/build/shim.d.ts +1 -1
- package/build/shim.js +2 -2
- package/build/token.d.ts +3 -3
- package/build/token.js +6 -6
- package/build/types.d.ts +4 -4
- package/build/webhooks.d.ts +2 -2
- package/build/webhooks.js +4 -4
- package/package.json +3 -3
- package/src/browserless.ts +6 -6
- package/src/browsers/chromium.cdp.ts +33 -23
- package/src/browsers/chromium.playwright.ts +28 -21
- package/src/browsers/firefox.playwright.ts +28 -21
- package/src/browsers/index.ts +32 -29
- package/src/browsers/webkit.playwright.ts +29 -22
- package/src/config.ts +166 -104
- package/src/file-system.ts +9 -9
- package/src/hooks.ts +4 -4
- package/src/limiter.ts +12 -12
- package/src/logger.ts +12 -12
- package/src/metrics.ts +23 -23
- package/src/monitoring.ts +9 -9
- package/src/router.ts +31 -31
- package/src/routes/firefox/ws/playwright.ts +3 -3
- package/src/routes/management/http/active.get.ts +3 -2
- package/src/routes/management/http/config.get.ts +2 -2
- package/src/routes/management/http/metrics-total.get.ts +2 -2
- package/src/routes/management/http/metrics.get.ts +2 -2
- package/src/routes/management/http/pressure.get.ts +2 -2
- package/src/routes/management/http/sessions.get.ts +2 -2
- package/src/routes/management/http/static.get.ts +3 -3
- package/src/routes/webkit/ws/playwright.ts +3 -3
- package/src/server.ts +14 -16
- package/src/shared/browser.ws.ts +4 -2
- package/src/shared/chromium.playwright.ws.ts +3 -3
- package/src/shared/chromium.ws.ts +4 -2
- package/src/shared/content.http.ts +3 -3
- package/src/shared/download.http.ts +4 -3
- package/src/shared/function.http.ts +3 -3
- package/src/shared/json-list.http.ts +2 -2
- package/src/shared/json-new.http.ts +2 -2
- package/src/shared/json-protocol.http.ts +2 -6
- package/src/shared/json-version.http.ts +2 -6
- package/src/shared/page.ws.ts +4 -2
- package/src/shared/pdf.http.ts +3 -3
- package/src/shared/performance.http.ts +3 -3
- package/src/shared/scrape.http.ts +3 -3
- package/src/shared/screenshot.http.ts +3 -3
- package/src/shared/utils/function/client.ts +3 -1
- package/src/shim.ts +2 -2
- package/src/token.ts +7 -7
- package/src/types.ts +7 -7
- package/src/webhooks.ts +4 -4
- package/static/docs/swagger.json +2 -2
- package/static/docs/swagger.min.json +1 -1
- package/static/function/client.js +3 -1
- package/static/function/index.html +3 -1
package/build/config.js
CHANGED
|
@@ -142,49 +142,99 @@ export class Config extends EventEmitter {
|
|
|
142
142
|
timeoutAlertURL = process.env.TIMEOUT_ALERT_URL ?? null;
|
|
143
143
|
errorAlertURL = process.env.ERROR_ALERT_URL ?? null;
|
|
144
144
|
pwVersions = {};
|
|
145
|
-
getRoutes
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
getRoutes() {
|
|
146
|
+
return this.routes;
|
|
147
|
+
}
|
|
148
|
+
getHost() {
|
|
149
|
+
return this.host;
|
|
150
|
+
}
|
|
151
|
+
getPort() {
|
|
152
|
+
return this.port;
|
|
153
|
+
}
|
|
154
|
+
getIsWin() {
|
|
155
|
+
return this.isWin;
|
|
156
|
+
}
|
|
157
|
+
getToken() {
|
|
158
|
+
return this.token;
|
|
159
|
+
}
|
|
160
|
+
getDebug() {
|
|
161
|
+
return this.debug;
|
|
162
|
+
}
|
|
163
|
+
getPwVersions() {
|
|
164
|
+
return this.pwVersions;
|
|
165
|
+
}
|
|
152
166
|
/**
|
|
153
167
|
* The maximum number of concurrent sessions allowed. Set
|
|
154
168
|
* to "-1" or "Infinity" for no limit.
|
|
155
169
|
* @returns number
|
|
156
170
|
*/
|
|
157
|
-
getConcurrent
|
|
171
|
+
getConcurrent() {
|
|
172
|
+
return this.concurrent;
|
|
173
|
+
}
|
|
158
174
|
/**
|
|
159
175
|
* The maximum number of queued sessions allowed. Set to
|
|
160
176
|
* "-1" or "Infinity" for no limit.
|
|
161
177
|
* @returns number
|
|
162
178
|
*/
|
|
163
|
-
getQueued
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
179
|
+
getQueued() {
|
|
180
|
+
return this.queued;
|
|
181
|
+
}
|
|
182
|
+
getTimeout() {
|
|
183
|
+
return this.timeout;
|
|
184
|
+
}
|
|
185
|
+
getStatic() {
|
|
186
|
+
return this.static;
|
|
187
|
+
}
|
|
188
|
+
getDebuggerDir() {
|
|
189
|
+
return this.debuggerDir;
|
|
190
|
+
}
|
|
191
|
+
getRetries() {
|
|
192
|
+
return this.retries;
|
|
193
|
+
}
|
|
194
|
+
getAllowFileProtocol() {
|
|
195
|
+
return this.allowFileProtocol;
|
|
196
|
+
}
|
|
197
|
+
getCPULimit() {
|
|
198
|
+
return this.maxCpu;
|
|
199
|
+
}
|
|
200
|
+
getMemoryLimit() {
|
|
201
|
+
return this.maxMemory;
|
|
202
|
+
}
|
|
203
|
+
getHealthChecksEnabled() {
|
|
204
|
+
return this.healthCheck;
|
|
205
|
+
}
|
|
206
|
+
getFailedHealthURL() {
|
|
207
|
+
return this.failedHealthURL;
|
|
208
|
+
}
|
|
209
|
+
getQueueAlertURL() {
|
|
210
|
+
return this.queueAlertURL;
|
|
211
|
+
}
|
|
212
|
+
getRejectAlertURL() {
|
|
213
|
+
return this.rejectAlertURL;
|
|
214
|
+
}
|
|
215
|
+
getTimeoutAlertURL() {
|
|
216
|
+
return this.timeoutAlertURL;
|
|
217
|
+
}
|
|
218
|
+
getErrorAlertURL() {
|
|
219
|
+
return this.errorAlertURL;
|
|
220
|
+
}
|
|
221
|
+
hasDebugger() {
|
|
222
|
+
return exists(this.debuggerDir);
|
|
223
|
+
}
|
|
178
224
|
/**
|
|
179
225
|
* If true, allows GET style calls on our browser-based APIs, using
|
|
180
226
|
* ?body=JSON format.
|
|
181
227
|
*/
|
|
182
|
-
getAllowGetCalls
|
|
228
|
+
getAllowGetCalls() {
|
|
229
|
+
return this.allowGet;
|
|
230
|
+
}
|
|
183
231
|
/**
|
|
184
232
|
* Determines if CORS is allowed
|
|
185
233
|
*/
|
|
186
|
-
getAllowCORS
|
|
187
|
-
|
|
234
|
+
getAllowCORS() {
|
|
235
|
+
return this.allowCors;
|
|
236
|
+
}
|
|
237
|
+
async getDataDir() {
|
|
188
238
|
if (this.createDataDir && !(await exists(this.dataDir))) {
|
|
189
239
|
await mkdir(this.dataDir, { recursive: true }).catch((err) => {
|
|
190
240
|
throw new Error(`Error in creating the data directory ${err}, exiting`);
|
|
@@ -195,8 +245,8 @@ export class Config extends EventEmitter {
|
|
|
195
245
|
throw new Error(`"${this.dataDir}" Directory doesn't exist, did you forget to mount or make it?`);
|
|
196
246
|
}
|
|
197
247
|
return this.dataDir;
|
|
198
|
-
}
|
|
199
|
-
|
|
248
|
+
}
|
|
249
|
+
async getDownloadsDir() {
|
|
200
250
|
if (this.createDownloadsDir && !(await exists(this.downloadsDir))) {
|
|
201
251
|
await mkdir(this.downloadsDir, { recursive: true }).catch((err) => {
|
|
202
252
|
throw new Error(`Error in creating the downloads directory ${err}, exiting`);
|
|
@@ -207,21 +257,23 @@ export class Config extends EventEmitter {
|
|
|
207
257
|
throw new Error(`"${this.downloadsDir}" Directory doesn't exist, did you forget to mount or make it?`);
|
|
208
258
|
}
|
|
209
259
|
return this.downloadsDir;
|
|
210
|
-
}
|
|
260
|
+
}
|
|
211
261
|
/**
|
|
212
262
|
* Repeats the TOKEN parameter up to 24 characters so we can
|
|
213
263
|
* do AES encoding for saving things to disk and generating
|
|
214
264
|
* secure links.
|
|
215
265
|
*/
|
|
216
|
-
getAESKey
|
|
266
|
+
getAESKey() {
|
|
217
267
|
const aesToken = this.token || 'browserless';
|
|
218
268
|
return Buffer.from(aesToken.repeat(keyLength).substring(0, keyLength));
|
|
219
|
-
}
|
|
220
|
-
getMetricsJSONPath
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
269
|
+
}
|
|
270
|
+
getMetricsJSONPath() {
|
|
271
|
+
return this.metricsJSONPath;
|
|
272
|
+
}
|
|
273
|
+
setPwVersions(versions) {
|
|
274
|
+
return (this.pwVersions = versions);
|
|
275
|
+
}
|
|
276
|
+
async loadPwVersion(version) {
|
|
225
277
|
const versions = this.getPwVersions();
|
|
226
278
|
try {
|
|
227
279
|
return await import(versions[version] || versions['default']);
|
|
@@ -230,107 +282,107 @@ export class Config extends EventEmitter {
|
|
|
230
282
|
debug.log('Error importing Playwright. Using default version', err);
|
|
231
283
|
return playwright;
|
|
232
284
|
}
|
|
233
|
-
}
|
|
234
|
-
|
|
285
|
+
}
|
|
286
|
+
async setDataDir(newDataDir) {
|
|
235
287
|
if (!(await exists(newDataDir))) {
|
|
236
288
|
throw new Error(`New data-directory "${newDataDir}" doesn't exist, did you forget to mount or create it?`);
|
|
237
289
|
}
|
|
238
290
|
this.dataDir = newDataDir;
|
|
239
291
|
this.emit('data-dir', newDataDir);
|
|
240
292
|
return this.dataDir;
|
|
241
|
-
}
|
|
242
|
-
setRoutes
|
|
293
|
+
}
|
|
294
|
+
setRoutes(newRoutePath) {
|
|
243
295
|
this.emit('routes', newRoutePath);
|
|
244
296
|
return (this.routes = newRoutePath);
|
|
245
|
-
}
|
|
246
|
-
setConcurrent
|
|
297
|
+
}
|
|
298
|
+
setConcurrent(newConcurrent) {
|
|
247
299
|
this.emit('concurrent', newConcurrent);
|
|
248
300
|
return (this.concurrent = newConcurrent);
|
|
249
|
-
}
|
|
250
|
-
setQueued
|
|
301
|
+
}
|
|
302
|
+
setQueued(newQueued) {
|
|
251
303
|
this.emit('queued', newQueued);
|
|
252
304
|
return (this.queued = newQueued);
|
|
253
|
-
}
|
|
254
|
-
setToken
|
|
305
|
+
}
|
|
306
|
+
setToken(newToken) {
|
|
255
307
|
this.emit('token', newToken);
|
|
256
308
|
return (this.token = newToken);
|
|
257
|
-
}
|
|
258
|
-
setTimeout
|
|
309
|
+
}
|
|
310
|
+
setTimeout(newTimeout) {
|
|
259
311
|
this.emit('timeout', newTimeout);
|
|
260
312
|
return (this.timeout = newTimeout);
|
|
261
|
-
}
|
|
262
|
-
setStatic
|
|
313
|
+
}
|
|
314
|
+
setStatic(newStatic) {
|
|
263
315
|
this.emit('static', newStatic);
|
|
264
316
|
return (this.static = newStatic);
|
|
265
|
-
}
|
|
266
|
-
setRetries
|
|
317
|
+
}
|
|
318
|
+
setRetries(newRetries) {
|
|
267
319
|
this.emit('retries', newRetries);
|
|
268
320
|
return (this.retries = newRetries);
|
|
269
|
-
}
|
|
270
|
-
setCPULimit
|
|
321
|
+
}
|
|
322
|
+
setCPULimit(limit) {
|
|
271
323
|
this.emit('cpuLimit', limit);
|
|
272
324
|
return (this.maxCpu = limit);
|
|
273
|
-
}
|
|
274
|
-
setMemoryLimit
|
|
325
|
+
}
|
|
326
|
+
setMemoryLimit(limit) {
|
|
275
327
|
this.emit('memoryLimit', limit);
|
|
276
328
|
return (this.maxMemory = limit);
|
|
277
|
-
}
|
|
278
|
-
enableHealthChecks
|
|
329
|
+
}
|
|
330
|
+
enableHealthChecks(enable) {
|
|
279
331
|
this.emit('healthCheck', enable);
|
|
280
332
|
return (this.healthCheck = enable);
|
|
281
|
-
}
|
|
282
|
-
enableGETRequests
|
|
333
|
+
}
|
|
334
|
+
enableGETRequests(enable) {
|
|
283
335
|
this.emit('getRequests', enable);
|
|
284
336
|
return (this.allowGet = enable);
|
|
285
|
-
}
|
|
286
|
-
enableCORS
|
|
337
|
+
}
|
|
338
|
+
enableCORS(enable) {
|
|
287
339
|
this.emit('cors', enable);
|
|
288
340
|
return (this.allowCors = enable);
|
|
289
|
-
}
|
|
290
|
-
setCORSMethods
|
|
341
|
+
}
|
|
342
|
+
setCORSMethods(methods) {
|
|
291
343
|
this.emit('corsMethods', methods);
|
|
292
344
|
return (this.corsMethods = methods);
|
|
293
|
-
}
|
|
294
|
-
setCORSOrigin
|
|
345
|
+
}
|
|
346
|
+
setCORSOrigin(origin) {
|
|
295
347
|
this.emit('corsOrigin', origin);
|
|
296
348
|
return (this.corsOrigin = origin);
|
|
297
|
-
}
|
|
298
|
-
setCORSMaxAge
|
|
349
|
+
}
|
|
350
|
+
setCORSMaxAge(maxAge) {
|
|
299
351
|
this.emit('corsMaxAge', maxAge);
|
|
300
352
|
return (this.corsMaxAge = maxAge);
|
|
301
|
-
}
|
|
302
|
-
setFailedHealthURL
|
|
353
|
+
}
|
|
354
|
+
setFailedHealthURL(url) {
|
|
303
355
|
this.emit('failedHealthURL');
|
|
304
356
|
return (this.failedHealthURL = url);
|
|
305
|
-
}
|
|
306
|
-
setQueueAlertURL
|
|
357
|
+
}
|
|
358
|
+
setQueueAlertURL(url) {
|
|
307
359
|
this.emit('queueAlertURL');
|
|
308
360
|
return (this.queueAlertURL = url);
|
|
309
|
-
}
|
|
310
|
-
setRejectAlertURL
|
|
361
|
+
}
|
|
362
|
+
setRejectAlertURL(url) {
|
|
311
363
|
this.emit('rejectAlertURL');
|
|
312
364
|
return (this.rejectAlertURL = url);
|
|
313
|
-
}
|
|
314
|
-
setTimeoutAlertURL
|
|
365
|
+
}
|
|
366
|
+
setTimeoutAlertURL(url) {
|
|
315
367
|
this.emit('timeoutAlertURL');
|
|
316
368
|
return (this.timeoutAlertURL = url);
|
|
317
|
-
}
|
|
318
|
-
setErrorAlertURL
|
|
369
|
+
}
|
|
370
|
+
setErrorAlertURL(url) {
|
|
319
371
|
this.emit('errorAlertURL');
|
|
320
372
|
return (this.errorAlertURL = url);
|
|
321
|
-
}
|
|
322
|
-
setMetricsJSONPath
|
|
373
|
+
}
|
|
374
|
+
setMetricsJSONPath(path) {
|
|
323
375
|
this.emit('metricsJSONPath', path);
|
|
324
376
|
return (this.metricsJSONPath = path);
|
|
325
|
-
}
|
|
326
|
-
setPort
|
|
377
|
+
}
|
|
378
|
+
setPort(port) {
|
|
327
379
|
this.emit('port', port);
|
|
328
380
|
return (this.port = port);
|
|
329
|
-
}
|
|
330
|
-
setAllowFileProtocol
|
|
381
|
+
}
|
|
382
|
+
setAllowFileProtocol(allow) {
|
|
331
383
|
this.emit('allowFileProtocol', allow);
|
|
332
384
|
return (this.allowFileProtocol = allow);
|
|
333
|
-
}
|
|
385
|
+
}
|
|
334
386
|
/**
|
|
335
387
|
* Returns the fully-qualified server address, which
|
|
336
388
|
* includes host, protocol, and port for which the
|
|
@@ -340,11 +392,13 @@ export class Config extends EventEmitter {
|
|
|
340
392
|
*
|
|
341
393
|
* @returns Fully-qualified server address
|
|
342
394
|
*/
|
|
343
|
-
getServerAddress
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
395
|
+
getServerAddress() {
|
|
396
|
+
return this.port === 443
|
|
397
|
+
? `https://${this.host}:${this.port}`
|
|
398
|
+
: this.port === 80
|
|
399
|
+
? `http://${this.host}`
|
|
400
|
+
: `http://${this.host}:${this.port}`;
|
|
401
|
+
}
|
|
348
402
|
/**
|
|
349
403
|
* Returns the fully-qualified URL for the
|
|
350
404
|
* external address that browserless might be
|
|
@@ -353,7 +407,9 @@ export class Config extends EventEmitter {
|
|
|
353
407
|
*
|
|
354
408
|
* @returns {string} The URL to reach the server
|
|
355
409
|
*/
|
|
356
|
-
getExternalAddress
|
|
410
|
+
getExternalAddress() {
|
|
411
|
+
return this.external ?? this.getServerAddress();
|
|
412
|
+
}
|
|
357
413
|
/**
|
|
358
414
|
* Set the external URL, which Browserless uses for encoding
|
|
359
415
|
* URLs over the HOST:PORT that it's bound to.
|
|
@@ -361,7 +417,9 @@ export class Config extends EventEmitter {
|
|
|
361
417
|
* @param address The fully-qualified URL, eg https://www.example.com/
|
|
362
418
|
* @returns {string} The address
|
|
363
419
|
*/
|
|
364
|
-
setExternalAddress
|
|
420
|
+
setExternalAddress(address) {
|
|
421
|
+
return (this.external = address);
|
|
422
|
+
}
|
|
365
423
|
/**
|
|
366
424
|
* Returns the fully-qualified WebSocket URL for the
|
|
367
425
|
* external address that browserless might be
|
|
@@ -370,33 +428,35 @@ export class Config extends EventEmitter {
|
|
|
370
428
|
*
|
|
371
429
|
* @returns {string} The URL to reach the server
|
|
372
430
|
*/
|
|
373
|
-
getExternalWebSocketAddress
|
|
431
|
+
getExternalWebSocketAddress() {
|
|
374
432
|
const httpAddress = new URL(this.external ?? this.getServerAddress());
|
|
375
433
|
httpAddress.protocol = httpAddress.protocol.startsWith('https')
|
|
376
434
|
? 'wss:'
|
|
377
435
|
: 'ws:';
|
|
378
436
|
return httpAddress.href;
|
|
379
|
-
}
|
|
437
|
+
}
|
|
380
438
|
/**
|
|
381
439
|
* When CORS is enabled, returns relevant CORS headers
|
|
382
440
|
* to requests and for the OPTIONS call. Values can be
|
|
383
441
|
* overridden by specifying `CORS_ALLOW_METHODS`, `CORS_ALLOW_ORIGIN`,
|
|
384
442
|
* and `CORS_MAX_AGE`
|
|
385
443
|
*/
|
|
386
|
-
getCORSHeaders
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
444
|
+
getCORSHeaders() {
|
|
445
|
+
return {
|
|
446
|
+
'Access-Control-Allow-Methods': this.corsMethods,
|
|
447
|
+
'Access-Control-Allow-Origin': this.corsOrigin,
|
|
448
|
+
'Access-Control-Max-Age': this.corsMaxAge,
|
|
449
|
+
};
|
|
450
|
+
}
|
|
391
451
|
/**
|
|
392
452
|
* Implement any browserless-core-specific shutdown logic here.
|
|
393
453
|
* Calls the empty-SDK stop method for downstream implementations.
|
|
394
454
|
*/
|
|
395
|
-
|
|
455
|
+
async shutdown() {
|
|
396
456
|
await this.stop();
|
|
397
|
-
}
|
|
457
|
+
}
|
|
398
458
|
/**
|
|
399
459
|
* Left blank for downstream SDK modules to optionally implement.
|
|
400
460
|
*/
|
|
401
|
-
stop
|
|
461
|
+
stop() { }
|
|
402
462
|
}
|
package/build/file-system.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare class FileSystem extends EventEmitter {
|
|
|
17
17
|
* @param newContent A string of new content to add to the file
|
|
18
18
|
* @returns void
|
|
19
19
|
*/
|
|
20
|
-
append
|
|
20
|
+
append(path: string, newContent: string, shouldEncode: boolean): Promise<void>;
|
|
21
21
|
/**
|
|
22
22
|
* Reads contents from the local map, if any exist, or loads
|
|
23
23
|
* from the file system and hydrates the cache for the particular filepath
|
|
@@ -25,14 +25,14 @@ export declare class FileSystem extends EventEmitter {
|
|
|
25
25
|
* @param path The filepath of the contents to read
|
|
26
26
|
* @returns Promise of the contents separated by newlines
|
|
27
27
|
*/
|
|
28
|
-
read
|
|
28
|
+
read(path: string, encoded: boolean): Promise<string[]>;
|
|
29
29
|
/**
|
|
30
30
|
* Implement any browserless-core-specific shutdown logic here.
|
|
31
31
|
* Calls the empty-SDK stop method for downstream implementations.
|
|
32
32
|
*/
|
|
33
|
-
shutdown
|
|
33
|
+
shutdown(): Promise<void>;
|
|
34
34
|
/**
|
|
35
35
|
* Left blank for downstream SDK modules to optionally implement.
|
|
36
36
|
*/
|
|
37
|
-
stop
|
|
37
|
+
stop(): void;
|
|
38
38
|
}
|
package/build/file-system.js
CHANGED
|
@@ -20,7 +20,7 @@ export class FileSystem extends EventEmitter {
|
|
|
20
20
|
* @param newContent A string of new content to add to the file
|
|
21
21
|
* @returns void
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
async append(path, newContent, shouldEncode) {
|
|
24
24
|
const contents = await this.read(path, shouldEncode);
|
|
25
25
|
contents.push(newContent);
|
|
26
26
|
this.fsMap.set(path, contents);
|
|
@@ -28,7 +28,7 @@ export class FileSystem extends EventEmitter {
|
|
|
28
28
|
? await encrypt(contents.join('\n'), this.currentAESKey)
|
|
29
29
|
: contents.join('\n');
|
|
30
30
|
return writeFile(path, encoded.toString());
|
|
31
|
-
}
|
|
31
|
+
}
|
|
32
32
|
/**
|
|
33
33
|
* Reads contents from the local map, if any exist, or loads
|
|
34
34
|
* from the file system and hydrates the cache for the particular filepath
|
|
@@ -36,7 +36,7 @@ export class FileSystem extends EventEmitter {
|
|
|
36
36
|
* @param path The filepath of the contents to read
|
|
37
37
|
* @returns Promise of the contents separated by newlines
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
async read(path, encoded) {
|
|
40
40
|
const hasKey = this.fsMap.has(path);
|
|
41
41
|
if (hasKey) {
|
|
42
42
|
return this.fsMap.get(path);
|
|
@@ -48,16 +48,16 @@ export class FileSystem extends EventEmitter {
|
|
|
48
48
|
const splitContents = decoded.length ? decoded.split('\n') : [];
|
|
49
49
|
this.fsMap.set(path, splitContents);
|
|
50
50
|
return splitContents;
|
|
51
|
-
}
|
|
51
|
+
}
|
|
52
52
|
/**
|
|
53
53
|
* Implement any browserless-core-specific shutdown logic here.
|
|
54
54
|
* Calls the empty-SDK stop method for downstream implementations.
|
|
55
55
|
*/
|
|
56
|
-
|
|
57
|
-
await this.stop();
|
|
58
|
-
}
|
|
56
|
+
async shutdown() {
|
|
57
|
+
return await this.stop();
|
|
58
|
+
}
|
|
59
59
|
/**
|
|
60
60
|
* Left blank for downstream SDK modules to optionally implement.
|
|
61
61
|
*/
|
|
62
|
-
stop
|
|
62
|
+
stop() { }
|
|
63
63
|
}
|
package/build/hooks.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ export declare class Hooks extends EventEmitter {
|
|
|
10
10
|
* Implement any browserless-core-specific shutdown logic here.
|
|
11
11
|
* Calls the empty-SDK stop method for downstream implementations.
|
|
12
12
|
*/
|
|
13
|
-
shutdown
|
|
13
|
+
shutdown(): Promise<void>;
|
|
14
14
|
/**
|
|
15
15
|
* Left blank for downstream SDK modules to optionally implement.
|
|
16
16
|
*/
|
|
17
|
-
stop
|
|
17
|
+
stop(): void;
|
|
18
18
|
}
|
package/build/hooks.js
CHANGED
|
@@ -27,11 +27,11 @@ export class Hooks extends EventEmitter {
|
|
|
27
27
|
* Implement any browserless-core-specific shutdown logic here.
|
|
28
28
|
* Calls the empty-SDK stop method for downstream implementations.
|
|
29
29
|
*/
|
|
30
|
-
|
|
31
|
-
await this.stop();
|
|
32
|
-
}
|
|
30
|
+
async shutdown() {
|
|
31
|
+
return await this.stop();
|
|
32
|
+
}
|
|
33
33
|
/**
|
|
34
34
|
* Left blank for downstream SDK modules to optionally implement.
|
|
35
35
|
*/
|
|
36
|
-
stop
|
|
36
|
+
stop() { }
|
|
37
37
|
}
|
package/build/limiter.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type ErrorFn<TArgs extends unknown[]> = (...args: TArgs) => void;
|
|
|
5
5
|
interface Job {
|
|
6
6
|
(): Promise<unknown>;
|
|
7
7
|
args: unknown[];
|
|
8
|
-
onTimeoutFn
|
|
8
|
+
onTimeoutFn(job: Job): unknown;
|
|
9
9
|
start: number;
|
|
10
10
|
timeout: number;
|
|
11
11
|
}
|
|
@@ -43,15 +43,15 @@ export declare class Limiter extends q {
|
|
|
43
43
|
get willQueue(): boolean;
|
|
44
44
|
get concurrencySize(): number;
|
|
45
45
|
get hasCapacity(): boolean;
|
|
46
|
-
limit
|
|
46
|
+
limit<TArgs extends unknown[], TResult>(limitFn: LimitFn<TArgs, TResult>, overCapacityFn: ErrorFn<TArgs>, onTimeoutFn: ErrorFn<TArgs>, timeoutOverrideFn: (...args: TArgs) => number | undefined): LimitFn<TArgs, unknown>;
|
|
47
47
|
/**
|
|
48
48
|
* Implement any browserless-core-specific shutdown logic here.
|
|
49
49
|
* Calls the empty-SDK stop method for downstream implementations.
|
|
50
50
|
*/
|
|
51
|
-
shutdown
|
|
51
|
+
shutdown(): Promise<void>;
|
|
52
52
|
/**
|
|
53
53
|
* Left blank for downstream SDK modules to optionally implement.
|
|
54
54
|
*/
|
|
55
|
-
stop
|
|
55
|
+
stop(): void;
|
|
56
56
|
}
|
|
57
57
|
export {};
|
package/build/limiter.js
CHANGED
|
@@ -34,12 +34,12 @@ export class Limiter extends q {
|
|
|
34
34
|
this.timeout = timeout <= 0 ? 0 : timeout;
|
|
35
35
|
});
|
|
36
36
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
this.addEventListener('timeout', this.handleJobTimeout);
|
|
37
|
+
this.addEventListener('timeout', this.handleJobTimeout.bind(this));
|
|
38
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
-
this.addEventListener('success', this.handleSuccess);
|
|
39
|
+
this.addEventListener('success', this.handleSuccess.bind(this));
|
|
40
40
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
-
this.addEventListener('error', this.handleFail);
|
|
42
|
-
this.addEventListener('end', this.handleEnd);
|
|
41
|
+
this.addEventListener('error', this.handleFail.bind(this));
|
|
42
|
+
this.addEventListener('end', this.handleEnd.bind(this));
|
|
43
43
|
}
|
|
44
44
|
handleEnd() {
|
|
45
45
|
this.logQueue('All jobs complete.');
|
|
@@ -100,7 +100,7 @@ export class Limiter extends q {
|
|
|
100
100
|
get hasCapacity() {
|
|
101
101
|
return this.length < this.concurrency + this.queued;
|
|
102
102
|
}
|
|
103
|
-
limit
|
|
103
|
+
limit(limitFn, overCapacityFn, onTimeoutFn, timeoutOverrideFn) {
|
|
104
104
|
return (...args) => new Promise(async (res, rej) => {
|
|
105
105
|
const timeout = timeoutOverrideFn(...args) ?? this.timeout;
|
|
106
106
|
this.logQueue(`Adding to queue, max time allowed is ${timeout.toLocaleString()}ms`);
|
|
@@ -148,16 +148,16 @@ export class Limiter extends q {
|
|
|
148
148
|
this.push(job);
|
|
149
149
|
return bound;
|
|
150
150
|
});
|
|
151
|
-
}
|
|
151
|
+
}
|
|
152
152
|
/**
|
|
153
153
|
* Implement any browserless-core-specific shutdown logic here.
|
|
154
154
|
* Calls the empty-SDK stop method for downstream implementations.
|
|
155
155
|
*/
|
|
156
|
-
|
|
157
|
-
await this.stop();
|
|
158
|
-
}
|
|
156
|
+
async shutdown() {
|
|
157
|
+
return await this.stop();
|
|
158
|
+
}
|
|
159
159
|
/**
|
|
160
160
|
* Left blank for downstream SDK modules to optionally implement.
|
|
161
161
|
*/
|
|
162
|
-
stop
|
|
162
|
+
stop() { }
|
|
163
163
|
}
|
package/build/logger.d.ts
CHANGED
|
@@ -10,10 +10,10 @@ export declare class Logger {
|
|
|
10
10
|
protected _fatal: (...args: unknown[]) => void;
|
|
11
11
|
constructor(prefix: string, request?: Request | undefined);
|
|
12
12
|
protected get reqInfo(): string;
|
|
13
|
-
trace
|
|
14
|
-
debug
|
|
15
|
-
info
|
|
16
|
-
warn
|
|
17
|
-
error
|
|
18
|
-
fatal
|
|
13
|
+
trace(...messages: unknown[]): void;
|
|
14
|
+
debug(...messages: unknown[]): void;
|
|
15
|
+
info(...messages: unknown[]): void;
|
|
16
|
+
warn(...messages: unknown[]): void;
|
|
17
|
+
error(...messages: unknown[]): void;
|
|
18
|
+
fatal(...messages: unknown[]): void;
|
|
19
19
|
}
|
package/build/logger.js
CHANGED
|
@@ -22,22 +22,22 @@ export class Logger {
|
|
|
22
22
|
get reqInfo() {
|
|
23
23
|
return this.request ? this.request.socket.remoteAddress ?? 'Unknown' : '';
|
|
24
24
|
}
|
|
25
|
-
trace
|
|
25
|
+
trace(...messages) {
|
|
26
26
|
this._trace(this.reqInfo, ...messages);
|
|
27
|
-
}
|
|
28
|
-
debug
|
|
27
|
+
}
|
|
28
|
+
debug(...messages) {
|
|
29
29
|
this._debug(this.reqInfo, ...messages);
|
|
30
|
-
}
|
|
31
|
-
info
|
|
30
|
+
}
|
|
31
|
+
info(...messages) {
|
|
32
32
|
this._info(this.reqInfo, ...messages);
|
|
33
|
-
}
|
|
34
|
-
warn
|
|
33
|
+
}
|
|
34
|
+
warn(...messages) {
|
|
35
35
|
this._warn(this.reqInfo, ...messages);
|
|
36
|
-
}
|
|
37
|
-
error
|
|
36
|
+
}
|
|
37
|
+
error(...messages) {
|
|
38
38
|
this._error(this.reqInfo, ...messages);
|
|
39
|
-
}
|
|
40
|
-
fatal
|
|
39
|
+
}
|
|
40
|
+
fatal(...messages) {
|
|
41
41
|
this._fatal(this.reqInfo, ...messages);
|
|
42
|
-
}
|
|
42
|
+
}
|
|
43
43
|
}
|