mobile-snap 1.0.8 → 1.1.0
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 +24 -21
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -399,7 +399,7 @@ async function analyzeRoutes(browser, baseUrl, initialPaths, email, password, lo
|
|
|
399
399
|
};
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
-
async function applyMockupBorder(browser, imageBuffer, deviceName, size, platform, isDarkTheme = false) {
|
|
402
|
+
async function applyMockupBorder(browser, imageBuffer, deviceName, size, platform, isDarkTheme = false, shadow = true) {
|
|
403
403
|
const base64Image = imageBuffer.toString('base64');
|
|
404
404
|
|
|
405
405
|
const now = new Date();
|
|
@@ -413,7 +413,19 @@ async function applyMockupBorder(browser, imageBuffer, deviceName, size, platfor
|
|
|
413
413
|
const batteryLevelBg = isDarkTheme ? '#ffffff' : '#000000';
|
|
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
|
-
const
|
|
416
|
+
const frameScale = shadow ? '0.88' : '0.94';
|
|
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';
|
|
417
429
|
|
|
418
430
|
let frameClass = 'ios';
|
|
419
431
|
let topElementHTML = '<div class="dynamic-island"></div>';
|
|
@@ -521,12 +533,9 @@ async function applyMockupBorder(browser, imageBuffer, deviceName, size, platfor
|
|
|
521
533
|
.device-frame {
|
|
522
534
|
position: relative;
|
|
523
535
|
background: #000;
|
|
524
|
-
box-shadow:
|
|
525
|
-
0 0 0 12px #1f1f21,
|
|
526
|
-
0 0 0 13px #2f2f31,
|
|
527
|
-
0 20px 50px rgba(0,0,0,0.6);
|
|
536
|
+
box-shadow: ${iosShadow};
|
|
528
537
|
overflow: hidden;
|
|
529
|
-
transform: scale(
|
|
538
|
+
transform: scale(${frameScale});
|
|
530
539
|
transform-origin: center;
|
|
531
540
|
flex-shrink: 0;
|
|
532
541
|
}
|
|
@@ -538,29 +547,21 @@ async function applyMockupBorder(browser, imageBuffer, deviceName, size, platfor
|
|
|
538
547
|
}
|
|
539
548
|
.device-frame.ios-tablet {
|
|
540
549
|
border-radius: 32px;
|
|
541
|
-
box-shadow:
|
|
542
|
-
0 0 0 14px #1f1f21,
|
|
543
|
-
0 0 0 15px #2f2f31,
|
|
544
|
-
0 20px 50px rgba(0,0,0,0.6);
|
|
550
|
+
box-shadow: ${iosTabletShadow};
|
|
545
551
|
}
|
|
546
552
|
.device-frame.ios-tablet .screenshot-img {
|
|
547
553
|
border-radius: 20px;
|
|
548
554
|
}
|
|
549
555
|
.device-frame.android-phone {
|
|
550
556
|
border-radius: 40px;
|
|
551
|
-
box-shadow:
|
|
552
|
-
0 0 0 10px #2a2a2c,
|
|
553
|
-
0 0 0 11px #3a3a3c,
|
|
554
|
-
0 20px 50px rgba(0,0,0,0.6);
|
|
557
|
+
box-shadow: ${androidPhoneShadow};
|
|
555
558
|
}
|
|
556
559
|
.device-frame.android-phone .screenshot-img {
|
|
557
560
|
border-radius: 30px;
|
|
558
561
|
}
|
|
559
562
|
.device-frame.android-tablet {
|
|
560
563
|
border-radius: 24px;
|
|
561
|
-
box-shadow:
|
|
562
|
-
0 0 0 14px #2a2a2c,
|
|
563
|
-
0 20px 50px rgba(0,0,0,0.6);
|
|
564
|
+
box-shadow: ${androidTabletShadow};
|
|
564
565
|
}
|
|
565
566
|
.device-frame.android-tablet .screenshot-img {
|
|
566
567
|
border-radius: 12px;
|
|
@@ -696,7 +697,7 @@ async function applyMockupBorder(browser, imageBuffer, deviceName, size, platfor
|
|
|
696
697
|
return buffer;
|
|
697
698
|
}
|
|
698
699
|
|
|
699
|
-
async function captureScreenshots(url, paths, outputDir, platform, crawl, detectPages, email, password, loginPath, addHtml, mockup) {
|
|
700
|
+
async function captureScreenshots(url, paths, outputDir, platform, crawl, detectPages, email, password, loginPath, addHtml, mockup, shadow = true) {
|
|
700
701
|
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
|
701
702
|
url = 'http://' + url;
|
|
702
703
|
}
|
|
@@ -823,7 +824,7 @@ async function captureScreenshots(url, paths, outputDir, platform, crawl, detect
|
|
|
823
824
|
});
|
|
824
825
|
|
|
825
826
|
const raw = await page.screenshot({ fullPage: false });
|
|
826
|
-
const framed = await applyMockupBorder(browser, raw, deviceName, size, plat, isDarkTheme);
|
|
827
|
+
const framed = await applyMockupBorder(browser, raw, deviceName, size, plat, isDarkTheme, shadow);
|
|
827
828
|
fs.writeFileSync(outputPath, framed);
|
|
828
829
|
} else {
|
|
829
830
|
await page.screenshot({ path: outputPath, fullPage: false });
|
|
@@ -1011,6 +1012,7 @@ program
|
|
|
1011
1012
|
.option('--login-path <path>', 'Path to the login page', '/login.html')
|
|
1012
1013
|
.option('--html', 'Auto append .html extension to detected routes', false)
|
|
1013
1014
|
.option('-m, --mockup', 'Wrap screenshots in a beautiful iPhone/Android device mockup frame', false)
|
|
1015
|
+
.option('--no-shadow', 'Disable mockup device shadow and stretch border to edges')
|
|
1014
1016
|
.action((options) => {
|
|
1015
1017
|
let pathList = [];
|
|
1016
1018
|
if (options.paths) {
|
|
@@ -1034,7 +1036,8 @@ program
|
|
|
1034
1036
|
options.password,
|
|
1035
1037
|
options.loginPath,
|
|
1036
1038
|
options.html,
|
|
1037
|
-
options.mockup
|
|
1039
|
+
options.mockup,
|
|
1040
|
+
options.shadow
|
|
1038
1041
|
).catch(err => {
|
|
1039
1042
|
console.error(pc.red(`An unexpected error occurred: ${err.message}`));
|
|
1040
1043
|
process.exit(1);
|