Skip to content

armgit / VERT

Public Imported from GitHub
0

The next-generation file converter. Open source, fully local* and free forever.

Merge branch 'merged-video-audio-and-dropdowns' into feat/merge-big-stuff

Mayad54343300736
diff --cc src/lib/components/functional/FormatDropdown.svelte
index da14d79,4937645..38bad18
--- a/src/lib/components/functional/FormatDropdown.svelte
+++ b/src/lib/components/functional/FormatDropdown.svelte
@@@ -107,24 -164,58 +166,56 @@@
};
const handleSearch = (event: Event) => {
- searchQuery = (event.target as HTMLInputElement).value;
+ const query = (event.target as HTMLInputElement).value;
+ searchQuery = query;
+
+ // find which categories have matching formats & switch
+ if (query) {
+ const queryLower = query.toLowerCase();
+ const categoriesWithMatches = availableCategories.filter((cat) =>
+ categories[cat].formats.some((format) =>
+ format.toLowerCase().includes(queryLower),
+ ),
+ );
+
+ if (categoriesWithMatches.length > 0) {
+ const currentHasMatches =
+ currentCategory &&
+ categories[currentCategory].formats.some((format) =>
+ format.toLowerCase().includes(queryLower),
+ );
+
+ if (!currentHasMatches) {
+ currentCategory = categoriesWithMatches[0];
+ }
+ }
+ }
+ };
+
- const clickDropdown = () => {
- open = !open;
- if (open) {
- setTimeout(() => {
- if (dropdownMenu) {
- const searchInput = dropdownMenu.querySelector(
- "#format-search",
- ) as HTMLInputElement;
- if (searchInput) {
- searchInput.focus();
- searchInput.select();
- }
- }
- }, 0); // let dropdown open first
- }
- };
-
+ const onEnter = (event: KeyboardEvent) => {
+ if (event.key === "Enter") {
+ event.preventDefault();
+ if (filteredData.formats.length > 0) {
+ selectOption(filteredData.formats[0]);
+ }
+ }
};
+ const clickDropdown = () => {
+ open = !open;
+ if (!open) return;
+ setTimeout(() => {
+ if (!dropdownMenu) return;
+ const searchInput = dropdownMenu.querySelector(
+ "#format-search",
+ ) as HTMLInputElement;
+ if (searchInput) {
+ searchInput.focus();
+ searchInput.select();
+ }
+ }, 0); // let dropdown open first
+ };
+
onMount(() => {
const handleClickOutside = (e: MouseEvent) => {
if (dropdown && !dropdown.contains(e.target as Node)) {
@@@ -219,7 -307,7 +309,8 @@@
class="flex-grow w-full !pl-11 !pr-3 rounded-lg bg-panel text-foreground"
bind:value={searchQuery}
oninput={handleSearch}
+ onkeydown={onEnter}
+ onfocus={() => {}}
id="format-search"
autocomplete="off"
/>
@@@ -245,21 -343,25 +346,26 @@@
</button>
{/each}
</div>
-
<!-- available formats -->
<div class="max-h-80 overflow-y-auto grid grid-cols-3 gap-2 p-2">
- {#each filteredData.formats as format}
- <button
- class="w-full p-2 text-center rounded-xl
- {format === selected
- ? 'bg-accent text-black'
- : 'hover:bg-panel'}
+ {#if filteredData.formats.length > 0}
+ {#each filteredData.formats as format}
+ <button
+ class="w-full p-2 text-center rounded-xl
- {format === selected ? 'bg-accent text-black' : 'hover:bg-panel'}"
++ {format === selected ? 'bg-accent text-black' : 'hover:bg-panel'}
+ {format === from ? 'bg-separator' : ''}"
- onclick={() => selectOption(format)}
- >
- {format}
- </button>
- {/each}
+ onclick={() => selectOption(format)}
+ >
+ {format}
+ </button>
+ {/each}
+ {:else}
+ <div class="col-span-3 text-center p-4 text-muted">
+ {searchQuery
+ ? "No formats match your search"
+ : "No formats available"}
+ </div>
+ {/if}
</div>
</div>
{/if}
diff --cc src/lib/converters/ffmpeg.svelte.ts
index f7e9a61,c53cd40..cf943c5
--- a/src/lib/converters/ffmpeg.svelte.ts
+++ b/src/lib/converters/ffmpeg.svelte.ts
@@@ -4,8 -4,9 +4,10 @@@ import { FFmpeg } from "@ffmpeg/ffmpeg"
import { browser } from "$app/environment";
import { error, log } from "$lib/logger";
import { addToast } from "$lib/store/ToastProvider";
+import { m } from "$lib/paraglide/messages";
+ const videoFormats = [".mkv", ".mp4", ".avi", ".mov", ".webm", ".ts", ".mts", ".m2ts", ".wmv"];
+
export class FFmpegConverter extends Converter {
private ffmpeg: FFmpeg = null!;
public name = "ffmpeg";
@@@ -23,9 -22,9 +25,10 @@@
new FormatInfo("wma", true, true),
new FormatInfo("amr", true, true),
new FormatInfo("ac3", true, true),
- new FormatInfo("alac", true, false),
+ new FormatInfo("alac", true, true),
new FormatInfo("aiff", true, true),
+ new FormatInfo("aif", true, true),
+ ...videoFormats.map((f) => new FormatInfo(f, true, true, false)),
];
public readonly reportsProgress = true;
diff --cc src/lib/converters/index.ts
index 83c5fe8,a83d892..6b9433d
--- a/src/lib/converters/index.ts
+++ b/src/lib/converters/index.ts
@@@ -34,12 -36,27 +36,27 @@@ categories.audio.formats
categories.video.formats =
converters
.find((c) => c.name === "vertd")
- ?.formatStrings((f) => f.toSupported) || [];
+ ?.supportedFormats.filter((f) => f.toSupported && f.isNative)
+ .map((f) => f.name) || [];
categories.image.formats =
converters
- .find((c) => c.name === "libvips")
- ?.supportedFormats.filter((f) => f.toSupported && f.isNative)
- .map((f) => f.name) || [];
+ .find((c) => c.name === "imagemagick")
+ ?.formatStrings((f) => f.toSupported) || [];
categories.docs.formats =
converters
.find((c) => c.name === "pandoc")
- ?.formatStrings((f) => f.toSupported) || [];
+ ?.supportedFormats.filter((f) => f.toSupported && f.isNative)
+ .map((f) => f.name) || [];
+
++
+ export const byNative = (format: string) => {
+ return (a: Converter, b: Converter) => {
+ const aFormat = a.supportedFormats.find((f) => f.name === format);
+ const bFormat = b.supportedFormats.find((f) => f.name === format);
+
+ if (aFormat && bFormat) {
+ return aFormat.isNative ? -1 : 1;
+ }
+ return 0;
+ };
+ };
diff --cc src/lib/types/file.svelte.ts
index 345d289,5bd9e62..7983e94
--- a/src/lib/types/file.svelte.ts
+++ b/src/lib/types/file.svelte.ts
@@@ -1,7 -1,6 +1,7 @@@
- import { converters } from "$lib/converters";
+ import { byNative, converters } from "$lib/converters";
import type { Converter } from "$lib/converters/converter.svelte";
import { error } from "$lib/logger";
+import { m } from "$lib/paraglide/messages";
import { addToast } from "$lib/store/ToastProvider";
export class VertFile {
diff --cc src/routes/convert/+page.svelte
index f4b8a79,747b373..e5d0101
--- a/src/routes/convert/+page.svelte
+++ b/src/routes/convert/+page.svelte
@@@ -108,11 -125,13 +117,12 @@@
.includes(file.from)}
{@const isVideo = converters
.find((c) => c.name === "vertd")
- ?.formatStrings((f) => f.fromSupported)
+ ?.supportedFormats.filter((f) => f.isNative)
+ .map((f) => f.name)
.includes(file.from)}
{@const isImage = converters
- .find((c) => c.name === "libvips")
- ?.supportedFormats.filter((f) => f.isNative)
- .map((f) => f.name)
+ .find((c) => c.name === "imagemagick")
+ ?.formatStrings((f) => f.fromSupported)
.includes(file.from)}
{@const isDocument = converters
.find((c) => c.name === "pandoc")