@browserless.io/browserless 2.0.0-beta-5 → 2.0.0-beta-7

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.
Files changed (246) hide show
  1. package/LICENSE +2 -0
  2. package/README.md +11 -11
  3. package/bin/browserless.js +169 -11
  4. package/bin/scaffold/README.md +415 -0
  5. package/bin/scaffold/package.json +21 -0
  6. package/bin/scaffold/src/hello-world.http.ts +27 -0
  7. package/bin/scaffold/tsconfig.json +4 -0
  8. package/build/browserless.js +18 -15
  9. package/build/browsers/index.d.ts +2 -18
  10. package/build/browsers/index.js +43 -14
  11. package/build/file-system.d.ts +5 -0
  12. package/build/file-system.js +20 -5
  13. package/build/file-system.spec.d.ts +1 -0
  14. package/build/file-system.spec.js +44 -0
  15. package/build/http.d.ts +3 -3
  16. package/build/http.js +3 -3
  17. package/build/router.js +2 -4
  18. package/build/routes/chromium/http/content-post.body.json +8 -8
  19. package/build/routes/chromium/http/content-post.d.ts +15 -3
  20. package/build/routes/chromium/http/content-post.js +14 -15
  21. package/build/routes/chromium/http/download-post.d.ts +16 -3
  22. package/build/routes/chromium/http/download-post.js +17 -22
  23. package/build/routes/chromium/http/function-post.d.ts +16 -3
  24. package/build/routes/chromium/http/function-post.js +17 -22
  25. package/build/routes/chromium/http/pdf-post.body.json +8 -8
  26. package/build/routes/chromium/http/pdf-post.d.ts +15 -3
  27. package/build/routes/chromium/http/pdf-post.js +19 -15
  28. package/build/routes/chromium/http/performance.d.ts +15 -3
  29. package/build/routes/chromium/http/performance.js +15 -23
  30. package/build/routes/chromium/http/scrape-post.body.json +8 -8
  31. package/build/routes/chromium/http/scrape-post.d.ts +15 -3
  32. package/build/routes/chromium/http/scrape-post.js +15 -16
  33. package/build/routes/chromium/http/screenshot-post.body.json +8 -8
  34. package/build/routes/chromium/http/screenshot-post.d.ts +15 -3
  35. package/build/routes/chromium/http/screenshot-post.js +18 -15
  36. package/build/routes/chromium/tests/websocket.spec.js +20 -1
  37. package/build/routes/chromium/utils/function/handler.js +2 -2
  38. package/build/routes/chromium/ws/browser.d.ts +13 -3
  39. package/build/routes/chromium/ws/browser.js +10 -11
  40. package/build/routes/chromium/ws/cdp-chromium.d.ts +13 -3
  41. package/build/routes/chromium/ws/cdp-chromium.js +10 -11
  42. package/build/routes/chromium/ws/page.d.ts +13 -3
  43. package/build/routes/chromium/ws/page.js +10 -11
  44. package/build/routes/chromium/ws/playwright-chromium.d.ts +13 -3
  45. package/build/routes/chromium/ws/playwright-chromium.js +11 -12
  46. package/build/routes/firefox/ws/playwright-firefox.d.ts +13 -3
  47. package/build/routes/firefox/ws/playwright-firefox.js +11 -12
  48. package/build/routes/management/http/config-get.d.ts +15 -3
  49. package/build/routes/management/http/config-get.js +15 -20
  50. package/build/routes/management/http/metrics-get.d.ts +15 -3
  51. package/build/routes/management/http/metrics-get.js +16 -21
  52. package/build/routes/management/http/metrics-total-get.d.ts +15 -3
  53. package/build/routes/management/http/metrics-total-get.js +16 -21
  54. package/build/routes/management/http/sessions-get.d.ts +15 -3
  55. package/build/routes/management/http/sessions-get.js +16 -20
  56. package/build/routes/management/http/static-get.d.ts +15 -3
  57. package/build/routes/management/http/static-get.js +15 -20
  58. package/build/routes/webkit/ws/playwright-webkit.d.ts +13 -3
  59. package/build/routes/webkit/ws/playwright-webkit.js +11 -12
  60. package/build/server.js +0 -1
  61. package/build/types.d.ts +48 -38
  62. package/build/types.js +135 -0
  63. package/extensions/ublock/1p-filters.html +0 -1
  64. package/extensions/ublock/3p-filters.html +0 -2
  65. package/extensions/ublock/_locales/bg/messages.json +6 -6
  66. package/extensions/ublock/_locales/br_FR/messages.json +14 -14
  67. package/extensions/ublock/_locales/bs/messages.json +8 -8
  68. package/extensions/ublock/_locales/ca/messages.json +1 -1
  69. package/extensions/ublock/_locales/da/messages.json +5 -5
  70. package/extensions/ublock/_locales/fa/messages.json +1 -1
  71. package/extensions/ublock/_locales/fi/messages.json +6 -6
  72. package/extensions/ublock/_locales/hr/messages.json +4 -4
  73. package/extensions/ublock/_locales/nb/messages.json +1 -1
  74. package/extensions/ublock/_locales/no/messages.json +1 -1
  75. package/extensions/ublock/_locales/ro/messages.json +2 -2
  76. package/extensions/ublock/_locales/ru/messages.json +1 -1
  77. package/extensions/ublock/_locales/sk/messages.json +1 -1
  78. package/extensions/ublock/_locales/sv/messages.json +2 -2
  79. package/extensions/ublock/_locales/te/messages.json +17 -17
  80. package/extensions/ublock/_locales/vi/messages.json +12 -12
  81. package/extensions/ublock/_locales/zh_TW/messages.json +13 -13
  82. package/extensions/ublock/assets/assets.json +3 -3
  83. package/extensions/ublock/assets/resources/scriptlets.js +218 -97
  84. package/extensions/ublock/assets/thirdparties/easylist/easylist.txt +3010 -2056
  85. package/extensions/ublock/assets/thirdparties/easylist/easyprivacy.txt +624 -433
  86. package/extensions/ublock/assets/thirdparties/pgl.yoyo.org/as/serverlist +93 -24
  87. package/extensions/ublock/assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat +7 -15
  88. package/extensions/ublock/assets/thirdparties/urlhaus-filter/urlhaus-filter-online.txt +795 -777
  89. package/extensions/ublock/assets/ublock/badware.min.txt +138 -72
  90. package/extensions/ublock/assets/ublock/filters.min.txt +1929 -2735
  91. package/extensions/ublock/assets/ublock/privacy.min.txt +57 -26
  92. package/extensions/ublock/assets/ublock/quick-fixes.min.txt +125 -74
  93. package/extensions/ublock/assets/ublock/unbreak.min.txt +46 -53
  94. package/extensions/ublock/css/codemirror.css +8 -7
  95. package/extensions/ublock/css/dom-inspector.css +40 -0
  96. package/extensions/ublock/css/logger-ui-inspector.css +7 -1
  97. package/extensions/ublock/css/logger-ui.css +12 -5
  98. package/extensions/ublock/css/popup-fenix.css +1 -1
  99. package/extensions/ublock/devtools.html +1 -0
  100. package/extensions/ublock/js/1p-filters.js +4 -3
  101. package/extensions/ublock/js/3p-filters.js +25 -31
  102. package/extensions/ublock/js/about.js +1 -1
  103. package/extensions/ublock/js/advanced-settings.js +1 -1
  104. package/extensions/ublock/js/asset-viewer.js +1 -1
  105. package/extensions/ublock/js/assets.js +74 -44
  106. package/extensions/ublock/js/background.js +9 -3
  107. package/extensions/ublock/js/base64-custom.js +1 -1
  108. package/extensions/ublock/js/benchmarks.js +1 -1
  109. package/extensions/ublock/js/biditrie.js +1 -1
  110. package/extensions/ublock/js/broadcast.js +75 -0
  111. package/extensions/ublock/js/cachestorage.js +68 -45
  112. package/extensions/ublock/js/click2load.js +1 -1
  113. package/extensions/ublock/js/cloud-ui.js +1 -1
  114. package/extensions/ublock/js/code-viewer.js +1 -1
  115. package/extensions/ublock/js/codemirror/search-thread.js +1 -1
  116. package/extensions/ublock/js/codemirror/search.js +1 -1
  117. package/extensions/ublock/js/codemirror/ubo-dynamic-filtering.js +1 -1
  118. package/extensions/ublock/js/codemirror/ubo-static-filtering.js +98 -24
  119. package/extensions/ublock/js/commands.js +1 -1
  120. package/extensions/ublock/js/console.js +1 -1
  121. package/extensions/ublock/js/contentscript-extra.js +1 -1
  122. package/extensions/ublock/js/contentscript.js +1 -3
  123. package/extensions/ublock/js/contextmenu.js +1 -1
  124. package/extensions/ublock/js/cosmetic-filtering.js +4 -4
  125. package/extensions/ublock/js/dashboard-common.js +1 -1
  126. package/extensions/ublock/js/dashboard.js +1 -1
  127. package/extensions/ublock/js/devtools.js +23 -15
  128. package/extensions/ublock/js/diff-updater.js +3 -3
  129. package/extensions/ublock/js/document-blocked.js +1 -1
  130. package/extensions/ublock/js/dom-inspector.js +68 -0
  131. package/extensions/ublock/js/dom.js +1 -1
  132. package/extensions/ublock/js/dyna-rules.js +1 -1
  133. package/extensions/ublock/js/dynamic-net-filtering.js +1 -1
  134. package/extensions/ublock/js/epicker-ui.js +35 -59
  135. package/extensions/ublock/js/fa-icons.js +1 -1
  136. package/extensions/ublock/js/filtering-context.js +1 -1
  137. package/extensions/ublock/js/filtering-engines.js +1 -1
  138. package/extensions/ublock/js/hnswitches.js +1 -1
  139. package/extensions/ublock/js/hntrie.js +1 -1
  140. package/extensions/ublock/js/html-filtering.js +1 -1
  141. package/extensions/ublock/js/httpheader-filtering.js +1 -1
  142. package/extensions/ublock/js/i18n.js +1 -1
  143. package/extensions/ublock/js/is-webrtc-supported.js +1 -1
  144. package/extensions/ublock/js/logger-ui-inspector.js +203 -145
  145. package/extensions/ublock/js/logger-ui.js +21 -5
  146. package/extensions/ublock/js/logger.js +6 -2
  147. package/extensions/ublock/js/lz4.js +2 -2
  148. package/extensions/ublock/js/messaging.js +266 -166
  149. package/extensions/ublock/js/mrucache.js +58 -0
  150. package/extensions/ublock/js/pagestore.js +1 -1
  151. package/extensions/ublock/js/popup-fenix.js +2 -1
  152. package/extensions/ublock/js/redirect-engine.js +1 -1
  153. package/extensions/ublock/js/redirect-resources.js +1 -12
  154. package/extensions/ublock/js/reverselookup-worker.js +1 -1
  155. package/extensions/ublock/js/reverselookup.js +1 -1
  156. package/extensions/ublock/js/scriptlet-filtering-core.js +300 -0
  157. package/extensions/ublock/js/scriptlet-filtering.js +122 -350
  158. package/extensions/ublock/js/scriptlets/cosmetic-logger.js +36 -47
  159. package/extensions/ublock/js/scriptlets/cosmetic-off.js +1 -1
  160. package/extensions/ublock/js/scriptlets/cosmetic-on.js +1 -1
  161. package/extensions/ublock/js/scriptlets/cosmetic-report.js +1 -1
  162. package/extensions/ublock/js/scriptlets/dom-inspector.js +341 -323
  163. package/extensions/ublock/js/scriptlets/dom-survey-elements.js +1 -1
  164. package/extensions/ublock/js/scriptlets/dom-survey-scripts.js +1 -1
  165. package/extensions/ublock/js/scriptlets/epicker.js +80 -89
  166. package/extensions/ublock/js/scriptlets/load-3p-css.js +1 -1
  167. package/extensions/ublock/js/scriptlets/load-large-media-all.js +1 -1
  168. package/extensions/ublock/js/scriptlets/load-large-media-interactive.js +1 -1
  169. package/extensions/ublock/js/scriptlets/noscript-spoof.js +1 -1
  170. package/extensions/ublock/js/scriptlets/should-inject-contentscript.js +1 -1
  171. package/extensions/ublock/js/scriptlets/subscriber.js +1 -1
  172. package/extensions/ublock/js/scriptlets/updater.js +20 -3
  173. package/extensions/ublock/js/settings.js +1 -1
  174. package/extensions/ublock/js/start.js +19 -20
  175. package/extensions/ublock/js/static-dnr-filtering.js +1 -1
  176. package/extensions/ublock/js/static-ext-filtering-db.js +1 -1
  177. package/extensions/ublock/js/static-ext-filtering.js +1 -1
  178. package/extensions/ublock/js/static-filtering-io.js +1 -1
  179. package/extensions/ublock/js/static-filtering-parser.js +5 -3
  180. package/extensions/ublock/js/static-net-filtering.js +57 -37
  181. package/extensions/ublock/js/storage.js +49 -29
  182. package/extensions/ublock/js/support.js +4 -4
  183. package/extensions/ublock/js/tab.js +1 -1
  184. package/extensions/ublock/js/tasks.js +1 -1
  185. package/extensions/ublock/js/text-encode.js +1 -1
  186. package/extensions/ublock/js/text-utils.js +1 -1
  187. package/extensions/ublock/js/theme.js +1 -1
  188. package/extensions/ublock/js/traffic.js +2 -1
  189. package/extensions/ublock/js/ublock.js +15 -11
  190. package/extensions/ublock/js/uri-utils.js +1 -1
  191. package/extensions/ublock/js/url-net-filtering.js +1 -1
  192. package/extensions/ublock/js/utils.js +1 -73
  193. package/extensions/ublock/js/vapi-background-ext.js +1 -1
  194. package/extensions/ublock/js/vapi-background.js +92 -83
  195. package/extensions/ublock/js/vapi-client.js +4 -33
  196. package/extensions/ublock/js/vapi-common.js +16 -30
  197. package/extensions/ublock/js/vapi.js +1 -1
  198. package/extensions/ublock/js/wasm/biditrie.wat +1 -1
  199. package/extensions/ublock/js/wasm/hntrie.wat +1 -1
  200. package/extensions/ublock/js/webext.js +1 -1
  201. package/extensions/ublock/js/whitelist.js +1 -1
  202. package/extensions/ublock/logger-ui.html +2 -2
  203. package/extensions/ublock/manifest.json +1 -1
  204. package/extensions/ublock/support.html +0 -1
  205. package/extensions/ublock/web_accessible_resources/dom-inspector.html +25 -0
  206. package/extensions/ublock/web_accessible_resources/epicker-ui.html +0 -1
  207. package/extensions/ublock/web_accessible_resources/googletagservices_gpt.js +1 -0
  208. package/package.json +7 -19
  209. package/scripts/build-open-api.js +7 -4
  210. package/src/browserless.ts +42 -18
  211. package/src/browsers/index.ts +48 -20
  212. package/src/file-system.spec.ts +58 -0
  213. package/src/file-system.ts +36 -8
  214. package/src/http.ts +3 -3
  215. package/src/router.ts +2 -6
  216. package/src/routes/chromium/http/content-post.ts +13 -16
  217. package/src/routes/chromium/http/download-post.ts +16 -27
  218. package/src/routes/chromium/http/function-post.ts +16 -25
  219. package/src/routes/chromium/http/pdf-post.ts +19 -15
  220. package/src/routes/chromium/http/performance.ts +14 -26
  221. package/src/routes/chromium/http/scrape-post.ts +14 -16
  222. package/src/routes/chromium/http/screenshot-post.ts +18 -15
  223. package/src/routes/chromium/tests/websocket.spec.ts +28 -1
  224. package/src/routes/chromium/utils/function/handler.ts +2 -1
  225. package/src/routes/chromium/ws/browser.ts +10 -12
  226. package/src/routes/chromium/ws/cdp-chromium.ts +10 -12
  227. package/src/routes/chromium/ws/page.ts +10 -12
  228. package/src/routes/chromium/ws/playwright-chromium.ts +10 -12
  229. package/src/routes/firefox/ws/playwright-firefox.ts +10 -12
  230. package/src/routes/management/http/config-get.ts +14 -23
  231. package/src/routes/management/http/metrics-get.ts +15 -24
  232. package/src/routes/management/http/metrics-total-get.ts +15 -26
  233. package/src/routes/management/http/sessions-get.ts +15 -23
  234. package/src/routes/management/http/static-get.ts +14 -22
  235. package/src/routes/webkit/ws/playwright-webkit.ts +10 -12
  236. package/src/server.ts +0 -1
  237. package/src/types.ts +59 -45
  238. package/static/docs/browserless-logo-inline.svg +1 -0
  239. package/static/docs/index.html +27 -0
  240. package/static/docs/swagger.json +33 -33
  241. package/static/function/client.js +626 -78
  242. package/extensions/ublock/js/vapi-client-extra.js +0 -312
  243. package/extensions/ublock/web_accessible_resources/addthis_widget.js +0 -39
  244. package/extensions/ublock/web_accessible_resources/ligatus_angular-tag.js +0 -29
  245. package/extensions/ublock/web_accessible_resources/monkeybroker.js +0 -43
  246. package/extensions/ublock/web_accessible_resources/mxpnl_mixpanel.js +0 -51
