mobile-snap 1.1.0 → 1.1.2
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/bin/cli.js +32 -0
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -697,6 +697,34 @@ async function applyMockupBorder(browser, imageBuffer, deviceName, size, platfor
|
|
|
697
697
|
return buffer;
|
|
698
698
|
}
|
|
699
699
|
|
|
700
|
+
async function injectSafeAreas(page, platform) {
|
|
701
|
+
try {
|
|
702
|
+
if (platform === 'ios') {
|
|
703
|
+
await page.addStyleTag({
|
|
704
|
+
content: `
|
|
705
|
+
:root {
|
|
706
|
+
--safe-top: 52px !important;
|
|
707
|
+
}
|
|
708
|
+
.nav-container {
|
|
709
|
+
padding-bottom: 5px !important;
|
|
710
|
+
}
|
|
711
|
+
`
|
|
712
|
+
});
|
|
713
|
+
} else if (platform === 'android') {
|
|
714
|
+
await page.addStyleTag({
|
|
715
|
+
content: `
|
|
716
|
+
:root {
|
|
717
|
+
--safe-top: 29px !important;
|
|
718
|
+
}
|
|
719
|
+
.nav-container {
|
|
720
|
+
padding-bottom: 5px !important;
|
|
721
|
+
}
|
|
722
|
+
`
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
} catch (e) {}
|
|
726
|
+
}
|
|
727
|
+
|
|
700
728
|
async function captureScreenshots(url, paths, outputDir, platform, crawl, detectPages, email, password, loginPath, addHtml, mockup, shadow = true) {
|
|
701
729
|
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
|
702
730
|
url = 'http://' + url;
|
|
@@ -859,6 +887,7 @@ async function captureScreenshots(url, paths, outputDir, platform, crawl, detect
|
|
|
859
887
|
const pageSpinner = ora(` Navigating to ${route}...`).start();
|
|
860
888
|
try {
|
|
861
889
|
await page.goto(targetUrl, { timeout: 30000 });
|
|
890
|
+
await injectSafeAreas(page, plat);
|
|
862
891
|
pageSpinner.text = ` Waiting for network idle on ${route}...`;
|
|
863
892
|
await page.waitForLoadState('networkidle', { timeout: 15000 });
|
|
864
893
|
await new Promise(resolve => setTimeout(resolve, 800));
|
|
@@ -928,6 +957,7 @@ async function captureScreenshots(url, paths, outputDir, platform, crawl, detect
|
|
|
928
957
|
const pageSpinner = ora(` Navigating to ${route}...`).start();
|
|
929
958
|
try {
|
|
930
959
|
await page.goto(targetUrl, { timeout: 30000 });
|
|
960
|
+
await injectSafeAreas(page, plat);
|
|
931
961
|
pageSpinner.text = ` Waiting for network idle on ${route}...`;
|
|
932
962
|
await page.waitForLoadState('networkidle', { timeout: 15000 });
|
|
933
963
|
await new Promise(resolve => setTimeout(resolve, 800));
|
|
@@ -952,6 +982,7 @@ async function captureScreenshots(url, paths, outputDir, platform, crawl, detect
|
|
|
952
982
|
const pageSpinner = ora(` Navigating to ${route}...`).start();
|
|
953
983
|
try {
|
|
954
984
|
await page.goto(targetUrl, { timeout: 30000 });
|
|
985
|
+
await injectSafeAreas(page, plat);
|
|
955
986
|
pageSpinner.text = ` Waiting for network idle on ${route}...`;
|
|
956
987
|
await page.waitForLoadState('networkidle', { timeout: 15000 });
|
|
957
988
|
await new Promise(resolve => setTimeout(resolve, 800));
|
|
@@ -975,6 +1006,7 @@ async function captureScreenshots(url, paths, outputDir, platform, crawl, detect
|
|
|
975
1006
|
const pageSpinner = ora(` Navigating to ${route}...`).start();
|
|
976
1007
|
try {
|
|
977
1008
|
await page.goto(targetUrl, { timeout: 30000 });
|
|
1009
|
+
await injectSafeAreas(page, plat);
|
|
978
1010
|
pageSpinner.text = ` Waiting for network idle on ${route}...`;
|
|
979
1011
|
await page.waitForLoadState('networkidle', { timeout: 15000 });
|
|
980
1012
|
await new Promise(resolve => setTimeout(resolve, 800));
|