@browserless.io/browserless 2.6.0 → 2.6.1-beta-2

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.
@@ -121,14 +121,15 @@ export class ChromiumCDP extends EventEmitter {
121
121
  if (!this.browserWSEndpoint) {
122
122
  return null;
123
123
  }
124
- const serverURL = new URL(this.config.getExternalWebSocketAddress());
125
- const wsURL = new URL(this.browserWSEndpoint);
126
- wsURL.host = serverURL.host;
127
- wsURL.port = serverURL.port;
124
+ const externalURL = new URL(this.config.getExternalWebSocketAddress());
125
+ const internalURL = new URL(this.browserWSEndpoint);
126
+ internalURL.host = externalURL.host;
127
+ internalURL.port = externalURL.port;
128
+ internalURL.protocol = externalURL.protocol;
128
129
  if (token) {
129
- wsURL.searchParams.set('token', token);
130
+ internalURL.searchParams.set('token', token);
130
131
  }
131
- return wsURL.href;
132
+ return internalURL.href;
132
133
  };
133
134
  proxyPageWebSocket = async (req, socket, head) => new Promise(async (resolve, reject) => {
134
135
  if (!this.browserWSEndpoint || !this.browser) {
@@ -68,14 +68,15 @@ export class ChromiumPlaywright extends EventEmitter {
68
68
  if (!this.browserWSEndpoint) {
69
69
  return null;
70
70
  }
71
- const serverURL = new URL(this.config.getExternalWebSocketAddress());
72
- const wsURL = new URL(this.browserWSEndpoint);
73
- wsURL.host = serverURL.host;
74
- wsURL.port = serverURL.port;
71
+ const externalURL = new URL(this.config.getExternalWebSocketAddress());
72
+ const internalURL = new URL(this.browserWSEndpoint);
73
+ internalURL.host = externalURL.host;
74
+ internalURL.port = externalURL.port;
75
+ internalURL.protocol = externalURL.protocol;
75
76
  if (token) {
76
- wsURL.searchParams.set('token', token);
77
+ internalURL.searchParams.set('token', token);
77
78
  }
78
- return wsURL.href;
79
+ return internalURL.href;
79
80
  };
80
81
  proxyPageWebSocket = async () => {
81
82
  console.warn(`Not yet implemented`);
@@ -62,14 +62,15 @@ export class FirefoxPlaywright extends EventEmitter {
62
62
  if (!this.browserWSEndpoint) {
63
63
  return null;
64
64
  }
65
- const serverURL = new URL(this.config.getExternalWebSocketAddress());
66
- const wsURL = new URL(this.browserWSEndpoint);
67
- wsURL.host = serverURL.host;
68
- wsURL.port = serverURL.port;
65
+ const externalURL = new URL(this.config.getExternalWebSocketAddress());
66
+ const internalURL = new URL(this.browserWSEndpoint);
67
+ internalURL.host = externalURL.host;
68
+ internalURL.port = externalURL.port;
69
+ internalURL.protocol = externalURL.protocol;
69
70
  if (token) {
70
- wsURL.searchParams.set('token', token);
71
+ internalURL.searchParams.set('token', token);
71
72
  }
72
- return wsURL.href;
73
+ return internalURL.href;
73
74
  };
74
75
  proxyPageWebSocket = async () => {
75
76
  console.warn(`Not yet implemented`);
@@ -62,14 +62,15 @@ export class WebkitPlaywright extends EventEmitter {
62
62
  if (!this.browserWSEndpoint) {
63
63
  return null;
64
64
  }
65
- const serverURL = new URL(this.config.getExternalWebSocketAddress());
66
- const wsURL = new URL(this.browserWSEndpoint);
67
- wsURL.host = serverURL.host;
68
- wsURL.port = serverURL.port;
65
+ const externalURL = new URL(this.config.getExternalWebSocketAddress());
66
+ const internalURL = new URL(this.browserWSEndpoint);
67
+ internalURL.host = externalURL.host;
68
+ internalURL.port = externalURL.port;
69
+ internalURL.protocol = externalURL.protocol;
69
70
  if (token) {
70
- wsURL.searchParams.set('token', token);
71
+ internalURL.searchParams.set('token', token);
71
72
  }
72
- return wsURL.href;
73
+ return internalURL.href;
73
74
  };
74
75
  proxyPageWebSocket = async () => {
75
76
  console.warn(`Not yet implemented`);
@@ -535,14 +535,14 @@
535
535
  "length": {
536
536
  "type": "number"
537
537
  },
538
- "__@toStringTag@86962": {
538
+ "__@toStringTag@97790": {
539
539
  "type": "string",
540
540
  "const": "Uint8Array"
541
541
  }
542
542
  },
543
543
  "required": [
544
544
  "BYTES_PER_ELEMENT",
545
- "__@toStringTag@86962",
545
+ "__@toStringTag@97790",
546
546
  "buffer",
547
547
  "byteLength",
548
548
  "byteOffset",
@@ -577,13 +577,13 @@
577
577
  "byteLength": {
578
578
  "type": "number"
579
579
  },
580
- "__@toStringTag@86962": {
580
+ "__@toStringTag@97790": {
581
581
  "type": "string"
582
582
  }
583
583
  },
584
584
  "additionalProperties": false,
585
585
  "required": [
586
- "__@toStringTag@86962",
586
+ "__@toStringTag@97790",
587
587
  "byteLength"
588
588
  ]
589
589
  },
@@ -593,18 +593,18 @@
593
593
  "byteLength": {
594
594
  "type": "number"
595
595
  },
596
- "__@species@87063": {
596
+ "__@species@97891": {
597
597
  "$ref": "#/definitions/SharedArrayBuffer"
598
598
  },
599
- "__@toStringTag@86962": {
599
+ "__@toStringTag@97790": {
600
600
  "type": "string",
601
601
  "const": "SharedArrayBuffer"
602
602
  }
603
603
  },
604
604
  "additionalProperties": false,
605
605
  "required": [
606
- "__@species@87063",
607
- "__@toStringTag@86962",
606
+ "__@species@97891",
607
+ "__@toStringTag@97790",
608
608
  "byteLength"
609
609
  ]
610
610
  },
@@ -441,14 +441,14 @@
441
441
  "length": {
442
442
  "type": "number"
443
443
  },
444
- "__@toStringTag@131087": {
444
+ "__@toStringTag@108884": {
445
445
  "type": "string",
446
446
  "const": "Uint8Array"
447
447
  }
448
448
  },
449
449
  "required": [
450
450
  "BYTES_PER_ELEMENT",
451
- "__@toStringTag@131087",
451
+ "__@toStringTag@108884",
452
452
  "buffer",
453
453
  "byteLength",
454
454
  "byteOffset",
@@ -483,13 +483,13 @@
483
483
  "byteLength": {
484
484
  "type": "number"
485
485
  },
486
- "__@toStringTag@131087": {
486
+ "__@toStringTag@108884": {
487
487
  "type": "string"
488
488
  }
489
489
  },
490
490
  "additionalProperties": false,
491
491
  "required": [
492
- "__@toStringTag@131087",
492
+ "__@toStringTag@108884",
493
493
  "byteLength"
494
494
  ]
495
495
  },
@@ -499,18 +499,18 @@
499
499
  "byteLength": {
500
500
  "type": "number"
501
501
  },
502
- "__@species@131188": {
502
+ "__@species@108985": {
503
503
  "$ref": "#/definitions/SharedArrayBuffer"
504
504
  },
505
- "__@toStringTag@131087": {
505
+ "__@toStringTag@108884": {
506
506
  "type": "string",
507
507
  "const": "SharedArrayBuffer"
508
508
  }
509
509
  },
510
510
  "additionalProperties": false,
511
511
  "required": [
512
- "__@species@131188",
513
- "__@toStringTag@131087",
512
+ "__@species@108985",
513
+ "__@toStringTag@108884",
514
514
  "byteLength"
515
515
  ]
516
516
  },
@@ -484,14 +484,14 @@
484
484
  "length": {
485
485
  "type": "number"
486
486
  },
487
- "__@toStringTag@108895": {
487
+ "__@toStringTag@130881": {
488
488
  "type": "string",
489
489
  "const": "Uint8Array"
490
490
  }
491
491
  },
492
492
  "required": [
493
493
  "BYTES_PER_ELEMENT",
494
- "__@toStringTag@108895",
494
+ "__@toStringTag@130881",
495
495
  "buffer",
496
496
  "byteLength",
497
497
  "byteOffset",
@@ -526,13 +526,13 @@
526
526
  "byteLength": {
527
527
  "type": "number"
528
528
  },
529
- "__@toStringTag@108895": {
529
+ "__@toStringTag@130881": {
530
530
  "type": "string"
531
531
  }
532
532
  },
533
533
  "additionalProperties": false,
534
534
  "required": [
535
- "__@toStringTag@108895",
535
+ "__@toStringTag@130881",
536
536
  "byteLength"
537
537
  ]
538
538
  },
@@ -542,18 +542,18 @@
542
542
  "byteLength": {
543
543
  "type": "number"
544
544
  },
545
- "__@species@108996": {
545
+ "__@species@130982": {
546
546
  "$ref": "#/definitions/SharedArrayBuffer"
547
547
  },
548
- "__@toStringTag@108895": {
548
+ "__@toStringTag@130881": {
549
549
  "type": "string",
550
550
  "const": "SharedArrayBuffer"
551
551
  }
552
552
  },
553
553
  "additionalProperties": false,
554
554
  "required": [
555
- "__@species@108996",
556
- "__@toStringTag@108895",
555
+ "__@species@130982",
556
+ "__@toStringTag@130881",
557
557
  "byteLength"
558
558
  ]
559
559
  },
@@ -394,14 +394,14 @@
394
394
  "length": {
395
395
  "type": "number"
396
396
  },
397
- "__@toStringTag@119976": {
397
+ "__@toStringTag@141962": {
398
398
  "type": "string",
399
399
  "const": "Uint8Array"
400
400
  }
401
401
  },
402
402
  "required": [
403
403
  "BYTES_PER_ELEMENT",
404
- "__@toStringTag@119976",
404
+ "__@toStringTag@141962",
405
405
  "buffer",
406
406
  "byteLength",
407
407
  "byteOffset",
@@ -436,13 +436,13 @@
436
436
  "byteLength": {
437
437
  "type": "number"
438
438
  },
439
- "__@toStringTag@119976": {
439
+ "__@toStringTag@141962": {
440
440
  "type": "string"
441
441
  }
442
442
  },
443
443
  "additionalProperties": false,
444
444
  "required": [
445
- "__@toStringTag@119976",
445
+ "__@toStringTag@141962",
446
446
  "byteLength"
447
447
  ]
448
448
  },
@@ -452,18 +452,18 @@
452
452
  "byteLength": {
453
453
  "type": "number"
454
454
  },
455
- "__@species@120077": {
455
+ "__@species@142063": {
456
456
  "$ref": "#/definitions/SharedArrayBuffer"
457
457
  },
458
- "__@toStringTag@119976": {
458
+ "__@toStringTag@141962": {
459
459
  "type": "string",
460
460
  "const": "SharedArrayBuffer"
461
461
  }
462
462
  },
463
463
  "additionalProperties": false,
464
464
  "required": [
465
- "__@species@120077",
466
- "__@toStringTag@119976",
465
+ "__@species@142063",
466
+ "__@toStringTag@141962",
467
467
  "byteLength"
468
468
  ]
469
469
  },
@@ -29,7 +29,7 @@ export default (config, debug, options = {}) => async (req, browser) => {
29
29
  */
30
30
  page.on('request', async (request) => {
31
31
  const requestUrl = request.url();
32
- debug(`/function.js: Page Request: "${requestUrl}"`);
32
+ debug(`Outbound Page Request: "${requestUrl}"`);
33
33
  if (requestUrl.startsWith(functionRequestPath)) {
34
34
  const filename = path.basename(requestUrl);
35
35
  if (filename === functionCodeJS) {
@@ -55,10 +55,10 @@ export default (config, debug, options = {}) => async (req, browser) => {
55
55
  status: 404,
56
56
  });
57
57
  }
58
+ debug(`Request: "${requestUrl}" no responder found, continuing...`);
58
59
  return request.continue();
59
60
  });
60
61
  page.on('response', (res) => {
61
- debug(`/function.js: Page Response: "${res.url()}"`);
62
62
  if (res.status() !== 200) {
63
63
  debug(`Received a non-200 response for request "${res.url()}"`);
64
64
  }
@@ -73,6 +73,7 @@ export default (config, debug, options = {}) => async (req, browser) => {
73
73
  import('./' + functionCodeJS),
74
74
  ]);
75
75
  console.log('/function.js: imported successfully.');
76
+ console.log(`/function.js: BrowserlessFunctionRunner: ${typeof window.BrowserlessFunctionRunner}`);
76
77
  const helper = new window.BrowserlessFunctionRunner();
77
78
  const options = JSON.parse(serializedOptions);
78
79
  console.log('/function.js: executing puppeteer code.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browserless.io/browserless",
3
- "version": "2.6.0",
3
+ "version": "2.6.1-beta-2",
4
4
  "license": "SSPL",
5
5
  "description": "The browserless platform",
6
6
  "author": "browserless.io",
@@ -1,18 +1,48 @@
1
1
  #!/usr/bin/env node
2
+ /* eslint-disable no-undef */
3
+
2
4
  'use strict';
3
5
 
4
6
  import { build } from 'esbuild';
7
+ import fs from 'fs/promises';
8
+ import { join } from 'path';
5
9
  import { polyfillNode } from 'esbuild-plugin-polyfill-node';
6
10
 
7
- build({
8
- bundle: true,
9
- entryPoints: ['src/shared/utils/function/client.ts'],
10
- outfile: 'static/function/client.js',
11
- plugins: [
12
- polyfillNode({
13
- globals: {
14
- process: false,
15
- },
16
- }),
17
- ],
18
- });
11
+ const html = (contents) => `<!DOCTYPE html>
12
+ <html lang="en">
13
+ <head>
14
+ <meta charset="UTF-8">
15
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
16
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
17
+ <title>browserless.io function runner</title>
18
+ <script type="module">
19
+ ${contents}
20
+ </script>
21
+ </head>
22
+ <body>
23
+ </body>
24
+ </html>
25
+ `;
26
+
27
+ const entryPoints = ['src/shared/utils/function/client.ts'];
28
+ const outfile = join(process.cwd(), 'static/function/client.js');
29
+ const htmlLocation = join(process.cwd(), 'static/function/index.html');
30
+
31
+ (async () => {
32
+ await build({
33
+ bundle: true,
34
+ entryPoints,
35
+ outfile,
36
+ plugins: [
37
+ polyfillNode({
38
+ globals: {
39
+ process: false,
40
+ },
41
+ }),
42
+ ],
43
+ });
44
+ const contents = await fs.readFile(outfile, 'utf-8');
45
+ const final = html(contents);
46
+
47
+ await fs.writeFile(htmlLocation, final);
48
+ })();
@@ -175,16 +175,17 @@ export class ChromiumCDP extends EventEmitter {
175
175
  return null;
176
176
  }
177
177
 
178
- const serverURL = new URL(this.config.getExternalWebSocketAddress());
179
- const wsURL = new URL(this.browserWSEndpoint);
180
- wsURL.host = serverURL.host;
181
- wsURL.port = serverURL.port;
178
+ const externalURL = new URL(this.config.getExternalWebSocketAddress());
179
+ const internalURL = new URL(this.browserWSEndpoint);
180
+ internalURL.host = externalURL.host;
181
+ internalURL.port = externalURL.port;
182
+ internalURL.protocol = externalURL.protocol;
182
183
 
183
184
  if (token) {
184
- wsURL.searchParams.set('token', token);
185
+ internalURL.searchParams.set('token', token);
185
186
  }
186
187
 
187
- return wsURL.href;
188
+ return internalURL.href;
188
189
  };
189
190
 
190
191
  public proxyPageWebSocket = async (
@@ -104,16 +104,17 @@ export class ChromiumPlaywright extends EventEmitter {
104
104
  return null;
105
105
  }
106
106
 
107
- const serverURL = new URL(this.config.getExternalWebSocketAddress());
108
- const wsURL = new URL(this.browserWSEndpoint);
109
- wsURL.host = serverURL.host;
110
- wsURL.port = serverURL.port;
107
+ const externalURL = new URL(this.config.getExternalWebSocketAddress());
108
+ const internalURL = new URL(this.browserWSEndpoint);
109
+ internalURL.host = externalURL.host;
110
+ internalURL.port = externalURL.port;
111
+ internalURL.protocol = externalURL.protocol;
111
112
 
112
113
  if (token) {
113
- wsURL.searchParams.set('token', token);
114
+ internalURL.searchParams.set('token', token);
114
115
  }
115
116
 
116
- return wsURL.href;
117
+ return internalURL.href;
117
118
  };
118
119
 
119
120
  public proxyPageWebSocket = async () => {
@@ -96,16 +96,17 @@ export class FirefoxPlaywright extends EventEmitter {
96
96
  return null;
97
97
  }
98
98
 
99
- const serverURL = new URL(this.config.getExternalWebSocketAddress());
100
- const wsURL = new URL(this.browserWSEndpoint);
101
- wsURL.host = serverURL.host;
102
- wsURL.port = serverURL.port;
99
+ const externalURL = new URL(this.config.getExternalWebSocketAddress());
100
+ const internalURL = new URL(this.browserWSEndpoint);
101
+ internalURL.host = externalURL.host;
102
+ internalURL.port = externalURL.port;
103
+ internalURL.protocol = externalURL.protocol;
103
104
 
104
105
  if (token) {
105
- wsURL.searchParams.set('token', token);
106
+ internalURL.searchParams.set('token', token);
106
107
  }
107
108
 
108
- return wsURL.href;
109
+ return internalURL.href;
109
110
  };
110
111
 
111
112
  public proxyPageWebSocket = async () => {
@@ -96,16 +96,17 @@ export class WebkitPlaywright extends EventEmitter {
96
96
  return null;
97
97
  }
98
98
 
99
- const serverURL = new URL(this.config.getExternalWebSocketAddress());
100
- const wsURL = new URL(this.browserWSEndpoint);
101
- wsURL.host = serverURL.host;
102
- wsURL.port = serverURL.port;
99
+ const externalURL = new URL(this.config.getExternalWebSocketAddress());
100
+ const internalURL = new URL(this.browserWSEndpoint);
101
+ internalURL.host = externalURL.host;
102
+ internalURL.port = externalURL.port;
103
+ internalURL.protocol = externalURL.protocol;
103
104
 
104
105
  if (token) {
105
- wsURL.searchParams.set('token', token);
106
+ internalURL.searchParams.set('token', token);
106
107
  }
107
108
 
108
- return wsURL.href;
109
+ return internalURL.href;
109
110
  };
110
111
 
111
112
  public proxyPageWebSocket = async () => {
package/src/server.ts CHANGED
@@ -143,7 +143,9 @@ export class HTTPServer extends EventEmitter {
143
143
  const route = await this.router.getRouteForHTTPRequest(req);
144
144
 
145
145
  if (!route) {
146
- this.log(`No matching HTTP route handler for "${req.method}: ${req.parsed.href}"`);
146
+ this.log(
147
+ `No matching HTTP route handler for "${req.method}: ${req.parsed.href}"`,
148
+ );
147
149
  writeResponse(res, 404, 'Not Found');
148
150
  return Promise.resolve();
149
151
  }
@@ -88,7 +88,7 @@ export default (
88
88
  */
89
89
  page.on('request', async (request) => {
90
90
  const requestUrl = request.url();
91
- debug(`/function.js: Page Request: "${requestUrl}"`);
91
+ debug(`Outbound Page Request: "${requestUrl}"`);
92
92
  if (requestUrl.startsWith(functionRequestPath)) {
93
93
  const filename = path.basename(requestUrl);
94
94
  if (filename === functionCodeJS) {
@@ -116,11 +116,11 @@ export default (
116
116
  status: 404,
117
117
  });
118
118
  }
119
+ debug(`Request: "${requestUrl}" no responder found, continuing...`);
119
120
  return request.continue();
120
121
  });
121
122
 
122
123
  page.on('response', (res) => {
123
- debug(`/function.js: Page Response: "${res.url()}"`);
124
124
  if (res.status() !== 200) {
125
125
  debug(`Received a non-200 response for request "${res.url()}"`);
126
126
  }
@@ -144,6 +144,9 @@ export default (
144
144
  import('./' + functionCodeJS),
145
145
  ]);
146
146
  console.log('/function.js: imported successfully.');
147
+ console.log(
148
+ `/function.js: BrowserlessFunctionRunner: ${typeof window.BrowserlessFunctionRunner}`,
149
+ );
147
150
  const helper = new window.BrowserlessFunctionRunner();
148
151
  const options = JSON.parse(serializedOptions);
149
152
  console.log('/function.js: executing puppeteer code.');
@@ -1098,7 +1098,7 @@
1098
1098
  },
1099
1099
  "info": {
1100
1100
  "title": "Browserless",
1101
- "version": "2.6.0",
1101
+ "version": "2.6.1-beta-2",
1102
1102
  "x-logo": {
1103
1103
  "altText": "browserless logo",
1104
1104
  "url": "./docs/browserless-logo-inline.svg"
@@ -1098,7 +1098,7 @@
1098
1098
  },
1099
1099
  "info": {
1100
1100
  "title": "Browserless",
1101
- "version": "2.6.0",
1101
+ "version": "2.6.1-beta-2",
1102
1102
  "x-logo": {
1103
1103
  "altText": "browserless logo",
1104
1104
  "url": "./docs/browserless-logo-inline.svg"