@browserless.io/browserless 2.3.0-beta-2 → 2.4.0-beta-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/bin/browserless.js +2 -0
- package/bin/scaffold/README.md +24 -1
- package/build/browserless.d.ts +2 -0
- package/build/browserless.js +8 -2
- package/build/data/selectors.json +1 -1
- package/build/routes/chrome/http/content.post.body.json +8 -8
- 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/chrome/tests/function.spec.js +32 -0
- 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/management/http/static.get.js +17 -11
- package/build/types.d.ts +9 -1
- package/build/types.js +10 -1
- package/package.json +3 -3
- package/src/browserless.ts +9 -0
- package/src/routes/chrome/tests/function.spec.ts +35 -0
- package/src/routes/management/http/static.get.ts +25 -15
- package/src/types.ts +9 -0
- package/static/docs/swagger.json +10 -10
- package/static/docs/swagger.min.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
# [Latest](https://github.com/browserless/chrome/compare/v2.
|
|
1
|
+
# [Latest](https://github.com/browserless/chrome/compare/v2.3.0...main)
|
|
2
|
+
- Dependency updates.
|
|
3
|
+
|
|
4
|
+
# [v2.3.0](https://github.com/browserless/chrome/compare/v2.2.0...v2.3.0)
|
|
5
|
+
**Potentially Breaking**
|
|
6
|
+
- Routes must define a unique `name` property in order to remove them in SDK projects.
|
|
7
|
+
- A new `browserless` object in the SDK `package.json` file can specify module overrides, in camelCase, instead of using a path-based semantic.
|
|
8
|
+
- Fixes issues with `npx playwright-core install...` potentially installing other browser versions than what is a dependency of Browserless.
|
|
9
|
+
- Fixes and other general improvements.
|
|
2
10
|
- Dependency updates.
|
|
3
11
|
|
|
4
12
|
# [v2.2.0](https://github.com/browserless/chrome/compare/v2.1.0...v2.2.0)
|
package/bin/browserless.js
CHANGED
package/bin/scaffold/README.md
CHANGED
|
@@ -13,7 +13,8 @@ Finally, this SDK and Browserless.io are built to support businesses and enterpr
|
|
|
13
13
|
- [Routing](#routing)
|
|
14
14
|
- [Utilities](#utilities)
|
|
15
15
|
- [Extending Modules](#extending-modules)
|
|
16
|
-
- [Disabling Routes](#
|
|
16
|
+
- [Disabling Routes](#disabling-routes)
|
|
17
|
+
- [Serving Static Files](#serving-static-files)
|
|
17
18
|
- [Running in Development](#running-in-development)
|
|
18
19
|
- [Building for Production](#building-for-production)
|
|
19
20
|
- [Running without Building](#running-without-building)
|
|
@@ -397,6 +398,28 @@ Disabling a route will do several things:
|
|
|
397
398
|
|
|
398
399
|
All of Browserless' internal routes are side-effect free, meaning their largely state-less and don't do exhibit kind of behavior aside from route handling and metrics reporting. Having them in Node's module cache is fine since they're never mounted in the router and set up as a potential route.
|
|
399
400
|
|
|
401
|
+
## Serving Static Files
|
|
402
|
+
|
|
403
|
+
Aside from the static files Browserless serves for documentation, and a few other APIs, SDK projects can also provide static files to be served. To do so, simply create a "static" directory in the root of your project with the files you wish to serve. These will then be served based upon their location in the directory and the file name. Unless that is, of course, you've disabled the static route. Don't be silly.
|
|
404
|
+
|
|
405
|
+
Care should be taken _not_ to create the same filenames that Browserless serves and uses as internal static files takes precedence over SDK files. In short, the list is:
|
|
406
|
+
|
|
407
|
+
- `assets/*`
|
|
408
|
+
- `devtools/*`
|
|
409
|
+
- `docs/*`
|
|
410
|
+
- `function/*`
|
|
411
|
+
- `favicon-32x32.png`
|
|
412
|
+
|
|
413
|
+
Anything else is fair game and will be served properly. An easy way to "scope" files into a path is to simply create a subpath, for instance:
|
|
414
|
+
|
|
415
|
+
`static/enterprise/docs`
|
|
416
|
+
|
|
417
|
+
Will be available to be served under:
|
|
418
|
+
|
|
419
|
+
`http://YOUR-HOST:YOUR-PORT/enterprise/docs`
|
|
420
|
+
|
|
421
|
+
Which prevents this route from colliding with our internal `/docs` route.
|
|
422
|
+
|
|
400
423
|
## Running in Development
|
|
401
424
|
|
|
402
425
|
After the project has been set up, you can use npm commands to build and run your code. The most important of these is the `npm run dev` command, which will do the following:
|
package/build/browserless.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class Browserless {
|
|
|
12
12
|
protected router: Router;
|
|
13
13
|
protected token: Token;
|
|
14
14
|
protected webhooks: WebHooks;
|
|
15
|
+
protected staticSDKDir: string | null;
|
|
15
16
|
disabledRouteNames: string[];
|
|
16
17
|
webSocketRouteFiles: string[];
|
|
17
18
|
httpRouteFiles: string[];
|
|
@@ -32,6 +33,7 @@ export declare class Browserless {
|
|
|
32
33
|
protected saveMetrics: () => Promise<void>;
|
|
33
34
|
setMetricsSaveInterval: (interval: number) => void;
|
|
34
35
|
private routeIsDisabled;
|
|
36
|
+
setStaticSDKDir(dir: string): void;
|
|
35
37
|
disableRoutes(...routeNames: string[]): void;
|
|
36
38
|
addHTTPRoute(httpRouteFilePath: string): void;
|
|
37
39
|
addWebSocketRoute(webSocketRouteFilePath: string): void;
|
package/build/browserless.js
CHANGED
|
@@ -14,6 +14,7 @@ export class Browserless {
|
|
|
14
14
|
router;
|
|
15
15
|
token;
|
|
16
16
|
webhooks;
|
|
17
|
+
staticSDKDir = null;
|
|
17
18
|
disabledRouteNames = [];
|
|
18
19
|
webSocketRouteFiles = [];
|
|
19
20
|
httpRouteFiles = [];
|
|
@@ -73,6 +74,9 @@ export class Browserless {
|
|
|
73
74
|
routeIsDisabled(route) {
|
|
74
75
|
return this.disabledRouteNames.some((name) => name === route.name);
|
|
75
76
|
}
|
|
77
|
+
setStaticSDKDir(dir) {
|
|
78
|
+
this.staticSDKDir = dir;
|
|
79
|
+
}
|
|
76
80
|
disableRoutes(...routeNames) {
|
|
77
81
|
this.disabledRouteNames.push(...routeNames);
|
|
78
82
|
}
|
|
@@ -121,7 +125,7 @@ export class Browserless {
|
|
|
121
125
|
const routeImport = `${this.config.getIsWin() ? 'file:///' : ''}${httpRoute}`;
|
|
122
126
|
const logger = createLogger(`http:${name}`);
|
|
123
127
|
const { default: Route, } = await import(routeImport + `?cb=${Date.now()}`);
|
|
124
|
-
const route = new Route(this.browserManager, this.config, this.fileSystem, logger, this.metrics, this.monitoring);
|
|
128
|
+
const route = new Route(this.browserManager, this.config, this.fileSystem, logger, this.metrics, this.monitoring, this.staticSDKDir);
|
|
125
129
|
if (!this.routeIsDisabled(route)) {
|
|
126
130
|
route.bodySchema = safeParse(bodySchema);
|
|
127
131
|
route.querySchema = safeParse(querySchema);
|
|
@@ -130,6 +134,7 @@ export class Browserless {
|
|
|
130
134
|
route.monitoring = () => this.monitoring;
|
|
131
135
|
route.fileSystem = () => this.fileSystem;
|
|
132
136
|
route.debug = () => logger;
|
|
137
|
+
route.staticSDKDir = () => this.staticSDKDir;
|
|
133
138
|
httpRoutes.push(route);
|
|
134
139
|
}
|
|
135
140
|
}
|
|
@@ -149,7 +154,7 @@ export class Browserless {
|
|
|
149
154
|
const wsImport = `${this.config.getIsWin() ? 'file:///' : ''}${wsRoute}`;
|
|
150
155
|
const logger = createLogger(`ws:${name}`);
|
|
151
156
|
const { default: Route, } = await import(wsImport + `?cb=${Date.now()}`);
|
|
152
|
-
const route = new Route(this.browserManager, this.config, this.fileSystem, logger, this.metrics, this.monitoring);
|
|
157
|
+
const route = new Route(this.browserManager, this.config, this.fileSystem, logger, this.metrics, this.monitoring, this.staticSDKDir);
|
|
153
158
|
if (!this.routeIsDisabled(route)) {
|
|
154
159
|
route.querySchema = safeParse(querySchema);
|
|
155
160
|
route.config = () => this.config;
|
|
@@ -157,6 +162,7 @@ export class Browserless {
|
|
|
157
162
|
route.monitoring = () => this.monitoring;
|
|
158
163
|
route.fileSystem = () => this.fileSystem;
|
|
159
164
|
route.debug = () => logger;
|
|
165
|
+
route.staticSDKDir = () => this.staticSDKDir;
|
|
160
166
|
wsRoutes.push(route);
|
|
161
167
|
}
|
|
162
168
|
}
|