@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.js
CHANGED
|
@@ -235,6 +235,7 @@ var ActorInfo = {
|
|
|
235
235
|
key: "baidu",
|
|
236
236
|
name: "\u767E\u5EA6AI\u641C",
|
|
237
237
|
domain: "www.baidu.com",
|
|
238
|
+
device: Device.Mobile,
|
|
238
239
|
path: "/s",
|
|
239
240
|
share: {
|
|
240
241
|
mode: "response",
|
|
@@ -535,6 +536,8 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
535
536
|
pushCandidate(root);
|
|
536
537
|
pushCandidate(body);
|
|
537
538
|
document.querySelectorAll("*").forEach(pushCandidate);
|
|
539
|
+
const scrollableOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
|
|
540
|
+
const clippingOverflow = /* @__PURE__ */ new Set(["hidden", "clip"]);
|
|
538
541
|
const isDocumentElement = (el) => el === root || el === body || el === scrollingElement;
|
|
539
542
|
const isVisible = (el, style, rect) => {
|
|
540
543
|
if (!el || !style || !rect) return false;
|
|
@@ -544,6 +547,27 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
544
547
|
if (Number(style.opacity) === 0) return false;
|
|
545
548
|
return rect.width > 0 && rect.height > 0;
|
|
546
549
|
};
|
|
550
|
+
const hasOverflowValue = (style, values) => {
|
|
551
|
+
const overflowY = String(style?.overflowY || "").toLowerCase();
|
|
552
|
+
const overflow = String(style?.overflow || "").toLowerCase();
|
|
553
|
+
return values.has(overflowY) || values.has(overflow);
|
|
554
|
+
};
|
|
555
|
+
const isLargeVerticalClipper = (el, rect) => {
|
|
556
|
+
if (!el || !rect) return false;
|
|
557
|
+
const viewportHeight = window.innerHeight || 0;
|
|
558
|
+
const visibleHeight = Math.ceil(rect.height || 0);
|
|
559
|
+
const clientHeight = Math.ceil(el.clientHeight || 0);
|
|
560
|
+
const boxHeight = Math.max(visibleHeight, clientHeight);
|
|
561
|
+
return boxHeight >= Math.max(320, viewportHeight * 0.45);
|
|
562
|
+
};
|
|
563
|
+
const hasLargeVerticalOverflow = (el, rect) => {
|
|
564
|
+
if (!isLargeVerticalClipper(el, rect)) return false;
|
|
565
|
+
const viewportHeight = window.innerHeight || 0;
|
|
566
|
+
const scrollHeight = Math.ceil(el.scrollHeight || 0);
|
|
567
|
+
const clientHeight = Math.ceil(el.clientHeight || 0);
|
|
568
|
+
const overflowDelta = scrollHeight - clientHeight;
|
|
569
|
+
return overflowDelta >= Math.max(160, viewportHeight * 0.18);
|
|
570
|
+
};
|
|
547
571
|
const rememberOriginalBoxStyles = (el, { includeDocumentElement = false } = {}) => {
|
|
548
572
|
if (!el || !includeDocumentElement && isDocumentElement(el) || el.classList.contains(className)) {
|
|
549
573
|
return;
|
|
@@ -578,19 +602,10 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
578
602
|
if (isDocumentElement(el)) {
|
|
579
603
|
return true;
|
|
580
604
|
}
|
|
581
|
-
|
|
582
|
-
const overflow = String(style.overflow || "").toLowerCase();
|
|
583
|
-
const scrollableOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
|
|
584
|
-
if (scrollableOverflow.has(overflowY) || scrollableOverflow.has(overflow)) {
|
|
605
|
+
if (hasOverflowValue(style, scrollableOverflow)) {
|
|
585
606
|
return true;
|
|
586
607
|
}
|
|
587
|
-
|
|
588
|
-
const clipsY = clippingOverflow.has(overflowY) || clippingOverflow.has(overflow);
|
|
589
|
-
if (!clipsY || !rect) {
|
|
590
|
-
return false;
|
|
591
|
-
}
|
|
592
|
-
const viewportHeight = window.innerHeight || 0;
|
|
593
|
-
return rect.height >= viewportHeight * 0.25 || el.scrollHeight >= viewportHeight * 0.75;
|
|
608
|
+
return hasOverflowValue(style, clippingOverflow) && hasLargeVerticalOverflow(el, rect);
|
|
594
609
|
};
|
|
595
610
|
const measureNeededHeight = (el) => {
|
|
596
611
|
if (!el) return 0;
|
|
@@ -623,10 +638,9 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
623
638
|
const style = window.getComputedStyle(node);
|
|
624
639
|
const rect = node.getBoundingClientRect();
|
|
625
640
|
if (!isVisible(node, style, rect)) continue;
|
|
626
|
-
const
|
|
627
|
-
const
|
|
628
|
-
|
|
629
|
-
if (!clipsContent) continue;
|
|
641
|
+
const scrollableClip = hasOverflowValue(style, scrollableOverflow);
|
|
642
|
+
const visualClip = hasOverflowValue(style, clippingOverflow);
|
|
643
|
+
if (!scrollableClip && (!visualClip || !isLargeVerticalClipper(node, rect))) continue;
|
|
630
644
|
rememberOriginalBoxStyles(node);
|
|
631
645
|
node.style.setProperty("overflow", "visible", "important");
|
|
632
646
|
node.style.setProperty("max-height", "none", "important");
|
|
@@ -1990,7 +2004,11 @@ var RuntimeEnv = {
|
|
|
1990
2004
|
// 指纹、时区、UA、viewport 的回放发生在 launch.js 启动阶段,不在这里做。
|
|
1991
2005
|
async applyToPage(page, source = {}, options = {}) {
|
|
1992
2006
|
if (!page) return;
|
|
1993
|
-
|
|
2007
|
+
let state = normalizeRuntimeState(source, options?.actor || "");
|
|
2008
|
+
if (typeof options?.preapply === "function") {
|
|
2009
|
+
state = await options.preapply(state) || state;
|
|
2010
|
+
rememberRuntimeState(state);
|
|
2011
|
+
}
|
|
1994
2012
|
Object.defineProperty(page, PageRuntimeStateKey, {
|
|
1995
2013
|
configurable: true,
|
|
1996
2014
|
enumerable: false,
|