@@ -7,7 +7,7 @@ const __filename = fileURLToPath(import.meta.url);
77const __dirname = path . dirname ( __filename ) ;
88
99const OUTPUT_DIR = path . resolve ( __dirname , '../public/screenshots' ) ;
10- const URL = 'http://localhost:3000 ' ; // Make sure the app is running!
10+ const URL = 'http://localhost:3001 ' ; // Make sure the app is running!
1111
1212if ( ! fs . existsSync ( OUTPUT_DIR ) ) {
1313 fs . mkdirSync ( OUTPUT_DIR , { recursive : true } ) ;
@@ -17,7 +17,12 @@ async function capture() {
1717 console . log ( '🚀 Launching browser for screenshot capture...' ) ;
1818 const browser = await puppeteer . launch ( {
1919 headless : "new" ,
20- args : [ '--no-sandbox' , '--disable-setuid-sandbox' ] ,
20+ args : [
21+ '--no-sandbox' ,
22+ '--disable-setuid-sandbox' ,
23+ '--disable-web-security' ,
24+ '--window-size=1920,1080'
25+ ] ,
2126 defaultViewport : null ,
2227 } ) ;
2328
@@ -29,15 +34,23 @@ async function capture() {
2934 try {
3035 console . log ( `🌐 Navigating to ${ URL } ...` ) ;
3136 // Wait until network is idle to ensure assets are loaded
32- await page . goto ( URL , { waitUntil : 'networkidle0' , timeout : 60000 } ) ;
37+ const response = await page . goto ( URL , { waitUntil : 'networkidle0' , timeout : 90000 } ) ;
38+
39+ if ( response ?. status ( ) !== 200 ) {
40+ console . warn ( `⚠️ Page loaded with status ${ response ?. status ( ) } ` ) ;
41+ }
3342
3443 // --- 1. Desktop Capture ---
3544 console . log ( '📸 Capturing Desktop View...' ) ;
3645 await page . setViewport ( { width : 1920 , height : 1080 } ) ;
3746
38- // Wait for Globe or critical UI to be visible
39- // We'll wait a bit extra for Cesium to render tiles
40- await new Promise ( r => setTimeout ( r , 10000 ) ) ;
47+ // Wait for Cesium Canvas explicitly
48+ await page . waitForSelector ( 'canvas' , { timeout : 30000 } ) ;
49+ console . log ( ' - Canvas detected' ) ;
50+
51+ // Wait for Fly-in Animation (Start + 4s duration) + Tile Loading
52+ console . log ( ' - Waiting for cinematic fly-in & tiles...' ) ;
53+ await new Promise ( r => setTimeout ( r , 12000 ) ) ;
4154
4255 await page . screenshot ( {
4356 path : path . join ( OUTPUT_DIR , 'desktop-preview.png' ) ,
@@ -51,7 +64,12 @@ async function capture() {
5164
5265 // Reload to trigger mobile-specific logic (e.g. Globe resolution reduction)
5366 await page . reload ( { waitUntil : 'networkidle0' } ) ;
54- await new Promise ( r => setTimeout ( r , 10000 ) ) ; // Wait for render
67+
68+ await page . waitForSelector ( 'canvas' , { timeout : 30000 } ) ;
69+ console . log ( ' - Mobile Canvas detected' ) ;
70+
71+ // Wait again for mobile reload + animation
72+ await new Promise ( r => setTimeout ( r , 12000 ) ) ;
5573
5674 await page . screenshot ( {
5775 path : path . join ( OUTPUT_DIR , 'mobile-preview.png' ) ,
@@ -61,6 +79,17 @@ async function capture() {
6179
6280 } catch ( error ) {
6381 console . error ( '❌ Error capturing screenshots:' , error ) ;
82+
83+ // Take an error screenshot to see what's happening
84+ try {
85+ await page . screenshot ( {
86+ path : path . join ( OUTPUT_DIR , 'debug-error.png' ) ,
87+ fullPage : true
88+ } ) ;
89+ console . log ( '📸 Saved debug-error.png' ) ;
90+ } catch ( e ) {
91+ console . error ( 'Could not save debug screenshot' ) ;
92+ }
6493 } finally {
6594 await browser . close ( ) ;
6695 console . log ( '✨ Done.' ) ;
0 commit comments