diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 4d1d431..001bc95 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -96,6 +96,11 @@ } async function startZipExtraction () { + const streamCount = files.reduce((sum, file) => { + return sum + (fileResults.get(file)?.parsed?.streams?.filter(e => e[selectedSymbol])?.length || 0) + }, 0) + if (streamCount === 1) return startSingleStreamDownload() + const {createZipWriter} = await import('/~/utils/zip-stream') const {default: streamSaver} = await import('streamsaver') @@ -108,9 +113,7 @@ } }) - const namePrefix = files.length === 1 - ? files[0].name - : new Date().toISOString().slice(0, 19).replace('T', ' ').replace(/[^\d ]+/g, '-') + const namePrefix = new Date().toISOString().slice(0, 19).replace('T', ' ').replace(/[^\d ]+/g, '-') const zipName = `${namePrefix}-extraction.zip` const fileStream = streamSaver.createWriteStream(zipName) @@ -147,6 +150,22 @@ } }) } + + async function startSingleStreamDownload () { + const {default: streamSaver} = await import('streamsaver') + let writer + + return handleExtraction({ + enqueue (name, contents) { + const fileStream = streamSaver.createWriteStream(name) + writer = fileStream.getWriter() + writer.write(contents) + }, + close () { + writer.close() + } + }) + } async function handleExtraction (controller) { pendingFiles = files.length diff --git a/src/style.css b/src/style.css index 51f4dcd..ac65011 100644 --- a/src/style.css +++ b/src/style.css @@ -1,4 +1,4 @@ -.large-drop { +.large-drop .bx--file__drop-container { font-size: 2em; } .large-drop .bx--file-browse-btn, @@ -6,7 +6,7 @@ max-width: 100%; } .large-drop .bx--file__drop-container { - height: 3em; + height: 4em; } html[theme="g90"] .large-drop { --cds-link-01: #a6c8ff; diff --git a/svelte.config.js b/svelte.config.js index 2f7c1d9..17e3198 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,5 +1,5 @@ import adapter from '@sveltejs/adapter-static' -import { vitePreprocess } from '@sveltejs/kit/vite' +import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' const dev = process.argv.includes('dev')