mobile-snap 1.0.9 → 1.1.1
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 +48 -18
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -414,9 +414,18 @@ async function applyMockupBorder(browser, imageBuffer, deviceName, size, platfor
|
|
|
414
414
|
const indicatorBg = isDarkTheme ? 'rgba(255, 255, 255, 0.85)' : 'rgba(0, 0, 0, 0.8)';
|
|
415
415
|
const androidIndicatorBg = isDarkTheme ? 'rgba(255, 255, 255, 0.6)' : 'rgba(0, 0, 0, 0.5)';
|
|
416
416
|
const frameScale = shadow ? '0.88' : '0.94';
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
|
|
417
|
+
const iosShadow = shadow ?
|
|
418
|
+
'0 0 0 12px #1f1f21, 0 0 0 13px #2f2f31, 0 20px 50px rgba(0,0,0,0.6)' :
|
|
419
|
+
'0 0 0 12px #1f1f21, 0 0 0 13px #2f2f31';
|
|
420
|
+
const iosTabletShadow = shadow ?
|
|
421
|
+
'0 0 0 14px #1f1f21, 0 0 0 15px #2f2f31, 0 20px 50px rgba(0,0,0,0.6)' :
|
|
422
|
+
'0 0 0 14px #1f1f21, 0 0 0 15px #2f2f31';
|
|
423
|
+
const androidPhoneShadow = shadow ?
|
|
424
|
+
'0 0 0 10px #2a2a2c, 0 0 0 11px #3a3a3c, 0 20px 50px rgba(0,0,0,0.6)' :
|
|
425
|
+
'0 0 0 10px #2a2a2c, 0 0 0 11px #3a3a3c';
|
|
426
|
+
const androidTabletShadow = shadow ?
|
|
427
|
+
'0 0 0 14px #2a2a2c, 0 20px 50px rgba(0,0,0,0.6)' :
|
|
428
|
+
'0 0 0 14px #2a2a2c';
|
|
420
429
|
|
|
421
430
|
let frameClass = 'ios';
|
|
422
431
|
let topElementHTML = '<div class="dynamic-island"></div>';
|
|
@@ -524,10 +533,7 @@ async function applyMockupBorder(browser, imageBuffer, deviceName, size, platfor
|
|
|
524
533
|
.device-frame {
|
|
525
534
|
position: relative;
|
|
526
535
|
background: #000;
|
|
527
|
-
box-shadow:
|
|
528
|
-
0 0 0 12px #1f1f21,
|
|
529
|
-
0 0 0 13px #2f2f31,
|
|
530
|
-
${dropShadow};
|
|
536
|
+
box-shadow: ${iosShadow};
|
|
531
537
|
overflow: hidden;
|
|
532
538
|
transform: scale(${frameScale});
|
|
533
539
|
transform-origin: center;
|
|
@@ -541,29 +547,21 @@ async function applyMockupBorder(browser, imageBuffer, deviceName, size, platfor
|
|
|
541
547
|
}
|
|
542
548
|
.device-frame.ios-tablet {
|
|
543
549
|
border-radius: 32px;
|
|
544
|
-
box-shadow:
|
|
545
|
-
0 0 0 14px #1f1f21,
|
|
546
|
-
0 0 0 15px #2f2f31,
|
|
547
|
-
${dropShadow};
|
|
550
|
+
box-shadow: ${iosTabletShadow};
|
|
548
551
|
}
|
|
549
552
|
.device-frame.ios-tablet .screenshot-img {
|
|
550
553
|
border-radius: 20px;
|
|
551
554
|
}
|
|
552
555
|
.device-frame.android-phone {
|
|
553
556
|
border-radius: 40px;
|
|
554
|
-
box-shadow:
|
|
555
|
-
0 0 0 10px #2a2a2c,
|
|
556
|
-
0 0 0 11px #3a3a3c,
|
|
557
|
-
${androidDropShadow};
|
|
557
|
+
box-shadow: ${androidPhoneShadow};
|
|
558
558
|
}
|
|
559
559
|
.device-frame.android-phone .screenshot-img {
|
|
560
560
|
border-radius: 30px;
|
|
561
561
|
}
|
|
562
562
|
.device-frame.android-tablet {
|
|
563
563
|
border-radius: 24px;
|
|
564
|
-
box-shadow:
|
|
565
|
-
0 0 0 14px #2a2a2c,
|
|
566
|
-
${tabletDropShadow};
|
|
564
|
+
box-shadow: ${androidTabletShadow};
|
|
567
565
|
}
|
|
568
566
|
.device-frame.android-tablet .screenshot-img {
|
|
569
567
|
border-radius: 12px;
|
|
@@ -699,6 +697,34 @@ async function applyMockupBorder(browser, imageBuffer, deviceName, size, platfor
|
|
|
699
697
|
return buffer;
|
|
700
698
|
}
|
|
701
699
|
|
|
700
|
+
async function injectSafeAreas(page, platform) {
|
|
701
|
+
try {
|
|
702
|
+
if (platform === 'ios') {
|
|
703
|
+
await page.addStyleTag({
|
|
704
|
+
content: `
|
|
705
|
+
:root {
|
|
706
|
+
--safe-top: 47px !important;
|
|
707
|
+
}
|
|
708
|
+
.nav-container {
|
|
709
|
+
padding-bottom: 34px !important;
|
|
710
|
+
}
|
|
711
|
+
`
|
|
712
|
+
});
|
|
713
|
+
} else if (platform === 'android') {
|
|
714
|
+
await page.addStyleTag({
|
|
715
|
+
content: `
|
|
716
|
+
:root {
|
|
717
|
+
--safe-top: 24px !important;
|
|
718
|
+
}
|
|
719
|
+
.nav-container {
|
|
720
|
+
padding-bottom: 16px !important;
|
|
721
|
+
}
|
|
722
|
+
`
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
} catch (e) {}
|
|
726
|
+
}
|
|
727
|
+
|
|
702
728
|
async function captureScreenshots(url, paths, outputDir, platform, crawl, detectPages, email, password, loginPath, addHtml, mockup, shadow = true) {
|
|
703
729
|
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
|
704
730
|
url = 'http://' + url;
|
|
@@ -861,6 +887,7 @@ async function captureScreenshots(url, paths, outputDir, platform, crawl, detect
|
|
|
861
887
|
const pageSpinner = ora(` Navigating to ${route}...`).start();
|
|
862
888
|
try {
|
|
863
889
|
await page.goto(targetUrl, { timeout: 30000 });
|
|
890
|
+
await injectSafeAreas(page, plat);
|
|
864
891
|
pageSpinner.text = ` Waiting for network idle on ${route}...`;
|
|
865
892
|
await page.waitForLoadState('networkidle', { timeout: 15000 });
|
|
866
893
|
await new Promise(resolve => setTimeout(resolve, 800));
|
|
@@ -930,6 +957,7 @@ async function captureScreenshots(url, paths, outputDir, platform, crawl, detect
|
|
|
930
957
|
const pageSpinner = ora(` Navigating to ${route}...`).start();
|
|
931
958
|
try {
|
|
932
959
|
await page.goto(targetUrl, { timeout: 30000 });
|
|
960
|
+
await injectSafeAreas(page, plat);
|
|
933
961
|
pageSpinner.text = ` Waiting for network idle on ${route}...`;
|
|
934
962
|
await page.waitForLoadState('networkidle', { timeout: 15000 });
|
|
935
963
|
await new Promise(resolve => setTimeout(resolve, 800));
|
|
@@ -954,6 +982,7 @@ async function captureScreenshots(url, paths, outputDir, platform, crawl, detect
|
|
|
954
982
|
const pageSpinner = ora(` Navigating to ${route}...`).start();
|
|
955
983
|
try {
|
|
956
984
|
await page.goto(targetUrl, { timeout: 30000 });
|
|
985
|
+
await injectSafeAreas(page, plat);
|
|
957
986
|
pageSpinner.text = ` Waiting for network idle on ${route}...`;
|
|
958
987
|
await page.waitForLoadState('networkidle', { timeout: 15000 });
|
|
959
988
|
await new Promise(resolve => setTimeout(resolve, 800));
|
|
@@ -977,6 +1006,7 @@ async function captureScreenshots(url, paths, outputDir, platform, crawl, detect
|
|
|
977
1006
|
const pageSpinner = ora(` Navigating to ${route}...`).start();
|
|
978
1007
|
try {
|
|
979
1008
|
await page.goto(targetUrl, { timeout: 30000 });
|
|
1009
|
+
await injectSafeAreas(page, plat);
|
|
980
1010
|
pageSpinner.text = ` Waiting for network idle on ${route}...`;
|
|
981
1011
|
await page.waitForLoadState('networkidle', { timeout: 15000 });
|
|
982
1012
|
await new Promise(resolve => setTimeout(resolve, 800));
|