@@ -5,7 +5,6 @@ import {
5
5
  Methods,
6
6
  NotFound,
7
7
  Request,
8
- ServerError,
9
8
  contentTypes,
10
9
  createLogger,
11
10
  fileExists,
@@ -47,15 +46,17 @@ const streamFile = (res: ServerResponse, file: string, contentType?: string) =>
47
46
  .pipe(res);
48
47
  });
49
48
 
50
- const route: HTTPRoute = {
51
- accepts: [contentTypes.any],
52
- auth: false,
53
- browser: null,
54
- concurrency: false,
55
- contentTypes: [contentTypes.any],
56
- description: `Serves static files inside of this "static" directory. Content-types will vary depending on the type of file being returned.`,
57
- handler: async (req: Request, res: ServerResponse): Promise<unknown> => {
58
- const { getConfig: getConfig } = route;
49
+ export default class StaticGetRoute extends HTTPRoute {
50
+ accepts = [contentTypes.any];
51
+ auth = false;
52
+ browser = null;
53
+ concurrency = false;
54
+ contentTypes = [contentTypes.any];
55
+ description = `Serves static files inside of this "static" directory. Content-types will vary depending on the type =of file being returned.`;
56
+ method = Methods.get;
57
+ path = HTTPManagementRoutes.static;
58
+ tags = [APITags.management];
59
+ handler = async (req: Request, res: ServerResponse): Promise<unknown> => {
59
60
  const { pathname } = req.parsed;
60
61
  const fileCache = pathMap.get(pathname);
61
62
 
@@ -63,11 +64,7 @@ const route: HTTPRoute = {
63
64
  return streamFile(res, fileCache.path, fileCache.contentType);
64
65
  }
65
66
 
66
- if (!getConfig) {
67
- throw new ServerError(`Couldn't load configuration for request`);
68
- }
69
-
70
- const config = getConfig();
67
+ const config = this.config();
71
68
  const file = path.join(config.getStatic(), pathname);
72
69
  const indexFile = path.join(file, 'index.html');
73
70
 
@@ -100,10 +97,5 @@ const route: HTTPRoute = {
100
97
  });
101
98
 
102
99
  return streamFile(res, filePath, contentType);
103
- },
104
- method: Methods.get,
105
- path: HTTPManagementRoutes.static,
106
- tags: [APITags.management],
107
- };
108
-
109
- export default route;
100
+ };
101
+ }
@@ -14,12 +14,14 @@ export interface QuerySchema extends SystemQueryParameters {
14
14
  launch?: BrowserServerOptions | string;
15
15
  }
