( manifestUrl: string, deps: FetchUrlManifestDeps )
| 588 | } |
| 589 | |
| 590 | export async function fetchUrlManifest( |
| 591 | manifestUrl: string, |
| 592 | deps: FetchUrlManifestDeps |
| 593 | ): Promise<ColmapManifest> { |
| 594 | const fetchImpl = deps.fetchImpl ?? defaultFetchUrl; |
| 595 | deps.setUrlProgress({ percent: 2, message: 'Fetching manifest...' }); |
| 596 | |
| 597 | const response = await fetchImpl(manifestUrl); |
| 598 | |
| 599 | if (!response.ok) { |
| 600 | const errorType: UrlLoadErrorType = response.status === 404 ? 'not_found' : 'network'; |
| 601 | const error: UrlLoadError = { |
| 602 | type: errorType, |
| 603 | message: `Failed to fetch manifest (${response.status})`, |
| 604 | details: response.statusText, |
| 605 | failedFile: manifestUrl, |
| 606 | }; |
| 607 | throw error; |
| 608 | } |
| 609 | |
| 610 | const data = await response.json(); |
| 611 | const result = validateColmapManifest(data); |
| 612 | if (!result.success) { |
| 613 | const error: UrlLoadError = { |
| 614 | type: 'invalid_manifest', |
| 615 | message: 'Invalid manifest format', |
| 616 | details: result.details, |
| 617 | failedFile: manifestUrl, |
| 618 | }; |
| 619 | throw error; |
| 620 | } |
| 621 | |
| 622 | deps.setUrlProgress({ percent: 5, message: 'Manifest loaded' }); |
| 623 | return result.manifest; |
| 624 | } |
| 625 | |
| 626 | export async function fetchManifestFile( |
| 627 | baseUrl: string, |
no test coverage detected