diff --git a/_headers b/_headers new file mode 100644 index 0000000..2568767 --- /dev/null +++ b/_headers @@ -0,0 +1,4 @@ +# For libvips/wasm-vips converter (images) +/* + Cross-Origin-Embedder-Policy: require-corp + Cross-Origin-Opener-Policy: same-origin \ No newline at end of file diff --git a/bun.lock b/bun.lock index c228172..52691d6 100644 --- a/bun.lock +++ b/bun.lock @@ -3363,4 +3363,4 @@ "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", ], }, -} +} \ No newline at end of file diff --git a/package.json b/package.json index 56999cf..6a5d424 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "clsx": "^2.1.1", "jsmediatags": "^3.9.7", "lucide-svelte": "^0.475.0", + "vite-plugin-static-copy": "^2.2.0", "wasm-vips": "^0.0.11" }, "patchedDependencies": { diff --git a/src/app.html b/src/app.html index 5d8cb17..be3d242 100644 --- a/src/app.html +++ b/src/app.html @@ -2,8 +2,15 @@
- + + + + + + + + %sveltekit.head% diff --git a/src/lib/converters/vips.svelte.ts b/src/lib/converters/vips.svelte.ts index 9f9a5ac..33fa389 100644 --- a/src/lib/converters/vips.svelte.ts +++ b/src/lib/converters/vips.svelte.ts @@ -33,6 +33,9 @@ export class VipsConverter extends Converter { ".tif", ".tiff", ".jfif", + //".heif", HEIF files that are encoded like HEIC files (and HEIC files in general) aren't supported due to https://github.com/kleisauke/wasm-vips/issues/3 + ".avif", + ".jxl", ]; public readonly reportsProgress = false; @@ -51,8 +54,6 @@ export class VipsConverter extends Converter { error(["converters", this.name], `error in worker: ${message.error}`); addToast("error", `Error in VIPS worker, some features may not work.`); throw new Error(message.error); - } else { - error(["converters", this.name], `unknown message type: ${message.type}`); } }; } diff --git a/src/lib/store/index.svelte.ts b/src/lib/store/index.svelte.ts index 3011321..bda2065 100644 --- a/src/lib/store/index.svelte.ts +++ b/src/lib/store/index.svelte.ts @@ -173,7 +173,7 @@ class Files { const file = files.files[i]; const result = file.result; if (!result) { - console.error("No result found"); + error(["files"], "No result found"); continue; } dlFiles.push({ @@ -215,6 +215,16 @@ export function setTheme(themeTo: "light" | "dark") { }); log(["theme"], `set to ${themeTo}`); theme.set(themeTo); + + // Lock dark reader if it's set to dark mode + if (themeTo === "dark") { + const lock = document.createElement('meta'); + lock.name = 'darkreader-lock'; + document.head.appendChild(lock); + } else { + const lock = document.querySelector('meta[name="darkreader-lock"]'); + if (lock) lock.remove(); + } } export function setEffects(effectsEnabled: boolean) { diff --git a/src/lib/types/file.svelte.ts b/src/lib/types/file.svelte.ts index 28e1068..6e2d03c 100644 --- a/src/lib/types/file.svelte.ts +++ b/src/lib/types/file.svelte.ts @@ -1,4 +1,5 @@ import type { Converter } from "$lib/converters/converter.svelte"; +import { error } from "$lib/logger"; import { addToast } from "$lib/store/ToastProvider"; export class VertFile { @@ -46,7 +47,7 @@ export class VertFile { res = await this.converter.convert(this, this.to); this.result = res; } catch (err) { - console.error(err); + error(["files"], err); addToast("error", `Error converting file: ${this.file.name}`); this.result = null; } diff --git a/src/lib/workers/vips.ts b/src/lib/workers/vips.ts index 058cb67..cde18c6 100644 --- a/src/lib/workers/vips.ts +++ b/src/lib/workers/vips.ts @@ -1,10 +1,7 @@ import { type WorkerMessage, type OmitBetterStrict } from "$lib/types"; import Vips from "wasm-vips"; -const vipsPromise = Vips({ - // see https://github.com/kleisauke/wasm-vips/issues/85 - dynamicLibraries: [], -}); +const vipsPromise = Vips({}); vipsPromise .then(() => { @@ -23,6 +20,7 @@ const handleMessage = async ( if (!message.to.startsWith(".")) message.to = `.${message.to}`; const image = vips.Image.newFromBuffer( await message.input.file.arrayBuffer(), + `${message.to === ".gif" || message.to === ".webp" ? "[n=-1]" : ""}`, ); const output = image.writeToBuffer(message.to); image.delete(); diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index d9fdda6..67d9aa9 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -64,7 +64,7 @@ /> @@ -83,15 +83,15 @@ /> + {#if PUB_PLAUSIBLE_URL}{/if} - diff --git a/src/routes/convert/+page.svelte b/src/routes/convert/+page.svelte index 345aa93..c27ee0c 100644 --- a/src/routes/convert/+page.svelte +++ b/src/routes/convert/+page.svelte @@ -4,7 +4,6 @@ import Uploader from "$lib/components/functional/Uploader.svelte"; import Panel from "$lib/components/visual/Panel.svelte"; import ProgressBar from "$lib/components/visual/ProgressBar.svelte"; - import { converters } from "$lib/converters"; import { effects, files, @@ -12,6 +11,7 @@ showGradient, vertdLoaded, } from "$lib/store/index.svelte"; + import { addToast } from "$lib/store/ToastProvider"; import { VertFile } from "$lib/types"; import { AudioLines, @@ -26,6 +26,18 @@ XIcon, } from "lucide-svelte"; + const handleSelect = (option: string, file: VertFile) => { + file.result = null; + switch (option) { + case ".webp": + case ".gif": + addToast( + "warning", + `Converting this file to "${option}" may take some time if animated.`, + ); + } + }; + $effect(() => { // Set gradient color depending on the file types // TODO: if more file types added, add a "fileType" property to the file object @@ -173,7 +185,7 @@