@boxlite-ai/boxlite 0.2.4 → 0.2.5
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/dist/browserbox.d.ts +135 -71
- package/dist/browserbox.d.ts.map +1 -1
- package/dist/browserbox.js +373 -124
- package/dist/browserbox.js.map +1 -1
- package/dist/constants.d.ts +3 -7
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -8
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/native/boxlite.js +52 -52
- package/package.json +14 -5
package/dist/browserbox.js
CHANGED
|
@@ -1,47 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* BrowserBox - Secure browser with
|
|
2
|
+
* BrowserBox - Secure browser with Playwright Server.
|
|
3
3
|
*
|
|
4
4
|
* Provides a minimal, elegant API for running isolated browsers that can be
|
|
5
|
-
* controlled from outside using
|
|
5
|
+
* controlled from outside using Playwright. Supports all browser types:
|
|
6
|
+
* chromium, firefox, and webkit.
|
|
6
7
|
*/
|
|
7
|
-
import { SimpleBox } from
|
|
8
|
-
import { TimeoutError } from
|
|
9
|
-
import * as constants from
|
|
8
|
+
import { SimpleBox } from "./simplebox.js";
|
|
9
|
+
import { BoxliteError, TimeoutError } from "./errors.js";
|
|
10
|
+
import * as constants from "./constants.js";
|
|
11
|
+
/** Default CDP port for Puppeteer connections */
|
|
12
|
+
const CDP_PORT = 9222;
|
|
10
13
|
/**
|
|
11
|
-
* Secure browser environment with
|
|
14
|
+
* Secure browser environment with Playwright Server.
|
|
12
15
|
*
|
|
13
|
-
* Auto-starts a browser with
|
|
14
|
-
* Connect from outside using
|
|
16
|
+
* Auto-starts a browser with Playwright Server enabled for remote control.
|
|
17
|
+
* Connect from outside using Playwright's `connect()` method.
|
|
15
18
|
*
|
|
16
19
|
* ## Usage
|
|
17
20
|
*
|
|
18
21
|
* ```typescript
|
|
19
|
-
*
|
|
22
|
+
* import { BrowserBox } from '@boxlite-ai/boxlite';
|
|
23
|
+
* import { chromium } from 'playwright-core';
|
|
24
|
+
*
|
|
25
|
+
* const box = new BrowserBox({ browser: 'chromium' });
|
|
20
26
|
* try {
|
|
21
|
-
* await
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
27
|
+
* const ws = await box.playwrightEndpoint();
|
|
28
|
+
* const browser = await chromium.connect(ws);
|
|
29
|
+
*
|
|
30
|
+
* const page = await browser.newPage();
|
|
31
|
+
* await page.goto('https://example.com');
|
|
32
|
+
* console.log(await page.title());
|
|
33
|
+
*
|
|
34
|
+
* await browser.close();
|
|
25
35
|
* } finally {
|
|
26
|
-
* await
|
|
36
|
+
* await box.stop();
|
|
27
37
|
* }
|
|
28
38
|
* ```
|
|
29
39
|
*
|
|
30
|
-
* ##
|
|
40
|
+
* ## All browsers supported
|
|
31
41
|
*
|
|
32
42
|
* ```typescript
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* });
|
|
38
|
-
* try {
|
|
39
|
-
* await browser.start();
|
|
40
|
-
* const endpoint = browser.endpoint();
|
|
41
|
-
* // Connect using Playwright or Puppeteer
|
|
42
|
-
* } finally {
|
|
43
|
-
* await browser.stop();
|
|
44
|
-
* }
|
|
43
|
+
* // WebKit works!
|
|
44
|
+
* const box = new BrowserBox({ browser: 'webkit' });
|
|
45
|
+
* const ws = await box.playwrightEndpoint();
|
|
46
|
+
* const browser = await webkit.connect(ws);
|
|
45
47
|
* ```
|
|
46
48
|
*/
|
|
47
49
|
export class BrowserBox extends SimpleBox {
|
|
@@ -53,145 +55,392 @@ export class BrowserBox extends SimpleBox {
|
|
|
53
55
|
* @example
|
|
54
56
|
* ```typescript
|
|
55
57
|
* const browser = new BrowserBox({
|
|
56
|
-
* browser: '
|
|
58
|
+
* browser: 'webkit', // All browsers work!
|
|
57
59
|
* memoryMib: 2048,
|
|
58
60
|
* cpus: 2
|
|
59
61
|
* });
|
|
60
62
|
* ```
|
|
61
63
|
*/
|
|
62
64
|
constructor(options = {}) {
|
|
63
|
-
const { browser =
|
|
65
|
+
const { browser = "chromium", memoryMib = 2048, cpus = 2, port, cdpPort, ports: userPorts = [], ...restOptions } = options;
|
|
66
|
+
// Playwright Server ports
|
|
67
|
+
const guestPort = BrowserBox.DEFAULT_PORT;
|
|
68
|
+
const hostPort = port ?? guestPort;
|
|
69
|
+
// CDP ports for Puppeteer
|
|
70
|
+
const cdpGuestPort = CDP_PORT;
|
|
71
|
+
const cdpHostPort = cdpPort ?? cdpGuestPort;
|
|
72
|
+
// Add port forwarding for both Playwright Server and CDP
|
|
73
|
+
const defaultPorts = [
|
|
74
|
+
{ hostPort, guestPort }, // Playwright Server
|
|
75
|
+
{ hostPort: cdpHostPort, guestPort: cdpGuestPort }, // CDP for Puppeteer
|
|
76
|
+
];
|
|
64
77
|
super({
|
|
65
78
|
...restOptions,
|
|
66
79
|
image: BrowserBox.DEFAULT_IMAGE,
|
|
67
80
|
memoryMib,
|
|
68
81
|
cpus,
|
|
82
|
+
ports: [...defaultPorts, ...userPorts],
|
|
69
83
|
});
|
|
84
|
+
this._playwrightStarted = false;
|
|
85
|
+
this._cdpStarted = false;
|
|
70
86
|
this._browser = browser;
|
|
71
|
-
this.
|
|
87
|
+
this._guestPort = guestPort;
|
|
88
|
+
this._hostPort = hostPort;
|
|
89
|
+
this._cdpGuestPort = cdpGuestPort;
|
|
72
90
|
}
|
|
73
91
|
/**
|
|
74
|
-
* Start the
|
|
75
|
-
*
|
|
76
|
-
* Call this method after creating the BrowserBox to start the browser process.
|
|
77
|
-
* Waits for the browser to be ready before returning.
|
|
92
|
+
* Start the Playwright Server with the configured browser.
|
|
78
93
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
94
|
+
* The Playwright Server binds to 0.0.0.0, so no proxy is needed.
|
|
95
|
+
* It handles all browser types natively.
|
|
81
96
|
*
|
|
82
|
-
* @
|
|
83
|
-
*
|
|
84
|
-
* const browser = new BrowserBox();
|
|
85
|
-
* try {
|
|
86
|
-
* await browser.start();
|
|
87
|
-
* console.log(`Connect to: ${browser.endpoint()}`);
|
|
88
|
-
* } finally {
|
|
89
|
-
* await browser.stop();
|
|
90
|
-
* }
|
|
91
|
-
* ```
|
|
97
|
+
* @param timeout - Maximum time to wait for server to start in seconds (default: 60)
|
|
98
|
+
* @throws {TimeoutError} If server doesn't start within timeout
|
|
92
99
|
*/
|
|
93
|
-
async start(timeout =
|
|
94
|
-
|
|
95
|
-
let processPattern;
|
|
96
|
-
if (this._browser === 'chromium') {
|
|
97
|
-
const binary = '/ms-playwright/chromium-*/chrome-linux/chrome';
|
|
98
|
-
cmd =
|
|
99
|
-
`${binary} --headless --no-sandbox --disable-dev-shm-usage ` +
|
|
100
|
-
`--disable-gpu --remote-debugging-address=0.0.0.0 ` +
|
|
101
|
-
`--remote-debugging-port=${this._port} ` +
|
|
102
|
-
`> /tmp/browser.log 2>&1 &`;
|
|
103
|
-
processPattern = 'chrome';
|
|
104
|
-
}
|
|
105
|
-
else if (this._browser === 'firefox') {
|
|
106
|
-
const binary = '/ms-playwright/firefox-*/firefox/firefox';
|
|
107
|
-
cmd =
|
|
108
|
-
`${binary} --headless ` +
|
|
109
|
-
`--remote-debugging-port=${this._port} ` +
|
|
110
|
-
`> /tmp/browser.log 2>&1 &`;
|
|
111
|
-
processPattern = 'firefox';
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
// webkit
|
|
115
|
-
cmd =
|
|
116
|
-
`playwright run-server --browser webkit ` +
|
|
117
|
-
`--port ${this._port} > /tmp/browser.log 2>&1 &`;
|
|
118
|
-
processPattern = 'playwright';
|
|
119
|
-
}
|
|
120
|
-
// Start browser in background
|
|
121
|
-
await this.exec('sh', '-c', `nohup ${cmd}`);
|
|
122
|
-
// Wait for browser to be ready
|
|
123
|
-
await this.waitForBrowser(processPattern, timeout);
|
|
100
|
+
async start(timeout = 60) {
|
|
101
|
+
await this._startPlaywrightServer(timeout);
|
|
124
102
|
}
|
|
125
|
-
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
103
|
+
/** Start Playwright Server (works for ALL browsers). */
|
|
104
|
+
async _startPlaywrightServer(timeout = 60) {
|
|
105
|
+
const startCmd = `npx -y playwright@${BrowserBox.PLAYWRIGHT_VERSION} run-server ` +
|
|
106
|
+
`--port ${this._guestPort} --host 0.0.0.0 > /tmp/playwright.log 2>&1 &`;
|
|
107
|
+
await this.exec("sh", "-c", `nohup ${startCmd}`);
|
|
108
|
+
await this._waitForPlaywrightServer(timeout);
|
|
109
|
+
this._playwrightStarted = true;
|
|
110
|
+
}
|
|
111
|
+
/** Wait for Playwright Server to be ready. */
|
|
112
|
+
async _waitForPlaywrightServer(timeout) {
|
|
113
|
+
const startTime = Date.now();
|
|
114
|
+
const pollInterval = 500;
|
|
115
|
+
while (true) {
|
|
116
|
+
const elapsed = (Date.now() - startTime) / 1000;
|
|
117
|
+
if (elapsed > timeout) {
|
|
118
|
+
let logContent = "";
|
|
119
|
+
try {
|
|
120
|
+
const logResult = await this.exec("sh", "-c", "cat /tmp/playwright.log 2>/dev/null || echo 'No log'");
|
|
121
|
+
logContent = logResult.stdout.trim();
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
// Ignore errors reading log
|
|
125
|
+
}
|
|
126
|
+
throw new TimeoutError(`Playwright Server (${this._browser}) did not start within ${timeout}s. Log: ${logContent.slice(0, 500)}`);
|
|
127
|
+
}
|
|
128
|
+
const checkCmd = `curl -sf http://${constants.GUEST_IP}:${this._guestPort}/json > /dev/null 2>&1 && echo ready || echo notready`;
|
|
129
|
+
const result = await this.exec("sh", "-c", checkCmd);
|
|
130
|
+
if (result.stdout.trim() === "ready")
|
|
131
|
+
return;
|
|
132
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/** Start browser with remote debugging for Puppeteer (CDP for Chromium, WebDriver BiDi for Firefox). */
|
|
136
|
+
async _startCdpBrowser(timeout = 60) {
|
|
137
|
+
if (this._browser === "webkit") {
|
|
138
|
+
throw new BoxliteError("Puppeteer does not support WebKit. Use playwrightEndpoint() with Playwright for webkit.");
|
|
139
|
+
}
|
|
140
|
+
// endpoint() and Playwright cannot be used simultaneously (they share port 3000 for forwarding)
|
|
141
|
+
if (this._playwrightStarted) {
|
|
142
|
+
throw new BoxliteError("Cannot use endpoint() when Playwright Server is already running. " +
|
|
143
|
+
"Create a separate BrowserBox instance for Puppeteer usage.");
|
|
144
|
+
}
|
|
145
|
+
if (this._browser === "chromium") {
|
|
146
|
+
await this._startChromiumCdp(timeout);
|
|
147
|
+
}
|
|
148
|
+
else if (this._browser === "firefox") {
|
|
149
|
+
await this._startFirefoxBiDi(timeout);
|
|
150
|
+
}
|
|
151
|
+
// Start Python TCP forwarder to route traffic through port 3000 (which has working port forwarding)
|
|
152
|
+
await this._startCdpForwarder();
|
|
153
|
+
this._cdpStarted = true;
|
|
154
|
+
}
|
|
155
|
+
/** Start Chromium with CDP remote debugging. */
|
|
156
|
+
async _startChromiumCdp(timeout) {
|
|
157
|
+
// Find chromium binary in Playwright's installation directory
|
|
158
|
+
const findChrome = `CHROME=$(find /ms-playwright -name chrome -type f 2>/dev/null | grep chrome-linux | head -1) && echo $CHROME`;
|
|
159
|
+
const findResult = await this.exec("sh", "-c", findChrome);
|
|
160
|
+
const chromePath = findResult.stdout.trim();
|
|
161
|
+
if (!chromePath) {
|
|
162
|
+
throw new BoxliteError("Could not find chromium binary in Playwright image. Make sure you're using the Playwright Docker image.");
|
|
163
|
+
}
|
|
164
|
+
const startCmd = `${chromePath} --headless --no-sandbox --disable-gpu --disable-dev-shm-usage ` +
|
|
165
|
+
`--disable-software-rasterizer --no-first-run --disable-extensions ` +
|
|
166
|
+
`--user-data-dir=/tmp/chromium-data ` +
|
|
167
|
+
`--remote-debugging-address=0.0.0.0 --remote-debugging-port=${this._cdpGuestPort} ` +
|
|
168
|
+
`--remote-allow-origins=* ` +
|
|
169
|
+
`> /tmp/chromium-cdp.log 2>&1 &`;
|
|
170
|
+
await this.exec("sh", "-c", `nohup ${startCmd}`);
|
|
171
|
+
await this._waitForCdpServer(timeout);
|
|
172
|
+
}
|
|
173
|
+
/** Start Firefox with WebDriver BiDi remote debugging. */
|
|
174
|
+
async _startFirefoxBiDi(timeout) {
|
|
175
|
+
// Find firefox binary in Playwright's installation directory
|
|
176
|
+
const findFirefox = `FF=$(find /ms-playwright -name firefox -type f 2>/dev/null | head -1) && echo $FF`;
|
|
177
|
+
const findResult = await this.exec("sh", "-c", findFirefox);
|
|
178
|
+
const firefoxPath = findResult.stdout.trim();
|
|
179
|
+
if (!firefoxPath) {
|
|
180
|
+
throw new BoxliteError("Could not find firefox binary in Playwright image. Make sure you're using the Playwright Docker image.");
|
|
181
|
+
}
|
|
182
|
+
// Firefox uses --remote-debugging-port for WebDriver BiDi
|
|
183
|
+
const startCmd = `${firefoxPath} --headless --no-remote ` +
|
|
184
|
+
`--profile /tmp/firefox-profile ` +
|
|
185
|
+
`--remote-debugging-port ${this._cdpGuestPort} ` +
|
|
186
|
+
`> /tmp/firefox-bidi.log 2>&1 &`;
|
|
187
|
+
// Create profile directory
|
|
188
|
+
await this.exec("sh", "-c", "mkdir -p /tmp/firefox-profile");
|
|
189
|
+
await this.exec("sh", "-c", `nohup ${startCmd}`);
|
|
190
|
+
await this._waitForBiDiServer(timeout);
|
|
191
|
+
}
|
|
192
|
+
/** Wait for Firefox WebDriver BiDi server to be ready. */
|
|
193
|
+
async _waitForBiDiServer(timeout) {
|
|
133
194
|
const startTime = Date.now();
|
|
134
|
-
const pollInterval =
|
|
195
|
+
const pollInterval = 500;
|
|
135
196
|
while (true) {
|
|
136
197
|
const elapsed = (Date.now() - startTime) / 1000;
|
|
137
198
|
if (elapsed > timeout) {
|
|
138
|
-
|
|
199
|
+
let logContent = "";
|
|
200
|
+
try {
|
|
201
|
+
const logResult = await this.exec("sh", "-c", "cat /tmp/firefox-bidi.log 2>/dev/null || echo 'No log'");
|
|
202
|
+
logContent = logResult.stdout.trim();
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
// Ignore errors
|
|
206
|
+
}
|
|
207
|
+
throw new TimeoutError(`Firefox WebDriver BiDi did not start within ${timeout}s.\nLog: ${logContent.slice(0, 500)}`);
|
|
139
208
|
}
|
|
140
|
-
// Check
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
209
|
+
// Check log for "WebDriver BiDi listening" message
|
|
210
|
+
const checkCmd = `grep -q "WebDriver BiDi listening" /tmp/firefox-bidi.log 2>/dev/null && echo ready || echo notready`;
|
|
211
|
+
const result = await this.exec("sh", "-c", checkCmd);
|
|
212
|
+
if (result.stdout.trim() === "ready")
|
|
213
|
+
return;
|
|
214
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/** Start Python TCP forwarder to route traffic through the working port 3000. */
|
|
218
|
+
async _startCdpForwarder() {
|
|
219
|
+
// Python script that forwards TCP connections and rewrites Host header for Firefox
|
|
220
|
+
const cdpPort = this._cdpGuestPort;
|
|
221
|
+
const fwdPort = this._guestPort;
|
|
222
|
+
const script = [
|
|
223
|
+
"import socket, threading, re",
|
|
224
|
+
"def fwd(s,d,rewrite=False):",
|
|
225
|
+
" try:",
|
|
226
|
+
" first=True",
|
|
227
|
+
" while True:",
|
|
228
|
+
" x=s.recv(65536)",
|
|
229
|
+
" if not x: break",
|
|
230
|
+
" if first and rewrite:",
|
|
231
|
+
` x=re.sub(rb'Host: [^\\r\\n]+',b'Host: 127.0.0.1:${cdpPort}',x)`,
|
|
232
|
+
" first=False",
|
|
233
|
+
" d.sendall(x)",
|
|
234
|
+
" except: pass",
|
|
235
|
+
" s.close(); d.close()",
|
|
236
|
+
"def handle(c):",
|
|
237
|
+
" try:",
|
|
238
|
+
" srv=socket.socket()",
|
|
239
|
+
` srv.connect(('127.0.0.1',${cdpPort}))`,
|
|
240
|
+
" threading.Thread(target=fwd,args=(c,srv,True)).start()",
|
|
241
|
+
" threading.Thread(target=fwd,args=(srv,c,False)).start()",
|
|
242
|
+
" except: c.close()",
|
|
243
|
+
"l=socket.socket()",
|
|
244
|
+
"l.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)",
|
|
245
|
+
`l.bind(('0.0.0.0',${fwdPort}))`,
|
|
246
|
+
"l.listen(10)",
|
|
247
|
+
"while True:",
|
|
248
|
+
" c,_=l.accept()",
|
|
249
|
+
" threading.Thread(target=handle,args=(c,)).start()",
|
|
250
|
+
].join("\n");
|
|
251
|
+
await this.exec("sh", "-c", `printf '%s' '${script.replace(/'/g, "'\\''")}' > /tmp/cdp_fwd.py`);
|
|
252
|
+
await this.exec("sh", "-c", "nohup python3 /tmp/cdp_fwd.py >/dev/null 2>&1 &");
|
|
253
|
+
// Wait for forwarder to be ready by testing connection
|
|
254
|
+
const startTime = Date.now();
|
|
255
|
+
while (Date.now() - startTime < 10000) {
|
|
256
|
+
// Test forwarder by attempting a TCP connection using Python
|
|
257
|
+
const checkCmd = `python3 -c "import socket; s=socket.socket(); s.settimeout(1); s.connect(('127.0.0.1',${this._guestPort})); s.close(); print('ready')" 2>/dev/null || echo notready`;
|
|
258
|
+
const check = await this.exec("sh", "-c", checkCmd);
|
|
259
|
+
if (check.stdout.trim() === "ready") {
|
|
145
260
|
return;
|
|
146
261
|
}
|
|
147
|
-
|
|
148
|
-
|
|
262
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/** Wait for CDP server to be ready. */
|
|
266
|
+
async _waitForCdpServer(timeout) {
|
|
267
|
+
const startTime = Date.now();
|
|
268
|
+
const pollInterval = 500;
|
|
269
|
+
while (true) {
|
|
270
|
+
const elapsed = (Date.now() - startTime) / 1000;
|
|
271
|
+
if (elapsed > timeout) {
|
|
272
|
+
let logContent = "";
|
|
273
|
+
let processInfo = "";
|
|
274
|
+
let portInfo = "";
|
|
275
|
+
try {
|
|
276
|
+
const logResult = await this.exec("sh", "-c", "cat /tmp/chromium-cdp.log 2>/dev/null || echo 'No log'");
|
|
277
|
+
logContent = logResult.stdout.trim();
|
|
278
|
+
const psResult = await this.exec("sh", "-c", "ps aux | grep -i chrom | head -5");
|
|
279
|
+
processInfo = psResult.stdout.trim();
|
|
280
|
+
const netResult = await this.exec("sh", "-c", `netstat -tlnp 2>/dev/null | grep ${this._cdpGuestPort} || ss -tlnp 2>/dev/null | grep ${this._cdpGuestPort} || echo 'Port not bound'`);
|
|
281
|
+
portInfo = netResult.stdout.trim();
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
// Ignore errors
|
|
285
|
+
}
|
|
286
|
+
throw new TimeoutError(`CDP browser did not start within ${timeout}s.\n` +
|
|
287
|
+
`Log: ${logContent.slice(0, 500)}\n` +
|
|
288
|
+
`Processes: ${processInfo}\n` +
|
|
289
|
+
`Port ${this._cdpGuestPort}: ${portInfo}`);
|
|
290
|
+
}
|
|
291
|
+
// Try both localhost and GUEST_IP since chromium binds to 0.0.0.0
|
|
292
|
+
const checkCmd = `(curl -sf http://localhost:${this._cdpGuestPort}/json/version > /dev/null 2>&1 || curl -sf http://${constants.GUEST_IP}:${this._cdpGuestPort}/json/version > /dev/null 2>&1) && echo ready || echo notready`;
|
|
293
|
+
const result = await this.exec("sh", "-c", checkCmd);
|
|
294
|
+
if (result.stdout.trim() === "ready")
|
|
295
|
+
return;
|
|
296
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/** Ensure Playwright server is started. */
|
|
300
|
+
async _ensurePlaywrightStarted(timeout) {
|
|
301
|
+
if (!this._playwrightStarted) {
|
|
302
|
+
await this._startPlaywrightServer(timeout ?? 60);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/** Ensure CDP browser is started. */
|
|
306
|
+
async _ensureCdpStarted(timeout) {
|
|
307
|
+
if (!this._cdpStarted) {
|
|
308
|
+
await this._startCdpBrowser(timeout ?? 60);
|
|
149
309
|
}
|
|
150
310
|
}
|
|
151
311
|
/**
|
|
152
|
-
* Get the
|
|
312
|
+
* Get the WebSocket endpoint for Playwright connect().
|
|
153
313
|
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
314
|
+
* This is the primary method for Playwright connections.
|
|
315
|
+
* The returned URL can be used with Playwright's `connect()` method.
|
|
156
316
|
*
|
|
157
|
-
* @
|
|
317
|
+
* @param timeout - Optional timeout to wait for server to start (starts automatically if not started)
|
|
318
|
+
* @returns WebSocket endpoint URL (e.g., 'ws://localhost:3000/')
|
|
158
319
|
*
|
|
159
320
|
* @example
|
|
160
321
|
* ```typescript
|
|
161
|
-
* const
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
322
|
+
* const box = new BrowserBox({ browser: 'chromium' });
|
|
323
|
+
* const ws = await box.playwrightEndpoint();
|
|
324
|
+
* const browser = await chromium.connect(ws);
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
async playwrightEndpoint(timeout) {
|
|
328
|
+
await this._ensurePlaywrightStarted(timeout);
|
|
329
|
+
return `ws://localhost:${this._hostPort}/`;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* @deprecated Use playwrightEndpoint() instead.
|
|
333
|
+
*/
|
|
334
|
+
async wsEndpoint(timeout) {
|
|
335
|
+
return this.playwrightEndpoint(timeout);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Get the WebSocket endpoint for CDP/BiDi connections.
|
|
339
|
+
*
|
|
340
|
+
* This is the generic endpoint that works with Puppeteer, Selenium, or any
|
|
341
|
+
* other CDP/BiDi client. Works with chromium (CDP) and firefox (WebDriver BiDi).
|
|
342
|
+
* WebKit is not supported - use playwrightEndpoint() with Playwright instead.
|
|
165
343
|
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* // .then(d => d.webSocketDebuggerUrl);
|
|
170
|
-
* // const browser = await puppeteer.connect({ browserWSEndpoint });
|
|
344
|
+
* @param timeout - Optional timeout to wait for browser to start
|
|
345
|
+
* @returns WebSocket endpoint URL
|
|
346
|
+
* @throws {BoxliteError} If browser type is webkit
|
|
171
347
|
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```typescript
|
|
350
|
+
* // Chromium (CDP)
|
|
351
|
+
* const box = new BrowserBox({ browser: 'chromium' });
|
|
352
|
+
* const wsEndpoint = await box.endpoint();
|
|
353
|
+
* const browser = await puppeteer.connect({ browserWSEndpoint: wsEndpoint });
|
|
354
|
+
*
|
|
355
|
+
* // Firefox (WebDriver BiDi)
|
|
356
|
+
* const box = new BrowserBox({ browser: 'firefox' });
|
|
357
|
+
* const wsEndpoint = await box.endpoint();
|
|
358
|
+
* const browser = await puppeteer.connect({
|
|
359
|
+
* browserWSEndpoint: wsEndpoint,
|
|
360
|
+
* protocol: 'webDriverBiDi'
|
|
361
|
+
* });
|
|
362
|
+
* // Note: Firefox headless has a limitation where newPage() hangs.
|
|
363
|
+
* // Use browser.pages()[0] instead of browser.newPage().
|
|
364
|
+
* const page = (await browser.pages())[0];
|
|
177
365
|
* ```
|
|
178
366
|
*/
|
|
179
|
-
endpoint() {
|
|
180
|
-
|
|
367
|
+
async endpoint(timeout) {
|
|
368
|
+
await this._ensureCdpStarted(timeout);
|
|
369
|
+
if (this._browser === "firefox") {
|
|
370
|
+
// Firefox WebDriver BiDi requires /session path for WebSocket upgrade
|
|
371
|
+
// See: https://github.com/puppeteer/puppeteer/issues/13057
|
|
372
|
+
return `ws://localhost:${this._hostPort}/session`;
|
|
373
|
+
}
|
|
374
|
+
// Chromium: Fetch the WebSocket URL from CDP endpoint
|
|
375
|
+
const result = await this.exec("sh", "-c", `curl -sf http://localhost:${this._cdpGuestPort}/json/version`);
|
|
376
|
+
if (!result.stdout.trim()) {
|
|
377
|
+
throw new BoxliteError("CDP endpoint returned empty response");
|
|
378
|
+
}
|
|
379
|
+
const versionInfo = JSON.parse(result.stdout);
|
|
380
|
+
let wsUrl = versionInfo.webSocketDebuggerUrl || "";
|
|
381
|
+
if (!wsUrl) {
|
|
382
|
+
throw new BoxliteError("CDP endpoint did not return webSocketDebuggerUrl");
|
|
383
|
+
}
|
|
384
|
+
// Replace the internal address with localhost:hostPort
|
|
385
|
+
// Traffic is routed through port 3000 via the Python forwarder
|
|
386
|
+
wsUrl = wsUrl.replace(/ws:\/\/[^:]+:\d+/, `ws://localhost:${this._hostPort}`);
|
|
387
|
+
return wsUrl;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* @deprecated Use endpoint() instead.
|
|
391
|
+
*/
|
|
392
|
+
async puppeteerEndpoint(timeout) {
|
|
393
|
+
return this.endpoint(timeout);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* @deprecated Use endpoint() instead. This method only works with chromium.
|
|
397
|
+
*/
|
|
398
|
+
async cdpEndpoint(timeout) {
|
|
399
|
+
if (this._browser !== "chromium") {
|
|
400
|
+
throw new BoxliteError(`cdpEndpoint() only works with chromium. For ${this._browser}, use endpoint() instead.`);
|
|
401
|
+
}
|
|
402
|
+
return this.endpoint(timeout);
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Connect to the browser using Playwright.
|
|
406
|
+
*
|
|
407
|
+
* Convenience method that returns a connected Playwright Browser instance.
|
|
408
|
+
* Requires playwright-core to be installed.
|
|
409
|
+
*
|
|
410
|
+
* @param options - Connection options
|
|
411
|
+
* @returns Connected Playwright Browser instance
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* ```typescript
|
|
415
|
+
* const box = new BrowserBox({ browser: 'webkit' });
|
|
416
|
+
* const browser = await box.connect();
|
|
417
|
+
* const page = await browser.newPage();
|
|
418
|
+
* await page.goto('https://example.com');
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
async connect(options) {
|
|
422
|
+
const ws = await this.playwrightEndpoint(options?.timeout);
|
|
423
|
+
// Dynamic import to avoid requiring playwright-core as a dependency
|
|
424
|
+
const playwright = await import("playwright-core");
|
|
425
|
+
const browserType = playwright[this._browser];
|
|
426
|
+
if (!browserType?.connect) {
|
|
427
|
+
throw new BoxliteError(`Unknown browser type: ${this._browser}`);
|
|
428
|
+
}
|
|
429
|
+
return browserType.connect(ws);
|
|
181
430
|
}
|
|
182
431
|
/**
|
|
183
|
-
*
|
|
432
|
+
* Get the browser type.
|
|
184
433
|
*
|
|
185
|
-
* @
|
|
434
|
+
* @returns The browser type ('chromium', 'firefox', or 'webkit')
|
|
186
435
|
*/
|
|
187
|
-
|
|
188
|
-
|
|
436
|
+
get browser() {
|
|
437
|
+
return this._browser;
|
|
189
438
|
}
|
|
190
439
|
}
|
|
191
|
-
|
|
192
|
-
BrowserBox.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
440
|
+
/** Playwright Docker image with all browsers pre-installed */
|
|
441
|
+
BrowserBox.DEFAULT_IMAGE = "mcr.microsoft.com/playwright:v1.58.0-jammy";
|
|
442
|
+
/** Playwright version - must match the Docker image */
|
|
443
|
+
BrowserBox.PLAYWRIGHT_VERSION = "1.58.0";
|
|
444
|
+
/** Default port for Playwright Server */
|
|
445
|
+
BrowserBox.DEFAULT_PORT = constants.BROWSERBOX_PORT;
|
|
197
446
|
//# sourceMappingURL=browserbox.js.map
|
package/dist/browserbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserbox.js","sourceRoot":"","sources":["../lib/browserbox.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAyB,MAAM,gBAAgB,CA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,QAAQ,EAAE,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;;AAneD,8DAA8D;AACtC,wBAAa,GACnC,4CAA4C,AADT,CACU;AAE/C,uDAAuD;AAC/B,6BAAkB,GAAG,QAAQ,AAAX,CAAY;AAEtD,yCAAyC;AACjB,uBAAY,GAAG,SAAS,CAAC,eAAe,AAA5B,CAA6B"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* These values match the Python SDK for consistency across language bindings.
|
|
5
5
|
*/
|
|
6
|
-
export declare const COMPUTERBOX_IMAGE = "
|
|
6
|
+
export declare const COMPUTERBOX_IMAGE = "lscr.io/linuxserver/webtop:ubuntu-xfce";
|
|
7
7
|
export declare const COMPUTERBOX_CPUS = 2;
|
|
8
8
|
export declare const COMPUTERBOX_MEMORY_MIB = 2048;
|
|
9
9
|
export declare const COMPUTERBOX_DISPLAY_NUMBER = ":1";
|
|
@@ -13,12 +13,8 @@ export declare const COMPUTERBOX_GUI_HTTP_PORT = 3000;
|
|
|
13
13
|
export declare const COMPUTERBOX_GUI_HTTPS_PORT = 3001;
|
|
14
14
|
export declare const DESKTOP_READY_TIMEOUT = 60;
|
|
15
15
|
export declare const DESKTOP_READY_RETRY_DELAY = 2;
|
|
16
|
-
export declare const
|
|
17
|
-
export declare const BROWSERBOX_IMAGE_FIREFOX = "browserless/firefox:latest";
|
|
18
|
-
export declare const BROWSERBOX_IMAGE_WEBKIT = "browserless/webkit:latest";
|
|
19
|
-
export declare const BROWSERBOX_PORT_CHROMIUM = 9222;
|
|
20
|
-
export declare const BROWSERBOX_PORT_FIREFOX = 9223;
|
|
21
|
-
export declare const BROWSERBOX_PORT_WEBKIT = 9224;
|
|
16
|
+
export declare const BROWSERBOX_PORT = 3000;
|
|
22
17
|
export declare const DEFAULT_CPUS = 1;
|
|
23
18
|
export declare const DEFAULT_MEMORY_MIB = 512;
|
|
19
|
+
export declare const GUEST_IP = "192.168.127.2";
|
|
24
20
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../lib/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../lib/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,eAAO,MAAM,iBAAiB,2CAA2C,CAAC;AAC1E,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAC3C,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAC/C,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAG/C,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAI3C,eAAO,MAAM,eAAe,OAAO,CAAC;AAGpC,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAGtC,eAAO,MAAM,QAAQ,kBAAkB,CAAC"}
|