brave-real-playwright-core 1.55.1-patch.1 → 1.56.0
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/README.md +5 -5
- package/advanced-stealth.js +1 -1
- package/lib/browserServerImpl.js +3 -6
- package/lib/client/browser.js +0 -10
- package/lib/client/browserContext.js +2 -8
- package/lib/client/channelOwner.js +0 -7
- package/lib/client/consoleMessage.js +2 -3
- package/lib/client/electron.js +1 -1
- package/lib/client/events.js +1 -0
- package/lib/client/network.js +3 -0
- package/lib/client/page.js +13 -1
- package/lib/generated/bindingsControllerSource.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/pollingRecorderSource.js +1 -1
- package/lib/generated/utilityScriptSource.js +1 -1
- package/lib/protocol/validator.js +26 -15
- package/lib/remote/playwrightServer.js +12 -14
- package/lib/server/bidi/bidiBrowser.js +54 -10
- package/lib/server/bidi/bidiChromium.js +1 -1
- package/lib/server/bidi/bidiConnection.js +31 -6
- package/lib/server/bidi/bidiExecutionContext.js +4 -4
- package/lib/server/bidi/bidiFirefox.js +16 -1
- package/lib/server/bidi/bidiNetworkManager.js +82 -16
- package/lib/server/bidi/bidiPage.js +84 -18
- package/lib/server/browserType.js +3 -3
- package/lib/server/chromium/chromium.js +1 -1
- package/lib/server/chromium/chromiumSwitches.js +3 -1
- package/lib/server/chromium/crBrowser.js +2 -33
- package/lib/server/chromium/crPage.js +22 -31
- package/lib/server/codegen/csharp.js +19 -26
- package/lib/server/codegen/java.js +4 -0
- package/lib/server/codegen/javascript.js +3 -1
- package/lib/server/codegen/python.js +2 -0
- package/lib/server/debugController.js +8 -36
- package/lib/server/deviceDescriptorsSource.json +62 -62
- package/lib/server/dispatchers/androidDispatcher.js +17 -0
- package/lib/server/dispatchers/browserContextDispatcher.js +1 -15
- package/lib/server/dispatchers/networkDispatchers.js +6 -3
- package/lib/server/dispatchers/pageDispatcher.js +24 -0
- package/lib/server/dom.js +8 -3
- package/lib/server/firefox/ffPage.js +1 -2
- package/lib/server/firefox/firefox.js +1 -1
- package/lib/server/frames.js +12 -4
- package/lib/server/har/harTracer.js +7 -8
- package/lib/server/network.js +12 -0
- package/lib/server/page.js +39 -17
- package/lib/server/recorder/chat.js +2 -2
- package/lib/server/recorder/recorderRunner.js +4 -0
- package/lib/server/registry/browserFetcher.js +3 -3
- package/lib/server/registry/index.js +27 -0
- package/lib/server/trace/recorder/snapshotter.js +13 -2
- package/lib/server/trace/recorder/snapshotterInjected.js +3 -1
- package/lib/server/utils/comparators.js +2 -2
- package/lib/server/utils/env.js +7 -2
- package/lib/server/utils/wsServer.js +2 -7
- package/lib/server/webkit/webkit.js +24 -8
- package/lib/server/webkit/wkBrowser.js +7 -3
- package/lib/server/webkit/wkPage.js +7 -8
- package/lib/server/webkit/wsl/webkit-wsl-transport-client.js +74 -0
- package/lib/server/webkit/wsl/webkit-wsl-transport-server.js +113 -0
- package/lib/utils/isomorphic/ariaSnapshot.js +12 -10
- package/lib/utils/isomorphic/protocolMetainfo.js +3 -0
- package/lib/utils/isomorphic/urlMatch.js +3 -8
- package/lib/utilsBundle.js +3 -0
- package/lib/utilsBundleImpl/index.js +80 -80
- package/lib/vite/htmlReport/index.html +37 -28
- package/lib/vite/recorder/assets/codeMirrorModule-RJCXzfmE.js +24 -0
- package/lib/vite/recorder/assets/index-Ri0uHF7I.css +1 -0
- package/lib/vite/recorder/assets/index-Y-X2TGJv.js +193 -0
- package/lib/vite/recorder/index.html +2 -2
- package/lib/vite/traceViewer/assets/codeMirrorModule-eyVcHN77.js +24 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-w0zYjHsW.js +265 -0
- package/lib/vite/traceViewer/assets/xtermModule-CsJ4vdCR.js +9 -0
- package/lib/vite/traceViewer/defaultSettingsView.TQ8_7ybu.css +1 -0
- package/lib/vite/traceViewer/index.Bx16ehp1.js +2 -0
- package/lib/vite/traceViewer/index.I8N9v4jT.css +1 -0
- package/lib/vite/traceViewer/index.html +4 -4
- package/lib/vite/traceViewer/sw.bundle.js +3 -3
- package/lib/vite/traceViewer/uiMode.Btcz36p_.css +1 -0
- package/lib/vite/traceViewer/uiMode.DRQ310U5.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +4 -4
- package/lib/vite/traceViewer/{xtermModule.Beg8tuEN.css → xtermModule.DYP7pi_n.css} +1 -1
- package/package.json +9 -9
- package/lib/vite/recorder/assets/codeMirrorModule-DzQ0k89p.js +0 -24
- package/lib/vite/recorder/assets/index-CI4HQ-Zb.css +0 -1
- package/lib/vite/recorder/assets/index-D7C7daHH.js +0 -184
- package/lib/vite/traceViewer/assets/codeMirrorModule-CEFqZ5b3.js +0 -24
- package/lib/vite/traceViewer/assets/defaultSettingsView-BA25Usqk.js +0 -256
- package/lib/vite/traceViewer/assets/xtermModule-BoAIEibi.js +0 -9
- package/lib/vite/traceViewer/defaultSettingsView.DVJHpiGt.css +0 -1
- package/lib/vite/traceViewer/index.BFsek2M6.css +0 -1
- package/lib/vite/traceViewer/index.CheexZ4_.js +0 -2
- package/lib/vite/traceViewer/uiMode.BatfzHMG.css +0 -1
- package/lib/vite/traceViewer/uiMode.Dy4dnPNW.js +0 -5
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# 🦁 brave-real-playwright-core v1.
|
|
1
|
+
# 🦁 brave-real-playwright-core v1.56.0
|
|
2
2
|
|
|
3
|
-
**Based on Playwright Core v1.
|
|
3
|
+
**Based on Playwright Core v1.56.0**
|
|
4
4
|
|
|
5
5
|
**Brave Real-World Optimized Playwright Core with comprehensive stealth patches**
|
|
6
6
|
|
|
7
|
-
This is a pre-patched version of **Playwright Core v1.
|
|
7
|
+
This is a pre-patched version of **Playwright Core v1.56.0** optimized for maximum stealth when using Brave browser.
|
|
8
8
|
|
|
9
9
|
## ✨ Features
|
|
10
10
|
|
|
@@ -46,9 +46,9 @@ await page.goto('https://bot-detector.rebrowser.net/');
|
|
|
46
46
|
|
|
47
47
|
## 📦 Based On
|
|
48
48
|
|
|
49
|
-
- **playwright-core**: v1.
|
|
49
|
+
- **playwright-core**: v1.56.0
|
|
50
50
|
- **rebrowser-patches**: Latest stealth optimizations
|
|
51
|
-
- **Brave optimization**: v1.
|
|
51
|
+
- **Brave optimization**: v1.56.0
|
|
52
52
|
|
|
53
53
|
## 🔗 Links
|
|
54
54
|
|
package/advanced-stealth.js
CHANGED
package/lib/browserServerImpl.js
CHANGED
|
@@ -49,8 +49,8 @@ class BrowserServerLauncherImpl {
|
|
|
49
49
|
const playwright = (0, import_playwright.createPlaywright)({ sdkLanguage: "javascript", isServer: true });
|
|
50
50
|
const metadata = { id: "", startTime: 0, endTime: 0, type: "Internal", method: "", params: {}, log: [], internal: true };
|
|
51
51
|
const validatorContext = {
|
|
52
|
-
tChannelImpl: (names, arg,
|
|
53
|
-
throw new validatorPrimitives.ValidationError(`${
|
|
52
|
+
tChannelImpl: (names, arg, path2) => {
|
|
53
|
+
throw new validatorPrimitives.ValidationError(`${path2}: channels are not expected in launchServer`);
|
|
54
54
|
},
|
|
55
55
|
binary: "buffer",
|
|
56
56
|
isUnderTest: import_debug.isUnderTest
|
|
@@ -82,11 +82,8 @@ class BrowserServerLauncherImpl {
|
|
|
82
82
|
(0, import_stackTrace.rewriteErrorMessage)(e, `${e.message} Failed to launch browser.${log}`);
|
|
83
83
|
throw e;
|
|
84
84
|
}
|
|
85
|
-
return this.launchServerOnExistingBrowser(browser, options);
|
|
86
|
-
}
|
|
87
|
-
async launchServerOnExistingBrowser(browser, options) {
|
|
88
85
|
const path = options.wsPath ? options.wsPath.startsWith("/") ? options.wsPath : `/${options.wsPath}` : `/${(0, import_crypto.createGuid)()}`;
|
|
89
|
-
const server = new import_playwrightServer.PlaywrightServer({ mode: options._sharedBrowser ? "launchServerShared" : "launchServer", path, maxConnections: Infinity, preLaunchedBrowser: browser
|
|
86
|
+
const server = new import_playwrightServer.PlaywrightServer({ mode: options._sharedBrowser ? "launchServerShared" : "launchServer", path, maxConnections: Infinity, preLaunchedBrowser: browser });
|
|
90
87
|
const wsEndpoint = await server.listen(options.port, options.host);
|
|
91
88
|
const browserServer = new import_utilsBundle.ws.EventEmitter();
|
|
92
89
|
browserServer.process = () => browser.options.browserProcess.process;
|
package/lib/client/browser.js
CHANGED
|
@@ -120,16 +120,6 @@ class Browser extends import_channelOwner.ChannelOwner {
|
|
|
120
120
|
async newBrowserCDPSession() {
|
|
121
121
|
return import_cdpSession.CDPSession.from((await this._channel.newBrowserCDPSession()).session);
|
|
122
122
|
}
|
|
123
|
-
async _launchServer(options = {}) {
|
|
124
|
-
const serverLauncher = this._browserType._serverLauncher;
|
|
125
|
-
const browserImpl = this._connection.toImpl?.(this);
|
|
126
|
-
if (!serverLauncher || !browserImpl)
|
|
127
|
-
throw new Error("Launching server is not supported");
|
|
128
|
-
return await serverLauncher.launchServerOnExistingBrowser(browserImpl, {
|
|
129
|
-
_sharedBrowser: true,
|
|
130
|
-
...options
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
123
|
async startTracing(page, options = {}) {
|
|
134
124
|
this._path = options.path;
|
|
135
125
|
await this._channel.startTracing({ ...options, page: page ? page._channel : void 0 });
|
|
@@ -67,7 +67,6 @@ class BrowserContext extends import_channelOwner.ChannelOwner {
|
|
|
67
67
|
this._browser = null;
|
|
68
68
|
this._bindings = /* @__PURE__ */ new Map();
|
|
69
69
|
this._forReuse = false;
|
|
70
|
-
this._backgroundPages = /* @__PURE__ */ new Set();
|
|
71
70
|
this._serviceWorkers = /* @__PURE__ */ new Set();
|
|
72
71
|
this._harRecorders = /* @__PURE__ */ new Map();
|
|
73
72
|
this._closingStatus = "none";
|
|
@@ -83,11 +82,6 @@ class BrowserContext extends import_channelOwner.ChannelOwner {
|
|
|
83
82
|
this._channel.on("page", ({ page }) => this._onPage(import_page.Page.from(page)));
|
|
84
83
|
this._channel.on("route", ({ route }) => this._onRoute(network.Route.from(route)));
|
|
85
84
|
this._channel.on("webSocketRoute", ({ webSocketRoute }) => this._onWebSocketRoute(network.WebSocketRoute.from(webSocketRoute)));
|
|
86
|
-
this._channel.on("backgroundPage", ({ page }) => {
|
|
87
|
-
const backgroundPage = import_page.Page.from(page);
|
|
88
|
-
this._backgroundPages.add(backgroundPage);
|
|
89
|
-
this.emit(import_events.Events.BrowserContext.BackgroundPage, backgroundPage);
|
|
90
|
-
});
|
|
91
85
|
this._channel.on("serviceWorker", ({ worker }) => {
|
|
92
86
|
const serviceWorker = import_worker.Worker.from(worker);
|
|
93
87
|
serviceWorker._context = this;
|
|
@@ -95,7 +89,7 @@ class BrowserContext extends import_channelOwner.ChannelOwner {
|
|
|
95
89
|
this.emit(import_events.Events.BrowserContext.ServiceWorker, serviceWorker);
|
|
96
90
|
});
|
|
97
91
|
this._channel.on("console", (event) => {
|
|
98
|
-
const consoleMessage = new import_consoleMessage.ConsoleMessage(this._platform, event);
|
|
92
|
+
const consoleMessage = new import_consoleMessage.ConsoleMessage(this._platform, event, import_page.Page.fromNullable(event.page));
|
|
99
93
|
this.emit(import_events.Events.BrowserContext.Console, consoleMessage);
|
|
100
94
|
const page = consoleMessage.page();
|
|
101
95
|
if (page)
|
|
@@ -402,7 +396,7 @@ class BrowserContext extends import_channelOwner.ChannelOwner {
|
|
|
402
396
|
return state;
|
|
403
397
|
}
|
|
404
398
|
backgroundPages() {
|
|
405
|
-
return [
|
|
399
|
+
return [];
|
|
406
400
|
}
|
|
407
401
|
serviceWorkers() {
|
|
408
402
|
return [...this._serviceWorkers];
|
|
@@ -164,14 +164,7 @@ class ChannelOwner extends import_eventEmitter.EventEmitter {
|
|
|
164
164
|
else
|
|
165
165
|
e.stack = "";
|
|
166
166
|
if (!options?.internal) {
|
|
167
|
-
const recoveryHandlers = [];
|
|
168
167
|
apiZone.error = e;
|
|
169
|
-
this._instrumentation.onApiCallRecovery(apiZone, e, recoveryHandlers);
|
|
170
|
-
for (const handler of recoveryHandlers) {
|
|
171
|
-
const recoverResult = await handler();
|
|
172
|
-
if (recoverResult.status === "recovered")
|
|
173
|
-
return recoverResult.value;
|
|
174
|
-
}
|
|
175
168
|
logApiCall(this._platform, logger, `<= ${apiZone.apiName} failed`);
|
|
176
169
|
this._instrumentation.onApiCallEnd(apiZone);
|
|
177
170
|
}
|
|
@@ -22,10 +22,9 @@ __export(consoleMessage_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(consoleMessage_exports);
|
|
24
24
|
var import_jsHandle = require("./jsHandle");
|
|
25
|
-
var import_page = require("./page");
|
|
26
25
|
class ConsoleMessage {
|
|
27
|
-
constructor(platform, event) {
|
|
28
|
-
this._page =
|
|
26
|
+
constructor(platform, event, page) {
|
|
27
|
+
this._page = page;
|
|
29
28
|
this._event = event;
|
|
30
29
|
if (platform.inspectCustom)
|
|
31
30
|
this[platform.inspectCustom] = () => this._inspect();
|
package/lib/client/electron.js
CHANGED
|
@@ -66,7 +66,7 @@ class ElectronApplication extends import_channelOwner.ChannelOwner {
|
|
|
66
66
|
this._channel.on("close", () => {
|
|
67
67
|
this.emit(import_events.Events.ElectronApplication.Close);
|
|
68
68
|
});
|
|
69
|
-
this._channel.on("console", (event) => this.emit(import_events.Events.ElectronApplication.Console, new import_consoleMessage.ConsoleMessage(this._platform, event)));
|
|
69
|
+
this._channel.on("console", (event) => this.emit(import_events.Events.ElectronApplication.Console, new import_consoleMessage.ConsoleMessage(this._platform, event, null)));
|
|
70
70
|
this._setEventToSubscriptionMapping(/* @__PURE__ */ new Map([
|
|
71
71
|
[import_events.Events.ElectronApplication.Console, "console"]
|
|
72
72
|
]));
|
package/lib/client/events.js
CHANGED
|
@@ -45,6 +45,7 @@ const Events = {
|
|
|
45
45
|
// @see https://nodejs.org/api/events.html#events_error_events
|
|
46
46
|
WebError: "weberror",
|
|
47
47
|
BackgroundPage: "backgroundpage",
|
|
48
|
+
// Deprecated in v1.56, never emitted anymore.
|
|
48
49
|
ServiceWorker: "serviceworker",
|
|
49
50
|
Request: "request",
|
|
50
51
|
Response: "response",
|
package/lib/client/network.js
CHANGED
|
@@ -51,6 +51,7 @@ class Request extends import_channelOwner.ChannelOwner {
|
|
|
51
51
|
this._redirectedTo = null;
|
|
52
52
|
this._failureText = null;
|
|
53
53
|
this._fallbackOverrides = {};
|
|
54
|
+
this._hasResponse = false;
|
|
54
55
|
this._redirectedFrom = Request.fromNullable(initializer.redirectedFrom);
|
|
55
56
|
if (this._redirectedFrom)
|
|
56
57
|
this._redirectedFrom._redirectedTo = this;
|
|
@@ -66,6 +67,8 @@ class Request extends import_channelOwner.ChannelOwner {
|
|
|
66
67
|
responseStart: -1,
|
|
67
68
|
responseEnd: -1
|
|
68
69
|
};
|
|
70
|
+
this._hasResponse = this._initializer.hasResponse;
|
|
71
|
+
this._channel.on("response", () => this._hasResponse = true);
|
|
69
72
|
}
|
|
70
73
|
static from(request) {
|
|
71
74
|
return request._object;
|
package/lib/client/page.js
CHANGED
|
@@ -48,6 +48,7 @@ var import_stringUtils = require("../utils/isomorphic/stringUtils");
|
|
|
48
48
|
var import_urlMatch = require("../utils/isomorphic/urlMatch");
|
|
49
49
|
var import_manualPromise = require("../utils/isomorphic/manualPromise");
|
|
50
50
|
var import_rtti = require("../utils/isomorphic/rtti");
|
|
51
|
+
var import_consoleMessage = require("./consoleMessage");
|
|
51
52
|
class Page extends import_channelOwner.ChannelOwner {
|
|
52
53
|
constructor(parent, type, guid, initializer) {
|
|
53
54
|
super(parent, type, guid, initializer);
|
|
@@ -174,7 +175,6 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
174
175
|
_onClose() {
|
|
175
176
|
this._closed = true;
|
|
176
177
|
this._browserContext._pages.delete(this);
|
|
177
|
-
this._browserContext._backgroundPages.delete(this);
|
|
178
178
|
this._disposeHarRouters();
|
|
179
179
|
this.emit(import_events.Events.Page.Close, this);
|
|
180
180
|
}
|
|
@@ -534,6 +534,14 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
534
534
|
async fill(selector, value, options) {
|
|
535
535
|
return await this._mainFrame.fill(selector, value, options);
|
|
536
536
|
}
|
|
537
|
+
async consoleMessages() {
|
|
538
|
+
const { messages } = await this._channel.consoleMessages();
|
|
539
|
+
return messages.map((message) => new import_consoleMessage.ConsoleMessage(this._platform, message, this));
|
|
540
|
+
}
|
|
541
|
+
async pageErrors() {
|
|
542
|
+
const { errors } = await this._channel.pageErrors();
|
|
543
|
+
return errors.map((error) => (0, import_errors.parseError)(error));
|
|
544
|
+
}
|
|
537
545
|
locator(selector, options) {
|
|
538
546
|
return this.mainFrame().locator(selector, options);
|
|
539
547
|
}
|
|
@@ -627,6 +635,10 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
627
635
|
async waitForFunction(pageFunction, arg, options) {
|
|
628
636
|
return await this._mainFrame.waitForFunction(pageFunction, arg, options);
|
|
629
637
|
}
|
|
638
|
+
async requests() {
|
|
639
|
+
const { requests } = await this._channel.requests();
|
|
640
|
+
return requests.map((request) => import_network.Request.from(request));
|
|
641
|
+
}
|
|
630
642
|
workers() {
|
|
631
643
|
return [...this._workers];
|
|
632
644
|
}
|
|
@@ -21,7 +21,7 @@ __export(bindingsControllerSource_exports, {
|
|
|
21
21
|
source: () => source
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(bindingsControllerSource_exports);
|
|
24
|
-
const source = '\nvar __commonJS = obj => {\n let required = false;\n let result;\n return function __require() {\n if (!required) {\n required = true;\n let fn;\n for (const name in obj) { fn = obj[name]; break; }\n const module = { exports: {} };\n fn(module.exports, module);\n result = module.exports;\n }\n return result;\n }\n};\nvar __export = (target, all) => {for (var name in all) target[name] = all[name];};\nvar __toESM = mod => ({ ...mod, \'default\': mod });\nvar __toCommonJS = mod => ({ ...mod, __esModule: true });\n\n\n// packages/injected/src/bindingsController.ts\nvar bindingsController_exports = {};\n__export(bindingsController_exports, {\n BindingsController: () => BindingsController\n});\nmodule.exports = __toCommonJS(bindingsController_exports);\n\n// packages/playwright-core/src/utils/isomorphic/utilityScriptSerializers.ts\nfunction isRegExp(obj) {\n try {\n return obj instanceof RegExp || Object.prototype.toString.call(obj) === "[object RegExp]";\n } catch (error) {\n return false;\n }\n}\nfunction isDate(obj) {\n try {\n return obj instanceof Date || Object.prototype.toString.call(obj) === "[object Date]";\n } catch (error) {\n return false;\n }\n}\nfunction isURL(obj) {\n try {\n return obj instanceof URL || Object.prototype.toString.call(obj) === "[object URL]";\n } catch (error) {\n return false;\n }\n}\nfunction isError(obj) {\n var _a;\n try {\n return obj instanceof Error || obj && ((_a = Object.getPrototypeOf(obj)) == null ? void 0 : _a.name) === "Error";\n } catch (error) {\n return false;\n }\n}\nfunction isTypedArray(obj, constructor) {\n try {\n return obj instanceof constructor || Object.prototype.toString.call(obj) === `[object ${constructor.name}]`;\n } catch (error) {\n return false;\n }\n}\nvar typedArrayConstructors = {\n i8: Int8Array,\n ui8: Uint8Array,\n ui8c: Uint8ClampedArray,\n i16: Int16Array,\n ui16: Uint16Array,\n i32: Int32Array,\n ui32: Uint32Array,\n // TODO: add Float16Array once it\'s in baseline\n f32: Float32Array,\n f64: Float64Array,\n bi64: BigInt64Array,\n bui64: BigUint64Array\n};\nfunction typedArrayToBase64(array) {\n if ("toBase64" in array)\n return array.toBase64();\n const binary = Array.from(new Uint8Array(array.buffer, array.byteOffset, array.byteLength)).map((b) => String.fromCharCode(b)).join("");\n return btoa(binary);\n}\nfunction serializeAsCallArgument(value, handleSerializer) {\n return serialize(value, handleSerializer, { visited: /* @__PURE__ */ new Map(), lastId: 0 });\n}\nfunction serialize(value, handleSerializer, visitorInfo) {\n if (value && typeof value === "object") {\n if (typeof globalThis.Window === "function" && value instanceof globalThis.Window)\n return "ref: <Window>";\n if (typeof globalThis.Document === "function" && value instanceof globalThis.Document)\n return "ref: <Document>";\n if (typeof globalThis.Node === "function" && value instanceof globalThis.Node)\n return "ref: <Node>";\n }\n return innerSerialize(value, handleSerializer, visitorInfo);\n}\nfunction innerSerialize(value, handleSerializer, visitorInfo) {\n var _a;\n const result = handleSerializer(value);\n if ("fallThrough" in result)\n value = result.fallThrough;\n else\n return result;\n if (typeof value === "symbol")\n return { v: "undefined" };\n if (Object.is(value, void 0))\n return { v: "undefined" };\n if (Object.is(value, null))\n return { v: "null" };\n if (Object.is(value, NaN))\n return { v: "NaN" };\n if (Object.is(value, Infinity))\n return { v: "Infinity" };\n if (Object.is(value, -Infinity))\n return { v: "-Infinity" };\n if (Object.is(value, -0))\n return { v: "-0" };\n if (typeof value === "boolean")\n return value;\n if (typeof value === "number")\n return value;\n if (typeof value === "string")\n return value;\n if (typeof value === "bigint")\n return { bi: value.toString() };\n if (isError(value)) {\n let stack;\n if ((_a = value.stack) == null ? void 0 : _a.startsWith(value.name + ": " + value.message)) {\n stack = value.stack;\n } else {\n stack = `${value.name}: ${value.message}\n${value.stack}`;\n }\n return { e: { n: value.name, m: value.message, s: stack } };\n }\n if (isDate(value))\n return { d: value.toJSON() };\n if (isURL(value))\n return { u: value.toJSON() };\n if (isRegExp(value))\n return { r: { p: value.source, f: value.flags } };\n for (const [k, ctor] of Object.entries(typedArrayConstructors)) {\n if (isTypedArray(value, ctor))\n return { ta: { b: typedArrayToBase64(value), k } };\n }\n const id = visitorInfo.visited.get(value);\n if (id)\n return { ref: id };\n if (Array.isArray(value)) {\n const a = [];\n const id2 = ++visitorInfo.lastId;\n visitorInfo.visited.set(value, id2);\n for (let i = 0; i < value.length; ++i)\n a.push(serialize(value[i], handleSerializer, visitorInfo));\n return { a, id: id2 };\n }\n if (typeof value === "object") {\n const o = [];\n const id2 = ++visitorInfo.lastId;\n visitorInfo.visited.set(value, id2);\n for (const name of Object.keys(value)) {\n let item;\n try {\n item = value[name];\n } catch (e) {\n continue;\n }\n if (name === "toJSON" && typeof item === "function")\n o.push({ k: name, v: { o: [], id: 0 } });\n else\n o.push({ k: name, v: serialize(item, handleSerializer, visitorInfo) });\n }\n let jsonWrapper;\n try {\n if (o.length === 0 && value.toJSON && typeof value.toJSON === "function")\n jsonWrapper = { value: value.toJSON() };\n } catch (e) {\n }\n if (jsonWrapper)\n return innerSerialize(jsonWrapper.value, handleSerializer, visitorInfo);\n return { o, id: id2 };\n }\n}\n\n// packages/injected/src/bindingsController.ts\nvar BindingsController = class {\n
|
|
24
|
+
const source = '\nvar __commonJS = obj => {\n let required = false;\n let result;\n return function __require() {\n if (!required) {\n required = true;\n let fn;\n for (const name in obj) { fn = obj[name]; break; }\n const module = { exports: {} };\n fn(module.exports, module);\n result = module.exports;\n }\n return result;\n }\n};\nvar __export = (target, all) => {for (var name in all) target[name] = all[name];};\nvar __toESM = mod => ({ ...mod, \'default\': mod });\nvar __toCommonJS = mod => ({ ...mod, __esModule: true });\n\n\n// packages/injected/src/bindingsController.ts\nvar bindingsController_exports = {};\n__export(bindingsController_exports, {\n BindingsController: () => BindingsController\n});\nmodule.exports = __toCommonJS(bindingsController_exports);\n\n// packages/playwright-core/src/utils/isomorphic/utilityScriptSerializers.ts\nfunction isRegExp(obj) {\n try {\n return obj instanceof RegExp || Object.prototype.toString.call(obj) === "[object RegExp]";\n } catch (error) {\n return false;\n }\n}\nfunction isDate(obj) {\n try {\n return obj instanceof Date || Object.prototype.toString.call(obj) === "[object Date]";\n } catch (error) {\n return false;\n }\n}\nfunction isURL(obj) {\n try {\n return obj instanceof URL || Object.prototype.toString.call(obj) === "[object URL]";\n } catch (error) {\n return false;\n }\n}\nfunction isError(obj) {\n var _a;\n try {\n return obj instanceof Error || obj && ((_a = Object.getPrototypeOf(obj)) == null ? void 0 : _a.name) === "Error";\n } catch (error) {\n return false;\n }\n}\nfunction isTypedArray(obj, constructor) {\n try {\n return obj instanceof constructor || Object.prototype.toString.call(obj) === `[object ${constructor.name}]`;\n } catch (error) {\n return false;\n }\n}\nvar typedArrayConstructors = {\n i8: Int8Array,\n ui8: Uint8Array,\n ui8c: Uint8ClampedArray,\n i16: Int16Array,\n ui16: Uint16Array,\n i32: Int32Array,\n ui32: Uint32Array,\n // TODO: add Float16Array once it\'s in baseline\n f32: Float32Array,\n f64: Float64Array,\n bi64: BigInt64Array,\n bui64: BigUint64Array\n};\nfunction typedArrayToBase64(array) {\n if ("toBase64" in array)\n return array.toBase64();\n const binary = Array.from(new Uint8Array(array.buffer, array.byteOffset, array.byteLength)).map((b) => String.fromCharCode(b)).join("");\n return btoa(binary);\n}\nfunction serializeAsCallArgument(value, handleSerializer) {\n return serialize(value, handleSerializer, { visited: /* @__PURE__ */ new Map(), lastId: 0 });\n}\nfunction serialize(value, handleSerializer, visitorInfo) {\n if (value && typeof value === "object") {\n if (typeof globalThis.Window === "function" && value instanceof globalThis.Window)\n return "ref: <Window>";\n if (typeof globalThis.Document === "function" && value instanceof globalThis.Document)\n return "ref: <Document>";\n if (typeof globalThis.Node === "function" && value instanceof globalThis.Node)\n return "ref: <Node>";\n }\n return innerSerialize(value, handleSerializer, visitorInfo);\n}\nfunction innerSerialize(value, handleSerializer, visitorInfo) {\n var _a;\n const result = handleSerializer(value);\n if ("fallThrough" in result)\n value = result.fallThrough;\n else\n return result;\n if (typeof value === "symbol")\n return { v: "undefined" };\n if (Object.is(value, void 0))\n return { v: "undefined" };\n if (Object.is(value, null))\n return { v: "null" };\n if (Object.is(value, NaN))\n return { v: "NaN" };\n if (Object.is(value, Infinity))\n return { v: "Infinity" };\n if (Object.is(value, -Infinity))\n return { v: "-Infinity" };\n if (Object.is(value, -0))\n return { v: "-0" };\n if (typeof value === "boolean")\n return value;\n if (typeof value === "number")\n return value;\n if (typeof value === "string")\n return value;\n if (typeof value === "bigint")\n return { bi: value.toString() };\n if (isError(value)) {\n let stack;\n if ((_a = value.stack) == null ? void 0 : _a.startsWith(value.name + ": " + value.message)) {\n stack = value.stack;\n } else {\n stack = `${value.name}: ${value.message}\n${value.stack}`;\n }\n return { e: { n: value.name, m: value.message, s: stack } };\n }\n if (isDate(value))\n return { d: value.toJSON() };\n if (isURL(value))\n return { u: value.toJSON() };\n if (isRegExp(value))\n return { r: { p: value.source, f: value.flags } };\n for (const [k, ctor] of Object.entries(typedArrayConstructors)) {\n if (isTypedArray(value, ctor))\n return { ta: { b: typedArrayToBase64(value), k } };\n }\n const id = visitorInfo.visited.get(value);\n if (id)\n return { ref: id };\n if (Array.isArray(value)) {\n const a = [];\n const id2 = ++visitorInfo.lastId;\n visitorInfo.visited.set(value, id2);\n for (let i = 0; i < value.length; ++i)\n a.push(serialize(value[i], handleSerializer, visitorInfo));\n return { a, id: id2 };\n }\n if (typeof value === "object") {\n const o = [];\n const id2 = ++visitorInfo.lastId;\n visitorInfo.visited.set(value, id2);\n for (const name of Object.keys(value)) {\n let item;\n try {\n item = value[name];\n } catch (e) {\n continue;\n }\n if (name === "toJSON" && typeof item === "function")\n o.push({ k: name, v: { o: [], id: 0 } });\n else\n o.push({ k: name, v: serialize(item, handleSerializer, visitorInfo) });\n }\n let jsonWrapper;\n try {\n if (o.length === 0 && value.toJSON && typeof value.toJSON === "function")\n jsonWrapper = { value: value.toJSON() };\n } catch (e) {\n }\n if (jsonWrapper)\n return innerSerialize(jsonWrapper.value, handleSerializer, visitorInfo);\n return { o, id: id2 };\n }\n}\n\n// packages/injected/src/bindingsController.ts\nvar BindingsController = class {\n constructor(global, globalBindingName) {\n this._bindings = /* @__PURE__ */ new Map();\n this._global = global;\n this._globalBindingName = globalBindingName;\n }\n addBinding(bindingName, needsHandle) {\n const data = {\n callbacks: /* @__PURE__ */ new Map(),\n lastSeq: 0,\n handles: /* @__PURE__ */ new Map(),\n removed: false\n };\n this._bindings.set(bindingName, data);\n this._global[bindingName] = (...args) => {\n if (data.removed)\n throw new Error(`binding "${bindingName}" has been removed`);\n if (needsHandle && args.slice(1).some((arg) => arg !== void 0))\n throw new Error(`exposeBindingHandle supports a single argument, ${args.length} received`);\n const seq = ++data.lastSeq;\n const promise = new Promise((resolve, reject) => data.callbacks.set(seq, { resolve, reject }));\n let payload;\n if (needsHandle) {\n data.handles.set(seq, args[0]);\n payload = { name: bindingName, seq };\n } else {\n const serializedArgs = [];\n for (let i = 0; i < args.length; i++) {\n serializedArgs[i] = serializeAsCallArgument(args[i], (v) => {\n return { fallThrough: v };\n });\n }\n payload = { name: bindingName, seq, serializedArgs };\n }\n this._global[this._globalBindingName](JSON.stringify(payload));\n return promise;\n };\n }\n removeBinding(bindingName) {\n const data = this._bindings.get(bindingName);\n if (data)\n data.removed = true;\n this._bindings.delete(bindingName);\n delete this._global[bindingName];\n }\n takeBindingHandle(arg) {\n const handles = this._bindings.get(arg.name).handles;\n const handle = handles.get(arg.seq);\n handles.delete(arg.seq);\n return handle;\n }\n deliverBindingResult(arg) {\n const callbacks = this._bindings.get(arg.name).callbacks;\n if ("error" in arg)\n callbacks.get(arg.seq).reject(arg.error);\n else\n callbacks.get(arg.seq).resolve(arg.result);\n callbacks.delete(arg.seq);\n }\n};\n';
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
27
|
source
|