mobile-snap 1.0.8 → 1.0.9

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.
Files changed (2) hide show
  1. package/bin/cli.js +15 -10
  2. 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,10 @@ 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 tabletIndicatorBg = isDarkTheme ? 'rgba(255, 255, 255, 0.4)' : 'rgba(0, 0, 0, 0.3)';
416
+ const frameScale = shadow ? '0.88' : '0.94';
417
+ const dropShadow = shadow ? '0 20px 50px rgba(0,0,0,0.6)' : 'none';
418
+ const androidDropShadow = shadow ? '0 20px 50px rgba(0,0,0,0.6)' : 'none';
419
+ const tabletDropShadow = shadow ? '0 20px 50px rgba(0,0,0,0.6)' : 'none';
417
420
 
418
421
  let frameClass = 'ios';
419
422
  let topElementHTML = '<div class="dynamic-island"></div>';
@@ -524,9 +527,9 @@ async function applyMockupBorder(browser, imageBuffer, deviceName, size, platfor
524
527
  box-shadow:
525
528
  0 0 0 12px #1f1f21,
526
529
  0 0 0 13px #2f2f31,
527
- 0 20px 50px rgba(0,0,0,0.6);
530
+ ${dropShadow};
528
531
  overflow: hidden;
529
- transform: scale(0.88);
532
+ transform: scale(${frameScale});
530
533
  transform-origin: center;
531
534
  flex-shrink: 0;
532
535
  }
@@ -541,7 +544,7 @@ async function applyMockupBorder(browser, imageBuffer, deviceName, size, platfor
541
544
  box-shadow:
542
545
  0 0 0 14px #1f1f21,
543
546
  0 0 0 15px #2f2f31,
544
- 0 20px 50px rgba(0,0,0,0.6);
547
+ ${dropShadow};
545
548
  }
546
549
  .device-frame.ios-tablet .screenshot-img {
547
550
  border-radius: 20px;
@@ -551,7 +554,7 @@ async function applyMockupBorder(browser, imageBuffer, deviceName, size, platfor
551
554
  box-shadow:
552
555
  0 0 0 10px #2a2a2c,
553
556
  0 0 0 11px #3a3a3c,
554
- 0 20px 50px rgba(0,0,0,0.6);
557
+ ${androidDropShadow};
555
558
  }
556
559
  .device-frame.android-phone .screenshot-img {
557
560
  border-radius: 30px;
@@ -560,7 +563,7 @@ async function applyMockupBorder(browser, imageBuffer, deviceName, size, platfor
560
563
  border-radius: 24px;
561
564
  box-shadow:
562
565
  0 0 0 14px #2a2a2c,
563
- 0 20px 50px rgba(0,0,0,0.6);
566
+ ${tabletDropShadow};
564
567
  }
565
568
  .device-frame.android-tablet .screenshot-img {
566
569
  border-radius: 12px;
@@ -696,7 +699,7 @@ async function applyMockupBorder(browser, imageBuffer, deviceName, size, platfor
696
699
  return buffer;
697
700
  }
698
701
 
699
- async function captureScreenshots(url, paths, outputDir, platform, crawl, detectPages, email, password, loginPath, addHtml, mockup) {
702
+ async function captureScreenshots(url, paths, outputDir, platform, crawl, detectPages, email, password, loginPath, addHtml, mockup, shadow = true) {
700
703
  if (!url.startsWith('http://') && !url.startsWith('https://')) {
701
704
  url = 'http://' + url;
702
705
  }
@@ -823,7 +826,7 @@ async function captureScreenshots(url, paths, outputDir, platform, crawl, detect
823
826
  });
824
827
 
825
828
  const raw = await page.screenshot({ fullPage: false });
826
- const framed = await applyMockupBorder(browser, raw, deviceName, size, plat, isDarkTheme);
829
+ const framed = await applyMockupBorder(browser, raw, deviceName, size, plat, isDarkTheme, shadow);
827
830
  fs.writeFileSync(outputPath, framed);
828
831
  } else {
829
832
  await page.screenshot({ path: outputPath, fullPage: false });
@@ -1011,6 +1014,7 @@ program
1011
1014
  .option('--login-path <path>', 'Path to the login page', '/login.html')
1012
1015
  .option('--html', 'Auto append .html extension to detected routes', false)
1013
1016
  .option('-m, --mockup', 'Wrap screenshots in a beautiful iPhone/Android device mockup frame', false)
1017
+ .option('--no-shadow', 'Disable mockup device shadow and stretch border to edges')
1014
1018
  .action((options) => {
1015
1019
  let pathList = [];
1016
1020
  if (options.paths) {
@@ -1034,7 +1038,8 @@ program
1034
1038
  options.password,
1035
1039
  options.loginPath,
1036
1040
  options.html,
1037
- options.mockup
1041
+ options.mockup,
1042
+ options.shadow
1038
1043
  ).catch(err => {
1039
1044
  console.error(pc.red(`An unexpected error occurred: ${err.message}`));
1040
1045
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobile-snap",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Automate pixel-precise App Store & Google Play screenshots from a local web server",
5
5
  "type": "module",
6
6
  "main": "bin/cli.js",