@roxybrowser/playwright 2.0.2-beta.4 → 2.0.2-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.
- package/dist/browserType.d.ts +23 -1
- package/dist/browserType.d.ts.map +1 -1
- package/dist/browserType.js +32 -5
- package/dist/browserType.js.map +1 -1
- package/dist/mcp/connectedBrowser.d.ts.map +1 -1
- package/dist/mcp/connectedBrowser.js +75 -4
- package/dist/mcp/connectedBrowser.js.map +1 -1
- package/dist/protocol/cdp/backend.d.ts.map +1 -1
- package/dist/protocol/cdp/backend.js +3 -0
- package/dist/protocol/cdp/backend.js.map +1 -1
- package/dist/roxybrowser.bundle.js +44 -8
- package/dist/roxybrowser.bundle.js.map +1 -1
- package/dist/types/api.d.ts +2 -2
- package/dist/types/api.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -53408,11 +53408,34 @@ var RoxyBrowserType = class {
|
|
|
53408
53408
|
protocol: options.protocol ?? (this.browserName === "firefox" ? "bidi" : "cdp")
|
|
53409
53409
|
});
|
|
53410
53410
|
}
|
|
53411
|
-
|
|
53411
|
+
/**
|
|
53412
|
+
* Connect to an already-running browser over a WebSocket endpoint.
|
|
53413
|
+
*
|
|
53414
|
+
* ⚠️ DIVERGENCE FROM PLAYWRIGHT — DO NOT "FIX" THIS BACK TO CDP-ONLY:
|
|
53415
|
+
*
|
|
53416
|
+
* In upstream Playwright, `BrowserType.connect()` is a CDP-only operation: it
|
|
53417
|
+
* connects to a running Chromium over the DevTools Protocol. Firefox/WebKit are
|
|
53418
|
+
* not supported here (Playwright routes BiDi through `connectOverCDP`-style
|
|
53419
|
+
* helpers or its own internal plumbing, not this method).
|
|
53420
|
+
*
|
|
53421
|
+
* Roxy intentionally changes that semantics. This method dispatches on
|
|
53422
|
+
* `browserName` so a single entry point serves both browser families:
|
|
53423
|
+
* - chromium → CDP (ws:// DevTools endpoint)
|
|
53424
|
+
* - firefox → BiDi (ws:// WebDriver BiDi endpoint)
|
|
53425
|
+
*
|
|
53426
|
+
* This is deliberate, not a bug. If you are an agent "normalizing" this code to
|
|
53427
|
+
* match Playwright upstream, STOP — the dual-protocol dispatch is the feature.
|
|
53428
|
+
* To force CDP specifically, call `connectOverCDP()` instead, which remains
|
|
53429
|
+
* chromium-only and CDP-only by design (see the guard below).
|
|
53430
|
+
*
|
|
53431
|
+
* `options.protocol` may still be passed to override the per-browser default.
|
|
53432
|
+
*/
|
|
53433
|
+
async connect(endpointURL, options) {
|
|
53412
53434
|
return this.connectBrowser({
|
|
53413
|
-
|
|
53414
|
-
|
|
53415
|
-
|
|
53435
|
+
browserName: this.browserName,
|
|
53436
|
+
protocol: this.browserName === "chromium" ? "cdp" : "bidi",
|
|
53437
|
+
wsEndpoint: endpointURL,
|
|
53438
|
+
...options
|
|
53416
53439
|
});
|
|
53417
53440
|
}
|
|
53418
53441
|
async connectOverCDP(progressOrEndpointURL, endpointURLOrOptions, maybeOptions = {}) {
|
|
@@ -74398,6 +74421,16 @@ var allTools = [...mouse_default, ...form_default];
|
|
|
74398
74421
|
function delay$1(ms) {
|
|
74399
74422
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
74400
74423
|
}
|
|
74424
|
+
async function withBiDiTimeout(promise, timeoutMs) {
|
|
74425
|
+
let timer;
|
|
74426
|
+
try {
|
|
74427
|
+
return await Promise.race([promise, new Promise((_, reject) => {
|
|
74428
|
+
timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`Timed out after ${timeoutMs}ms.`)), timeoutMs);
|
|
74429
|
+
})]);
|
|
74430
|
+
} finally {
|
|
74431
|
+
if (timer) clearTimeout(timer);
|
|
74432
|
+
}
|
|
74433
|
+
}
|
|
74401
74434
|
var chromeRemoteInterface = "default" in import_chrome_remote_interface ? import_chrome_remote_interface.default : import_chrome_remote_interface;
|
|
74402
74435
|
function buildConnectionFromWsEndpoint(browserWsEndpoint) {
|
|
74403
74436
|
const parsed = new URL(browserWsEndpoint);
|
|
@@ -76082,10 +76115,12 @@ var BidiConnectedBrowserSession = class BidiConnectedBrowserSession {
|
|
|
76082
76115
|
parameters: { pointerType: "mouse" },
|
|
76083
76116
|
actions: pointerActions
|
|
76084
76117
|
});
|
|
76085
|
-
|
|
76118
|
+
const performPromise = this.client.inputPerformActions({
|
|
76086
76119
|
context: tabId,
|
|
76087
76120
|
actions
|
|
76088
76121
|
});
|
|
76122
|
+
await Promise.race([performPromise, this.waitForDialog(tabId, options.clickHoldMs + 5e3)]);
|
|
76123
|
+
performPromise.catch(() => {});
|
|
76089
76124
|
await this.client.inputReleaseActions({ context: tabId }).catch(() => {});
|
|
76090
76125
|
}
|
|
76091
76126
|
async drag(start, end, options) {
|
|
@@ -76389,11 +76424,11 @@ var BidiConnectedBrowserSession = class BidiConnectedBrowserSession {
|
|
|
76389
76424
|
const tabId = this.dialogTabId();
|
|
76390
76425
|
if (!this.pageDialogStates.has(tabId)) throw new McpToolError("no_dialog", "No dialog visible.");
|
|
76391
76426
|
this.pageDialogStates.delete(tabId);
|
|
76392
|
-
await this.client.browsingContextHandleUserPrompt({
|
|
76427
|
+
await withBiDiTimeout(this.client.browsingContextHandleUserPrompt({
|
|
76393
76428
|
context: tabId,
|
|
76394
76429
|
accept,
|
|
76395
76430
|
...promptText !== void 0 ? { userText: promptText } : {}
|
|
76396
|
-
});
|
|
76431
|
+
}), 5e3);
|
|
76397
76432
|
}
|
|
76398
76433
|
async hasDialog() {
|
|
76399
76434
|
return this.pageDialogStates.size > 0;
|
|
@@ -76431,6 +76466,7 @@ var BidiConnectedBrowserSession = class BidiConnectedBrowserSession {
|
|
|
76431
76466
|
}`);
|
|
76432
76467
|
}
|
|
76433
76468
|
async initialize() {
|
|
76469
|
+
this.attachBiDiListeners();
|
|
76434
76470
|
await this.client.sessionSubscribe({ events: [
|
|
76435
76471
|
"browsingContext.userPromptOpened",
|
|
76436
76472
|
"log.entryAdded",
|
|
@@ -76444,7 +76480,6 @@ var BidiConnectedBrowserSession = class BidiConnectedBrowserSession {
|
|
|
76444
76480
|
maxEncodedDataSize: 1e7
|
|
76445
76481
|
}).catch(() => void 0);
|
|
76446
76482
|
this.responseDataCollector = collectorResult?.collector;
|
|
76447
|
-
this.attachBiDiListeners();
|
|
76448
76483
|
}
|
|
76449
76484
|
attachBiDiListeners() {
|
|
76450
76485
|
this.attachBiDiListener("log.entryAdded", (payload) => this.handleLogEntry(payload));
|
|
@@ -76574,6 +76609,7 @@ var BidiConnectedBrowserSession = class BidiConnectedBrowserSession {
|
|
|
76574
76609
|
type: event.type ?? "alert",
|
|
76575
76610
|
...event.defaultValue !== void 0 ? { defaultPrompt: event.defaultValue } : {}
|
|
76576
76611
|
});
|
|
76612
|
+
this.resolveDialogWaiters(event.context);
|
|
76577
76613
|
}
|
|
76578
76614
|
handleBeforeRequestSent(payload) {
|
|
76579
76615
|
const event = parseBidiNetworkEvent(payload);
|