chore: re-organize structure a bit

This commit is contained in:
Maya 2026-03-09 19:41:10 +03:00
parent 9b0470e4de
commit 95210e84eb
No known key found for this signature in database
11 changed files with 32 additions and 23 deletions

View File

@ -8,7 +8,7 @@
import { onMount } from "svelte"; import { onMount } from "svelte";
import { quintOut } from "svelte/easing"; import { quintOut } from "svelte/easing";
import { VertFile } from "$lib/types"; import { VertFile } from "$lib/types";
import SettingsModal from "./SettingsModal.svelte"; import SettingsModal from "./popups/SettingsModal.svelte";
import { log } from "$lib/util/logger"; import { log } from "$lib/util/logger";
type Props = { type Props = {
@ -279,7 +279,7 @@
}); });
const ext = filename.split(".").pop() ?? ""; const ext = filename.split(".").pop() ?? "";
return new VertFile(f, ext); return new VertFile(f, ext);
} catch (err) { } catch {
return null; return null;
} }
}) })

View File

@ -1,8 +1,8 @@
<script lang="ts"> <script lang="ts">
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { SearchIcon } from "lucide-svelte"; import { SearchIcon } from "lucide-svelte";
import Dropdown from "./Dropdown.svelte"; import Dropdown from "../Dropdown.svelte";
import FancyInput from "./FancyInput.svelte"; import FancyInput from "../FancyInput.svelte";
import Modal from "./Modal.svelte"; import Modal from "./Modal.svelte";
import { m } from "$lib/paraglide/messages"; import { m } from "$lib/paraglide/messages";
import type { VertFile } from "$lib/types"; import type { VertFile } from "$lib/types";

View File

@ -31,8 +31,9 @@
submitting = true; submitting = true;
try { try {
await submitInner(); await submitInner();
} catch (e) {} } finally {
submitting = false; submitting = false;
}
}; };
const submitInner = async () => { const submitInner = async () => {

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { duration, fade } from "$lib/util/animation"; import { duration, fade } from "$lib/util/animation";
import { quintOut } from "svelte/easing"; import { quintOut } from "svelte/easing";
import Dialog from "../functional/Dialog.svelte"; import Dialog from "../functional/popups/Dialog.svelte";
import { import {
type Dialog as DialogType, type Dialog as DialogType,
dialogs, dialogs,

View File

@ -17,12 +17,12 @@ import {
WEBM, WEBM,
WebMOutputFormat, WebMOutputFormat,
} from "mediabunny"; } from "mediabunny";
import { registerMp3Encoder } from "@mediabunny/mp3-encoder";
import { registerAc3Decoder, registerAc3Encoder } from "@mediabunny/ac3"; import { registerAc3Decoder, registerAc3Encoder } from "@mediabunny/ac3";
import { registerMp3Encoder } from "@mediabunny/mp3-encoder";
import { registerFlacEncoder } from "@mediabunny/flac-encoder";
import { Converter, FormatInfo, type WorkerStatus } from "./converter.svelte"; import { Converter, FormatInfo, type WorkerStatus } from "./converter.svelte";
import { ToastManager } from "$lib/util/toast.svelte"; import { ToastManager } from "$lib/util/toast.svelte";
import { error, log } from "$lib/util/logger"; import { error, log } from "$lib/util/logger";
import { registerFlacEncoder } from "@mediabunny/flac-encoder";
import { m } from "$lib/paraglide/messages"; import { m } from "$lib/paraglide/messages";
import type { import type {
SettingDefinition, SettingDefinition,
@ -32,6 +32,7 @@ import { CONVERSION_BITRATES, SAMPLE_RATES } from "./ffmpeg.svelte";
// codec compatibility object, based on docs // codec compatibility object, based on docs
// https://mediabunny.dev/guide/supported-formats-and-codecs#compatibility-table // https://mediabunny.dev/guide/supported-formats-and-codecs#compatibility-table
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const codecCompatibility = { const codecCompatibility = {
video: { video: {
mp4: ["avc", "hevc", "vp8", "vp9", "av1"], mp4: ["avc", "hevc", "vp8", "vp9", "av1"],
@ -200,7 +201,7 @@ export class MediabunnyConverter extends Converter {
super(); super();
// additional mediabunny coders // additional mediabunny coders
// currently both official ones -- maybe add our own in the future // currently the official ones -- maybe add our own in the future
this.initializeCodecs(); this.initializeCodecs();
} }

View File

@ -1,4 +1,4 @@
import VertdErrorComponent from "$lib/components/functional/VertdError.svelte"; import VertdErrorComponent from "$lib/components/functional/popups/VertdError.svelte";
import { error, log } from "$lib/util/logger"; import { error, log } from "$lib/util/logger";
import { m } from "$lib/paraglide/messages"; import { m } from "$lib/paraglide/messages";
import { Settings } from "$lib/sections/settings/index.svelte"; import { Settings } from "$lib/sections/settings/index.svelte";

View File

@ -142,14 +142,27 @@ export class VertFile {
const customConverter = this.converters.find( const customConverter = this.converters.find(
(c) => c.name === this.conversionSettings.converter, (c) => c.name === this.conversionSettings.converter,
); );
const converter = let converter = customConverter;
customConverter ||
(this.isZip() // TODO: not sure if the zip needs to be changed now if (!converter) {
? this.converters[0] const compatibleConverters = this.findConverters([
: this.findConverters([this.from, this.to])[0]); this.from,
log(["file", "convert"], `using converter: ${converter.name}`); this.to,
]);
if (compatibleConverters.length) {
converter = compatibleConverters[0];
log(["file", "convert"], `found compatible converter: ${converter.name}`);
} else {
log(["file", "convert"], `no compatible converter found for ${this.from} to ${this.to}`);
// TODO: handle zip converter fallback explicitly if needed
// TODO: provide a clearer error path for unsupported from/to pairs
}
} else {
log(["file", "convert"], `using custom converter from settings: ${converter.name}`);
}
if (!converter) throw new Error("No converter found"); if (!converter) throw new Error("No converter found");
log(["file", "convert"], `using converter: ${converter.name}`);
this.result = null; this.result = null;
this.progress = 0; this.progress = 0;

View File

@ -64,12 +64,6 @@
const converter = getCurrentConverter(file); const converter = getCurrentConverter(file);
if (!converter) return; if (!converter) return;
// Initialize converter in settings if not already set
if (!file.conversionSettings.converter)
file.conversionSettings.converter = converter.name;
let category: string | undefined; let category: string | undefined;
const isImage = converterCategories.image.includes(converter.name); const isImage = converterCategories.image.includes(converter.name);
const isAudio = converterCategories.audio.includes(converter.name); const isAudio = converterCategories.audio.includes(converter.name);