codeplay-common 4.7.5 → 4.7.6
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/files/take-screen-image.js +49 -15
- package/package.json +1 -1
|
@@ -1211,12 +1211,33 @@ async function capturePageSnapshot(client) {
|
|
|
1211
1211
|
};
|
|
1212
1212
|
|
|
1213
1213
|
const serializeDocument = async (sourceDocument) => {
|
|
1214
|
-
const
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1214
|
+
const originalElements = [];
|
|
1215
|
+
const clonedElements = [];
|
|
1216
|
+
const cloneWithShadowRoots = (original) => {
|
|
1217
|
+
const clone = original.cloneNode(false);
|
|
1218
|
+
if (original.nodeType === Node.ELEMENT_NODE) {
|
|
1219
|
+
originalElements.push(original);
|
|
1220
|
+
clonedElements.push(clone);
|
|
1221
|
+
}
|
|
1222
|
+
for (const child of original.childNodes) {
|
|
1223
|
+
clone.appendChild(cloneWithShadowRoots(child));
|
|
1224
|
+
}
|
|
1225
|
+
if (original.shadowRoot) {
|
|
1226
|
+
const template = sourceDocument.createElement('template');
|
|
1227
|
+
template.setAttribute('shadowrootmode', 'open');
|
|
1228
|
+
for (const stylesheet of original.shadowRoot.adoptedStyleSheets || []) {
|
|
1229
|
+
const style = sourceDocument.createElement('style');
|
|
1230
|
+
style.textContent = [...stylesheet.cssRules].map((rule) => rule.cssText).join('\\n');
|
|
1231
|
+
template.content.appendChild(style);
|
|
1232
|
+
}
|
|
1233
|
+
for (const child of original.shadowRoot.childNodes) {
|
|
1234
|
+
template.content.appendChild(cloneWithShadowRoots(child));
|
|
1235
|
+
}
|
|
1236
|
+
clone.prepend(template);
|
|
1237
|
+
}
|
|
1238
|
+
return clone;
|
|
1239
|
+
};
|
|
1240
|
+
const clonedRoot = cloneWithShadowRoots(sourceDocument.documentElement);
|
|
1220
1241
|
|
|
1221
1242
|
clonedRoot.setAttribute(
|
|
1222
1243
|
'data-responsive-window-scroll-y',
|
|
@@ -1234,9 +1255,13 @@ async function capturePageSnapshot(client) {
|
|
|
1234
1255
|
clone.setAttribute('data-responsive-scroll-left', String(original.scrollLeft));
|
|
1235
1256
|
}
|
|
1236
1257
|
|
|
1237
|
-
if (original.classList.contains('swiper-initialized')) {
|
|
1258
|
+
if (original.classList.contains('swiper-initialized') || original.swiper) {
|
|
1238
1259
|
clone.setAttribute('data-responsive-swiper-width', String(original.clientWidth));
|
|
1239
1260
|
clone.setAttribute('data-responsive-swiper-height', String(original.clientHeight));
|
|
1261
|
+
if (original.swiper) {
|
|
1262
|
+
clone.setAttribute('data-responsive-swiper-active-index', String(original.swiper.activeIndex));
|
|
1263
|
+
clone.setAttribute('data-responsive-swiper-direction', original.swiper.params.direction);
|
|
1264
|
+
}
|
|
1240
1265
|
}
|
|
1241
1266
|
|
|
1242
1267
|
const tagName = original.tagName?.toLowerCase();
|
|
@@ -1321,7 +1346,7 @@ async function capturePageSnapshot(client) {
|
|
|
1321
1346
|
}
|
|
1322
1347
|
}));
|
|
1323
1348
|
|
|
1324
|
-
|
|
1349
|
+
clonedElements.filter((element) => element.matches('script, link[rel="modulepreload"]')).forEach(
|
|
1325
1350
|
(element) => element.remove(),
|
|
1326
1351
|
);
|
|
1327
1352
|
clonedRoot.querySelectorAll('meta[http-equiv="Content-Security-Policy"]').forEach(
|
|
@@ -1560,25 +1585,34 @@ async function waitForReplayLayout(client, snapshot) {
|
|
|
1560
1585
|
new Promise((resolve) => setTimeout(resolve, 5000)),
|
|
1561
1586
|
]);
|
|
1562
1587
|
|
|
1563
|
-
const
|
|
1564
|
-
|
|
1588
|
+
const replayRoots = [];
|
|
1589
|
+
const collectRoots = (root) => {
|
|
1590
|
+
replayRoots.push(root);
|
|
1591
|
+
root.querySelectorAll('*').forEach((element) => {
|
|
1592
|
+
if (element.shadowRoot) collectRoots(element.shadowRoot);
|
|
1593
|
+
});
|
|
1594
|
+
};
|
|
1595
|
+
replayDocuments.forEach(collectRoots);
|
|
1596
|
+
const replayElements = (selector) => replayRoots.flatMap((root) => (
|
|
1597
|
+
[...root.querySelectorAll(selector)]
|
|
1565
1598
|
));
|
|
1566
1599
|
|
|
1567
1600
|
replayElements('[data-responsive-swiper-width]').forEach((swiper) => {
|
|
1568
|
-
const wrapper = [...swiper.children].find((element) => (
|
|
1601
|
+
const wrapper = swiper.shadowRoot?.querySelector('.swiper-wrapper') || [...swiper.children].find((element) => (
|
|
1569
1602
|
element.classList.contains('swiper-wrapper')
|
|
1570
1603
|
));
|
|
1571
1604
|
|
|
1572
1605
|
if (!wrapper) return;
|
|
1573
1606
|
|
|
1574
|
-
const slides = [...wrapper.children].filter((element) => (
|
|
1575
|
-
element.
|
|
1607
|
+
const slides = [...(swiper.shadowRoot ? swiper.children : wrapper.children)].filter((element) => (
|
|
1608
|
+
element.matches('.swiper-slide, swiper-slide')
|
|
1576
1609
|
));
|
|
1577
1610
|
const sourceWidth = Number(swiper.dataset.responsiveSwiperWidth);
|
|
1578
1611
|
const sourceHeight = Number(swiper.dataset.responsiveSwiperHeight);
|
|
1579
1612
|
const widthScale = sourceWidth > 0 ? swiper.clientWidth / sourceWidth : 1;
|
|
1580
1613
|
const heightScale = sourceHeight > 0 ? swiper.clientHeight / sourceHeight : 1;
|
|
1581
|
-
const isVertical = swiper.
|
|
1614
|
+
const isVertical = swiper.dataset.responsiveSwiperDirection === 'vertical'
|
|
1615
|
+
|| swiper.classList.contains('swiper-vertical');
|
|
1582
1616
|
|
|
1583
1617
|
slides.forEach((slide) => {
|
|
1584
1618
|
if (!slide.dataset.responsiveSwiperWidth && slide.style.width) {
|
|
@@ -1601,7 +1635,7 @@ async function waitForReplayLayout(client, snapshot) {
|
|
|
1601
1635
|
}
|
|
1602
1636
|
});
|
|
1603
1637
|
|
|
1604
|
-
const activeSlide = slides.find((slide) => (
|
|
1638
|
+
const activeSlide = slides[Number(swiper.dataset.responsiveSwiperActiveIndex)] || slides.find((slide) => (
|
|
1605
1639
|
slide.classList.contains('swiper-slide-active')
|
|
1606
1640
|
)) || slides[0];
|
|
1607
1641
|
|