16
16
 
17
- const route: BrowserWebsocketRoute = {
18
- auth: true,
19
- browser: PlaywrightWebkit,
20
- concurrency: true,
21
- description: `Connect to Webkit with any playwright-compliant library.`,
22
- handler: async (
17
+ export default class PlaywrightWebkitRoute extends BrowserWebsocketRoute {
18
+ auth = true;
19
+ browser = PlaywrightWebkit;
20
+ concurrency = true;
21
+ description = `Connect to Webkit with any playwright-compliant library.`;
22
+ path = WebsocketRoutes.playwrightWebkit;
23
+ tags = [APITags.browserWS];
24
+ handler = async (
23
25
  req: Request,
24
26
  socket: Duplex,
25
27
  head: Buffer,
@@ -36,9 +38,5 @@ const route: BrowserWebsocketRoute = {
36
38
  }
37
39
 
38
40
  return browser.proxyWebSocket(req, socket, head);
39
- },
40
- path: WebsocketRoutes.playwrightWebkit,
41
- tags: [APITags.browserWS],
42
- };
43
-
44
- export default route;
41
+ };
42
+ }
package/src/server.ts CHANGED
@@ -298,7 +298,6 @@ export class HTTPServer {
298
298
  return writeResponse(res, 408, e.message);
299
299
  }
