@browserless.io/browserless 2.3.0 → 2.4.0-beta-3
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 +6 -0
- package/bin/browserless.js +2 -0
- package/bin/scaffold/README.md +26 -1
- package/build/browserless.d.ts +6 -2
- package/build/browserless.js +23 -4
- package/build/browsers/chromium.cdp.d.ts +1 -5
- package/build/browsers/chromium.cdp.js +5 -115
- package/build/browsers/chromium.playwright.d.ts +1 -3
- package/build/browsers/chromium.playwright.js +1 -6
- package/build/browsers/firefox.playwright.d.ts +1 -3
- package/build/browsers/firefox.playwright.js +1 -6
- package/build/browsers/index.d.ts +5 -1
- package/build/browsers/index.js +6 -5
- package/build/browsers/webkit.playwright.d.ts +1 -3
- package/build/browsers/webkit.playwright.js +1 -6
- package/build/config.d.ts +9 -0
- package/build/config.js +11 -0
- package/build/constants.d.ts +0 -1
- package/build/constants.js +0 -1
- package/build/data/selectors.json +1 -1
- package/build/file-system.d.ts +12 -1
- package/build/file-system.js +14 -1
- package/build/http.d.ts +0 -7
- package/build/limiter.d.ts +9 -0
- package/build/limiter.js +11 -0
- package/build/metrics.d.ts +12 -1
- package/build/metrics.js +13 -1
- package/build/monitoring.d.ts +12 -1
- package/build/monitoring.js +14 -1
- package/build/router.d.ts +12 -2
- package/build/router.js +16 -6
- package/build/routes/chrome/http/content.post.body.json +8 -8
- package/build/routes/chrome/http/content.post.query.json +0 -4
- package/build/routes/chrome/http/download.post.query.json +0 -4
- package/build/routes/chrome/http/function.post.query.json +0 -4
- package/build/routes/chrome/http/pdf.post.body.json +8 -8
- package/build/routes/chrome/http/pdf.post.query.json +0 -4
- package/build/routes/chrome/http/performance.post.query.json +0 -4
- package/build/routes/chrome/http/scrape.post.body.json +8 -8
- package/build/routes/chrome/http/scrape.post.query.json +0 -4
- package/build/routes/chrome/http/screenshot.post.body.json +8 -8
- package/build/routes/chrome/http/screenshot.post.query.json +0 -4
- package/build/routes/chrome/tests/function.spec.js +32 -0
- package/build/routes/chrome/ws/browser.query.json +0 -4
- package/build/routes/chrome/ws/cdp.query.json +0 -4
- package/build/routes/chrome/ws/page.query.json +0 -4
- package/build/routes/chrome/ws/playwright.query.json +0 -4
- package/build/routes/chromium/http/content.post.body.json +8 -8
- package/build/routes/chromium/http/content.post.query.json +0 -4
- package/build/routes/chromium/http/download.post.query.json +0 -4
- package/build/routes/chromium/http/function.post.query.json +0 -4
- package/build/routes/chromium/http/pdf.post.body.json +8 -8
- package/build/routes/chromium/http/pdf.post.query.json +0 -4
- package/build/routes/chromium/http/performance.post.query.json +0 -4
- package/build/routes/chromium/http/scrape.post.body.json +8 -8
- package/build/routes/chromium/http/scrape.post.query.json +0 -4
- package/build/routes/chromium/http/screenshot.post.body.json +8 -8
- package/build/routes/chromium/http/screenshot.post.query.json +0 -4
- package/build/routes/chromium/ws/browser.query.json +0 -4
- package/build/routes/chromium/ws/cdp.query.json +0 -4
- package/build/routes/chromium/ws/page.query.json +0 -4
- package/build/routes/chromium/ws/playwright.query.json +0 -4
- package/build/routes/firefox/ws/playwright.query.json +0 -4
- package/build/routes/management/http/static.get.js +17 -11
- package/build/routes/webkit/ws/playwright.query.json +0 -4
- package/build/server.d.ts +8 -3
- package/build/server.js +15 -13
- package/build/token.d.ts +12 -1
- package/build/token.js +14 -1
- package/build/types.d.ts +9 -12
- package/build/types.js +10 -1
- package/build/webhooks.d.ts +12 -1
- package/build/webhooks.js +14 -1
- package/extensions/.gitkeep +0 -0
- package/package.json +5 -5
- package/src/browserless.ts +24 -2
- package/src/browsers/chromium.cdp.ts +10 -157
- package/src/browsers/chromium.playwright.ts +0 -8
- package/src/browsers/firefox.playwright.ts +0 -8
- package/src/browsers/index.ts +7 -6
- package/src/browsers/webkit.playwright.ts +0 -8
- package/src/config.ts +13 -0
- package/src/constants.ts +0 -1
- package/src/file-system.ts +16 -1
- package/src/http.ts +0 -8
- package/src/limiter.ts +13 -0
- package/src/metrics.ts +16 -1
- package/src/monitoring.ts +18 -2
- package/src/router.ts +20 -9
- package/src/routes/chrome/tests/function.spec.ts +35 -0
- package/src/routes/management/http/static.get.ts +25 -15
- package/src/server.ts +18 -16
- package/src/token.ts +18 -2
- package/src/types.ts +9 -13
- package/src/webhooks.ts +18 -2
- package/static/docs/swagger.json +10 -186
- package/static/docs/swagger.min.json +9 -185
- package/extensions/screencast/background.js +0 -143
- package/extensions/screencast/content_script.js +0 -18
- package/extensions/screencast/manifest.json +0 -19
package/build/file-system.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="debug" />
|
|
3
|
+
/// <reference types="node" />
|
|
3
4
|
import { Config } from '@browserless.io/browserless';
|
|
4
|
-
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
export declare class FileSystem extends EventEmitter {
|
|
5
7
|
protected config: Config;
|
|
6
8
|
protected fsMap: Map<string, string[]>;
|
|
7
9
|
protected currentAESKey: Buffer;
|
|
@@ -26,4 +28,13 @@ export declare class FileSystem {
|
|
|
26
28
|
* @returns Promise of the contents separated by newlines
|
|
27
29
|
*/
|
|
28
30
|
read: (path: string) => Promise<string[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Implement any browserless-core-specific shutdown logic here.
|
|
33
|
+
* Calls the empty-SDK stop method for downstream implementations.
|
|
34
|
+
*/
|
|
35
|
+
shutdown: () => Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Left blank for downstream SDK modules to optionally implement.
|
|
38
|
+
*/
|
|
39
|
+
stop: () => void;
|
|
29
40
|
}
|
package/build/file-system.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { createLogger, decrypt, encrypt, } from '@browserless.io/browserless';
|
|
2
2
|
import { readFile, writeFile } from 'fs/promises';
|
|
3
|
-
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
export class FileSystem extends EventEmitter {
|
|
4
5
|
config;
|
|
5
6
|
fsMap = new Map();
|
|
6
7
|
currentAESKey;
|
|
7
8
|
log = createLogger('file-system');
|
|
8
9
|
constructor(config) {
|
|
10
|
+
super();
|
|
9
11
|
this.config = config;
|
|
10
12
|
this.currentAESKey = config.getAESKey();
|
|
11
13
|
this.config.on('token', this.handleTokenChange);
|
|
@@ -58,4 +60,15 @@ export class FileSystem {
|
|
|
58
60
|
this.fsMap.set(path, splitContents);
|
|
59
61
|
return splitContents;
|
|
60
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* Implement any browserless-core-specific shutdown logic here.
|
|
65
|
+
* Calls the empty-SDK stop method for downstream implementations.
|
|
66
|
+
*/
|
|
67
|
+
shutdown = async () => {
|
|
68
|
+
await this.stop();
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Left blank for downstream SDK modules to optionally implement.
|
|
72
|
+
*/
|
|
73
|
+
stop = () => { };
|
|
61
74
|
}
|
package/build/http.d.ts
CHANGED
|
@@ -181,13 +181,6 @@ export interface SystemQueryParameters {
|
|
|
181
181
|
* object, or a base64-encoded JSON object.
|
|
182
182
|
*/
|
|
183
183
|
launch?: CDPLaunchOptions | BrowserServerOptions | string;
|
|
184
|
-
/**
|
|
185
|
-
* Whether or nor to record the session. The browser will run
|
|
186
|
-
* in "head-full" mode, and recording is started and closed
|
|
187
|
-
* via the embedded browserless API. Please refer to the "Recording"
|
|
188
|
-
* section in the live documentation site for more details.
|
|
189
|
-
*/
|
|
190
|
-
record?: boolean;
|
|
191
184
|
/**
|
|
192
185
|
* Override the system-level timeout for this request.
|
|
193
186
|
* Accepts a value in milliseconds.
|
package/build/limiter.d.ts
CHANGED
|
@@ -44,5 +44,14 @@ export declare class Limiter extends q {
|
|
|
44
44
|
get concurrencySize(): number;
|
|
45
45
|
get hasCapacity(): boolean;
|
|
46
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
|
+
/**
|
|
48
|
+
* Implement any browserless-core-specific shutdown logic here.
|
|
49
|
+
* Calls the empty-SDK stop method for downstream implementations.
|
|
50
|
+
*/
|
|
51
|
+
shutdown: () => Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Left blank for downstream SDK modules to optionally implement.
|
|
54
|
+
*/
|
|
55
|
+
stop: () => void;
|
|
47
56
|
}
|
|
48
57
|
export {};
|
package/build/limiter.js
CHANGED
|
@@ -147,4 +147,15 @@ export class Limiter extends q {
|
|
|
147
147
|
return bound;
|
|
148
148
|
});
|
|
149
149
|
};
|
|
150
|
+
/**
|
|
151
|
+
* Implement any browserless-core-specific shutdown logic here.
|
|
152
|
+
* Calls the empty-SDK stop method for downstream implementations.
|
|
153
|
+
*/
|
|
154
|
+
shutdown = async () => {
|
|
155
|
+
await this.stop();
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Left blank for downstream SDK modules to optionally implement.
|
|
159
|
+
*/
|
|
160
|
+
stop = () => { };
|
|
150
161
|
}
|
package/build/metrics.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { IBrowserlessStats } from '@browserless.io/browserless';
|
|
2
|
-
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
export declare class Metrics extends EventEmitter {
|
|
3
5
|
protected sessionTimes: number[];
|
|
4
6
|
protected successful: number;
|
|
5
7
|
protected queued: number;
|
|
@@ -27,4 +29,13 @@ export declare class Metrics {
|
|
|
27
29
|
totalTime: number;
|
|
28
30
|
units: number;
|
|
29
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Implement any browserless-core-specific shutdown logic here.
|
|
34
|
+
* Calls the empty-SDK stop method for downstream implementations.
|
|
35
|
+
*/
|
|
36
|
+
shutdown: () => Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Left blank for downstream SDK modules to optionally implement.
|
|
39
|
+
*/
|
|
40
|
+
stop: () => void;
|
|
30
41
|
}
|
package/build/metrics.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
export class Metrics extends EventEmitter {
|
|
2
3
|
sessionTimes = [];
|
|
3
4
|
successful = 0;
|
|
4
5
|
queued = 0;
|
|
@@ -83,4 +84,15 @@ export class Metrics {
|
|
|
83
84
|
units: sessionTimes.reduce((sum, value) => sum + Math.ceil(value / 30000), 0),
|
|
84
85
|
};
|
|
85
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Implement any browserless-core-specific shutdown logic here.
|
|
89
|
+
* Calls the empty-SDK stop method for downstream implementations.
|
|
90
|
+
*/
|
|
91
|
+
shutdown = async () => {
|
|
92
|
+
await this.stop();
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Left blank for downstream SDK modules to optionally implement.
|
|
96
|
+
*/
|
|
97
|
+
stop = () => { };
|
|
86
98
|
}
|
package/build/monitoring.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="debug" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { Config, IResourceLoad } from '@browserless.io/browserless';
|
|
3
|
-
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
|
+
export declare class Monitoring extends EventEmitter {
|
|
4
6
|
protected config: Config;
|
|
5
7
|
protected log: import("debug").Debugger;
|
|
6
8
|
constructor(config: Config);
|
|
@@ -11,4 +13,13 @@ export declare class Monitoring {
|
|
|
11
13
|
memoryInt: number | null;
|
|
12
14
|
memoryOverloaded: boolean;
|
|
13
15
|
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Implement any browserless-core-specific shutdown logic here.
|
|
18
|
+
* Calls the empty-SDK stop method for downstream implementations.
|
|
19
|
+
*/
|
|
20
|
+
shutdown: () => Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Left blank for downstream SDK modules to optionally implement.
|
|
23
|
+
*/
|
|
24
|
+
stop: () => void;
|
|
14
25
|
}
|
package/build/monitoring.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { createLogger, } from '@browserless.io/browserless';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
2
3
|
import si from 'systeminformation';
|
|
3
|
-
export class Monitoring {
|
|
4
|
+
export class Monitoring extends EventEmitter {
|
|
4
5
|
config;
|
|
5
6
|
log = createLogger('hardware');
|
|
6
7
|
constructor(config) {
|
|
8
|
+
super();
|
|
7
9
|
this.config = config;
|
|
8
10
|
}
|
|
9
11
|
getMachineStats = async () => {
|
|
@@ -35,4 +37,15 @@ export class Monitoring {
|
|
|
35
37
|
memoryOverloaded,
|
|
36
38
|
};
|
|
37
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Implement any browserless-core-specific shutdown logic here.
|
|
42
|
+
* Calls the empty-SDK stop method for downstream implementations.
|
|
43
|
+
*/
|
|
44
|
+
shutdown = async () => {
|
|
45
|
+
await this.stop();
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Left blank for downstream SDK modules to optionally implement.
|
|
49
|
+
*/
|
|
50
|
+
stop = () => { };
|
|
38
51
|
}
|
package/build/router.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="debug" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" />
|
|
4
5
|
import { BrowserHTTPRoute, BrowserManager, BrowserWebsocketRoute, Config, HTTPRoute, Limiter, Request, Response, WebSocketRoute } from '@browserless.io/browserless';
|
|
6
|
+
import { EventEmitter } from 'events';
|
|
5
7
|
import stream from 'stream';
|
|
6
|
-
export declare class Router {
|
|
8
|
+
export declare class Router extends EventEmitter {
|
|
7
9
|
protected config: Config;
|
|
8
10
|
protected browserManager: BrowserManager;
|
|
9
11
|
protected limiter: Limiter;
|
|
@@ -21,8 +23,16 @@ export declare class Router {
|
|
|
21
23
|
protected wrapWebSocketHandler: (route: WebSocketRoute | BrowserWebsocketRoute, handler: WebSocketRoute['handler'] | BrowserWebsocketRoute['handler']) => (req: Request, socket: stream.Duplex, head: Buffer) => Promise<unknown>;
|
|
22
24
|
registerHTTPRoute(route: HTTPRoute | BrowserHTTPRoute): HTTPRoute | BrowserHTTPRoute;
|
|
23
25
|
registerWebSocketRoute(route: WebSocketRoute | BrowserWebsocketRoute): WebSocketRoute | BrowserWebsocketRoute;
|
|
24
|
-
teardown(): Promise<void>;
|
|
25
26
|
getStaticHandler(): HTTPRoute;
|
|
26
27
|
getRouteForHTTPRequest(req: Request): Promise<HTTPRoute | BrowserHTTPRoute | null>;
|
|
27
28
|
getRouteForWebSocketRequest(req: Request): Promise<WebSocketRoute | BrowserWebsocketRoute | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* Implement any browserless-core-specific shutdown logic here.
|
|
31
|
+
* Calls the empty-SDK stop method for downstream implementations.
|
|
32
|
+
*/
|
|
33
|
+
shutdown: () => Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Left blank for downstream SDK modules to optionally implement.
|
|
36
|
+
*/
|
|
37
|
+
stop: () => void;
|
|
28
38
|
}
|
package/build/router.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HTTPManagementRoutes, contentTypes, createLogger, isConnected, writeResponse, } from '@browserless.io/browserless';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
2
3
|
import micromatch from 'micromatch';
|
|
3
|
-
export class Router {
|
|
4
|
+
export class Router extends EventEmitter {
|
|
4
5
|
config;
|
|
5
6
|
browserManager;
|
|
6
7
|
limiter;
|
|
@@ -9,6 +10,7 @@ export class Router {
|
|
|
9
10
|
httpRoutes = [];
|
|
10
11
|
webSocketRoutes = [];
|
|
11
12
|
constructor(config, browserManager, limiter) {
|
|
13
|
+
super();
|
|
12
14
|
this.config = config;
|
|
13
15
|
this.browserManager = browserManager;
|
|
14
16
|
this.limiter = limiter;
|
|
@@ -129,11 +131,6 @@ export class Router {
|
|
|
129
131
|
this.webSocketRoutes.push(route);
|
|
130
132
|
return route;
|
|
131
133
|
}
|
|
132
|
-
teardown() {
|
|
133
|
-
this.httpRoutes = [];
|
|
134
|
-
this.webSocketRoutes = [];
|
|
135
|
-
return this.browserManager.stop();
|
|
136
|
-
}
|
|
137
134
|
getStaticHandler() {
|
|
138
135
|
return this.httpRoutes.find((route) => route.path.includes(HTTPManagementRoutes.static));
|
|
139
136
|
}
|
|
@@ -156,4 +153,17 @@ export class Router {
|
|
|
156
153
|
// Once registered, paths are always an array here.
|
|
157
154
|
r.path.some((p) => micromatch.isMatch(pathname, p)));
|
|
158
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Implement any browserless-core-specific shutdown logic here.
|
|
158
|
+
* Calls the empty-SDK stop method for downstream implementations.
|
|
159
|
+
*/
|
|
160
|
+
shutdown = async () => {
|
|
161
|
+
this.httpRoutes = [];
|
|
162
|
+
this.webSocketRoutes = [];
|
|
163
|
+
await this.stop();
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Left blank for downstream SDK modules to optionally implement.
|
|
167
|
+
*/
|
|
168
|
+
stop = () => { };
|
|
159
169
|
}
|
|
@@ -394,14 +394,14 @@
|
|
|
394
394
|
"length": {
|
|
395
395
|
"type": "number"
|
|
396
396
|
},
|
|
397
|
-
"__@toStringTag@
|
|
397
|
+
"__@toStringTag@10915": {
|
|
398
398
|
"type": "string",
|
|
399
399
|
"const": "Uint8Array"
|
|
400
400
|
}
|
|
401
401
|
},
|
|
402
402
|
"required": [
|
|
403
403
|
"BYTES_PER_ELEMENT",
|
|
404
|
-
"__@toStringTag@
|
|
404
|
+
"__@toStringTag@10915",
|
|
405
405
|
"buffer",
|
|
406
406
|
"byteLength",
|
|
407
407
|
"byteOffset",
|
|
@@ -436,13 +436,13 @@
|
|
|
436
436
|
"byteLength": {
|
|
437
437
|
"type": "number"
|
|
438
438
|
},
|
|
439
|
-
"__@toStringTag@
|
|
439
|
+
"__@toStringTag@10915": {
|
|
440
440
|
"type": "string"
|
|
441
441
|
}
|
|
442
442
|
},
|
|
443
443
|
"additionalProperties": false,
|
|
444
444
|
"required": [
|
|
445
|
-
"__@toStringTag@
|
|
445
|
+
"__@toStringTag@10915",
|
|
446
446
|
"byteLength"
|
|
447
447
|
]
|
|
448
448
|
},
|
|
@@ -452,18 +452,18 @@
|
|
|
452
452
|
"byteLength": {
|
|
453
453
|
"type": "number"
|
|
454
454
|
},
|
|
455
|
-
"__@species@
|
|
455
|
+
"__@species@11016": {
|
|
456
456
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
457
457
|
},
|
|
458
|
-
"__@toStringTag@
|
|
458
|
+
"__@toStringTag@10915": {
|
|
459
459
|
"type": "string",
|
|
460
460
|
"const": "SharedArrayBuffer"
|
|
461
461
|
}
|
|
462
462
|
},
|
|
463
463
|
"additionalProperties": false,
|
|
464
464
|
"required": [
|
|
465
|
-
"__@species@
|
|
466
|
-
"__@toStringTag@
|
|
465
|
+
"__@species@11016",
|
|
466
|
+
"__@toStringTag@10915",
|
|
467
467
|
"byteLength"
|
|
468
468
|
]
|
|
469
469
|
},
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
}
|
|
17
17
|
]
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
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
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -16,10 +16,6 @@
|
|
|
16
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
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
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
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -16,10 +16,6 @@
|
|
|
16
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
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
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
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -538,14 +538,14 @@
|
|
|
538
538
|
"length": {
|
|
539
539
|
"type": "number"
|
|
540
540
|
},
|
|
541
|
-
"__@toStringTag@
|
|
541
|
+
"__@toStringTag@97592": {
|
|
542
542
|
"type": "string",
|
|
543
543
|
"const": "Uint8Array"
|
|
544
544
|
}
|
|
545
545
|
},
|
|
546
546
|
"required": [
|
|
547
547
|
"BYTES_PER_ELEMENT",
|
|
548
|
-
"__@toStringTag@
|
|
548
|
+
"__@toStringTag@97592",
|
|
549
549
|
"buffer",
|
|
550
550
|
"byteLength",
|
|
551
551
|
"byteOffset",
|
|
@@ -580,13 +580,13 @@
|
|
|
580
580
|
"byteLength": {
|
|
581
581
|
"type": "number"
|
|
582
582
|
},
|
|
583
|
-
"__@toStringTag@
|
|
583
|
+
"__@toStringTag@97592": {
|
|
584
584
|
"type": "string"
|
|
585
585
|
}
|
|
586
586
|
},
|
|
587
587
|
"additionalProperties": false,
|
|
588
588
|
"required": [
|
|
589
|
-
"__@toStringTag@
|
|
589
|
+
"__@toStringTag@97592",
|
|
590
590
|
"byteLength"
|
|
591
591
|
]
|
|
592
592
|
},
|
|
@@ -596,18 +596,18 @@
|
|
|
596
596
|
"byteLength": {
|
|
597
597
|
"type": "number"
|
|
598
598
|
},
|
|
599
|
-
"__@species@
|
|
599
|
+
"__@species@97693": {
|
|
600
600
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
601
601
|
},
|
|
602
|
-
"__@toStringTag@
|
|
602
|
+
"__@toStringTag@97592": {
|
|
603
603
|
"type": "string",
|
|
604
604
|
"const": "SharedArrayBuffer"
|
|
605
605
|
}
|
|
606
606
|
},
|
|
607
607
|
"additionalProperties": false,
|
|
608
608
|
"required": [
|
|
609
|
-
"__@species@
|
|
610
|
-
"__@toStringTag@
|
|
609
|
+
"__@species@97693",
|
|
610
|
+
"__@toStringTag@97592",
|
|
611
611
|
"byteLength"
|
|
612
612
|
]
|
|
613
613
|
},
|
|
@@ -16,10 +16,6 @@
|
|
|
16
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
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
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
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -16,10 +16,6 @@
|
|
|
16
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
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
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
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -441,14 +441,14 @@
|
|
|
441
441
|
"length": {
|
|
442
442
|
"type": "number"
|
|
443
443
|
},
|
|
444
|
-
"__@toStringTag@
|
|
444
|
+
"__@toStringTag@108664": {
|
|
445
445
|
"type": "string",
|
|
446
446
|
"const": "Uint8Array"
|
|
447
447
|
}
|
|
448
448
|
},
|
|
449
449
|
"required": [
|
|
450
450
|
"BYTES_PER_ELEMENT",
|
|
451
|
-
"__@toStringTag@
|
|
451
|
+
"__@toStringTag@108664",
|
|
452
452
|
"buffer",
|
|
453
453
|
"byteLength",
|
|
454
454
|
"byteOffset",
|
|
@@ -483,13 +483,13 @@
|
|
|
483
483
|
"byteLength": {
|
|
484
484
|
"type": "number"
|
|
485
485
|
},
|
|
486
|
-
"__@toStringTag@
|
|
486
|
+
"__@toStringTag@108664": {
|
|
487
487
|
"type": "string"
|
|
488
488
|
}
|
|
489
489
|
},
|
|
490
490
|
"additionalProperties": false,
|
|
491
491
|
"required": [
|
|
492
|
-
"__@toStringTag@
|
|
492
|
+
"__@toStringTag@108664",
|
|
493
493
|
"byteLength"
|
|
494
494
|
]
|
|
495
495
|
},
|
|
@@ -499,18 +499,18 @@
|
|
|
499
499
|
"byteLength": {
|
|
500
500
|
"type": "number"
|
|
501
501
|
},
|
|
502
|
-
"__@species@
|
|
502
|
+
"__@species@108765": {
|
|
503
503
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
504
504
|
},
|
|
505
|
-
"__@toStringTag@
|
|
505
|
+
"__@toStringTag@108664": {
|
|
506
506
|
"type": "string",
|
|
507
507
|
"const": "SharedArrayBuffer"
|
|
508
508
|
}
|
|
509
509
|
},
|
|
510
510
|
"additionalProperties": false,
|
|
511
511
|
"required": [
|
|
512
|
-
"__@species@
|
|
513
|
-
"__@toStringTag@
|
|
512
|
+
"__@species@108765",
|
|
513
|
+
"__@toStringTag@108664",
|
|
514
514
|
"byteLength"
|
|
515
515
|
]
|
|
516
516
|
},
|
|
@@ -16,10 +16,6 @@
|
|
|
16
16
|
}
|
|
17
17
|
]
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
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
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -484,14 +484,14 @@
|
|
|
484
484
|
"length": {
|
|
485
485
|
"type": "number"
|
|
486
486
|
},
|
|
487
|
-
"__@toStringTag@
|
|
487
|
+
"__@toStringTag@119813": {
|
|
488
488
|
"type": "string",
|
|
489
489
|
"const": "Uint8Array"
|
|
490
490
|
}
|
|
491
491
|
},
|
|
492
492
|
"required": [
|
|
493
493
|
"BYTES_PER_ELEMENT",
|
|
494
|
-
"__@toStringTag@
|
|
494
|
+
"__@toStringTag@119813",
|
|
495
495
|
"buffer",
|
|
496
496
|
"byteLength",
|
|
497
497
|
"byteOffset",
|
|
@@ -526,13 +526,13 @@
|
|
|
526
526
|
"byteLength": {
|
|
527
527
|
"type": "number"
|
|
528
528
|
},
|
|
529
|
-
"__@toStringTag@
|
|
529
|
+
"__@toStringTag@119813": {
|
|
530
530
|
"type": "string"
|
|
531
531
|
}
|
|
532
532
|
},
|
|
533
533
|
"additionalProperties": false,
|
|
534
534
|
"required": [
|
|
535
|
-
"__@toStringTag@
|
|
535
|
+
"__@toStringTag@119813",
|
|
536
536
|
"byteLength"
|
|
537
537
|
]
|
|
538
538
|
},
|
|
@@ -542,18 +542,18 @@
|
|
|
542
542
|
"byteLength": {
|
|
543
543
|
"type": "number"
|
|
544
544
|
},
|
|
545
|
-
"__@species@
|
|
545
|
+
"__@species@119914": {
|
|
546
546
|
"$ref": "#/definitions/SharedArrayBuffer"
|
|
547
547
|
},
|
|
548
|
-
"__@toStringTag@
|
|
548
|
+
"__@toStringTag@119813": {
|
|
549
549
|
"type": "string",
|
|
550
550
|
"const": "SharedArrayBuffer"
|
|
551
551
|
}
|
|
552
552
|
},
|
|
553
553
|
"additionalProperties": false,
|
|
554
554
|
"required": [
|
|
555
|
-
"__@species@
|
|
556
|
-
"__@toStringTag@
|
|
555
|
+
"__@species@119914",
|
|
556
|
+
"__@toStringTag@119813",
|
|
557
557
|
"byteLength"
|
|
558
558
|
]
|
|
559
559
|
},
|
|
@@ -16,10 +16,6 @@
|
|
|
16
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
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
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
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -36,6 +36,38 @@ describe('/chrome/function API', function () {
|
|
|
36
36
|
expect(res.status).to.equal(200);
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
+
it('runs functions with "context"', async () => {
|
|
40
|
+
const config = new Config();
|
|
41
|
+
config.setToken('browserless');
|
|
42
|
+
const metrics = new Metrics();
|
|
43
|
+
await start({ config, metrics });
|
|
44
|
+
const body = {
|
|
45
|
+
code: `export default async function ({ page, context }) {
|
|
46
|
+
if (!!context.ok) {
|
|
47
|
+
return Promise.resolve({
|
|
48
|
+
data: "ok",
|
|
49
|
+
type: "application/text",
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return Promise.reject(new Error('Bad context!'));
|
|
53
|
+
}`,
|
|
54
|
+
context: {
|
|
55
|
+
ok: true,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
await fetch('http://localhost:3000/chrome/function?token=browserless', {
|
|
59
|
+
body: JSON.stringify(body),
|
|
60
|
+
headers: {
|
|
61
|
+
'content-type': 'application/json',
|
|
62
|
+
},
|
|
63
|
+
method: 'POST',
|
|
64
|
+
}).then(async (res) => {
|
|
65
|
+
const json = await res.json();
|
|
66
|
+
expect(json).to.have.property('data');
|
|
67
|
+
expect(json.data).to.equal('ok');
|
|
68
|
+
expect(res.status).to.equal(200);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
39
71
|
it('runs "application/javascript" functions', async () => {
|
|
40
72
|
const config = new Config();
|
|
41
73
|
config.setToken('browserless');
|
|
@@ -16,10 +16,6 @@
|
|
|
16
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
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
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
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|
|
@@ -16,10 +16,6 @@
|
|
|
16
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
17
|
"type": "boolean"
|
|
18
18
|
},
|
|
19
|
-
"record": {
|
|
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
|
-
"type": "boolean"
|
|
22
|
-
},
|
|
23
19
|
"timeout": {
|
|
24
20
|
"description": "Override the system-level timeout for this request.\nAccepts a value in milliseconds.",
|
|
25
21
|
"type": "number"
|