Skip to content

armgit / VERT

Public Imported from GitHub
0

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

feat: /debug page

JovannMC07a3c67445fd
diff --git a/messages/en.json b/messages/en.json
index 47f5afe..d3b5143 100644
--- a/messages/en.json
+++ b/messages/en.json
@@ -376,6 +376,66 @@
"clear_all_data_cancel": "Cancel",
"all_data_cleared": "All site data cleared! Reloading page...",
"all_data_clear_error": "Failed to clear all site data."
+ },
+ "debug_link": "Debug tools"
+ },
+ "debug": {
+ "title": "Debug",
+ "logs": {
+ "title": "Logs",
+ "search_placeholder": "Search logs...",
+ "count": "{count} entries",
+ "empty": "No logs to show",
+ "refresh": "Refresh",
+ "clear": "Clear",
+ "cleared": "Logs cleared!",
+ "levels": {
+ "all": "All levels",
+ "log": "Log",
+ "error": "Error"
+ }
+ },
+ "system": {
+ "title": "System information",
+ "cores": "CPU cores",
+ "memory": "Device memory",
+ "platform": "Platform",
+ "screen": "Screen",
+ "environment": "Environment",
+ "external_requests": "External requests",
+ "enabled": "Enabled",
+ "disabled": "Disabled"
+ },
+ "converters": {
+ "title": "Converters",
+ "formats": "Formats",
+ "statuses": {
+ "not_ready": "Not ready",
+ "downloading": "Downloading",
+ "ready": "Ready",
+ "partially_ready": "Partially ready",
+ "error": "Error"
+ }
+ },
+ "storage": {
+ "registration": "Service worker",
+ "registered": "Registered",
+ "controller": "SW controller",
+ "controlled": "Active",
+ "cache_size": "Cache size",
+ "cache_files": "Cached files",
+ "quota_used": "Storage used",
+ "quota_available": "Available"
+ },
+ "tools": {
+ "title": "Debugging tools",
+ "report_title": "Bug report",
+ "report_description": "Bundle system information together with your logs to share with the developers for debugging purposes. It may contain filenames, formats, and other information about your conversions.",
+ "copy_report": "Copy report",
+ "download_report": "Download report",
+ "report_copied": "Report copied to clipboard!",
+ "report_copy_error": "Failed to copy report.",
+ "report_downloaded": "Report downloaded!"
}
}
},
diff --git a/src/lib/components/functional/ConversionPanel.svelte b/src/lib/components/functional/ConversionPanel.svelte
index 21100d8..9ab149f 100644
--- a/src/lib/components/functional/ConversionPanel.svelte
+++ b/src/lib/components/functional/ConversionPanel.svelte
@@ -1,6 +1,6 @@
<script lang="ts">
import { effects, files, isMobile } from "$lib/store/index.svelte";
- import { FolderArchiveIcon, RefreshCw, Trash2Icon } from "@lucide/svelte";
+ import { FolderArchiveIcon, RefreshCw, TrashIcon } from "@lucide/svelte";
import Panel from "../visual/Panel.svelte";
import Dropdown from "./Dropdown.svelte";
import Tooltip from "../visual/Tooltip.svelte";
@@ -78,7 +78,7 @@
disabled={files.files.length === 0}
onclick={() => files.removeAll()}
>
- <Trash2Icon size="24" />
+ <TrashIcon size="24" />
<p>{m["convert.panel.remove_all"]()}</p>
</button>
{:else}
@@ -93,7 +93,7 @@
disabled={files.files.length === 0}
onclick={() => files.removeAll()}
>
- <Trash2Icon size="24" />
+ <TrashIcon size="24" />
</button>
</Tooltip>
{/if}
diff --git a/src/lib/components/functional/FormatDropdown.svelte b/src/lib/components/functional/FormatDropdown.svelte
index 3b6a877..d586217 100644
--- a/src/lib/components/functional/FormatDropdown.svelte
+++ b/src/lib/components/functional/FormatDropdown.svelte
@@ -18,7 +18,7 @@
import { onMount, tick } from "svelte";
import { quintOut } from "svelte/easing";
import { VertFile } from "$lib/types";
- import { log } from "$lib/util/logger";
+ import { log } from "$lib/util/logger.svelte";
import FancyInput from "./FancyInput.svelte";
import Tooltip from "../visual/Tooltip.svelte";
import { vertdSizeLimit } from "$lib/sections/settings/vertdSettings.svelte";
diff --git a/src/lib/components/functional/popups/SettingsModal.svelte b/src/lib/components/functional/popups/SettingsModal.svelte
index 1d4f731..7b9fe42 100644
--- a/src/lib/components/functional/popups/SettingsModal.svelte
+++ b/src/lib/components/functional/popups/SettingsModal.svelte
@@ -8,7 +8,7 @@
import type { VertFile } from "$lib/types";
import { effects, files } from "$lib/store/index.svelte";
import { converterCategories } from "$lib/converters";
- import { log, error } from "$lib/util/logger";
+ import { log, error } from "$lib/util/logger.svelte";
import type {
ConversionSettings,
SettingCategories,
diff --git a/src/lib/components/layout/Gradients.svelte b/src/lib/components/layout/Gradients.svelte
index a816851..d7b2218 100644
--- a/src/lib/components/layout/Gradients.svelte
+++ b/src/lib/components/layout/Gradients.svelte
@@ -37,6 +37,11 @@
color: "var(--bg-gradient-red-from)",
at: 100,
},
+ {
+ matcher: (path) => path === "/debug/",
+ color: "var(--bg-gradient-red-from)",
+ at: 100,
+ },
]);
const color = $derived(
diff --git a/src/lib/converters/ffmpeg/ffmpeg.svelte.ts b/src/lib/converters/ffmpeg/ffmpeg.svelte.ts
index 8186278..63296d3 100644
--- a/src/lib/converters/ffmpeg/ffmpeg.svelte.ts
+++ b/src/lib/converters/ffmpeg/ffmpeg.svelte.ts
@@ -2,7 +2,7 @@ import { VertFile } from "$lib/types";
import { Converter, FormatInfo } from "../converter.svelte";
import { FFmpeg } from "@ffmpeg/ffmpeg";
import { browser } from "$app/environment";
-import { error, log } from "$lib/util/logger";
+import { error, log } from "$lib/util/logger.svelte";
import { m } from "$lib/paraglide/messages";
import { Settings } from "$lib/sections/settings/index.svelte";
import { ToastManager } from "$lib/util/toast.svelte";
diff --git a/src/lib/converters/magick/magick.svelte.ts b/src/lib/converters/magick/magick.svelte.ts
index 9fd3a97..dfcb330 100644
--- a/src/lib/converters/magick/magick.svelte.ts
+++ b/src/lib/converters/magick/magick.svelte.ts
@@ -1,5 +1,5 @@
import { browser } from "$app/environment";
-import { error, log } from "$lib/util/logger";
+import { error, log } from "$lib/util/logger.svelte";
import { m } from "$lib/paraglide/messages";
import { VertFile, type WorkerMessage } from "$lib/types";
import MagickWorker from "$lib/workers/magick?worker&url";
diff --git a/src/lib/converters/mediabunny/mediabunny.svelte.ts b/src/lib/converters/mediabunny/mediabunny.svelte.ts
index 9e68eb5..72a2b3c 100644
--- a/src/lib/converters/mediabunny/mediabunny.svelte.ts
+++ b/src/lib/converters/mediabunny/mediabunny.svelte.ts
@@ -25,7 +25,7 @@ import { registerMp3Encoder } from "@mediabunny/mp3-encoder";
import { registerFlacEncoder } from "@mediabunny/flac-encoder";
import { registerProresDecoder } from "@mediabunny/prores";
import { Converter, FormatInfo, type WorkerStatus } from "../converter.svelte";
-import { error, log } from "$lib/util/logger";
+import { error, log } from "$lib/util/logger.svelte";
import { m } from "$lib/paraglide/messages";
import type {
SettingDefinition,
@@ -65,46 +65,11 @@ const codecCompatibility = {
m4a: mp4AudioCodecs,
m4b: mp4AudioCodecs,
m4p: mp4AudioCodecs,
- mkv: [
- "aac",
- "opus",
- "mp3",
- "vorbis",
- "flac",
- "ac3",
- "eac3",
- "dts",
- "pcm-u8",
- "pcm-s16",
- "pcm-s24",
- "pcm-s32",
- "pcm-f32",
- "pcm-f64",
- ],
+ // prettier-ignore
+ mkv: ["aac", "opus", "mp3", "vorbis", "flac", "ac3", "eac3", "dts", "pcm-u8", "pcm-s16", "pcm-s24", "pcm-s32", "pcm-f32", "pcm-f64"],
webm: ["opus", "vorbis"],
- mov: [
- "aac",
- "opus",
- "mp3",
- "vorbis",
- "flac",
- "ac3",
- "eac3",
- "dts",
- "pcm-u8",
- "pcm-s8",
- "pcm-s16",
- "pcm-s16be",
- "pcm-s24",
- "pcm-s24be",
- "pcm-s32",
- "pcm-s32be",
- "pcm-f32",
- "pcm-f32be",
- "pcm-f64",
- "ulaw",
- "alaw",
- ],
+ // prettier-ignore
+ mov: ["aac", "opus", "mp3", "vorbis", "flac", "ac3", "eac3", "dts", "pcm-u8", "pcm-s8", "pcm-s16", "pcm-s16be", "pcm-s24", "pcm-s24be", "pcm-s32", "pcm-s32be", "pcm-f32", "pcm-f32be", "pcm-f64", "ulaw", "alaw"],
ts: ["aac", "mp3", "ac3", "eac3", "dts"],
},
} as const;
@@ -437,9 +402,7 @@ export class MediabunnyConverter extends Converter {
output,
video: videoConfig,
audio: audioConfig,
- ...(!conversionSettings.metadata
- ? { tags: {} }
- : {}),
+ ...(!conversionSettings.metadata ? { tags: {} } : {}),
});
this.activeConversions.set(file.id, conversion);
diff --git a/src/lib/converters/pandoc/pandoc.svelte.ts b/src/lib/converters/pandoc/pandoc.svelte.ts
index dffcb17..1266a81 100644
--- a/src/lib/converters/pandoc/pandoc.svelte.ts
+++ b/src/lib/converters/pandoc/pandoc.svelte.ts
@@ -2,7 +2,7 @@ import { VertFile, type WorkerMessage } from "$lib/types";
import { Converter, FormatInfo } from "../converter.svelte";
import { browser } from "$app/environment";
import PandocWorker from "$lib/workers/pandoc?worker&url";
-import { error, log } from "$lib/util/logger";
+import { error, log } from "$lib/util/logger.svelte";
import { ToastManager } from "$lib/util/toast.svelte";
import { m } from "$lib/paraglide/messages";
diff --git a/src/lib/converters/vertd/vertd.svelte.ts b/src/lib/converters/vertd/vertd.svelte.ts
index ade838d..42eadea 100644
--- a/src/lib/converters/vertd/vertd.svelte.ts
+++ b/src/lib/converters/vertd/vertd.svelte.ts
@@ -1,5 +1,5 @@
import VertdErrorComponent from "$lib/components/functional/popups/VertdError.svelte";
-import { error, log } from "$lib/util/logger";
+import { error, log } from "$lib/util/logger.svelte";
import { m } from "$lib/paraglide/messages";
import { Settings } from "$lib/sections/settings/index.svelte";
import {
diff --git a/src/lib/sections/about/Donate.svelte b/src/lib/sections/about/Donate.svelte
index 3881686..f998a7c 100644
--- a/src/lib/sections/about/Donate.svelte
+++ b/src/lib/sections/about/Donate.svelte
@@ -38,7 +38,7 @@
import { quintOut } from "svelte/easing";
import { m } from "$lib/paraglide/messages";
import { ToastManager } from "$lib/util/toast.svelte";
- import { log } from "$lib/util/logger";
+ import { log } from "$lib/util/logger.svelte";
let amount = $state(1);
let customAmount = $state("");
diff --git a/src/lib/sections/about/Sponsors.svelte b/src/lib/sections/about/Sponsors.svelte
index 964ac8e..729882f 100644
--- a/src/lib/sections/about/Sponsors.svelte
+++ b/src/lib/sections/about/Sponsors.svelte
@@ -2,7 +2,7 @@
import Panel from "$lib/components/visual/Panel.svelte";
import { PiggyBankIcon, CopyIcon, CheckIcon } from "@lucide/svelte";
import { DISCORD_URL } from "$lib/util/consts";
- import { error } from "$lib/util/logger";
+ import { error } from "$lib/util/logger.svelte";
import { m } from "$lib/paraglide/messages";
import { link, sanitize } from "$lib/store/index.svelte";
import { ToastManager } from "$lib/util/toast.svelte";
diff --git a/src/lib/sections/settings/Appearance.svelte b/src/lib/sections/settings/Appearance.svelte
index c212324..864e627 100644
--- a/src/lib/sections/settings/Appearance.svelte
+++ b/src/lib/sections/settings/Appearance.svelte
@@ -95,7 +95,7 @@
</script>
<Panel class="flex flex-col gap-8 p-6">
- <div class="flex flex-col gap-3">
+ <div class="flex flex-col gap-4">
<h2 class="text-2xl font-bold">
<PaletteIcon
size="40"
diff --git a/src/lib/sections/settings/Conversion.svelte b/src/lib/sections/settings/Conversion.svelte
index 882d9cb..86c9de9 100644
--- a/src/lib/sections/settings/Conversion.svelte
+++ b/src/lib/sections/settings/Conversion.svelte
@@ -20,7 +20,7 @@
</script>
<Panel class="flex flex-col gap-8 p-6">
- <div class="flex flex-col gap-3">
+ <div class="flex flex-col gap-4">
<h2 class="text-2xl font-bold">
<RefreshCwIcon
size="40"
diff --git a/src/lib/sections/settings/Privacy.svelte b/src/lib/sections/settings/Privacy.svelte
index 13c4018..734ab64 100644
--- a/src/lib/sections/settings/Privacy.svelte
+++ b/src/lib/sections/settings/Privacy.svelte
@@ -1,11 +1,12 @@
<script lang="ts">
import Panel from "$lib/components/visual/Panel.svelte";
import {
+ BugIcon,
ChartColumnIcon,
PauseIcon,
PlayIcon,
RefreshCwIcon,
- Trash2Icon,
+ TrashIcon,
} from "@lucide/svelte";
import type { ISettings } from "./index.svelte";
import { effects } from "$lib/store/index.svelte";
@@ -13,7 +14,7 @@
import { link, sanitize } from "$lib/store/index.svelte";
import { swManager, type CacheInfo } from "$lib/util/sw";
import { onMount } from "svelte";
- import { error } from "$lib/util/logger";
+ import { error } from "$lib/util/logger.svelte";
import { ToastManager } from "$lib/util/toast.svelte";
import { DISABLE_ALL_EXTERNAL_REQUESTS } from "$lib/util/consts";
import { addDialog } from "$lib/store/DialogProvider";
@@ -41,9 +42,13 @@
if (!navigator.serviceWorker.controller) {
await new Promise<void>((resolve) => {
controllerListener = () => {
- if (navigator.serviceWorker.controller) resolve();
- };
- navigator.serviceWorker.addEventListener("controllerchange", controllerListener);
+ if (navigator.serviceWorker.controller)
+ resolve();
+ };
+ navigator.serviceWorker.addEventListener(
+ "controllerchange",
+ controllerListener,
+ );
controllerListener();
});
}
@@ -52,7 +57,12 @@
})(),
new Promise<never>((_, reject) => {
timeout = setTimeout(
- () => reject(new Error("Service worker cache loading timed out")),
+ () =>
+ reject(
+ new Error(
+ "Service worker cache loading timed out",
+ ),
+ ),
10000,
);
}),
@@ -63,7 +73,10 @@
expired = true;
clearTimeout(timeout);
if (controllerListener)
- navigator.serviceWorker.removeEventListener("controllerchange", controllerListener);
+ navigator.serviceWorker.removeEventListener(
+ "controllerchange",
+ controllerListener,
+ );
isLoadingCache = false;
}
}
@@ -114,17 +127,26 @@
const operations = [
["cache", () => swManager.clearCache()],
["localStorage", () => localStorage.clear()],
- ["sessionStorage", () => sessionStorage.clear()],
+ [
+ "sessionStorage",
+ () => sessionStorage.clear(),
+ ],
] as const;
for (const [name, clear] of operations) {
try {
await clear();
} catch (err) {
failed = true;
- error(["privacy", "data"], `Failed to clear ${name}: ${err}`);
+ error(
+ ["privacy", "data"],
+ `Failed to clear ${name}: ${err}`,
+ );
}
}
- if (failed) throw new Error("Some site data failed to clear");
+ if (failed)
+ throw new Error(
+ "Some site data failed to clear",
+ );
ToastManager.add({
type: "success",
@@ -164,7 +186,7 @@
</script>
<Panel class="flex flex-col gap-8 p-6">
- <div class="flex flex-col gap-3">
+ <div class="flex flex-col gap-4">
<h2 class="text-2xl font-bold">
<ChartColumnIcon
size="40"
@@ -286,7 +308,7 @@
: '!scale-100'} flex-1 p-4 rounded-lg text-black dynadark:text-white flex items-center justify-center"
disabled={isLoadingCache || isClearingData}
>
- <Trash2Icon size="24" class="inline-block mr-2" />
+ <TrashIcon size="24" class="inline-block mr-2" />
{m["settings.privacy.cache.clear_cache"]()}
</button>
</div>
@@ -309,10 +331,20 @@
: '!scale-100'} w-full p-4 rounded-lg text-black dynadark:text-white flex items-center justify-center"
disabled={isClearingData}
>
- <Trash2Icon size="24" class="inline-block mr-2" />
+ <TrashIcon size="24" class="inline-block mr-2" />
{m["settings.privacy.site_data.clear_all_data"]()}
</button>
</div>
+
+ <div class="flex justify-center">
+ <a
+ href="/debug"
+ class="text-xs text-muted hover:text-foreground transition-colors flex items-center gap-1"
+ >
+ <BugIcon size="14" />
+ {m["settings.privacy.debug_link"]()}
+ </a>
+ </div>
</div>
</div></Panel
>
diff --git a/src/lib/sections/settings/Vertd.svelte b/src/lib/sections/settings/Vertd.svelte
index a7c29af..c523f4b 100644
--- a/src/lib/sections/settings/Vertd.svelte
+++ b/src/lib/sections/settings/Vertd.svelte
@@ -59,7 +59,7 @@
</script>
<Panel class="flex flex-col gap-8 p-6">
- <div class="flex flex-col gap-3">
+ <div class="flex flex-col gap-4">
<h2 class="text-2xl font-bold">
<ServerIcon
size="40"
diff --git a/src/lib/sections/settings/vertdSettings.svelte.ts b/src/lib/sections/settings/vertdSettings.svelte.ts
index b15b4ec..b16b333 100644
--- a/src/lib/sections/settings/vertdSettings.svelte.ts
+++ b/src/lib/sections/settings/vertdSettings.svelte.ts
@@ -1,6 +1,6 @@
import { Settings } from "./index.svelte";
import { PUB_VERTD_URL } from "$env/static/public";
-import { error, log } from "$lib/util/logger";
+import { error, log } from "$lib/util/logger.svelte";
import { writable } from "svelte/store";
import { getVertdLimit } from "$lib/store/index.svelte";
diff --git a/src/lib/store/index.svelte.ts b/src/lib/store/index.svelte.ts
index d70783e..24fb5dd 100644
--- a/src/lib/store/index.svelte.ts
+++ b/src/lib/store/index.svelte.ts
@@ -6,7 +6,7 @@ import {
converters,
} from "$lib/converters";
import type { Converter } from "$lib/converters/converter.svelte";
-import { error, log } from "$lib/util/logger";
+import { error, log } from "$lib/util/logger.svelte";
import { VertFile } from "$lib/types";
import { parseBlob, selectCover } from "music-metadata";
import { get, writable } from "svelte/store";
diff --git a/src/lib/types/file.svelte.ts b/src/lib/types/file.svelte.ts
index b045edc..9670c62 100644
--- a/src/lib/types/file.svelte.ts
+++ b/src/lib/types/file.svelte.ts
@@ -13,7 +13,7 @@ import type {
NormalizedSettings,
SettingCategories,
} from "./conversion-settings";
-import { error, log } from "$lib/util/logger";
+import { error, log } from "$lib/util/logger.svelte";
import { readSettings } from "$lib/util/settings";
import { formatFilename } from "$lib/util/file";
import { conversionConcurrency } from "$lib/util/consts";
@@ -338,6 +338,7 @@ export class VertFile {
this.from = `.${detectedExtension}`;
if (!this.fileTypeMismatchShown) {
error(
+ ["file", "type"],
`file type mismatched: expected ${expectedExtension}, detected ${detectedExtension}`,
);
ToastManager.add({
diff --git a/src/lib/util/debug.svelte.ts b/src/lib/util/debug.svelte.ts
new file mode 100644
index 0000000..9ee6323
--- /dev/null
+++ b/src/lib/util/debug.svelte.ts
@@ -0,0 +1,235 @@
+import { browser } from "$app/environment";
+import { PUB_ENV } from "$env/static/public";
+import {
+ AudioLinesIcon,
+ BookTextIcon,
+ FilmIcon,
+ ImageIcon,
+ RefreshCwIcon,
+ ServerIcon,
+} from "@lucide/svelte";
+import type { Component } from "svelte";
+import { converters } from "$lib/converters";
+import { m } from "$lib/paraglide/messages";
+import { DISABLE_ALL_EXTERNAL_REQUESTS, VERT_NAME } from "$lib/util/consts";
+import {
+ error as logError,
+ formatLogLine,
+ logs,
+ type LogEntry,
+} from "$lib/util/logger.svelte";
+import { swManager, type CacheInfo } from "$lib/util/sw";
+
+declare const __COMMIT_HASH__: string | undefined;
+export const commitHash =
+ __COMMIT_HASH__ && __COMMIT_HASH__ !== "unknown"
+ ? __COMMIT_HASH__
+ : "unknown";
+
+export interface ConverterInfo {
+ name: string;
+ status: string;
+ formats: number;
+ category: string;
+ icon: Component;
+ accent: string;
+}
+
+export const CONVERTER_META: Record<
+ string,
+ { category: string; icon: Component; accent: string }
+> = {
+ imagemagick: {
+ category: "image",
+ icon: ImageIcon,
+ accent: "bg-accent-blue",
+ },
+ ffmpeg: {
+ category: "audio",
+ icon: AudioLinesIcon,
+ accent: "bg-accent-purple",
+ },
+ pandoc: {
+ category: "doc",
+ icon: BookTextIcon,
+ accent: "bg-accent-green",
+ },
+ mediabunny: {
+ category: "video",
+ icon: FilmIcon,
+ accent: "bg-accent-red",
+ },
+ vertd: {
+ category: "video",
+ icon: ServerIcon,
+ accent: "bg-accent-red",
+ },
+};
+
+export const STATUS_CLASSES: Record<string, string> = {
+ "not-ready": "bg-button text-muted",
+ downloading: "bg-accent-blue text-black",
+ ready: "bg-accent-green text-black",
+ "partially-ready": "bg-accent-purple text-black",
+ error: "bg-accent-red text-black",
+};
+
+export function getStatusLabels(): Record<string, string> {
+ return {
+ "not-ready": m["settings.debug.converters.statuses.not_ready"](),
+ downloading: m["settings.debug.converters.statuses.downloading"](),
+ ready: m["settings.debug.converters.statuses.ready"](),
+ "partially-ready":
+ m["settings.debug.converters.statuses.partially_ready"](),
+ error: m["settings.debug.converters.statuses.error"](),
+ };
+}
+
+export function getConverterList(): ConverterInfo[] {
+ return converters.map((converter) => ({
+ name: converter.name,
+ status: converter.status,
+ formats: converter.supportedFormats.length,
+ ...(CONVERTER_META[converter.name] ?? {
+ category: "other",
+ icon: RefreshCwIcon,
+ accent: "bg-button",
+ }),
+ }));
+}
+
+export function getLogLevelOptions() {
+ return [
+ { value: "all", label: m["settings.debug.logs.levels.all"]() },
+ { value: "log", label: m["settings.debug.logs.levels.log"]() },
+ { value: "error", label: m["settings.debug.logs.levels.error"]() },
+ ];
+}
+
+export function filterLogs(
+ entries: LogEntry[],
+ level: string,
+ query: string,
+): LogEntry[] {
+ const normalized = query.trim().toLowerCase();
+ return entries.filter((entry) => {
+ const matchesLevel = level === "all" || entry.level === level;
+ const matchesQuery =
+ !normalized ||
+ entry.message.toLowerCase().includes(normalized) ||
+ entry.prefixes.some((p) => p.toLowerCase().includes(normalized));
+ return matchesLevel && matchesQuery;
+ });
+}
+
+export interface SystemInfo {
+ cores: string;
+ memory: string;
+ platform: string;
+ screen: string;
+}
+
+const UNKNOWN = "-";
+
+export function getSystemInfo(): SystemInfo {
+ if (!browser) {
+ return {
+ cores: UNKNOWN,
+ memory: UNKNOWN,
+ platform: UNKNOWN,
+ screen: UNKNOWN,
+ };
+ }
+
+ const nav = navigator as Navigator & {
+ deviceMemory?: number;
+ userAgentData?: { platform?: string };
+ };
+
+ return {
+ cores: navigator.hardwareConcurrency
+ ? String(navigator.hardwareConcurrency)
+ : UNKNOWN,
+ memory: nav.deviceMemory ? `${nav.deviceMemory} GB` : UNKNOWN,
+ platform: nav.userAgentData?.platform || navigator.platform || UNKNOWN,
+ screen: `${window.screen.width}x${window.screen.height} @ ${window.devicePixelRatio}x`,
+ };
+}
+
+export interface StorageInfo {
+ cacheInfo: CacheInfo | null;
+ storageEstimate: { usage: number; quota: number } | null;
+ swRegistered: boolean;
+ swControlled: boolean;
+}
+
+export async function getStorageInfo(): Promise<StorageInfo> {
+ const result: StorageInfo = {
+ cacheInfo: null,
+ storageEstimate: null,
+ swRegistered: false,
+ swControlled: false,
+ };
+
+ if (!browser) return result;
+
+ try {
+ if (navigator.storage?.estimate) {
+ const estimate = await navigator.storage.estimate();
+ result.storageEstimate = {
+ usage: estimate.usage ?? 0,
+ quota: estimate.quota ?? 0,
+ };
+ }
+
+ if ("serviceWorker" in navigator) {
+ const registration =
+ await navigator.serviceWorker.getRegistration();
+ result.swRegistered = !!registration;
+ result.swControlled = !!navigator.serviceWorker.controller;
+ await swManager.init();
+ await navigator.serviceWorker.ready;
+ result.cacheInfo = await swManager.getCacheInfo();
+ }
+ } catch (err) {
+ logError(["debug", "storage"], `failed to load storage info: ${err}`);
+ }
+
+ return result;
+}
+
+export function formatFileStamp(): string {
+ return new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);
+}
+
+export function downloadText(filename: string, content: string): void {
+ if (!browser) return;
+ const blob = new Blob([content], { type: "text/plain" });
+ const url = URL.createObjectURL(blob);
+ const anchor = document.createElement("a");
+ anchor.href = url;
+ anchor.download = filename;
+ anchor.click();
+ URL.revokeObjectURL(url);
+}
+
+export function buildReport(systemInfo: SystemInfo): string {
+ return [
+ `${VERT_NAME} debug report`,
+ `Generated: ${new Date().toISOString()}`,
+ `Environment: ${PUB_ENV}`,
+ `Commit: ${commitHash}`,
+ `User agent: ${browser ? navigator.userAgent : "unknown"}`,
+ `Platform: ${systemInfo.platform}`,
+ `Cores: ${systemInfo.cores}`,
+ `Memory: ${systemInfo.memory}`,
+ `Screen: ${systemInfo.screen}`,
+ `External requests: ${DISABLE_ALL_EXTERNAL_REQUESTS ? "disabled" : "enabled"}`,
+ `Converters: ${getConverterList()
+ .map((c) => `${c.name}=${c.status}`)
+ .join(", ")}`,
+ "",
+ `--- logs (${logs.entries.length}) ---`,
+ ...logs.entries.map(formatLogLine),
+ ].join("\n");
+}
diff --git a/src/lib/util/file.ts b/src/lib/util/file.ts
index 81c9746..c3dc4e6 100644
--- a/src/lib/util/file.ts
+++ b/src/lib/util/file.ts
@@ -1,4 +1,4 @@
-import { error, log } from "$lib/util/logger";
+import { error, log } from "$lib/util/logger.svelte";
import { unzip } from "fflate";
import { downloadZip } from "client-zip";
diff --git a/src/lib/util/logger.svelte.ts b/src/lib/util/logger.svelte.ts
new file mode 100644
index 0000000..c704480
--- /dev/null
+++ b/src/lib/util/logger.svelte.ts
@@ -0,0 +1,181 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
+import { browser } from "$app/environment";
+
+export type LogLevel = "log" | "error";
+
+export interface LogEntry {
+ id: number;
+ time: string; // HH:MM:SS.mmm, pre-formatted for display/export
+ timestamp: number; // epoch ms
+ level: LogLevel;
+ prefixes: string[];
+ message: string;
+}
+
+export const MAX_LOG_ENTRIES = 1000;
+
+export const logs = $state<{ entries: LogEntry[] }>({ entries: [] });
+
+let internalWrite = false;
+let consoleInstalled = false;
+const originalConsole = new Map<string, (...args: any[]) => void>();
+
+const pad = (value: number, length = 2) => String(value).padStart(length, "0");
+
+const formatTime = (date: Date) =>
+ `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}`;
+
+const stripConsoleStyles = (args: unknown[]): unknown[] => {
+ if (typeof args[0] === "string" && args[0].includes("%c")) {
+ const format = args[0];
+ const styleCount = (format.match(/%c/g) ?? []).length;
+ const cleaned = format.replace(/%c/g, "").trim();
+ return [cleaned, ...args.slice(1 + styleCount)];
+ }
+ return args;
+};
+
+const stringifyArg = (arg: unknown): string => {
+ if (arg instanceof Error) return `${arg.name}: ${arg.message}`;
+ if (typeof arg === "string") return arg;
+ if (arg === null) return "null";
+ if (arg === undefined) return "undefined";
+ try {
+ if (typeof arg === "object") return JSON.stringify(arg);
+ return String(arg);
+ } catch {
+ return String(arg);
+ }
+};
+
+export const formatLogMessage = (args: unknown[]) =>
+ args.map(stringifyArg).join(" ");
+
+export const formatLogLine = (entry: LogEntry) =>
+ `[${entry.time}]${entry.prefixes.map((p) => ` [${p}]`).join("")} ${entry.message}`;
+
+export const addLog = (
+ level: LogLevel,
+ prefix: string | string[],
+ ...args: any[]
+) => {
+ if (!browser) return;
+ const prefixes = Array.isArray(prefix) ? prefix : [prefix];
+ const now = new Date();
+ logs.entries.push({
+ id: logs.entries.length
+ ? logs.entries[logs.entries.length - 1].id + 1
+ : 1,
+ time: formatTime(now),
+ timestamp: now.getTime(),
+ level,
+ prefixes,
+ message: formatLogMessage(args),
+ });
+ if (logs.entries.length > MAX_LOG_ENTRIES) {
+ logs.entries.splice(0, logs.entries.length - MAX_LOG_ENTRIES);
+ }
+};
+
+export const clearLogs = () => {
+ logs.entries = [];
+};
+
+const randomColorFromStr = (str: string) => {
+ // generate a pleasant color from a string, using HSL
+ let hash = 0;
+ for (let i = 0; i < str.length; i++) {
+ hash = str.charCodeAt(i) + ((hash << 5) - hash);
+ }
+ const h = hash % 360;
+ return `hsl(${h}, 75%, 71%)`;
+};
+
+const whiteOrBlack = (hsl: string) => {
+ // determine if the text should be white or black based on the background color
+ const [, , l] = hsl
+ .replace("hsl(", "")
+ .replace(")", "")
+ .split(",")
+ .map((v) => parseInt(v));
+ return l > 70 ? "black" : "white";
+};
+
+export const printToConsole = (
+ level: LogLevel,
+ prefix: string | string[],
+ ...args: any[]
+) => {
+ const prefixes = Array.isArray(prefix) ? prefix : [prefix];
+ if (!browser)
+ return level === "error"
+ ? console.error(prefixes.map((p) => `[${p}]`).join(" "), ...args)
+ : console.log(prefixes.map((p) => `[${p}]`).join(" "), ...args);
+ const prefixesWithMeta = prefixes.map((p) => ({
+ prefix: p,
+ bgColor: randomColorFromStr(p),
+ textColor: whiteOrBlack(randomColorFromStr(p)),
+ }));
+
+ const write = level === "error" ? console.error : console.log;
+ internalWrite = true;
+ try {
+ write(
+ `%c${prefixesWithMeta.map(({ prefix }) => prefix).join(" %c")}`,
+ ...prefixesWithMeta.map(
+ ({ bgColor, textColor }, i) =>
+ `color: ${textColor}; background-color: ${bgColor}; margin-left: ${i === 0 ? 0 : -6}px; padding: 0px 4px 0 4px; border-radius: 0px 9999px 9999px 0px;`,
+ ),
+ ...args,
+ );
+ } finally {
+ internalWrite = false;
+ }
+};
+
+export const installConsoleCapture = () => {
+ if (!browser || consoleInstalled) return;
+ consoleInstalled = true;
+
+ const capture: Array<[keyof Console, LogLevel]> = [
+ ["log", "log"],
+ ["info", "log"],
+ ["debug", "log"],
+ ["warn", "log"],
+ ["error", "error"],
+ ];
+
+ for (const [method, level] of capture) {
+ const original = (console[method] as (...args: any[]) => void).bind(
+ console,
+ );
+ originalConsole.set(method, original);
+
+ (console as unknown as Record<string, unknown>)[method] = (
+ ...args: any[]
+ ) => {
+ if (!internalWrite)
+ addLog(level, ["console"], ...stripConsoleStyles(args));
+ original(...args);
+ };
+ }
+};
+
+export const uninstallConsoleCapture = () => {
+ if (!browser || !consoleInstalled) return;
+ for (const [method, original] of originalConsole) {
+ (console as unknown as Record<string, unknown>)[method] = original;
+ }
+ originalConsole.clear();
+ consoleInstalled = false;
+};
+
+export const log = (prefix: string | string[], ...args: any[]) => {
+ addLog("log", prefix, ...args);
+ printToConsole("log", prefix, ...args);
+};
+
+export const error = (prefix: string | string[], ...args: any[]) => {
+ addLog("error", prefix, ...args);
+ printToConsole("error", prefix, ...args);
+};
diff --git a/src/lib/util/logger.ts b/src/lib/util/logger.ts
deleted file mode 100644
index 985f76a..0000000
--- a/src/lib/util/logger.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-/* eslint-disable @typescript-eslint/no-explicit-any */
-import { browser } from "$app/environment";
-
-const randomColorFromStr = (str: string) => {
- // generate a pleasant color from a string, using HSL
- let hash = 0;
- for (let i = 0; i < str.length; i++) {
- hash = str.charCodeAt(i) + ((hash << 5) - hash);
- }
- const h = hash % 360;
- return `hsl(${h}, 75%, 71%)`;
-};
-
-const whiteOrBlack = (hsl: string) => {
- // determine if the text should be white or black based on the background color
- const [, , l] = hsl
- .replace("hsl(", "")
- .replace(")", "")
- .split(",")
- .map((v) => parseInt(v));
- return l > 70 ? "black" : "white";
-};
-
-export const log = (prefix: string | string[], ...args: any[]) => {
- const prefixes = Array.isArray(prefix) ? prefix : [prefix];
- if (!browser)
- return console.log(prefixes.map((p) => `[${p}]`).join(" "), ...args);
- const prefixesWithMeta = prefixes.map((p) => ({
- prefix: p,
- bgColor: randomColorFromStr(p),
- textColor: whiteOrBlack(randomColorFromStr(p)),
- }));
-
- console.log(
- `%c${prefixesWithMeta.map(({ prefix }) => prefix).join(" %c")}`,
- ...prefixesWithMeta.map(
- ({ bgColor, textColor }, i) =>
- `color: ${textColor}; background-color: ${bgColor}; margin-left: ${i === 0 ? 0 : -6}px; padding: 0px 4px 0 4px; border-radius: 0px 9999px 9999px 0px;`,
- ),
- ...args,
- );
-};
-
-export const error = (prefix: string | string[], ...args: any[]) => {
- const prefixes = Array.isArray(prefix) ? prefix : [prefix];
- if (!browser)
- return console.error(prefixes.map((p) => `[${p}]`).join(" "), ...args);
- const prefixesWithMeta = prefixes.map((p) => ({
- prefix: p,
- bgColor: randomColorFromStr(p),
- textColor: whiteOrBlack(randomColorFromStr(p)),
- }));
-
- console.error(
- `%c${prefixesWithMeta.map(({ prefix }) => prefix).join(" %c")}`,
- ...prefixesWithMeta.map(
- ({ bgColor, textColor }, i) =>
- `color: ${textColor}; background-color: ${bgColor}; margin-left: ${i === 0 ? 0 : -6}px; padding: 0px 4px 0 4px; border-radius: 0px 9999px 9999px 0px;`,
- ),
- ...args,
- );
-};
diff --git a/src/lib/util/settings.ts b/src/lib/util/settings.ts
index 28888e8..0e1878f 100644
--- a/src/lib/util/settings.ts
+++ b/src/lib/util/settings.ts
@@ -1,5 +1,5 @@
import { browser } from "$app/environment";
-import { error } from "$lib/util/logger";
+import { error } from "$lib/util/logger.svelte";
export function readSettings<
T extends object = Record<string, unknown>,
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 1036cd7..187d255 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -24,7 +24,11 @@
import { converters } from "$lib/converters";
import { ToastManager } from "$lib/util/toast.svelte";
import { m } from "$lib/paraglide/messages";
- import { log } from "$lib/util/logger";
+ import {
+ addLog,
+ installConsoleCapture,
+ log,
+ } from "$lib/util/logger.svelte";
let { children } = $props();
let enablePlausible = $state(false);
@@ -68,6 +72,17 @@
};
onMount(() => {
+ // captures console output for debugging page
+ installConsoleCapture();
+
+ // catch global errors and unhandled promise rejections for debugging page
+ const handleGlobalError = (event: ErrorEvent) =>
+ addLog("error", ["window"], event.message);
+ const handleUnhandledRejection = (event: PromiseRejectionEvent) =>
+ addLog("error", ["window", "unhandledrejection"], event.reason);
+ window.addEventListener("error", handleGlobalError);
+ window.addEventListener("unhandledrejection", handleUnhandledRejection);
+
const now = new Date();
isAprilFools = now.getDate() === 1 && now.getMonth() === 3;
@@ -106,6 +121,11 @@
return () => {
window.removeEventListener("paste", handlePaste);
window.removeEventListener("resize", handleResize);
+ window.removeEventListener("error", handleGlobalError);
+ window.removeEventListener(
+ "unhandledrejection",
+ handleUnhandledRejection,
+ );
};
});
diff --git a/src/routes/about/+page.svelte b/src/routes/about/+page.svelte
index 367547c..7553b05 100644
--- a/src/routes/about/+page.svelte
+++ b/src/routes/about/+page.svelte
@@ -1,5 +1,5 @@
<script lang="ts">
- import { error } from "$lib/util/logger";
+ import { error } from "$lib/util/logger.svelte";
import * as About from "$lib/sections/about";
import { InfoIcon } from "@lucide/svelte";
import { onMount } from "svelte";
diff --git a/src/routes/debug/+page.svelte b/src/routes/debug/+page.svelte
new file mode 100644
index 0000000..f518734
--- /dev/null
+++ b/src/routes/debug/+page.svelte
@@ -0,0 +1,551 @@
+<script lang="ts">
+ import Panel from "$lib/components/visual/Panel.svelte";
+ import Dropdown from "$lib/components/functional/Dropdown.svelte";
+ import {
+ BugIcon,
+ ClipboardCopyIcon,
+ CpuIcon,
+ DatabaseIcon,
+ DownloadIcon,
+ ExternalLinkIcon,
+ HardDriveIcon,
+ InfoIcon,
+ MonitorSmartphoneIcon,
+ RefreshCwIcon,
+ RulerIcon,
+ SearchIcon,
+ TerminalIcon,
+ TrashIcon,
+ WifiIcon,
+ WrenchIcon,
+ } from "@lucide/svelte";
+ import clsx from "clsx";
+ import type { Component } from "svelte";
+ import { browser } from "$app/environment";
+ import { onMount } from "svelte";
+ import { PUB_ENV } from "$env/static/public";
+ import { effects } from "$lib/store/index.svelte";
+ import { ToastManager } from "$lib/util/toast.svelte";
+ import { swManager, type CacheInfo } from "$lib/util/sw";
+ import { DISABLE_ALL_EXTERNAL_REQUESTS } from "$lib/util/consts";
+ import {
+ buildReport,
+ downloadText,
+ filterLogs,
+ formatFileStamp,
+ getConverterList,
+ getLogLevelOptions,
+ getStatusLabels,
+ getStorageInfo,
+ getSystemInfo,
+ STATUS_CLASSES,
+ type SystemInfo,
+ } from "$lib/util/debug.svelte";
+ import {
+ clearLogs,
+ error as logError,
+ logs,
+ } from "$lib/util/logger.svelte";
+ import { m } from "$lib/paraglide/messages";
+
+ let logQuery = $state("");
+ let logLevel = $state("all");
+
+ const logLevelOptions = $derived(getLogLevelOptions());
+
+ const filteredLogs = $derived(filterLogs(logs.entries, logLevel, logQuery));
+
+ let systemInfo = $state<SystemInfo>({
+ cores: "-",
+ memory: "-",
+ platform: "-",
+ screen: "-",
+ });
+
+ let cacheInfo = $state<CacheInfo | null>(null);
+ let storageEstimate = $state<{ usage: number; quota: number } | null>(null);
+ let swRegistered = $state(false);
+ let swControlled = $state(false);
+
+ const quotaPercent = $derived(
+ storageEstimate && storageEstimate.quota > 0
+ ? Math.min(
+ 100,
+ (storageEstimate.usage / storageEstimate.quota) * 100,
+ )
+ : 0,
+ );
+
+ const converterList = $derived(getConverterList());
+ const statusLabels = $derived(getStatusLabels());
+ const statusClasses = STATUS_CLASSES;
+
+ function clearLogsHandler() {
+ clearLogs();
+ ToastManager.add({
+ type: "success",
+ message: m["settings.debug.logs.cleared"](),
+ });
+ }
+
+ async function refresh() {
+ await loadStorage();
+ systemInfo = getSystemInfo();
+ }
+
+ async function copyReport() {
+ try {
+ await navigator.clipboard.writeText(buildReport(systemInfo));
+ ToastManager.add({
+ type: "success",
+ message: m["settings.debug.tools.report_copied"](),
+ });
+ } catch (err) {
+ logError(["debug", "report"], `failed to copy report: ${err}`);
+ ToastManager.add({
+ type: "error",
+ message: m["settings.debug.tools.report_copy_error"](),
+ });
+ }
+ }
+
+ function downloadReport() {
+ downloadText(
+ `vert-report-${formatFileStamp()}.txt`,
+ buildReport(systemInfo),
+ );
+ ToastManager.add({
+ type: "success",
+ message: m["settings.debug.tools.report_downloaded"](),
+ });
+ }
+
+ async function loadStorage() {
+ const info = await getStorageInfo();
+ cacheInfo = info.cacheInfo;
+ storageEstimate = info.storageEstimate;
+ swRegistered = info.swRegistered;
+ swControlled = info.swControlled;
+ }
+
+ onMount(() => {
+ if (!browser) return;
+
+ systemInfo = getSystemInfo();
+ void loadStorage();
+ });
+</script>
+
+<div class="flex flex-col h-full items-center">
+ <h1 class="hidden md:block text-[40px] tracking-tight leading-[72px] mb-6">
+ <BugIcon size="40" class="inline-block -mt-2 mr-2" />
+ {m["settings.debug.title"]()}
+ </h1>
+
+ <div
+ class="w-full max-w-[1280px] flex flex-col md:flex-row gap-4 p-4 md:px-4 md:py-0"
+ >
+ <!-- left side -->
+ <div class="flex flex-col gap-4 flex-1 min-w-0">
+ <!-- logs -->
+ <Panel class="flex flex-col gap-8 p-6 min-w-0">
+ <div class="flex flex-col gap-4 min-w-0">
+ <h2 class="text-2xl font-bold">
+ <TerminalIcon
+ size="40"
+ class="inline-block -mt-1 mr-2 bg-accent-blue p-2 rounded-full"
+ color="black"
+ />
+ {m["settings.debug.logs.title"]()}
+ </h2>
+
+ <div class="flex flex-col sm:flex-row gap-3">
+ <div class="relative flex flex-1">
+ <input
+ type="text"
+ placeholder={m[
+ "settings.debug.logs.search_placeholder"
+ ]()}
+ class="flex-grow w-full !pl-11 !pr-3 rounded-lg bg-panel text-foreground"
+ bind:value={logQuery}
+ autocomplete="off"
+ />
+ <span
+ class="absolute left-4 top-1/2 -translate-y-1/2 flex items-center"
+ >
+ <SearchIcon class="w-4 h-4" />
+ </span>
+ {#if logQuery}
+ <span
+ class="absolute right-2 top-1/2 -translate-y-1/2 text-xs text-muted"
+ style="font-size: 0.7rem;"
+ >
+ {filteredLogs.length}
+ {filteredLogs.length === 1
+ ? "result"
+ : "results"}
+ </span>
+ {/if}
+ </div>
+ <div class="w-full sm:w-44">
+ <Dropdown
+ options={logLevelOptions}
+ style="settings"
+ bind:selected={logLevel}
+ />
+ </div>
+ </div>
+
+ <div
+ class="rounded-lg border-2 border-button overflow-hidden"
+ >
+ <div
+ class="flex items-center justify-between px-3 py-2 bg-button"
+ >
+ <span
+ class="text-xs font-bold uppercase tracking-wide text-muted"
+ >
+ <TerminalIcon
+ size="14"
+ class="inline-block mr-1 -mt-0.5"
+ />
+ {m["settings.debug.logs.title"]()}
+ </span>
+ <span class="text-xs text-muted">
+ {m["settings.debug.logs.count"]({
+ count: filteredLogs.length,
+ })}
+ </span>
+ </div>
+ <div
+ class="h-72 overflow-auto font-mono text-xs leading-relaxed"
+ >
+ <div class="flex flex-col w-max min-w-full h-full">
+ {#each filteredLogs as entry (entry.id)}
+ <div
+ class="flex gap-2 px-3 py-1.5 border-b border-separator hover:bg-panel-highlight whitespace-nowrap"
+ >
+ <span class="shrink-0 text-muted"
+ >{entry.time}</span
+ >
+ <span
+ class={clsx(
+ "shrink-0 font-bold uppercase",
+ entry.level === "error"
+ ? "text-failure"
+ : "text-muted",
+ )}
+ >
+ {entry.level}
+ </span>
+ <span class="shrink-0 text-accent">
+ [{entry.prefixes.join("] [")}]
+ </span>
+ <span class="whitespace-pre"
+ >{entry.message}</span
+ >
+ </div>
+ {:else}
+ <div
+ class="flex flex-col items-center justify-center gap-2 h-full text-muted"
+ >
+ <InfoIcon size="20" />
+ {m["settings.debug.logs.empty"]()}
+ </div>
+ {/each}
+ </div>
+ </div>
+ </div>
+
+ <div class="flex flex-col gap-2">
+ <div class="flex flex-wrap gap-3 w-full">
+ {@render logAction(
+ RefreshCwIcon,
+ m["settings.debug.logs.refresh"](),
+ refresh,
+ "flex-1 min-w-[8rem]",
+ )}
+ {@render logAction(
+ TrashIcon,
+ m["settings.debug.logs.clear"](),
+ clearLogsHandler,
+ "flex-1 min-w-[8rem]",
+ )}
+ </div>
+ </div>
+ </div>
+ </Panel>
+
+ <!-- tools -->
+ <Panel class="flex flex-col gap-8 p-6">
+ <div class="flex flex-col gap-4">
+ <h2 class="text-2xl font-bold">
+ <WrenchIcon
+ size="40"
+ class="inline-block -mt-1 mr-2 bg-accent-red p-2 rounded-full"
+ color="black"
+ />
+ {m["settings.debug.tools.title"]()}
+ </h2>
+
+ <div class="flex flex-col gap-3">
+ <div class="flex flex-col gap-1">
+ <p class="text-sm font-bold">
+ {m["settings.debug.tools.report_title"]()}
+ </p>
+ <p class="text-xs text-muted font-normal">
+ {m["settings.debug.tools.report_description"]()}
+ </p>
+ </div>
+ <div class="flex flex-wrap gap-3 w-full">
+ {@render logAction(
+ ClipboardCopyIcon,
+ m["settings.debug.tools.copy_report"](),
+ copyReport,
+ "flex-1 min-w-[8rem]",
+ )}
+ {@render logAction(
+ DownloadIcon,
+ m["settings.debug.tools.download_report"](),
+ downloadReport,
+ "flex-1 min-w-[8rem]",
+ )}
+ </div>
+ </div>
+ </div>
+ </Panel>
+ </div>
+
+ <!-- right side -->
+ <div class="flex flex-col gap-4 flex-1">
+ <!-- system info -->
+ <Panel class="flex flex-col gap-8 p-6">
+ <div class="flex flex-col gap-4">
+ <h2 class="text-2xl font-bold">
+ <CpuIcon
+ size="40"
+ class="inline-block -mt-1 mr-2 bg-accent-purple p-2 rounded-full"
+ color="black"
+ />
+ {m["settings.debug.system.title"]()}
+ </h2>
+ <div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
+ {@render infoRow(
+ CpuIcon,
+ m["settings.debug.system.cores"](),
+ systemInfo.cores,
+ )}
+ {@render infoRow(
+ DatabaseIcon,
+ m["settings.debug.system.memory"](),
+ systemInfo.memory,
+ )}
+ {@render infoRow(
+ MonitorSmartphoneIcon,
+ m["settings.debug.system.platform"](),
+ systemInfo.platform,
+ )}
+ {@render infoRow(
+ RulerIcon,
+ m["settings.debug.system.screen"](),
+ systemInfo.screen,
+ )}
+ {@render infoRow(
+ HardDriveIcon,
+ m["settings.debug.storage.registration"](),
+ swRegistered
+ ? m["settings.debug.storage.registered"]()
+ : m["settings.debug.system.disabled"](),
+ )}
+ {@render infoRow(
+ WifiIcon,
+ m["settings.debug.storage.controller"](),
+ swControlled
+ ? m["settings.debug.storage.controlled"]()
+ : m["settings.debug.system.disabled"](),
+ )}
+ {@render infoRow(
+ TerminalIcon,
+ m["settings.debug.system.environment"](),
+ PUB_ENV,
+ )}
+ {@render infoRow(
+ ExternalLinkIcon,
+ m["settings.debug.system.external_requests"](),
+ DISABLE_ALL_EXTERNAL_REQUESTS
+ ? m["settings.debug.system.disabled"]()
+ : m["settings.debug.system.enabled"](),
+ )}
+ </div>
+
+ <div class="rounded-lg bg-button p-4 flex flex-col gap-3">
+ <div class="flex items-center justify-between text-sm">
+ <span class="text-muted"
+ >{m[
+ "settings.debug.storage.quota_used"
+ ]()}</span
+ >
+ <span class="font-bold">
+ {#if storageEstimate}
+ {swManager.formatSize(
+ storageEstimate.usage,
+ )}
+ /
+ {swManager.formatSize(
+ storageEstimate.quota,
+ )}
+ {:else}
+ -
+ {/if}
+ </span>
+ </div>
+ <div
+ class="h-2 w-full rounded-full bg-panel overflow-hidden"
+ >
+ <div
+ class="h-full bg-accent-blue transition-all"
+ style="width: {quotaPercent}%"
+ ></div>
+ </div>
+ <span class="text-xs text-muted">
+ {m["settings.debug.storage.quota_available"]()}:
+ {storageEstimate
+ ? swManager.formatSize(
+ Math.max(
+ 0,
+ storageEstimate.quota -
+ storageEstimate.usage,
+ ),
+ )
+ : "-"}
+ </span>
+ </div>
+ <div class="flex flex-col gap-3">
+ <div class="grid grid-cols-2 gap-4">
+ {@render statCard(
+ m["settings.debug.storage.cache_size"](),
+ cacheInfo
+ ? swManager.formatSize(cacheInfo.totalSize)
+ : "-",
+ )}
+ {@render statCard(
+ m["settings.debug.storage.cache_files"](),
+ cacheInfo ? String(cacheInfo.fileCount) : "-",
+ )}
+ </div>
+ </div>
+ </div></Panel
+ >
+
+ <!-- converter info -->
+ <Panel class="flex flex-col gap-8 p-6">
+ <div class="flex flex-col gap-4">
+ <h2 class="text-2xl font-bold">
+ <RefreshCwIcon
+ size="40"
+ class="inline-block -mt-1 mr-2 bg-accent p-2 rounded-full"
+ color="black"
+ />
+ {m["settings.debug.converters.title"]()}
+ </h2>
+ <div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
+ {#each converterList as converter (converter.name)}
+ {@const Icon = converter.icon}
+ <div
+ class="flex flex-col gap-4 rounded-lg bg-button p-4"
+ >
+ <div
+ class="flex items-start justify-between gap-3"
+ >
+ <div
+ class="flex items-center gap-3 min-w-0"
+ >
+ <span
+ class={clsx(
+ "shrink-0 p-2 rounded-lg text-black",
+ converter.accent,
+ )}
+ >
+ <Icon size="20" />
+ </span>
+ <div class="flex flex-col min-w-0">
+ <span
+ class="text-sm font-bold truncate"
+ >{converter.name}</span
+ >
+ <span
+ class="text-xs text-muted truncate"
+ >
+ {converter.category}</span
+ >
+ </div>
+ </div>
+ <span
+ class={clsx(
+ "shrink-0 rounded-full px-2 py-0.5 text-xs font-bold whitespace-nowrap",
+ statusClasses[converter.status] ??
+ "bg-button text-muted",
+ )}
+ >
+ {statusLabels[converter.status] ??
+ converter.status}
+ </span>
+ </div>
+ <div
+ class="flex items-center justify-between gap-2 border-t border-separator pt-3"
+ >
+ <span class="text-xs text-muted"
+ >{m[
+ "settings.debug.converters.formats"
+ ]()}</span
+ >
+ <span class="text-sm font-bold"
+ >{converter.formats}</span
+ >
+ </div>
+ </div>
+ {/each}
+ </div>
+ </div>
+ </Panel>
+ </div>
+ </div>
+</div>
+
+{#snippet logAction(
+ Icon: Component,
+ label: string,
+ onclick: () => void,
+ className = "",
+)}
+ <button
+ {onclick}
+ class={clsx(
+ "btn px-4 rounded-lg text-black dynadark:text-white flex items-center justify-center",
+ $effects ? "" : "!scale-100",
+ className,
+ )}
+ >
+ <Icon size="20" class="mr-2" />
+ {label}
+ </button>
+{/snippet}
+
+{#snippet infoRow(Icon: Component, label: string, value: string)}
+ <div
+ class="flex items-center justify-between gap-3 rounded-lg bg-button p-3"
+ >
+ <span class="flex items-center gap-2 text-sm text-muted min-w-0">
+ <Icon size="18" class="shrink-0" />
+ <span class="truncate">{label}</span>
+ </span>
+ <span class="text-sm font-bold truncate">{value}</span>
+ </div>
+{/snippet}
+
+{#snippet statCard(label: string, value: string)}
+ <div class="bg-button p-4 rounded-lg">
+ <div class="text-sm text-muted">{label}</div>
+ <div class="text-lg font-bold truncate">{value}</div>
+ </div>
+{/snippet}
diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte
index 5e19b69..39255d7 100644
--- a/src/routes/settings/+page.svelte
+++ b/src/routes/settings/+page.svelte
@@ -1,6 +1,6 @@
<script lang="ts">
import { browser } from "$app/environment";
- import { error, log } from "$lib/util/logger";
+ import { error, log } from "$lib/util/logger.svelte";
import * as Settings from "$lib/sections/settings/index.svelte";
import { SettingsIcon } from "@lucide/svelte";
import { onMount } from "svelte";