@skrillex1224/playwright-toolkit 2.1.237 → 2.1.239

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/index.cjs CHANGED
@@ -167,8 +167,9 @@ var ActorInfo = {
167
167
  qbot: createActorInfo({
168
168
  key: "qbot",
169
169
  name: "QQ\u6D4F\u89C8\u5668AI\u641C",
170
- domain: "sogou.com",
170
+ domain: "m.sogou.com",
171
171
  path: "/web",
172
+ device: Device.Mobile,
172
173
  share: {
173
174
  mode: "dom",
174
175
  prefix: "",
@@ -749,6 +750,84 @@ var expandScrollableContent = async (page, options = {}) => {
749
750
  expandDocumentElements: options.expandDocumentElements === true
750
751
  });
751
752
  };
753
+ var pinBottomAffixedElements = async (page, options = {}) => {
754
+ return await page.evaluate(({ className, targetHeight }) => {
755
+ const viewportHeight = window.innerHeight || document.documentElement?.clientHeight || document.body?.clientHeight || 0;
756
+ const safeTargetHeight = Math.ceil(Number(targetHeight) || 0);
757
+ const deltaY = safeTargetHeight - viewportHeight;
758
+ if (deltaY <= 1) {
759
+ return 0;
760
+ }
761
+ const isVisible = (el, style, rect) => {
762
+ if (!el || !style || !rect) return false;
763
+ if (style.display === "none" || style.visibility === "hidden" || style.visibility === "collapse") {
764
+ return false;
765
+ }
766
+ if (Number(style.opacity) === 0) return false;
767
+ return rect.width > 0 && rect.height > 0;
768
+ };
769
+ const bottomThreshold = Math.max(24, Math.min(96, viewportHeight * 0.12));
770
+ const maxAffixedHeight = Math.max(56, viewportHeight * 0.65);
771
+ const candidates = [];
772
+ document.querySelectorAll("*").forEach((el) => {
773
+ const style = window.getComputedStyle(el);
774
+ const position = String(style.position || "").toLowerCase();
775
+ if (position !== "fixed" && position !== "sticky") return;
776
+ const rect = el.getBoundingClientRect();
777
+ if (!isVisible(el, style, rect)) return;
778
+ if (rect.height > maxAffixedHeight) return;
779
+ if (rect.bottom < viewportHeight - bottomThreshold) return;
780
+ const bottom = Number.parseFloat(style.bottom);
781
+ const hasBottomRule = Number.isFinite(bottom) && bottom <= Math.max(160, viewportHeight * 0.25);
782
+ const isNearViewportBottom = rect.bottom >= viewportHeight - bottomThreshold;
783
+ if (!hasBottomRule && !isNearViewportBottom) return;
784
+ candidates.push(el);
785
+ });
786
+ const candidateSet = new Set(candidates);
787
+ const topLevelCandidates = candidates.filter((el) => {
788
+ for (let parent = el.parentElement; parent; parent = parent.parentElement) {
789
+ if (candidateSet.has(parent)) return false;
790
+ }
791
+ return true;
792
+ });
793
+ topLevelCandidates.forEach((el) => {
794
+ if (!Object.prototype.hasOwnProperty.call(el.dataset, "pkBottomPinned")) {
795
+ el.dataset.pkBottomPinned = "1";
796
+ el.dataset.pkOrigTranslate = el.style.getPropertyValue("translate") || "";
797
+ el.dataset.pkOrigTranslatePriority = el.style.getPropertyPriority("translate") || "";
798
+ }
799
+ el.classList.add(className);
800
+ el.style.setProperty("translate", `0 ${Math.round(deltaY)}px`, "important");
801
+ });
802
+ return topLevelCandidates.length;
803
+ }, {
804
+ className: EXPANDED_SCROLLABLE_CLASS,
805
+ targetHeight: options.targetHeight
806
+ });
807
+ };
808
+ var restoreBottomAffixedElements = async (page) => {
809
+ await page.evaluate((className) => {
810
+ const hasOwn = (source, key) => Object.prototype.hasOwnProperty.call(source, key);
811
+ const expansionKeys = [
812
+ "pkOrigOverflow",
813
+ "pkOrigHeight",
814
+ "pkOrigMinHeight",
815
+ "pkOrigMaxHeight"
816
+ ];
817
+ document.querySelectorAll('[data-pk-bottom-pinned="1"]').forEach((el) => {
818
+ if (hasOwn(el.dataset, "pkOrigTranslate")) {
819
+ el.style.setProperty("translate", el.dataset.pkOrigTranslate || "", el.dataset.pkOrigTranslatePriority || "");
820
+ delete el.dataset.pkOrigTranslate;
821
+ delete el.dataset.pkOrigTranslatePriority;
822
+ }
823
+ delete el.dataset.pkBottomPinned;
824
+ const stillExpanded = expansionKeys.some((key) => hasOwn(el.dataset, key));
825
+ if (!stillExpanded) {
826
+ el.classList.remove(className);
827
+ }
828
+ });
829
+ }, EXPANDED_SCROLLABLE_CLASS);
830
+ };
752
831
  var prepareExpandedFullPageScreenshot = async (page, options = {}) => {
753
832
  const originalViewport = await resolveCurrentViewportSize(page);
754
833
  const maxHeight = toPositiveInteger(options.maxHeight, DEFAULT_MAX_HEIGHT);
@@ -769,6 +848,10 @@ var prepareExpandedFullPageScreenshot = async (page, options = {}) => {
769
848
  height: targetHeight
770
849
  });
771
850
  viewportResized = true;
851
+ } else {
852
+ await pinBottomAffixedElements(page, { targetHeight }).catch((error) => {
853
+ logger.warning(`\u79FB\u52A8\u7AEF\u5438\u5E95\u5143\u7D20\u91CD\u5B9A\u4F4D\u5931\u8D25: ${error?.message || error}`);
854
+ });
772
855
  }
773
856
  if (settleMs > 0) {
774
857
  await (0, import_delay.default)(settleMs);
@@ -873,6 +956,9 @@ var captureExpandedFullPageScreenshot = async (page, options = {}) => {
873
956
  maxClipHeight: state.targetHeight
874
957
  });
875
958
  } finally {
959
+ await restoreBottomAffixedElements(page).catch((error) => {
960
+ logger.warning(`\u79FB\u52A8\u7AEF\u5438\u5E95\u5143\u7D20\u6062\u590D\u5931\u8D25: ${error?.message || error}`);
961
+ });
876
962
  if (options.restore) {
877
963
  await restoreExpandedFullPageScreenshot(page, state);
878
964
  }