From b5ac70a0156856e258f25f1f2ba3eb6151191798 Mon Sep 17 00:00:00 2001 From: not-nullptr Date: Mon, 11 Nov 2024 16:33:46 +0000 Subject: [PATCH] feat: basic functionality --- src/lib/converters/converter.ts | 11 +++++ src/lib/converters/vips.ts | 15 +++++- src/routes/+page.svelte | 86 +++++++++++++++++++++++++++++++-- 3 files changed, 108 insertions(+), 4 deletions(-) diff --git a/src/lib/converters/converter.ts b/src/lib/converters/converter.ts index bb371f4..c2eda76 100644 --- a/src/lib/converters/converter.ts +++ b/src/lib/converters/converter.ts @@ -1,7 +1,18 @@ import type { IFile, OmitBetterStrict } from "$lib/types"; +/** + * Base class for all converters. + */ export class Converter { + /** + * List of supported formats. + */ public supportedFormats: string[] = []; + /** + * Convert a file to a different format. + * @param input The input file. + * @param to The format to convert to. Includes the dot. + */ public async convert( // eslint-disable-next-line @typescript-eslint/no-unused-vars input: OmitBetterStrict, diff --git a/src/lib/converters/vips.ts b/src/lib/converters/vips.ts index 9102a13..6b44ce7 100644 --- a/src/lib/converters/vips.ts +++ b/src/lib/converters/vips.ts @@ -7,7 +7,20 @@ import type { VipsWorkerMessage, OmitBetterStrict } from "$lib/types"; export class VipsConverter extends Converter { private worker: Worker = browser ? new VipsWorker() : null!; private id = 0; - public supportedFormats = [""]; + public supportedFormats = [ + ".jpg", + ".jpeg", + ".png", + ".webp", + ".tiff", + ".tif", + ".gif", + ".svg", + ".webp", + ".jfif", + ".ico", + ".bmp", + ]; constructor() { super(); diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index d9cd0e0..e595e5b 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,12 +1,92 @@ -
-
- +
+
+
+ +
+
+ {#each iterableFiles as file, i} +
+
+ {file.name} +
+
+ {#if downloadFns[i]} + + {/if} + + +
+
+ {/each} + +