@browserless.io/browserless 2.1.0 → 2.1.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/CHANGELOG.md +19 -2
- package/bin/browserless.js +49 -13
- package/build/browserless.js +9 -2
- package/build/browsers/cdp-chromium.d.ts +1 -1
- package/build/browsers/cdp-chromium.js +3 -3
- package/build/browsers/index.d.ts +1 -0
- package/build/browsers/index.js +20 -0
- package/build/browsers/playwright-chromium.d.ts +1 -1
- package/build/browsers/playwright-firefox.d.ts +1 -1
- package/build/browsers/playwright-webkit.d.ts +1 -1
- package/build/constants.d.ts +1 -0
- package/build/constants.js +1 -0
- package/build/data/classes.json +1 -1
- package/build/data/selectors.json +1 -1
- package/build/http.d.ts +3 -0
- package/build/http.js +3 -0
- package/build/routes/chromium/http/content-post.body.json +8 -8
- package/build/routes/chromium/http/json-list.d.ts +15 -0
- package/build/routes/chromium/http/json-list.js +23 -0
- package/build/routes/chromium/http/json-list.response.json +52 -0
- package/build/routes/chromium/http/json-new.d.ts +15 -0
- package/build/routes/chromium/http/json-new.js +23 -0
- package/build/routes/chromium/http/json-new.response.json +44 -0
- package/build/routes/chromium/http/json-protocol-get.d.ts +15 -0
- package/build/routes/chromium/http/json-protocol-get.js +20 -0
- package/build/routes/chromium/http/json-protocol-get.response.json +6 -0
- package/build/routes/chromium/http/json-version-get.d.ts +1 -1
- package/build/routes/chromium/http/json-version-get.js +1 -1
- package/build/routes/chromium/http/pdf-post.body.json +12 -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/chromium/utils/cdp.d.ts +2 -0
- package/build/routes/chromium/utils/cdp.js +14 -0
- package/build/types.d.ts +31 -0
- package/build/utils.d.ts +9 -0
- package/build/utils.js +17 -2
- package/package.json +11 -13
- package/src/browserless.ts +12 -1
- package/src/browsers/cdp-chromium.ts +5 -7
- package/src/browsers/index.ts +25 -0
- package/src/browsers/playwright-chromium.ts +1 -1
- package/src/browsers/playwright-firefox.ts +1 -1
- package/src/browsers/playwright-webkit.ts +1 -1
- package/src/constants.ts +1 -0
- package/src/http.ts +3 -0
- package/src/routes/chromium/http/json-list.ts +50 -0
- package/src/routes/chromium/http/json-new.ts +50 -0
- package/src/routes/chromium/http/json-protocol-get.ts +38 -0
- package/src/routes/chromium/http/json-version-get.ts +1 -1
- package/src/routes/chromium/utils/cdp.ts +19 -0
- package/src/types.ts +38 -0
- package/src/utils.ts +26 -4
- package/static/docs/swagger.json +315 -10
- package/static/function/client.js +2328 -1975
- package/browser.json +0 -7
- package/scripts/install-cdp-json.js +0 -37
package/build/http.d.ts
CHANGED
|
@@ -119,6 +119,9 @@ export declare enum HTTPRoutes {
|
|
|
119
119
|
content = "/content",
|
|
120
120
|
download = "/download",
|
|
121
121
|
function = "/function",
|
|
122
|
+
jsonList = "/json/list",
|
|
123
|
+
jsonNew = "/json/new",
|
|
124
|
+
jsonProtocol = "/json/protocol",
|
|
122
125
|
jsonVersion = "/json/version",
|
|
123
126
|
pdf = "/pdf",
|
|
124
127
|
performance = "/performance",
|
package/build/http.js
CHANGED
|
@@ -83,6 +83,9 @@ export var HTTPRoutes;
|
|
|
83
83
|
HTTPRoutes["content"] = "/content";
|
|
84
84
|
HTTPRoutes["download"] = "/download";
|
|
85
85
|
HTTPRoutes["function"] = "/function";
|
|
86
|
+
HTTPRoutes["jsonList"] = "/json/list";
|
|
87
|
+
HTTPRoutes["jsonNew"] = "/json/new";
|
|
88
|
+
HTTPRoutes["jsonProtocol"] = "/json/protocol";
|
|
86
89
|
HTTPRoutes["jsonVersion"] = "/json/version";
|
|
87
90
|
HTTPRoutes["pdf"] = "/pdf";
|
|
88
91
|
HTTPRoutes["performance"] = "/performance";
|
|
@@ -398,14 +398,14 @@
|
|
|
398
398
|
"length": {
|
|
399
399
|
"type": "number"
|
|
400
400
|
},
|
|
401
|
-
"__@toStringTag@
|
|
401
|
+
"__@toStringTag@10788": {
|
|
402
402
|
"type": "string",
|
|
403
403
|
"const": "Uint8Array"
|
|
404
404
|
}
|
|
405
405
|
},
|
|
406
406
|
"required": [
|
|
407
407
|
"BYTES_PER_ELEMENT",
|
|
408
|
-
"__@toStringTag@
|
|
408
|
+
"__@toStringTag@10788",
|
|
409
409
|
"buffer",
|
|
410
410
|
"byteLength",
|
|
411
411
|
"byteOffset",
|
|
@@ -440,13 +440,13 @@
|
|
|
440
440
|
"byteLength": {
|
|
441
441
|
"type": "number"
|
|
442
442
|
},
|
|
443
|
-
"__@toStringTag@
|
|
443
|
+
"__@toStringTag@10788": {
|
|
444
444
|
"type": "string"
|
|
445
445
|
}
|
|
446
446
|
},
|
|
447
447
|
"additionalProperties": false,
|
|
448
448
|
"required": [
|
|
449
|
-
"__@toStringTag@
|
|
449
|
+
"__@toStringTag@10788",
|
|
450
450
|
"byteLength"
|
|
451
451
|
]
|
|
452
452
|
},
|
|
@@ -456,18 +456,18 @@
|
|
|
456
456
|
"byteLength": {
|
|
457
457
|
"type": "number"
|
|
458
458
|
},
|
|
459
|
-
"__@species@
|
|
459
|
+
"__@species@10889": {
|
|
460
460
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
461
461
|
},
|
|
462
|
-
"__@toStringTag@
|
|
462
|
+
"__@toStringTag@10788": {
|
|
463
463
|
"type": "string",
|
|
464
464
|
"const": "SharedArrayBuffer"
|
|
465
465
|
}
|
|
466
466
|
},
|
|
467
467
|
"additionalProperties": false,
|
|
468
468
|
"required": [
|
|
469
|
-
"__@species@
|
|
470
|
-
"__@toStringTag@
|
|
469
|
+
"__@species@10889",
|
|
470
|
+
"__@toStringTag@10788",
|
|
471
471
|
"byteLength"
|
|
472
472
|
]
|
|
473
473
|
},
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { APITags, HTTPRoute, HTTPRoutes, Methods, Request, Response, contentTypes } from '@browserless.io/browserless';
|
|
2
|
+
import { getCDPJSONPayload } from '../utils/cdp.js';
|
|
3
|
+
export type ResponseSchema = Array<ReturnType<typeof getCDPJSONPayload>>;
|
|
4
|
+
export default class GetJSONList extends HTTPRoute {
|
|
5
|
+
accepts: contentTypes[];
|
|
6
|
+
auth: boolean;
|
|
7
|
+
browser: null;
|
|
8
|
+
concurrency: boolean;
|
|
9
|
+
contentTypes: contentTypes[];
|
|
10
|
+
description: string;
|
|
11
|
+
method: Methods;
|
|
12
|
+
path: HTTPRoutes;
|
|
13
|
+
tags: APITags[];
|
|
14
|
+
handler: (_req: Request, res: Response) => Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { APITags, HTTPRoute, HTTPRoutes, Methods, contentTypes, dedent, jsonResponse, } from '@browserless.io/browserless';
|
|
2
|
+
import { getCDPJSONPayload } from '../utils/cdp.js';
|
|
3
|
+
export default class GetJSONList extends HTTPRoute {
|
|
4
|
+
accepts = [contentTypes.any];
|
|
5
|
+
auth = true;
|
|
6
|
+
browser = null;
|
|
7
|
+
concurrency = false;
|
|
8
|
+
contentTypes = [contentTypes.json];
|
|
9
|
+
description = dedent(`
|
|
10
|
+
Returns a JSON payload that acts as a pass-through to the DevTools /json/list HTTP API in Chromium.
|
|
11
|
+
Browserless mocks this payload so that remote clients can connect to the underlying "webSocketDebuggerUrl"
|
|
12
|
+
which will cause Browserless to start the browser and proxy that request into a blank page.
|
|
13
|
+
`);
|
|
14
|
+
method = Methods.get;
|
|
15
|
+
path = HTTPRoutes.jsonList;
|
|
16
|
+
tags = [APITags.browserAPI];
|
|
17
|
+
handler = async (_req, res) => {
|
|
18
|
+
const config = this.config();
|
|
19
|
+
const externalAddress = config.getExternalAddress();
|
|
20
|
+
const payload = getCDPJSONPayload(externalAddress);
|
|
21
|
+
return jsonResponse(res, 200, [payload]);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "array",
|
|
3
|
+
"items": {
|
|
4
|
+
"$ref": "#/definitions/CDPJSONPayload"
|
|
5
|
+
},
|
|
6
|
+
"definitions": {
|
|
7
|
+
"CDPJSONPayload": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"description": {
|
|
11
|
+
"description": "The description of the target. Generally the page's title.",
|
|
12
|
+
"type": "string"
|
|
13
|
+
},
|
|
14
|
+
"devtoolsFrontendUrl": {
|
|
15
|
+
"description": "The fully-qualified URL of the Devtools inspector app.",
|
|
16
|
+
"type": "string"
|
|
17
|
+
},
|
|
18
|
+
"id": {
|
|
19
|
+
"description": "A Unique Id for the underlying target.",
|
|
20
|
+
"type": "string"
|
|
21
|
+
},
|
|
22
|
+
"title": {
|
|
23
|
+
"description": "The title of the target. For pages this is the page's title.",
|
|
24
|
+
"type": "string"
|
|
25
|
+
},
|
|
26
|
+
"type": {
|
|
27
|
+
"description": "The type of target, generally \"page\" or \"background_page\".",
|
|
28
|
+
"type": "string"
|
|
29
|
+
},
|
|
30
|
+
"url": {
|
|
31
|
+
"description": "The current URL the target is consuming or visiting.",
|
|
32
|
+
"type": "string"
|
|
33
|
+
},
|
|
34
|
+
"webSocketDebuggerUrl": {
|
|
35
|
+
"description": "The target or page's WebSocket Debugger URL. Primarily used for legacy\nlibraries to connect and inspect or remote automate this target.",
|
|
36
|
+
"type": "string"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"additionalProperties": false,
|
|
40
|
+
"required": [
|
|
41
|
+
"description",
|
|
42
|
+
"devtoolsFrontendUrl",
|
|
43
|
+
"id",
|
|
44
|
+
"title",
|
|
45
|
+
"type",
|
|
46
|
+
"url",
|
|
47
|
+
"webSocketDebuggerUrl"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
52
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { APITags, HTTPRoute, HTTPRoutes, Methods, Request, Response, contentTypes } from '@browserless.io/browserless';
|
|
2
|
+
import { getCDPJSONPayload } from '../utils/cdp.js';
|
|
3
|
+
export type ResponseSchema = ReturnType<typeof getCDPJSONPayload>;
|
|
4
|
+
export default class GetJSONList extends HTTPRoute {
|
|
5
|
+
accepts: contentTypes[];
|
|
6
|
+
auth: boolean;
|
|
7
|
+
browser: null;
|
|
8
|
+
concurrency: boolean;
|
|
9
|
+
contentTypes: contentTypes[];
|
|
10
|
+
description: string;
|
|
11
|
+
method: Methods;
|
|
12
|
+
path: HTTPRoutes;
|
|
13
|
+
tags: APITags[];
|
|
14
|
+
handler: (_req: Request, res: Response) => Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { APITags, HTTPRoute, HTTPRoutes, Methods, contentTypes, dedent, jsonResponse, } from '@browserless.io/browserless';
|
|
2
|
+
import { getCDPJSONPayload } from '../utils/cdp.js';
|
|
3
|
+
export default class GetJSONList extends HTTPRoute {
|
|
4
|
+
accepts = [contentTypes.any];
|
|
5
|
+
auth = true;
|
|
6
|
+
browser = null;
|
|
7
|
+
concurrency = false;
|
|
8
|
+
contentTypes = [contentTypes.json];
|
|
9
|
+
description = dedent(`
|
|
10
|
+
Returns a JSON payload that acts as a pass-through to the DevTools /json/list HTTP API in Chromium.
|
|
11
|
+
Browserless mocks this payload so that remote clients can connect to the underlying "webSocketDebuggerUrl"
|
|
12
|
+
which will cause Browserless to start the browser and proxy that request into a blank page.
|
|
13
|
+
`);
|
|
14
|
+
method = Methods.put;
|
|
15
|
+
path = HTTPRoutes.jsonNew;
|
|
16
|
+
tags = [APITags.browserAPI];
|
|
17
|
+
handler = async (_req, res) => {
|
|
18
|
+
const config = this.config();
|
|
19
|
+
const externalAddress = config.getExternalAddress();
|
|
20
|
+
const payload = getCDPJSONPayload(externalAddress);
|
|
21
|
+
return jsonResponse(res, 200, payload);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"properties": {
|
|
4
|
+
"description": {
|
|
5
|
+
"description": "The description of the target. Generally the page's title.",
|
|
6
|
+
"type": "string"
|
|
7
|
+
},
|
|
8
|
+
"devtoolsFrontendUrl": {
|
|
9
|
+
"description": "The fully-qualified URL of the Devtools inspector app.",
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"id": {
|
|
13
|
+
"description": "A Unique Id for the underlying target.",
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
16
|
+
"title": {
|
|
17
|
+
"description": "The title of the target. For pages this is the page's title.",
|
|
18
|
+
"type": "string"
|
|
19
|
+
},
|
|
20
|
+
"type": {
|
|
21
|
+
"description": "The type of target, generally \"page\" or \"background_page\".",
|
|
22
|
+
"type": "string"
|
|
23
|
+
},
|
|
24
|
+
"url": {
|
|
25
|
+
"description": "The current URL the target is consuming or visiting.",
|
|
26
|
+
"type": "string"
|
|
27
|
+
},
|
|
28
|
+
"webSocketDebuggerUrl": {
|
|
29
|
+
"description": "The target or page's WebSocket Debugger URL. Primarily used for legacy\nlibraries to connect and inspect or remote automate this target.",
|
|
30
|
+
"type": "string"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"additionalProperties": false,
|
|
34
|
+
"required": [
|
|
35
|
+
"description",
|
|
36
|
+
"devtoolsFrontendUrl",
|
|
37
|
+
"id",
|
|
38
|
+
"title",
|
|
39
|
+
"type",
|
|
40
|
+
"url",
|
|
41
|
+
"webSocketDebuggerUrl"
|
|
42
|
+
],
|
|
43
|
+
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
44
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { APITags, HTTPRoute, HTTPRoutes, Methods, Request, Response, contentTypes } from '@browserless.io/browserless';
|
|
2
|
+
export type ResponseSchema = object;
|
|
3
|
+
export default class GetJSONVersion extends HTTPRoute {
|
|
4
|
+
accepts: contentTypes[];
|
|
5
|
+
auth: boolean;
|
|
6
|
+
browser: null;
|
|
7
|
+
concurrency: boolean;
|
|
8
|
+
contentTypes: contentTypes[];
|
|
9
|
+
description: string;
|
|
10
|
+
method: Methods;
|
|
11
|
+
path: HTTPRoutes;
|
|
12
|
+
tags: APITags[];
|
|
13
|
+
private cachedProtocol;
|
|
14
|
+
handler: (_req: Request, res: Response) => Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { APITags, HTTPRoute, HTTPRoutes, Methods, contentTypes, jsonResponse, } from '@browserless.io/browserless';
|
|
2
|
+
export default class GetJSONVersion extends HTTPRoute {
|
|
3
|
+
accepts = [contentTypes.any];
|
|
4
|
+
auth = true;
|
|
5
|
+
browser = null;
|
|
6
|
+
concurrency = false;
|
|
7
|
+
contentTypes = [contentTypes.json];
|
|
8
|
+
description = `Returns Protocol JSON meta-data that Chrome comes with.`;
|
|
9
|
+
method = Methods.get;
|
|
10
|
+
path = HTTPRoutes.jsonProtocol;
|
|
11
|
+
tags = [APITags.browserAPI];
|
|
12
|
+
cachedProtocol;
|
|
13
|
+
handler = async (_req, res) => {
|
|
14
|
+
const browserManager = this.browserManager();
|
|
15
|
+
if (!this.cachedProtocol) {
|
|
16
|
+
this.cachedProtocol = await browserManager.getProtocolJSON();
|
|
17
|
+
}
|
|
18
|
+
return jsonResponse(res, 200, this.cachedProtocol);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APITags, BrowserManager,
|
|
1
|
+
import { APITags, BrowserManager, HTTPRoute, HTTPRoutes, Methods, Request, Response, UnwrapPromise, contentTypes } from '@browserless.io/browserless';
|
|
2
2
|
export type ResponseSchema = UnwrapPromise<ReturnType<BrowserManager['getVersionJSON']>>;
|
|
3
3
|
export default class GetJSONVersion extends HTTPRoute {
|
|
4
4
|
accepts: contentTypes[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APITags,
|
|
1
|
+
import { APITags, HTTPRoute, HTTPRoutes, Methods, contentTypes, jsonResponse, writeResponse, } from '@browserless.io/browserless';
|
|
2
2
|
export default class GetJSONVersion extends HTTPRoute {
|
|
3
3
|
accepts = [contentTypes.any];
|
|
4
4
|
auth = true;
|
|
@@ -462,6 +462,10 @@
|
|
|
462
462
|
"description": "Generate tagged (accessible) PDF.",
|
|
463
463
|
"type": "boolean"
|
|
464
464
|
},
|
|
465
|
+
"outline": {
|
|
466
|
+
"description": "Generate document outline.",
|
|
467
|
+
"type": "boolean"
|
|
468
|
+
},
|
|
465
469
|
"timeout": {
|
|
466
470
|
"description": "Timeout in milliseconds. Pass `0` to disable timeout.",
|
|
467
471
|
"type": "number"
|
|
@@ -538,14 +542,14 @@
|
|
|
538
542
|
"length": {
|
|
539
543
|
"type": "number"
|
|
540
544
|
},
|
|
541
|
-
"__@toStringTag@
|
|
545
|
+
"__@toStringTag@75058": {
|
|
542
546
|
"type": "string",
|
|
543
547
|
"const": "Uint8Array"
|
|
544
548
|
}
|
|
545
549
|
},
|
|
546
550
|
"required": [
|
|
547
551
|
"BYTES_PER_ELEMENT",
|
|
548
|
-
"__@toStringTag@
|
|
552
|
+
"__@toStringTag@75058",
|
|
549
553
|
"buffer",
|
|
550
554
|
"byteLength",
|
|
551
555
|
"byteOffset",
|
|
@@ -580,13 +584,13 @@
|
|
|
580
584
|
"byteLength": {
|
|
581
585
|
"type": "number"
|
|
582
586
|
},
|
|
583
|
-
"__@toStringTag@
|
|
587
|
+
"__@toStringTag@75058": {
|
|
584
588
|
"type": "string"
|
|
585
589
|
}
|
|
586
590
|
},
|
|
587
591
|
"additionalProperties": false,
|
|
588
592
|
"required": [
|
|
589
|
-
"__@toStringTag@
|
|
593
|
+
"__@toStringTag@75058",
|
|
590
594
|
"byteLength"
|
|
591
595
|
]
|
|
592
596
|
},
|
|
@@ -596,18 +600,18 @@
|
|
|
596
600
|
"byteLength": {
|
|
597
601
|
"type": "number"
|
|
598
602
|
},
|
|
599
|
-
"__@species@
|
|
603
|
+
"__@species@75159": {
|
|
600
604
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
601
605
|
},
|
|
602
|
-
"__@toStringTag@
|
|
606
|
+
"__@toStringTag@75058": {
|
|
603
607
|
"type": "string",
|
|
604
608
|
"const": "SharedArrayBuffer"
|
|
605
609
|
}
|
|
606
610
|
},
|
|
607
611
|
"additionalProperties": false,
|
|
608
612
|
"required": [
|
|
609
|
-
"__@species@
|
|
610
|
-
"__@toStringTag@
|
|
613
|
+
"__@species@75159",
|
|
614
|
+
"__@toStringTag@75058",
|
|
611
615
|
"byteLength"
|
|
612
616
|
]
|
|
613
617
|
},
|
|
@@ -445,14 +445,14 @@
|
|
|
445
445
|
"length": {
|
|
446
446
|
"type": "number"
|
|
447
447
|
},
|
|
448
|
-
"__@toStringTag@
|
|
448
|
+
"__@toStringTag@107362": {
|
|
449
449
|
"type": "string",
|
|
450
450
|
"const": "Uint8Array"
|
|
451
451
|
}
|
|
452
452
|
},
|
|
453
453
|
"required": [
|
|
454
454
|
"BYTES_PER_ELEMENT",
|
|
455
|
-
"__@toStringTag@
|
|
455
|
+
"__@toStringTag@107362",
|
|
456
456
|
"buffer",
|
|
457
457
|
"byteLength",
|
|
458
458
|
"byteOffset",
|
|
@@ -487,13 +487,13 @@
|
|
|
487
487
|
"byteLength": {
|
|
488
488
|
"type": "number"
|
|
489
489
|
},
|
|
490
|
-
"__@toStringTag@
|
|
490
|
+
"__@toStringTag@107362": {
|
|
491
491
|
"type": "string"
|
|
492
492
|
}
|
|
493
493
|
},
|
|
494
494
|
"additionalProperties": false,
|
|
495
495
|
"required": [
|
|
496
|
-
"__@toStringTag@
|
|
496
|
+
"__@toStringTag@107362",
|
|
497
497
|
"byteLength"
|
|
498
498
|
]
|
|
499
499
|
},
|
|
@@ -503,18 +503,18 @@
|
|
|
503
503
|
"byteLength": {
|
|
504
504
|
"type": "number"
|
|
505
505
|
},
|
|
506
|
-
"__@species@
|
|
506
|
+
"__@species@107463": {
|
|
507
507
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
508
508
|
},
|
|
509
|
-
"__@toStringTag@
|
|
509
|
+
"__@toStringTag@107362": {
|
|
510
510
|
"type": "string",
|
|
511
511
|
"const": "SharedArrayBuffer"
|
|
512
512
|
}
|
|
513
513
|
},
|
|
514
514
|
"additionalProperties": false,
|
|
515
515
|
"required": [
|
|
516
|
-
"__@species@
|
|
517
|
-
"__@toStringTag@
|
|
516
|
+
"__@species@107463",
|
|
517
|
+
"__@toStringTag@107362",
|
|
518
518
|
"byteLength"
|
|
519
519
|
]
|
|
520
520
|
},
|
|
@@ -488,14 +488,14 @@
|
|
|
488
488
|
"length": {
|
|
489
489
|
"type": "number"
|
|
490
490
|
},
|
|
491
|
-
"__@toStringTag@
|
|
491
|
+
"__@toStringTag@118386": {
|
|
492
492
|
"type": "string",
|
|
493
493
|
"const": "Uint8Array"
|
|
494
494
|
}
|
|
495
495
|
},
|
|
496
496
|
"required": [
|
|
497
497
|
"BYTES_PER_ELEMENT",
|
|
498
|
-
"__@toStringTag@
|
|
498
|
+
"__@toStringTag@118386",
|
|
499
499
|
"buffer",
|
|
500
500
|
"byteLength",
|
|
501
501
|
"byteOffset",
|
|
@@ -530,13 +530,13 @@
|
|
|
530
530
|
"byteLength": {
|
|
531
531
|
"type": "number"
|
|
532
532
|
},
|
|
533
|
-
"__@toStringTag@
|
|
533
|
+
"__@toStringTag@118386": {
|
|
534
534
|
"type": "string"
|
|
535
535
|
}
|
|
536
536
|
},
|
|
537
537
|
"additionalProperties": false,
|
|
538
538
|
"required": [
|
|
539
|
-
"__@toStringTag@
|
|
539
|
+
"__@toStringTag@118386",
|
|
540
540
|
"byteLength"
|
|
541
541
|
]
|
|
542
542
|
},
|
|
@@ -546,18 +546,18 @@
|
|
|
546
546
|
"byteLength": {
|
|
547
547
|
"type": "number"
|
|
548
548
|
},
|
|
549
|
-
"__@species@
|
|
549
|
+
"__@species@118487": {
|
|
550
550
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
551
551
|
},
|
|
552
|
-
"__@toStringTag@
|
|
552
|
+
"__@toStringTag@118386": {
|
|
553
553
|
"type": "string",
|
|
554
554
|
"const": "SharedArrayBuffer"
|
|
555
555
|
}
|
|
556
556
|
},
|
|
557
557
|
"additionalProperties": false,
|
|
558
558
|
"required": [
|
|
559
|
-
"__@species@
|
|
560
|
-
"__@toStringTag@
|
|
559
|
+
"__@species@118487",
|
|
560
|
+
"__@toStringTag@118386",
|
|
561
561
|
"byteLength"
|
|
562
562
|
]
|
|
563
563
|
},
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { pageID } from '@browserless.io/browserless';
|
|
2
|
+
export const getCDPJSONPayload = (externalAddress) => {
|
|
3
|
+
const id = pageID();
|
|
4
|
+
const { protocol, host, pathname, href } = new URL(`/devtools/page/${id}`, externalAddress);
|
|
5
|
+
return {
|
|
6
|
+
description: '',
|
|
7
|
+
devtoolsFrontendUrl: `/devtools/inspector.html?${protocol.replace(':', '')}=${host}${pathname}`,
|
|
8
|
+
id,
|
|
9
|
+
title: 'New Tab',
|
|
10
|
+
type: 'page',
|
|
11
|
+
url: 'about:blank',
|
|
12
|
+
webSocketDebuggerUrl: href,
|
|
13
|
+
};
|
|
14
|
+
};
|
package/build/types.d.ts
CHANGED
|
@@ -438,4 +438,35 @@ export interface IBrowserlessStats {
|
|
|
438
438
|
unhealthy: number;
|
|
439
439
|
units: number;
|
|
440
440
|
}
|
|
441
|
+
export interface CDPJSONPayload {
|
|
442
|
+
/**
|
|
443
|
+
* The description of the target. Generally the page's title.
|
|
444
|
+
*/
|
|
445
|
+
description: string;
|
|
446
|
+
/**
|
|
447
|
+
* The fully-qualified URL of the Devtools inspector app.
|
|
448
|
+
*/
|
|
449
|
+
devtoolsFrontendUrl: string;
|
|
450
|
+
/**
|
|
451
|
+
* A Unique Id for the underlying target.
|
|
452
|
+
*/
|
|
453
|
+
id: string;
|
|
454
|
+
/**
|
|
455
|
+
* The title of the target. For pages this is the page's title.
|
|
456
|
+
*/
|
|
457
|
+
title: string;
|
|
458
|
+
/**
|
|
459
|
+
* The type of target, generally "page" or "background_page".
|
|
460
|
+
*/
|
|
461
|
+
type: string;
|
|
462
|
+
/**
|
|
463
|
+
* The current URL the target is consuming or visiting.
|
|
464
|
+
*/
|
|
465
|
+
url: string;
|
|
466
|
+
/**
|
|
467
|
+
* The target or page's WebSocket Debugger URL. Primarily used for legacy
|
|
468
|
+
* libraries to connect and inspect or remote automate this target.
|
|
469
|
+
*/
|
|
470
|
+
webSocketDebuggerUrl: string;
|
|
471
|
+
}
|
|
441
472
|
export {};
|
package/build/utils.d.ts
CHANGED
|
@@ -12,6 +12,15 @@ export declare const tsExtension = ".d.ts";
|
|
|
12
12
|
export declare const jsonExtension = ".json";
|
|
13
13
|
export declare const jsExtension = ".js";
|
|
14
14
|
export declare const id: () => string;
|
|
15
|
+
/**
|
|
16
|
+
* Generates a random, Chrome-compliant page ID with "BLESS"
|
|
17
|
+
* prepended. This prepended text signals to other parts of the
|
|
18
|
+
* system that this is a Browserless-created ID so it can be appropriately
|
|
19
|
+
* handled.
|
|
20
|
+
*
|
|
21
|
+
* @returns {string} A random Page ID
|
|
22
|
+
*/
|
|
23
|
+
export declare const pageID: () => string;
|
|
15
24
|
export declare const createLogger: (domain: string) => debug.Debugger;
|
|
16
25
|
export declare const dedent: (strings: string | string[], ...values: string[]) => string;
|
|
17
26
|
export declare const isConnected: (connection: Duplex | ServerResponse) => boolean;
|
package/build/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as fs from 'fs/promises';
|
|
2
|
-
import { CDPChromium, PlaywrightChromium, PlaywrightFirefox, PlaywrightWebkit, codes, contentTypes, encodings, encryptionAlgo, encryptionSep, } from '@browserless.io/browserless';
|
|
2
|
+
import { BLESS_PAGE_IDENTIFIER, CDPChromium, PlaywrightChromium, PlaywrightFirefox, PlaywrightWebkit, codes, contentTypes, encodings, encryptionAlgo, encryptionSep, } from '@browserless.io/browserless';
|
|
3
3
|
import playwright from 'playwright-core';
|
|
4
4
|
import crypto from 'crypto';
|
|
5
5
|
import debug from 'debug';
|
|
@@ -26,6 +26,21 @@ export const tsExtension = '.d.ts';
|
|
|
26
26
|
export const jsonExtension = '.json';
|
|
27
27
|
export const jsExtension = '.js';
|
|
28
28
|
export const id = () => crypto.randomUUID();
|
|
29
|
+
/**
|
|
30
|
+
* Generates a random, Chrome-compliant page ID with "BLESS"
|
|
31
|
+
* prepended. This prepended text signals to other parts of the
|
|
32
|
+
* system that this is a Browserless-created ID so it can be appropriately
|
|
33
|
+
* handled.
|
|
34
|
+
*
|
|
35
|
+
* @returns {string} A random Page ID
|
|
36
|
+
*/
|
|
37
|
+
export const pageID = () => {
|
|
38
|
+
const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
39
|
+
const id = Array.from({ length: 32 - BLESS_PAGE_IDENTIFIER.length })
|
|
40
|
+
.map(() => chars[Math.floor(Math.random() * chars.length)])
|
|
41
|
+
.join('');
|
|
42
|
+
return `${BLESS_PAGE_IDENTIFIER}${id}`;
|
|
43
|
+
};
|
|
29
44
|
export const createLogger = (domain) => {
|
|
30
45
|
return debug(`browserless.io:${domain}`);
|
|
31
46
|
};
|
|
@@ -158,7 +173,7 @@ export const removeNullStringify = (json, allowNull = true) => {
|
|
|
158
173
|
return value;
|
|
159
174
|
if (value !== null)
|
|
160
175
|
return value;
|
|
161
|
-
});
|
|
176
|
+
}, ' ');
|
|
162
177
|
};
|
|
163
178
|
export const jsonOrString = (maybeJson) => safeParse(maybeJson) ?? maybeJson;
|
|
164
179
|
export const readBody = async (req) => {
|