@skrillex1224/playwright-toolkit 2.1.250 → 2.1.252
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 +5 -1
- package/dist/browser.js.map +2 -2
- package/dist/index.cjs +33 -16
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +33 -16
- package/dist/index.js.map +2 -2
- package/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -563,6 +563,8 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
563
563
|
pushCandidate(root);
|
|
564
564
|
pushCandidate(body);
|
|
565
565
|
document.querySelectorAll("*").forEach(pushCandidate);
|
|
566
|
+
const scrollableOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
|
|
567
|
+
const clippingOverflow = /* @__PURE__ */ new Set(["hidden", "clip"]);
|
|
566
568
|
const isDocumentElement = (el) => el === root || el === body || el === scrollingElement;
|
|
567
569
|
const isVisible = (el, style, rect) => {
|
|
568
570
|
if (!el || !style || !rect) return false;
|
|
@@ -572,6 +574,27 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
572
574
|
if (Number(style.opacity) === 0) return false;
|
|
573
575
|
return rect.width > 0 && rect.height > 0;
|
|
574
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
|
+
};
|
|
575
598
|
const rememberOriginalBoxStyles = (el, { includeDocumentElement = false } = {}) => {
|
|
576
599
|
if (!el || !includeDocumentElement && isDocumentElement(el) || el.classList.contains(className)) {
|
|
577
600
|
return;
|
|
@@ -606,19 +629,10 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
606
629
|
if (isDocumentElement(el)) {
|
|
607
630
|
return true;
|
|
608
631
|
}
|
|
609
|
-
|
|
610
|
-
const overflow = String(style.overflow || "").toLowerCase();
|
|
611
|
-
const scrollableOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
|
|
612
|
-
if (scrollableOverflow.has(overflowY) || scrollableOverflow.has(overflow)) {
|
|
632
|
+
if (hasOverflowValue(style, scrollableOverflow)) {
|
|
613
633
|
return true;
|
|
614
634
|
}
|
|
615
|
-
|
|
616
|
-
const clipsY = clippingOverflow.has(overflowY) || clippingOverflow.has(overflow);
|
|
617
|
-
if (!clipsY || !rect) {
|
|
618
|
-
return false;
|
|
619
|
-
}
|
|
620
|
-
const viewportHeight = window.innerHeight || 0;
|
|
621
|
-
return rect.height >= viewportHeight * 0.25 || el.scrollHeight >= viewportHeight * 0.75;
|
|
635
|
+
return hasOverflowValue(style, clippingOverflow) && hasLargeVerticalOverflow(el, rect);
|
|
622
636
|
};
|
|
623
637
|
const measureNeededHeight = (el) => {
|
|
624
638
|
if (!el) return 0;
|
|
@@ -651,10 +665,9 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
651
665
|
const style = window.getComputedStyle(node);
|
|
652
666
|
const rect = node.getBoundingClientRect();
|
|
653
667
|
if (!isVisible(node, style, rect)) continue;
|
|
654
|
-
const
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
if (!clipsContent) continue;
|
|
668
|
+
const scrollableClip = hasOverflowValue(style, scrollableOverflow);
|
|
669
|
+
const visualClip = hasOverflowValue(style, clippingOverflow);
|
|
670
|
+
if (!scrollableClip && (!visualClip || !isLargeVerticalClipper(node, rect))) continue;
|
|
658
671
|
rememberOriginalBoxStyles(node);
|
|
659
672
|
node.style.setProperty("overflow", "visible", "important");
|
|
660
673
|
node.style.setProperty("max-height", "none", "important");
|
|
@@ -2019,7 +2032,11 @@ var RuntimeEnv = {
|
|
|
2019
2032
|
// 指纹、时区、UA、viewport 的回放发生在 launch.js 启动阶段,不在这里做。
|
|
2020
2033
|
async applyToPage(page, source = {}, options = {}) {
|
|
2021
2034
|
if (!page) return;
|
|
2022
|
-
|
|
2035
|
+
let state = normalizeRuntimeState(source, options?.actor || "");
|
|
2036
|
+
if (typeof options?.preapply === "function") {
|
|
2037
|
+
state = await options.preapply(state) || state;
|
|
2038
|
+
rememberRuntimeState(state);
|
|
2039
|
+
}
|
|
2023
2040
|
Object.defineProperty(page, PageRuntimeStateKey, {
|
|
2024
2041
|
configurable: true,
|
|
2025
2042
|
enumerable: false,
|