(menuData, x, y, options = {})
| 15766 | elements.forEach(element => { |
| 15767 | if (element) container.appendChild(element); |
| 15768 | }); |
| 15769 | await new Promise(resolve => setTimeout(resolve, 50)); |
| 15770 | } |
| 15771 | |
| 15772 | // Just update the count, don't touch progress bars |
| 15773 | await updateModelCounts(files.length); |
| 15774 | } |
| 15775 | |
| 15776 | // Add a separate function for generating thumbnails |
| 15777 | async function generateThumbnail(file) { |
| 15778 | try { |
| 15779 | const filePath = (typeof file === 'string') ? file : file.filePath; |
| 15780 | if (!filePath) { |
| 15781 | throw new Error("generateThumbnail: filePath is undefined"); |
| 15782 | } |
| 15783 | |
| 15784 | // 1. Try to get embedded thumbnail for 3MF |
| 15785 | if (filePath.toLowerCase().endsWith('.3mf')) { |
| 15786 | console.log(`[DEBUG] generateThumbnail: Attempting to extract embedded thumbnail for ${filePath}`); |
| 15787 | try { |
| 15788 | const images = await extract3MFThumbnail(filePath); |
| 15789 | if (images && images.length > 0) { |
| 15790 | const validImages = images.filter( |
| 15791 | (im) => typeof im === 'string' && im.startsWith('data:image') |
| 15792 | ); |
| 15793 | if (validImages.length > 0) { |
| 15794 | const firstImage = validImages[0]; |
| 15795 | console.log( |
| 15796 | `[DEBUG] generateThumbnail: SUCCESS - Saving ${validImages.length} embedded image(s) for ${filePath}` |
| 15797 | ); |
| 15798 | await window.electron.addMultipleThumbnails(filePath, validImages); |
| 15799 | |
| 15800 | try { |
| 15801 | await window.electron.calculateFileHash(filePath); |
| 15802 | } catch (hashError) { |
| 15803 | console.error(`Error calculating hash for ${filePath}:`, hashError); |
| 15804 | } |
| 15805 | |
| 15806 | return firstImage; |
| 15807 | } else { |
| 15808 | console.log(`[DEBUG] generateThumbnail: Invalid image format for ${filePath}`); |
| 15809 | } |
| 15810 | } else { |
| 15811 | console.log(`[DEBUG] generateThumbnail: No embedded images found for ${filePath}`); |
| 15812 | } |
| 15813 | } catch (e) { |
| 15814 | console.error('Error extracting 3MF thumbnail:', e); |
| 15815 | } |
| 15816 | } |
| 15817 | |
| 15818 | // Use the exposed function to get file stats |
| 15819 | const stats = await window.electron.getFileStats(filePath); |
| 15820 | const fileSizeInMB = stats.size / (1024 * 1024); |
| 15821 | |
| 15822 | if (fileSizeInMB > MAX_FILE_SIZE_MB) { |
| 15823 | debugLog(`Skipping thumbnail generation for ${filePath} (${fileSizeInMB.toFixed(2)}MB > ${MAX_FILE_SIZE_MB}MB)`); |
| 15824 | console.warn(`Skipping thumbnail generation for ${filePath} (${fileSizeInMB.toFixed(2)}MB > ${MAX_FILE_SIZE_MB}MB)`); |
| 15825 | await window.electron.saveThumbnail(filePath, '3d.png'); |
no outgoing calls
no test coverage detected