@skrillex1224/playwright-toolkit 3.0.39 → 3.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +104 -38
- package/dist/browser.js.map +4 -4
- package/dist/index.cjs +282 -265
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +282 -265
- package/dist/index.js.map +4 -4
- package/index.d.ts +7 -0
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -1398,9 +1398,9 @@ var require_picomatch = __commonJS({
|
|
|
1398
1398
|
var utils = require_utils();
|
|
1399
1399
|
var constants = require_constants();
|
|
1400
1400
|
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1401
|
-
var
|
|
1401
|
+
var picomatch3 = (glob, options, returnState = false) => {
|
|
1402
1402
|
if (Array.isArray(glob)) {
|
|
1403
|
-
const fns = glob.map((input) =>
|
|
1403
|
+
const fns = glob.map((input) => picomatch3(input, options, returnState));
|
|
1404
1404
|
const arrayMatcher = (str) => {
|
|
1405
1405
|
for (const isMatch of fns) {
|
|
1406
1406
|
const state3 = isMatch(str);
|
|
@@ -1416,16 +1416,16 @@ var require_picomatch = __commonJS({
|
|
|
1416
1416
|
}
|
|
1417
1417
|
const opts = options || {};
|
|
1418
1418
|
const posix = opts.windows;
|
|
1419
|
-
const regex = isState ?
|
|
1419
|
+
const regex = isState ? picomatch3.compileRe(glob, options) : picomatch3.makeRe(glob, options, false, true);
|
|
1420
1420
|
const state2 = regex.state;
|
|
1421
1421
|
delete regex.state;
|
|
1422
1422
|
let isIgnored = () => false;
|
|
1423
1423
|
if (opts.ignore) {
|
|
1424
1424
|
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
1425
|
-
isIgnored =
|
|
1425
|
+
isIgnored = picomatch3(opts.ignore, ignoreOpts, returnState);
|
|
1426
1426
|
}
|
|
1427
1427
|
const matcher = (input, returnObject = false) => {
|
|
1428
|
-
const { isMatch, match, output } =
|
|
1428
|
+
const { isMatch, match, output } = picomatch3.test(input, regex, options, { glob, posix });
|
|
1429
1429
|
const result = { glob, state: state2, regex, posix, input, output, match, isMatch };
|
|
1430
1430
|
if (typeof opts.onResult === "function") {
|
|
1431
1431
|
opts.onResult(result);
|
|
@@ -1451,7 +1451,7 @@ var require_picomatch = __commonJS({
|
|
|
1451
1451
|
}
|
|
1452
1452
|
return matcher;
|
|
1453
1453
|
};
|
|
1454
|
-
|
|
1454
|
+
picomatch3.test = (input, regex, options, { glob, posix } = {}) => {
|
|
1455
1455
|
if (typeof input !== "string") {
|
|
1456
1456
|
throw new TypeError("Expected input to be a string");
|
|
1457
1457
|
}
|
|
@@ -1468,24 +1468,24 @@ var require_picomatch = __commonJS({
|
|
|
1468
1468
|
}
|
|
1469
1469
|
if (match === false || opts.capture === true) {
|
|
1470
1470
|
if (opts.matchBase === true || opts.basename === true) {
|
|
1471
|
-
match =
|
|
1471
|
+
match = picomatch3.matchBase(input, regex, options, posix);
|
|
1472
1472
|
} else {
|
|
1473
1473
|
match = regex.exec(output);
|
|
1474
1474
|
}
|
|
1475
1475
|
}
|
|
1476
1476
|
return { isMatch: Boolean(match), match, output };
|
|
1477
1477
|
};
|
|
1478
|
-
|
|
1479
|
-
const regex = glob instanceof RegExp ? glob :
|
|
1478
|
+
picomatch3.matchBase = (input, glob, options) => {
|
|
1479
|
+
const regex = glob instanceof RegExp ? glob : picomatch3.makeRe(glob, options);
|
|
1480
1480
|
return regex.test(utils.basename(input));
|
|
1481
1481
|
};
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
if (Array.isArray(pattern)) return pattern.map((p) =>
|
|
1482
|
+
picomatch3.isMatch = (str, patterns, options) => picomatch3(patterns, options)(str);
|
|
1483
|
+
picomatch3.parse = (pattern, options) => {
|
|
1484
|
+
if (Array.isArray(pattern)) return pattern.map((p) => picomatch3.parse(p, options));
|
|
1485
1485
|
return parse(pattern, { ...options, fastpaths: false });
|
|
1486
1486
|
};
|
|
1487
|
-
|
|
1488
|
-
|
|
1487
|
+
picomatch3.scan = (input, options) => scan(input, options);
|
|
1488
|
+
picomatch3.compileRe = (state2, options, returnOutput = false, returnState = false) => {
|
|
1489
1489
|
if (returnOutput === true) {
|
|
1490
1490
|
return state2.output;
|
|
1491
1491
|
}
|
|
@@ -1496,13 +1496,13 @@ var require_picomatch = __commonJS({
|
|
|
1496
1496
|
if (state2 && state2.negated === true) {
|
|
1497
1497
|
source = `^(?!${source}).*$`;
|
|
1498
1498
|
}
|
|
1499
|
-
const regex =
|
|
1499
|
+
const regex = picomatch3.toRegex(source, options);
|
|
1500
1500
|
if (returnState === true) {
|
|
1501
1501
|
regex.state = state2;
|
|
1502
1502
|
}
|
|
1503
1503
|
return regex;
|
|
1504
1504
|
};
|
|
1505
|
-
|
|
1505
|
+
picomatch3.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
1506
1506
|
if (!input || typeof input !== "string") {
|
|
1507
1507
|
throw new TypeError("Expected a non-empty string");
|
|
1508
1508
|
}
|
|
@@ -1513,9 +1513,9 @@ var require_picomatch = __commonJS({
|
|
|
1513
1513
|
if (!parsed.output) {
|
|
1514
1514
|
parsed = parse(input, options);
|
|
1515
1515
|
}
|
|
1516
|
-
return
|
|
1516
|
+
return picomatch3.compileRe(parsed, options, returnOutput, returnState);
|
|
1517
1517
|
};
|
|
1518
|
-
|
|
1518
|
+
picomatch3.toRegex = (source, options) => {
|
|
1519
1519
|
try {
|
|
1520
1520
|
const opts = options || {};
|
|
1521
1521
|
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
@@ -1524,8 +1524,8 @@ var require_picomatch = __commonJS({
|
|
|
1524
1524
|
return /$^/;
|
|
1525
1525
|
}
|
|
1526
1526
|
};
|
|
1527
|
-
|
|
1528
|
-
module.exports =
|
|
1527
|
+
picomatch3.constants = constants;
|
|
1528
|
+
module.exports = picomatch3;
|
|
1529
1529
|
}
|
|
1530
1530
|
});
|
|
1531
1531
|
|
|
@@ -1535,14 +1535,14 @@ var require_picomatch2 = __commonJS({
|
|
|
1535
1535
|
"use strict";
|
|
1536
1536
|
var pico = require_picomatch();
|
|
1537
1537
|
var utils = require_utils();
|
|
1538
|
-
function
|
|
1538
|
+
function picomatch3(glob, options, returnState = false) {
|
|
1539
1539
|
if (options && (options.windows === null || options.windows === void 0)) {
|
|
1540
1540
|
options = { ...options, windows: utils.isWindows() };
|
|
1541
1541
|
}
|
|
1542
1542
|
return pico(glob, options, returnState);
|
|
1543
1543
|
}
|
|
1544
|
-
Object.assign(
|
|
1545
|
-
module.exports =
|
|
1544
|
+
Object.assign(picomatch3, pico);
|
|
1545
|
+
module.exports = picomatch3;
|
|
1546
1546
|
}
|
|
1547
1547
|
});
|
|
1548
1548
|
|
|
@@ -1574,18 +1574,18 @@ var fallbackLog = {
|
|
|
1574
1574
|
error: (...args) => console.error(...args),
|
|
1575
1575
|
debug: (...args) => console.debug ? console.debug(...args) : console.log(...args)
|
|
1576
1576
|
};
|
|
1577
|
-
var resolveLogMethod = (
|
|
1578
|
-
if (
|
|
1579
|
-
return
|
|
1577
|
+
var resolveLogMethod = (logger2, name) => {
|
|
1578
|
+
if (logger2 && typeof logger2[name] === "function") {
|
|
1579
|
+
return logger2[name].bind(logger2);
|
|
1580
1580
|
}
|
|
1581
|
-
if (name === "warning" &&
|
|
1582
|
-
return
|
|
1581
|
+
if (name === "warning" && logger2 && typeof logger2.warn === "function") {
|
|
1582
|
+
return logger2.warn.bind(logger2);
|
|
1583
1583
|
}
|
|
1584
1584
|
return fallbackLog[name];
|
|
1585
1585
|
};
|
|
1586
1586
|
var defaultLogger = null;
|
|
1587
|
-
var setDefaultLogger = (
|
|
1588
|
-
defaultLogger =
|
|
1587
|
+
var setDefaultLogger = (logger2) => {
|
|
1588
|
+
defaultLogger = logger2;
|
|
1589
1589
|
};
|
|
1590
1590
|
var resolveLogger = (explicitLogger) => {
|
|
1591
1591
|
if (explicitLogger && typeof explicitLogger.info === "function") {
|
|
@@ -1612,8 +1612,8 @@ var colorize = (text, color) => {
|
|
|
1612
1612
|
var createBaseLogger = (prefix = "", explicitLogger) => {
|
|
1613
1613
|
const name = prefix ? String(prefix) : "";
|
|
1614
1614
|
const dispatch = (methodName, icon, message, color) => {
|
|
1615
|
-
const
|
|
1616
|
-
const logFn = resolveLogMethod(
|
|
1615
|
+
const logger2 = resolveLogger(explicitLogger);
|
|
1616
|
+
const logFn = resolveLogMethod(logger2, methodName);
|
|
1617
1617
|
const timestamp = colorize(`[${formatTimestamp()}]`, ANSI.gray);
|
|
1618
1618
|
const line = formatLine(name, icon, message);
|
|
1619
1619
|
const coloredLine = colorize(line, color);
|
|
@@ -1629,6 +1629,38 @@ var createBaseLogger = (prefix = "", explicitLogger) => {
|
|
|
1629
1629
|
start: (message) => dispatch("info", "\u{1F537}", message, ANSI.blue)
|
|
1630
1630
|
};
|
|
1631
1631
|
};
|
|
1632
|
+
function createInternalLogger(moduleName, explicitLogger) {
|
|
1633
|
+
const baseLogger = createBaseLogger(moduleName, explicitLogger);
|
|
1634
|
+
return {
|
|
1635
|
+
start(methodName, params = "") {
|
|
1636
|
+
const paramStr = params ? ` (${params})` : "";
|
|
1637
|
+
baseLogger.start(`${methodName} \u5F00\u59CB${paramStr}`);
|
|
1638
|
+
},
|
|
1639
|
+
success(methodName, result = "") {
|
|
1640
|
+
const resultStr = result ? ` (${result})` : "";
|
|
1641
|
+
baseLogger.success(`${methodName} \u5B8C\u6210${resultStr}`);
|
|
1642
|
+
},
|
|
1643
|
+
fail(methodName, error) {
|
|
1644
|
+
const message = error instanceof Error ? error.message : error;
|
|
1645
|
+
baseLogger.error(`${methodName} \u5931\u8D25: ${message}`);
|
|
1646
|
+
},
|
|
1647
|
+
debug(message) {
|
|
1648
|
+
baseLogger.debug(message);
|
|
1649
|
+
},
|
|
1650
|
+
warn(message) {
|
|
1651
|
+
baseLogger.warning(message);
|
|
1652
|
+
},
|
|
1653
|
+
warning(message) {
|
|
1654
|
+
baseLogger.warning(message);
|
|
1655
|
+
},
|
|
1656
|
+
info(message) {
|
|
1657
|
+
baseLogger.info(message);
|
|
1658
|
+
},
|
|
1659
|
+
error(message) {
|
|
1660
|
+
baseLogger.error(message);
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1632
1664
|
|
|
1633
1665
|
// src/logger.js
|
|
1634
1666
|
var stripAnsi = (input) => {
|
|
@@ -2433,7 +2465,7 @@ var createTemplateLogger = (baseLogger = createBaseLogger()) => {
|
|
|
2433
2465
|
};
|
|
2434
2466
|
var getDefaultBaseLogger = () => createBaseLogger("");
|
|
2435
2467
|
var Logger = {
|
|
2436
|
-
setLogger: (
|
|
2468
|
+
setLogger: (logger2) => setDefaultLogger(logger2),
|
|
2437
2469
|
info: (message) => getDefaultBaseLogger().info(message),
|
|
2438
2470
|
success: (message) => getDefaultBaseLogger().success(message),
|
|
2439
2471
|
warning: (message) => getDefaultBaseLogger().warning(message),
|
|
@@ -2441,8 +2473,8 @@ var Logger = {
|
|
|
2441
2473
|
error: (message) => getDefaultBaseLogger().error(message),
|
|
2442
2474
|
debug: (message) => getDefaultBaseLogger().debug(message),
|
|
2443
2475
|
start: (message) => getDefaultBaseLogger().start(message),
|
|
2444
|
-
useTemplate: (
|
|
2445
|
-
if (
|
|
2476
|
+
useTemplate: (logger2) => {
|
|
2477
|
+
if (logger2) return createTemplateLogger(createBaseLogger("", logger2));
|
|
2446
2478
|
return createTemplateLogger();
|
|
2447
2479
|
}
|
|
2448
2480
|
};
|
|
@@ -2928,12 +2960,16 @@ var ByPass = {
|
|
|
2928
2960
|
resolveRouteByProxy
|
|
2929
2961
|
};
|
|
2930
2962
|
|
|
2963
|
+
// src/runtime-env.js
|
|
2964
|
+
var import_picomatch2 = __toESM(require_picomatch2(), 1);
|
|
2965
|
+
|
|
2931
2966
|
// src/internals/constants.js
|
|
2932
2967
|
var PageRuntimeStateKey = "__playwright_toolkit_runtime_state__";
|
|
2933
2968
|
|
|
2934
2969
|
// src/runtime-env.js
|
|
2935
2970
|
var BROWSER_PROFILE_SCHEMA_VERSION = 1;
|
|
2936
2971
|
var SUPPORTED_CLOAK_FINGERPRINT_PLATFORMS = /* @__PURE__ */ new Set(["linux", "macos", "windows"]);
|
|
2972
|
+
var logger = createInternalLogger("RuntimeEnv");
|
|
2937
2973
|
var rememberedRuntimeState = null;
|
|
2938
2974
|
var isPlainObject = (value) => value && typeof value === "object" && !Array.isArray(value);
|
|
2939
2975
|
var normalizeKnownDevice = (value) => {
|
|
@@ -3091,6 +3127,18 @@ var uniqueStrings = (value) => {
|
|
|
3091
3127
|
});
|
|
3092
3128
|
return result;
|
|
3093
3129
|
};
|
|
3130
|
+
var buildApplyExcludeMatcher = (patterns = []) => {
|
|
3131
|
+
const normalized = (Array.isArray(patterns) ? patterns : []).map((pattern) => String(pattern || "").trim()).filter(Boolean);
|
|
3132
|
+
return normalized.length > 0 ? (0, import_picomatch2.default)(normalized, { nocase: true }) : () => false;
|
|
3133
|
+
};
|
|
3134
|
+
var filterApplyEntries = (entries = {}, matcher = () => false) => Object.entries(entries || {}).reduce((acc, [key, value]) => {
|
|
3135
|
+
if (matcher(key)) acc.skipped.push(key);
|
|
3136
|
+
else acc.payload[key] = value;
|
|
3137
|
+
return acc;
|
|
3138
|
+
}, { payload: {}, skipped: [] });
|
|
3139
|
+
var logApplySkipped = (type, keys = []) => {
|
|
3140
|
+
if (keys.length > 0) logger.info(`applyToPage \u8DF3\u8FC7\u6CE8\u5165 ${type}: ${keys.join(", ")}`);
|
|
3141
|
+
};
|
|
3094
3142
|
var normalizeHttpUrlList = (value) => uniqueStrings(
|
|
3095
3143
|
(Array.isArray(value) ? value : [value]).map((item) => normalizeHttpUrl(item)).filter(Boolean)
|
|
3096
3144
|
);
|
|
@@ -3565,9 +3613,24 @@ var RuntimeEnv = {
|
|
|
3565
3613
|
writable: true,
|
|
3566
3614
|
value: state2
|
|
3567
3615
|
});
|
|
3568
|
-
const
|
|
3569
|
-
const
|
|
3570
|
-
|
|
3616
|
+
const exclude = (options == null ? void 0 : options.exclude) || {};
|
|
3617
|
+
const localStorageResult = filterApplyEntries(
|
|
3618
|
+
state2.localStorage || {},
|
|
3619
|
+
buildApplyExcludeMatcher(exclude.local_storage)
|
|
3620
|
+
);
|
|
3621
|
+
const sessionStorageResult = filterApplyEntries(
|
|
3622
|
+
state2.sessionStorage || {},
|
|
3623
|
+
buildApplyExcludeMatcher(exclude.session_storage)
|
|
3624
|
+
);
|
|
3625
|
+
const cookieMatcher = buildApplyExcludeMatcher(exclude.cookies);
|
|
3626
|
+
const skippedCookies = [];
|
|
3627
|
+
const localStorage = localStorageResult.payload;
|
|
3628
|
+
const sessionStorage = sessionStorageResult.payload;
|
|
3629
|
+
const cookies = (state2.cookies || []).filter((cookie) => {
|
|
3630
|
+
if (!cookieMatcher(cookie == null ? void 0 : cookie.name)) return true;
|
|
3631
|
+
skippedCookies.push(cookie.name);
|
|
3632
|
+
return false;
|
|
3633
|
+
}).map((cookie) => {
|
|
3571
3634
|
const normalized = { ...cookie };
|
|
3572
3635
|
if (!normalized.path) {
|
|
3573
3636
|
normalized.path = "/";
|
|
@@ -3577,6 +3640,9 @@ var RuntimeEnv = {
|
|
|
3577
3640
|
}
|
|
3578
3641
|
return normalized;
|
|
3579
3642
|
}).filter(Boolean);
|
|
3643
|
+
logApplySkipped("cookies", skippedCookies);
|
|
3644
|
+
logApplySkipped("local_storage", localStorageResult.skipped);
|
|
3645
|
+
logApplySkipped("session_storage", sessionStorageResult.skipped);
|
|
3580
3646
|
if (cookies.length > 0) {
|
|
3581
3647
|
await page.context().addCookies(cookies);
|
|
3582
3648
|
}
|