First Commit
This commit is contained in:
308
node_modules/playwright-core/lib/server/dispatchers/androidDispatcher.js
generated
vendored
Normal file
308
node_modules/playwright-core/lib/server/dispatchers/androidDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,308 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var androidDispatcher_exports = {};
|
||||
__export(androidDispatcher_exports, {
|
||||
AndroidDeviceDispatcher: () => AndroidDeviceDispatcher,
|
||||
AndroidDispatcher: () => AndroidDispatcher,
|
||||
AndroidSocketDispatcher: () => AndroidSocketDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(androidDispatcher_exports);
|
||||
var import_browserContextDispatcher = require("./browserContextDispatcher");
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_android = require("../android/android");
|
||||
var import_eventsHelper = require("../utils/eventsHelper");
|
||||
var import_instrumentation = require("../instrumentation");
|
||||
class AndroidDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, android) {
|
||||
super(scope, android, "Android", {});
|
||||
this._type_Android = true;
|
||||
}
|
||||
async devices(params, progress) {
|
||||
const devices = await this._object.devices(progress, params);
|
||||
return {
|
||||
devices: devices.map((d) => AndroidDeviceDispatcher.from(this, d))
|
||||
};
|
||||
}
|
||||
}
|
||||
class AndroidDeviceDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, device) {
|
||||
super(scope, device, "AndroidDevice", {
|
||||
model: device.model,
|
||||
serial: device.serial
|
||||
});
|
||||
this._type_EventTarget = true;
|
||||
this._type_AndroidDevice = true;
|
||||
for (const webView of device.webViews())
|
||||
this._dispatchEvent("webViewAdded", { webView });
|
||||
this.addObjectListener(import_android.AndroidDevice.Events.WebViewAdded, (webView) => this._dispatchEvent("webViewAdded", { webView }));
|
||||
this.addObjectListener(import_android.AndroidDevice.Events.WebViewRemoved, (socketName) => this._dispatchEvent("webViewRemoved", { socketName }));
|
||||
this.addObjectListener(import_android.AndroidDevice.Events.Close, () => this._dispatchEvent("close"));
|
||||
}
|
||||
static from(scope, device) {
|
||||
const result = scope.connection.existingDispatcher(device);
|
||||
return result || new AndroidDeviceDispatcher(scope, device);
|
||||
}
|
||||
async wait(params, progress) {
|
||||
await progress.race(this._object.send("wait", params));
|
||||
}
|
||||
async fill(params, progress) {
|
||||
await progress.race(this._object.send("click", { selector: params.androidSelector }));
|
||||
await progress.race(this._object.send("fill", params));
|
||||
}
|
||||
async tap(params, progress) {
|
||||
await progress.race(this._object.send("click", params));
|
||||
}
|
||||
async drag(params, progress) {
|
||||
await progress.race(this._object.send("drag", params));
|
||||
}
|
||||
async fling(params, progress) {
|
||||
await progress.race(this._object.send("fling", params));
|
||||
}
|
||||
async longTap(params, progress) {
|
||||
await progress.race(this._object.send("longClick", params));
|
||||
}
|
||||
async pinchClose(params, progress) {
|
||||
await progress.race(this._object.send("pinchClose", params));
|
||||
}
|
||||
async pinchOpen(params, progress) {
|
||||
await progress.race(this._object.send("pinchOpen", params));
|
||||
}
|
||||
async scroll(params, progress) {
|
||||
await progress.race(this._object.send("scroll", params));
|
||||
}
|
||||
async swipe(params, progress) {
|
||||
await progress.race(this._object.send("swipe", params));
|
||||
}
|
||||
async info(params, progress) {
|
||||
const info = await progress.race(this._object.send("info", params));
|
||||
fixupAndroidElementInfo(info);
|
||||
return { info };
|
||||
}
|
||||
async inputType(params, progress) {
|
||||
const text = params.text;
|
||||
const keyCodes = [];
|
||||
for (let i = 0; i < text.length; ++i) {
|
||||
const code = keyMap.get(text[i].toUpperCase());
|
||||
if (code === void 0)
|
||||
throw new Error("No mapping for " + text[i] + " found");
|
||||
keyCodes.push(code);
|
||||
}
|
||||
await progress.race(Promise.all(keyCodes.map((keyCode) => this._object.send("inputPress", { keyCode }))));
|
||||
}
|
||||
async inputPress(params, progress) {
|
||||
if (!keyMap.has(params.key))
|
||||
throw new Error("Unknown key: " + params.key);
|
||||
await progress.race(this._object.send("inputPress", { keyCode: keyMap.get(params.key) }));
|
||||
}
|
||||
async inputTap(params, progress) {
|
||||
await progress.race(this._object.send("inputClick", params));
|
||||
}
|
||||
async inputSwipe(params, progress) {
|
||||
await progress.race(this._object.send("inputSwipe", params));
|
||||
}
|
||||
async inputDrag(params, progress) {
|
||||
await progress.race(this._object.send("inputDrag", params));
|
||||
}
|
||||
async screenshot(params, progress) {
|
||||
return { binary: await progress.race(this._object.screenshot()) };
|
||||
}
|
||||
async shell(params, progress) {
|
||||
return { result: await progress.race(this._object.shell(params.command)) };
|
||||
}
|
||||
async open(params, progress) {
|
||||
const socket = await this._object.open(progress, params.command);
|
||||
return { socket: new AndroidSocketDispatcher(this, new SocketSdkObject(this._object, socket)) };
|
||||
}
|
||||
async installApk(params, progress) {
|
||||
await this._object.installApk(progress, params.file, { args: params.args });
|
||||
}
|
||||
async push(params, progress) {
|
||||
await progress.race(this._object.push(progress, params.file, params.path, params.mode));
|
||||
}
|
||||
async launchBrowser(params, progress) {
|
||||
const context = await this._object.launchBrowser(progress, params.pkg, params);
|
||||
return { context: import_browserContextDispatcher.BrowserContextDispatcher.from(this, context) };
|
||||
}
|
||||
async close(params, progress) {
|
||||
await this._object.close();
|
||||
}
|
||||
async connectToWebView(params, progress) {
|
||||
return { context: import_browserContextDispatcher.BrowserContextDispatcher.from(this, await this._object.connectToWebView(progress, params.socketName)) };
|
||||
}
|
||||
}
|
||||
class SocketSdkObject extends import_instrumentation.SdkObject {
|
||||
constructor(parent, socket) {
|
||||
super(parent, "socket");
|
||||
this._socket = socket;
|
||||
this._eventListeners = [
|
||||
import_eventsHelper.eventsHelper.addEventListener(socket, "data", (data) => this.emit("data", data)),
|
||||
import_eventsHelper.eventsHelper.addEventListener(socket, "close", () => {
|
||||
import_eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);
|
||||
this.emit("close");
|
||||
})
|
||||
];
|
||||
}
|
||||
async write(data) {
|
||||
await this._socket.write(data);
|
||||
}
|
||||
close() {
|
||||
this._socket.close();
|
||||
}
|
||||
}
|
||||
class AndroidSocketDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, socket) {
|
||||
super(scope, socket, "AndroidSocket", {});
|
||||
this._type_AndroidSocket = true;
|
||||
this.addObjectListener("data", (data) => this._dispatchEvent("data", { data }));
|
||||
this.addObjectListener("close", () => {
|
||||
this._dispatchEvent("close");
|
||||
this._dispose();
|
||||
});
|
||||
}
|
||||
async write(params, progress) {
|
||||
await progress.race(this._object.write(params.data));
|
||||
}
|
||||
async close(params, progress) {
|
||||
this._object.close();
|
||||
}
|
||||
}
|
||||
const keyMap = /* @__PURE__ */ new Map([
|
||||
["Unknown", 0],
|
||||
["SoftLeft", 1],
|
||||
["SoftRight", 2],
|
||||
["Home", 3],
|
||||
["Back", 4],
|
||||
["Call", 5],
|
||||
["EndCall", 6],
|
||||
["0", 7],
|
||||
["1", 8],
|
||||
["2", 9],
|
||||
["3", 10],
|
||||
["4", 11],
|
||||
["5", 12],
|
||||
["6", 13],
|
||||
["7", 14],
|
||||
["8", 15],
|
||||
["9", 16],
|
||||
["Star", 17],
|
||||
["*", 17],
|
||||
["Pound", 18],
|
||||
["#", 18],
|
||||
["DialUp", 19],
|
||||
["DialDown", 20],
|
||||
["DialLeft", 21],
|
||||
["DialRight", 22],
|
||||
["DialCenter", 23],
|
||||
["VolumeUp", 24],
|
||||
["VolumeDown", 25],
|
||||
["Power", 26],
|
||||
["Camera", 27],
|
||||
["Clear", 28],
|
||||
["A", 29],
|
||||
["B", 30],
|
||||
["C", 31],
|
||||
["D", 32],
|
||||
["E", 33],
|
||||
["F", 34],
|
||||
["G", 35],
|
||||
["H", 36],
|
||||
["I", 37],
|
||||
["J", 38],
|
||||
["K", 39],
|
||||
["L", 40],
|
||||
["M", 41],
|
||||
["N", 42],
|
||||
["O", 43],
|
||||
["P", 44],
|
||||
["Q", 45],
|
||||
["R", 46],
|
||||
["S", 47],
|
||||
["T", 48],
|
||||
["U", 49],
|
||||
["V", 50],
|
||||
["W", 51],
|
||||
["X", 52],
|
||||
["Y", 53],
|
||||
["Z", 54],
|
||||
["Comma", 55],
|
||||
[",", 55],
|
||||
["Period", 56],
|
||||
[".", 56],
|
||||
["AltLeft", 57],
|
||||
["AltRight", 58],
|
||||
["ShiftLeft", 59],
|
||||
["ShiftRight", 60],
|
||||
["Tab", 61],
|
||||
[" ", 61],
|
||||
["Space", 62],
|
||||
[" ", 62],
|
||||
["Sym", 63],
|
||||
["Explorer", 64],
|
||||
["Envelop", 65],
|
||||
["Enter", 66],
|
||||
["Del", 67],
|
||||
["Grave", 68],
|
||||
["Minus", 69],
|
||||
["-", 69],
|
||||
["Equals", 70],
|
||||
["=", 70],
|
||||
["LeftBracket", 71],
|
||||
["(", 71],
|
||||
["RightBracket", 72],
|
||||
[")", 72],
|
||||
["Backslash", 73],
|
||||
["\\", 73],
|
||||
["Semicolon", 74],
|
||||
[";", 74],
|
||||
["Apostrophe", 75],
|
||||
["`", 75],
|
||||
["Slash", 76],
|
||||
["/", 76],
|
||||
["At", 77],
|
||||
["@", 77],
|
||||
["Num", 78],
|
||||
["HeadsetHook", 79],
|
||||
["Focus", 80],
|
||||
["Plus", 81],
|
||||
["Menu", 82],
|
||||
["Notification", 83],
|
||||
["Search", 84],
|
||||
["ChannelUp", 166],
|
||||
["ChannelDown", 167],
|
||||
["AppSwitch", 187],
|
||||
["Assist", 219],
|
||||
["Cut", 277],
|
||||
["Copy", 278],
|
||||
["Paste", 279]
|
||||
]);
|
||||
function fixupAndroidElementInfo(info) {
|
||||
info.clazz = info.clazz || "";
|
||||
info.pkg = info.pkg || "";
|
||||
info.res = info.res || "";
|
||||
info.desc = info.desc || "";
|
||||
info.text = info.text || "";
|
||||
for (const child of info.children || [])
|
||||
fixupAndroidElementInfo(child);
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
AndroidDeviceDispatcher,
|
||||
AndroidDispatcher,
|
||||
AndroidSocketDispatcher
|
||||
});
|
118
node_modules/playwright-core/lib/server/dispatchers/artifactDispatcher.js
generated
vendored
Normal file
118
node_modules/playwright-core/lib/server/dispatchers/artifactDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var artifactDispatcher_exports = {};
|
||||
__export(artifactDispatcher_exports, {
|
||||
ArtifactDispatcher: () => ArtifactDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(artifactDispatcher_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_streamDispatcher = require("./streamDispatcher");
|
||||
var import_fileUtils = require("../utils/fileUtils");
|
||||
class ArtifactDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, artifact) {
|
||||
super(scope, artifact, "Artifact", {
|
||||
absolutePath: artifact.localPath()
|
||||
});
|
||||
this._type_Artifact = true;
|
||||
}
|
||||
static from(parentScope, artifact) {
|
||||
return ArtifactDispatcher.fromNullable(parentScope, artifact);
|
||||
}
|
||||
static fromNullable(parentScope, artifact) {
|
||||
if (!artifact)
|
||||
return void 0;
|
||||
const result = parentScope.connection.existingDispatcher(artifact);
|
||||
return result || new ArtifactDispatcher(parentScope, artifact);
|
||||
}
|
||||
async pathAfterFinished(params, progress) {
|
||||
const path = await progress.race(this._object.localPathAfterFinished());
|
||||
return { value: path };
|
||||
}
|
||||
async saveAs(params, progress) {
|
||||
return await progress.race(new Promise((resolve, reject) => {
|
||||
this._object.saveAs(async (localPath, error) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await (0, import_fileUtils.mkdirIfNeeded)(params.path);
|
||||
await import_fs.default.promises.copyFile(localPath, params.path);
|
||||
resolve();
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
async saveAsStream(params, progress) {
|
||||
return await progress.race(new Promise((resolve, reject) => {
|
||||
this._object.saveAs(async (localPath, error) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const readable = import_fs.default.createReadStream(localPath, { highWaterMark: 1024 * 1024 });
|
||||
const stream = new import_streamDispatcher.StreamDispatcher(this, readable);
|
||||
resolve({ stream });
|
||||
await new Promise((resolve2) => {
|
||||
readable.on("close", resolve2);
|
||||
readable.on("end", resolve2);
|
||||
readable.on("error", resolve2);
|
||||
});
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
async stream(params, progress) {
|
||||
const fileName = await progress.race(this._object.localPathAfterFinished());
|
||||
const readable = import_fs.default.createReadStream(fileName, { highWaterMark: 1024 * 1024 });
|
||||
return { stream: new import_streamDispatcher.StreamDispatcher(this, readable) };
|
||||
}
|
||||
async failure(params, progress) {
|
||||
const error = await progress.race(this._object.failureError());
|
||||
return { error: error || void 0 };
|
||||
}
|
||||
async cancel(params, progress) {
|
||||
await progress.race(this._object.cancel());
|
||||
}
|
||||
async delete(params, progress) {
|
||||
progress.metadata.potentiallyClosesScope = true;
|
||||
await progress.race(this._object.delete());
|
||||
this._dispose();
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
ArtifactDispatcher
|
||||
});
|
378
node_modules/playwright-core/lib/server/dispatchers/browserContextDispatcher.js
generated
vendored
Normal file
378
node_modules/playwright-core/lib/server/dispatchers/browserContextDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,378 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var browserContextDispatcher_exports = {};
|
||||
__export(browserContextDispatcher_exports, {
|
||||
BrowserContextDispatcher: () => BrowserContextDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(browserContextDispatcher_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var import_path = __toESM(require("path"));
|
||||
var import_browserContext = require("../browserContext");
|
||||
var import_artifactDispatcher = require("./artifactDispatcher");
|
||||
var import_cdpSessionDispatcher = require("./cdpSessionDispatcher");
|
||||
var import_dialogDispatcher = require("./dialogDispatcher");
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_elementHandlerDispatcher = require("./elementHandlerDispatcher");
|
||||
var import_frameDispatcher = require("./frameDispatcher");
|
||||
var import_jsHandleDispatcher = require("./jsHandleDispatcher");
|
||||
var import_networkDispatchers = require("./networkDispatchers");
|
||||
var import_pageDispatcher = require("./pageDispatcher");
|
||||
var import_crBrowser = require("../chromium/crBrowser");
|
||||
var import_errors = require("../errors");
|
||||
var import_tracingDispatcher = require("./tracingDispatcher");
|
||||
var import_webSocketRouteDispatcher = require("./webSocketRouteDispatcher");
|
||||
var import_writableStreamDispatcher = require("./writableStreamDispatcher");
|
||||
var import_crypto = require("../utils/crypto");
|
||||
var import_urlMatch = require("../../utils/isomorphic/urlMatch");
|
||||
var import_recorder = require("../recorder");
|
||||
var import_recorderApp = require("../recorder/recorderApp");
|
||||
class BrowserContextDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(parentScope, context) {
|
||||
const requestContext = import_networkDispatchers.APIRequestContextDispatcher.from(parentScope, context.fetchRequest);
|
||||
const tracing = import_tracingDispatcher.TracingDispatcher.from(parentScope, context.tracing);
|
||||
super(parentScope, context, "BrowserContext", {
|
||||
isChromium: context._browser.options.isChromium,
|
||||
requestContext,
|
||||
tracing,
|
||||
options: context._options
|
||||
});
|
||||
this._type_EventTarget = true;
|
||||
this._type_BrowserContext = true;
|
||||
this._subscriptions = /* @__PURE__ */ new Set();
|
||||
this._webSocketInterceptionPatterns = [];
|
||||
this._bindings = [];
|
||||
this._initScripts = [];
|
||||
this._clockPaused = false;
|
||||
this._interceptionUrlMatchers = [];
|
||||
this.adopt(requestContext);
|
||||
this.adopt(tracing);
|
||||
this._requestInterceptor = (route, request) => {
|
||||
const matchesSome = this._interceptionUrlMatchers.some((urlMatch) => (0, import_urlMatch.urlMatches)(this._context._options.baseURL, request.url(), urlMatch));
|
||||
const routeDispatcher = this.connection.existingDispatcher(route);
|
||||
if (!matchesSome || routeDispatcher) {
|
||||
route.continue({ isFallback: true }).catch(() => {
|
||||
});
|
||||
return;
|
||||
}
|
||||
this._dispatchEvent("route", { route: new import_networkDispatchers.RouteDispatcher(import_networkDispatchers.RequestDispatcher.from(this, request), route) });
|
||||
};
|
||||
this._context = context;
|
||||
const onVideo = (artifact) => {
|
||||
const artifactDispatcher = import_artifactDispatcher.ArtifactDispatcher.from(parentScope, artifact);
|
||||
this._dispatchEvent("video", { artifact: artifactDispatcher });
|
||||
};
|
||||
this.addObjectListener(import_browserContext.BrowserContext.Events.VideoStarted, onVideo);
|
||||
for (const video of context._browser._idToVideo.values()) {
|
||||
if (video.context === context)
|
||||
onVideo(video.artifact);
|
||||
}
|
||||
for (const page of context.pages())
|
||||
this._dispatchEvent("page", { page: import_pageDispatcher.PageDispatcher.from(this, page) });
|
||||
this.addObjectListener(import_browserContext.BrowserContext.Events.Page, (page) => {
|
||||
this._dispatchEvent("page", { page: import_pageDispatcher.PageDispatcher.from(this, page) });
|
||||
});
|
||||
this.addObjectListener(import_browserContext.BrowserContext.Events.Close, () => {
|
||||
this._dispatchEvent("close");
|
||||
this._dispose();
|
||||
});
|
||||
this.addObjectListener(import_browserContext.BrowserContext.Events.PageError, (error, page) => {
|
||||
this._dispatchEvent("pageError", { error: (0, import_errors.serializeError)(error), page: import_pageDispatcher.PageDispatcher.from(this, page) });
|
||||
});
|
||||
this.addObjectListener(import_browserContext.BrowserContext.Events.Console, (message) => {
|
||||
const page = message.page();
|
||||
if (this._shouldDispatchEvent(page, "console")) {
|
||||
const pageDispatcher = import_pageDispatcher.PageDispatcher.from(this, page);
|
||||
this._dispatchEvent("console", {
|
||||
page: pageDispatcher,
|
||||
type: message.type(),
|
||||
text: message.text(),
|
||||
args: message.args().map((a) => {
|
||||
const elementHandle = a.asElement();
|
||||
if (elementHandle)
|
||||
return import_elementHandlerDispatcher.ElementHandleDispatcher.from(import_frameDispatcher.FrameDispatcher.from(this, elementHandle._frame), elementHandle);
|
||||
return import_jsHandleDispatcher.JSHandleDispatcher.fromJSHandle(pageDispatcher, a);
|
||||
}),
|
||||
location: message.location()
|
||||
});
|
||||
}
|
||||
});
|
||||
this._dialogHandler = (dialog) => {
|
||||
if (!this._shouldDispatchEvent(dialog.page(), "dialog"))
|
||||
return false;
|
||||
this._dispatchEvent("dialog", { dialog: new import_dialogDispatcher.DialogDispatcher(this, dialog) });
|
||||
return true;
|
||||
};
|
||||
context.dialogManager.addDialogHandler(this._dialogHandler);
|
||||
if (context._browser.options.name === "chromium") {
|
||||
for (const page of context.backgroundPages())
|
||||
this._dispatchEvent("backgroundPage", { page: import_pageDispatcher.PageDispatcher.from(this, page) });
|
||||
this.addObjectListener(import_crBrowser.CRBrowserContext.CREvents.BackgroundPage, (page) => this._dispatchEvent("backgroundPage", { page: import_pageDispatcher.PageDispatcher.from(this, page) }));
|
||||
for (const serviceWorker of context.serviceWorkers())
|
||||
this._dispatchEvent("serviceWorker", { worker: new import_pageDispatcher.WorkerDispatcher(this, serviceWorker) });
|
||||
this.addObjectListener(import_crBrowser.CRBrowserContext.CREvents.ServiceWorker, (serviceWorker) => this._dispatchEvent("serviceWorker", { worker: new import_pageDispatcher.WorkerDispatcher(this, serviceWorker) }));
|
||||
}
|
||||
this.addObjectListener(import_browserContext.BrowserContext.Events.Request, (request) => {
|
||||
const redirectFromDispatcher = request.redirectedFrom() && this.connection.existingDispatcher(request.redirectedFrom());
|
||||
if (!redirectFromDispatcher && !this._shouldDispatchNetworkEvent(request, "request") && !request.isNavigationRequest())
|
||||
return;
|
||||
const requestDispatcher = import_networkDispatchers.RequestDispatcher.from(this, request);
|
||||
this._dispatchEvent("request", {
|
||||
request: requestDispatcher,
|
||||
page: import_pageDispatcher.PageDispatcher.fromNullable(this, request.frame()?._page.initializedOrUndefined())
|
||||
});
|
||||
});
|
||||
this.addObjectListener(import_browserContext.BrowserContext.Events.Response, (response) => {
|
||||
const requestDispatcher = this.connection.existingDispatcher(response.request());
|
||||
if (!requestDispatcher && !this._shouldDispatchNetworkEvent(response.request(), "response"))
|
||||
return;
|
||||
this._dispatchEvent("response", {
|
||||
response: import_networkDispatchers.ResponseDispatcher.from(this, response),
|
||||
page: import_pageDispatcher.PageDispatcher.fromNullable(this, response.frame()?._page.initializedOrUndefined())
|
||||
});
|
||||
});
|
||||
this.addObjectListener(import_browserContext.BrowserContext.Events.RequestFailed, (request) => {
|
||||
const requestDispatcher = this.connection.existingDispatcher(request);
|
||||
if (!requestDispatcher && !this._shouldDispatchNetworkEvent(request, "requestFailed"))
|
||||
return;
|
||||
this._dispatchEvent("requestFailed", {
|
||||
request: import_networkDispatchers.RequestDispatcher.from(this, request),
|
||||
failureText: request._failureText || void 0,
|
||||
responseEndTiming: request._responseEndTiming,
|
||||
page: import_pageDispatcher.PageDispatcher.fromNullable(this, request.frame()?._page.initializedOrUndefined())
|
||||
});
|
||||
});
|
||||
this.addObjectListener(import_browserContext.BrowserContext.Events.RequestFinished, ({ request, response }) => {
|
||||
const requestDispatcher = this.connection.existingDispatcher(request);
|
||||
if (!requestDispatcher && !this._shouldDispatchNetworkEvent(request, "requestFinished"))
|
||||
return;
|
||||
this._dispatchEvent("requestFinished", {
|
||||
request: import_networkDispatchers.RequestDispatcher.from(this, request),
|
||||
response: import_networkDispatchers.ResponseDispatcher.fromNullable(this, response),
|
||||
responseEndTiming: request._responseEndTiming,
|
||||
page: import_pageDispatcher.PageDispatcher.fromNullable(this, request.frame()?._page.initializedOrUndefined())
|
||||
});
|
||||
});
|
||||
this.addObjectListener(import_browserContext.BrowserContext.Events.RecorderEvent, ({ event, data, page, code }) => {
|
||||
this._dispatchEvent("recorderEvent", { event, data, code, page: import_pageDispatcher.PageDispatcher.from(this, page) });
|
||||
});
|
||||
}
|
||||
static from(parentScope, context) {
|
||||
const result = parentScope.connection.existingDispatcher(context);
|
||||
return result || new BrowserContextDispatcher(parentScope, context);
|
||||
}
|
||||
_shouldDispatchNetworkEvent(request, event) {
|
||||
return this._shouldDispatchEvent(request.frame()?._page?.initializedOrUndefined(), event);
|
||||
}
|
||||
_shouldDispatchEvent(page, event) {
|
||||
if (this._subscriptions.has(event))
|
||||
return true;
|
||||
const pageDispatcher = page ? this.connection.existingDispatcher(page) : void 0;
|
||||
if (pageDispatcher?._subscriptions.has(event))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
async createTempFiles(params, progress) {
|
||||
const dir = this._context._browser.options.artifactsDir;
|
||||
const tmpDir = import_path.default.join(dir, "upload-" + (0, import_crypto.createGuid)());
|
||||
const tempDirWithRootName = params.rootDirName ? import_path.default.join(tmpDir, import_path.default.basename(params.rootDirName)) : tmpDir;
|
||||
await progress.race(import_fs.default.promises.mkdir(tempDirWithRootName, { recursive: true }));
|
||||
this._context._tempDirs.push(tmpDir);
|
||||
return {
|
||||
rootDir: params.rootDirName ? new import_writableStreamDispatcher.WritableStreamDispatcher(this, tempDirWithRootName) : void 0,
|
||||
writableStreams: await Promise.all(params.items.map(async (item) => {
|
||||
await progress.race(import_fs.default.promises.mkdir(import_path.default.dirname(import_path.default.join(tempDirWithRootName, item.name)), { recursive: true }));
|
||||
const file = import_fs.default.createWriteStream(import_path.default.join(tempDirWithRootName, item.name));
|
||||
return new import_writableStreamDispatcher.WritableStreamDispatcher(this, file, item.lastModifiedMs);
|
||||
}))
|
||||
};
|
||||
}
|
||||
async exposeBinding(params, progress) {
|
||||
const binding = await this._context.exposeBinding(progress, params.name, !!params.needsHandle, (source, ...args) => {
|
||||
if (this._disposed)
|
||||
return;
|
||||
const pageDispatcher = import_pageDispatcher.PageDispatcher.from(this, source.page);
|
||||
const binding2 = new import_pageDispatcher.BindingCallDispatcher(pageDispatcher, params.name, !!params.needsHandle, source, args);
|
||||
this._dispatchEvent("bindingCall", { binding: binding2 });
|
||||
return binding2.promise();
|
||||
});
|
||||
this._bindings.push(binding);
|
||||
}
|
||||
async newPage(params, progress) {
|
||||
return { page: import_pageDispatcher.PageDispatcher.from(this, await this._context.newPage(progress)) };
|
||||
}
|
||||
async cookies(params, progress) {
|
||||
return { cookies: await progress.race(this._context.cookies(params.urls)) };
|
||||
}
|
||||
async addCookies(params, progress) {
|
||||
await this._context.addCookies(params.cookies);
|
||||
}
|
||||
async clearCookies(params, progress) {
|
||||
const nameRe = params.nameRegexSource !== void 0 && params.nameRegexFlags !== void 0 ? new RegExp(params.nameRegexSource, params.nameRegexFlags) : void 0;
|
||||
const domainRe = params.domainRegexSource !== void 0 && params.domainRegexFlags !== void 0 ? new RegExp(params.domainRegexSource, params.domainRegexFlags) : void 0;
|
||||
const pathRe = params.pathRegexSource !== void 0 && params.pathRegexFlags !== void 0 ? new RegExp(params.pathRegexSource, params.pathRegexFlags) : void 0;
|
||||
await this._context.clearCookies({
|
||||
name: nameRe || params.name,
|
||||
domain: domainRe || params.domain,
|
||||
path: pathRe || params.path
|
||||
});
|
||||
}
|
||||
async grantPermissions(params, progress) {
|
||||
await this._context.grantPermissions(params.permissions, params.origin);
|
||||
}
|
||||
async clearPermissions(params, progress) {
|
||||
await this._context.clearPermissions();
|
||||
}
|
||||
async setGeolocation(params, progress) {
|
||||
await this._context.setGeolocation(params.geolocation);
|
||||
}
|
||||
async setExtraHTTPHeaders(params, progress) {
|
||||
await this._context.setExtraHTTPHeaders(progress, params.headers);
|
||||
}
|
||||
async setOffline(params, progress) {
|
||||
await this._context.setOffline(progress, params.offline);
|
||||
}
|
||||
async setHTTPCredentials(params, progress) {
|
||||
await progress.race(this._context.setHTTPCredentials(params.httpCredentials));
|
||||
}
|
||||
async addInitScript(params, progress) {
|
||||
this._initScripts.push(await this._context.addInitScript(progress, params.source));
|
||||
}
|
||||
async setNetworkInterceptionPatterns(params, progress) {
|
||||
const hadMatchers = this._interceptionUrlMatchers.length > 0;
|
||||
if (!params.patterns.length) {
|
||||
if (hadMatchers)
|
||||
await this._context.removeRequestInterceptor(this._requestInterceptor);
|
||||
this._interceptionUrlMatchers = [];
|
||||
} else {
|
||||
this._interceptionUrlMatchers = params.patterns.map((pattern) => pattern.regexSource ? new RegExp(pattern.regexSource, pattern.regexFlags) : pattern.glob);
|
||||
if (!hadMatchers)
|
||||
await this._context.addRequestInterceptor(progress, this._requestInterceptor);
|
||||
}
|
||||
}
|
||||
async setWebSocketInterceptionPatterns(params, progress) {
|
||||
this._webSocketInterceptionPatterns = params.patterns;
|
||||
if (params.patterns.length && !this._routeWebSocketInitScript)
|
||||
this._routeWebSocketInitScript = await import_webSocketRouteDispatcher.WebSocketRouteDispatcher.install(progress, this.connection, this._context);
|
||||
}
|
||||
async storageState(params, progress) {
|
||||
return await progress.race(this._context.storageState(progress, params.indexedDB));
|
||||
}
|
||||
async close(params, progress) {
|
||||
progress.metadata.potentiallyClosesScope = true;
|
||||
await this._context.close(params);
|
||||
}
|
||||
async enableRecorder(params, progress) {
|
||||
await import_recorderApp.RecorderApp.show(this._context, params);
|
||||
}
|
||||
async disableRecorder(params, progress) {
|
||||
const recorder = import_recorder.Recorder.existingForContext(this._context);
|
||||
if (recorder)
|
||||
recorder.setMode("none");
|
||||
}
|
||||
async pause(params, progress) {
|
||||
}
|
||||
async newCDPSession(params, progress) {
|
||||
if (!this._object._browser.options.isChromium)
|
||||
throw new Error(`CDP session is only available in Chromium`);
|
||||
if (!params.page && !params.frame || params.page && params.frame)
|
||||
throw new Error(`CDP session must be initiated with either Page or Frame, not none or both`);
|
||||
const crBrowserContext = this._object;
|
||||
return { session: new import_cdpSessionDispatcher.CDPSessionDispatcher(this, await progress.race(crBrowserContext.newCDPSession((params.page ? params.page : params.frame)._object))) };
|
||||
}
|
||||
async harStart(params, progress) {
|
||||
const harId = this._context.harStart(params.page ? params.page._object : null, params.options);
|
||||
return { harId };
|
||||
}
|
||||
async harExport(params, progress) {
|
||||
const artifact = await progress.race(this._context.harExport(params.harId));
|
||||
if (!artifact)
|
||||
throw new Error("No HAR artifact. Ensure record.harPath is set.");
|
||||
return { artifact: import_artifactDispatcher.ArtifactDispatcher.from(this, artifact) };
|
||||
}
|
||||
async clockFastForward(params, progress) {
|
||||
await this._context.clock.fastForward(progress, params.ticksString ?? params.ticksNumber ?? 0);
|
||||
}
|
||||
async clockInstall(params, progress) {
|
||||
await this._context.clock.install(progress, params.timeString ?? params.timeNumber ?? void 0);
|
||||
}
|
||||
async clockPauseAt(params, progress) {
|
||||
await this._context.clock.pauseAt(progress, params.timeString ?? params.timeNumber ?? 0);
|
||||
this._clockPaused = true;
|
||||
}
|
||||
async clockResume(params, progress) {
|
||||
await this._context.clock.resume(progress);
|
||||
this._clockPaused = false;
|
||||
}
|
||||
async clockRunFor(params, progress) {
|
||||
await this._context.clock.runFor(progress, params.ticksString ?? params.ticksNumber ?? 0);
|
||||
}
|
||||
async clockSetFixedTime(params, progress) {
|
||||
await this._context.clock.setFixedTime(progress, params.timeString ?? params.timeNumber ?? 0);
|
||||
}
|
||||
async clockSetSystemTime(params, progress) {
|
||||
await this._context.clock.setSystemTime(progress, params.timeString ?? params.timeNumber ?? 0);
|
||||
}
|
||||
async updateSubscription(params, progress) {
|
||||
if (params.enabled)
|
||||
this._subscriptions.add(params.event);
|
||||
else
|
||||
this._subscriptions.delete(params.event);
|
||||
}
|
||||
async registerSelectorEngine(params, progress) {
|
||||
this._object.selectors().register(params.selectorEngine);
|
||||
}
|
||||
async setTestIdAttributeName(params, progress) {
|
||||
this._object.selectors().setTestIdAttributeName(params.testIdAttributeName);
|
||||
}
|
||||
_onDispose() {
|
||||
if (this._context.isClosingOrClosed())
|
||||
return;
|
||||
this._context.dialogManager.removeDialogHandler(this._dialogHandler);
|
||||
this._interceptionUrlMatchers = [];
|
||||
this._context.removeRequestInterceptor(this._requestInterceptor).catch(() => {
|
||||
});
|
||||
this._context.removeExposedBindings(this._bindings).catch(() => {
|
||||
});
|
||||
this._bindings = [];
|
||||
this._context.removeInitScripts(this._initScripts).catch(() => {
|
||||
});
|
||||
this._initScripts = [];
|
||||
if (this._routeWebSocketInitScript)
|
||||
import_webSocketRouteDispatcher.WebSocketRouteDispatcher.uninstall(this.connection, this._context, this._routeWebSocketInitScript).catch(() => {
|
||||
});
|
||||
this._routeWebSocketInitScript = void 0;
|
||||
if (this._clockPaused)
|
||||
this._context.clock.resumeNoReply();
|
||||
this._clockPaused = false;
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
BrowserContextDispatcher
|
||||
});
|
118
node_modules/playwright-core/lib/server/dispatchers/browserDispatcher.js
generated
vendored
Normal file
118
node_modules/playwright-core/lib/server/dispatchers/browserDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var browserDispatcher_exports = {};
|
||||
__export(browserDispatcher_exports, {
|
||||
BrowserDispatcher: () => BrowserDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(browserDispatcher_exports);
|
||||
var import_browser = require("../browser");
|
||||
var import_browserContextDispatcher = require("./browserContextDispatcher");
|
||||
var import_cdpSessionDispatcher = require("./cdpSessionDispatcher");
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_browserContext = require("../browserContext");
|
||||
var import_artifactDispatcher = require("./artifactDispatcher");
|
||||
class BrowserDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, browser, options = {}) {
|
||||
super(scope, browser, "Browser", { version: browser.version(), name: browser.options.name });
|
||||
this._type_Browser = true;
|
||||
this._isolatedContexts = /* @__PURE__ */ new Set();
|
||||
this._options = options;
|
||||
if (!options.isolateContexts) {
|
||||
this.addObjectListener(import_browser.Browser.Events.Context, (context) => this._dispatchEvent("context", { context: import_browserContextDispatcher.BrowserContextDispatcher.from(this, context) }));
|
||||
this.addObjectListener(import_browser.Browser.Events.Disconnected, () => this._didClose());
|
||||
if (browser._defaultContext)
|
||||
this._dispatchEvent("context", { context: import_browserContextDispatcher.BrowserContextDispatcher.from(this, browser._defaultContext) });
|
||||
for (const context of browser.contexts())
|
||||
this._dispatchEvent("context", { context: import_browserContextDispatcher.BrowserContextDispatcher.from(this, context) });
|
||||
}
|
||||
}
|
||||
_didClose() {
|
||||
this._dispatchEvent("close");
|
||||
this._dispose();
|
||||
}
|
||||
async newContext(params, progress) {
|
||||
if (params.recordVideo && this._object.attribution.playwright.options.isServer)
|
||||
params.recordVideo.dir = this._object.options.artifactsDir;
|
||||
if (!this._options.isolateContexts) {
|
||||
const context2 = await this._object.newContext(progress, params);
|
||||
const contextDispatcher2 = import_browserContextDispatcher.BrowserContextDispatcher.from(this, context2);
|
||||
return { context: contextDispatcher2 };
|
||||
}
|
||||
const context = await this._object.newContext(progress, params);
|
||||
this._isolatedContexts.add(context);
|
||||
context.on(import_browserContext.BrowserContext.Events.Close, () => this._isolatedContexts.delete(context));
|
||||
const contextDispatcher = import_browserContextDispatcher.BrowserContextDispatcher.from(this, context);
|
||||
this._dispatchEvent("context", { context: contextDispatcher });
|
||||
return { context: contextDispatcher };
|
||||
}
|
||||
async newContextForReuse(params, progress) {
|
||||
const context = await this._object.newContextForReuse(progress, params);
|
||||
const contextDispatcher = import_browserContextDispatcher.BrowserContextDispatcher.from(this, context);
|
||||
this._dispatchEvent("context", { context: contextDispatcher });
|
||||
return { context: contextDispatcher };
|
||||
}
|
||||
async disconnectFromReusedContext(params, progress) {
|
||||
const context = this._object.contextForReuse();
|
||||
const contextDispatcher = context ? this.connection.existingDispatcher(context) : void 0;
|
||||
if (contextDispatcher) {
|
||||
await contextDispatcher.stopPendingOperations(new Error(params.reason));
|
||||
contextDispatcher._dispose();
|
||||
}
|
||||
}
|
||||
async close(params, progress) {
|
||||
if (this._options.ignoreStopAndKill)
|
||||
return;
|
||||
progress.metadata.potentiallyClosesScope = true;
|
||||
await this._object.close(params);
|
||||
}
|
||||
async killForTests(params, progress) {
|
||||
if (this._options.ignoreStopAndKill)
|
||||
return;
|
||||
progress.metadata.potentiallyClosesScope = true;
|
||||
await this._object.killForTests();
|
||||
}
|
||||
async defaultUserAgentForTest() {
|
||||
return { userAgent: this._object.userAgent() };
|
||||
}
|
||||
async newBrowserCDPSession(params, progress) {
|
||||
if (!this._object.options.isChromium)
|
||||
throw new Error(`CDP session is only available in Chromium`);
|
||||
const crBrowser = this._object;
|
||||
return { session: new import_cdpSessionDispatcher.CDPSessionDispatcher(this, await crBrowser.newBrowserCDPSession()) };
|
||||
}
|
||||
async startTracing(params, progress) {
|
||||
if (!this._object.options.isChromium)
|
||||
throw new Error(`Tracing is only available in Chromium`);
|
||||
const crBrowser = this._object;
|
||||
await crBrowser.startTracing(params.page ? params.page._object : void 0, params);
|
||||
}
|
||||
async stopTracing(params, progress) {
|
||||
if (!this._object.options.isChromium)
|
||||
throw new Error(`Tracing is only available in Chromium`);
|
||||
const crBrowser = this._object;
|
||||
return { artifact: import_artifactDispatcher.ArtifactDispatcher.from(this, await crBrowser.stopTracing()) };
|
||||
}
|
||||
async cleanupContexts() {
|
||||
await Promise.all(Array.from(this._isolatedContexts).map((context) => context.close({ reason: "Global context cleanup (connection terminated)" })));
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
BrowserDispatcher
|
||||
});
|
64
node_modules/playwright-core/lib/server/dispatchers/browserTypeDispatcher.js
generated
vendored
Normal file
64
node_modules/playwright-core/lib/server/dispatchers/browserTypeDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var browserTypeDispatcher_exports = {};
|
||||
__export(browserTypeDispatcher_exports, {
|
||||
BrowserTypeDispatcher: () => BrowserTypeDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(browserTypeDispatcher_exports);
|
||||
var import_browserContextDispatcher = require("./browserContextDispatcher");
|
||||
var import_browserDispatcher = require("./browserDispatcher");
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
class BrowserTypeDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, browserType, denyLaunch) {
|
||||
super(scope, browserType, "BrowserType", {
|
||||
executablePath: browserType.executablePath(),
|
||||
name: browserType.name()
|
||||
});
|
||||
this._type_BrowserType = true;
|
||||
this._denyLaunch = denyLaunch;
|
||||
}
|
||||
async launch(params, progress) {
|
||||
if (this._denyLaunch)
|
||||
throw new Error(`Launching more browsers is not allowed.`);
|
||||
const browser = await this._object.launch(progress, params);
|
||||
return { browser: new import_browserDispatcher.BrowserDispatcher(this, browser) };
|
||||
}
|
||||
async launchPersistentContext(params, progress) {
|
||||
if (this._denyLaunch)
|
||||
throw new Error(`Launching more browsers is not allowed.`);
|
||||
const browserContext = await this._object.launchPersistentContext(progress, params.userDataDir, params);
|
||||
const browserDispatcher = new import_browserDispatcher.BrowserDispatcher(this, browserContext._browser);
|
||||
const contextDispatcher = import_browserContextDispatcher.BrowserContextDispatcher.from(browserDispatcher, browserContext);
|
||||
return { browser: browserDispatcher, context: contextDispatcher };
|
||||
}
|
||||
async connectOverCDP(params, progress) {
|
||||
if (this._denyLaunch)
|
||||
throw new Error(`Launching more browsers is not allowed.`);
|
||||
const browser = await this._object.connectOverCDP(progress, params.endpointURL, params);
|
||||
const browserDispatcher = new import_browserDispatcher.BrowserDispatcher(this, browser);
|
||||
return {
|
||||
browser: browserDispatcher,
|
||||
defaultContext: browser._defaultContext ? import_browserContextDispatcher.BrowserContextDispatcher.from(browserDispatcher, browser._defaultContext) : void 0
|
||||
};
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
BrowserTypeDispatcher
|
||||
});
|
44
node_modules/playwright-core/lib/server/dispatchers/cdpSessionDispatcher.js
generated
vendored
Normal file
44
node_modules/playwright-core/lib/server/dispatchers/cdpSessionDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var cdpSessionDispatcher_exports = {};
|
||||
__export(cdpSessionDispatcher_exports, {
|
||||
CDPSessionDispatcher: () => CDPSessionDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(cdpSessionDispatcher_exports);
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_crConnection = require("../chromium/crConnection");
|
||||
class CDPSessionDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, cdpSession) {
|
||||
super(scope, cdpSession, "CDPSession", {});
|
||||
this._type_CDPSession = true;
|
||||
this.addObjectListener(import_crConnection.CDPSession.Events.Event, ({ method, params }) => this._dispatchEvent("event", { method, params }));
|
||||
this.addObjectListener(import_crConnection.CDPSession.Events.Closed, () => this._dispose());
|
||||
}
|
||||
async send(params, progress) {
|
||||
return { result: await progress.race(this._object.send(params.method, params.params)) };
|
||||
}
|
||||
async detach(_, progress) {
|
||||
progress.metadata.potentiallyClosesScope = true;
|
||||
await this._object.detach();
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
CDPSessionDispatcher
|
||||
});
|
78
node_modules/playwright-core/lib/server/dispatchers/debugControllerDispatcher.js
generated
vendored
Normal file
78
node_modules/playwright-core/lib/server/dispatchers/debugControllerDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var debugControllerDispatcher_exports = {};
|
||||
__export(debugControllerDispatcher_exports, {
|
||||
DebugControllerDispatcher: () => DebugControllerDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(debugControllerDispatcher_exports);
|
||||
var import_utils = require("../../utils");
|
||||
var import_debugController = require("../debugController");
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
class DebugControllerDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(connection, debugController) {
|
||||
super(connection, debugController, "DebugController", {});
|
||||
this._type_DebugController = true;
|
||||
this._listeners = [
|
||||
import_utils.eventsHelper.addEventListener(this._object, import_debugController.DebugController.Events.StateChanged, (params) => {
|
||||
this._dispatchEvent("stateChanged", params);
|
||||
}),
|
||||
import_utils.eventsHelper.addEventListener(this._object, import_debugController.DebugController.Events.InspectRequested, ({ selector, locator, ariaSnapshot }) => {
|
||||
this._dispatchEvent("inspectRequested", { selector, locator, ariaSnapshot });
|
||||
}),
|
||||
import_utils.eventsHelper.addEventListener(this._object, import_debugController.DebugController.Events.SourceChanged, ({ text, header, footer, actions }) => {
|
||||
this._dispatchEvent("sourceChanged", { text, header, footer, actions });
|
||||
}),
|
||||
import_utils.eventsHelper.addEventListener(this._object, import_debugController.DebugController.Events.Paused, ({ paused }) => {
|
||||
this._dispatchEvent("paused", { paused });
|
||||
}),
|
||||
import_utils.eventsHelper.addEventListener(this._object, import_debugController.DebugController.Events.SetModeRequested, ({ mode }) => {
|
||||
this._dispatchEvent("setModeRequested", { mode });
|
||||
})
|
||||
];
|
||||
}
|
||||
async initialize(params, progress) {
|
||||
this._object.initialize(params.codegenId, params.sdkLanguage);
|
||||
}
|
||||
async setReportStateChanged(params, progress) {
|
||||
this._object.setReportStateChanged(params.enabled);
|
||||
}
|
||||
async setRecorderMode(params, progress) {
|
||||
await this._object.setRecorderMode(progress, params);
|
||||
}
|
||||
async highlight(params, progress) {
|
||||
await this._object.highlight(progress, params);
|
||||
}
|
||||
async hideHighlight(params, progress) {
|
||||
await this._object.hideHighlight(progress);
|
||||
}
|
||||
async resume(params, progress) {
|
||||
await this._object.resume(progress);
|
||||
}
|
||||
async kill(params, progress) {
|
||||
this._object.kill();
|
||||
}
|
||||
_onDispose() {
|
||||
import_utils.eventsHelper.removeEventListeners(this._listeners);
|
||||
this._object.dispose();
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
DebugControllerDispatcher
|
||||
});
|
47
node_modules/playwright-core/lib/server/dispatchers/dialogDispatcher.js
generated
vendored
Normal file
47
node_modules/playwright-core/lib/server/dispatchers/dialogDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var dialogDispatcher_exports = {};
|
||||
__export(dialogDispatcher_exports, {
|
||||
DialogDispatcher: () => DialogDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(dialogDispatcher_exports);
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_pageDispatcher = require("./pageDispatcher");
|
||||
class DialogDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, dialog) {
|
||||
const page = import_pageDispatcher.PageDispatcher.fromNullable(scope, dialog.page().initializedOrUndefined());
|
||||
super(page || scope, dialog, "Dialog", {
|
||||
page,
|
||||
type: dialog.type(),
|
||||
message: dialog.message(),
|
||||
defaultValue: dialog.defaultValue()
|
||||
});
|
||||
this._type_Dialog = true;
|
||||
}
|
||||
async accept(params, progress) {
|
||||
await progress.race(this._object.accept(params.promptText));
|
||||
}
|
||||
async dismiss(params, progress) {
|
||||
await progress.race(this._object.dismiss());
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
DialogDispatcher
|
||||
});
|
371
node_modules/playwright-core/lib/server/dispatchers/dispatcher.js
generated
vendored
Normal file
371
node_modules/playwright-core/lib/server/dispatchers/dispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,371 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var dispatcher_exports = {};
|
||||
__export(dispatcher_exports, {
|
||||
Dispatcher: () => Dispatcher,
|
||||
DispatcherConnection: () => DispatcherConnection,
|
||||
RootDispatcher: () => RootDispatcher,
|
||||
setMaxDispatchersForTest: () => setMaxDispatchersForTest
|
||||
});
|
||||
module.exports = __toCommonJS(dispatcher_exports);
|
||||
var import_events = require("events");
|
||||
var import_eventsHelper = require("../utils/eventsHelper");
|
||||
var import_validator = require("../../protocol/validator");
|
||||
var import_utils = require("../../utils");
|
||||
var import_debug = require("../utils/debug");
|
||||
var import_errors = require("../errors");
|
||||
var import_instrumentation = require("../instrumentation");
|
||||
var import_protocolError = require("../protocolError");
|
||||
var import_callLog = require("../callLog");
|
||||
var import_protocolMetainfo = require("../../utils/isomorphic/protocolMetainfo");
|
||||
var import_progress = require("../progress");
|
||||
const metadataValidator = (0, import_validator.createMetadataValidator)();
|
||||
let maxDispatchersOverride;
|
||||
function setMaxDispatchersForTest(value) {
|
||||
maxDispatchersOverride = value;
|
||||
}
|
||||
function maxDispatchersForBucket(gcBucket) {
|
||||
return maxDispatchersOverride ?? {
|
||||
"JSHandle": 1e5,
|
||||
"ElementHandle": 1e5
|
||||
}[gcBucket] ?? 1e4;
|
||||
}
|
||||
class Dispatcher extends import_events.EventEmitter {
|
||||
constructor(parent, object, type, initializer, gcBucket) {
|
||||
super();
|
||||
this._dispatchers = /* @__PURE__ */ new Map();
|
||||
this._disposed = false;
|
||||
this._eventListeners = [];
|
||||
this._activeProgressControllers = /* @__PURE__ */ new Set();
|
||||
this.connection = parent instanceof DispatcherConnection ? parent : parent.connection;
|
||||
this._parent = parent instanceof DispatcherConnection ? void 0 : parent;
|
||||
const guid = object.guid;
|
||||
this._guid = guid;
|
||||
this._type = type;
|
||||
this._object = object;
|
||||
this._gcBucket = gcBucket ?? type;
|
||||
this.connection.registerDispatcher(this);
|
||||
if (this._parent) {
|
||||
(0, import_utils.assert)(!this._parent._dispatchers.has(guid));
|
||||
this._parent._dispatchers.set(guid, this);
|
||||
}
|
||||
if (this._parent)
|
||||
this.connection.sendCreate(this._parent, type, guid, initializer);
|
||||
this.connection.maybeDisposeStaleDispatchers(this._gcBucket);
|
||||
}
|
||||
parentScope() {
|
||||
return this._parent;
|
||||
}
|
||||
addObjectListener(eventName, handler) {
|
||||
this._eventListeners.push(import_eventsHelper.eventsHelper.addEventListener(this._object, eventName, handler));
|
||||
}
|
||||
adopt(child) {
|
||||
if (child._parent === this)
|
||||
return;
|
||||
const oldParent = child._parent;
|
||||
oldParent._dispatchers.delete(child._guid);
|
||||
this._dispatchers.set(child._guid, child);
|
||||
child._parent = this;
|
||||
this.connection.sendAdopt(this, child);
|
||||
}
|
||||
async _runCommand(callMetadata, method, validParams) {
|
||||
const controller = new import_progress.ProgressController(callMetadata, (message) => {
|
||||
const logName = this._object.logName || "api";
|
||||
import_utils.debugLogger.log(logName, message);
|
||||
this._object.instrumentation.onCallLog(this._object, callMetadata, logName, message);
|
||||
});
|
||||
this._activeProgressControllers.add(controller);
|
||||
try {
|
||||
return await controller.run((progress) => this[method](validParams, progress), validParams?.timeout);
|
||||
} finally {
|
||||
this._activeProgressControllers.delete(controller);
|
||||
}
|
||||
}
|
||||
_dispatchEvent(method, params) {
|
||||
if (this._disposed) {
|
||||
if ((0, import_debug.isUnderTest)())
|
||||
throw new Error(`${this._guid} is sending "${String(method)}" event after being disposed`);
|
||||
return;
|
||||
}
|
||||
this.connection.sendEvent(this, method, params);
|
||||
}
|
||||
_dispose(reason) {
|
||||
this._disposeRecursively(new import_errors.TargetClosedError());
|
||||
this.connection.sendDispose(this, reason);
|
||||
}
|
||||
_onDispose() {
|
||||
}
|
||||
async stopPendingOperations(error) {
|
||||
const controllers = [];
|
||||
const collect = (dispatcher) => {
|
||||
controllers.push(...dispatcher._activeProgressControllers);
|
||||
for (const child of [...dispatcher._dispatchers.values()])
|
||||
collect(child);
|
||||
};
|
||||
collect(this);
|
||||
await Promise.all(controllers.map((controller) => controller.abort(error)));
|
||||
}
|
||||
_disposeRecursively(error) {
|
||||
(0, import_utils.assert)(!this._disposed, `${this._guid} is disposed more than once`);
|
||||
for (const controller of this._activeProgressControllers) {
|
||||
if (!controller.metadata.potentiallyClosesScope)
|
||||
controller.abort(error).catch(() => {
|
||||
});
|
||||
}
|
||||
this._onDispose();
|
||||
this._disposed = true;
|
||||
import_eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);
|
||||
this._parent?._dispatchers.delete(this._guid);
|
||||
const list = this.connection._dispatchersByBucket.get(this._gcBucket);
|
||||
list?.delete(this._guid);
|
||||
this.connection._dispatcherByGuid.delete(this._guid);
|
||||
this.connection._dispatcherByObject.delete(this._object);
|
||||
for (const dispatcher of [...this._dispatchers.values()])
|
||||
dispatcher._disposeRecursively(error);
|
||||
this._dispatchers.clear();
|
||||
}
|
||||
_debugScopeState() {
|
||||
return {
|
||||
_guid: this._guid,
|
||||
objects: Array.from(this._dispatchers.values()).map((o) => o._debugScopeState())
|
||||
};
|
||||
}
|
||||
async waitForEventInfo() {
|
||||
}
|
||||
}
|
||||
class RootDispatcher extends Dispatcher {
|
||||
constructor(connection, createPlaywright) {
|
||||
super(connection, (0, import_instrumentation.createRootSdkObject)(), "Root", {});
|
||||
this.createPlaywright = createPlaywright;
|
||||
this._initialized = false;
|
||||
}
|
||||
async initialize(params, progress) {
|
||||
(0, import_utils.assert)(this.createPlaywright);
|
||||
(0, import_utils.assert)(!this._initialized);
|
||||
this._initialized = true;
|
||||
return {
|
||||
playwright: await this.createPlaywright(this, params)
|
||||
};
|
||||
}
|
||||
}
|
||||
class DispatcherConnection {
|
||||
constructor(isLocal) {
|
||||
this._dispatcherByGuid = /* @__PURE__ */ new Map();
|
||||
this._dispatcherByObject = /* @__PURE__ */ new Map();
|
||||
this._dispatchersByBucket = /* @__PURE__ */ new Map();
|
||||
this.onmessage = (message) => {
|
||||
};
|
||||
this._waitOperations = /* @__PURE__ */ new Map();
|
||||
this._isLocal = !!isLocal;
|
||||
}
|
||||
sendEvent(dispatcher, event, params) {
|
||||
const validator = (0, import_validator.findValidator)(dispatcher._type, event, "Event");
|
||||
params = validator(params, "", this._validatorToWireContext());
|
||||
this.onmessage({ guid: dispatcher._guid, method: event, params });
|
||||
}
|
||||
sendCreate(parent, type, guid, initializer) {
|
||||
const validator = (0, import_validator.findValidator)(type, "", "Initializer");
|
||||
initializer = validator(initializer, "", this._validatorToWireContext());
|
||||
this.onmessage({ guid: parent._guid, method: "__create__", params: { type, initializer, guid } });
|
||||
}
|
||||
sendAdopt(parent, dispatcher) {
|
||||
this.onmessage({ guid: parent._guid, method: "__adopt__", params: { guid: dispatcher._guid } });
|
||||
}
|
||||
sendDispose(dispatcher, reason) {
|
||||
this.onmessage({ guid: dispatcher._guid, method: "__dispose__", params: { reason } });
|
||||
}
|
||||
_validatorToWireContext() {
|
||||
return {
|
||||
tChannelImpl: this._tChannelImplToWire.bind(this),
|
||||
binary: this._isLocal ? "buffer" : "toBase64",
|
||||
isUnderTest: import_debug.isUnderTest
|
||||
};
|
||||
}
|
||||
_validatorFromWireContext() {
|
||||
return {
|
||||
tChannelImpl: this._tChannelImplFromWire.bind(this),
|
||||
binary: this._isLocal ? "buffer" : "fromBase64",
|
||||
isUnderTest: import_debug.isUnderTest
|
||||
};
|
||||
}
|
||||
_tChannelImplFromWire(names, arg, path, context) {
|
||||
if (arg && typeof arg === "object" && typeof arg.guid === "string") {
|
||||
const guid = arg.guid;
|
||||
const dispatcher = this._dispatcherByGuid.get(guid);
|
||||
if (!dispatcher)
|
||||
throw new import_validator.ValidationError(`${path}: no object with guid ${guid}`);
|
||||
if (names !== "*" && !names.includes(dispatcher._type))
|
||||
throw new import_validator.ValidationError(`${path}: object with guid ${guid} has type ${dispatcher._type}, expected ${names.toString()}`);
|
||||
return dispatcher;
|
||||
}
|
||||
throw new import_validator.ValidationError(`${path}: expected guid for ${names.toString()}`);
|
||||
}
|
||||
_tChannelImplToWire(names, arg, path, context) {
|
||||
if (arg instanceof Dispatcher) {
|
||||
if (names !== "*" && !names.includes(arg._type))
|
||||
throw new import_validator.ValidationError(`${path}: dispatcher with guid ${arg._guid} has type ${arg._type}, expected ${names.toString()}`);
|
||||
return { guid: arg._guid };
|
||||
}
|
||||
throw new import_validator.ValidationError(`${path}: expected dispatcher ${names.toString()}`);
|
||||
}
|
||||
existingDispatcher(object) {
|
||||
return this._dispatcherByObject.get(object);
|
||||
}
|
||||
registerDispatcher(dispatcher) {
|
||||
(0, import_utils.assert)(!this._dispatcherByGuid.has(dispatcher._guid));
|
||||
this._dispatcherByGuid.set(dispatcher._guid, dispatcher);
|
||||
this._dispatcherByObject.set(dispatcher._object, dispatcher);
|
||||
let list = this._dispatchersByBucket.get(dispatcher._gcBucket);
|
||||
if (!list) {
|
||||
list = /* @__PURE__ */ new Set();
|
||||
this._dispatchersByBucket.set(dispatcher._gcBucket, list);
|
||||
}
|
||||
list.add(dispatcher._guid);
|
||||
}
|
||||
maybeDisposeStaleDispatchers(gcBucket) {
|
||||
const maxDispatchers = maxDispatchersForBucket(gcBucket);
|
||||
const list = this._dispatchersByBucket.get(gcBucket);
|
||||
if (!list || list.size <= maxDispatchers)
|
||||
return;
|
||||
const dispatchersArray = [...list];
|
||||
const disposeCount = maxDispatchers / 10 | 0;
|
||||
this._dispatchersByBucket.set(gcBucket, new Set(dispatchersArray.slice(disposeCount)));
|
||||
for (let i = 0; i < disposeCount; ++i) {
|
||||
const d = this._dispatcherByGuid.get(dispatchersArray[i]);
|
||||
if (!d)
|
||||
continue;
|
||||
d._dispose("gc");
|
||||
}
|
||||
}
|
||||
async dispatch(message) {
|
||||
const { id, guid, method, params, metadata } = message;
|
||||
const dispatcher = this._dispatcherByGuid.get(guid);
|
||||
if (!dispatcher) {
|
||||
this.onmessage({ id, error: (0, import_errors.serializeError)(new import_errors.TargetClosedError()) });
|
||||
return;
|
||||
}
|
||||
let validParams;
|
||||
let validMetadata;
|
||||
try {
|
||||
const validator = (0, import_validator.findValidator)(dispatcher._type, method, "Params");
|
||||
const validatorContext = this._validatorFromWireContext();
|
||||
validParams = validator(params, "", validatorContext);
|
||||
validMetadata = metadataValidator(metadata, "", validatorContext);
|
||||
if (typeof dispatcher[method] !== "function")
|
||||
throw new Error(`Mismatching dispatcher: "${dispatcher._type}" does not implement "${method}"`);
|
||||
} catch (e) {
|
||||
this.onmessage({ id, error: (0, import_errors.serializeError)(e) });
|
||||
return;
|
||||
}
|
||||
const metainfo = import_protocolMetainfo.methodMetainfo.get(dispatcher._type + "." + method);
|
||||
if (metainfo?.internal) {
|
||||
validMetadata.internal = true;
|
||||
}
|
||||
const sdkObject = dispatcher._object;
|
||||
const callMetadata = {
|
||||
id: `call@${id}`,
|
||||
location: validMetadata.location,
|
||||
title: validMetadata.title,
|
||||
internal: validMetadata.internal,
|
||||
stepId: validMetadata.stepId,
|
||||
objectId: sdkObject.guid,
|
||||
pageId: sdkObject.attribution?.page?.guid,
|
||||
frameId: sdkObject.attribution?.frame?.guid,
|
||||
startTime: (0, import_utils.monotonicTime)(),
|
||||
endTime: 0,
|
||||
type: dispatcher._type,
|
||||
method,
|
||||
params: params || {},
|
||||
log: []
|
||||
};
|
||||
if (params?.info?.waitId) {
|
||||
const info = params.info;
|
||||
switch (info.phase) {
|
||||
case "before": {
|
||||
this._waitOperations.set(info.waitId, callMetadata);
|
||||
await sdkObject.instrumentation.onBeforeCall(sdkObject, callMetadata);
|
||||
this.onmessage({ id });
|
||||
return;
|
||||
}
|
||||
case "log": {
|
||||
const originalMetadata = this._waitOperations.get(info.waitId);
|
||||
originalMetadata.log.push(info.message);
|
||||
sdkObject.instrumentation.onCallLog(sdkObject, originalMetadata, "api", info.message);
|
||||
this.onmessage({ id });
|
||||
return;
|
||||
}
|
||||
case "after": {
|
||||
const originalMetadata = this._waitOperations.get(info.waitId);
|
||||
originalMetadata.endTime = (0, import_utils.monotonicTime)();
|
||||
originalMetadata.error = info.error ? { error: { name: "Error", message: info.error } } : void 0;
|
||||
this._waitOperations.delete(info.waitId);
|
||||
await sdkObject.instrumentation.onAfterCall(sdkObject, originalMetadata);
|
||||
this.onmessage({ id });
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
await sdkObject.instrumentation.onBeforeCall(sdkObject, callMetadata);
|
||||
const response = { id };
|
||||
try {
|
||||
if (this._dispatcherByGuid.get(guid) !== dispatcher)
|
||||
throw new import_errors.TargetClosedError(closeReason(sdkObject));
|
||||
const result = await dispatcher._runCommand(callMetadata, method, validParams);
|
||||
const validator = (0, import_validator.findValidator)(dispatcher._type, method, "Result");
|
||||
response.result = validator(result, "", this._validatorToWireContext());
|
||||
callMetadata.result = result;
|
||||
} catch (e) {
|
||||
if ((0, import_errors.isTargetClosedError)(e)) {
|
||||
const reason = closeReason(sdkObject);
|
||||
if (reason)
|
||||
(0, import_utils.rewriteErrorMessage)(e, reason);
|
||||
} else if ((0, import_protocolError.isProtocolError)(e)) {
|
||||
if (e.type === "closed")
|
||||
e = new import_errors.TargetClosedError(closeReason(sdkObject), e.browserLogMessage());
|
||||
else if (e.type === "crashed")
|
||||
(0, import_utils.rewriteErrorMessage)(e, "Target crashed " + e.browserLogMessage());
|
||||
}
|
||||
response.error = (0, import_errors.serializeError)(e);
|
||||
callMetadata.error = response.error;
|
||||
} finally {
|
||||
callMetadata.endTime = (0, import_utils.monotonicTime)();
|
||||
await sdkObject.instrumentation.onAfterCall(sdkObject, callMetadata);
|
||||
if (metainfo?.slowMo)
|
||||
await this._doSlowMo(sdkObject);
|
||||
}
|
||||
if (response.error)
|
||||
response.log = (0, import_callLog.compressCallLog)(callMetadata.log);
|
||||
this.onmessage(response);
|
||||
}
|
||||
async _doSlowMo(sdkObject) {
|
||||
const slowMo = sdkObject.attribution.browser?.options.slowMo;
|
||||
if (slowMo)
|
||||
await new Promise((f) => setTimeout(f, slowMo));
|
||||
}
|
||||
}
|
||||
function closeReason(sdkObject) {
|
||||
return sdkObject.attribution.page?.closeReason || sdkObject.attribution.context?._closeReason || sdkObject.attribution.browser?._closeReason;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
Dispatcher,
|
||||
DispatcherConnection,
|
||||
RootDispatcher,
|
||||
setMaxDispatchersForTest
|
||||
});
|
89
node_modules/playwright-core/lib/server/dispatchers/electronDispatcher.js
generated
vendored
Normal file
89
node_modules/playwright-core/lib/server/dispatchers/electronDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var electronDispatcher_exports = {};
|
||||
__export(electronDispatcher_exports, {
|
||||
ElectronApplicationDispatcher: () => ElectronApplicationDispatcher,
|
||||
ElectronDispatcher: () => ElectronDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(electronDispatcher_exports);
|
||||
var import_browserContextDispatcher = require("./browserContextDispatcher");
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_jsHandleDispatcher = require("./jsHandleDispatcher");
|
||||
var import_electron = require("../electron/electron");
|
||||
class ElectronDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, electron, denyLaunch) {
|
||||
super(scope, electron, "Electron", {});
|
||||
this._type_Electron = true;
|
||||
this._denyLaunch = denyLaunch;
|
||||
}
|
||||
async launch(params, progress) {
|
||||
if (this._denyLaunch)
|
||||
throw new Error(`Launching more browsers is not allowed.`);
|
||||
const electronApplication = await this._object.launch(progress, params);
|
||||
return { electronApplication: new ElectronApplicationDispatcher(this, electronApplication) };
|
||||
}
|
||||
}
|
||||
class ElectronApplicationDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, electronApplication) {
|
||||
super(scope, electronApplication, "ElectronApplication", {
|
||||
context: import_browserContextDispatcher.BrowserContextDispatcher.from(scope, electronApplication.context())
|
||||
});
|
||||
this._type_EventTarget = true;
|
||||
this._type_ElectronApplication = true;
|
||||
this._subscriptions = /* @__PURE__ */ new Set();
|
||||
this.addObjectListener(import_electron.ElectronApplication.Events.Close, () => {
|
||||
this._dispatchEvent("close");
|
||||
this._dispose();
|
||||
});
|
||||
this.addObjectListener(import_electron.ElectronApplication.Events.Console, (message) => {
|
||||
if (!this._subscriptions.has("console"))
|
||||
return;
|
||||
this._dispatchEvent("console", {
|
||||
type: message.type(),
|
||||
text: message.text(),
|
||||
args: message.args().map((a) => import_jsHandleDispatcher.JSHandleDispatcher.fromJSHandle(this, a)),
|
||||
location: message.location()
|
||||
});
|
||||
});
|
||||
}
|
||||
async browserWindow(params, progress) {
|
||||
const handle = await progress.race(this._object.browserWindow(params.page.page()));
|
||||
return { handle: import_jsHandleDispatcher.JSHandleDispatcher.fromJSHandle(this, handle) };
|
||||
}
|
||||
async evaluateExpression(params, progress) {
|
||||
const handle = await progress.race(this._object._nodeElectronHandlePromise);
|
||||
return { value: (0, import_jsHandleDispatcher.serializeResult)(await progress.race(handle.evaluateExpression(params.expression, { isFunction: params.isFunction }, (0, import_jsHandleDispatcher.parseArgument)(params.arg)))) };
|
||||
}
|
||||
async evaluateExpressionHandle(params, progress) {
|
||||
const handle = await progress.race(this._object._nodeElectronHandlePromise);
|
||||
const result = await progress.race(handle.evaluateExpressionHandle(params.expression, { isFunction: params.isFunction }, (0, import_jsHandleDispatcher.parseArgument)(params.arg)));
|
||||
return { handle: import_jsHandleDispatcher.JSHandleDispatcher.fromJSHandle(this, result) };
|
||||
}
|
||||
async updateSubscription(params, progress) {
|
||||
if (params.enabled)
|
||||
this._subscriptions.add(params.event);
|
||||
else
|
||||
this._subscriptions.delete(params.event);
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
ElectronApplicationDispatcher,
|
||||
ElectronDispatcher
|
||||
});
|
181
node_modules/playwright-core/lib/server/dispatchers/elementHandlerDispatcher.js
generated
vendored
Normal file
181
node_modules/playwright-core/lib/server/dispatchers/elementHandlerDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var elementHandlerDispatcher_exports = {};
|
||||
__export(elementHandlerDispatcher_exports, {
|
||||
ElementHandleDispatcher: () => ElementHandleDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(elementHandlerDispatcher_exports);
|
||||
var import_browserContextDispatcher = require("./browserContextDispatcher");
|
||||
var import_frameDispatcher = require("./frameDispatcher");
|
||||
var import_jsHandleDispatcher = require("./jsHandleDispatcher");
|
||||
class ElementHandleDispatcher extends import_jsHandleDispatcher.JSHandleDispatcher {
|
||||
constructor(scope, elementHandle) {
|
||||
super(scope, elementHandle);
|
||||
this._type_ElementHandle = true;
|
||||
this._elementHandle = elementHandle;
|
||||
}
|
||||
static from(scope, handle) {
|
||||
return scope.connection.existingDispatcher(handle) || new ElementHandleDispatcher(scope, handle);
|
||||
}
|
||||
static fromNullable(scope, handle) {
|
||||
if (!handle)
|
||||
return void 0;
|
||||
return scope.connection.existingDispatcher(handle) || new ElementHandleDispatcher(scope, handle);
|
||||
}
|
||||
static fromJSOrElementHandle(scope, handle) {
|
||||
const result = scope.connection.existingDispatcher(handle);
|
||||
if (result)
|
||||
return result;
|
||||
const elementHandle = handle.asElement();
|
||||
if (!elementHandle)
|
||||
return new import_jsHandleDispatcher.JSHandleDispatcher(scope, handle);
|
||||
return new ElementHandleDispatcher(scope, elementHandle);
|
||||
}
|
||||
async ownerFrame(params, progress) {
|
||||
const frame = await this._elementHandle.ownerFrame();
|
||||
return { frame: frame ? import_frameDispatcher.FrameDispatcher.from(this._browserContextDispatcher(), frame) : void 0 };
|
||||
}
|
||||
async contentFrame(params, progress) {
|
||||
const frame = await progress.race(this._elementHandle.contentFrame());
|
||||
return { frame: frame ? import_frameDispatcher.FrameDispatcher.from(this._browserContextDispatcher(), frame) : void 0 };
|
||||
}
|
||||
async getAttribute(params, progress) {
|
||||
const value = await this._elementHandle.getAttribute(progress, params.name);
|
||||
return { value: value === null ? void 0 : value };
|
||||
}
|
||||
async inputValue(params, progress) {
|
||||
const value = await this._elementHandle.inputValue(progress);
|
||||
return { value };
|
||||
}
|
||||
async textContent(params, progress) {
|
||||
const value = await this._elementHandle.textContent(progress);
|
||||
return { value: value === null ? void 0 : value };
|
||||
}
|
||||
async innerText(params, progress) {
|
||||
return { value: await this._elementHandle.innerText(progress) };
|
||||
}
|
||||
async innerHTML(params, progress) {
|
||||
return { value: await this._elementHandle.innerHTML(progress) };
|
||||
}
|
||||
async isChecked(params, progress) {
|
||||
return { value: await this._elementHandle.isChecked(progress) };
|
||||
}
|
||||
async isDisabled(params, progress) {
|
||||
return { value: await this._elementHandle.isDisabled(progress) };
|
||||
}
|
||||
async isEditable(params, progress) {
|
||||
return { value: await this._elementHandle.isEditable(progress) };
|
||||
}
|
||||
async isEnabled(params, progress) {
|
||||
return { value: await this._elementHandle.isEnabled(progress) };
|
||||
}
|
||||
async isHidden(params, progress) {
|
||||
return { value: await this._elementHandle.isHidden(progress) };
|
||||
}
|
||||
async isVisible(params, progress) {
|
||||
return { value: await this._elementHandle.isVisible(progress) };
|
||||
}
|
||||
async dispatchEvent(params, progress) {
|
||||
await this._elementHandle.dispatchEvent(progress, params.type, (0, import_jsHandleDispatcher.parseArgument)(params.eventInit));
|
||||
}
|
||||
async scrollIntoViewIfNeeded(params, progress) {
|
||||
await this._elementHandle.scrollIntoViewIfNeeded(progress);
|
||||
}
|
||||
async hover(params, progress) {
|
||||
return await this._elementHandle.hover(progress, params);
|
||||
}
|
||||
async click(params, progress) {
|
||||
return await this._elementHandle.click(progress, params);
|
||||
}
|
||||
async dblclick(params, progress) {
|
||||
return await this._elementHandle.dblclick(progress, params);
|
||||
}
|
||||
async tap(params, progress) {
|
||||
return await this._elementHandle.tap(progress, params);
|
||||
}
|
||||
async selectOption(params, progress) {
|
||||
const elements = (params.elements || []).map((e) => e._elementHandle);
|
||||
return { values: await this._elementHandle.selectOption(progress, elements, params.options || [], params) };
|
||||
}
|
||||
async fill(params, progress) {
|
||||
return await this._elementHandle.fill(progress, params.value, params);
|
||||
}
|
||||
async selectText(params, progress) {
|
||||
await this._elementHandle.selectText(progress, params);
|
||||
}
|
||||
async setInputFiles(params, progress) {
|
||||
return await this._elementHandle.setInputFiles(progress, params);
|
||||
}
|
||||
async focus(params, progress) {
|
||||
await this._elementHandle.focus(progress);
|
||||
}
|
||||
async type(params, progress) {
|
||||
return await this._elementHandle.type(progress, params.text, params);
|
||||
}
|
||||
async press(params, progress) {
|
||||
return await this._elementHandle.press(progress, params.key, params);
|
||||
}
|
||||
async check(params, progress) {
|
||||
return await this._elementHandle.check(progress, params);
|
||||
}
|
||||
async uncheck(params, progress) {
|
||||
return await this._elementHandle.uncheck(progress, params);
|
||||
}
|
||||
async boundingBox(params, progress) {
|
||||
const value = await progress.race(this._elementHandle.boundingBox());
|
||||
return { value: value || void 0 };
|
||||
}
|
||||
async screenshot(params, progress) {
|
||||
const mask = (params.mask || []).map(({ frame, selector }) => ({
|
||||
frame: frame._object,
|
||||
selector
|
||||
}));
|
||||
return { binary: await this._elementHandle.screenshot(progress, { ...params, mask }) };
|
||||
}
|
||||
async querySelector(params, progress) {
|
||||
const handle = await progress.race(this._elementHandle.querySelector(params.selector, params));
|
||||
return { element: ElementHandleDispatcher.fromNullable(this.parentScope(), handle) };
|
||||
}
|
||||
async querySelectorAll(params, progress) {
|
||||
const elements = await progress.race(this._elementHandle.querySelectorAll(params.selector));
|
||||
return { elements: elements.map((e) => ElementHandleDispatcher.from(this.parentScope(), e)) };
|
||||
}
|
||||
async evalOnSelector(params, progress) {
|
||||
return { value: (0, import_jsHandleDispatcher.serializeResult)(await progress.race(this._elementHandle.evalOnSelector(params.selector, !!params.strict, params.expression, params.isFunction, (0, import_jsHandleDispatcher.parseArgument)(params.arg)))) };
|
||||
}
|
||||
async evalOnSelectorAll(params, progress) {
|
||||
return { value: (0, import_jsHandleDispatcher.serializeResult)(await progress.race(this._elementHandle.evalOnSelectorAll(params.selector, params.expression, params.isFunction, (0, import_jsHandleDispatcher.parseArgument)(params.arg)))) };
|
||||
}
|
||||
async waitForElementState(params, progress) {
|
||||
await this._elementHandle.waitForElementState(progress, params.state);
|
||||
}
|
||||
async waitForSelector(params, progress) {
|
||||
return { element: ElementHandleDispatcher.fromNullable(this.parentScope(), await this._elementHandle.waitForSelector(progress, params.selector, params)) };
|
||||
}
|
||||
_browserContextDispatcher() {
|
||||
const parentScope = this.parentScope().parentScope();
|
||||
if (parentScope instanceof import_browserContextDispatcher.BrowserContextDispatcher)
|
||||
return parentScope;
|
||||
return parentScope.parentScope();
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
ElementHandleDispatcher
|
||||
});
|
227
node_modules/playwright-core/lib/server/dispatchers/frameDispatcher.js
generated
vendored
Normal file
227
node_modules/playwright-core/lib/server/dispatchers/frameDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,227 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var frameDispatcher_exports = {};
|
||||
__export(frameDispatcher_exports, {
|
||||
FrameDispatcher: () => FrameDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(frameDispatcher_exports);
|
||||
var import_frames = require("../frames");
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_elementHandlerDispatcher = require("./elementHandlerDispatcher");
|
||||
var import_jsHandleDispatcher = require("./jsHandleDispatcher");
|
||||
var import_networkDispatchers = require("./networkDispatchers");
|
||||
var import_networkDispatchers2 = require("./networkDispatchers");
|
||||
var import_ariaSnapshot = require("../../utils/isomorphic/ariaSnapshot");
|
||||
var import_utilsBundle = require("../../utilsBundle");
|
||||
class FrameDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, frame) {
|
||||
const gcBucket = frame._page.mainFrame() === frame ? "MainFrame" : "Frame";
|
||||
const pageDispatcher = scope.connection.existingDispatcher(frame._page);
|
||||
super(pageDispatcher || scope, frame, "Frame", {
|
||||
url: frame.url(),
|
||||
name: frame.name(),
|
||||
parentFrame: FrameDispatcher.fromNullable(scope, frame.parentFrame()),
|
||||
loadStates: Array.from(frame._firedLifecycleEvents)
|
||||
}, gcBucket);
|
||||
this._type_Frame = true;
|
||||
this._browserContextDispatcher = scope;
|
||||
this._frame = frame;
|
||||
this.addObjectListener(import_frames.Frame.Events.AddLifecycle, (lifecycleEvent) => {
|
||||
this._dispatchEvent("loadstate", { add: lifecycleEvent });
|
||||
});
|
||||
this.addObjectListener(import_frames.Frame.Events.RemoveLifecycle, (lifecycleEvent) => {
|
||||
this._dispatchEvent("loadstate", { remove: lifecycleEvent });
|
||||
});
|
||||
this.addObjectListener(import_frames.Frame.Events.InternalNavigation, (event) => {
|
||||
if (!event.isPublic)
|
||||
return;
|
||||
const params = { url: event.url, name: event.name, error: event.error ? event.error.message : void 0 };
|
||||
if (event.newDocument)
|
||||
params.newDocument = { request: import_networkDispatchers2.RequestDispatcher.fromNullable(this._browserContextDispatcher, event.newDocument.request || null) };
|
||||
this._dispatchEvent("navigated", params);
|
||||
});
|
||||
}
|
||||
static from(scope, frame) {
|
||||
const result = scope.connection.existingDispatcher(frame);
|
||||
return result || new FrameDispatcher(scope, frame);
|
||||
}
|
||||
static fromNullable(scope, frame) {
|
||||
if (!frame)
|
||||
return;
|
||||
return FrameDispatcher.from(scope, frame);
|
||||
}
|
||||
async goto(params, progress) {
|
||||
return { response: import_networkDispatchers.ResponseDispatcher.fromNullable(this._browserContextDispatcher, await this._frame.goto(progress, params.url, params)) };
|
||||
}
|
||||
async frameElement(params, progress) {
|
||||
return { element: import_elementHandlerDispatcher.ElementHandleDispatcher.from(this, await progress.race(this._frame.frameElement())) };
|
||||
}
|
||||
async evaluateExpression(params, progress) {
|
||||
return { value: (0, import_jsHandleDispatcher.serializeResult)(await progress.race(this._frame.evaluateExpression(params.expression, { isFunction: params.isFunction }, (0, import_jsHandleDispatcher.parseArgument)(params.arg)))) };
|
||||
}
|
||||
async evaluateExpressionHandle(params, progress) {
|
||||
return { handle: import_elementHandlerDispatcher.ElementHandleDispatcher.fromJSOrElementHandle(this, await progress.race(this._frame.evaluateExpressionHandle(params.expression, { isFunction: params.isFunction }, (0, import_jsHandleDispatcher.parseArgument)(params.arg)))) };
|
||||
}
|
||||
async waitForSelector(params, progress) {
|
||||
return { element: import_elementHandlerDispatcher.ElementHandleDispatcher.fromNullable(this, await this._frame.waitForSelector(progress, params.selector, true, params)) };
|
||||
}
|
||||
async dispatchEvent(params, progress) {
|
||||
return this._frame.dispatchEvent(progress, params.selector, params.type, (0, import_jsHandleDispatcher.parseArgument)(params.eventInit), params);
|
||||
}
|
||||
async evalOnSelector(params, progress) {
|
||||
return { value: (0, import_jsHandleDispatcher.serializeResult)(await progress.race(this._frame.evalOnSelector(params.selector, !!params.strict, params.expression, params.isFunction, (0, import_jsHandleDispatcher.parseArgument)(params.arg)))) };
|
||||
}
|
||||
async evalOnSelectorAll(params, progress) {
|
||||
return { value: (0, import_jsHandleDispatcher.serializeResult)(await progress.race(this._frame.evalOnSelectorAll(params.selector, params.expression, params.isFunction, (0, import_jsHandleDispatcher.parseArgument)(params.arg)))) };
|
||||
}
|
||||
async querySelector(params, progress) {
|
||||
return { element: import_elementHandlerDispatcher.ElementHandleDispatcher.fromNullable(this, await progress.race(this._frame.querySelector(params.selector, params))) };
|
||||
}
|
||||
async querySelectorAll(params, progress) {
|
||||
const elements = await progress.race(this._frame.querySelectorAll(params.selector));
|
||||
return { elements: elements.map((e) => import_elementHandlerDispatcher.ElementHandleDispatcher.from(this, e)) };
|
||||
}
|
||||
async queryCount(params, progress) {
|
||||
return { value: await progress.race(this._frame.queryCount(params.selector, params)) };
|
||||
}
|
||||
async content(params, progress) {
|
||||
return { value: await progress.race(this._frame.content()) };
|
||||
}
|
||||
async setContent(params, progress) {
|
||||
return await this._frame.setContent(progress, params.html, params);
|
||||
}
|
||||
async addScriptTag(params, progress) {
|
||||
return { element: import_elementHandlerDispatcher.ElementHandleDispatcher.from(this, await progress.race(this._frame.addScriptTag(params))) };
|
||||
}
|
||||
async addStyleTag(params, progress) {
|
||||
return { element: import_elementHandlerDispatcher.ElementHandleDispatcher.from(this, await progress.race(this._frame.addStyleTag(params))) };
|
||||
}
|
||||
async click(params, progress) {
|
||||
progress.metadata.potentiallyClosesScope = true;
|
||||
return await this._frame.click(progress, params.selector, params);
|
||||
}
|
||||
async dblclick(params, progress) {
|
||||
return await this._frame.dblclick(progress, params.selector, params);
|
||||
}
|
||||
async dragAndDrop(params, progress) {
|
||||
return await this._frame.dragAndDrop(progress, params.source, params.target, params);
|
||||
}
|
||||
async tap(params, progress) {
|
||||
return await this._frame.tap(progress, params.selector, params);
|
||||
}
|
||||
async fill(params, progress) {
|
||||
return await this._frame.fill(progress, params.selector, params.value, params);
|
||||
}
|
||||
async focus(params, progress) {
|
||||
await this._frame.focus(progress, params.selector, params);
|
||||
}
|
||||
async blur(params, progress) {
|
||||
await this._frame.blur(progress, params.selector, params);
|
||||
}
|
||||
async textContent(params, progress) {
|
||||
const value = await this._frame.textContent(progress, params.selector, params);
|
||||
return { value: value === null ? void 0 : value };
|
||||
}
|
||||
async innerText(params, progress) {
|
||||
return { value: await this._frame.innerText(progress, params.selector, params) };
|
||||
}
|
||||
async innerHTML(params, progress) {
|
||||
return { value: await this._frame.innerHTML(progress, params.selector, params) };
|
||||
}
|
||||
async resolveSelector(params, progress) {
|
||||
return await this._frame.resolveSelector(progress, params.selector);
|
||||
}
|
||||
async getAttribute(params, progress) {
|
||||
const value = await this._frame.getAttribute(progress, params.selector, params.name, params);
|
||||
return { value: value === null ? void 0 : value };
|
||||
}
|
||||
async inputValue(params, progress) {
|
||||
const value = await this._frame.inputValue(progress, params.selector, params);
|
||||
return { value };
|
||||
}
|
||||
async isChecked(params, progress) {
|
||||
return { value: await this._frame.isChecked(progress, params.selector, params) };
|
||||
}
|
||||
async isDisabled(params, progress) {
|
||||
return { value: await this._frame.isDisabled(progress, params.selector, params) };
|
||||
}
|
||||
async isEditable(params, progress) {
|
||||
return { value: await this._frame.isEditable(progress, params.selector, params) };
|
||||
}
|
||||
async isEnabled(params, progress) {
|
||||
return { value: await this._frame.isEnabled(progress, params.selector, params) };
|
||||
}
|
||||
async isHidden(params, progress) {
|
||||
return { value: await this._frame.isHidden(progress, params.selector, params) };
|
||||
}
|
||||
async isVisible(params, progress) {
|
||||
return { value: await this._frame.isVisible(progress, params.selector, params) };
|
||||
}
|
||||
async hover(params, progress) {
|
||||
return await this._frame.hover(progress, params.selector, params);
|
||||
}
|
||||
async selectOption(params, progress) {
|
||||
const elements = (params.elements || []).map((e) => e._elementHandle);
|
||||
return { values: await this._frame.selectOption(progress, params.selector, elements, params.options || [], params) };
|
||||
}
|
||||
async setInputFiles(params, progress) {
|
||||
return await this._frame.setInputFiles(progress, params.selector, params);
|
||||
}
|
||||
async type(params, progress) {
|
||||
return await this._frame.type(progress, params.selector, params.text, params);
|
||||
}
|
||||
async press(params, progress) {
|
||||
return await this._frame.press(progress, params.selector, params.key, params);
|
||||
}
|
||||
async check(params, progress) {
|
||||
return await this._frame.check(progress, params.selector, params);
|
||||
}
|
||||
async uncheck(params, progress) {
|
||||
return await this._frame.uncheck(progress, params.selector, params);
|
||||
}
|
||||
async waitForTimeout(params, progress) {
|
||||
return await this._frame.waitForTimeout(progress, params.waitTimeout);
|
||||
}
|
||||
async waitForFunction(params, progress) {
|
||||
return { handle: import_elementHandlerDispatcher.ElementHandleDispatcher.fromJSOrElementHandle(this, await this._frame.waitForFunctionExpression(progress, params.expression, params.isFunction, (0, import_jsHandleDispatcher.parseArgument)(params.arg), params)) };
|
||||
}
|
||||
async title(params, progress) {
|
||||
return { value: await progress.race(this._frame.title()) };
|
||||
}
|
||||
async highlight(params, progress) {
|
||||
return await this._frame.highlight(progress, params.selector);
|
||||
}
|
||||
async expect(params, progress) {
|
||||
progress.metadata.potentiallyClosesScope = true;
|
||||
let expectedValue = params.expectedValue ? (0, import_jsHandleDispatcher.parseArgument)(params.expectedValue) : void 0;
|
||||
if (params.expression === "to.match.aria" && expectedValue)
|
||||
expectedValue = (0, import_ariaSnapshot.parseAriaSnapshotUnsafe)(import_utilsBundle.yaml, expectedValue);
|
||||
const result = await this._frame.expect(progress, params.selector, { ...params, expectedValue }, params.timeout);
|
||||
if (result.received !== void 0)
|
||||
result.received = (0, import_jsHandleDispatcher.serializeResult)(result.received);
|
||||
return result;
|
||||
}
|
||||
async ariaSnapshot(params, progress) {
|
||||
return { snapshot: await this._frame.ariaSnapshot(progress, params.selector) };
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
FrameDispatcher
|
||||
});
|
85
node_modules/playwright-core/lib/server/dispatchers/jsHandleDispatcher.js
generated
vendored
Normal file
85
node_modules/playwright-core/lib/server/dispatchers/jsHandleDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var jsHandleDispatcher_exports = {};
|
||||
__export(jsHandleDispatcher_exports, {
|
||||
JSHandleDispatcher: () => JSHandleDispatcher,
|
||||
parseArgument: () => parseArgument,
|
||||
parseValue: () => parseValue,
|
||||
serializeResult: () => serializeResult
|
||||
});
|
||||
module.exports = __toCommonJS(jsHandleDispatcher_exports);
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_elementHandlerDispatcher = require("./elementHandlerDispatcher");
|
||||
var import_serializers = require("../../protocol/serializers");
|
||||
class JSHandleDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, jsHandle) {
|
||||
super(scope, jsHandle, jsHandle.asElement() ? "ElementHandle" : "JSHandle", {
|
||||
preview: jsHandle.toString()
|
||||
});
|
||||
this._type_JSHandle = true;
|
||||
jsHandle._setPreviewCallback((preview) => this._dispatchEvent("previewUpdated", { preview }));
|
||||
}
|
||||
static fromJSHandle(scope, handle) {
|
||||
return scope.connection.existingDispatcher(handle) || new JSHandleDispatcher(scope, handle);
|
||||
}
|
||||
async evaluateExpression(params, progress) {
|
||||
const jsHandle = await progress.race(this._object.evaluateExpression(params.expression, { isFunction: params.isFunction }, parseArgument(params.arg)));
|
||||
return { value: serializeResult(jsHandle) };
|
||||
}
|
||||
async evaluateExpressionHandle(params, progress) {
|
||||
const jsHandle = await progress.race(this._object.evaluateExpressionHandle(params.expression, { isFunction: params.isFunction }, parseArgument(params.arg)));
|
||||
return { handle: import_elementHandlerDispatcher.ElementHandleDispatcher.fromJSOrElementHandle(this.parentScope(), jsHandle) };
|
||||
}
|
||||
async getProperty(params, progress) {
|
||||
const jsHandle = await progress.race(this._object.getProperty(params.name));
|
||||
return { handle: import_elementHandlerDispatcher.ElementHandleDispatcher.fromJSOrElementHandle(this.parentScope(), jsHandle) };
|
||||
}
|
||||
async getPropertyList(params, progress) {
|
||||
const map = await progress.race(this._object.getProperties());
|
||||
const properties = [];
|
||||
for (const [name, value] of map) {
|
||||
properties.push({ name, value: import_elementHandlerDispatcher.ElementHandleDispatcher.fromJSOrElementHandle(this.parentScope(), value) });
|
||||
}
|
||||
return { properties };
|
||||
}
|
||||
async jsonValue(params, progress) {
|
||||
return { value: serializeResult(await progress.race(this._object.jsonValue())) };
|
||||
}
|
||||
async dispose(_, progress) {
|
||||
progress.metadata.potentiallyClosesScope = true;
|
||||
this._object.dispose();
|
||||
this._dispose();
|
||||
}
|
||||
}
|
||||
function parseArgument(arg) {
|
||||
return (0, import_serializers.parseSerializedValue)(arg.value, arg.handles.map((a) => a._object));
|
||||
}
|
||||
function parseValue(v) {
|
||||
return (0, import_serializers.parseSerializedValue)(v, []);
|
||||
}
|
||||
function serializeResult(arg) {
|
||||
return (0, import_serializers.serializeValue)(arg, (value) => ({ fallThrough: value }));
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
JSHandleDispatcher,
|
||||
parseArgument,
|
||||
parseValue,
|
||||
serializeResult
|
||||
});
|
58
node_modules/playwright-core/lib/server/dispatchers/jsonPipeDispatcher.js
generated
vendored
Normal file
58
node_modules/playwright-core/lib/server/dispatchers/jsonPipeDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var jsonPipeDispatcher_exports = {};
|
||||
__export(jsonPipeDispatcher_exports, {
|
||||
JsonPipeDispatcher: () => JsonPipeDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(jsonPipeDispatcher_exports);
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_instrumentation = require("../instrumentation");
|
||||
class JsonPipeDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope) {
|
||||
super(scope, new import_instrumentation.SdkObject(scope._object, "jsonPipe"), "JsonPipe", {});
|
||||
this._type_JsonPipe = true;
|
||||
}
|
||||
async send(params, progress) {
|
||||
this.emit("message", params.message);
|
||||
}
|
||||
async close(params, progress) {
|
||||
this.emit("close");
|
||||
if (!this._disposed) {
|
||||
this._dispatchEvent("closed", {});
|
||||
this._dispose();
|
||||
}
|
||||
}
|
||||
dispatch(message) {
|
||||
if (!this._disposed)
|
||||
this._dispatchEvent("message", { message });
|
||||
}
|
||||
wasClosed(reason) {
|
||||
if (!this._disposed) {
|
||||
this._dispatchEvent("closed", { reason });
|
||||
this._dispose();
|
||||
}
|
||||
}
|
||||
dispose() {
|
||||
this._dispose();
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
JsonPipeDispatcher
|
||||
});
|
149
node_modules/playwright-core/lib/server/dispatchers/localUtilsDispatcher.js
generated
vendored
Normal file
149
node_modules/playwright-core/lib/server/dispatchers/localUtilsDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var localUtilsDispatcher_exports = {};
|
||||
__export(localUtilsDispatcher_exports, {
|
||||
LocalUtilsDispatcher: () => LocalUtilsDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(localUtilsDispatcher_exports);
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_instrumentation = require("../../server/instrumentation");
|
||||
var localUtils = __toESM(require("../localUtils"));
|
||||
var import_userAgent = require("../utils/userAgent");
|
||||
var import_deviceDescriptors = require("../deviceDescriptors");
|
||||
var import_jsonPipeDispatcher = require("../dispatchers/jsonPipeDispatcher");
|
||||
var import_socksInterceptor = require("../socksInterceptor");
|
||||
var import_transport = require("../transport");
|
||||
var import_network = require("../utils/network");
|
||||
var import_urlMatch = require("../../utils/isomorphic/urlMatch");
|
||||
class LocalUtilsDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, playwright) {
|
||||
const localUtils2 = new import_instrumentation.SdkObject(playwright, "localUtils", "localUtils");
|
||||
localUtils2.logName = "browser";
|
||||
const deviceDescriptors = Object.entries(import_deviceDescriptors.deviceDescriptors).map(([name, descriptor]) => ({ name, descriptor }));
|
||||
super(scope, localUtils2, "LocalUtils", {
|
||||
deviceDescriptors
|
||||
});
|
||||
this._harBackends = /* @__PURE__ */ new Map();
|
||||
this._stackSessions = /* @__PURE__ */ new Map();
|
||||
this._type_LocalUtils = true;
|
||||
}
|
||||
async zip(params, progress) {
|
||||
return await localUtils.zip(progress, this._stackSessions, params);
|
||||
}
|
||||
async harOpen(params, progress) {
|
||||
return await localUtils.harOpen(progress, this._harBackends, params);
|
||||
}
|
||||
async harLookup(params, progress) {
|
||||
return await localUtils.harLookup(progress, this._harBackends, params);
|
||||
}
|
||||
async harClose(params, progress) {
|
||||
localUtils.harClose(this._harBackends, params);
|
||||
}
|
||||
async harUnzip(params, progress) {
|
||||
return await localUtils.harUnzip(progress, params);
|
||||
}
|
||||
async tracingStarted(params, progress) {
|
||||
return await localUtils.tracingStarted(progress, this._stackSessions, params);
|
||||
}
|
||||
async traceDiscarded(params, progress) {
|
||||
return await localUtils.traceDiscarded(progress, this._stackSessions, params);
|
||||
}
|
||||
async addStackToTracingNoReply(params, progress) {
|
||||
localUtils.addStackToTracingNoReply(this._stackSessions, params);
|
||||
}
|
||||
async connect(params, progress) {
|
||||
const wsHeaders = {
|
||||
"User-Agent": (0, import_userAgent.getUserAgent)(),
|
||||
"x-playwright-proxy": params.exposeNetwork ?? "",
|
||||
...params.headers
|
||||
};
|
||||
const wsEndpoint = await urlToWSEndpoint(progress, params.wsEndpoint);
|
||||
const transport = await import_transport.WebSocketTransport.connect(progress, wsEndpoint, { headers: wsHeaders, followRedirects: true, debugLogHeader: "x-playwright-debug-log" });
|
||||
const socksInterceptor = new import_socksInterceptor.SocksInterceptor(transport, params.exposeNetwork, params.socksProxyRedirectPortForTest);
|
||||
const pipe = new import_jsonPipeDispatcher.JsonPipeDispatcher(this);
|
||||
transport.onmessage = (json) => {
|
||||
if (socksInterceptor.interceptMessage(json))
|
||||
return;
|
||||
const cb = () => {
|
||||
try {
|
||||
pipe.dispatch(json);
|
||||
} catch (e) {
|
||||
transport.close();
|
||||
}
|
||||
};
|
||||
if (params.slowMo)
|
||||
setTimeout(cb, params.slowMo);
|
||||
else
|
||||
cb();
|
||||
};
|
||||
pipe.on("message", (message) => {
|
||||
transport.send(message);
|
||||
});
|
||||
transport.onclose = (reason) => {
|
||||
socksInterceptor?.cleanup();
|
||||
pipe.wasClosed(reason);
|
||||
};
|
||||
pipe.on("close", () => transport.close());
|
||||
return { pipe, headers: transport.headers };
|
||||
}
|
||||
async globToRegex(params, progress) {
|
||||
const regex = (0, import_urlMatch.resolveGlobToRegexPattern)(params.baseURL, params.glob, params.webSocketUrl);
|
||||
return { regex };
|
||||
}
|
||||
}
|
||||
async function urlToWSEndpoint(progress, endpointURL) {
|
||||
if (endpointURL.startsWith("ws"))
|
||||
return endpointURL;
|
||||
progress.log(`<ws preparing> retrieving websocket url from ${endpointURL}`);
|
||||
const fetchUrl = new URL(endpointURL);
|
||||
if (!fetchUrl.pathname.endsWith("/"))
|
||||
fetchUrl.pathname += "/";
|
||||
fetchUrl.pathname += "json";
|
||||
const json = await (0, import_network.fetchData)(progress, {
|
||||
url: fetchUrl.toString(),
|
||||
method: "GET",
|
||||
headers: { "User-Agent": (0, import_userAgent.getUserAgent)() }
|
||||
}, async (params, response) => {
|
||||
return new Error(`Unexpected status ${response.statusCode} when connecting to ${fetchUrl.toString()}.
|
||||
This does not look like a Playwright server, try connecting via ws://.`);
|
||||
});
|
||||
const wsUrl = new URL(endpointURL);
|
||||
let wsEndpointPath = JSON.parse(json).wsEndpointPath;
|
||||
if (wsEndpointPath.startsWith("/"))
|
||||
wsEndpointPath = wsEndpointPath.substring(1);
|
||||
if (!wsUrl.pathname.endsWith("/"))
|
||||
wsUrl.pathname += "/";
|
||||
wsUrl.pathname += wsEndpointPath;
|
||||
wsUrl.protocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
||||
return wsUrl.toString();
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
LocalUtilsDispatcher
|
||||
});
|
210
node_modules/playwright-core/lib/server/dispatchers/networkDispatchers.js
generated
vendored
Normal file
210
node_modules/playwright-core/lib/server/dispatchers/networkDispatchers.js
generated
vendored
Normal file
@@ -0,0 +1,210 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var networkDispatchers_exports = {};
|
||||
__export(networkDispatchers_exports, {
|
||||
APIRequestContextDispatcher: () => APIRequestContextDispatcher,
|
||||
RequestDispatcher: () => RequestDispatcher,
|
||||
ResponseDispatcher: () => ResponseDispatcher,
|
||||
RouteDispatcher: () => RouteDispatcher,
|
||||
WebSocketDispatcher: () => WebSocketDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(networkDispatchers_exports);
|
||||
var import_network = require("../network");
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_frameDispatcher = require("./frameDispatcher");
|
||||
var import_pageDispatcher = require("./pageDispatcher");
|
||||
var import_tracingDispatcher = require("./tracingDispatcher");
|
||||
class RequestDispatcher extends import_dispatcher.Dispatcher {
|
||||
static from(scope, request) {
|
||||
const result = scope.connection.existingDispatcher(request);
|
||||
return result || new RequestDispatcher(scope, request);
|
||||
}
|
||||
static fromNullable(scope, request) {
|
||||
return request ? RequestDispatcher.from(scope, request) : void 0;
|
||||
}
|
||||
constructor(scope, request) {
|
||||
const postData = request.postDataBuffer();
|
||||
const frame = request.frame();
|
||||
const page = request.frame()?._page;
|
||||
const pageDispatcher = page ? scope.connection.existingDispatcher(page) : null;
|
||||
const frameDispatcher = frame ? import_frameDispatcher.FrameDispatcher.from(scope, frame) : null;
|
||||
super(pageDispatcher || frameDispatcher || scope, request, "Request", {
|
||||
frame: import_frameDispatcher.FrameDispatcher.fromNullable(scope, request.frame()),
|
||||
serviceWorker: import_pageDispatcher.WorkerDispatcher.fromNullable(scope, request.serviceWorker()),
|
||||
url: request.url(),
|
||||
resourceType: request.resourceType(),
|
||||
method: request.method(),
|
||||
postData: postData === null ? void 0 : postData,
|
||||
headers: request.headers(),
|
||||
isNavigationRequest: request.isNavigationRequest(),
|
||||
redirectedFrom: RequestDispatcher.fromNullable(scope, request.redirectedFrom())
|
||||
});
|
||||
this._type_Request = true;
|
||||
this._browserContextDispatcher = scope;
|
||||
}
|
||||
async rawRequestHeaders(params, progress) {
|
||||
return { headers: await progress.race(this._object.rawRequestHeaders()) };
|
||||
}
|
||||
async response(params, progress) {
|
||||
return { response: ResponseDispatcher.fromNullable(this._browserContextDispatcher, await progress.race(this._object.response())) };
|
||||
}
|
||||
}
|
||||
class ResponseDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, response) {
|
||||
super(scope, response, "Response", {
|
||||
// TODO: responses in popups can point to non-reported requests.
|
||||
request: scope,
|
||||
url: response.url(),
|
||||
status: response.status(),
|
||||
statusText: response.statusText(),
|
||||
headers: response.headers(),
|
||||
timing: response.timing(),
|
||||
fromServiceWorker: response.fromServiceWorker()
|
||||
});
|
||||
this._type_Response = true;
|
||||
}
|
||||
static from(scope, response) {
|
||||
const result = scope.connection.existingDispatcher(response);
|
||||
const requestDispatcher = RequestDispatcher.from(scope, response.request());
|
||||
return result || new ResponseDispatcher(requestDispatcher, response);
|
||||
}
|
||||
static fromNullable(scope, response) {
|
||||
return response ? ResponseDispatcher.from(scope, response) : void 0;
|
||||
}
|
||||
async body(params, progress) {
|
||||
return { binary: await progress.race(this._object.body()) };
|
||||
}
|
||||
async securityDetails(params, progress) {
|
||||
return { value: await progress.race(this._object.securityDetails()) || void 0 };
|
||||
}
|
||||
async serverAddr(params, progress) {
|
||||
return { value: await progress.race(this._object.serverAddr()) || void 0 };
|
||||
}
|
||||
async rawResponseHeaders(params, progress) {
|
||||
return { headers: await progress.race(this._object.rawResponseHeaders()) };
|
||||
}
|
||||
async sizes(params, progress) {
|
||||
return { sizes: await progress.race(this._object.sizes()) };
|
||||
}
|
||||
}
|
||||
class RouteDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, route) {
|
||||
super(scope, route, "Route", {
|
||||
// Context route can point to a non-reported request, so we send the request in the initializer.
|
||||
request: scope
|
||||
});
|
||||
this._type_Route = true;
|
||||
this._handled = false;
|
||||
}
|
||||
_checkNotHandled() {
|
||||
if (this._handled)
|
||||
throw new Error("Route is already handled!");
|
||||
this._handled = true;
|
||||
}
|
||||
async continue(params, progress) {
|
||||
this._checkNotHandled();
|
||||
await this._object.continue({
|
||||
url: params.url,
|
||||
method: params.method,
|
||||
headers: params.headers,
|
||||
postData: params.postData,
|
||||
isFallback: params.isFallback
|
||||
});
|
||||
}
|
||||
async fulfill(params, progress) {
|
||||
this._checkNotHandled();
|
||||
await this._object.fulfill(params);
|
||||
}
|
||||
async abort(params, progress) {
|
||||
this._checkNotHandled();
|
||||
await this._object.abort(params.errorCode || "failed");
|
||||
}
|
||||
async redirectNavigationRequest(params, progress) {
|
||||
this._checkNotHandled();
|
||||
this._object.redirectNavigationRequest(params.url);
|
||||
}
|
||||
}
|
||||
class WebSocketDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, webSocket) {
|
||||
super(scope, webSocket, "WebSocket", {
|
||||
url: webSocket.url()
|
||||
});
|
||||
this._type_EventTarget = true;
|
||||
this._type_WebSocket = true;
|
||||
this.addObjectListener(import_network.WebSocket.Events.FrameSent, (event) => this._dispatchEvent("frameSent", event));
|
||||
this.addObjectListener(import_network.WebSocket.Events.FrameReceived, (event) => this._dispatchEvent("frameReceived", event));
|
||||
this.addObjectListener(import_network.WebSocket.Events.SocketError, (error) => this._dispatchEvent("socketError", { error }));
|
||||
this.addObjectListener(import_network.WebSocket.Events.Close, () => this._dispatchEvent("close", {}));
|
||||
}
|
||||
}
|
||||
class APIRequestContextDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(parentScope, request) {
|
||||
const tracing = import_tracingDispatcher.TracingDispatcher.from(parentScope, request.tracing());
|
||||
super(parentScope, request, "APIRequestContext", {
|
||||
tracing
|
||||
});
|
||||
this._type_APIRequestContext = true;
|
||||
this.adopt(tracing);
|
||||
}
|
||||
static from(scope, request) {
|
||||
const result = scope.connection.existingDispatcher(request);
|
||||
return result || new APIRequestContextDispatcher(scope, request);
|
||||
}
|
||||
static fromNullable(scope, request) {
|
||||
return request ? APIRequestContextDispatcher.from(scope, request) : void 0;
|
||||
}
|
||||
async storageState(params, progress) {
|
||||
return await this._object.storageState(progress, params.indexedDB);
|
||||
}
|
||||
async dispose(params, progress) {
|
||||
progress.metadata.potentiallyClosesScope = true;
|
||||
await this._object.dispose(params);
|
||||
this._dispose();
|
||||
}
|
||||
async fetch(params, progress) {
|
||||
const fetchResponse = await this._object.fetch(progress, params);
|
||||
return {
|
||||
response: {
|
||||
url: fetchResponse.url,
|
||||
status: fetchResponse.status,
|
||||
statusText: fetchResponse.statusText,
|
||||
headers: fetchResponse.headers,
|
||||
fetchUid: fetchResponse.fetchUid
|
||||
}
|
||||
};
|
||||
}
|
||||
async fetchResponseBody(params, progress) {
|
||||
return { binary: this._object.fetchResponses.get(params.fetchUid) };
|
||||
}
|
||||
async fetchLog(params, progress) {
|
||||
const log = this._object.fetchLog.get(params.fetchUid) || [];
|
||||
return { log };
|
||||
}
|
||||
async disposeAPIResponse(params, progress) {
|
||||
this._object.disposeResponse(params.fetchUid);
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
APIRequestContextDispatcher,
|
||||
RequestDispatcher,
|
||||
ResponseDispatcher,
|
||||
RouteDispatcher,
|
||||
WebSocketDispatcher
|
||||
});
|
377
node_modules/playwright-core/lib/server/dispatchers/pageDispatcher.js
generated
vendored
Normal file
377
node_modules/playwright-core/lib/server/dispatchers/pageDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,377 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var pageDispatcher_exports = {};
|
||||
__export(pageDispatcher_exports, {
|
||||
BindingCallDispatcher: () => BindingCallDispatcher,
|
||||
PageDispatcher: () => PageDispatcher,
|
||||
WorkerDispatcher: () => WorkerDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(pageDispatcher_exports);
|
||||
var import_page = require("../page");
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_errors = require("../errors");
|
||||
var import_artifactDispatcher = require("./artifactDispatcher");
|
||||
var import_elementHandlerDispatcher = require("./elementHandlerDispatcher");
|
||||
var import_frameDispatcher = require("./frameDispatcher");
|
||||
var import_jsHandleDispatcher = require("./jsHandleDispatcher");
|
||||
var import_networkDispatchers = require("./networkDispatchers");
|
||||
var import_networkDispatchers2 = require("./networkDispatchers");
|
||||
var import_networkDispatchers3 = require("./networkDispatchers");
|
||||
var import_webSocketRouteDispatcher = require("./webSocketRouteDispatcher");
|
||||
var import_instrumentation = require("../instrumentation");
|
||||
var import_urlMatch = require("../../utils/isomorphic/urlMatch");
|
||||
class PageDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(parentScope, page) {
|
||||
const mainFrame = import_frameDispatcher.FrameDispatcher.from(parentScope, page.mainFrame());
|
||||
super(parentScope, page, "Page", {
|
||||
mainFrame,
|
||||
viewportSize: page.emulatedSize()?.viewport,
|
||||
isClosed: page.isClosed(),
|
||||
opener: PageDispatcher.fromNullable(parentScope, page.opener())
|
||||
});
|
||||
this._type_EventTarget = true;
|
||||
this._type_Page = true;
|
||||
this._subscriptions = /* @__PURE__ */ new Set();
|
||||
this._webSocketInterceptionPatterns = [];
|
||||
this._bindings = [];
|
||||
this._initScripts = [];
|
||||
this._interceptionUrlMatchers = [];
|
||||
this._locatorHandlers = /* @__PURE__ */ new Set();
|
||||
this._jsCoverageActive = false;
|
||||
this._cssCoverageActive = false;
|
||||
this.adopt(mainFrame);
|
||||
this._page = page;
|
||||
this._requestInterceptor = (route, request) => {
|
||||
const matchesSome = this._interceptionUrlMatchers.some((urlMatch) => (0, import_urlMatch.urlMatches)(this._page.browserContext._options.baseURL, request.url(), urlMatch));
|
||||
if (!matchesSome) {
|
||||
route.continue({ isFallback: true }).catch(() => {
|
||||
});
|
||||
return;
|
||||
}
|
||||
this._dispatchEvent("route", { route: new import_networkDispatchers3.RouteDispatcher(import_networkDispatchers.RequestDispatcher.from(this.parentScope(), request), route) });
|
||||
};
|
||||
this.addObjectListener(import_page.Page.Events.Close, () => {
|
||||
this._dispatchEvent("close");
|
||||
this._dispose();
|
||||
});
|
||||
this.addObjectListener(import_page.Page.Events.Crash, () => this._dispatchEvent("crash"));
|
||||
this.addObjectListener(import_page.Page.Events.Download, (download) => {
|
||||
this._dispatchEvent("download", { url: download.url, suggestedFilename: download.suggestedFilename(), artifact: import_artifactDispatcher.ArtifactDispatcher.from(parentScope, download.artifact) });
|
||||
});
|
||||
this.addObjectListener(import_page.Page.Events.EmulatedSizeChanged, () => this._dispatchEvent("viewportSizeChanged", { viewportSize: page.emulatedSize()?.viewport }));
|
||||
this.addObjectListener(import_page.Page.Events.FileChooser, (fileChooser) => this._dispatchEvent("fileChooser", {
|
||||
element: import_elementHandlerDispatcher.ElementHandleDispatcher.from(mainFrame, fileChooser.element()),
|
||||
isMultiple: fileChooser.isMultiple()
|
||||
}));
|
||||
this.addObjectListener(import_page.Page.Events.FrameAttached, (frame) => this._onFrameAttached(frame));
|
||||
this.addObjectListener(import_page.Page.Events.FrameDetached, (frame) => this._onFrameDetached(frame));
|
||||
this.addObjectListener(import_page.Page.Events.LocatorHandlerTriggered, (uid) => this._dispatchEvent("locatorHandlerTriggered", { uid }));
|
||||
this.addObjectListener(import_page.Page.Events.WebSocket, (webSocket) => this._dispatchEvent("webSocket", { webSocket: new import_networkDispatchers3.WebSocketDispatcher(this, webSocket) }));
|
||||
this.addObjectListener(import_page.Page.Events.Worker, (worker) => this._dispatchEvent("worker", { worker: new WorkerDispatcher(this, worker) }));
|
||||
this.addObjectListener(import_page.Page.Events.Video, (artifact) => this._dispatchEvent("video", { artifact: import_artifactDispatcher.ArtifactDispatcher.from(parentScope, artifact) }));
|
||||
if (page.video)
|
||||
this._dispatchEvent("video", { artifact: import_artifactDispatcher.ArtifactDispatcher.from(this.parentScope(), page.video) });
|
||||
const frames = page.frameManager.frames();
|
||||
for (let i = 1; i < frames.length; i++)
|
||||
this._onFrameAttached(frames[i]);
|
||||
}
|
||||
static from(parentScope, page) {
|
||||
return PageDispatcher.fromNullable(parentScope, page);
|
||||
}
|
||||
static fromNullable(parentScope, page) {
|
||||
if (!page)
|
||||
return void 0;
|
||||
const result = parentScope.connection.existingDispatcher(page);
|
||||
return result || new PageDispatcher(parentScope, page);
|
||||
}
|
||||
page() {
|
||||
return this._page;
|
||||
}
|
||||
async exposeBinding(params, progress) {
|
||||
const binding = await this._page.exposeBinding(progress, params.name, !!params.needsHandle, (source, ...args) => {
|
||||
if (this._disposed)
|
||||
return;
|
||||
const binding2 = new BindingCallDispatcher(this, params.name, !!params.needsHandle, source, args);
|
||||
this._dispatchEvent("bindingCall", { binding: binding2 });
|
||||
return binding2.promise();
|
||||
});
|
||||
this._bindings.push(binding);
|
||||
}
|
||||
async setExtraHTTPHeaders(params, progress) {
|
||||
await this._page.setExtraHTTPHeaders(progress, params.headers);
|
||||
}
|
||||
async reload(params, progress) {
|
||||
return { response: import_networkDispatchers2.ResponseDispatcher.fromNullable(this.parentScope(), await this._page.reload(progress, params)) };
|
||||
}
|
||||
async goBack(params, progress) {
|
||||
return { response: import_networkDispatchers2.ResponseDispatcher.fromNullable(this.parentScope(), await this._page.goBack(progress, params)) };
|
||||
}
|
||||
async goForward(params, progress) {
|
||||
return { response: import_networkDispatchers2.ResponseDispatcher.fromNullable(this.parentScope(), await this._page.goForward(progress, params)) };
|
||||
}
|
||||
async requestGC(params, progress) {
|
||||
await progress.race(this._page.requestGC());
|
||||
}
|
||||
async registerLocatorHandler(params, progress) {
|
||||
const uid = this._page.registerLocatorHandler(params.selector, params.noWaitAfter);
|
||||
this._locatorHandlers.add(uid);
|
||||
return { uid };
|
||||
}
|
||||
async resolveLocatorHandlerNoReply(params, progress) {
|
||||
this._page.resolveLocatorHandler(params.uid, params.remove);
|
||||
}
|
||||
async unregisterLocatorHandler(params, progress) {
|
||||
this._page.unregisterLocatorHandler(params.uid);
|
||||
this._locatorHandlers.delete(params.uid);
|
||||
}
|
||||
async emulateMedia(params, progress) {
|
||||
await this._page.emulateMedia(progress, {
|
||||
media: params.media,
|
||||
colorScheme: params.colorScheme,
|
||||
reducedMotion: params.reducedMotion,
|
||||
forcedColors: params.forcedColors,
|
||||
contrast: params.contrast
|
||||
});
|
||||
}
|
||||
async setViewportSize(params, progress) {
|
||||
await this._page.setViewportSize(progress, params.viewportSize);
|
||||
}
|
||||
async addInitScript(params, progress) {
|
||||
this._initScripts.push(await this._page.addInitScript(progress, params.source));
|
||||
}
|
||||
async setNetworkInterceptionPatterns(params, progress) {
|
||||
const hadMatchers = this._interceptionUrlMatchers.length > 0;
|
||||
if (!params.patterns.length) {
|
||||
if (hadMatchers)
|
||||
await this._page.removeRequestInterceptor(this._requestInterceptor);
|
||||
this._interceptionUrlMatchers = [];
|
||||
} else {
|
||||
this._interceptionUrlMatchers = params.patterns.map((pattern) => pattern.regexSource ? new RegExp(pattern.regexSource, pattern.regexFlags) : pattern.glob);
|
||||
if (!hadMatchers)
|
||||
await this._page.addRequestInterceptor(progress, this._requestInterceptor);
|
||||
}
|
||||
}
|
||||
async setWebSocketInterceptionPatterns(params, progress) {
|
||||
this._webSocketInterceptionPatterns = params.patterns;
|
||||
if (params.patterns.length && !this._routeWebSocketInitScript)
|
||||
this._routeWebSocketInitScript = await import_webSocketRouteDispatcher.WebSocketRouteDispatcher.install(progress, this.connection, this._page);
|
||||
}
|
||||
async expectScreenshot(params, progress) {
|
||||
const mask = (params.mask || []).map(({ frame, selector }) => ({
|
||||
frame: frame._object,
|
||||
selector
|
||||
}));
|
||||
const locator = params.locator ? {
|
||||
frame: params.locator.frame._object,
|
||||
selector: params.locator.selector
|
||||
} : void 0;
|
||||
return await this._page.expectScreenshot(progress, {
|
||||
...params,
|
||||
locator,
|
||||
mask
|
||||
});
|
||||
}
|
||||
async screenshot(params, progress) {
|
||||
const mask = (params.mask || []).map(({ frame, selector }) => ({
|
||||
frame: frame._object,
|
||||
selector
|
||||
}));
|
||||
return { binary: await this._page.screenshot(progress, { ...params, mask }) };
|
||||
}
|
||||
async close(params, progress) {
|
||||
if (!params.runBeforeUnload)
|
||||
progress.metadata.potentiallyClosesScope = true;
|
||||
await this._page.close(params);
|
||||
}
|
||||
async updateSubscription(params, progress) {
|
||||
if (params.event === "fileChooser")
|
||||
await this._page.setFileChooserInterceptedBy(params.enabled, this);
|
||||
if (params.enabled)
|
||||
this._subscriptions.add(params.event);
|
||||
else
|
||||
this._subscriptions.delete(params.event);
|
||||
}
|
||||
async keyboardDown(params, progress) {
|
||||
await this._page.keyboard.down(progress, params.key);
|
||||
}
|
||||
async keyboardUp(params, progress) {
|
||||
await this._page.keyboard.up(progress, params.key);
|
||||
}
|
||||
async keyboardInsertText(params, progress) {
|
||||
await this._page.keyboard.insertText(progress, params.text);
|
||||
}
|
||||
async keyboardType(params, progress) {
|
||||
await this._page.keyboard.type(progress, params.text, params);
|
||||
}
|
||||
async keyboardPress(params, progress) {
|
||||
await this._page.keyboard.press(progress, params.key, params);
|
||||
}
|
||||
async mouseMove(params, progress) {
|
||||
progress.metadata.point = { x: params.x, y: params.y };
|
||||
await this._page.mouse.move(progress, params.x, params.y, params);
|
||||
}
|
||||
async mouseDown(params, progress) {
|
||||
progress.metadata.point = this._page.mouse.currentPoint();
|
||||
await this._page.mouse.down(progress, params);
|
||||
}
|
||||
async mouseUp(params, progress) {
|
||||
progress.metadata.point = this._page.mouse.currentPoint();
|
||||
await this._page.mouse.up(progress, params);
|
||||
}
|
||||
async mouseClick(params, progress) {
|
||||
progress.metadata.point = { x: params.x, y: params.y };
|
||||
await this._page.mouse.click(progress, params.x, params.y, params);
|
||||
}
|
||||
async mouseWheel(params, progress) {
|
||||
await this._page.mouse.wheel(progress, params.deltaX, params.deltaY);
|
||||
}
|
||||
async touchscreenTap(params, progress) {
|
||||
progress.metadata.point = { x: params.x, y: params.y };
|
||||
await this._page.touchscreen.tap(progress, params.x, params.y);
|
||||
}
|
||||
async accessibilitySnapshot(params, progress) {
|
||||
const rootAXNode = await progress.race(this._page.accessibility.snapshot({
|
||||
interestingOnly: params.interestingOnly,
|
||||
root: params.root ? params.root._elementHandle : void 0
|
||||
}));
|
||||
return { rootAXNode: rootAXNode || void 0 };
|
||||
}
|
||||
async pdf(params, progress) {
|
||||
if (!this._page.pdf)
|
||||
throw new Error("PDF generation is only supported for Headless Chromium");
|
||||
const buffer = await progress.race(this._page.pdf(params));
|
||||
return { pdf: buffer };
|
||||
}
|
||||
async snapshotForAI(params, progress) {
|
||||
return { snapshot: await this._page.snapshotForAI(progress) };
|
||||
}
|
||||
async bringToFront(params, progress) {
|
||||
await progress.race(this._page.bringToFront());
|
||||
}
|
||||
async startJSCoverage(params, progress) {
|
||||
const coverage = this._page.coverage;
|
||||
await coverage.startJSCoverage(progress, params);
|
||||
this._jsCoverageActive = true;
|
||||
}
|
||||
async stopJSCoverage(params, progress) {
|
||||
this._jsCoverageActive = false;
|
||||
const coverage = this._page.coverage;
|
||||
return await coverage.stopJSCoverage();
|
||||
}
|
||||
async startCSSCoverage(params, progress) {
|
||||
const coverage = this._page.coverage;
|
||||
await coverage.startCSSCoverage(progress, params);
|
||||
this._cssCoverageActive = true;
|
||||
}
|
||||
async stopCSSCoverage(params, progress) {
|
||||
this._cssCoverageActive = false;
|
||||
const coverage = this._page.coverage;
|
||||
return await coverage.stopCSSCoverage();
|
||||
}
|
||||
_onFrameAttached(frame) {
|
||||
this._dispatchEvent("frameAttached", { frame: import_frameDispatcher.FrameDispatcher.from(this.parentScope(), frame) });
|
||||
}
|
||||
_onFrameDetached(frame) {
|
||||
this._dispatchEvent("frameDetached", { frame: import_frameDispatcher.FrameDispatcher.from(this.parentScope(), frame) });
|
||||
}
|
||||
_onDispose() {
|
||||
if (this._page.isClosedOrClosingOrCrashed())
|
||||
return;
|
||||
this._interceptionUrlMatchers = [];
|
||||
this._page.removeRequestInterceptor(this._requestInterceptor).catch(() => {
|
||||
});
|
||||
this._page.removeExposedBindings(this._bindings).catch(() => {
|
||||
});
|
||||
this._bindings = [];
|
||||
this._page.removeInitScripts(this._initScripts).catch(() => {
|
||||
});
|
||||
this._initScripts = [];
|
||||
if (this._routeWebSocketInitScript)
|
||||
import_webSocketRouteDispatcher.WebSocketRouteDispatcher.uninstall(this.connection, this._page, this._routeWebSocketInitScript).catch(() => {
|
||||
});
|
||||
this._routeWebSocketInitScript = void 0;
|
||||
for (const uid of this._locatorHandlers)
|
||||
this._page.unregisterLocatorHandler(uid);
|
||||
this._locatorHandlers.clear();
|
||||
this._page.setFileChooserInterceptedBy(false, this).catch(() => {
|
||||
});
|
||||
if (this._jsCoverageActive)
|
||||
this._page.coverage.stopJSCoverage().catch(() => {
|
||||
});
|
||||
this._jsCoverageActive = false;
|
||||
if (this._cssCoverageActive)
|
||||
this._page.coverage.stopCSSCoverage().catch(() => {
|
||||
});
|
||||
this._cssCoverageActive = false;
|
||||
}
|
||||
}
|
||||
class WorkerDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, worker) {
|
||||
super(scope, worker, "Worker", {
|
||||
url: worker.url
|
||||
});
|
||||
this._type_Worker = true;
|
||||
this.addObjectListener(import_page.Worker.Events.Close, () => this._dispatchEvent("close"));
|
||||
}
|
||||
static fromNullable(scope, worker) {
|
||||
if (!worker)
|
||||
return void 0;
|
||||
const result = scope.connection.existingDispatcher(worker);
|
||||
return result || new WorkerDispatcher(scope, worker);
|
||||
}
|
||||
async evaluateExpression(params, progress) {
|
||||
return { value: (0, import_jsHandleDispatcher.serializeResult)(await progress.race(this._object.evaluateExpression(params.expression, params.isFunction, (0, import_jsHandleDispatcher.parseArgument)(params.arg)))) };
|
||||
}
|
||||
async evaluateExpressionHandle(params, progress) {
|
||||
return { handle: import_jsHandleDispatcher.JSHandleDispatcher.fromJSHandle(this, await progress.race(this._object.evaluateExpressionHandle(params.expression, params.isFunction, (0, import_jsHandleDispatcher.parseArgument)(params.arg)))) };
|
||||
}
|
||||
}
|
||||
class BindingCallDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, name, needsHandle, source, args) {
|
||||
const frameDispatcher = import_frameDispatcher.FrameDispatcher.from(scope.parentScope(), source.frame);
|
||||
super(scope, new import_instrumentation.SdkObject(scope._object, "bindingCall"), "BindingCall", {
|
||||
frame: frameDispatcher,
|
||||
name,
|
||||
args: needsHandle ? void 0 : args.map(import_jsHandleDispatcher.serializeResult),
|
||||
handle: needsHandle ? import_elementHandlerDispatcher.ElementHandleDispatcher.fromJSOrElementHandle(frameDispatcher, args[0]) : void 0
|
||||
});
|
||||
this._type_BindingCall = true;
|
||||
this._promise = new Promise((resolve, reject) => {
|
||||
this._resolve = resolve;
|
||||
this._reject = reject;
|
||||
});
|
||||
}
|
||||
promise() {
|
||||
return this._promise;
|
||||
}
|
||||
async resolve(params, progress) {
|
||||
this._resolve((0, import_jsHandleDispatcher.parseArgument)(params.result));
|
||||
this._dispose();
|
||||
}
|
||||
async reject(params, progress) {
|
||||
this._reject((0, import_errors.parseError)(params.error));
|
||||
this._dispose();
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
BindingCallDispatcher,
|
||||
PageDispatcher,
|
||||
WorkerDispatcher
|
||||
});
|
112
node_modules/playwright-core/lib/server/dispatchers/playwrightDispatcher.js
generated
vendored
Normal file
112
node_modules/playwright-core/lib/server/dispatchers/playwrightDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var playwrightDispatcher_exports = {};
|
||||
__export(playwrightDispatcher_exports, {
|
||||
PlaywrightDispatcher: () => PlaywrightDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(playwrightDispatcher_exports);
|
||||
var import_socksProxy = require("../utils/socksProxy");
|
||||
var import_fetch = require("../fetch");
|
||||
var import_androidDispatcher = require("./androidDispatcher");
|
||||
var import_androidDispatcher2 = require("./androidDispatcher");
|
||||
var import_browserDispatcher = require("./browserDispatcher");
|
||||
var import_browserTypeDispatcher = require("./browserTypeDispatcher");
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_electronDispatcher = require("./electronDispatcher");
|
||||
var import_localUtilsDispatcher = require("./localUtilsDispatcher");
|
||||
var import_networkDispatchers = require("./networkDispatchers");
|
||||
var import_instrumentation = require("../instrumentation");
|
||||
var import_eventsHelper = require("../utils/eventsHelper");
|
||||
class PlaywrightDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, playwright, options = {}) {
|
||||
const denyLaunch = options.denyLaunch ?? false;
|
||||
const chromium = new import_browserTypeDispatcher.BrowserTypeDispatcher(scope, playwright.chromium, denyLaunch);
|
||||
const firefox = new import_browserTypeDispatcher.BrowserTypeDispatcher(scope, playwright.firefox, denyLaunch);
|
||||
const webkit = new import_browserTypeDispatcher.BrowserTypeDispatcher(scope, playwright.webkit, denyLaunch);
|
||||
const _bidiChromium = new import_browserTypeDispatcher.BrowserTypeDispatcher(scope, playwright._bidiChromium, denyLaunch);
|
||||
const _bidiFirefox = new import_browserTypeDispatcher.BrowserTypeDispatcher(scope, playwright._bidiFirefox, denyLaunch);
|
||||
const android = new import_androidDispatcher.AndroidDispatcher(scope, playwright.android);
|
||||
const initializer = {
|
||||
chromium,
|
||||
firefox,
|
||||
webkit,
|
||||
_bidiChromium,
|
||||
_bidiFirefox,
|
||||
android,
|
||||
electron: new import_electronDispatcher.ElectronDispatcher(scope, playwright.electron, denyLaunch),
|
||||
utils: playwright.options.isServer ? void 0 : new import_localUtilsDispatcher.LocalUtilsDispatcher(scope, playwright),
|
||||
socksSupport: options.socksProxy ? new SocksSupportDispatcher(scope, playwright, options.socksProxy) : void 0
|
||||
};
|
||||
let browserDispatcher;
|
||||
if (options.preLaunchedBrowser) {
|
||||
const browserTypeDispatcher = initializer[options.preLaunchedBrowser.options.name];
|
||||
browserDispatcher = new import_browserDispatcher.BrowserDispatcher(browserTypeDispatcher, options.preLaunchedBrowser, {
|
||||
ignoreStopAndKill: true,
|
||||
isolateContexts: !options.sharedBrowser
|
||||
});
|
||||
initializer.preLaunchedBrowser = browserDispatcher;
|
||||
}
|
||||
if (options.preLaunchedAndroidDevice)
|
||||
initializer.preConnectedAndroidDevice = new import_androidDispatcher2.AndroidDeviceDispatcher(android, options.preLaunchedAndroidDevice);
|
||||
super(scope, playwright, "Playwright", initializer);
|
||||
this._type_Playwright = true;
|
||||
this._browserDispatcher = browserDispatcher;
|
||||
}
|
||||
async newRequest(params, progress) {
|
||||
const request = new import_fetch.GlobalAPIRequestContext(this._object, params);
|
||||
return { request: import_networkDispatchers.APIRequestContextDispatcher.from(this.parentScope(), request) };
|
||||
}
|
||||
async cleanup() {
|
||||
await this._browserDispatcher?.cleanupContexts();
|
||||
}
|
||||
}
|
||||
class SocksSupportDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, parent, socksProxy) {
|
||||
super(scope, new import_instrumentation.SdkObject(parent, "socksSupport"), "SocksSupport", {});
|
||||
this._type_SocksSupport = true;
|
||||
this._socksProxy = socksProxy;
|
||||
this._socksListeners = [
|
||||
import_eventsHelper.eventsHelper.addEventListener(socksProxy, import_socksProxy.SocksProxy.Events.SocksRequested, (payload) => this._dispatchEvent("socksRequested", payload)),
|
||||
import_eventsHelper.eventsHelper.addEventListener(socksProxy, import_socksProxy.SocksProxy.Events.SocksData, (payload) => this._dispatchEvent("socksData", payload)),
|
||||
import_eventsHelper.eventsHelper.addEventListener(socksProxy, import_socksProxy.SocksProxy.Events.SocksClosed, (payload) => this._dispatchEvent("socksClosed", payload))
|
||||
];
|
||||
}
|
||||
async socksConnected(params, progress) {
|
||||
this._socksProxy?.socketConnected(params);
|
||||
}
|
||||
async socksFailed(params, progress) {
|
||||
this._socksProxy?.socketFailed(params);
|
||||
}
|
||||
async socksData(params, progress) {
|
||||
this._socksProxy?.sendSocketData(params);
|
||||
}
|
||||
async socksError(params, progress) {
|
||||
this._socksProxy?.sendSocketError(params);
|
||||
}
|
||||
async socksEnd(params, progress) {
|
||||
this._socksProxy?.sendSocketEnd(params);
|
||||
}
|
||||
_onDispose() {
|
||||
import_eventsHelper.eventsHelper.removeEventListeners(this._socksListeners);
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
PlaywrightDispatcher
|
||||
});
|
67
node_modules/playwright-core/lib/server/dispatchers/streamDispatcher.js
generated
vendored
Normal file
67
node_modules/playwright-core/lib/server/dispatchers/streamDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var streamDispatcher_exports = {};
|
||||
__export(streamDispatcher_exports, {
|
||||
StreamDispatcher: () => StreamDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(streamDispatcher_exports);
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_manualPromise = require("../../utils/isomorphic/manualPromise");
|
||||
var import_instrumentation = require("../instrumentation");
|
||||
class StreamSdkObject extends import_instrumentation.SdkObject {
|
||||
constructor(parent, stream) {
|
||||
super(parent, "stream");
|
||||
this.stream = stream;
|
||||
}
|
||||
}
|
||||
class StreamDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, stream) {
|
||||
super(scope, new StreamSdkObject(scope._object, stream), "Stream", {});
|
||||
this._type_Stream = true;
|
||||
this._ended = false;
|
||||
stream.once("end", () => this._ended = true);
|
||||
stream.once("error", () => this._ended = true);
|
||||
}
|
||||
async read(params, progress) {
|
||||
const stream = this._object.stream;
|
||||
if (this._ended)
|
||||
return { binary: Buffer.from("") };
|
||||
if (!stream.readableLength) {
|
||||
const readyPromise = new import_manualPromise.ManualPromise();
|
||||
const done = () => readyPromise.resolve();
|
||||
stream.on("readable", done);
|
||||
stream.on("end", done);
|
||||
stream.on("error", done);
|
||||
await progress.race(readyPromise).finally(() => {
|
||||
stream.off("readable", done);
|
||||
stream.off("end", done);
|
||||
stream.off("error", done);
|
||||
});
|
||||
}
|
||||
const buffer = stream.read(Math.min(stream.readableLength, params.size || stream.readableLength));
|
||||
return { binary: buffer || Buffer.from("") };
|
||||
}
|
||||
async close(params, progress) {
|
||||
this._object.stream.destroy();
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
StreamDispatcher
|
||||
});
|
68
node_modules/playwright-core/lib/server/dispatchers/tracingDispatcher.js
generated
vendored
Normal file
68
node_modules/playwright-core/lib/server/dispatchers/tracingDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var tracingDispatcher_exports = {};
|
||||
__export(tracingDispatcher_exports, {
|
||||
TracingDispatcher: () => TracingDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(tracingDispatcher_exports);
|
||||
var import_artifactDispatcher = require("./artifactDispatcher");
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
class TracingDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, tracing) {
|
||||
super(scope, tracing, "Tracing", {});
|
||||
this._type_Tracing = true;
|
||||
this._started = false;
|
||||
}
|
||||
static from(scope, tracing) {
|
||||
const result = scope.connection.existingDispatcher(tracing);
|
||||
return result || new TracingDispatcher(scope, tracing);
|
||||
}
|
||||
async tracingStart(params, progress) {
|
||||
this._object.start(params);
|
||||
this._started = true;
|
||||
}
|
||||
async tracingStartChunk(params, progress) {
|
||||
return await this._object.startChunk(progress, params);
|
||||
}
|
||||
async tracingGroup(params, progress) {
|
||||
const { name, location } = params;
|
||||
this._object.group(name, location, progress.metadata);
|
||||
}
|
||||
async tracingGroupEnd(params, progress) {
|
||||
this._object.groupEnd();
|
||||
}
|
||||
async tracingStopChunk(params, progress) {
|
||||
const { artifact, entries } = await this._object.stopChunk(progress, params);
|
||||
return { artifact: artifact ? import_artifactDispatcher.ArtifactDispatcher.from(this, artifact) : void 0, entries };
|
||||
}
|
||||
async tracingStop(params, progress) {
|
||||
this._started = false;
|
||||
await this._object.stop(progress);
|
||||
}
|
||||
_onDispose() {
|
||||
if (this._started)
|
||||
this._object.stopChunk(void 0, { mode: "discard" }).then(() => this._object.stop(void 0)).catch(() => {
|
||||
});
|
||||
this._started = false;
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
TracingDispatcher
|
||||
});
|
165
node_modules/playwright-core/lib/server/dispatchers/webSocketRouteDispatcher.js
generated
vendored
Normal file
165
node_modules/playwright-core/lib/server/dispatchers/webSocketRouteDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var webSocketRouteDispatcher_exports = {};
|
||||
__export(webSocketRouteDispatcher_exports, {
|
||||
WebSocketRouteDispatcher: () => WebSocketRouteDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(webSocketRouteDispatcher_exports);
|
||||
var import_page = require("../page");
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_pageDispatcher = require("./pageDispatcher");
|
||||
var rawWebSocketMockSource = __toESM(require("../../generated/webSocketMockSource"));
|
||||
var import_instrumentation = require("../instrumentation");
|
||||
var import_urlMatch = require("../../utils/isomorphic/urlMatch");
|
||||
var import_eventsHelper = require("../utils/eventsHelper");
|
||||
class WebSocketRouteDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, id, url, frame) {
|
||||
super(scope, new import_instrumentation.SdkObject(scope._object, "webSocketRoute"), "WebSocketRoute", { url });
|
||||
this._type_WebSocketRoute = true;
|
||||
this._id = id;
|
||||
this._frame = frame;
|
||||
this._eventListeners.push(
|
||||
// When the frame navigates or detaches, there will be no more communication
|
||||
// from the mock websocket, so pretend like it was closed.
|
||||
import_eventsHelper.eventsHelper.addEventListener(frame._page, import_page.Page.Events.InternalFrameNavigatedToNewDocument, (frame2) => {
|
||||
if (frame2 === this._frame)
|
||||
this._executionContextGone();
|
||||
}),
|
||||
import_eventsHelper.eventsHelper.addEventListener(frame._page, import_page.Page.Events.FrameDetached, (frame2) => {
|
||||
if (frame2 === this._frame)
|
||||
this._executionContextGone();
|
||||
}),
|
||||
import_eventsHelper.eventsHelper.addEventListener(frame._page, import_page.Page.Events.Close, () => this._executionContextGone()),
|
||||
import_eventsHelper.eventsHelper.addEventListener(frame._page, import_page.Page.Events.Crash, () => this._executionContextGone())
|
||||
);
|
||||
WebSocketRouteDispatcher._idToDispatcher.set(this._id, this);
|
||||
scope._dispatchEvent("webSocketRoute", { webSocketRoute: this });
|
||||
}
|
||||
static {
|
||||
this._idToDispatcher = /* @__PURE__ */ new Map();
|
||||
}
|
||||
static async install(progress, connection, target) {
|
||||
const context = target instanceof import_page.Page ? target.browserContext : target;
|
||||
let data = context.getBindingClient(kBindingName);
|
||||
if (data && data.connection !== connection)
|
||||
throw new Error("Another client is already routing WebSockets");
|
||||
if (!data) {
|
||||
data = { counter: 0, connection, binding: null };
|
||||
data.binding = await context.exposeBinding(progress, kBindingName, false, (source, payload) => {
|
||||
if (payload.type === "onCreate") {
|
||||
const contextDispatcher = connection.existingDispatcher(context);
|
||||
const pageDispatcher = contextDispatcher ? import_pageDispatcher.PageDispatcher.fromNullable(contextDispatcher, source.page) : void 0;
|
||||
let scope;
|
||||
if (pageDispatcher && matchesPattern(pageDispatcher, context._options.baseURL, payload.url))
|
||||
scope = pageDispatcher;
|
||||
else if (contextDispatcher && matchesPattern(contextDispatcher, context._options.baseURL, payload.url))
|
||||
scope = contextDispatcher;
|
||||
if (scope) {
|
||||
new WebSocketRouteDispatcher(scope, payload.id, payload.url, source.frame);
|
||||
} else {
|
||||
const request = { id: payload.id, type: "passthrough" };
|
||||
source.frame.evaluateExpression(`globalThis.__pwWebSocketDispatch(${JSON.stringify(request)})`).catch(() => {
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
const dispatcher = WebSocketRouteDispatcher._idToDispatcher.get(payload.id);
|
||||
if (payload.type === "onMessageFromPage")
|
||||
dispatcher?._dispatchEvent("messageFromPage", { message: payload.data.data, isBase64: payload.data.isBase64 });
|
||||
if (payload.type === "onMessageFromServer")
|
||||
dispatcher?._dispatchEvent("messageFromServer", { message: payload.data.data, isBase64: payload.data.isBase64 });
|
||||
if (payload.type === "onClosePage")
|
||||
dispatcher?._dispatchEvent("closePage", { code: payload.code, reason: payload.reason, wasClean: payload.wasClean });
|
||||
if (payload.type === "onCloseServer")
|
||||
dispatcher?._dispatchEvent("closeServer", { code: payload.code, reason: payload.reason, wasClean: payload.wasClean });
|
||||
}, data);
|
||||
}
|
||||
++data.counter;
|
||||
return await target.addInitScript(progress, `
|
||||
(() => {
|
||||
const module = {};
|
||||
${rawWebSocketMockSource.source}
|
||||
(module.exports.inject())(globalThis);
|
||||
})();
|
||||
`);
|
||||
}
|
||||
static async uninstall(connection, target, initScript) {
|
||||
const context = target instanceof import_page.Page ? target.browserContext : target;
|
||||
const data = context.getBindingClient(kBindingName);
|
||||
if (!data || data.connection !== connection)
|
||||
return;
|
||||
if (--data.counter <= 0)
|
||||
await context.removeExposedBindings([data.binding]);
|
||||
await target.removeInitScripts([initScript]);
|
||||
}
|
||||
async connect(params, progress) {
|
||||
await this._evaluateAPIRequest(progress, { id: this._id, type: "connect" });
|
||||
}
|
||||
async ensureOpened(params, progress) {
|
||||
await this._evaluateAPIRequest(progress, { id: this._id, type: "ensureOpened" });
|
||||
}
|
||||
async sendToPage(params, progress) {
|
||||
await this._evaluateAPIRequest(progress, { id: this._id, type: "sendToPage", data: { data: params.message, isBase64: params.isBase64 } });
|
||||
}
|
||||
async sendToServer(params, progress) {
|
||||
await this._evaluateAPIRequest(progress, { id: this._id, type: "sendToServer", data: { data: params.message, isBase64: params.isBase64 } });
|
||||
}
|
||||
async closePage(params, progress) {
|
||||
await this._evaluateAPIRequest(progress, { id: this._id, type: "closePage", code: params.code, reason: params.reason, wasClean: params.wasClean });
|
||||
}
|
||||
async closeServer(params, progress) {
|
||||
await this._evaluateAPIRequest(progress, { id: this._id, type: "closeServer", code: params.code, reason: params.reason, wasClean: params.wasClean });
|
||||
}
|
||||
async _evaluateAPIRequest(progress, request) {
|
||||
await progress.race(this._frame.evaluateExpression(`globalThis.__pwWebSocketDispatch(${JSON.stringify(request)})`).catch(() => {
|
||||
}));
|
||||
}
|
||||
_onDispose() {
|
||||
WebSocketRouteDispatcher._idToDispatcher.delete(this._id);
|
||||
}
|
||||
_executionContextGone() {
|
||||
if (!this._disposed) {
|
||||
this._dispatchEvent("closePage", { wasClean: true });
|
||||
this._dispatchEvent("closeServer", { wasClean: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
function matchesPattern(dispatcher, baseURL, url) {
|
||||
for (const pattern of dispatcher._webSocketInterceptionPatterns || []) {
|
||||
const urlMatch = pattern.regexSource ? new RegExp(pattern.regexSource, pattern.regexFlags) : pattern.glob;
|
||||
if ((0, import_urlMatch.urlMatches)(baseURL, url, urlMatch, true))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const kBindingName = "__pwWebSocketBinding";
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
WebSocketRouteDispatcher
|
||||
});
|
79
node_modules/playwright-core/lib/server/dispatchers/writableStreamDispatcher.js
generated
vendored
Normal file
79
node_modules/playwright-core/lib/server/dispatchers/writableStreamDispatcher.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var writableStreamDispatcher_exports = {};
|
||||
__export(writableStreamDispatcher_exports, {
|
||||
WritableStreamDispatcher: () => WritableStreamDispatcher
|
||||
});
|
||||
module.exports = __toCommonJS(writableStreamDispatcher_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var import_dispatcher = require("./dispatcher");
|
||||
var import_instrumentation = require("../instrumentation");
|
||||
class WritableStreamSdkObject extends import_instrumentation.SdkObject {
|
||||
constructor(parent, streamOrDirectory, lastModifiedMs) {
|
||||
super(parent, "stream");
|
||||
this.streamOrDirectory = streamOrDirectory;
|
||||
this.lastModifiedMs = lastModifiedMs;
|
||||
}
|
||||
}
|
||||
class WritableStreamDispatcher extends import_dispatcher.Dispatcher {
|
||||
constructor(scope, streamOrDirectory, lastModifiedMs) {
|
||||
super(scope, new WritableStreamSdkObject(scope._object, streamOrDirectory, lastModifiedMs), "WritableStream", {});
|
||||
this._type_WritableStream = true;
|
||||
}
|
||||
async write(params, progress) {
|
||||
if (typeof this._object.streamOrDirectory === "string")
|
||||
throw new Error("Cannot write to a directory");
|
||||
const stream = this._object.streamOrDirectory;
|
||||
await progress.race(new Promise((fulfill, reject) => {
|
||||
stream.write(params.binary, (error) => {
|
||||
if (error)
|
||||
reject(error);
|
||||
else
|
||||
fulfill();
|
||||
});
|
||||
}));
|
||||
}
|
||||
async close(params, progress) {
|
||||
if (typeof this._object.streamOrDirectory === "string")
|
||||
throw new Error("Cannot close a directory");
|
||||
const stream = this._object.streamOrDirectory;
|
||||
await progress.race(new Promise((fulfill) => stream.end(fulfill)));
|
||||
if (this._object.lastModifiedMs)
|
||||
await progress.race(import_fs.default.promises.utimes(this.path(), new Date(this._object.lastModifiedMs), new Date(this._object.lastModifiedMs)));
|
||||
}
|
||||
path() {
|
||||
if (typeof this._object.streamOrDirectory === "string")
|
||||
return this._object.streamOrDirectory;
|
||||
return this._object.streamOrDirectory.path;
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
WritableStreamDispatcher
|
||||
});
|
Reference in New Issue
Block a user