Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat: add build info module with versioning and formatting functions

Tonhob06b7d1d358a
diff --git a/src/components/buttons/Switcher.svelte b/src/components/buttons/Switcher.svelte
deleted file mode 100644
index f59712a5..00000000
--- a/src/components/buttons/Switcher.svelte
+++ /dev/null
@@ -1,126 +0,0 @@
-<script lang="ts">
- import { onMount } from "svelte";
-
- type $$Slots = {
- default: {};
- };
-
- let { 'aria-label': ariaLabel } = $props();
- let container = $state<HTMLDivElement | null>(null);
- let focusedIndex = $state(0);
-
- onMount(() => {
- const buttons = container?.querySelectorAll('button[role="radio"]');
- if (buttons && buttons.length > 0) {
- const firstActive = Array.from(buttons).findIndex(
- (btn) => btn.getAttribute('aria-checked') === 'true'
- );
- focusedIndex = firstActive >= 0 ? firstActive : 0;
- }
- });
-
- function handleKeyDown(e: KeyboardEvent) {
- if (!container) return;
-
- const buttons = Array.from(
- container.querySelectorAll('button[role="radio"]')
- );
- const currentIndex = buttons.findIndex(
- (btn) => btn === document.activeElement
- );
-
- if (currentIndex === -1) return;
-
- let nextIndex = currentIndex;
-
- if (e.key === "ArrowRight" || e.key === "ArrowDown") {
- e.preventDefault();
- nextIndex = (currentIndex + 1) % buttons.length;
- } else if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
- e.preventDefault();
- nextIndex = (currentIndex - 1 + buttons.length) % buttons.length;
- } else if (e.key === "Home") {
- e.preventDefault();
- nextIndex = 0;
- } else if (e.key === "End") {
- e.preventDefault();
- nextIndex = buttons.length - 1;
- }
-
- if (nextIndex !== currentIndex) {
- (buttons[nextIndex] as HTMLButtonElement).focus();
- }
- }
-</script>
-
-<div
- bind:this={container}
- role="radiogroup"
- aria-label={ariaLabel}
- class="switcher"
- onkeydown={handleKeyDown}
->
- <slot />
-</div>
-
-<style>
- .switcher {
- display: flex;
- gap: 0;
- border-radius: var(--border-radius);
- background: var(--button);
- box-shadow: var(--button-box-shadow);
- }
-
- .switcher :global(button[role="radio"]) {
- flex: 1;
- padding: var(--padding);
- font-size: 14.5px;
- font-weight: 500;
- background: transparent;
- border: none;
- border-radius: 0;
- color: var(--button-text);
- cursor: pointer;
- text-align: center;
- position: relative;
- margin-left: -1px;
- }
-
- .switcher :global(button[role="radio"]:first-child) {
- border-top-left-radius: calc(var(--border-radius) - 2px);
- border-bottom-left-radius: calc(var(--border-radius) - 2px);
- margin-left: 0;
- }
-
- .switcher :global(button[role="radio"]:last-child) {
- border-top-right-radius: calc(var(--border-radius) - 2px);
- border-bottom-right-radius: calc(var(--border-radius) - 2px);
- }
-
- .switcher :global(button[role="radio"][aria-checked="true"]) {
- background: var(--button-elevated);
- color: var(--secondary);
- }
-
- @media (hover: hover) {
- .switcher :global(button[role="radio"]:not([aria-checked="true"]):hover) {
- background: var(--button-hover);
- }
- }
-
- .switcher :global(button[role="radio"]:active) {
- background: var(--button-press);
- }
-
- .switcher :global(button[role="radio"]:focus-visible) {
- outline: var(--focus-ring);
- outline-offset: var(--focus-ring-offset);
- }
-
- @media (prefers-reduced-motion: reduce) {
- .switcher :global(button[role="radio"]) {
- transition: none;
- }
- }
-</style>
diff --git a/src/components/download/DownloadSpeedGraph.svelte b/src/components/download/DownloadSpeedGraph.svelte
new file mode 100644
index 00000000..1b89795e
--- /dev/null
+++ b/src/components/download/DownloadSpeedGraph.svelte
@@ -0,0 +1,118 @@
+<script lang="ts">
+ import { formatSpeed, type SpeedPoint } from "$lib/stores/download-store.svelte";
+
+ interface Props {
+ points: SpeedPoint[];
+ windowMs?: number;
+ width?: number;
+ height?: number;
+ }
+
+ let {
+ points,
+ windowMs = 60_000,
+ width = 64,
+ height = 20,
+ }: Props = $props();
+
+ let endT = $derived(points.length ? points[points.length - 1].t : Date.now());
+ let startT = $derived(endT - windowMs);
+
+ let rawWindowPoints = $derived(points.filter((p) => p.t >= startT));
+
+ let windowPoints = $derived.by(() => {
+ if (rawWindowPoints.length <= 2) return rawWindowPoints;
+ const alpha = 0.35;
+ let ema = rawWindowPoints[0].bps;
+ return rawWindowPoints.map((p, idx) => {
+ if (idx === 0) return p;
+ ema = alpha * p.bps + (1 - alpha) * ema;
+ return { ...p, bps: ema };
+ });
+ });
+
+ let maxBps = $derived.by(() => {
+ let max = 0;
+ for (const p of windowPoints) if (p.bps > max) max = p.bps;
+ return Math.max(1, Math.ceil(max * 1.15));
+ });
+
+ let peakBps = $derived.by(() => {
+ let max = 0;
+ for (const p of windowPoints) if (p.bps > max) max = p.bps;
+ return max;
+ });
+
+ let dLine = $derived.by(() => {
+ if (windowPoints.length === 0) return "";
+ const toX = (t: number) => ((t - startT) / windowMs) * 100;
+ const toY = (bps: number) => 100 - (Math.max(0, bps) / maxBps) * 100;
+ let d = "";
+ for (let i = 0; i < windowPoints.length; i++) {
+ const p = windowPoints[i];
+ const x = toX(p.t);
+ const y = toY(p.bps);
+ d += i === 0 ? `M ${x.toFixed(3)} ${y.toFixed(3)}` : ` L ${x.toFixed(3)} ${y.toFixed(3)}`;
+ }
+ return d;
+ });
+
+ let currentBps = $derived(windowPoints.length ? windowPoints[windowPoints.length - 1].bps : 0);
+ let lastPoint = $derived(windowPoints.length ? windowPoints[windowPoints.length - 1] : undefined);
+ let lastX = $derived(lastPoint ? ((lastPoint.t - startT) / windowMs) * 100 : 100);
+ let lastY = $derived(lastPoint ? 100 - (Math.max(0, lastPoint.bps) / maxBps) * 100 : 100);
+ let isIdle = $derived(windowPoints.length > 2 && currentBps < 1024);
+</script>
+
+<div
+ class="speed-graph"
+ style="width: {width}px; height: {height}px"
+ title="Now: {formatSpeed(currentBps)} • Peak: {formatSpeed(peakBps)}"
+ aria-hidden="true"
+>
+ <svg viewBox="0 0 100 100" preserveAspectRatio="none">
+ {#if dLine}
+ <path class="line" d={dLine} vector-effect="non-scaling-stroke" />
+ {:else}
+ <path class="line" d="M 0 100 L 100 100" vector-effect="non-scaling-stroke" />
+ {/if}
+ {#if windowPoints.length}
+ <circle class="now-dot" class:idle={isIdle} cx={lastX} cy={lastY} r="1.8" />
+ {/if}
+ </svg>
+</div>
+
+<style>
+ .speed-graph {
+ display: inline-block;
+ vertical-align: middle;
+ }
+
+ svg {
+ width: 100%;
+ height: 100%;
+ display: block;
+ overflow: visible;
+ }
+
+ .line {
+ fill: none;
+ stroke: var(--accent, rgba(80, 160, 255, 1));
+ stroke-width: 1px;
+ stroke-linejoin: round;
+ stroke-linecap: round;
+ opacity: 0.78;
+ filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
+ shape-rendering: geometricPrecision;
+ }
+
+ .now-dot {
+ fill: var(--accent, rgba(80, 160, 255, 1));
+ opacity: 0.9;
+ }
+
+ .now-dot.idle {
+ fill: rgba(255, 195, 90, 0.95);
+ opacity: 0.95;
+ }
+</style>
diff --git a/src/components/misc/Toggle.svelte b/src/components/misc/Toggle.svelte
deleted file mode 100644
index bfb15add..00000000
--- a/src/components/misc/Toggle.svelte
+++ /dev/null
@@ -1,81 +0,0 @@
-<script lang="ts">
- let { enabled = $bindable(false), onToggle } = $props();
-
- function handleKeyDown(e: KeyboardEvent) {
- if (e.key === " " || e.key === "Enter") {
- e.preventDefault();
- enabled = !enabled;
- onToggle?.();
- }
- }
-
- function handleClick() {
- enabled = !enabled;
- onToggle?.();
- }
-</script>
-
-<div
- role="switch"
- aria-checked={enabled}
- tabindex="0"
- class="toggle"
- class:enabled
- onclick={handleClick}
- onkeydown={handleKeyDown}
->
- <div class="toggle-knob"></div>
-</div>
-
-<style>
- .toggle {
- position: relative;
- width: 40px;
- height: 24px;
- background: var(--button);
- border-radius: 12px;
- border: 1px solid var(--button-stroke);
- cursor: pointer;
- display: inline-flex;
- align-items: center;
- padding: 2px;
- transition: background-color 0.2s;
- }
-
- .toggle:focus-visible {
- outline: var(--focus-ring);
- outline-offset: var(--focus-ring-offset);
- }
-
- .toggle:active {
- background: var(--button-press);
- }
-
- .toggle.enabled {
- background: var(--blue);
- border-color: var(--blue);
- }
-
- .toggle-knob {
- width: 18px;
- height: 18px;
- background: var(--secondary);
- border-radius: 50%;
- transition: transform 0.2s cubic-bezier(0.53, 0.05, 0.02, 1.2);
- }
-
- .toggle.enabled .toggle-knob {
- transform: translateX(16px);
- }
-
- :dir(rtl) .toggle.enabled .toggle-knob {
- transform: translateX(-16px);
- }
-
- @media (prefers-reduced-motion: reduce) {
- .toggle,
- .toggle-knob {
- transition: none;
- }
- }
-</style>
diff --git a/src/components/omnibox/FormatSelector.svelte b/src/components/omnibox/FormatSelector.svelte
index 9d7007f1..4ccafa7d 100644
--- a/src/components/omnibox/FormatSelector.svelte
+++ b/src/components/omnibox/FormatSelector.svelte
@@ -41,12 +41,15 @@
return codec.split(".")[0];
}
- let showAllFormats = $state(false);
+ type Preset = "best" | "music" | "custom" | null;
+ let activePreset = $state<Preset>(null);
let bestVA = $derived([...formats].reverse().find(f => f.has_video && f.has_audio) ?? null);
let bestAudio = $derived([...formats].reverse().find(f => f.has_audio && !f.has_video) ?? null);
let bestVideo = $derived([...formats].reverse().find(f => f.has_video && !f.has_audio) ?? null);
+ let hasMusicPreset = $derived(bestAudio !== null);
+
let selectedFormatLabel = $derived.by(() => {
if (!selectedFormatId) return null;
const f = formats.find(fmt => fmt.format_id === selectedFormatId);
@@ -63,6 +66,28 @@
function isYtdlpPlatform(p: string): boolean {
return !["hotmart", "telegram", "udemy", "unknown"].includes(p);
}
+
+ function applyBest() {
+ activePreset = "best";
+ const target = bestVA ?? bestVideo;
+ if (target) onSelectFormat(target.format_id);
+ }
+
+ function applyMusic() {
+ activePreset = "music";
+ if (bestAudio) onSelectFormat(bestAudio.format_id);
+ }
+
+ function toggleCustom() {
+ activePreset = activePreset === "custom" ? null : "custom";
+ if (selectedFormatId) onClearFormat();
+ }
+
+ $effect(() => {
+ if (!formats.length) {
+ activePreset = null;
+ }
+ });
</script>
{#if isYtdlpPlatform(platform)}
@@ -97,103 +122,118 @@
{/if}
{#if formats.length > 0}
- {#if !selectedFormatId}
- <div class="formats-panel">
- <div class="formats-quick">
- {#if bestVA}
- <button
- class="button format-quick-btn"
- class:active={selectedFormatId === bestVA.format_id}
- onclick={() => onSelectFormat(bestVA!.format_id)}
- >
- {$t('omnibox.best_va')}
- </button>
- {/if}
- {#if bestAudio}
- <button
- class="button format-quick-btn"
- class:active={selectedFormatId === bestAudio.format_id}
- onclick={() => onSelectFormat(bestAudio!.format_id)}
- >
- {$t('omnibox.best_audio')}
- </button>
- {/if}
- {#if bestVideo}
- <button
- class="button format-quick-btn"
- class:active={selectedFormatId === bestVideo.format_id}
- onclick={() => onSelectFormat(bestVideo!.format_id)}
- >
- {$t('omnibox.best_video')}
- </button>
- {/if}
- </div>
+ <div class="formats-panel">
+ <div class="formats-presets" role="radiogroup" aria-label={$t('omnibox.formats_presets_label')}>
+ {#if bestVA || bestVideo}
+ <button
+ type="button"
+ class="preset-pill"
+ class:active={activePreset === "best"}
+ onclick={applyBest}
+ role="radio"
+ aria-checked={activePreset === "best"}
+ >
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <polygon points="5 3 19 12 5 21 5 3" />
+ </svg>
+ <span>{$t('omnibox.preset_best')}</span>
+ </button>
+ {/if}
+ {#if hasMusicPreset}
+ <button
+ type="button"
+ class="preset-pill"
+ class:active={activePreset === "music"}
+ onclick={applyMusic}
+ role="radio"
+ aria-checked={activePreset === "music"}
+ >
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M9 18V5l12-2v13" />
+ <circle cx="6" cy="18" r="3" />
+ <circle cx="18" cy="16" r="3" />
+ </svg>
+ <span>{$t('omnibox.preset_music')}</span>
+ </button>
+ {/if}
+ <button
+ type="button"
+ class="preset-pill"
+ class:active={activePreset === "custom"}
+ onclick={toggleCustom}
+ role="radio"
+ aria-checked={activePreset === "custom"}
+ >
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <circle cx="12" cy="12" r="3" />
+ <path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z" />
+ </svg>
+ <span>{$t('omnibox.preset_custom')}</span>
+ </button>
+ </div>
+ {#if selectedFormatId}
+ <div class="format-selected">
+ <span class="format-selected-label">{selectedFormatLabel}</span>
+ <button class="format-clear-btn" onclick={() => { onClearFormat(); activePreset = null; }} aria-label={$t('common.close')}>
+ <svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M18 6L6 18M6 6l12 12" />
+ </svg>
+ </button>
+ </div>
+ {:else}
<div class="formats-info">
<span class="formats-note">
{$t('omnibox.formats_merge_note')}
</span>
</div>
-
- <button class="button formats-show-all-btn" onclick={() => { showAllFormats = !showAllFormats; }}>
- {showAllFormats ? $t('omnibox.hide_all_formats') : $t('omnibox.show_all_formats')}
- </button>
-
- {#if showAllFormats}
- <div class="formats-list">
- <div class="format-header">
- <span>ID</span>
- <span>{$t('omnibox.fmt_type')}</span>
- <span>{$t('omnibox.fmt_quality')}</span>
- <span>{$t('omnibox.fmt_streams')}</span>
- <span>{$t('omnibox.fmt_video')}</span>
- <span>{$t('omnibox.fmt_audio')}</span>
- <span>{$t('omnibox.fmt_size')}</span>
- <span>{$t('omnibox.fmt_speed')}</span>
- </div>
- {#each formats as fmt (fmt.format_id)}
- <button
- class="format-row"
- class:format-row-selected={selectedFormatId === fmt.format_id}
- onclick={() => onSelectFormat(fmt.format_id)}
- >
- <span class="format-id">{fmt.format_id}</span>
- <span class="format-ext">{fmt.ext}</span>
- <span class="format-res">{fmt.resolution ?? "—"}</span>
- <span class="format-codec">
- {#if fmt.has_video && fmt.has_audio}
- V+A
- {:else if fmt.has_video}
- V
- {:else if fmt.has_audio}
- A
- {:else}
- —
- {/if}
- </span>
- <span class="format-vcodec">{formatCodec(fmt.vcodec)}</span>
- <span class="format-acodec">{formatCodec(fmt.acodec)}</span>
- <span class="format-size">{formatFilesize(fmt.filesize)}</span>
- {#if fmt.tbr}
- <span class="format-tbr">{fmt.tbr.toFixed(0)}k</span>
+ {/if}
+
+ {#if activePreset === "custom"}
+ <div class="formats-list">
+ <div class="format-header">
+ <span>ID</span>
+ <span>{$t('omnibox.fmt_type')}</span>
+ <span>{$t('omnibox.fmt_quality')}</span>
+ <span>{$t('omnibox.fmt_streams')}</span>
+ <span>{$t('omnibox.fmt_video')}</span>
+ <span>{$t('omnibox.fmt_audio')}</span>
+ <span>{$t('omnibox.fmt_size')}</span>
+ <span>{$t('omnibox.fmt_speed')}</span>
+ </div>
+ {#each formats as fmt (fmt.format_id)}
+ <button
+ class="format-row"
+ class:format-row-selected={selectedFormatId === fmt.format_id}
+ onclick={() => onSelectFormat(fmt.format_id)}
+ >
+ <span class="format-id">{fmt.format_id}</span>
+ <span class="format-ext">{fmt.ext}</span>
+ <span class="format-res">{fmt.resolution ?? "—"}</span>
+ <span class="format-codec">
+ {#if fmt.has_video && fmt.has_audio}
+ V+A
+ {:else if fmt.has_video}
+ V
+ {:else if fmt.has_audio}
+ A
{:else}
- <span class="format-tbr">—</span>
+ —
{/if}
- </button>
- {/each}
- </div>
- {/if}
- </div>
- {:else}
- <div class="format-selected">
- <span class="format-selected-label">{selectedFormatLabel}</span>
- <button class="format-clear-btn" onclick={onClearFormat} aria-label={$t('common.close')}>
- <svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M18 6L6 18M6 6l12 12" />
- </svg>
- </button>
- </div>
- {/if}
+ </span>
+ <span class="format-vcodec">{formatCodec(fmt.vcodec)}</span>
+ <span class="format-acodec">{formatCodec(fmt.acodec)}</span>
+ <span class="format-size">{formatFilesize(fmt.filesize)}</span>
+ {#if fmt.tbr}
+ <span class="format-tbr">{fmt.tbr.toFixed(0)}k</span>
+ {:else}
+ <span class="format-tbr">—</span>
+ {/if}
+ </button>
+ {/each}
+ </div>
+ {/if}
+ </div>
{/if}
{/if}
@@ -252,15 +292,47 @@
overflow: hidden;
}
- .formats-quick {
+ .formats-presets {
display: flex;
gap: calc(var(--padding) / 2);
flex-wrap: wrap;
}
- .format-quick-btn {
+ .preset-pill {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 6px 14px;
font-size: 13px;
- padding: 6px 12px;
+ font-weight: 500;
+ color: var(--secondary);
+ background: var(--button);
+ border: 1px solid var(--button-stroke);
+ border-radius: 999px;
+ cursor: pointer;
+ transition: background 0.15s, border-color 0.15s, color 0.15s;
+ }
+
+ @media (hover: hover) {
+ .preset-pill:hover {
+ background: var(--button-hover);
+ border-color: var(--content-border);
+ }
+ }
+
+ .preset-pill:active {
+ background: var(--button-press);
+ }
+
+ .preset-pill.active {
+ background: var(--button-elevated);
+ border-color: var(--accent, var(--secondary));
+ color: var(--primary, var(--secondary));
+ }
+
+ .preset-pill:focus-visible {
+ outline: 2px solid var(--accent, var(--secondary));
+ outline-offset: 2px;
}
.formats-info {
@@ -276,12 +348,6 @@
line-height: 1.4;
}
- .formats-show-all-btn {
- font-size: 12px;
- padding: 4px 10px;
- opacity: 0.7;
- }
-
.formats-list {
max-height: 240px;
overflow-y: auto;
diff --git a/src/components/settings/SettingsToggle.svelte b/src/components/settings/SettingsToggle.svelte
deleted file mode 100644
index 5272b05c..00000000
--- a/src/components/settings/SettingsToggle.svelte
+++ /dev/null
@@ -1,64 +0,0 @@
-<script lang="ts">
- import Toggle from "$components/misc/Toggle.svelte";
-
- let {
- label = "",
- description = "",
- enabled = $bindable(false),
- onToggle,
- } = $props();
-
- const toggleId = `toggle-${Math.random().toString(36).slice(2, 9)}`;
-</script>
-
-<div class="settings-toggle">
- <div class="toggle-row">
- <div class="toggle-labels">
- <label class="toggle-label" for={toggleId}>{label}</label>
- {#if description}
- <p class="toggle-description">{description}</p>
- {/if}
- </div>
- <Toggle bind:enabled onToggle={onToggle} />
- </div>
-</div>
-
-<style>
- .settings-toggle {
- display: flex;
- flex-direction: column;
- gap: var(--padding);
- padding: var(--padding);
- background: var(--button);
- border-radius: var(--border-radius);
- }
-
- .toggle-row {
- display: flex;
- align-items: flex-start;
- justify-content: space-between;
- gap: var(--padding);
- }
-
- .toggle-labels {
- display: flex;
- flex-direction: column;
- gap: calc(var(--padding) / 4);
- flex: 1;
- }
-
- .toggle-label {
- font-size: 14.5px;
- font-weight: 500;
- color: var(--secondary);
- cursor: pointer;
- }
-
- .toggle-description {
- margin: 0;
- font-size: 12.5px;
- font-weight: 400;
- color: var(--gray);
- line-height: 1.4;
- }
-</style>
diff --git a/src/components/toast/Toast.svelte b/src/components/toast/Toast.svelte
index 68205484..f048cdeb 100644
--- a/src/components/toast/Toast.svelte
+++ b/src/components/toast/Toast.svelte
@@ -16,15 +16,21 @@
</script>
{#if toasts.length > 0}
- <div class="toast-container">
+ <div class="toast-container" aria-live="polite" aria-atomic="false">
{#each toasts as toast (toast.id)}
- <div class="toast" data-type={toast.type} class:closing={toast.closing}>
- <svg class="toast-icon" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <div
+ class="toast"
+ data-type={toast.type}
+ class:closing={toast.closing}
+ role={toast.type === "error" ? "alert" : "status"}
+ aria-live={toast.type === "error" ? "assertive" : "polite"}
+ >
+ <svg class="toast-icon" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d={iconPath(toast.type)} />
</svg>
<span class="toast-message">{toast.message}</span>
<button class="toast-close" onclick={() => dismissToast(toast.id)} aria-label="Close">
- <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M18 6L6 18M6 6l12 12" />
</svg>
</button>
diff --git a/src/lib/build-info.test.ts b/src/lib/build-info.test.ts
new file mode 100644
index 00000000..7dde8df2
--- /dev/null
+++ b/src/lib/build-info.test.ts
@@ -0,0 +1,29 @@
+import { describe, it, expect } from "vitest";
+import { BUILD_INFO, formatBuildInfo } from "./build-info";
+
+describe("BUILD_INFO", () => {
+ it("exposes version from build-time define", () => {
+ expect(BUILD_INFO.version).toBe("0.0.0-test");
+ });
+
+ it("derives a 7-char short commit hash", () => {
+ expect(BUILD_INFO.commitShort).toBe("test-co");
+ expect(BUILD_INFO.commitShort.length).toBe(7);
+ });
+
+ it("includes branch and date", () => {
+ expect(BUILD_INFO.branch).toBe("test-branch");
+ expect(BUILD_INFO.date).toBe("2026-04-13");
+ });
+});
+
+describe("formatBuildInfo", () => {
+ it("joins all non-empty build parts with ' · '", () => {
+ const formatted = formatBuildInfo();
+ expect(formatted).toContain("v0.0.0-test");
+ expect(formatted).toContain("test-co");
+ expect(formatted).toContain("test-branch");
+ expect(formatted).toContain("2026-04-13");
+ expect(formatted.split(" · ").length).toBe(4);
+ });
+});
diff --git a/src/lib/build-info.ts b/src/lib/build-info.ts
new file mode 100644
index 00000000..4b8dfbba
--- /dev/null
+++ b/src/lib/build-info.ts
@@ -0,0 +1,21 @@
+export const BUILD_INFO = {
+ version: __APP_VERSION__,
+ commit: __COMMIT_HASH__,
+ commitShort: __COMMIT_HASH__.slice(0, 7),
+ branch: __GIT_BRANCH__,
+ date: __BUILD_DATE__,
+};
+
+export function formatBuildInfo(): string {
+ const parts = [`v${BUILD_INFO.version}`];
+ if (BUILD_INFO.commit && BUILD_INFO.commit !== "unknown") {
+ parts.push(BUILD_INFO.commitShort);
+ }
+ if (BUILD_INFO.branch && BUILD_INFO.branch !== "unknown") {
+ parts.push(BUILD_INFO.branch);
+ }
+ if (BUILD_INFO.date) {
+ parts.push(BUILD_INFO.date);
+ }
+ return parts.join(" · ");
+}
diff --git a/src/lib/error-translate.test.ts b/src/lib/error-translate.test.ts
new file mode 100644
index 00000000..30028332
--- /dev/null
+++ b/src/lib/error-translate.test.ts
@@ -0,0 +1,76 @@
+import { describe, it, expect } from "vitest";
+import { translateBackendError } from "./error-translate";
+
+const mockT = (key: string) => `T[${key}]`;
+
+describe("translateBackendError", () => {
+ it("returns common.unknown_error for empty input", () => {
+ expect(translateBackendError("", mockT)).toBe("T[common.unknown_error]");
+ });
+
+ it("maps known backend strings exactly", () => {
+ expect(
+ translateBackendError("Video unavailable or removed.", mockT),
+ ).toBe("T[errors.video_unavailable]");
+ expect(translateBackendError("This video is private.", mockT)).toBe(
+ "T[errors.video_private]",
+ );
+ expect(
+ translateBackendError(
+ "Server returned error 429 (too many requests). Try again later.",
+ mockT,
+ ),
+ ).toBe("T[errors.rate_limited]");
+ });
+
+ it("strips the 'Failed to get formats:' prefix before matching", () => {
+ expect(
+ translateBackendError(
+ "Failed to get formats: Video unavailable or removed.",
+ mockT,
+ ),
+ ).toBe("T[errors.video_unavailable]");
+ });
+
+ it("falls back to heuristic cookie_database match", () => {
+ expect(
+ translateBackendError("Could not copy Chrome cookie database", mockT),
+ ).toBe("T[errors.cookie_database]");
+ });
+
+ it("falls back to heuristic size_mismatch match", () => {
+ expect(
+ translateBackendError("Got a size mismatch on chunk 3", mockT),
+ ).toBe("T[errors.size_mismatch]");
+ });
+
+ it("falls back to heuristic disk_full match", () => {
+ expect(translateBackendError("Disk full on volume D:", mockT)).toBe(
+ "T[errors.disk_full]",
+ );
+ expect(
+ translateBackendError("write error when flushing buffer", mockT),
+ ).toBe("T[errors.disk_full]");
+ });
+
+ it("falls back to heuristic tiktok_blocked match", () => {
+ expect(
+ translateBackendError("TikTok is blocking requests from this IP", mockT),
+ ).toBe("T[errors.tiktok_blocked]");
+ });
+
+ it("returns the original stripped message when no mapping matches", () => {
+ expect(translateBackendError("some unknown error detail", mockT)).toBe(
+ "some unknown error detail",
+ );
+ });
+
+ it("preserves punctuation in unmapped messages after strip", () => {
+ expect(
+ translateBackendError(
+ "Failed to get formats: weird backend msg: x=1",
+ mockT,
+ ),
+ ).toBe("weird backend msg: x=1");
+ });
+});
diff --git a/src/lib/nav-config.test.ts b/src/lib/nav-config.test.ts
new file mode 100644
index 00000000..2f9a5f3a
--- /dev/null
+++ b/src/lib/nav-config.test.ts
@@ -0,0 +1,34 @@
+import { describe, it, expect } from "vitest";
+import { CORE_NAV_ITEMS } from "./nav-config";
+
+describe("CORE_NAV_ITEMS", () => {
+ it("has the expected 5 core entries", () => {
+ expect(CORE_NAV_ITEMS).toHaveLength(5);
+ });
+
+ it("Home is first in primary group", () => {
+ const home = CORE_NAV_ITEMS.find((i) => i.href === "/");
+ expect(home?.group).toBe("primary");
+ expect(home?.labelKey).toBe("nav.home");
+ });
+
+ it("Downloads carries the downloads badge", () => {
+ const downloads = CORE_NAV_ITEMS.find((i) => i.href === "/downloads");
+ expect(downloads?.badge).toBe("downloads");
+ });
+
+ it("About is in the secondary group and sorted last", () => {
+ const about = CORE_NAV_ITEMS.find((i) => i.href === "/about");
+ expect(about?.group).toBe("secondary");
+ expect(about?.order).toBe(999);
+ });
+
+ it("order is strictly increasing among primary items", () => {
+ const primaryOrders = CORE_NAV_ITEMS.filter((i) => i.group === "primary")
+ .map((i) => i.order ?? 0)
+ .sort((a, b) => a - b);
+ for (let i = 1; i < primaryOrders.length; i++) {
+ expect(primaryOrders[i]).toBeGreaterThan(primaryOrders[i - 1]);
+ }
+ });
+});
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index e26d3d59..fb7e1eb9 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -354,8 +354,8 @@
.watermark {
position: fixed;
- bottom: 8px;
- right: 12px;
+ bottom: calc(8px + var(--safe-area-bottom));
+ right: calc(12px + var(--safe-area-right));
font-size: 10px;
font-weight: 400;
color: var(--gray);
@@ -440,9 +440,9 @@
left: 0;
right: 0;
padding: 0;
- padding-left: env(safe-area-inset-left);
- padding-right: env(safe-area-inset-right);
- padding-bottom: env(safe-area-inset-bottom);
+ padding-left: var(--safe-area-left);
+ padding-right: var(--safe-area-right);
+ padding-bottom: var(--safe-area-bottom);
border-top: 1px solid var(--content-border);
overflow-x: auto;
overflow-y: hidden;
@@ -490,7 +490,7 @@
.content {
padding: calc(var(--padding) * 2);
- padding-bottom: calc(44px + env(safe-area-inset-bottom) + var(--padding));
+ padding-bottom: var(--mobile-nav-clearance);
order: -1;
}
}