@skrillex1224/playwright-toolkit 2.1.249 → 2.1.251
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 +6 -1
- package/dist/browser.js.map +2 -2
- package/dist/index.cjs +34 -16
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +34 -16
- package/dist/index.js.map +2 -2
- package/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -262,6 +262,7 @@ var ActorInfo = {
|
|
|
262
262
|
key: "baidu",
|
|
263
263
|
name: "\u767E\u5EA6AI\u641C",
|
|
264
264
|
domain: "www.baidu.com",
|
|
265
|
+
device: Device.Mobile,
|
|
265
266
|
path: "/s",
|
|
266
267
|
share: {
|
|
267
268
|
mode: "response",
|
|
@@ -562,6 +563,8 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
562
563
|
pushCandidate(root);
|
|
563
564
|
pushCandidate(body);
|
|
564
565
|
document.querySelectorAll("*").forEach(pushCandidate);
|
|
566
|
+
const scrollableOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
|
|
567
|
+
const clippingOverflow = /* @__PURE__ */ new Set(["hidden", "clip"]);
|
|
565
568
|
const isDocumentElement = (el) => el === root || el === body || el === scrollingElement;
|
|
566
569
|
const isVisible = (el, style, rect) => {
|
|
567
570
|
if (!el || !style || !rect) return false;
|
|
@@ -571,6 +574,27 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
571
574
|
if (Number(style.opacity) === 0) return false;
|
|
572
575
|
return rect.width > 0 && rect.height > 0;
|
|
573
576
|
};
|
|
577
|
+
const hasOverflowValue = (style, values) => {
|
|
578
|
+
const overflowY = String(style?.overflowY || "").toLowerCase();
|
|
579
|
+
const overflow = String(style?.overflow || "").toLowerCase();
|
|
580
|
+
return values.has(overflowY) || values.has(overflow);
|
|
581
|
+
};
|
|
582
|
+
const isLargeVerticalClipper = (el, rect) => {
|
|
583
|
+
if (!el || !rect) return false;
|
|
584
|
+
const viewportHeight = window.innerHeight || 0;
|
|
585
|
+
const visibleHeight = Math.ceil(rect.height || 0);
|
|
586
|
+
const clientHeight = Math.ceil(el.clientHeight || 0);
|
|
587
|
+
const boxHeight = Math.max(visibleHeight, clientHeight);
|
|
588
|
+
return boxHeight >= Math.max(320, viewportHeight * 0.45);
|
|
589
|
+
};
|
|
590
|
+
const hasLargeVerticalOverflow = (el, rect) => {
|
|
591
|
+
if (!isLargeVerticalClipper(el, rect)) return false;
|
|
592
|
+
const viewportHeight = window.innerHeight || 0;
|
|
593
|
+
const scrollHeight = Math.ceil(el.scrollHeight || 0);
|
|
594
|
+
const clientHeight = Math.ceil(el.clientHeight || 0);
|
|
595
|
+
const overflowDelta = scrollHeight - clientHeight;
|
|
596
|
+
return overflowDelta >= Math.max(160, viewportHeight * 0.18);
|
|
597
|
+
};
|
|
574
598
|
const rememberOriginalBoxStyles = (el, { includeDocumentElement = false } = {}) => {
|
|
575
599
|
if (!el || !includeDocumentElement && isDocumentElement(el) || el.classList.contains(className)) {
|
|
576
600
|
return;
|
|
@@ -605,19 +629,10 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
605
629
|
if (isDocumentElement(el)) {
|
|
606
630
|
return true;
|
|
607
631
|
}
|
|
608
|
-
|
|
609
|
-
const overflow = String(style.overflow || "").toLowerCase();
|
|
610
|
-
const scrollableOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
|
|
611
|
-
if (scrollableOverflow.has(overflowY) || scrollableOverflow.has(overflow)) {
|
|
632
|
+
if (hasOverflowValue(style, scrollableOverflow)) {
|
|
612
633
|
return true;
|
|
613
634
|
}
|
|
614
|
-
|
|
615
|
-
const clipsY = clippingOverflow.has(overflowY) || clippingOverflow.has(overflow);
|
|
616
|
-
if (!clipsY || !rect) {
|
|
617
|
-
return false;
|
|
618
|
-
}
|
|
619
|
-
const viewportHeight = window.innerHeight || 0;
|
|
620
|
-
return rect.height >= viewportHeight * 0.25 || el.scrollHeight >= viewportHeight * 0.75;
|
|
635
|
+
return hasOverflowValue(style, clippingOverflow) && hasLargeVerticalOverflow(el, rect);
|
|
621
636
|
};
|
|
622
637
|
const measureNeededHeight = (el) => {
|
|
623
638
|
if (!el) return 0;
|
|
@@ -650,10 +665,9 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
650
665
|
const style = window.getComputedStyle(node);
|
|
651
666
|
const rect = node.getBoundingClientRect();
|
|
652
667
|
if (!isVisible(node, style, rect)) continue;
|
|
653
|
-
const
|
|
654
|
-
const
|
|
655
|
-
|
|
656
|
-
if (!clipsContent) continue;
|
|
668
|
+
const scrollableClip = hasOverflowValue(style, scrollableOverflow);
|
|
669
|
+
const visualClip = hasOverflowValue(style, clippingOverflow);
|
|
670
|
+
if (!scrollableClip && (!visualClip || !isLargeVerticalClipper(node, rect))) continue;
|
|
657
671
|
rememberOriginalBoxStyles(node);
|
|
658
672
|
node.style.setProperty("overflow", "visible", "important");
|
|
659
673
|
node.style.setProperty("max-height", "none", "important");
|
|
@@ -2018,7 +2032,11 @@ var RuntimeEnv = {
|
|
|
2018
2032
|
// 指纹、时区、UA、viewport 的回放发生在 launch.js 启动阶段,不在这里做。
|
|
2019
2033
|
async applyToPage(page, source = {}, options = {}) {
|
|
2020
2034
|
if (!page) return;
|
|
2021
|
-
|
|
2035
|
+
let state = normalizeRuntimeState(source, options?.actor || "");
|
|
2036
|
+
if (typeof options?.preapply === "function") {
|
|
2037
|
+
state = await options.preapply(state) || state;
|
|
2038
|
+
rememberRuntimeState(state);
|
|
2039
|
+
}
|
|
2022
2040
|
Object.defineProperty(page, PageRuntimeStateKey, {
|
|
2023
2041
|
configurable: true,
|
|
2024
2042
|
enumerable: false,
|