Add support for loading files from Google Drive

#vibecoded
This commit is contained in:
Przemek Więch
2026-05-19 00:38:16 +02:00
parent 60e076fca1
commit 55a1626cf4
26 changed files with 2005 additions and 107 deletions

View File

@@ -117,6 +117,20 @@ export async function loadFile(
return {gedcom: await blob.text(), images: new Map()};
}
/** Parses the given file and prepares the TopolaData structure, revoking URLs on error. */
export async function loadAndPrepareFile(
blob: Blob,
cacheId: string,
): Promise<TopolaData> {
const {gedcom, images} = await loadFile(blob);
try {
return prepareData(gedcom, cacheId, images);
} catch (error) {
revokeObjectUrls(images);
throw error;
}
}
/** Fetches data from the given URL. Uses cors-anywhere if handleCors is true. */
export async function loadFromUrl(
url: string,
@@ -151,13 +165,7 @@ export async function loadFromUrl(
throw new Error(response.statusText);
}
const {gedcom, images} = await loadFile(await response.blob());
try {
return prepareData(gedcom, url, images);
} catch (error) {
revokeObjectUrls(images);
throw error;
}
return loadAndPrepareFile(await response.blob(), url);
}
/** Loads data from the given GEDCOM file contents. */