300
300
 
301
- this.log(`Error handling request at "${route.path}": ${e}`);
302
301
  return writeResponse(res, 500, e.toString());
303
302
  });
304
303
  };
package/src/types.ts CHANGED
@@ -88,12 +88,21 @@ type defaultLaunchOptions =
88
88
  | BrowserlessLaunch
89
89
  | ((req: Request) => CDPLaunchOptions | BrowserlessLaunch);
90
90
 
91
- interface Route {
91
+ abstract class Route {
92
+ constructor(
93
+ protected _browserManager: Browserless['browserManager'],
94
+ protected _config: Browserless['config'],
95
+ protected _fileSystem: Browserless['fileSystem'],
96
+ protected _debug: Browserless['debug'],
97
+ protected _metrics: Browserless['metrics'],
98
+ protected _monitoring: Browserless['monitoring'],
99
+ ) {}
100
+
92
101
  /**
93
102
  * A boolean, or a function that returns a boolean, on
94
103
  * whether the route requires an API token to access.
95
104
  */
96
- auth: boolean | ((req: Request) => Promise<boolean>);
105
+ auth: boolean | ((req: Request) => Promise<boolean>) = true;
97
106
 
98
107
  /**
99
108
  * The schematic of the submitted BODY (typically)
@@ -102,31 +111,45 @@ interface Route {
102
111
  */
103
112
  bodySchema?: unknown;
104
113
 
114
+ /**
115
+ * The query parameters accepted by the route, defined in
116
+ * an object format. This is auto-generated for you if your
117
+ * route defines and exports a QuerySchema type.
118
+ */
119
+ querySchema?: unknown;
120
+
121
+ /**
122
+ * The structure of the routes response when successful. This
123
+ * is auto-generated for you if your route defines a ResponseSchema
124
+ * type and exports it in your route.
125
+ */
126
+ responseSchema?: unknown;
127
+
105
128
  /**
106
129
  * Whether the route should be bound by the global
107
130
  * concurrency limit defined in your configuration.
108
131
  */
109
- concurrency: boolean;
132
+ concurrency: boolean = true;
110
133
 
111
134
  /**
112
135
  * Description of the route and what it does. This description
113
136
  * is then used in the embedded documentation site.
114
137
  */
115
- description: string;
138
+ description?: string;
116
139
 
117
140
  /**
118
141
  * Helper function to load the browser-manager instance. Defined
119
142
  * and injected by browserless after initialization.
120
143
  * @returns BrowserManager
121
144
  */
122
- getBrowserManager?: () => Browserless['browserManager'];
145
+ browserManager = () => this._browserManager;
123
146
 
124
147
  /**
125
148
  * Helper function that loads the config module. Defined and injected by
126
149
  * browserless after initialization.
127
150
  * @returns Config
128
151
  */
129
- getConfig?: () => Browserless['config'];
152
+ config = () => this._config;
130
153
 
131
154
  /**
132
155
  * Helper function that loads the debug module, useful
@@ -134,7 +157,7 @@ interface Route {
134
157
  * and injected by browserless after initialization.
135
158
  * @returns Debug
136
159
  */
137
- getDebug?: () => debug.Debugger;
160
+ debug = () => this._debug;
138
161
 
139
162
  /**
140
163
  * Helper function that loads the file-system module
@@ -142,7 +165,7 @@ interface Route {
142
165
  * browserless after initialization.
143
166
  * @returns FileSystem
144
167
  */
145
- getFileSystem?: () => Browserless['fileSystem'];
168
+ fileSystem = () => this._fileSystem;
146
169
 
147
170
  /**
148
171
  * Helper function that loads the metrics module for
@@ -150,7 +173,7 @@ interface Route {
150
173
  * browserless after initialization.
151
174
  * @returns Metrics
152
175
  */
153
- getMetrics?: () => Browserless['metrics'];
176
+ metrics = () => this._metrics;
154
177
 
155
178
  /**
156
179
  * Helper function that loads the monitoring module useful
@@ -158,32 +181,18 @@ interface Route {
158
181
  * browserless after initialization.
159
182
  * @returns Monitor
160
183
  */
161
- getMonitoring?: () => Browserless['monitoring'];
184
+ monitoring = () => this._monitoring;
162
185
 
163
186
  /**
164
187
  * The HTTP path that this route handles, eg '/my-route'
165
188
  */
166
- path: HTTPRoutes | WebsocketRoutes | HTTPManagementRoutes | string;
167
-
168
- /**
169
- * The query parameters accepted by the route, defined in
170
- * an object format. This is auto-generated for you if your
171
- * route defines and exports a QuerySchema type.
172
- */
173
- querySchema?: unknown;
174
-
175
- /**
176
- * The structure of the routes response when successful. This
177
- * is auto-generated for you if your route defines a ResponseSchema
178
- * type and exports it in your route.
179
- */
180
- responseSchema?: unknown;
189
+ abstract path: HTTPRoutes | WebsocketRoutes | HTTPManagementRoutes | string;
181
190
 
182
191
  /**
183
192
  * The tag(s) for the route to categorize it in the
184
193
  * documentation portal
185
194
  */
186
- tags: APITags[];
195
+ abstract tags: APITags[];
187
196
  }
188
197
 
189
198
  /**
@@ -191,38 +200,39 @@ interface Route {
191
200
  * browser in order to fulfill requests. Used by downstream HTTPRoute
192
201
  * and WebSocketRoute
193
202
  */
194
- interface BasicHTTPRoute extends Route {
203
+ abstract class BasicHTTPRoute extends Route {
195
204
  /**
196
205
  * The allowed Content-Types that this route can read and handle.
197
206
  * If a request comes in with a Content-Type of 'application/json', then
198
207
  * this accepts would need to include ["application/json"] in order to not 404
199
208
  */
200
- accepts: Array<contentTypes>;
209
+ abstract accepts: Array<contentTypes>;
201
210
 
202
211
  /**
203
212
  * The Content-Types that this route will will respond with, and must match the Accepts
204
213
  * Header from a client if present. If a request comes in with an Accepts of "application/json"
205
214
  * then the contentTypes here would need to include ["application/json"] in order to not 404.
206
215
  */
207
- contentTypes: Array<contentTypes>;
216
+ abstract contentTypes: Array<contentTypes>;
208
217
 
209
218
  /**
210
219
  * The allowed methods ("GET", "POST", etc) this route can utilize and match against.
211
220
  */
212
- method: Methods;
221
+ abstract method: Methods;
213
222
  }
214
223
 
215
224
  /**
216
225
  * A HTTP-based route, with a handler, that can fulfill requests without
217
226
  * a browser required.
218
227
  */
219
- export interface HTTPRoute extends BasicHTTPRoute {
220
- browser: null;
221
-
228
+ export abstract class HTTPRoute extends BasicHTTPRoute {
222
229
  /**
223
230
  * Handles an inbound HTTP request, and supplies the Request and Response objects from node's HTTP request event
224
231
  */
225
- handler: (req: Request, res: http.ServerResponse) => Promise<unknown>;
232
+ abstract handler: (
233
+ req: Request,
234
+ res: http.ServerResponse,
235
+ ) => Promise<unknown>;
226
236
  }
227
237
 
228
238
  /**
@@ -230,35 +240,39 @@ export interface HTTPRoute extends BasicHTTPRoute {
230
240
  * requires a browser in order to do so. Handler will then be called
231
241
  * with a 3rd argument of the browser class specified.
232
242
  */
233
- export interface BrowserHTTPRoute extends BasicHTTPRoute {
234
- browser: BrowserClasses;
235
-
243
+ export abstract class BrowserHTTPRoute extends BasicHTTPRoute {
236
244
  defaultLaunchOptions?: defaultLaunchOptions;
237
245
 
246
+ abstract browser: BrowserClasses;
247
+
238
248
  /**
239
249
  * Handles an inbound HTTP request with a 3rd param of the predefined
240
250
  * browser used for the route -- only Chrome CDP is support currently.
241
251
  */
242
- handler: (
252
+ abstract handler: (
243
253
  req: Request,
244
254
  res: http.ServerResponse,
245
255
  browser: BrowserInstance,
246
256
  ) => Promise<unknown>;
247
257
 
248
- onNewPage?: undefined;
258
+ /**
259
+ * An optional function to automatically set up or handle new page
260
+ * creation. Useful for injecting behaviors or other functionality.
261
+ */
262
+ onNewPage?: (url: URL, page: Page) => Promise<void>;
249
263
  }
250
264
 
251
265
  /**
252
266
  * A WebSocket-based route, with a handler, that can fulfill requests
253
267
  * that do not require a browser in order to operate.
254
268
  */
255
- export interface WebSocketRoute extends Route {
256
- browser: null;
269
+ export abstract class WebSocketRoute extends Route {
270
+ browser = null;
257
271
 
258
272
  /**
259
273
  * Handles an inbound Websocket request, and handles the connection
260
274
  */
261
- handler: (
275
+ abstract handler: (
262
276
  req: Request,
263
277
  socket: stream.Duplex,
264
278
  head: Buffer,
@@ -270,8 +284,8 @@ export interface WebSocketRoute extends Route {
270
284
  * that need a browser. Handler is called with an additional argument of
271
285
  * browser (the browser class required to run the route).
272
286
  */
273
- export interface BrowserWebsocketRoute extends Route {
274
- browser: BrowserClasses;
287
+ export abstract class BrowserWebsocketRoute extends Route {
288
+ abstract browser: BrowserClasses;
275
289
 
276
290
  defaultLaunchOptions?: defaultLaunchOptions;
277
291
 
@@ -279,7 +293,7 @@ export interface BrowserWebsocketRoute extends Route {
279
293
  * Handles an inbound Websocket request, and handles the connection
280
294
  * with the prior set browser being injected.
281
295
  */
282
- handler(
296
+ abstract handler(
283
297
  req: Request,
284
298
  socket: stream.Duplex,
285
299
  head: Buffer,
@@ -0,0 +1 @@
1
+ <svg width="148" height="38" viewBox="0 0 148 38" fill="#fff" xmlns="http://www.w3.org/2000/svg" class="xl:h-8 xl:w-[125px]"><path class="logo_inline_svg__cls-1" d="M11.09 14.86V6.57L7.38 4.38V22.8l6.15-2.88.01 4.03-9.81 4.88V2.17L.04 0 0 30.73l3.56 2.39 13.69-6.8-.02-7.84-6.14-3.62zM35.06 16.13a3.21 3.21 0 00-1.42-1 6.33 6.33 0 00-2.07-.3 6.64 6.64 0 00-2.45.61v-3.29l-3-1.59v16.16h4.43a10.47 10.47 0 002.64-.29 3.81 3.81 0 001.75-1 3.91 3.91 0 001-1.83 11.13 11.13 0 00.3-2.81 12.56 12.56 0 00-.35-2.79 4.61 4.61 0 00-.83-1.87zM33 22.22a2.41 2.41 0 01-.41 1 1.62 1.62 0 01-.8.57 4 4 0 01-1.24.17L30 24l-.86-.07v-6.08l.32-.07a6.12 6.12 0 011.72-.23c1.28 0 1.91 1 1.91 3.07a10.28 10.28 0 01-.09 1.6zM41.79 15.1h-3v11.35h3v-7.61l.46-.15c.44-.14.92-.28 1.44-.41s1.09-.27 1.71-.39v-3.06a11.83 11.83 0 00-3.63 1.47zM52.19 14.83a6.3 6.3 0 00-2.45.42 3.94 3.94 0 00-1.62 1.19 4.87 4.87 0 00-.88 1.86 10.21 10.21 0 00-.24 2.45q0 6 5.22 6t5.22-6a7 7 0 00-1.2-4.37 4.77 4.77 0 00-4.05-1.55zm1.68 8.5a1.74 1.74 0 01-1.68.8 2 2 0 01-1.17-.3 2 2 0 01-.64-.8 3.56 3.56 0 01-.27-1.09 11.85 11.85 0 01-.06-1.19 5.35 5.35 0 01.46-2.55 2.18 2.18 0 013.36 0 5.37 5.37 0 01.45 2.55 5.56 5.56 0 01-.45 2.58zM71.17 23.86h-.54l-1.73-8.54h-3.13l-1.73 8.54h-.54l-1.39-8.76h-3l2.16 11.35h4.77l1.29-6.95 1.3 6.95h4.76l2.16-11.35h-2.99l-1.39 8.76zM85.59 20.62a3 3 0 00-1-.67 6.81 6.81 0 00-1.59-.42c-.62-.11-1.12-.2-1.49-.29a5.51 5.51 0 01-.78-.21.64.64 0 01-.46-.62.69.69 0 01.34-.63 3.18 3.18 0 011.46-.21q.57 0 1.53.09c.64.06 1.44.16 2.4.28v-2.52l-.75-.14c-.77-.15-1.46-.26-2.08-.33a13.89 13.89 0 00-1.57-.1 6.1 6.1 0 00-1.76.23 3.84 3.84 0 00-1.39.68 3.25 3.25 0 00-.91 1.13 3.64 3.64 0 00-.33 1.59 4.59 4.59 0 00.26 1.52 2.38 2.38 0 00.65 1 3.05 3.05 0 001.09.64 8.94 8.94 0 001.54.37 13.1 13.1 0 012.18.5.68.68 0 01.41.64.67.67 0 01-.39.63 3.29 3.29 0 01-1.5.23q-.56 0-1.53-.09c-.64-.06-1.44-.15-2.39-.27l-.09 2.54.72.13a19.48 19.48 0 003.64.41q4.56 0 4.56-3.67a5.05 5.05 0 00-.18-1.44 2.36 2.36 0 00-.59-1zM93.35 14.83c-3.34 0-5 2-5 6.1a6.82 6.82 0 001.16 4.43 4.64 4.64 0 003.73 1.36 20 20 0 004.72-.63v-2.25l-.63.07c-1.11.09-2.36.13-3.77.13a2.28 2.28 0 01-1.55-.46 2 2 0 01-.54-1.51h6.67L98.3 20q0-5.17-4.95-5.17zm-2 4.92a3.15 3.15 0 01.46-1.87 1.87 1.87 0 011.53-.56 1.81 1.81 0 011.51.54 3.13 3.13 0 01.42 1.89zM103.84 15.1h-3v11.35h3v-7.61l.46-.15c.44-.14.92-.28 1.44-.41s1.09-.27 1.71-.39v-3.06a11.83 11.83 0 00-3.63 1.47zM109.74 10.56h3.04v15.89h-3.04zM120.53 14.83q-5 0-5 6.1a6.82 6.82 0 001.16 4.43 4.62 4.62 0 003.72 1.36 20 20 0 004.73-.63l-.05-2.25-.64.07c-1.1.09-2.36.13-3.76.13a2.26 2.26 0 01-1.55-.46 2 2 0 01-.54-1.51h6.67l.23-2.11q-.02-5.13-4.97-5.13zm-2 4.92a3.14 3.14 0 01.47-1.87 1.85 1.85 0 011.53-.56 1.81 1.81 0 011.51.54 3.13 3.13 0 01.42 1.89zM135.74 20.62a3 3 0 00-1-.67 6.9 6.9 0 00-1.55-.42c-.62-.11-1.11-.2-1.48-.29a5.37 5.37 0 01-.79-.21.63.63 0 01-.45-.62.68.68 0 01.34-.63 3.1 3.1 0 011.45-.21q.57 0 1.53.09c.65.06 1.45.16 2.4.28v-2.52l-.75-.14c-.78-.15-1.47-.26-2.08-.33a14 14 0 00-1.58-.1 6.15 6.15 0 00-1.76.23 3.72 3.72 0 00-1.38.68 3.14 3.14 0 00-.91 1.13 3.64 3.64 0 00-.33 1.59 4.61 4.61 0 00.21 1.51 2.48 2.48 0 00.65 1 3.14 3.14 0 001.09.64 8.94 8.94 0 001.54.37 12.83 12.83 0 012.18.5.71.71 0 010 1.27 3.35 3.35 0 01-1.5.23q-.57 0-1.53-.09t-2.4-.27l-.09 2.54.73.13a19.39 19.39 0 003.63.41q4.56 0 4.56-3.67a5.05 5.05 0 00-.18-1.44 2.36 2.36 0 00-.55-.99zM147.39 21.61a2.36 2.36 0 00-.59-1 2.92 2.92 0 00-1.05-.67 6.81 6.81 0 00-1.54-.42c-.62-.11-1.12-.2-1.49-.29a5.51 5.51 0 01-.78-.21.63.63 0 01-.45-.62.68.68 0 01.34-.63 3.1 3.1 0 011.45-.21q.57 0 1.53.09c.64.06 1.44.16 2.4.28v-2.52l-.75-.14q-1.16-.22-2.07-.33a14.19 14.19 0 00-1.58-.1 6.1 6.1 0 00-1.76.23 3.84 3.84 0 00-1.39.68 3.25 3.25 0 00-.91 1.13 3.64 3.64 0 00-.32 1.59 4.61 4.61 0 00.21 1.51 2.38 2.38 0 00.65 1 3.14 3.14 0 001.09.64A8.94 8.94 0 00142 22a13.1 13.1 0 012.18.5.68.68 0 01.41.64.67.67 0 01-.39.63 3.27 3.27 0 01-1.49.23c-.38 0-.89 0-1.54-.09s-1.44-.15-2.39-.27l-.09 2.54.72.13a19.48 19.48 0 003.64.41q4.56 0 4.56-3.67a5.05 5.05 0 00-.22-1.44z"></path></svg>
@@ -13,6 +13,8 @@
13
13
  a[href^="mailto:"] {
14
14
  text-decoration: underline !important;
15
15
  }
16
+
17
+ img[src="/assets/logo.png"],
16
18
  a[href="https://github.com/Redocly/redoc"],
17
19
  a[href="https://redocly.com/redoc/"] {
18
20
  display: none !important;
@@ -63,6 +65,31 @@
63
65
  .redoc-markdown :not(pre) code {
64
66
  color: rgb(255, 102, 178) !important;
65
67
  }
68
+
69
+ input[aria-label="Search"] {
70
+ color: white;
71
+ }
72
+
73
+ div[role="search"] svg.search-icon path {
74
+ fill: white !important;
75
+ }
76
+
77
+ div[data-role="search:results"] {
78
+ background: rgb(51, 51, 51);
79
+ }
80
+
81
+ div[role="search"] div.scrollbar-container {
82
+ height: fit-content;
83
+ z-index: 11111;
84
+ position: absolute;
85
+ width: 94%;
86
+ }
87
+
88
+ div.menu-content > div > img {
89
+ width: 75%;
90
+ margin-left: 5%;
91
+ margin-bottom: 10%;
92
+ }
66
93
  </style>
67
94
  </head>
68
95
  <body>