First Commit
This commit is contained in:
44
node_modules/playwright-core/lib/server/utils/ascii.js
generated
vendored
Normal file
44
node_modules/playwright-core/lib/server/utils/ascii.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 ascii_exports = {};
|
||||
__export(ascii_exports, {
|
||||
jsonStringifyForceASCII: () => jsonStringifyForceASCII,
|
||||
wrapInASCIIBox: () => wrapInASCIIBox
|
||||
});
|
||||
module.exports = __toCommonJS(ascii_exports);
|
||||
function wrapInASCIIBox(text, padding = 0) {
|
||||
const lines = text.split("\n");
|
||||
const maxLength = Math.max(...lines.map((line) => line.length));
|
||||
return [
|
||||
"\u2554" + "\u2550".repeat(maxLength + padding * 2) + "\u2557",
|
||||
...lines.map((line) => "\u2551" + " ".repeat(padding) + line + " ".repeat(maxLength - line.length + padding) + "\u2551"),
|
||||
"\u255A" + "\u2550".repeat(maxLength + padding * 2) + "\u255D"
|
||||
].join("\n");
|
||||
}
|
||||
function jsonStringifyForceASCII(object) {
|
||||
return JSON.stringify(object).replace(
|
||||
/[\u007f-\uffff]/g,
|
||||
(c) => "\\u" + ("0000" + c.charCodeAt(0).toString(16)).slice(-4)
|
||||
);
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
jsonStringifyForceASCII,
|
||||
wrapInASCIIBox
|
||||
});
|
161
node_modules/playwright-core/lib/server/utils/comparators.js
generated
vendored
Normal file
161
node_modules/playwright-core/lib/server/utils/comparators.js
generated
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
"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 comparators_exports = {};
|
||||
__export(comparators_exports, {
|
||||
compareBuffersOrStrings: () => compareBuffersOrStrings,
|
||||
getComparator: () => getComparator
|
||||
});
|
||||
module.exports = __toCommonJS(comparators_exports);
|
||||
var import_compare = require("./image_tools/compare");
|
||||
var import_pixelmatch = __toESM(require("../../third_party/pixelmatch"));
|
||||
var import_utilsBundle = require("../../utilsBundle");
|
||||
var import_utilsBundle2 = require("../../utilsBundle");
|
||||
var import_utilsBundle3 = require("../../utilsBundle");
|
||||
function getComparator(mimeType) {
|
||||
if (mimeType === "image/png")
|
||||
return compareImages.bind(null, "image/png");
|
||||
if (mimeType === "image/jpeg")
|
||||
return compareImages.bind(null, "image/jpeg");
|
||||
if (mimeType === "text/plain")
|
||||
return compareText;
|
||||
return compareBuffersOrStrings;
|
||||
}
|
||||
const JPEG_JS_MAX_BUFFER_SIZE_IN_MB = 5 * 1024;
|
||||
function compareBuffersOrStrings(actualBuffer, expectedBuffer) {
|
||||
if (typeof actualBuffer === "string")
|
||||
return compareText(actualBuffer, expectedBuffer);
|
||||
if (!actualBuffer || !(actualBuffer instanceof Buffer))
|
||||
return { errorMessage: "Actual result should be a Buffer or a string." };
|
||||
if (Buffer.compare(actualBuffer, expectedBuffer))
|
||||
return { errorMessage: "Buffers differ" };
|
||||
return null;
|
||||
}
|
||||
function compareImages(mimeType, actualBuffer, expectedBuffer, options = {}) {
|
||||
if (!actualBuffer || !(actualBuffer instanceof Buffer))
|
||||
return { errorMessage: "Actual result should be a Buffer." };
|
||||
validateBuffer(expectedBuffer, mimeType);
|
||||
let actual = mimeType === "image/png" ? import_utilsBundle3.PNG.sync.read(actualBuffer) : import_utilsBundle.jpegjs.decode(actualBuffer, { maxMemoryUsageInMB: JPEG_JS_MAX_BUFFER_SIZE_IN_MB });
|
||||
let expected = mimeType === "image/png" ? import_utilsBundle3.PNG.sync.read(expectedBuffer) : import_utilsBundle.jpegjs.decode(expectedBuffer, { maxMemoryUsageInMB: JPEG_JS_MAX_BUFFER_SIZE_IN_MB });
|
||||
const size = { width: Math.max(expected.width, actual.width), height: Math.max(expected.height, actual.height) };
|
||||
let sizesMismatchError = "";
|
||||
if (expected.width !== actual.width || expected.height !== actual.height) {
|
||||
sizesMismatchError = `Expected an image ${expected.width}px by ${expected.height}px, received ${actual.width}px by ${actual.height}px. `;
|
||||
actual = resizeImage(actual, size);
|
||||
expected = resizeImage(expected, size);
|
||||
}
|
||||
const diff2 = new import_utilsBundle3.PNG({ width: size.width, height: size.height });
|
||||
let count;
|
||||
if (options.comparator === "ssim-cie94") {
|
||||
count = (0, import_compare.compare)(expected.data, actual.data, diff2.data, size.width, size.height, {
|
||||
// All ΔE* formulae are originally designed to have the difference of 1.0 stand for a "just noticeable difference" (JND).
|
||||
// See https://en.wikipedia.org/wiki/Color_difference#CIELAB_%CE%94E*
|
||||
maxColorDeltaE94: 1
|
||||
});
|
||||
} else if ((options.comparator ?? "pixelmatch") === "pixelmatch") {
|
||||
count = (0, import_pixelmatch.default)(expected.data, actual.data, diff2.data, size.width, size.height, {
|
||||
threshold: options.threshold ?? 0.2
|
||||
});
|
||||
} else {
|
||||
throw new Error(`Configuration specifies unknown comparator "${options.comparator}"`);
|
||||
}
|
||||
const maxDiffPixels1 = options.maxDiffPixels;
|
||||
const maxDiffPixels2 = options.maxDiffPixelRatio !== void 0 ? expected.width * expected.height * options.maxDiffPixelRatio : void 0;
|
||||
let maxDiffPixels;
|
||||
if (maxDiffPixels1 !== void 0 && maxDiffPixels2 !== void 0)
|
||||
maxDiffPixels = Math.min(maxDiffPixels1, maxDiffPixels2);
|
||||
else
|
||||
maxDiffPixels = maxDiffPixels1 ?? maxDiffPixels2 ?? 0;
|
||||
const ratio = Math.ceil(count / (expected.width * expected.height) * 100) / 100;
|
||||
const pixelsMismatchError = count > maxDiffPixels ? `${count} pixels (ratio ${ratio.toFixed(2)} of all image pixels) are different.` : "";
|
||||
if (pixelsMismatchError || sizesMismatchError)
|
||||
return { errorMessage: sizesMismatchError + pixelsMismatchError, diff: import_utilsBundle3.PNG.sync.write(diff2) };
|
||||
return null;
|
||||
}
|
||||
function validateBuffer(buffer, mimeType) {
|
||||
if (mimeType === "image/png") {
|
||||
const pngMagicNumber = [137, 80, 78, 71, 13, 10, 26, 10];
|
||||
if (buffer.length < pngMagicNumber.length || !pngMagicNumber.every((byte, index) => buffer[index] === byte))
|
||||
throw new Error("could not decode image as PNG.");
|
||||
} else if (mimeType === "image/jpeg") {
|
||||
const jpegMagicNumber = [255, 216];
|
||||
if (buffer.length < jpegMagicNumber.length || !jpegMagicNumber.every((byte, index) => buffer[index] === byte))
|
||||
throw new Error("could not decode image as JPEG.");
|
||||
}
|
||||
}
|
||||
function compareText(actual, expectedBuffer) {
|
||||
if (typeof actual !== "string")
|
||||
return { errorMessage: "Actual result should be a string" };
|
||||
let expected = expectedBuffer.toString("utf-8");
|
||||
if (expected === actual)
|
||||
return null;
|
||||
if (!actual.endsWith("\n"))
|
||||
actual += "\n";
|
||||
if (!expected.endsWith("\n"))
|
||||
expected += "\n";
|
||||
const lines = import_utilsBundle2.diff.createPatch("file", expected, actual, void 0, void 0, { context: 5 }).split("\n");
|
||||
const coloredLines = lines.slice(4).map((line) => {
|
||||
if (line.startsWith("-"))
|
||||
return import_utilsBundle2.colors.green(line);
|
||||
if (line.startsWith("+"))
|
||||
return import_utilsBundle2.colors.red(line);
|
||||
if (line.startsWith("@@"))
|
||||
return import_utilsBundle2.colors.dim(line);
|
||||
return line;
|
||||
});
|
||||
const errorMessage = coloredLines.join("\n");
|
||||
return { errorMessage };
|
||||
}
|
||||
function resizeImage(image, size) {
|
||||
if (image.width === size.width && image.height === size.height)
|
||||
return image;
|
||||
const buffer = new Uint8Array(size.width * size.height * 4);
|
||||
for (let y = 0; y < size.height; y++) {
|
||||
for (let x = 0; x < size.width; x++) {
|
||||
const to = (y * size.width + x) * 4;
|
||||
if (y < image.height && x < image.width) {
|
||||
const from = (y * image.width + x) * 4;
|
||||
buffer[to] = image.data[from];
|
||||
buffer[to + 1] = image.data[from + 1];
|
||||
buffer[to + 2] = image.data[from + 2];
|
||||
buffer[to + 3] = image.data[from + 3];
|
||||
} else {
|
||||
buffer[to] = 0;
|
||||
buffer[to + 1] = 0;
|
||||
buffer[to + 2] = 0;
|
||||
buffer[to + 3] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return { data: Buffer.from(buffer), width: size.width, height: size.height };
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
compareBuffersOrStrings,
|
||||
getComparator
|
||||
});
|
216
node_modules/playwright-core/lib/server/utils/crypto.js
generated
vendored
Normal file
216
node_modules/playwright-core/lib/server/utils/crypto.js
generated
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
"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 crypto_exports = {};
|
||||
__export(crypto_exports, {
|
||||
calculateSha1: () => calculateSha1,
|
||||
createGuid: () => createGuid,
|
||||
generateSelfSignedCertificate: () => generateSelfSignedCertificate
|
||||
});
|
||||
module.exports = __toCommonJS(crypto_exports);
|
||||
var import_crypto = __toESM(require("crypto"));
|
||||
var import_assert = require("../../utils/isomorphic/assert");
|
||||
function createGuid() {
|
||||
return import_crypto.default.randomBytes(16).toString("hex");
|
||||
}
|
||||
function calculateSha1(buffer) {
|
||||
const hash = import_crypto.default.createHash("sha1");
|
||||
hash.update(buffer);
|
||||
return hash.digest("hex");
|
||||
}
|
||||
function encodeBase128(value) {
|
||||
const bytes = [];
|
||||
do {
|
||||
let byte = value & 127;
|
||||
value >>>= 7;
|
||||
if (bytes.length > 0)
|
||||
byte |= 128;
|
||||
bytes.push(byte);
|
||||
} while (value > 0);
|
||||
return Buffer.from(bytes.reverse());
|
||||
}
|
||||
class DER {
|
||||
static encodeSequence(data) {
|
||||
return this._encode(48, Buffer.concat(data));
|
||||
}
|
||||
static encodeInteger(data) {
|
||||
(0, import_assert.assert)(data >= -128 && data <= 127);
|
||||
return this._encode(2, Buffer.from([data]));
|
||||
}
|
||||
static encodeObjectIdentifier(oid) {
|
||||
const parts = oid.split(".").map((v) => Number(v));
|
||||
const output = [encodeBase128(40 * parts[0] + parts[1])];
|
||||
for (let i = 2; i < parts.length; i++)
|
||||
output.push(encodeBase128(parts[i]));
|
||||
return this._encode(6, Buffer.concat(output));
|
||||
}
|
||||
static encodeNull() {
|
||||
return Buffer.from([5, 0]);
|
||||
}
|
||||
static encodeSet(data) {
|
||||
(0, import_assert.assert)(data.length === 1, "Only one item in the set is supported. We'd need to sort the data to support more.");
|
||||
return this._encode(49, Buffer.concat(data));
|
||||
}
|
||||
static encodeExplicitContextDependent(tag, data) {
|
||||
return this._encode(160 + tag, data);
|
||||
}
|
||||
static encodePrintableString(data) {
|
||||
return this._encode(19, Buffer.from(data));
|
||||
}
|
||||
static encodeBitString(data) {
|
||||
const unusedBits = 0;
|
||||
const content = Buffer.concat([Buffer.from([unusedBits]), data]);
|
||||
return this._encode(3, content);
|
||||
}
|
||||
static encodeDate(date) {
|
||||
const year = date.getUTCFullYear();
|
||||
const isGeneralizedTime = year >= 2050;
|
||||
const parts = [
|
||||
isGeneralizedTime ? year.toString() : year.toString().slice(-2),
|
||||
(date.getUTCMonth() + 1).toString().padStart(2, "0"),
|
||||
date.getUTCDate().toString().padStart(2, "0"),
|
||||
date.getUTCHours().toString().padStart(2, "0"),
|
||||
date.getUTCMinutes().toString().padStart(2, "0"),
|
||||
date.getUTCSeconds().toString().padStart(2, "0")
|
||||
];
|
||||
const encodedDate = parts.join("") + "Z";
|
||||
const tag = isGeneralizedTime ? 24 : 23;
|
||||
return this._encode(tag, Buffer.from(encodedDate));
|
||||
}
|
||||
static _encode(tag, data) {
|
||||
const lengthBytes = this._encodeLength(data.length);
|
||||
return Buffer.concat([Buffer.from([tag]), lengthBytes, data]);
|
||||
}
|
||||
static _encodeLength(length) {
|
||||
if (length < 128) {
|
||||
return Buffer.from([length]);
|
||||
} else {
|
||||
const lengthBytes = [];
|
||||
while (length > 0) {
|
||||
lengthBytes.unshift(length & 255);
|
||||
length >>= 8;
|
||||
}
|
||||
return Buffer.from([128 | lengthBytes.length, ...lengthBytes]);
|
||||
}
|
||||
}
|
||||
}
|
||||
function generateSelfSignedCertificate() {
|
||||
const { privateKey, publicKey } = import_crypto.default.generateKeyPairSync("rsa", { modulusLength: 2048 });
|
||||
const publicKeyDer = publicKey.export({ type: "pkcs1", format: "der" });
|
||||
const oneYearInMilliseconds = 365 * 24 * 60 * 60 * 1e3;
|
||||
const notBefore = new Date((/* @__PURE__ */ new Date()).getTime() - oneYearInMilliseconds);
|
||||
const notAfter = new Date((/* @__PURE__ */ new Date()).getTime() + oneYearInMilliseconds);
|
||||
const tbsCertificate = DER.encodeSequence([
|
||||
DER.encodeExplicitContextDependent(0, DER.encodeInteger(1)),
|
||||
// version
|
||||
DER.encodeInteger(1),
|
||||
// serialNumber
|
||||
DER.encodeSequence([
|
||||
DER.encodeObjectIdentifier("1.2.840.113549.1.1.11"),
|
||||
// sha256WithRSAEncryption PKCS #1
|
||||
DER.encodeNull()
|
||||
]),
|
||||
// signature
|
||||
DER.encodeSequence([
|
||||
DER.encodeSet([
|
||||
DER.encodeSequence([
|
||||
DER.encodeObjectIdentifier("2.5.4.3"),
|
||||
// commonName X.520 DN component
|
||||
DER.encodePrintableString("localhost")
|
||||
])
|
||||
]),
|
||||
DER.encodeSet([
|
||||
DER.encodeSequence([
|
||||
DER.encodeObjectIdentifier("2.5.4.10"),
|
||||
// organizationName X.520 DN component
|
||||
DER.encodePrintableString("Playwright Client Certificate Support")
|
||||
])
|
||||
])
|
||||
]),
|
||||
// issuer
|
||||
DER.encodeSequence([
|
||||
DER.encodeDate(notBefore),
|
||||
// notBefore
|
||||
DER.encodeDate(notAfter)
|
||||
// notAfter
|
||||
]),
|
||||
// validity
|
||||
DER.encodeSequence([
|
||||
DER.encodeSet([
|
||||
DER.encodeSequence([
|
||||
DER.encodeObjectIdentifier("2.5.4.3"),
|
||||
// commonName X.520 DN component
|
||||
DER.encodePrintableString("localhost")
|
||||
])
|
||||
]),
|
||||
DER.encodeSet([
|
||||
DER.encodeSequence([
|
||||
DER.encodeObjectIdentifier("2.5.4.10"),
|
||||
// organizationName X.520 DN component
|
||||
DER.encodePrintableString("Playwright Client Certificate Support")
|
||||
])
|
||||
])
|
||||
]),
|
||||
// subject
|
||||
DER.encodeSequence([
|
||||
DER.encodeSequence([
|
||||
DER.encodeObjectIdentifier("1.2.840.113549.1.1.1"),
|
||||
// rsaEncryption PKCS #1
|
||||
DER.encodeNull()
|
||||
]),
|
||||
DER.encodeBitString(publicKeyDer)
|
||||
])
|
||||
// SubjectPublicKeyInfo
|
||||
]);
|
||||
const signature = import_crypto.default.sign("sha256", tbsCertificate, privateKey);
|
||||
const certificate = DER.encodeSequence([
|
||||
tbsCertificate,
|
||||
DER.encodeSequence([
|
||||
DER.encodeObjectIdentifier("1.2.840.113549.1.1.11"),
|
||||
// sha256WithRSAEncryption PKCS #1
|
||||
DER.encodeNull()
|
||||
]),
|
||||
DER.encodeBitString(signature)
|
||||
]);
|
||||
const certPem = [
|
||||
"-----BEGIN CERTIFICATE-----",
|
||||
// Split the base64 string into lines of 64 characters
|
||||
certificate.toString("base64").match(/.{1,64}/g).join("\n"),
|
||||
"-----END CERTIFICATE-----"
|
||||
].join("\n");
|
||||
return {
|
||||
cert: certPem,
|
||||
key: privateKey.export({ type: "pkcs1", format: "pem" })
|
||||
};
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
calculateSha1,
|
||||
createGuid,
|
||||
generateSelfSignedCertificate
|
||||
});
|
42
node_modules/playwright-core/lib/server/utils/debug.js
generated
vendored
Normal file
42
node_modules/playwright-core/lib/server/utils/debug.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"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 debug_exports = {};
|
||||
__export(debug_exports, {
|
||||
debugMode: () => debugMode,
|
||||
isUnderTest: () => isUnderTest
|
||||
});
|
||||
module.exports = __toCommonJS(debug_exports);
|
||||
var import_env = require("./env");
|
||||
const _debugMode = (0, import_env.getFromENV)("PWDEBUG") || "";
|
||||
function debugMode() {
|
||||
if (_debugMode === "console")
|
||||
return "console";
|
||||
if (_debugMode === "0" || _debugMode === "false")
|
||||
return "";
|
||||
return _debugMode ? "inspector" : "";
|
||||
}
|
||||
const _isUnderTest = (0, import_env.getAsBooleanFromENV)("PWTEST_UNDER_TEST");
|
||||
function isUnderTest() {
|
||||
return _isUnderTest;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
debugMode,
|
||||
isUnderTest
|
||||
});
|
122
node_modules/playwright-core/lib/server/utils/debugLogger.js
generated
vendored
Normal file
122
node_modules/playwright-core/lib/server/utils/debugLogger.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
"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 debugLogger_exports = {};
|
||||
__export(debugLogger_exports, {
|
||||
RecentLogsCollector: () => RecentLogsCollector,
|
||||
debugLogger: () => debugLogger
|
||||
});
|
||||
module.exports = __toCommonJS(debugLogger_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var import_utilsBundle = require("../../utilsBundle");
|
||||
const debugLoggerColorMap = {
|
||||
"api": 45,
|
||||
// cyan
|
||||
"protocol": 34,
|
||||
// green
|
||||
"install": 34,
|
||||
// green
|
||||
"download": 34,
|
||||
// green
|
||||
"browser": 0,
|
||||
// reset
|
||||
"socks": 92,
|
||||
// purple
|
||||
"client-certificates": 92,
|
||||
// purple
|
||||
"error": 160,
|
||||
// red,
|
||||
"channel": 33,
|
||||
// blue
|
||||
"server": 45,
|
||||
// cyan
|
||||
"server:channel": 34,
|
||||
// green
|
||||
"server:metadata": 33,
|
||||
// blue,
|
||||
"recorder": 45
|
||||
// cyan
|
||||
};
|
||||
class DebugLogger {
|
||||
constructor() {
|
||||
this._debuggers = /* @__PURE__ */ new Map();
|
||||
if (process.env.DEBUG_FILE) {
|
||||
const ansiRegex = new RegExp([
|
||||
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
||||
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
|
||||
].join("|"), "g");
|
||||
const stream = import_fs.default.createWriteStream(process.env.DEBUG_FILE);
|
||||
import_utilsBundle.debug.log = (data) => {
|
||||
stream.write(data.replace(ansiRegex, ""));
|
||||
stream.write("\n");
|
||||
};
|
||||
}
|
||||
}
|
||||
log(name, message) {
|
||||
let cachedDebugger = this._debuggers.get(name);
|
||||
if (!cachedDebugger) {
|
||||
cachedDebugger = (0, import_utilsBundle.debug)(`pw:${name}`);
|
||||
this._debuggers.set(name, cachedDebugger);
|
||||
cachedDebugger.color = debugLoggerColorMap[name] || 0;
|
||||
}
|
||||
cachedDebugger(message);
|
||||
}
|
||||
isEnabled(name) {
|
||||
return import_utilsBundle.debug.enabled(`pw:${name}`);
|
||||
}
|
||||
}
|
||||
const debugLogger = new DebugLogger();
|
||||
const kLogCount = 150;
|
||||
class RecentLogsCollector {
|
||||
constructor() {
|
||||
this._logs = [];
|
||||
this._listeners = [];
|
||||
}
|
||||
log(message) {
|
||||
this._logs.push(message);
|
||||
if (this._logs.length === kLogCount * 2)
|
||||
this._logs.splice(0, kLogCount);
|
||||
for (const listener of this._listeners)
|
||||
listener(message);
|
||||
}
|
||||
recentLogs() {
|
||||
if (this._logs.length > kLogCount)
|
||||
return this._logs.slice(-kLogCount);
|
||||
return this._logs;
|
||||
}
|
||||
onMessage(listener) {
|
||||
for (const message of this._logs)
|
||||
listener(message);
|
||||
this._listeners.push(listener);
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
RecentLogsCollector,
|
||||
debugLogger
|
||||
});
|
68
node_modules/playwright-core/lib/server/utils/env.js
generated
vendored
Normal file
68
node_modules/playwright-core/lib/server/utils/env.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 env_exports = {};
|
||||
__export(env_exports, {
|
||||
getAsBooleanFromENV: () => getAsBooleanFromENV,
|
||||
getFromENV: () => getFromENV,
|
||||
getPackageManager: () => getPackageManager,
|
||||
getPackageManagerExecCommand: () => getPackageManagerExecCommand,
|
||||
isLikelyNpxGlobal: () => isLikelyNpxGlobal
|
||||
});
|
||||
module.exports = __toCommonJS(env_exports);
|
||||
function getFromENV(name) {
|
||||
let value = process.env[name];
|
||||
value = value === void 0 ? process.env[`npm_config_${name.toLowerCase()}`] : value;
|
||||
value = value === void 0 ? process.env[`npm_package_config_${name.toLowerCase()}`] : value;
|
||||
return value;
|
||||
}
|
||||
function getAsBooleanFromENV(name, defaultValue) {
|
||||
const value = getFromENV(name);
|
||||
if (value === "false" || value === "0")
|
||||
return false;
|
||||
if (value)
|
||||
return true;
|
||||
return !!defaultValue;
|
||||
}
|
||||
function getPackageManager() {
|
||||
const env = process.env.npm_config_user_agent || "";
|
||||
if (env.includes("yarn"))
|
||||
return "yarn";
|
||||
if (env.includes("pnpm"))
|
||||
return "pnpm";
|
||||
return "npm";
|
||||
}
|
||||
function getPackageManagerExecCommand() {
|
||||
const packageManager = getPackageManager();
|
||||
if (packageManager === "yarn")
|
||||
return "yarn";
|
||||
if (packageManager === "pnpm")
|
||||
return "pnpm exec";
|
||||
return "npx";
|
||||
}
|
||||
function isLikelyNpxGlobal() {
|
||||
return process.argv.length >= 2 && process.argv[1].includes("_npx");
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
getAsBooleanFromENV,
|
||||
getFromENV,
|
||||
getPackageManager,
|
||||
getPackageManagerExecCommand,
|
||||
isLikelyNpxGlobal
|
||||
});
|
39
node_modules/playwright-core/lib/server/utils/eventsHelper.js
generated
vendored
Normal file
39
node_modules/playwright-core/lib/server/utils/eventsHelper.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
"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 eventsHelper_exports = {};
|
||||
__export(eventsHelper_exports, {
|
||||
eventsHelper: () => eventsHelper
|
||||
});
|
||||
module.exports = __toCommonJS(eventsHelper_exports);
|
||||
class EventsHelper {
|
||||
static addEventListener(emitter, eventName, handler) {
|
||||
emitter.on(eventName, handler);
|
||||
return { emitter, eventName, handler };
|
||||
}
|
||||
static removeEventListeners(listeners) {
|
||||
for (const listener of listeners)
|
||||
listener.emitter.removeListener(listener.eventName, listener.handler);
|
||||
listeners.splice(0, listeners.length);
|
||||
}
|
||||
}
|
||||
const eventsHelper = EventsHelper;
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
eventsHelper
|
||||
});
|
38
node_modules/playwright-core/lib/server/utils/expectUtils.js
generated
vendored
Normal file
38
node_modules/playwright-core/lib/server/utils/expectUtils.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"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 expectUtils_exports = {};
|
||||
__export(expectUtils_exports, {
|
||||
serializeExpectedTextValues: () => serializeExpectedTextValues
|
||||
});
|
||||
module.exports = __toCommonJS(expectUtils_exports);
|
||||
var import_rtti = require("../../utils/isomorphic/rtti");
|
||||
function serializeExpectedTextValues(items, options = {}) {
|
||||
return items.map((i) => ({
|
||||
string: (0, import_rtti.isString)(i) ? i : void 0,
|
||||
regexSource: (0, import_rtti.isRegExp)(i) ? i.source : void 0,
|
||||
regexFlags: (0, import_rtti.isRegExp)(i) ? i.flags : void 0,
|
||||
matchSubstring: options.matchSubstring,
|
||||
ignoreCase: options.ignoreCase,
|
||||
normalizeWhiteSpace: options.normalizeWhiteSpace
|
||||
}));
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
serializeExpectedTextValues
|
||||
});
|
191
node_modules/playwright-core/lib/server/utils/fileUtils.js
generated
vendored
Normal file
191
node_modules/playwright-core/lib/server/utils/fileUtils.js
generated
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
"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 fileUtils_exports = {};
|
||||
__export(fileUtils_exports, {
|
||||
SerializedFS: () => SerializedFS,
|
||||
canAccessFile: () => canAccessFile,
|
||||
copyFileAndMakeWritable: () => copyFileAndMakeWritable,
|
||||
existsAsync: () => existsAsync,
|
||||
mkdirIfNeeded: () => mkdirIfNeeded,
|
||||
removeFolders: () => removeFolders,
|
||||
sanitizeForFilePath: () => sanitizeForFilePath,
|
||||
toPosixPath: () => toPosixPath
|
||||
});
|
||||
module.exports = __toCommonJS(fileUtils_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var import_path = __toESM(require("path"));
|
||||
var import_manualPromise = require("../../utils/isomorphic/manualPromise");
|
||||
var import_zipBundle = require("../../zipBundle");
|
||||
const existsAsync = (path2) => new Promise((resolve) => import_fs.default.stat(path2, (err) => resolve(!err)));
|
||||
async function mkdirIfNeeded(filePath) {
|
||||
await import_fs.default.promises.mkdir(import_path.default.dirname(filePath), { recursive: true }).catch(() => {
|
||||
});
|
||||
}
|
||||
async function removeFolders(dirs) {
|
||||
return await Promise.all(dirs.map(
|
||||
(dir) => import_fs.default.promises.rm(dir, { recursive: true, force: true, maxRetries: 10 }).catch((e) => e)
|
||||
));
|
||||
}
|
||||
function canAccessFile(file) {
|
||||
if (!file)
|
||||
return false;
|
||||
try {
|
||||
import_fs.default.accessSync(file);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
async function copyFileAndMakeWritable(from, to) {
|
||||
await import_fs.default.promises.copyFile(from, to);
|
||||
await import_fs.default.promises.chmod(to, 436);
|
||||
}
|
||||
function sanitizeForFilePath(s) {
|
||||
return s.replace(/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+/g, "-");
|
||||
}
|
||||
function toPosixPath(aPath) {
|
||||
return aPath.split(import_path.default.sep).join(import_path.default.posix.sep);
|
||||
}
|
||||
class SerializedFS {
|
||||
constructor() {
|
||||
this._buffers = /* @__PURE__ */ new Map();
|
||||
this._operations = [];
|
||||
this._operationsDone = new import_manualPromise.ManualPromise();
|
||||
this._operationsDone.resolve();
|
||||
}
|
||||
mkdir(dir) {
|
||||
this._appendOperation({ op: "mkdir", dir });
|
||||
}
|
||||
writeFile(file, content, skipIfExists) {
|
||||
this._buffers.delete(file);
|
||||
this._appendOperation({ op: "writeFile", file, content, skipIfExists });
|
||||
}
|
||||
appendFile(file, text, flush) {
|
||||
if (!this._buffers.has(file))
|
||||
this._buffers.set(file, []);
|
||||
this._buffers.get(file).push(text);
|
||||
if (flush)
|
||||
this._flushFile(file);
|
||||
}
|
||||
_flushFile(file) {
|
||||
const buffer = this._buffers.get(file);
|
||||
if (buffer === void 0)
|
||||
return;
|
||||
const content = buffer.join("");
|
||||
this._buffers.delete(file);
|
||||
this._appendOperation({ op: "appendFile", file, content });
|
||||
}
|
||||
copyFile(from, to) {
|
||||
this._flushFile(from);
|
||||
this._buffers.delete(to);
|
||||
this._appendOperation({ op: "copyFile", from, to });
|
||||
}
|
||||
async syncAndGetError() {
|
||||
for (const file of this._buffers.keys())
|
||||
this._flushFile(file);
|
||||
await this._operationsDone;
|
||||
return this._error;
|
||||
}
|
||||
zip(entries, zipFileName) {
|
||||
for (const file of this._buffers.keys())
|
||||
this._flushFile(file);
|
||||
this._appendOperation({ op: "zip", entries, zipFileName });
|
||||
}
|
||||
// This method serializes all writes to the trace.
|
||||
_appendOperation(op) {
|
||||
const last = this._operations[this._operations.length - 1];
|
||||
if (last?.op === "appendFile" && op.op === "appendFile" && last.file === op.file) {
|
||||
last.content += op.content;
|
||||
return;
|
||||
}
|
||||
this._operations.push(op);
|
||||
if (this._operationsDone.isDone())
|
||||
this._performOperations();
|
||||
}
|
||||
async _performOperations() {
|
||||
this._operationsDone = new import_manualPromise.ManualPromise();
|
||||
while (this._operations.length) {
|
||||
const op = this._operations.shift();
|
||||
if (this._error)
|
||||
continue;
|
||||
try {
|
||||
await this._performOperation(op);
|
||||
} catch (e) {
|
||||
this._error = e;
|
||||
}
|
||||
}
|
||||
this._operationsDone.resolve();
|
||||
}
|
||||
async _performOperation(op) {
|
||||
switch (op.op) {
|
||||
case "mkdir": {
|
||||
await import_fs.default.promises.mkdir(op.dir, { recursive: true });
|
||||
return;
|
||||
}
|
||||
case "writeFile": {
|
||||
if (op.skipIfExists)
|
||||
await import_fs.default.promises.writeFile(op.file, op.content, { flag: "wx" }).catch(() => {
|
||||
});
|
||||
else
|
||||
await import_fs.default.promises.writeFile(op.file, op.content);
|
||||
return;
|
||||
}
|
||||
case "copyFile": {
|
||||
await import_fs.default.promises.copyFile(op.from, op.to);
|
||||
return;
|
||||
}
|
||||
case "appendFile": {
|
||||
await import_fs.default.promises.appendFile(op.file, op.content);
|
||||
return;
|
||||
}
|
||||
case "zip": {
|
||||
const zipFile = new import_zipBundle.yazl.ZipFile();
|
||||
const result = new import_manualPromise.ManualPromise();
|
||||
zipFile.on("error", (error) => result.reject(error));
|
||||
for (const entry of op.entries)
|
||||
zipFile.addFile(entry.value, entry.name);
|
||||
zipFile.end();
|
||||
zipFile.outputStream.pipe(import_fs.default.createWriteStream(op.zipFileName)).on("close", () => result.resolve()).on("error", (error) => result.reject(error));
|
||||
await result;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
SerializedFS,
|
||||
canAccessFile,
|
||||
copyFileAndMakeWritable,
|
||||
existsAsync,
|
||||
mkdirIfNeeded,
|
||||
removeFolders,
|
||||
sanitizeForFilePath,
|
||||
toPosixPath
|
||||
});
|
207
node_modules/playwright-core/lib/server/utils/happyEyeballs.js
generated
vendored
Normal file
207
node_modules/playwright-core/lib/server/utils/happyEyeballs.js
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
"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 happyEyeballs_exports = {};
|
||||
__export(happyEyeballs_exports, {
|
||||
createConnectionAsync: () => createConnectionAsync,
|
||||
createSocket: () => createSocket,
|
||||
createTLSSocket: () => createTLSSocket,
|
||||
httpHappyEyeballsAgent: () => httpHappyEyeballsAgent,
|
||||
httpsHappyEyeballsAgent: () => httpsHappyEyeballsAgent,
|
||||
timingForSocket: () => timingForSocket
|
||||
});
|
||||
module.exports = __toCommonJS(happyEyeballs_exports);
|
||||
var import_dns = __toESM(require("dns"));
|
||||
var import_http = __toESM(require("http"));
|
||||
var import_https = __toESM(require("https"));
|
||||
var import_net = __toESM(require("net"));
|
||||
var import_tls = __toESM(require("tls"));
|
||||
var import_assert = require("../../utils/isomorphic/assert");
|
||||
var import_manualPromise = require("../../utils/isomorphic/manualPromise");
|
||||
var import_time = require("../../utils/isomorphic/time");
|
||||
const connectionAttemptDelayMs = 300;
|
||||
const kDNSLookupAt = Symbol("kDNSLookupAt");
|
||||
const kTCPConnectionAt = Symbol("kTCPConnectionAt");
|
||||
class HttpHappyEyeballsAgent extends import_http.default.Agent {
|
||||
createConnection(options, oncreate) {
|
||||
if (import_net.default.isIP(clientRequestArgsToHostName(options)))
|
||||
return import_net.default.createConnection(options);
|
||||
createConnectionAsync(
|
||||
options,
|
||||
oncreate,
|
||||
/* useTLS */
|
||||
false
|
||||
).catch((err) => oncreate?.(err));
|
||||
}
|
||||
}
|
||||
class HttpsHappyEyeballsAgent extends import_https.default.Agent {
|
||||
createConnection(options, oncreate) {
|
||||
if (import_net.default.isIP(clientRequestArgsToHostName(options)))
|
||||
return import_tls.default.connect(options);
|
||||
createConnectionAsync(
|
||||
options,
|
||||
oncreate,
|
||||
/* useTLS */
|
||||
true
|
||||
).catch((err) => oncreate?.(err));
|
||||
}
|
||||
}
|
||||
const httpsHappyEyeballsAgent = new HttpsHappyEyeballsAgent({ keepAlive: true });
|
||||
const httpHappyEyeballsAgent = new HttpHappyEyeballsAgent({ keepAlive: true });
|
||||
async function createSocket(host, port) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (import_net.default.isIP(host)) {
|
||||
const socket = import_net.default.createConnection({ host, port });
|
||||
socket.on("connect", () => resolve(socket));
|
||||
socket.on("error", (error) => reject(error));
|
||||
} else {
|
||||
createConnectionAsync(
|
||||
{ host, port },
|
||||
(err, socket) => {
|
||||
if (err)
|
||||
reject(err);
|
||||
if (socket)
|
||||
resolve(socket);
|
||||
},
|
||||
/* useTLS */
|
||||
false
|
||||
).catch((err) => reject(err));
|
||||
}
|
||||
});
|
||||
}
|
||||
async function createTLSSocket(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
(0, import_assert.assert)(options.host, "host is required");
|
||||
if (import_net.default.isIP(options.host)) {
|
||||
const socket = import_tls.default.connect(options);
|
||||
socket.on("secureConnect", () => resolve(socket));
|
||||
socket.on("error", (error) => reject(error));
|
||||
} else {
|
||||
createConnectionAsync(options, (err, socket) => {
|
||||
if (err)
|
||||
reject(err);
|
||||
if (socket) {
|
||||
socket.on("secureConnect", () => resolve(socket));
|
||||
socket.on("error", (error) => reject(error));
|
||||
}
|
||||
}, true).catch((err) => reject(err));
|
||||
}
|
||||
});
|
||||
}
|
||||
async function createConnectionAsync(options, oncreate, useTLS) {
|
||||
const lookup = options.__testHookLookup || lookupAddresses;
|
||||
const hostname = clientRequestArgsToHostName(options);
|
||||
const addresses = await lookup(hostname);
|
||||
const dnsLookupAt = (0, import_time.monotonicTime)();
|
||||
const sockets = /* @__PURE__ */ new Set();
|
||||
let firstError;
|
||||
let errorCount = 0;
|
||||
const handleError = (socket, err) => {
|
||||
if (!sockets.delete(socket))
|
||||
return;
|
||||
++errorCount;
|
||||
firstError ??= err;
|
||||
if (errorCount === addresses.length)
|
||||
oncreate?.(firstError);
|
||||
};
|
||||
const connected = new import_manualPromise.ManualPromise();
|
||||
for (const { address } of addresses) {
|
||||
const socket = useTLS ? import_tls.default.connect({
|
||||
...options,
|
||||
port: options.port,
|
||||
host: address,
|
||||
servername: hostname
|
||||
}) : import_net.default.createConnection({
|
||||
...options,
|
||||
port: options.port,
|
||||
host: address
|
||||
});
|
||||
socket[kDNSLookupAt] = dnsLookupAt;
|
||||
socket.on("connect", () => {
|
||||
socket[kTCPConnectionAt] = (0, import_time.monotonicTime)();
|
||||
connected.resolve();
|
||||
oncreate?.(null, socket);
|
||||
sockets.delete(socket);
|
||||
for (const s of sockets)
|
||||
s.destroy();
|
||||
sockets.clear();
|
||||
});
|
||||
socket.on("timeout", () => {
|
||||
socket.destroy();
|
||||
handleError(socket, new Error("Connection timeout"));
|
||||
});
|
||||
socket.on("error", (e) => handleError(socket, e));
|
||||
sockets.add(socket);
|
||||
await Promise.race([
|
||||
connected,
|
||||
new Promise((f) => setTimeout(f, connectionAttemptDelayMs))
|
||||
]);
|
||||
if (connected.isDone())
|
||||
break;
|
||||
}
|
||||
}
|
||||
async function lookupAddresses(hostname) {
|
||||
const addresses = await import_dns.default.promises.lookup(hostname, { all: true, family: 0, verbatim: true });
|
||||
let firstFamily = addresses.filter(({ family }) => family === 6);
|
||||
let secondFamily = addresses.filter(({ family }) => family === 4);
|
||||
if (firstFamily.length && firstFamily[0] !== addresses[0]) {
|
||||
const tmp = firstFamily;
|
||||
firstFamily = secondFamily;
|
||||
secondFamily = tmp;
|
||||
}
|
||||
const result = [];
|
||||
for (let i = 0; i < Math.max(firstFamily.length, secondFamily.length); i++) {
|
||||
if (firstFamily[i])
|
||||
result.push(firstFamily[i]);
|
||||
if (secondFamily[i])
|
||||
result.push(secondFamily[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function clientRequestArgsToHostName(options) {
|
||||
if (options.hostname)
|
||||
return options.hostname;
|
||||
if (options.host)
|
||||
return options.host;
|
||||
throw new Error("Either options.hostname or options.host must be provided");
|
||||
}
|
||||
function timingForSocket(socket) {
|
||||
return {
|
||||
dnsLookupAt: socket[kDNSLookupAt],
|
||||
tcpConnectionAt: socket[kTCPConnectionAt]
|
||||
};
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
createConnectionAsync,
|
||||
createSocket,
|
||||
createTLSSocket,
|
||||
httpHappyEyeballsAgent,
|
||||
httpsHappyEyeballsAgent,
|
||||
timingForSocket
|
||||
});
|
111
node_modules/playwright-core/lib/server/utils/hostPlatform.js
generated
vendored
Normal file
111
node_modules/playwright-core/lib/server/utils/hostPlatform.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
"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 hostPlatform_exports = {};
|
||||
__export(hostPlatform_exports, {
|
||||
hostPlatform: () => hostPlatform,
|
||||
isOfficiallySupportedPlatform: () => isOfficiallySupportedPlatform
|
||||
});
|
||||
module.exports = __toCommonJS(hostPlatform_exports);
|
||||
var import_os = __toESM(require("os"));
|
||||
var import_linuxUtils = require("./linuxUtils");
|
||||
function calculatePlatform() {
|
||||
if (process.env.PLAYWRIGHT_HOST_PLATFORM_OVERRIDE) {
|
||||
return {
|
||||
hostPlatform: process.env.PLAYWRIGHT_HOST_PLATFORM_OVERRIDE,
|
||||
isOfficiallySupportedPlatform: false
|
||||
};
|
||||
}
|
||||
const platform = import_os.default.platform();
|
||||
if (platform === "darwin") {
|
||||
const ver = import_os.default.release().split(".").map((a) => parseInt(a, 10));
|
||||
let macVersion = "";
|
||||
if (ver[0] < 18) {
|
||||
macVersion = "mac10.13";
|
||||
} else if (ver[0] === 18) {
|
||||
macVersion = "mac10.14";
|
||||
} else if (ver[0] === 19) {
|
||||
macVersion = "mac10.15";
|
||||
} else {
|
||||
const LAST_STABLE_MACOS_MAJOR_VERSION = 15;
|
||||
macVersion = "mac" + Math.min(ver[0] - 9, LAST_STABLE_MACOS_MAJOR_VERSION);
|
||||
if (import_os.default.cpus().some((cpu) => cpu.model.includes("Apple")))
|
||||
macVersion += "-arm64";
|
||||
}
|
||||
return { hostPlatform: macVersion, isOfficiallySupportedPlatform: true };
|
||||
}
|
||||
if (platform === "linux") {
|
||||
if (!["x64", "arm64"].includes(import_os.default.arch()))
|
||||
return { hostPlatform: "<unknown>", isOfficiallySupportedPlatform: false };
|
||||
const archSuffix = "-" + import_os.default.arch();
|
||||
const distroInfo = (0, import_linuxUtils.getLinuxDistributionInfoSync)();
|
||||
if (distroInfo?.id === "ubuntu" || distroInfo?.id === "pop" || distroInfo?.id === "neon" || distroInfo?.id === "tuxedo") {
|
||||
const isUbuntu = distroInfo?.id === "ubuntu";
|
||||
const version = distroInfo?.version;
|
||||
const major = parseInt(distroInfo.version, 10);
|
||||
if (major < 20)
|
||||
return { hostPlatform: "ubuntu18.04" + archSuffix, isOfficiallySupportedPlatform: false };
|
||||
if (major < 22)
|
||||
return { hostPlatform: "ubuntu20.04" + archSuffix, isOfficiallySupportedPlatform: isUbuntu && version === "20.04" };
|
||||
if (major < 24)
|
||||
return { hostPlatform: "ubuntu22.04" + archSuffix, isOfficiallySupportedPlatform: isUbuntu && version === "22.04" };
|
||||
if (major < 26)
|
||||
return { hostPlatform: "ubuntu24.04" + archSuffix, isOfficiallySupportedPlatform: isUbuntu && version === "24.04" };
|
||||
return { hostPlatform: "ubuntu" + distroInfo.version + archSuffix, isOfficiallySupportedPlatform: false };
|
||||
}
|
||||
if (distroInfo?.id === "linuxmint") {
|
||||
const mintMajor = parseInt(distroInfo.version, 10);
|
||||
if (mintMajor <= 20)
|
||||
return { hostPlatform: "ubuntu20.04" + archSuffix, isOfficiallySupportedPlatform: false };
|
||||
if (mintMajor === 21)
|
||||
return { hostPlatform: "ubuntu22.04" + archSuffix, isOfficiallySupportedPlatform: false };
|
||||
return { hostPlatform: "ubuntu24.04" + archSuffix, isOfficiallySupportedPlatform: false };
|
||||
}
|
||||
if (distroInfo?.id === "debian" || distroInfo?.id === "raspbian") {
|
||||
const isOfficiallySupportedPlatform2 = distroInfo?.id === "debian";
|
||||
if (distroInfo?.version === "11")
|
||||
return { hostPlatform: "debian11" + archSuffix, isOfficiallySupportedPlatform: isOfficiallySupportedPlatform2 };
|
||||
if (distroInfo?.version === "12")
|
||||
return { hostPlatform: "debian12" + archSuffix, isOfficiallySupportedPlatform: isOfficiallySupportedPlatform2 };
|
||||
if (distroInfo?.version === "13")
|
||||
return { hostPlatform: "debian13" + archSuffix, isOfficiallySupportedPlatform: isOfficiallySupportedPlatform2 };
|
||||
if (distroInfo?.version === "")
|
||||
return { hostPlatform: "debian13" + archSuffix, isOfficiallySupportedPlatform: isOfficiallySupportedPlatform2 };
|
||||
}
|
||||
return { hostPlatform: "ubuntu20.04" + archSuffix, isOfficiallySupportedPlatform: false };
|
||||
}
|
||||
if (platform === "win32")
|
||||
return { hostPlatform: "win64", isOfficiallySupportedPlatform: true };
|
||||
return { hostPlatform: "<unknown>", isOfficiallySupportedPlatform: false };
|
||||
}
|
||||
const { hostPlatform, isOfficiallySupportedPlatform } = calculatePlatform();
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
hostPlatform,
|
||||
isOfficiallySupportedPlatform
|
||||
});
|
218
node_modules/playwright-core/lib/server/utils/httpServer.js
generated
vendored
Normal file
218
node_modules/playwright-core/lib/server/utils/httpServer.js
generated
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
"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 httpServer_exports = {};
|
||||
__export(httpServer_exports, {
|
||||
HttpServer: () => HttpServer
|
||||
});
|
||||
module.exports = __toCommonJS(httpServer_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var import_path = __toESM(require("path"));
|
||||
var import_utilsBundle = require("../../utilsBundle");
|
||||
var import_crypto = require("./crypto");
|
||||
var import_assert = require("../../utils/isomorphic/assert");
|
||||
var import_manualPromise = require("../../utils/isomorphic/manualPromise");
|
||||
var import_network = require("./network");
|
||||
class HttpServer {
|
||||
constructor() {
|
||||
this._urlPrefixPrecise = "";
|
||||
this._urlPrefixHumanReadable = "";
|
||||
this._port = 0;
|
||||
this._started = false;
|
||||
this._routes = [];
|
||||
this._server = (0, import_network.createHttpServer)(this._onRequest.bind(this));
|
||||
}
|
||||
server() {
|
||||
return this._server;
|
||||
}
|
||||
routePrefix(prefix, handler) {
|
||||
this._routes.push({ prefix, handler });
|
||||
}
|
||||
routePath(path2, handler) {
|
||||
this._routes.push({ exact: path2, handler });
|
||||
}
|
||||
port() {
|
||||
return this._port;
|
||||
}
|
||||
async _tryStart(port, host) {
|
||||
const errorPromise = new import_manualPromise.ManualPromise();
|
||||
const errorListener = (error) => errorPromise.reject(error);
|
||||
this._server.on("error", errorListener);
|
||||
try {
|
||||
this._server.listen(port, host);
|
||||
await Promise.race([
|
||||
new Promise((cb) => this._server.once("listening", cb)),
|
||||
errorPromise
|
||||
]);
|
||||
} finally {
|
||||
this._server.removeListener("error", errorListener);
|
||||
}
|
||||
}
|
||||
createWebSocket(transport, guid) {
|
||||
(0, import_assert.assert)(!this._wsGuid, "can only create one main websocket transport per server");
|
||||
this._wsGuid = guid || (0, import_crypto.createGuid)();
|
||||
const wss = new import_utilsBundle.wsServer({ server: this._server, path: "/" + this._wsGuid });
|
||||
wss.on("connection", (ws) => {
|
||||
transport.onconnect();
|
||||
transport.sendEvent = (method, params) => ws.send(JSON.stringify({ method, params }));
|
||||
transport.close = () => ws.close();
|
||||
ws.on("message", async (message) => {
|
||||
const { id, method, params } = JSON.parse(String(message));
|
||||
try {
|
||||
const result = await transport.dispatch(method, params);
|
||||
ws.send(JSON.stringify({ id, result }));
|
||||
} catch (e) {
|
||||
ws.send(JSON.stringify({ id, error: String(e) }));
|
||||
}
|
||||
});
|
||||
ws.on("close", () => transport.onclose());
|
||||
ws.on("error", () => transport.onclose());
|
||||
});
|
||||
}
|
||||
wsGuid() {
|
||||
return this._wsGuid;
|
||||
}
|
||||
async start(options = {}) {
|
||||
(0, import_assert.assert)(!this._started, "server already started");
|
||||
this._started = true;
|
||||
const host = options.host || "localhost";
|
||||
if (options.preferredPort) {
|
||||
try {
|
||||
await this._tryStart(options.preferredPort, host);
|
||||
} catch (e) {
|
||||
if (!e || !e.message || !e.message.includes("EADDRINUSE"))
|
||||
throw e;
|
||||
await this._tryStart(void 0, host);
|
||||
}
|
||||
} else {
|
||||
await this._tryStart(options.port, host);
|
||||
}
|
||||
const address = this._server.address();
|
||||
(0, import_assert.assert)(address, "Could not bind server socket");
|
||||
if (typeof address === "string") {
|
||||
this._urlPrefixPrecise = address;
|
||||
this._urlPrefixHumanReadable = address;
|
||||
} else {
|
||||
this._port = address.port;
|
||||
const resolvedHost = address.family === "IPv4" ? address.address : `[${address.address}]`;
|
||||
this._urlPrefixPrecise = `http://${resolvedHost}:${address.port}`;
|
||||
this._urlPrefixHumanReadable = `http://${host}:${address.port}`;
|
||||
}
|
||||
}
|
||||
async stop() {
|
||||
await new Promise((cb) => this._server.close(cb));
|
||||
}
|
||||
urlPrefix(purpose) {
|
||||
return purpose === "human-readable" ? this._urlPrefixHumanReadable : this._urlPrefixPrecise;
|
||||
}
|
||||
serveFile(request, response, absoluteFilePath, headers) {
|
||||
try {
|
||||
for (const [name, value] of Object.entries(headers || {}))
|
||||
response.setHeader(name, value);
|
||||
if (request.headers.range)
|
||||
this._serveRangeFile(request, response, absoluteFilePath);
|
||||
else
|
||||
this._serveFile(response, absoluteFilePath);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_serveFile(response, absoluteFilePath) {
|
||||
const content = import_fs.default.readFileSync(absoluteFilePath);
|
||||
response.statusCode = 200;
|
||||
const contentType = import_utilsBundle.mime.getType(import_path.default.extname(absoluteFilePath)) || "application/octet-stream";
|
||||
response.setHeader("Content-Type", contentType);
|
||||
response.setHeader("Content-Length", content.byteLength);
|
||||
response.end(content);
|
||||
}
|
||||
_serveRangeFile(request, response, absoluteFilePath) {
|
||||
const range = request.headers.range;
|
||||
if (!range || !range.startsWith("bytes=") || range.includes(", ") || [...range].filter((char) => char === "-").length !== 1) {
|
||||
response.statusCode = 400;
|
||||
return response.end("Bad request");
|
||||
}
|
||||
const [startStr, endStr] = range.replace(/bytes=/, "").split("-");
|
||||
let start;
|
||||
let end;
|
||||
const size = import_fs.default.statSync(absoluteFilePath).size;
|
||||
if (startStr !== "" && endStr === "") {
|
||||
start = +startStr;
|
||||
end = size - 1;
|
||||
} else if (startStr === "" && endStr !== "") {
|
||||
start = size - +endStr;
|
||||
end = size - 1;
|
||||
} else {
|
||||
start = +startStr;
|
||||
end = +endStr;
|
||||
}
|
||||
if (Number.isNaN(start) || Number.isNaN(end) || start >= size || end >= size || start > end) {
|
||||
response.writeHead(416, {
|
||||
"Content-Range": `bytes */${size}`
|
||||
});
|
||||
return response.end();
|
||||
}
|
||||
response.writeHead(206, {
|
||||
"Content-Range": `bytes ${start}-${end}/${size}`,
|
||||
"Accept-Ranges": "bytes",
|
||||
"Content-Length": end - start + 1,
|
||||
"Content-Type": import_utilsBundle.mime.getType(import_path.default.extname(absoluteFilePath))
|
||||
});
|
||||
const readable = import_fs.default.createReadStream(absoluteFilePath, { start, end });
|
||||
readable.pipe(response);
|
||||
}
|
||||
_onRequest(request, response) {
|
||||
if (request.method === "OPTIONS") {
|
||||
response.writeHead(200);
|
||||
response.end();
|
||||
return;
|
||||
}
|
||||
request.on("error", () => response.end());
|
||||
try {
|
||||
if (!request.url) {
|
||||
response.end();
|
||||
return;
|
||||
}
|
||||
const url = new URL("http://localhost" + request.url);
|
||||
for (const route of this._routes) {
|
||||
if (route.exact && url.pathname === route.exact && route.handler(request, response))
|
||||
return;
|
||||
if (route.prefix && url.pathname.startsWith(route.prefix) && route.handler(request, response))
|
||||
return;
|
||||
}
|
||||
response.statusCode = 404;
|
||||
response.end();
|
||||
} catch (e) {
|
||||
response.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
HttpServer
|
||||
});
|
89
node_modules/playwright-core/lib/server/utils/image_tools/colorUtils.js
generated
vendored
Normal file
89
node_modules/playwright-core/lib/server/utils/image_tools/colorUtils.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 colorUtils_exports = {};
|
||||
__export(colorUtils_exports, {
|
||||
blendWithWhite: () => blendWithWhite,
|
||||
colorDeltaE94: () => colorDeltaE94,
|
||||
rgb2gray: () => rgb2gray,
|
||||
srgb2xyz: () => srgb2xyz,
|
||||
xyz2lab: () => xyz2lab
|
||||
});
|
||||
module.exports = __toCommonJS(colorUtils_exports);
|
||||
function blendWithWhite(c, a) {
|
||||
return 255 + (c - 255) * a;
|
||||
}
|
||||
function rgb2gray(r, g, b) {
|
||||
return 77 * r + 150 * g + 29 * b + 128 >> 8;
|
||||
}
|
||||
function colorDeltaE94(rgb1, rgb2) {
|
||||
const [l1, a1, b1] = xyz2lab(srgb2xyz(rgb1));
|
||||
const [l2, a2, b2] = xyz2lab(srgb2xyz(rgb2));
|
||||
const deltaL = l1 - l2;
|
||||
const deltaA = a1 - a2;
|
||||
const deltaB = b1 - b2;
|
||||
const c1 = Math.sqrt(a1 ** 2 + b1 ** 2);
|
||||
const c2 = Math.sqrt(a2 ** 2 + b2 ** 2);
|
||||
const deltaC = c1 - c2;
|
||||
let deltaH = deltaA ** 2 + deltaB ** 2 - deltaC ** 2;
|
||||
deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH);
|
||||
const k1 = 0.045;
|
||||
const k2 = 0.015;
|
||||
const kL = 1;
|
||||
const kC = 1;
|
||||
const kH = 1;
|
||||
const sC = 1 + k1 * c1;
|
||||
const sH = 1 + k2 * c1;
|
||||
const sL = 1;
|
||||
return Math.sqrt((deltaL / sL / kL) ** 2 + (deltaC / sC / kC) ** 2 + (deltaH / sH / kH) ** 2);
|
||||
}
|
||||
function srgb2xyz(rgb) {
|
||||
let r = rgb[0] / 255;
|
||||
let g = rgb[1] / 255;
|
||||
let b = rgb[2] / 255;
|
||||
r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
|
||||
g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
|
||||
b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
|
||||
return [
|
||||
r * 0.4124 + g * 0.3576 + b * 0.1805,
|
||||
r * 0.2126 + g * 0.7152 + b * 0.0722,
|
||||
r * 0.0193 + g * 0.1192 + b * 0.9505
|
||||
];
|
||||
}
|
||||
const sigma_pow2 = 6 * 6 / 29 / 29;
|
||||
const sigma_pow3 = 6 * 6 * 6 / 29 / 29 / 29;
|
||||
function xyz2lab(xyz) {
|
||||
const x = xyz[0] / 0.950489;
|
||||
const y = xyz[1];
|
||||
const z = xyz[2] / 1.08884;
|
||||
const fx = x > sigma_pow3 ? x ** (1 / 3) : x / 3 / sigma_pow2 + 4 / 29;
|
||||
const fy = y > sigma_pow3 ? y ** (1 / 3) : y / 3 / sigma_pow2 + 4 / 29;
|
||||
const fz = z > sigma_pow3 ? z ** (1 / 3) : z / 3 / sigma_pow2 + 4 / 29;
|
||||
const l = 116 * fy - 16;
|
||||
const a = 500 * (fx - fy);
|
||||
const b = 200 * (fy - fz);
|
||||
return [l, a, b];
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
blendWithWhite,
|
||||
colorDeltaE94,
|
||||
rgb2gray,
|
||||
srgb2xyz,
|
||||
xyz2lab
|
||||
});
|
109
node_modules/playwright-core/lib/server/utils/image_tools/compare.js
generated
vendored
Normal file
109
node_modules/playwright-core/lib/server/utils/image_tools/compare.js
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
"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 compare_exports = {};
|
||||
__export(compare_exports, {
|
||||
compare: () => compare
|
||||
});
|
||||
module.exports = __toCommonJS(compare_exports);
|
||||
var import_colorUtils = require("./colorUtils");
|
||||
var import_imageChannel = require("./imageChannel");
|
||||
var import_stats = require("./stats");
|
||||
const SSIM_WINDOW_RADIUS = 15;
|
||||
const VARIANCE_WINDOW_RADIUS = 1;
|
||||
function drawPixel(width, data, x, y, r, g, b) {
|
||||
const idx = (y * width + x) * 4;
|
||||
data[idx + 0] = r;
|
||||
data[idx + 1] = g;
|
||||
data[idx + 2] = b;
|
||||
data[idx + 3] = 255;
|
||||
}
|
||||
function compare(actual, expected, diff, width, height, options = {}) {
|
||||
const {
|
||||
maxColorDeltaE94 = 1
|
||||
} = options;
|
||||
const paddingSize = Math.max(VARIANCE_WINDOW_RADIUS, SSIM_WINDOW_RADIUS);
|
||||
const paddingColorEven = [255, 0, 255];
|
||||
const paddingColorOdd = [0, 255, 0];
|
||||
const [r1, g1, b1] = import_imageChannel.ImageChannel.intoRGB(width, height, expected, {
|
||||
paddingSize,
|
||||
paddingColorEven,
|
||||
paddingColorOdd
|
||||
});
|
||||
const [r2, g2, b2] = import_imageChannel.ImageChannel.intoRGB(width, height, actual, {
|
||||
paddingSize,
|
||||
paddingColorEven,
|
||||
paddingColorOdd
|
||||
});
|
||||
const noop = (x, y) => {
|
||||
};
|
||||
const drawRedPixel = diff ? (x, y) => drawPixel(width, diff, x - paddingSize, y - paddingSize, 255, 0, 0) : noop;
|
||||
const drawYellowPixel = diff ? (x, y) => drawPixel(width, diff, x - paddingSize, y - paddingSize, 255, 255, 0) : noop;
|
||||
const drawGrayPixel = diff ? (x, y) => {
|
||||
const gray = (0, import_colorUtils.rgb2gray)(r1.get(x, y), g1.get(x, y), b1.get(x, y));
|
||||
const value = (0, import_colorUtils.blendWithWhite)(gray, 0.1);
|
||||
drawPixel(width, diff, x - paddingSize, y - paddingSize, value, value, value);
|
||||
} : noop;
|
||||
let fastR, fastG, fastB;
|
||||
let diffCount = 0;
|
||||
for (let y = paddingSize; y < r1.height - paddingSize; ++y) {
|
||||
for (let x = paddingSize; x < r1.width - paddingSize; ++x) {
|
||||
if (r1.get(x, y) === r2.get(x, y) && g1.get(x, y) === g2.get(x, y) && b1.get(x, y) === b2.get(x, y)) {
|
||||
drawGrayPixel(x, y);
|
||||
continue;
|
||||
}
|
||||
const delta = (0, import_colorUtils.colorDeltaE94)(
|
||||
[r1.get(x, y), g1.get(x, y), b1.get(x, y)],
|
||||
[r2.get(x, y), g2.get(x, y), b2.get(x, y)]
|
||||
);
|
||||
if (delta <= maxColorDeltaE94) {
|
||||
drawGrayPixel(x, y);
|
||||
continue;
|
||||
}
|
||||
if (!fastR || !fastG || !fastB) {
|
||||
fastR = new import_stats.FastStats(r1, r2);
|
||||
fastG = new import_stats.FastStats(g1, g2);
|
||||
fastB = new import_stats.FastStats(b1, b2);
|
||||
}
|
||||
const [varX1, varY1] = r1.boundXY(x - VARIANCE_WINDOW_RADIUS, y - VARIANCE_WINDOW_RADIUS);
|
||||
const [varX2, varY2] = r1.boundXY(x + VARIANCE_WINDOW_RADIUS, y + VARIANCE_WINDOW_RADIUS);
|
||||
const var1 = fastR.varianceC1(varX1, varY1, varX2, varY2) + fastG.varianceC1(varX1, varY1, varX2, varY2) + fastB.varianceC1(varX1, varY1, varX2, varY2);
|
||||
const var2 = fastR.varianceC2(varX1, varY1, varX2, varY2) + fastG.varianceC2(varX1, varY1, varX2, varY2) + fastB.varianceC2(varX1, varY1, varX2, varY2);
|
||||
if (var1 === 0 || var2 === 0) {
|
||||
drawRedPixel(x, y);
|
||||
++diffCount;
|
||||
continue;
|
||||
}
|
||||
const [ssimX1, ssimY1] = r1.boundXY(x - SSIM_WINDOW_RADIUS, y - SSIM_WINDOW_RADIUS);
|
||||
const [ssimX2, ssimY2] = r1.boundXY(x + SSIM_WINDOW_RADIUS, y + SSIM_WINDOW_RADIUS);
|
||||
const ssimRGB = ((0, import_stats.ssim)(fastR, ssimX1, ssimY1, ssimX2, ssimY2) + (0, import_stats.ssim)(fastG, ssimX1, ssimY1, ssimX2, ssimY2) + (0, import_stats.ssim)(fastB, ssimX1, ssimY1, ssimX2, ssimY2)) / 3;
|
||||
const isAntialiased = ssimRGB >= 0.99;
|
||||
if (isAntialiased) {
|
||||
drawYellowPixel(x, y);
|
||||
} else {
|
||||
drawRedPixel(x, y);
|
||||
++diffCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
return diffCount;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
compare
|
||||
});
|
78
node_modules/playwright-core/lib/server/utils/image_tools/imageChannel.js
generated
vendored
Normal file
78
node_modules/playwright-core/lib/server/utils/image_tools/imageChannel.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 imageChannel_exports = {};
|
||||
__export(imageChannel_exports, {
|
||||
ImageChannel: () => ImageChannel
|
||||
});
|
||||
module.exports = __toCommonJS(imageChannel_exports);
|
||||
var import_colorUtils = require("./colorUtils");
|
||||
class ImageChannel {
|
||||
static intoRGB(width, height, data, options = {}) {
|
||||
const {
|
||||
paddingSize = 0,
|
||||
paddingColorOdd = [255, 0, 255],
|
||||
paddingColorEven = [0, 255, 0]
|
||||
} = options;
|
||||
const newWidth = width + 2 * paddingSize;
|
||||
const newHeight = height + 2 * paddingSize;
|
||||
const r = new Uint8Array(newWidth * newHeight);
|
||||
const g = new Uint8Array(newWidth * newHeight);
|
||||
const b = new Uint8Array(newWidth * newHeight);
|
||||
for (let y = 0; y < newHeight; ++y) {
|
||||
for (let x = 0; x < newWidth; ++x) {
|
||||
const index = y * newWidth + x;
|
||||
if (y >= paddingSize && y < newHeight - paddingSize && x >= paddingSize && x < newWidth - paddingSize) {
|
||||
const offset = ((y - paddingSize) * width + (x - paddingSize)) * 4;
|
||||
const alpha = data[offset + 3] === 255 ? 1 : data[offset + 3] / 255;
|
||||
r[index] = (0, import_colorUtils.blendWithWhite)(data[offset], alpha);
|
||||
g[index] = (0, import_colorUtils.blendWithWhite)(data[offset + 1], alpha);
|
||||
b[index] = (0, import_colorUtils.blendWithWhite)(data[offset + 2], alpha);
|
||||
} else {
|
||||
const color = (y + x) % 2 === 0 ? paddingColorEven : paddingColorOdd;
|
||||
r[index] = color[0];
|
||||
g[index] = color[1];
|
||||
b[index] = color[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
return [
|
||||
new ImageChannel(newWidth, newHeight, r),
|
||||
new ImageChannel(newWidth, newHeight, g),
|
||||
new ImageChannel(newWidth, newHeight, b)
|
||||
];
|
||||
}
|
||||
constructor(width, height, data) {
|
||||
this.data = data;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
get(x, y) {
|
||||
return this.data[y * this.width + x];
|
||||
}
|
||||
boundXY(x, y) {
|
||||
return [
|
||||
Math.min(Math.max(x, 0), this.width - 1),
|
||||
Math.min(Math.max(y, 0), this.height - 1)
|
||||
];
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
ImageChannel
|
||||
});
|
102
node_modules/playwright-core/lib/server/utils/image_tools/stats.js
generated
vendored
Normal file
102
node_modules/playwright-core/lib/server/utils/image_tools/stats.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
"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 stats_exports = {};
|
||||
__export(stats_exports, {
|
||||
FastStats: () => FastStats,
|
||||
ssim: () => ssim
|
||||
});
|
||||
module.exports = __toCommonJS(stats_exports);
|
||||
const DYNAMIC_RANGE = 2 ** 8 - 1;
|
||||
function ssim(stats, x1, y1, x2, y2) {
|
||||
const mean1 = stats.meanC1(x1, y1, x2, y2);
|
||||
const mean2 = stats.meanC2(x1, y1, x2, y2);
|
||||
const var1 = stats.varianceC1(x1, y1, x2, y2);
|
||||
const var2 = stats.varianceC2(x1, y1, x2, y2);
|
||||
const cov = stats.covariance(x1, y1, x2, y2);
|
||||
const c1 = (0.01 * DYNAMIC_RANGE) ** 2;
|
||||
const c2 = (0.03 * DYNAMIC_RANGE) ** 2;
|
||||
return (2 * mean1 * mean2 + c1) * (2 * cov + c2) / (mean1 ** 2 + mean2 ** 2 + c1) / (var1 + var2 + c2);
|
||||
}
|
||||
class FastStats {
|
||||
constructor(c1, c2) {
|
||||
this.c1 = c1;
|
||||
this.c2 = c2;
|
||||
const { width, height } = c1;
|
||||
this._partialSumC1 = new Array(width * height);
|
||||
this._partialSumC2 = new Array(width * height);
|
||||
this._partialSumSq1 = new Array(width * height);
|
||||
this._partialSumSq2 = new Array(width * height);
|
||||
this._partialSumMult = new Array(width * height);
|
||||
const recalc = (mx, idx, initial, x, y) => {
|
||||
mx[idx] = initial;
|
||||
if (y > 0)
|
||||
mx[idx] += mx[(y - 1) * width + x];
|
||||
if (x > 0)
|
||||
mx[idx] += mx[y * width + x - 1];
|
||||
if (x > 0 && y > 0)
|
||||
mx[idx] -= mx[(y - 1) * width + x - 1];
|
||||
};
|
||||
for (let y = 0; y < height; ++y) {
|
||||
for (let x = 0; x < width; ++x) {
|
||||
const idx = y * width + x;
|
||||
recalc(this._partialSumC1, idx, this.c1.data[idx], x, y);
|
||||
recalc(this._partialSumC2, idx, this.c2.data[idx], x, y);
|
||||
recalc(this._partialSumSq1, idx, this.c1.data[idx] * this.c1.data[idx], x, y);
|
||||
recalc(this._partialSumSq2, idx, this.c2.data[idx] * this.c2.data[idx], x, y);
|
||||
recalc(this._partialSumMult, idx, this.c1.data[idx] * this.c2.data[idx], x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
_sum(partialSum, x1, y1, x2, y2) {
|
||||
const width = this.c1.width;
|
||||
let result = partialSum[y2 * width + x2];
|
||||
if (y1 > 0)
|
||||
result -= partialSum[(y1 - 1) * width + x2];
|
||||
if (x1 > 0)
|
||||
result -= partialSum[y2 * width + x1 - 1];
|
||||
if (x1 > 0 && y1 > 0)
|
||||
result += partialSum[(y1 - 1) * width + x1 - 1];
|
||||
return result;
|
||||
}
|
||||
meanC1(x1, y1, x2, y2) {
|
||||
const N = (y2 - y1 + 1) * (x2 - x1 + 1);
|
||||
return this._sum(this._partialSumC1, x1, y1, x2, y2) / N;
|
||||
}
|
||||
meanC2(x1, y1, x2, y2) {
|
||||
const N = (y2 - y1 + 1) * (x2 - x1 + 1);
|
||||
return this._sum(this._partialSumC2, x1, y1, x2, y2) / N;
|
||||
}
|
||||
varianceC1(x1, y1, x2, y2) {
|
||||
const N = (y2 - y1 + 1) * (x2 - x1 + 1);
|
||||
return (this._sum(this._partialSumSq1, x1, y1, x2, y2) - this._sum(this._partialSumC1, x1, y1, x2, y2) ** 2 / N) / N;
|
||||
}
|
||||
varianceC2(x1, y1, x2, y2) {
|
||||
const N = (y2 - y1 + 1) * (x2 - x1 + 1);
|
||||
return (this._sum(this._partialSumSq2, x1, y1, x2, y2) - this._sum(this._partialSumC2, x1, y1, x2, y2) ** 2 / N) / N;
|
||||
}
|
||||
covariance(x1, y1, x2, y2) {
|
||||
const N = (y2 - y1 + 1) * (x2 - x1 + 1);
|
||||
return (this._sum(this._partialSumMult, x1, y1, x2, y2) - this._sum(this._partialSumC1, x1, y1, x2, y2) * this._sum(this._partialSumC2, x1, y1, x2, y2) / N) / N;
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
FastStats,
|
||||
ssim
|
||||
});
|
71
node_modules/playwright-core/lib/server/utils/linuxUtils.js
generated
vendored
Normal file
71
node_modules/playwright-core/lib/server/utils/linuxUtils.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
"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 linuxUtils_exports = {};
|
||||
__export(linuxUtils_exports, {
|
||||
getLinuxDistributionInfoSync: () => getLinuxDistributionInfoSync
|
||||
});
|
||||
module.exports = __toCommonJS(linuxUtils_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
let didFailToReadOSRelease = false;
|
||||
let osRelease;
|
||||
function getLinuxDistributionInfoSync() {
|
||||
if (process.platform !== "linux")
|
||||
return void 0;
|
||||
if (!osRelease && !didFailToReadOSRelease) {
|
||||
try {
|
||||
const osReleaseText = import_fs.default.readFileSync("/etc/os-release", "utf8");
|
||||
const fields = parseOSReleaseText(osReleaseText);
|
||||
osRelease = {
|
||||
id: fields.get("id") ?? "",
|
||||
version: fields.get("version_id") ?? ""
|
||||
};
|
||||
} catch (e) {
|
||||
didFailToReadOSRelease = true;
|
||||
}
|
||||
}
|
||||
return osRelease;
|
||||
}
|
||||
function parseOSReleaseText(osReleaseText) {
|
||||
const fields = /* @__PURE__ */ new Map();
|
||||
for (const line of osReleaseText.split("\n")) {
|
||||
const tokens = line.split("=");
|
||||
const name = tokens.shift();
|
||||
let value = tokens.join("=").trim();
|
||||
if (value.startsWith('"') && value.endsWith('"'))
|
||||
value = value.substring(1, value.length - 1);
|
||||
if (!name)
|
||||
continue;
|
||||
fields.set(name.toLowerCase(), value);
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
getLinuxDistributionInfoSync
|
||||
});
|
227
node_modules/playwright-core/lib/server/utils/network.js
generated
vendored
Normal file
227
node_modules/playwright-core/lib/server/utils/network.js
generated
vendored
Normal file
@@ -0,0 +1,227 @@
|
||||
"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 network_exports = {};
|
||||
__export(network_exports, {
|
||||
NET_DEFAULT_TIMEOUT: () => NET_DEFAULT_TIMEOUT,
|
||||
createHttp2Server: () => createHttp2Server,
|
||||
createHttpServer: () => createHttpServer,
|
||||
createHttpsServer: () => createHttpsServer,
|
||||
createProxyAgent: () => createProxyAgent,
|
||||
fetchData: () => fetchData,
|
||||
httpRequest: () => httpRequest,
|
||||
isURLAvailable: () => isURLAvailable
|
||||
});
|
||||
module.exports = __toCommonJS(network_exports);
|
||||
var import_http = __toESM(require("http"));
|
||||
var import_http2 = __toESM(require("http2"));
|
||||
var import_https = __toESM(require("https"));
|
||||
var import_url = __toESM(require("url"));
|
||||
var import_utilsBundle = require("../../utilsBundle");
|
||||
var import_happyEyeballs = require("./happyEyeballs");
|
||||
var import_manualPromise = require("../../utils/isomorphic/manualPromise");
|
||||
const NET_DEFAULT_TIMEOUT = 3e4;
|
||||
function httpRequest(params, onResponse, onError) {
|
||||
const parsedUrl = import_url.default.parse(params.url);
|
||||
let options = {
|
||||
...parsedUrl,
|
||||
agent: parsedUrl.protocol === "https:" ? import_happyEyeballs.httpsHappyEyeballsAgent : import_happyEyeballs.httpHappyEyeballsAgent,
|
||||
method: params.method || "GET",
|
||||
headers: params.headers
|
||||
};
|
||||
if (params.rejectUnauthorized !== void 0)
|
||||
options.rejectUnauthorized = params.rejectUnauthorized;
|
||||
const proxyURL = (0, import_utilsBundle.getProxyForUrl)(params.url);
|
||||
if (proxyURL) {
|
||||
const parsedProxyURL = import_url.default.parse(proxyURL);
|
||||
if (params.url.startsWith("http:")) {
|
||||
options = {
|
||||
path: parsedUrl.href,
|
||||
host: parsedProxyURL.hostname,
|
||||
port: parsedProxyURL.port,
|
||||
headers: options.headers,
|
||||
method: options.method
|
||||
};
|
||||
} else {
|
||||
parsedProxyURL.secureProxy = parsedProxyURL.protocol === "https:";
|
||||
options.agent = new import_utilsBundle.HttpsProxyAgent(parsedProxyURL);
|
||||
options.rejectUnauthorized = false;
|
||||
}
|
||||
}
|
||||
let cancelRequest;
|
||||
const requestCallback = (res) => {
|
||||
const statusCode = res.statusCode || 0;
|
||||
if (statusCode >= 300 && statusCode < 400 && res.headers.location) {
|
||||
request.destroy();
|
||||
cancelRequest = httpRequest({ ...params, url: new URL(res.headers.location, params.url).toString() }, onResponse, onError).cancel;
|
||||
} else {
|
||||
onResponse(res);
|
||||
}
|
||||
};
|
||||
const request = options.protocol === "https:" ? import_https.default.request(options, requestCallback) : import_http.default.request(options, requestCallback);
|
||||
request.on("error", onError);
|
||||
if (params.socketTimeout !== void 0) {
|
||||
request.setTimeout(params.socketTimeout, () => {
|
||||
onError(new Error(`Request to ${params.url} timed out after ${params.socketTimeout}ms`));
|
||||
request.abort();
|
||||
});
|
||||
}
|
||||
cancelRequest = (e) => {
|
||||
try {
|
||||
request.destroy(e);
|
||||
} catch {
|
||||
}
|
||||
};
|
||||
request.end(params.data);
|
||||
return { cancel: (e) => cancelRequest(e) };
|
||||
}
|
||||
async function fetchData(progress, params, onError) {
|
||||
const promise = new import_manualPromise.ManualPromise();
|
||||
const { cancel } = httpRequest(params, async (response) => {
|
||||
if (response.statusCode !== 200) {
|
||||
const error = onError ? await onError(params, response) : new Error(`fetch failed: server returned code ${response.statusCode}. URL: ${params.url}`);
|
||||
promise.reject(error);
|
||||
return;
|
||||
}
|
||||
let body = "";
|
||||
response.on("data", (chunk) => body += chunk);
|
||||
response.on("error", (error) => promise.reject(error));
|
||||
response.on("end", () => promise.resolve(body));
|
||||
}, (error) => promise.reject(error));
|
||||
if (!progress)
|
||||
return promise;
|
||||
try {
|
||||
return await progress.race(promise);
|
||||
} catch (error) {
|
||||
cancel(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
function shouldBypassProxy(url2, bypass) {
|
||||
if (!bypass)
|
||||
return false;
|
||||
const domains = bypass.split(",").map((s) => {
|
||||
s = s.trim();
|
||||
if (!s.startsWith("."))
|
||||
s = "." + s;
|
||||
return s;
|
||||
});
|
||||
const domain = "." + url2.hostname;
|
||||
return domains.some((d) => domain.endsWith(d));
|
||||
}
|
||||
function createProxyAgent(proxy, forUrl) {
|
||||
if (!proxy)
|
||||
return;
|
||||
if (forUrl && proxy.bypass && shouldBypassProxy(forUrl, proxy.bypass))
|
||||
return;
|
||||
let proxyServer = proxy.server.trim();
|
||||
if (!/^\w+:\/\//.test(proxyServer))
|
||||
proxyServer = "http://" + proxyServer;
|
||||
const proxyOpts = import_url.default.parse(proxyServer);
|
||||
if (proxyOpts.protocol?.startsWith("socks")) {
|
||||
return new import_utilsBundle.SocksProxyAgent({
|
||||
host: proxyOpts.hostname,
|
||||
port: proxyOpts.port || void 0
|
||||
});
|
||||
}
|
||||
if (proxy.username)
|
||||
proxyOpts.auth = `${proxy.username}:${proxy.password || ""}`;
|
||||
if (forUrl && ["ws:", "wss:"].includes(forUrl.protocol)) {
|
||||
return new import_utilsBundle.HttpsProxyAgent(proxyOpts);
|
||||
}
|
||||
return new import_utilsBundle.HttpsProxyAgent(proxyOpts);
|
||||
}
|
||||
function createHttpServer(...args) {
|
||||
const server = import_http.default.createServer(...args);
|
||||
decorateServer(server);
|
||||
return server;
|
||||
}
|
||||
function createHttpsServer(...args) {
|
||||
const server = import_https.default.createServer(...args);
|
||||
decorateServer(server);
|
||||
return server;
|
||||
}
|
||||
function createHttp2Server(...args) {
|
||||
const server = import_http2.default.createSecureServer(...args);
|
||||
decorateServer(server);
|
||||
return server;
|
||||
}
|
||||
async function isURLAvailable(url2, ignoreHTTPSErrors, onLog, onStdErr) {
|
||||
let statusCode = await httpStatusCode(url2, ignoreHTTPSErrors, onLog, onStdErr);
|
||||
if (statusCode === 404 && url2.pathname === "/") {
|
||||
const indexUrl = new URL(url2);
|
||||
indexUrl.pathname = "/index.html";
|
||||
statusCode = await httpStatusCode(indexUrl, ignoreHTTPSErrors, onLog, onStdErr);
|
||||
}
|
||||
return statusCode >= 200 && statusCode < 404;
|
||||
}
|
||||
async function httpStatusCode(url2, ignoreHTTPSErrors, onLog, onStdErr) {
|
||||
return new Promise((resolve) => {
|
||||
onLog?.(`HTTP GET: ${url2}`);
|
||||
httpRequest({
|
||||
url: url2.toString(),
|
||||
headers: { Accept: "*/*" },
|
||||
rejectUnauthorized: !ignoreHTTPSErrors
|
||||
}, (res) => {
|
||||
res.resume();
|
||||
const statusCode = res.statusCode ?? 0;
|
||||
onLog?.(`HTTP Status: ${statusCode}`);
|
||||
resolve(statusCode);
|
||||
}, (error) => {
|
||||
if (error.code === "DEPTH_ZERO_SELF_SIGNED_CERT")
|
||||
onStdErr?.(`[WebServer] Self-signed certificate detected. Try adding ignoreHTTPSErrors: true to config.webServer.`);
|
||||
onLog?.(`Error while checking if ${url2} is available: ${error.message}`);
|
||||
resolve(0);
|
||||
});
|
||||
});
|
||||
}
|
||||
function decorateServer(server) {
|
||||
const sockets = /* @__PURE__ */ new Set();
|
||||
server.on("connection", (socket) => {
|
||||
sockets.add(socket);
|
||||
socket.once("close", () => sockets.delete(socket));
|
||||
});
|
||||
const close = server.close;
|
||||
server.close = (callback) => {
|
||||
for (const socket of sockets)
|
||||
socket.destroy();
|
||||
sockets.clear();
|
||||
return close.call(server, callback);
|
||||
};
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
NET_DEFAULT_TIMEOUT,
|
||||
createHttp2Server,
|
||||
createHttpServer,
|
||||
createHttpsServer,
|
||||
createProxyAgent,
|
||||
fetchData,
|
||||
httpRequest,
|
||||
isURLAvailable
|
||||
});
|
148
node_modules/playwright-core/lib/server/utils/nodePlatform.js
generated
vendored
Normal file
148
node_modules/playwright-core/lib/server/utils/nodePlatform.js
generated
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
"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 nodePlatform_exports = {};
|
||||
__export(nodePlatform_exports, {
|
||||
nodePlatform: () => nodePlatform,
|
||||
setBoxedStackPrefixes: () => setBoxedStackPrefixes
|
||||
});
|
||||
module.exports = __toCommonJS(nodePlatform_exports);
|
||||
var import_crypto = __toESM(require("crypto"));
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var import_path = __toESM(require("path"));
|
||||
var util = __toESM(require("util"));
|
||||
var import_stream = require("stream");
|
||||
var import_events = require("events");
|
||||
var import_utilsBundle = require("../../utilsBundle");
|
||||
var import_debugLogger = require("./debugLogger");
|
||||
var import_zones = require("./zones");
|
||||
var import_debug = require("./debug");
|
||||
const pipelineAsync = util.promisify(import_stream.pipeline);
|
||||
class NodeZone {
|
||||
constructor(zone) {
|
||||
this._zone = zone;
|
||||
}
|
||||
push(data) {
|
||||
return new NodeZone(this._zone.with("apiZone", data));
|
||||
}
|
||||
pop() {
|
||||
return new NodeZone(this._zone.without("apiZone"));
|
||||
}
|
||||
run(func) {
|
||||
return this._zone.run(func);
|
||||
}
|
||||
data() {
|
||||
return this._zone.data("apiZone");
|
||||
}
|
||||
}
|
||||
let boxedStackPrefixes = [];
|
||||
function setBoxedStackPrefixes(prefixes) {
|
||||
boxedStackPrefixes = prefixes;
|
||||
}
|
||||
const coreDir = import_path.default.dirname(require.resolve("../../../package.json"));
|
||||
const nodePlatform = {
|
||||
name: "node",
|
||||
boxedStackPrefixes: () => {
|
||||
if (process.env.PWDEBUGIMPL)
|
||||
return [];
|
||||
return [coreDir, ...boxedStackPrefixes];
|
||||
},
|
||||
calculateSha1: (text) => {
|
||||
const sha1 = import_crypto.default.createHash("sha1");
|
||||
sha1.update(text);
|
||||
return Promise.resolve(sha1.digest("hex"));
|
||||
},
|
||||
colors: import_utilsBundle.colors,
|
||||
coreDir,
|
||||
createGuid: () => import_crypto.default.randomBytes(16).toString("hex"),
|
||||
defaultMaxListeners: () => import_events.EventEmitter.defaultMaxListeners,
|
||||
fs: () => import_fs.default,
|
||||
env: process.env,
|
||||
inspectCustom: util.inspect.custom,
|
||||
isDebugMode: () => (0, import_debug.debugMode)() === "inspector",
|
||||
isJSDebuggerAttached: () => !!require("inspector").url(),
|
||||
isLogEnabled(name) {
|
||||
return import_debugLogger.debugLogger.isEnabled(name);
|
||||
},
|
||||
isUnderTest: () => (0, import_debug.isUnderTest)(),
|
||||
log(name, message) {
|
||||
import_debugLogger.debugLogger.log(name, message);
|
||||
},
|
||||
path: () => import_path.default,
|
||||
pathSeparator: import_path.default.sep,
|
||||
showInternalStackFrames: () => !!process.env.PWDEBUGIMPL,
|
||||
async streamFile(path2, stream) {
|
||||
await pipelineAsync(import_fs.default.createReadStream(path2), stream);
|
||||
},
|
||||
streamReadable: (channel) => {
|
||||
return new ReadableStreamImpl(channel);
|
||||
},
|
||||
streamWritable: (channel) => {
|
||||
return new WritableStreamImpl(channel);
|
||||
},
|
||||
zones: {
|
||||
current: () => new NodeZone((0, import_zones.currentZone)()),
|
||||
empty: new NodeZone(import_zones.emptyZone)
|
||||
}
|
||||
};
|
||||
class ReadableStreamImpl extends import_stream.Readable {
|
||||
constructor(channel) {
|
||||
super();
|
||||
this._channel = channel;
|
||||
}
|
||||
async _read() {
|
||||
const result = await this._channel.read({ size: 1024 * 1024 });
|
||||
if (result.binary.byteLength)
|
||||
this.push(result.binary);
|
||||
else
|
||||
this.push(null);
|
||||
}
|
||||
_destroy(error, callback) {
|
||||
this._channel.close().catch((e) => null);
|
||||
super._destroy(error, callback);
|
||||
}
|
||||
}
|
||||
class WritableStreamImpl extends import_stream.Writable {
|
||||
constructor(channel) {
|
||||
super();
|
||||
this._channel = channel;
|
||||
}
|
||||
async _write(chunk, encoding, callback) {
|
||||
const error = await this._channel.write({ binary: typeof chunk === "string" ? Buffer.from(chunk) : chunk }).catch((e) => e);
|
||||
callback(error || null);
|
||||
}
|
||||
async _final(callback) {
|
||||
const error = await this._channel.close().catch((e) => e);
|
||||
callback(error || null);
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
nodePlatform,
|
||||
setBoxedStackPrefixes
|
||||
});
|
84
node_modules/playwright-core/lib/server/utils/pipeTransport.js
generated
vendored
Normal file
84
node_modules/playwright-core/lib/server/utils/pipeTransport.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
"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 pipeTransport_exports = {};
|
||||
__export(pipeTransport_exports, {
|
||||
PipeTransport: () => PipeTransport
|
||||
});
|
||||
module.exports = __toCommonJS(pipeTransport_exports);
|
||||
var import_task = require("./task");
|
||||
class PipeTransport {
|
||||
constructor(pipeWrite, pipeRead, closeable, endian = "le") {
|
||||
this._data = Buffer.from([]);
|
||||
this._waitForNextTask = (0, import_task.makeWaitForNextTask)();
|
||||
this._closed = false;
|
||||
this._bytesLeft = 0;
|
||||
this._pipeWrite = pipeWrite;
|
||||
this._endian = endian;
|
||||
this._closeableStream = closeable;
|
||||
pipeRead.on("data", (buffer) => this._dispatch(buffer));
|
||||
pipeRead.on("close", () => {
|
||||
this._closed = true;
|
||||
if (this.onclose)
|
||||
this.onclose();
|
||||
});
|
||||
this.onmessage = void 0;
|
||||
this.onclose = void 0;
|
||||
}
|
||||
send(message) {
|
||||
if (this._closed)
|
||||
throw new Error("Pipe has been closed");
|
||||
const data = Buffer.from(message, "utf-8");
|
||||
const dataLength = Buffer.alloc(4);
|
||||
if (this._endian === "be")
|
||||
dataLength.writeUInt32BE(data.length, 0);
|
||||
else
|
||||
dataLength.writeUInt32LE(data.length, 0);
|
||||
this._pipeWrite.write(dataLength);
|
||||
this._pipeWrite.write(data);
|
||||
}
|
||||
close() {
|
||||
this._closeableStream.close();
|
||||
}
|
||||
_dispatch(buffer) {
|
||||
this._data = Buffer.concat([this._data, buffer]);
|
||||
while (true) {
|
||||
if (!this._bytesLeft && this._data.length < 4) {
|
||||
break;
|
||||
}
|
||||
if (!this._bytesLeft) {
|
||||
this._bytesLeft = this._endian === "be" ? this._data.readUInt32BE(0) : this._data.readUInt32LE(0);
|
||||
this._data = this._data.slice(4);
|
||||
}
|
||||
if (!this._bytesLeft || this._data.length < this._bytesLeft) {
|
||||
break;
|
||||
}
|
||||
const message = this._data.slice(0, this._bytesLeft);
|
||||
this._data = this._data.slice(this._bytesLeft);
|
||||
this._bytesLeft = 0;
|
||||
this._waitForNextTask(() => {
|
||||
if (this.onmessage)
|
||||
this.onmessage(message.toString("utf-8"));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
PipeTransport
|
||||
});
|
241
node_modules/playwright-core/lib/server/utils/processLauncher.js
generated
vendored
Normal file
241
node_modules/playwright-core/lib/server/utils/processLauncher.js
generated
vendored
Normal file
@@ -0,0 +1,241 @@
|
||||
"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 processLauncher_exports = {};
|
||||
__export(processLauncher_exports, {
|
||||
envArrayToObject: () => envArrayToObject,
|
||||
gracefullyCloseAll: () => gracefullyCloseAll,
|
||||
gracefullyCloseSet: () => gracefullyCloseSet,
|
||||
gracefullyProcessExitDoNotHang: () => gracefullyProcessExitDoNotHang,
|
||||
launchProcess: () => launchProcess
|
||||
});
|
||||
module.exports = __toCommonJS(processLauncher_exports);
|
||||
var childProcess = __toESM(require("child_process"));
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var readline = __toESM(require("readline"));
|
||||
var import_fileUtils = require("./fileUtils");
|
||||
var import_utils = require("../../utils");
|
||||
const gracefullyCloseSet = /* @__PURE__ */ new Set();
|
||||
const killSet = /* @__PURE__ */ new Set();
|
||||
async function gracefullyCloseAll() {
|
||||
await Promise.all(Array.from(gracefullyCloseSet).map((gracefullyClose) => gracefullyClose().catch((e) => {
|
||||
})));
|
||||
}
|
||||
function gracefullyProcessExitDoNotHang(code) {
|
||||
setTimeout(() => process.exit(code), 3e4);
|
||||
gracefullyCloseAll().then(() => {
|
||||
process.exit(code);
|
||||
});
|
||||
}
|
||||
function exitHandler() {
|
||||
for (const kill of killSet)
|
||||
kill();
|
||||
}
|
||||
let sigintHandlerCalled = false;
|
||||
function sigintHandler() {
|
||||
const exitWithCode130 = () => {
|
||||
if ((0, import_utils.isUnderTest)()) {
|
||||
setTimeout(() => process.exit(130), 1e3);
|
||||
} else {
|
||||
process.exit(130);
|
||||
}
|
||||
};
|
||||
if (sigintHandlerCalled) {
|
||||
process.off("SIGINT", sigintHandler);
|
||||
for (const kill of killSet)
|
||||
kill();
|
||||
exitWithCode130();
|
||||
} else {
|
||||
sigintHandlerCalled = true;
|
||||
gracefullyCloseAll().then(() => exitWithCode130());
|
||||
}
|
||||
}
|
||||
function sigtermHandler() {
|
||||
gracefullyCloseAll();
|
||||
}
|
||||
function sighupHandler() {
|
||||
gracefullyCloseAll();
|
||||
}
|
||||
const installedHandlers = /* @__PURE__ */ new Set();
|
||||
const processHandlers = {
|
||||
exit: exitHandler,
|
||||
SIGINT: sigintHandler,
|
||||
SIGTERM: sigtermHandler,
|
||||
SIGHUP: sighupHandler
|
||||
};
|
||||
function addProcessHandlerIfNeeded(name) {
|
||||
if (!installedHandlers.has(name)) {
|
||||
installedHandlers.add(name);
|
||||
process.on(name, processHandlers[name]);
|
||||
}
|
||||
}
|
||||
function removeProcessHandlersIfNeeded() {
|
||||
if (killSet.size)
|
||||
return;
|
||||
for (const handler of installedHandlers)
|
||||
process.off(handler, processHandlers[handler]);
|
||||
installedHandlers.clear();
|
||||
}
|
||||
async function launchProcess(options) {
|
||||
const stdio = options.stdio === "pipe" ? ["ignore", "pipe", "pipe", "pipe", "pipe"] : ["pipe", "pipe", "pipe"];
|
||||
options.log(`<launching> ${options.command} ${options.args ? options.args.join(" ") : ""}`);
|
||||
const spawnOptions = {
|
||||
// On non-windows platforms, `detached: true` makes child process a leader of a new
|
||||
// process group, making it possible to kill child process tree with `.kill(-pid)` command.
|
||||
// @see https://nodejs.org/api/child_process.html#child_process_options_detached
|
||||
detached: process.platform !== "win32",
|
||||
env: options.env,
|
||||
cwd: options.cwd,
|
||||
shell: options.shell,
|
||||
stdio
|
||||
};
|
||||
const spawnedProcess = childProcess.spawn(options.command, options.args || [], spawnOptions);
|
||||
const cleanup = async () => {
|
||||
options.log(`[pid=${spawnedProcess.pid || "N/A"}] starting temporary directories cleanup`);
|
||||
const errors = await (0, import_fileUtils.removeFolders)(options.tempDirectories);
|
||||
for (let i = 0; i < options.tempDirectories.length; ++i) {
|
||||
if (errors[i])
|
||||
options.log(`[pid=${spawnedProcess.pid || "N/A"}] exception while removing ${options.tempDirectories[i]}: ${errors[i]}`);
|
||||
}
|
||||
options.log(`[pid=${spawnedProcess.pid || "N/A"}] finished temporary directories cleanup`);
|
||||
};
|
||||
spawnedProcess.on("error", () => {
|
||||
});
|
||||
if (!spawnedProcess.pid) {
|
||||
let failed;
|
||||
const failedPromise = new Promise((f, r) => failed = f);
|
||||
spawnedProcess.once("error", (error) => {
|
||||
failed(new Error("Failed to launch: " + error));
|
||||
});
|
||||
return failedPromise.then(async (error) => {
|
||||
await cleanup();
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
options.log(`<launched> pid=${spawnedProcess.pid}`);
|
||||
const stdout = readline.createInterface({ input: spawnedProcess.stdout });
|
||||
stdout.on("line", (data) => {
|
||||
options.log(`[pid=${spawnedProcess.pid}][out] ` + data);
|
||||
});
|
||||
const stderr = readline.createInterface({ input: spawnedProcess.stderr });
|
||||
stderr.on("line", (data) => {
|
||||
options.log(`[pid=${spawnedProcess.pid}][err] ` + data);
|
||||
});
|
||||
let processClosed = false;
|
||||
let fulfillCleanup = () => {
|
||||
};
|
||||
const waitForCleanup = new Promise((f) => fulfillCleanup = f);
|
||||
spawnedProcess.once("close", (exitCode, signal) => {
|
||||
options.log(`[pid=${spawnedProcess.pid}] <process did exit: exitCode=${exitCode}, signal=${signal}>`);
|
||||
processClosed = true;
|
||||
gracefullyCloseSet.delete(gracefullyClose);
|
||||
killSet.delete(killProcessAndCleanup);
|
||||
removeProcessHandlersIfNeeded();
|
||||
options.onExit(exitCode, signal);
|
||||
cleanup().then(fulfillCleanup);
|
||||
});
|
||||
addProcessHandlerIfNeeded("exit");
|
||||
if (options.handleSIGINT)
|
||||
addProcessHandlerIfNeeded("SIGINT");
|
||||
if (options.handleSIGTERM)
|
||||
addProcessHandlerIfNeeded("SIGTERM");
|
||||
if (options.handleSIGHUP)
|
||||
addProcessHandlerIfNeeded("SIGHUP");
|
||||
gracefullyCloseSet.add(gracefullyClose);
|
||||
killSet.add(killProcessAndCleanup);
|
||||
let gracefullyClosing = false;
|
||||
async function gracefullyClose() {
|
||||
if (gracefullyClosing) {
|
||||
options.log(`[pid=${spawnedProcess.pid}] <forcefully close>`);
|
||||
killProcess();
|
||||
await waitForCleanup;
|
||||
return;
|
||||
}
|
||||
gracefullyClosing = true;
|
||||
options.log(`[pid=${spawnedProcess.pid}] <gracefully close start>`);
|
||||
await options.attemptToGracefullyClose().catch(() => killProcess());
|
||||
await waitForCleanup;
|
||||
options.log(`[pid=${spawnedProcess.pid}] <gracefully close end>`);
|
||||
}
|
||||
function killProcess() {
|
||||
gracefullyCloseSet.delete(gracefullyClose);
|
||||
killSet.delete(killProcessAndCleanup);
|
||||
removeProcessHandlersIfNeeded();
|
||||
options.log(`[pid=${spawnedProcess.pid}] <kill>`);
|
||||
if (spawnedProcess.pid && !spawnedProcess.killed && !processClosed) {
|
||||
options.log(`[pid=${spawnedProcess.pid}] <will force kill>`);
|
||||
try {
|
||||
if (process.platform === "win32") {
|
||||
const taskkillProcess = childProcess.spawnSync(`taskkill /pid ${spawnedProcess.pid} /T /F`, { shell: true });
|
||||
const [stdout2, stderr2] = [taskkillProcess.stdout.toString(), taskkillProcess.stderr.toString()];
|
||||
if (stdout2)
|
||||
options.log(`[pid=${spawnedProcess.pid}] taskkill stdout: ${stdout2}`);
|
||||
if (stderr2)
|
||||
options.log(`[pid=${spawnedProcess.pid}] taskkill stderr: ${stderr2}`);
|
||||
} else {
|
||||
process.kill(-spawnedProcess.pid, "SIGKILL");
|
||||
}
|
||||
} catch (e) {
|
||||
options.log(`[pid=${spawnedProcess.pid}] exception while trying to kill process: ${e}`);
|
||||
}
|
||||
} else {
|
||||
options.log(`[pid=${spawnedProcess.pid}] <skipped force kill spawnedProcess.killed=${spawnedProcess.killed} processClosed=${processClosed}>`);
|
||||
}
|
||||
}
|
||||
function killProcessAndCleanup() {
|
||||
killProcess();
|
||||
options.log(`[pid=${spawnedProcess.pid || "N/A"}] starting temporary directories cleanup`);
|
||||
for (const dir of options.tempDirectories) {
|
||||
try {
|
||||
import_fs.default.rmSync(dir, { force: true, recursive: true, maxRetries: 5 });
|
||||
} catch (e) {
|
||||
options.log(`[pid=${spawnedProcess.pid || "N/A"}] exception while removing ${dir}: ${e}`);
|
||||
}
|
||||
}
|
||||
options.log(`[pid=${spawnedProcess.pid || "N/A"}] finished temporary directories cleanup`);
|
||||
}
|
||||
function killAndWait() {
|
||||
killProcess();
|
||||
return waitForCleanup;
|
||||
}
|
||||
return { launchedProcess: spawnedProcess, gracefullyClose, kill: killAndWait };
|
||||
}
|
||||
function envArrayToObject(env) {
|
||||
const result = {};
|
||||
for (const { name, value } of env)
|
||||
result[name] = value;
|
||||
return result;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
envArrayToObject,
|
||||
gracefullyCloseAll,
|
||||
gracefullyCloseSet,
|
||||
gracefullyProcessExitDoNotHang,
|
||||
launchProcess
|
||||
});
|
65
node_modules/playwright-core/lib/server/utils/profiler.js
generated
vendored
Normal file
65
node_modules/playwright-core/lib/server/utils/profiler.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
"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 profiler_exports = {};
|
||||
__export(profiler_exports, {
|
||||
startProfiling: () => startProfiling,
|
||||
stopProfiling: () => stopProfiling
|
||||
});
|
||||
module.exports = __toCommonJS(profiler_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var import_path = __toESM(require("path"));
|
||||
const profileDir = process.env.PWTEST_PROFILE_DIR || "";
|
||||
let session;
|
||||
async function startProfiling() {
|
||||
if (!profileDir)
|
||||
return;
|
||||
session = new (require("inspector")).Session();
|
||||
session.connect();
|
||||
await new Promise((f) => {
|
||||
session.post("Profiler.enable", () => {
|
||||
session.post("Profiler.start", f);
|
||||
});
|
||||
});
|
||||
}
|
||||
async function stopProfiling(profileName) {
|
||||
if (!profileDir)
|
||||
return;
|
||||
await new Promise((f) => session.post("Profiler.stop", (err, { profile }) => {
|
||||
if (!err) {
|
||||
import_fs.default.mkdirSync(profileDir, { recursive: true });
|
||||
import_fs.default.writeFileSync(import_path.default.join(profileDir, profileName + ".json"), JSON.stringify(profile));
|
||||
}
|
||||
f();
|
||||
}));
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
startProfiling,
|
||||
stopProfiling
|
||||
});
|
511
node_modules/playwright-core/lib/server/utils/socksProxy.js
generated
vendored
Normal file
511
node_modules/playwright-core/lib/server/utils/socksProxy.js
generated
vendored
Normal file
@@ -0,0 +1,511 @@
|
||||
"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 socksProxy_exports = {};
|
||||
__export(socksProxy_exports, {
|
||||
SocksProxy: () => SocksProxy,
|
||||
SocksProxyHandler: () => SocksProxyHandler,
|
||||
parsePattern: () => parsePattern
|
||||
});
|
||||
module.exports = __toCommonJS(socksProxy_exports);
|
||||
var import_events = __toESM(require("events"));
|
||||
var import_net = __toESM(require("net"));
|
||||
var import_assert = require("../../utils/isomorphic/assert");
|
||||
var import_crypto = require("./crypto");
|
||||
var import_debugLogger = require("./debugLogger");
|
||||
var import_happyEyeballs = require("./happyEyeballs");
|
||||
var SocksAuth = /* @__PURE__ */ ((SocksAuth2) => {
|
||||
SocksAuth2[SocksAuth2["NO_AUTHENTICATION_REQUIRED"] = 0] = "NO_AUTHENTICATION_REQUIRED";
|
||||
SocksAuth2[SocksAuth2["GSSAPI"] = 1] = "GSSAPI";
|
||||
SocksAuth2[SocksAuth2["USERNAME_PASSWORD"] = 2] = "USERNAME_PASSWORD";
|
||||
SocksAuth2[SocksAuth2["NO_ACCEPTABLE_METHODS"] = 255] = "NO_ACCEPTABLE_METHODS";
|
||||
return SocksAuth2;
|
||||
})(SocksAuth || {});
|
||||
var SocksAddressType = /* @__PURE__ */ ((SocksAddressType2) => {
|
||||
SocksAddressType2[SocksAddressType2["IPv4"] = 1] = "IPv4";
|
||||
SocksAddressType2[SocksAddressType2["FqName"] = 3] = "FqName";
|
||||
SocksAddressType2[SocksAddressType2["IPv6"] = 4] = "IPv6";
|
||||
return SocksAddressType2;
|
||||
})(SocksAddressType || {});
|
||||
var SocksCommand = /* @__PURE__ */ ((SocksCommand2) => {
|
||||
SocksCommand2[SocksCommand2["CONNECT"] = 1] = "CONNECT";
|
||||
SocksCommand2[SocksCommand2["BIND"] = 2] = "BIND";
|
||||
SocksCommand2[SocksCommand2["UDP_ASSOCIATE"] = 3] = "UDP_ASSOCIATE";
|
||||
return SocksCommand2;
|
||||
})(SocksCommand || {});
|
||||
var SocksReply = /* @__PURE__ */ ((SocksReply2) => {
|
||||
SocksReply2[SocksReply2["Succeeded"] = 0] = "Succeeded";
|
||||
SocksReply2[SocksReply2["GeneralServerFailure"] = 1] = "GeneralServerFailure";
|
||||
SocksReply2[SocksReply2["NotAllowedByRuleSet"] = 2] = "NotAllowedByRuleSet";
|
||||
SocksReply2[SocksReply2["NetworkUnreachable"] = 3] = "NetworkUnreachable";
|
||||
SocksReply2[SocksReply2["HostUnreachable"] = 4] = "HostUnreachable";
|
||||
SocksReply2[SocksReply2["ConnectionRefused"] = 5] = "ConnectionRefused";
|
||||
SocksReply2[SocksReply2["TtlExpired"] = 6] = "TtlExpired";
|
||||
SocksReply2[SocksReply2["CommandNotSupported"] = 7] = "CommandNotSupported";
|
||||
SocksReply2[SocksReply2["AddressTypeNotSupported"] = 8] = "AddressTypeNotSupported";
|
||||
return SocksReply2;
|
||||
})(SocksReply || {});
|
||||
class SocksConnection {
|
||||
constructor(uid, socket, client) {
|
||||
this._buffer = Buffer.from([]);
|
||||
this._offset = 0;
|
||||
this._fence = 0;
|
||||
this._uid = uid;
|
||||
this._socket = socket;
|
||||
this._client = client;
|
||||
this._boundOnData = this._onData.bind(this);
|
||||
socket.on("data", this._boundOnData);
|
||||
socket.on("close", () => this._onClose());
|
||||
socket.on("end", () => this._onClose());
|
||||
socket.on("error", () => this._onClose());
|
||||
this._run().catch(() => this._socket.end());
|
||||
}
|
||||
async _run() {
|
||||
(0, import_assert.assert)(await this._authenticate());
|
||||
const { command, host, port } = await this._parseRequest();
|
||||
if (command !== 1 /* CONNECT */) {
|
||||
this._writeBytes(Buffer.from([
|
||||
5,
|
||||
7 /* CommandNotSupported */,
|
||||
0,
|
||||
// RSV
|
||||
1,
|
||||
// IPv4
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
// Address
|
||||
0,
|
||||
0
|
||||
// Port
|
||||
]));
|
||||
return;
|
||||
}
|
||||
this._socket.off("data", this._boundOnData);
|
||||
this._client.onSocketRequested({ uid: this._uid, host, port });
|
||||
}
|
||||
async _authenticate() {
|
||||
const version = await this._readByte();
|
||||
(0, import_assert.assert)(version === 5, "The VER field must be set to x05 for this version of the protocol, was " + version);
|
||||
const nMethods = await this._readByte();
|
||||
(0, import_assert.assert)(nMethods, "No authentication methods specified");
|
||||
const methods = await this._readBytes(nMethods);
|
||||
for (const method of methods) {
|
||||
if (method === 0) {
|
||||
this._writeBytes(Buffer.from([version, method]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
this._writeBytes(Buffer.from([version, 255 /* NO_ACCEPTABLE_METHODS */]));
|
||||
return false;
|
||||
}
|
||||
async _parseRequest() {
|
||||
const version = await this._readByte();
|
||||
(0, import_assert.assert)(version === 5, "The VER field must be set to x05 for this version of the protocol, was " + version);
|
||||
const command = await this._readByte();
|
||||
await this._readByte();
|
||||
const addressType = await this._readByte();
|
||||
let host = "";
|
||||
switch (addressType) {
|
||||
case 1 /* IPv4 */:
|
||||
host = (await this._readBytes(4)).join(".");
|
||||
break;
|
||||
case 3 /* FqName */:
|
||||
const length = await this._readByte();
|
||||
host = (await this._readBytes(length)).toString();
|
||||
break;
|
||||
case 4 /* IPv6 */:
|
||||
const bytes = await this._readBytes(16);
|
||||
const tokens = [];
|
||||
for (let i = 0; i < 8; ++i)
|
||||
tokens.push(bytes.readUInt16BE(i * 2).toString(16));
|
||||
host = tokens.join(":");
|
||||
break;
|
||||
}
|
||||
const port = (await this._readBytes(2)).readUInt16BE(0);
|
||||
this._buffer = Buffer.from([]);
|
||||
this._offset = 0;
|
||||
this._fence = 0;
|
||||
return {
|
||||
command,
|
||||
host,
|
||||
port
|
||||
};
|
||||
}
|
||||
async _readByte() {
|
||||
const buffer = await this._readBytes(1);
|
||||
return buffer[0];
|
||||
}
|
||||
async _readBytes(length) {
|
||||
this._fence = this._offset + length;
|
||||
if (!this._buffer || this._buffer.length < this._fence)
|
||||
await new Promise((f) => this._fenceCallback = f);
|
||||
this._offset += length;
|
||||
return this._buffer.slice(this._offset - length, this._offset);
|
||||
}
|
||||
_writeBytes(buffer) {
|
||||
if (this._socket.writable)
|
||||
this._socket.write(buffer);
|
||||
}
|
||||
_onClose() {
|
||||
this._client.onSocketClosed({ uid: this._uid });
|
||||
}
|
||||
_onData(buffer) {
|
||||
this._buffer = Buffer.concat([this._buffer, buffer]);
|
||||
if (this._fenceCallback && this._buffer.length >= this._fence) {
|
||||
const callback = this._fenceCallback;
|
||||
this._fenceCallback = void 0;
|
||||
callback();
|
||||
}
|
||||
}
|
||||
socketConnected(host, port) {
|
||||
this._writeBytes(Buffer.from([
|
||||
5,
|
||||
0 /* Succeeded */,
|
||||
0,
|
||||
// RSV
|
||||
...ipToSocksAddress(host),
|
||||
// ATYP, Address
|
||||
port >> 8,
|
||||
port & 255
|
||||
// Port
|
||||
]));
|
||||
this._socket.on("data", (data) => this._client.onSocketData({ uid: this._uid, data }));
|
||||
}
|
||||
socketFailed(errorCode) {
|
||||
const buffer = Buffer.from([
|
||||
5,
|
||||
0,
|
||||
0,
|
||||
// RSV
|
||||
...ipToSocksAddress("0.0.0.0"),
|
||||
// ATYP, Address
|
||||
0,
|
||||
0
|
||||
// Port
|
||||
]);
|
||||
switch (errorCode) {
|
||||
case "ENOENT":
|
||||
case "ENOTFOUND":
|
||||
case "ETIMEDOUT":
|
||||
case "EHOSTUNREACH":
|
||||
buffer[1] = 4 /* HostUnreachable */;
|
||||
break;
|
||||
case "ENETUNREACH":
|
||||
buffer[1] = 3 /* NetworkUnreachable */;
|
||||
break;
|
||||
case "ECONNREFUSED":
|
||||
buffer[1] = 5 /* ConnectionRefused */;
|
||||
break;
|
||||
case "ERULESET":
|
||||
buffer[1] = 2 /* NotAllowedByRuleSet */;
|
||||
break;
|
||||
}
|
||||
this._writeBytes(buffer);
|
||||
this._socket.end();
|
||||
}
|
||||
sendData(data) {
|
||||
this._socket.write(data);
|
||||
}
|
||||
end() {
|
||||
this._socket.end();
|
||||
}
|
||||
error(error) {
|
||||
this._socket.destroy(new Error(error));
|
||||
}
|
||||
}
|
||||
function hexToNumber(hex) {
|
||||
return [...hex].reduce((value, digit) => {
|
||||
const code = digit.charCodeAt(0);
|
||||
if (code >= 48 && code <= 57)
|
||||
return value + code;
|
||||
if (code >= 97 && code <= 102)
|
||||
return value + (code - 97) + 10;
|
||||
if (code >= 65 && code <= 70)
|
||||
return value + (code - 65) + 10;
|
||||
throw new Error("Invalid IPv6 token " + hex);
|
||||
}, 0);
|
||||
}
|
||||
function ipToSocksAddress(address) {
|
||||
if (import_net.default.isIPv4(address)) {
|
||||
return [
|
||||
1,
|
||||
// IPv4
|
||||
...address.split(".", 4).map((t) => +t & 255)
|
||||
// Address
|
||||
];
|
||||
}
|
||||
if (import_net.default.isIPv6(address)) {
|
||||
const result = [4];
|
||||
const tokens = address.split(":", 8);
|
||||
while (tokens.length < 8)
|
||||
tokens.unshift("");
|
||||
for (const token of tokens) {
|
||||
const value = hexToNumber(token);
|
||||
result.push(value >> 8 & 255, value & 255);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
throw new Error("Only IPv4 and IPv6 addresses are supported");
|
||||
}
|
||||
function starMatchToRegex(pattern) {
|
||||
const source = pattern.split("*").map((s) => {
|
||||
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
}).join(".*");
|
||||
return new RegExp("^" + source + "$");
|
||||
}
|
||||
function parsePattern(pattern) {
|
||||
if (!pattern)
|
||||
return () => false;
|
||||
const matchers = pattern.split(",").map((token) => {
|
||||
const match = token.match(/^(.*?)(?::(\d+))?$/);
|
||||
if (!match)
|
||||
throw new Error(`Unsupported token "${token}" in pattern "${pattern}"`);
|
||||
const tokenPort = match[2] ? +match[2] : void 0;
|
||||
const portMatches = (port) => tokenPort === void 0 || tokenPort === port;
|
||||
let tokenHost = match[1];
|
||||
if (tokenHost === "<loopback>") {
|
||||
return (host, port) => {
|
||||
if (!portMatches(port))
|
||||
return false;
|
||||
return host === "localhost" || host.endsWith(".localhost") || host === "127.0.0.1" || host === "[::1]";
|
||||
};
|
||||
}
|
||||
if (tokenHost === "*")
|
||||
return (host, port) => portMatches(port);
|
||||
if (import_net.default.isIPv4(tokenHost) || import_net.default.isIPv6(tokenHost))
|
||||
return (host, port) => host === tokenHost && portMatches(port);
|
||||
if (tokenHost[0] === ".")
|
||||
tokenHost = "*" + tokenHost;
|
||||
const tokenRegex = starMatchToRegex(tokenHost);
|
||||
return (host, port) => {
|
||||
if (!portMatches(port))
|
||||
return false;
|
||||
if (import_net.default.isIPv4(host) || import_net.default.isIPv6(host))
|
||||
return false;
|
||||
return !!host.match(tokenRegex);
|
||||
};
|
||||
});
|
||||
return (host, port) => matchers.some((matcher) => matcher(host, port));
|
||||
}
|
||||
class SocksProxy extends import_events.default {
|
||||
constructor() {
|
||||
super();
|
||||
this._connections = /* @__PURE__ */ new Map();
|
||||
this._sockets = /* @__PURE__ */ new Set();
|
||||
this._closed = false;
|
||||
this._patternMatcher = () => false;
|
||||
this._directSockets = /* @__PURE__ */ new Map();
|
||||
this._server = new import_net.default.Server((socket) => {
|
||||
const uid = (0, import_crypto.createGuid)();
|
||||
const connection = new SocksConnection(uid, socket, this);
|
||||
this._connections.set(uid, connection);
|
||||
});
|
||||
this._server.on("connection", (socket) => {
|
||||
if (this._closed) {
|
||||
socket.destroy();
|
||||
return;
|
||||
}
|
||||
this._sockets.add(socket);
|
||||
socket.once("close", () => this._sockets.delete(socket));
|
||||
});
|
||||
}
|
||||
static {
|
||||
this.Events = {
|
||||
SocksRequested: "socksRequested",
|
||||
SocksData: "socksData",
|
||||
SocksClosed: "socksClosed"
|
||||
};
|
||||
}
|
||||
setPattern(pattern) {
|
||||
try {
|
||||
this._patternMatcher = parsePattern(pattern);
|
||||
} catch (e) {
|
||||
this._patternMatcher = () => false;
|
||||
}
|
||||
}
|
||||
async _handleDirect(request) {
|
||||
try {
|
||||
const socket = await (0, import_happyEyeballs.createSocket)(request.host, request.port);
|
||||
socket.on("data", (data) => this._connections.get(request.uid)?.sendData(data));
|
||||
socket.on("error", (error) => {
|
||||
this._connections.get(request.uid)?.error(error.message);
|
||||
this._directSockets.delete(request.uid);
|
||||
});
|
||||
socket.on("end", () => {
|
||||
this._connections.get(request.uid)?.end();
|
||||
this._directSockets.delete(request.uid);
|
||||
});
|
||||
const localAddress = socket.localAddress;
|
||||
const localPort = socket.localPort;
|
||||
this._directSockets.set(request.uid, socket);
|
||||
this._connections.get(request.uid)?.socketConnected(localAddress, localPort);
|
||||
} catch (error) {
|
||||
this._connections.get(request.uid)?.socketFailed(error.code);
|
||||
}
|
||||
}
|
||||
port() {
|
||||
return this._port;
|
||||
}
|
||||
async listen(port, hostname) {
|
||||
return new Promise((f) => {
|
||||
this._server.listen(port, hostname, () => {
|
||||
const port2 = this._server.address().port;
|
||||
this._port = port2;
|
||||
f(port2);
|
||||
});
|
||||
});
|
||||
}
|
||||
async close() {
|
||||
if (this._closed)
|
||||
return;
|
||||
this._closed = true;
|
||||
for (const socket of this._sockets)
|
||||
socket.destroy();
|
||||
this._sockets.clear();
|
||||
await new Promise((f) => this._server.close(f));
|
||||
}
|
||||
onSocketRequested(payload) {
|
||||
if (!this._patternMatcher(payload.host, payload.port)) {
|
||||
this._handleDirect(payload);
|
||||
return;
|
||||
}
|
||||
this.emit(SocksProxy.Events.SocksRequested, payload);
|
||||
}
|
||||
onSocketData(payload) {
|
||||
const direct = this._directSockets.get(payload.uid);
|
||||
if (direct) {
|
||||
direct.write(payload.data);
|
||||
return;
|
||||
}
|
||||
this.emit(SocksProxy.Events.SocksData, payload);
|
||||
}
|
||||
onSocketClosed(payload) {
|
||||
const direct = this._directSockets.get(payload.uid);
|
||||
if (direct) {
|
||||
direct.destroy();
|
||||
this._directSockets.delete(payload.uid);
|
||||
return;
|
||||
}
|
||||
this.emit(SocksProxy.Events.SocksClosed, payload);
|
||||
}
|
||||
socketConnected({ uid, host, port }) {
|
||||
this._connections.get(uid)?.socketConnected(host, port);
|
||||
}
|
||||
socketFailed({ uid, errorCode }) {
|
||||
this._connections.get(uid)?.socketFailed(errorCode);
|
||||
}
|
||||
sendSocketData({ uid, data }) {
|
||||
this._connections.get(uid)?.sendData(data);
|
||||
}
|
||||
sendSocketEnd({ uid }) {
|
||||
this._connections.get(uid)?.end();
|
||||
}
|
||||
sendSocketError({ uid, error }) {
|
||||
this._connections.get(uid)?.error(error);
|
||||
}
|
||||
}
|
||||
class SocksProxyHandler extends import_events.default {
|
||||
constructor(pattern, redirectPortForTest) {
|
||||
super();
|
||||
this._sockets = /* @__PURE__ */ new Map();
|
||||
this._patternMatcher = () => false;
|
||||
this._patternMatcher = parsePattern(pattern);
|
||||
this._redirectPortForTest = redirectPortForTest;
|
||||
}
|
||||
static {
|
||||
this.Events = {
|
||||
SocksConnected: "socksConnected",
|
||||
SocksData: "socksData",
|
||||
SocksError: "socksError",
|
||||
SocksFailed: "socksFailed",
|
||||
SocksEnd: "socksEnd"
|
||||
};
|
||||
}
|
||||
cleanup() {
|
||||
for (const uid of this._sockets.keys())
|
||||
this.socketClosed({ uid });
|
||||
}
|
||||
async socketRequested({ uid, host, port }) {
|
||||
import_debugLogger.debugLogger.log("socks", `[${uid}] => request ${host}:${port}`);
|
||||
if (!this._patternMatcher(host, port)) {
|
||||
const payload = { uid, errorCode: "ERULESET" };
|
||||
import_debugLogger.debugLogger.log("socks", `[${uid}] <= pattern error ${payload.errorCode}`);
|
||||
this.emit(SocksProxyHandler.Events.SocksFailed, payload);
|
||||
return;
|
||||
}
|
||||
if (host === "local.playwright")
|
||||
host = "localhost";
|
||||
try {
|
||||
if (this._redirectPortForTest)
|
||||
port = this._redirectPortForTest;
|
||||
const socket = await (0, import_happyEyeballs.createSocket)(host, port);
|
||||
socket.on("data", (data) => {
|
||||
const payload2 = { uid, data };
|
||||
this.emit(SocksProxyHandler.Events.SocksData, payload2);
|
||||
});
|
||||
socket.on("error", (error) => {
|
||||
const payload2 = { uid, error: error.message };
|
||||
import_debugLogger.debugLogger.log("socks", `[${uid}] <= network socket error ${payload2.error}`);
|
||||
this.emit(SocksProxyHandler.Events.SocksError, payload2);
|
||||
this._sockets.delete(uid);
|
||||
});
|
||||
socket.on("end", () => {
|
||||
const payload2 = { uid };
|
||||
import_debugLogger.debugLogger.log("socks", `[${uid}] <= network socket closed`);
|
||||
this.emit(SocksProxyHandler.Events.SocksEnd, payload2);
|
||||
this._sockets.delete(uid);
|
||||
});
|
||||
const localAddress = socket.localAddress;
|
||||
const localPort = socket.localPort;
|
||||
this._sockets.set(uid, socket);
|
||||
const payload = { uid, host: localAddress, port: localPort };
|
||||
import_debugLogger.debugLogger.log("socks", `[${uid}] <= connected to network ${payload.host}:${payload.port}`);
|
||||
this.emit(SocksProxyHandler.Events.SocksConnected, payload);
|
||||
} catch (error) {
|
||||
const payload = { uid, errorCode: error.code };
|
||||
import_debugLogger.debugLogger.log("socks", `[${uid}] <= connect error ${payload.errorCode}`);
|
||||
this.emit(SocksProxyHandler.Events.SocksFailed, payload);
|
||||
}
|
||||
}
|
||||
sendSocketData({ uid, data }) {
|
||||
this._sockets.get(uid)?.write(data);
|
||||
}
|
||||
socketClosed({ uid }) {
|
||||
import_debugLogger.debugLogger.log("socks", `[${uid}] <= browser socket closed`);
|
||||
this._sockets.get(uid)?.destroy();
|
||||
this._sockets.delete(uid);
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
SocksProxy,
|
||||
SocksProxyHandler,
|
||||
parsePattern
|
||||
});
|
41
node_modules/playwright-core/lib/server/utils/spawnAsync.js
generated
vendored
Normal file
41
node_modules/playwright-core/lib/server/utils/spawnAsync.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
"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 spawnAsync_exports = {};
|
||||
__export(spawnAsync_exports, {
|
||||
spawnAsync: () => spawnAsync
|
||||
});
|
||||
module.exports = __toCommonJS(spawnAsync_exports);
|
||||
var import_child_process = require("child_process");
|
||||
function spawnAsync(cmd, args, options = {}) {
|
||||
const process = (0, import_child_process.spawn)(cmd, args, Object.assign({ windowsHide: true }, options));
|
||||
return new Promise((resolve) => {
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
if (process.stdout)
|
||||
process.stdout.on("data", (data) => stdout += data.toString());
|
||||
if (process.stderr)
|
||||
process.stderr.on("data", (data) => stderr += data.toString());
|
||||
process.on("close", (code) => resolve({ stdout, stderr, code }));
|
||||
process.on("error", (error) => resolve({ stdout, stderr, code: 0, error }));
|
||||
});
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
spawnAsync
|
||||
});
|
51
node_modules/playwright-core/lib/server/utils/task.js
generated
vendored
Normal file
51
node_modules/playwright-core/lib/server/utils/task.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
"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 task_exports = {};
|
||||
__export(task_exports, {
|
||||
makeWaitForNextTask: () => makeWaitForNextTask
|
||||
});
|
||||
module.exports = __toCommonJS(task_exports);
|
||||
function makeWaitForNextTask() {
|
||||
if (process.versions.electron)
|
||||
return (callback) => setTimeout(callback, 0);
|
||||
if (parseInt(process.versions.node, 10) >= 11)
|
||||
return setImmediate;
|
||||
let spinning = false;
|
||||
const callbacks = [];
|
||||
const loop = () => {
|
||||
const callback = callbacks.shift();
|
||||
if (!callback) {
|
||||
spinning = false;
|
||||
return;
|
||||
}
|
||||
setImmediate(loop);
|
||||
callback();
|
||||
};
|
||||
return (callback) => {
|
||||
callbacks.push(callback);
|
||||
if (!spinning) {
|
||||
spinning = true;
|
||||
setImmediate(loop);
|
||||
}
|
||||
};
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
makeWaitForNextTask
|
||||
});
|
98
node_modules/playwright-core/lib/server/utils/userAgent.js
generated
vendored
Normal file
98
node_modules/playwright-core/lib/server/utils/userAgent.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
"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 userAgent_exports = {};
|
||||
__export(userAgent_exports, {
|
||||
getEmbedderName: () => getEmbedderName,
|
||||
getPlaywrightVersion: () => getPlaywrightVersion,
|
||||
getUserAgent: () => getUserAgent
|
||||
});
|
||||
module.exports = __toCommonJS(userAgent_exports);
|
||||
var import_child_process = require("child_process");
|
||||
var import_os = __toESM(require("os"));
|
||||
var import_linuxUtils = require("../utils/linuxUtils");
|
||||
let cachedUserAgent;
|
||||
function getUserAgent() {
|
||||
if (cachedUserAgent)
|
||||
return cachedUserAgent;
|
||||
try {
|
||||
cachedUserAgent = determineUserAgent();
|
||||
} catch (e) {
|
||||
cachedUserAgent = "Playwright/unknown";
|
||||
}
|
||||
return cachedUserAgent;
|
||||
}
|
||||
function determineUserAgent() {
|
||||
let osIdentifier = "unknown";
|
||||
let osVersion = "unknown";
|
||||
if (process.platform === "win32") {
|
||||
const version = import_os.default.release().split(".");
|
||||
osIdentifier = "windows";
|
||||
osVersion = `${version[0]}.${version[1]}`;
|
||||
} else if (process.platform === "darwin") {
|
||||
const version = (0, import_child_process.execSync)("sw_vers -productVersion", { stdio: ["ignore", "pipe", "ignore"] }).toString().trim().split(".");
|
||||
osIdentifier = "macOS";
|
||||
osVersion = `${version[0]}.${version[1]}`;
|
||||
} else if (process.platform === "linux") {
|
||||
const distroInfo = (0, import_linuxUtils.getLinuxDistributionInfoSync)();
|
||||
if (distroInfo) {
|
||||
osIdentifier = distroInfo.id || "linux";
|
||||
osVersion = distroInfo.version || "unknown";
|
||||
} else {
|
||||
osIdentifier = "linux";
|
||||
}
|
||||
}
|
||||
const additionalTokens = [];
|
||||
if (process.env.CI)
|
||||
additionalTokens.push("CI/1");
|
||||
const serializedTokens = additionalTokens.length ? " " + additionalTokens.join(" ") : "";
|
||||
const { embedderName, embedderVersion } = getEmbedderName();
|
||||
return `Playwright/${getPlaywrightVersion()} (${import_os.default.arch()}; ${osIdentifier} ${osVersion}) ${embedderName}/${embedderVersion}${serializedTokens}`;
|
||||
}
|
||||
function getEmbedderName() {
|
||||
let embedderName = "unknown";
|
||||
let embedderVersion = "unknown";
|
||||
if (!process.env.PW_LANG_NAME) {
|
||||
embedderName = "node";
|
||||
embedderVersion = process.version.substring(1).split(".").slice(0, 2).join(".");
|
||||
} else if (["node", "python", "java", "csharp"].includes(process.env.PW_LANG_NAME)) {
|
||||
embedderName = process.env.PW_LANG_NAME;
|
||||
embedderVersion = process.env.PW_LANG_NAME_VERSION ?? "unknown";
|
||||
}
|
||||
return { embedderName, embedderVersion };
|
||||
}
|
||||
function getPlaywrightVersion(majorMinorOnly = false) {
|
||||
const version = process.env.PW_VERSION_OVERRIDE || require("./../../../package.json").version;
|
||||
return majorMinorOnly ? version.split(".").slice(0, 2).join(".") : version;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
getEmbedderName,
|
||||
getPlaywrightVersion,
|
||||
getUserAgent
|
||||
});
|
126
node_modules/playwright-core/lib/server/utils/wsServer.js
generated
vendored
Normal file
126
node_modules/playwright-core/lib/server/utils/wsServer.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
"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 wsServer_exports = {};
|
||||
__export(wsServer_exports, {
|
||||
WSServer: () => WSServer,
|
||||
perMessageDeflate: () => perMessageDeflate
|
||||
});
|
||||
module.exports = __toCommonJS(wsServer_exports);
|
||||
var import_network = require("./network");
|
||||
var import_utilsBundle = require("../../utilsBundle");
|
||||
var import_debugLogger = require("./debugLogger");
|
||||
let lastConnectionId = 0;
|
||||
const kConnectionSymbol = Symbol("kConnection");
|
||||
const perMessageDeflate = {
|
||||
serverNoContextTakeover: true,
|
||||
zlibDeflateOptions: {
|
||||
level: 3
|
||||
},
|
||||
zlibInflateOptions: {
|
||||
chunkSize: 10 * 1024
|
||||
},
|
||||
threshold: 10 * 1024
|
||||
};
|
||||
class WSServer {
|
||||
constructor(delegate) {
|
||||
this._delegate = delegate;
|
||||
}
|
||||
async listen(port = 0, hostname, path) {
|
||||
import_debugLogger.debugLogger.log("server", `Server started at ${/* @__PURE__ */ new Date()}`);
|
||||
const server = (0, import_network.createHttpServer)(this._delegate.onRequest);
|
||||
server.on("error", (error) => import_debugLogger.debugLogger.log("server", String(error)));
|
||||
this.server = server;
|
||||
const wsEndpoint = await new Promise((resolve, reject) => {
|
||||
server.listen(port, hostname, () => {
|
||||
const address = server.address();
|
||||
if (!address) {
|
||||
reject(new Error("Could not bind server socket"));
|
||||
return;
|
||||
}
|
||||
const wsEndpoint2 = typeof address === "string" ? `${address}${path}` : `ws://${hostname || "localhost"}:${address.port}${path}`;
|
||||
resolve(wsEndpoint2);
|
||||
}).on("error", reject);
|
||||
});
|
||||
import_debugLogger.debugLogger.log("server", "Listening at " + wsEndpoint);
|
||||
this._wsServer = new import_utilsBundle.wsServer({
|
||||
noServer: true,
|
||||
perMessageDeflate
|
||||
});
|
||||
this._wsServer.on("headers", (headers) => this._delegate.onHeaders(headers));
|
||||
server.on("upgrade", (request, socket, head) => {
|
||||
const pathname = new URL("http://localhost" + request.url).pathname;
|
||||
if (pathname !== path) {
|
||||
socket.write(`HTTP/${request.httpVersion} 400 Bad Request\r
|
||||
\r
|
||||
`);
|
||||
socket.destroy();
|
||||
return;
|
||||
}
|
||||
const upgradeResult = this._delegate.onUpgrade(request, socket);
|
||||
if (upgradeResult) {
|
||||
socket.write(upgradeResult.error);
|
||||
socket.destroy();
|
||||
return;
|
||||
}
|
||||
this._wsServer.handleUpgrade(request, socket, head, (ws) => this._wsServer.emit("connection", ws, request));
|
||||
});
|
||||
this._wsServer.on("connection", (ws, request) => {
|
||||
import_debugLogger.debugLogger.log("server", "Connected client ws.extension=" + ws.extensions);
|
||||
const url = new URL("http://localhost" + (request.url || ""));
|
||||
const id = String(++lastConnectionId);
|
||||
import_debugLogger.debugLogger.log("server", `[${id}] serving connection: ${request.url}`);
|
||||
try {
|
||||
const connection = this._delegate.onConnection(request, url, ws, id);
|
||||
ws[kConnectionSymbol] = connection;
|
||||
} catch (error) {
|
||||
import_debugLogger.debugLogger.log("server", `[${id}] connection error: ${error}`);
|
||||
ws.close(1011, String(error));
|
||||
}
|
||||
});
|
||||
return wsEndpoint;
|
||||
}
|
||||
async close() {
|
||||
const server = this._wsServer;
|
||||
if (!server)
|
||||
return;
|
||||
import_debugLogger.debugLogger.log("server", "closing websocket server");
|
||||
const waitForClose = new Promise((f) => server.close(f));
|
||||
await Promise.all(Array.from(server.clients).map(async (ws) => {
|
||||
const connection = ws[kConnectionSymbol];
|
||||
if (connection)
|
||||
await connection.close();
|
||||
try {
|
||||
ws.terminate();
|
||||
} catch (e) {
|
||||
}
|
||||
}));
|
||||
await waitForClose;
|
||||
import_debugLogger.debugLogger.log("server", "closing http server");
|
||||
if (this.server)
|
||||
await new Promise((f) => this.server.close(f));
|
||||
this._wsServer = void 0;
|
||||
this.server = void 0;
|
||||
import_debugLogger.debugLogger.log("server", "closed server");
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
WSServer,
|
||||
perMessageDeflate
|
||||
});
|
74
node_modules/playwright-core/lib/server/utils/zipFile.js
generated
vendored
Normal file
74
node_modules/playwright-core/lib/server/utils/zipFile.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
"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 zipFile_exports = {};
|
||||
__export(zipFile_exports, {
|
||||
ZipFile: () => ZipFile
|
||||
});
|
||||
module.exports = __toCommonJS(zipFile_exports);
|
||||
var import_zipBundle = require("../../zipBundle");
|
||||
class ZipFile {
|
||||
constructor(fileName) {
|
||||
this._entries = /* @__PURE__ */ new Map();
|
||||
this._fileName = fileName;
|
||||
this._openedPromise = this._open();
|
||||
}
|
||||
async _open() {
|
||||
await new Promise((fulfill, reject) => {
|
||||
import_zipBundle.yauzl.open(this._fileName, { autoClose: false }, (e, z) => {
|
||||
if (e) {
|
||||
reject(e);
|
||||
return;
|
||||
}
|
||||
this._zipFile = z;
|
||||
this._zipFile.on("entry", (entry) => {
|
||||
this._entries.set(entry.fileName, entry);
|
||||
});
|
||||
this._zipFile.on("end", fulfill);
|
||||
});
|
||||
});
|
||||
}
|
||||
async entries() {
|
||||
await this._openedPromise;
|
||||
return [...this._entries.keys()];
|
||||
}
|
||||
async read(entryPath) {
|
||||
await this._openedPromise;
|
||||
const entry = this._entries.get(entryPath);
|
||||
if (!entry)
|
||||
throw new Error(`${entryPath} not found in file ${this._fileName}`);
|
||||
return new Promise((resolve, reject) => {
|
||||
this._zipFile.openReadStream(entry, (error, readStream) => {
|
||||
if (error || !readStream) {
|
||||
reject(error || "Entry not found");
|
||||
return;
|
||||
}
|
||||
const buffers = [];
|
||||
readStream.on("data", (data) => buffers.push(data));
|
||||
readStream.on("end", () => resolve(Buffer.concat(buffers)));
|
||||
});
|
||||
});
|
||||
}
|
||||
close() {
|
||||
this._zipFile?.close();
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
ZipFile
|
||||
});
|
57
node_modules/playwright-core/lib/server/utils/zones.js
generated
vendored
Normal file
57
node_modules/playwright-core/lib/server/utils/zones.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
"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 zones_exports = {};
|
||||
__export(zones_exports, {
|
||||
Zone: () => Zone,
|
||||
currentZone: () => currentZone,
|
||||
emptyZone: () => emptyZone
|
||||
});
|
||||
module.exports = __toCommonJS(zones_exports);
|
||||
var import_async_hooks = require("async_hooks");
|
||||
const asyncLocalStorage = new import_async_hooks.AsyncLocalStorage();
|
||||
class Zone {
|
||||
constructor(asyncLocalStorage2, store) {
|
||||
this._asyncLocalStorage = asyncLocalStorage2;
|
||||
this._data = store;
|
||||
}
|
||||
with(type, data) {
|
||||
return new Zone(this._asyncLocalStorage, new Map(this._data).set(type, data));
|
||||
}
|
||||
without(type) {
|
||||
const data = type ? new Map(this._data) : /* @__PURE__ */ new Map();
|
||||
data.delete(type);
|
||||
return new Zone(this._asyncLocalStorage, data);
|
||||
}
|
||||
run(func) {
|
||||
return this._asyncLocalStorage.run(this, func);
|
||||
}
|
||||
data(type) {
|
||||
return this._data.get(type);
|
||||
}
|
||||
}
|
||||
const emptyZone = new Zone(asyncLocalStorage, /* @__PURE__ */ new Map());
|
||||
function currentZone() {
|
||||
return asyncLocalStorage.getStore() ?? emptyZone;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
Zone,
|
||||
currentZone,
|
||||
emptyZone
|
||||
});
|
Reference in New Issue
Block a user