| 
						
						
						
					 | 
				
				 | 
				
					@ -1,9 +1,9 @@ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const fs = require('fs'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const path = require('path'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    console.log('Starting electron build process...'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					console.log('Starting electron build process...'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    // Copy web files
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// Define paths
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const webDistPath = path.join(__dirname, '..', 'dist'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const electronDistPath = path.join(__dirname, '..', 'dist-electron'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const wwwPath = path.join(electronDistPath, 'www'); | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -16,20 +16,94 @@ if (!fs.existsSync(wwwPath)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// Copy web files to www directory
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					fs.cpSync(webDistPath, wwwPath, { recursive: true }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// Fix asset paths in index.html
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// Remove service worker files
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const swFilesToRemove = [ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  'sw.js', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  'sw.js.map', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  'workbox-*.js', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  'workbox-*.js.map', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  'registerSW.js', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  'manifest.webmanifest', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  '**/workbox-*.js', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  '**/workbox-*.js.map', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  '**/sw.js', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  '**/sw.js.map', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  '**/registerSW.js', | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  '**/manifest.webmanifest' | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					console.log('Removing service worker files...'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					swFilesToRemove.forEach(pattern => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  const files = fs.readdirSync(wwwPath).filter(file =>  | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    file.match(new RegExp(pattern.replace(/\*/g, '.*'))) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  ); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  files.forEach(file => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const filePath = path.join(wwwPath, file); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    console.log(`Removing ${filePath}`); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      fs.unlinkSync(filePath); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } catch (err) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      console.warn(`Could not remove ${filePath}:`, err.message); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					}); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// Also check and remove from assets directory
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const assetsPath = path.join(wwwPath, 'assets'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					if (fs.existsSync(assetsPath)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  swFilesToRemove.forEach(pattern => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const files = fs.readdirSync(assetsPath).filter(file =>  | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      file.match(new RegExp(pattern.replace(/\*/g, '.*'))) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    ); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    files.forEach(file => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      const filePath = path.join(assetsPath, file); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      console.log(`Removing ${filePath}`); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        fs.unlinkSync(filePath); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      } catch (err) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        console.warn(`Could not remove ${filePath}:`, err.message); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// Modify index.html to remove service worker registration
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const indexPath = path.join(wwwPath, 'index.html'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					let indexContent = fs.readFileSync(indexPath, 'utf8'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					if (fs.existsSync(indexPath)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  console.log('Modifying index.html to remove service worker registration...'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  let indexContent = fs.readFileSync(indexPath, 'utf8'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					   | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  // Remove service worker registration script
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  indexContent = indexContent | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    .replace(/<script[^>]*id="vite-plugin-pwa:register-sw"[^>]*><\/script>/g, '') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    .replace(/<script[^>]*registerServiceWorker[^>]*><\/script>/g, '') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    .replace(/<link[^>]*rel="manifest"[^>]*>/g, '') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    .replace(/<link[^>]*rel="serviceworker"[^>]*>/g, '') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    .replace(/navigator\.serviceWorker\.register\([^)]*\)/g, '') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    .replace(/if\s*\(\s*['"]serviceWorker['"]\s*in\s*navigator\s*\)\s*{[^}]*}/g, ''); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					   | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  fs.writeFileSync(indexPath, indexContent); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  console.log('Successfully modified index.html'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// Fix asset paths
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    indexContent = indexContent | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					console.log('Fixing asset paths in index.html...'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					let indexContent = fs.readFileSync(indexPath, 'utf8'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					indexContent = indexContent | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  .replace(/\/assets\//g, './assets/') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  .replace(/href="\//g, 'href="./') | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  .replace(/src="\//g, 'src="./'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					fs.writeFileSync(indexPath, indexContent); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// Verify no service worker references remain
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					const finalContent = fs.readFileSync(indexPath, 'utf8'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					if (finalContent.includes('serviceWorker') || finalContent.includes('workbox')) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  console.warn('Warning: Service worker references may still exist in index.html'); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					// Check for remaining /assets/ paths
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    console.log('After path fixing, checking for remaining /assets/ paths:', indexContent.includes('/assets/')); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					console.log('After path fixing, checking for remaining /assets/ paths:', indexContent.includes('/assets/')); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					console.log('Sample of fixed content:', indexContent.substring(0, 500)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					console.log('Copied and fixed web files in:', wwwPath); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |