( zipFile: File, onProgress: (progress: ZipProgress) => void )
| 246 | * Extracts COLMAP files immediately and builds an index for lazy image extraction. |
| 247 | */ |
| 248 | export async function loadZipFromFile( |
| 249 | zipFile: File, |
| 250 | onProgress: (progress: ZipProgress) => void |
| 251 | ): Promise<ZipLoadResult> { |
| 252 | // Initialize libarchive.js |
| 253 | await initializeArchive(); |
| 254 | |
| 255 | onProgress({ percent: 0, message: 'Checking archive...' }); |
| 256 | |
| 257 | // Validate size |
| 258 | const validation = validateZipFile(zipFile); |
| 259 | if (!validation.valid) { |
| 260 | throw new Error(validation.error ?? 'Invalid archive'); |
| 261 | } |
| 262 | |
| 263 | onProgress({ percent: 40, message: 'Opening archive...' }); |
| 264 | |
| 265 | // Open archive |
| 266 | const archive = await Archive.open(zipFile); |
| 267 | |
| 268 | // Process archive |
| 269 | const { colmapFiles, imageIndex, imageCount } = await processZipArchive(archive, onProgress); |
| 270 | |
| 271 | // Verify we have required COLMAP files |
| 272 | if (!hasRequiredColmapArchiveFiles(colmapFiles.keys())) { |
| 273 | throw new Error( |
| 274 | 'ZIP does not contain valid COLMAP files (cameras.bin, images.bin, points3D.bin)' |
| 275 | ); |
| 276 | } |
| 277 | |
| 278 | return { colmapFiles, imageIndex, archive, fileSize: zipFile.size, imageCount }; |
| 279 | } |
nothing calls this directly
no test coverage detected