refactor: run prettier

This commit is contained in:
Maya 2026-05-25 21:29:28 +03:00
parent 35949a6d04
commit c139eae565
No known key found for this signature in database
24 changed files with 583 additions and 524 deletions

View File

@ -1,53 +1,53 @@
<!doctype html>
<html lang="%lang%">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<link rel="apple-touch-icon" href="%sveltekit.assets%/favicon.png" />
<link
rel="apple-touch-startup-image"
href="%sveltekit.assets%/lettermark.jpg"
/>
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta
name="apple-mobile-web-app-status-bar-style"
content="black-translucent"
/>
%sveltekit.head%
<script>
(function () {
// Apply theme before DOM is loaded
let theme = localStorage.getItem("theme");
const prefersDark = window.matchMedia(
"(prefers-color-scheme: dark)",
).matches;
console.log(
`Theme: ${theme || "N/A"}, prefers dark: ${prefersDark}`,
);
if (theme !== "light" && theme !== "dark") {
console.log("Invalid theme, setting to default");
theme = prefersDark ? "dark" : "light";
localStorage.setItem("theme", theme);
}
console.log(`Applying theme: ${theme}`);
document.documentElement.classList.add(theme);
// Lock dark reader if it's set to dark mode
if (theme === "dark") {
const lock = document.createElement("meta");
lock.name = "darkreader-lock";
document.head.appendChild(lock);
}
})();
</script>
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
<!doctype html>
<html lang="%lang%">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<link rel="apple-touch-icon" href="%sveltekit.assets%/favicon.png" />
<link
rel="apple-touch-startup-image"
href="%sveltekit.assets%/lettermark.jpg"
/>
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta
name="apple-mobile-web-app-status-bar-style"
content="black-translucent"
/>
%sveltekit.head%
<script>
(function () {
// Apply theme before DOM is loaded
let theme = localStorage.getItem("theme");
const prefersDark = window.matchMedia(
"(prefers-color-scheme: dark)",
).matches;
console.log(
`Theme: ${theme || "N/A"}, prefers dark: ${prefersDark}`,
);
if (theme !== "light" && theme !== "dark") {
console.log("Invalid theme, setting to default");
theme = prefersDark ? "dark" : "light";
localStorage.setItem("theme", theme);
}
console.log(`Applying theme: ${theme}`);
document.documentElement.classList.add(theme);
// Lock dark reader if it's set to dark mode
if (theme === "dark") {
const lock = document.createElement("meta");
lock.name = "darkreader-lock";
document.head.appendChild(lock);
}
})();
</script>
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>

View File

@ -58,7 +58,8 @@
if (!file) return;
file.conversionSettings.imageSequence = imageSequence;
file.conversionSettings.imageSequenceFPS = imageSequenceFPS;
file.conversionSettings.imageSequenceTransparency = imageSequenceTransparency;
file.conversionSettings.imageSequenceTransparency =
imageSequenceTransparency;
});
const normalize = (str: string) => str.replace(/^\./, "").toLowerCase();

View File

@ -75,7 +75,7 @@
</div>
<h2 class="text-center text-2xl font-semibold mt-4">
{m["upload.uploader.text"]({
action: m["upload.uploader.convert"]()
action: m["upload.uploader.convert"](),
})}
</h2>
</Panel>

View File

@ -19,8 +19,8 @@
<div class="flex flex-col gap-4">
<p class="text-black">
{m["convert.external_warning.text"]({
filename: toast.additional.filename,
})}
filename: toast.additional.filename,
})}
</p>
<div class="flex flex-col gap-2">
<button

View File

@ -38,40 +38,50 @@
<p>{@html sanitize(m["convert.errors.vertd.details.body"]())}</p>
<p>
<span class="text-black dynadark:text-white">
{@html sanitize(m["convert.errors.vertd.details.job_id"]({
jobId: additional.jobId,
}))}
{@html sanitize(
m["convert.errors.vertd.details.job_id"]({
jobId: additional.jobId,
}),
)}
</span>
</p>
<p>
<span class="text-black dynadark:text-white">
{@html sanitize(m["convert.errors.vertd.details.from"]({
from: additional.from,
}))}
{@html sanitize(
m["convert.errors.vertd.details.from"]({
from: additional.from,
}),
)}
</span>
</p>
<p>
<span class="text-black dynadark:text-white">
{@html sanitize(m["convert.errors.vertd.details.to"]({ to: additional.to }))}
{@html sanitize(
m["convert.errors.vertd.details.to"]({ to: additional.to }),
)}
</span>
</p>
<p>
<span class="text-black dynadark:text-white">
{@html sanitize(link(
["view_link"],
m["convert.errors.vertd.details.error_message"](),
[errorBlobUrl || "#"],
{@html sanitize(
link(
["view_link"],
m["convert.errors.vertd.details.error_message"](),
[errorBlobUrl || "#"],
[true],
["text-blue-500 font-normal"],
),
)}
</span>
</p>
<p>
{@html sanitize(
link(
["privacy_link"],
m["convert.errors.vertd.details.footer"](),
"/privacy",
[true],
["text-blue-500 font-normal"],
))}
</span>
</p>
<p>
{@html sanitize(link(
["privacy_link"],
m["convert.errors.vertd.details.footer"](),
"/privacy",
[true],
))}
),
)}
</p>
</div>

View File

@ -37,10 +37,7 @@
{m["footer.discord_server"]()}
</a>
<p></p>
<a
class="hover:underline font-normal"
href="/privacy/"
>
<a class="hover:underline font-normal" href="/privacy/">
{m["footer.privacy_policy"]()}
</a>
{#if commitHash}

View File

@ -1,212 +1,212 @@
<script lang="ts">
import { browser } from "$app/environment";
import { page } from "$app/state";
import { duration, fade } from "$lib/util/animation";
import {
effects,
files,
goingLeft,
setTheme,
} from "$lib/store/index.svelte";
import clsx from "clsx";
import {
InfoIcon,
MoonIcon,
RefreshCw,
SettingsIcon,
SunIcon,
UploadIcon,
type Icon as IconType,
} from "lucide-svelte";
import { quintOut } from "svelte/easing";
import Panel from "../../visual/Panel.svelte";
import Logo from "../../visual/svg/Logo.svelte";
import { beforeNavigate } from "$app/navigation";
import Tooltip from "$lib/components/visual/Tooltip.svelte";
import { m } from "$lib/paraglide/messages";
const items = $derived<
{
name: string;
url: string;
activeMatch: (pathname: string) => boolean;
icon: typeof IconType;
badge?: number;
}[]
>([
{
name: m["navbar.upload"](),
url: "/",
activeMatch: (pathname) => pathname === "/",
icon: UploadIcon,
},
{
name: m["navbar.convert"](),
url: "/convert/",
activeMatch: (pathname) =>
pathname === "/convert/" || pathname === "/convert",
icon: RefreshCw,
badge: files.files.length,
},
{
name: m["navbar.settings"](),
url: "/settings/",
activeMatch: (pathname) => pathname.startsWith("/settings"),
icon: SettingsIcon,
},
{
name: m["navbar.about"](),
url: "/about/",
activeMatch: (pathname) => pathname.startsWith("/about"),
icon: InfoIcon,
},
]);
let links = $state<HTMLAnchorElement[]>([]);
let container = $state<HTMLDivElement>();
let containerRect = $derived(container?.getBoundingClientRect());
let isInitialized = $state(false);
const linkRects = $derived(links.map((l) => l.getBoundingClientRect()));
const selectedIndex = $derived(
items.findIndex((i) => i.activeMatch(page.url.pathname)),
);
const isSecretPage = $derived(selectedIndex === -1);
$effect(() => {
if (containerRect && linkRects.length > 0 && links.length > 0) {
setTimeout(() => {
isInitialized = true;
}, 10);
} else {
isInitialized = false;
}
});
beforeNavigate((e) => {
const oldIndex = items.findIndex((i) =>
i.activeMatch(e.from?.url.pathname || ""),
);
const newIndex = items.findIndex((i) =>
i.activeMatch(e.to?.url.pathname || ""),
);
if (newIndex < oldIndex) {
goingLeft.set(true);
} else {
goingLeft.set(false);
}
});
</script>
{#snippet link(item: (typeof items)[0], index: number)}
{@const Icon = item.icon}
<a
bind:this={links[index]}
href={item.url}
aria-label={item.name}
class={clsx(
"min-w-16 md:min-w-32 h-full relative z-10 rounded-xl flex flex-1 items-center justify-center gap-3 overflow-hidden",
{
"bg-panel-highlight":
item.activeMatch(page.url.pathname) && !browser,
},
)}
draggable={false}
>
<div class="grid grid-rows-1 grid-cols-1">
{#key item.name}
<div
class="w-full row-start-1 col-start-1 h-full flex items-center justify-center gap-3"
in:fade={{
duration,
easing: quintOut,
}}
out:fade={{
duration,
easing: quintOut,
}}
>
<div class="relative">
<Icon />
{#if item.badge}
<div
class="absolute overflow-hidden grid grid-rows-1 grid-cols-1 -top-1 font-display -right-1 w-fit px-1.5 h-4 rounded-full bg-badge text-on-badge font-medium"
style="font-size: 0.7rem;"
transition:fade={{
duration,
easing: quintOut,
}}
>
{#key item.badge}
<div
class="flex items-center justify-center w-full h-full col-start-1 row-start-1"
in:fade={{
duration,
easing: quintOut,
}}
out:fade={{
duration,
easing: quintOut,
}}
>
{item.badge}
</div>
{/key}
</div>
{/if}
</div>
<p
class="font-medium hidden hyphens-auto break-all md:flex min-w-0"
>
{item.name}
</p>
</div>
{/key}
</div>
</a>
{/snippet}
<div bind:this={container}>
<Panel class="max-w-[778px] w-screen h-20 flex items-center gap-3 relative">
{@const linkRect = linkRects.at(selectedIndex) || linkRects[0]}
{#if linkRect && isInitialized}
<div
class="absolute bg-panel-highlight rounded-xl"
style="width: {linkRect.width}px; height: {linkRect.height}px; top: {linkRect.top -
(containerRect?.top || 0)}px; left: {linkRect.left -
(containerRect?.left || 0)}px; opacity: {isSecretPage
? 0
: 1}; {$effects
? `transition: left var(--transition) ${duration}ms, top var(--transition) ${duration}ms, opacity var(--transition) ${duration}ms;`
: ''}"
></div>
{/if}
<a
class="w-28 h-full bg-accent rounded-xl items-center justify-center hidden md:flex"
href="/"
>
<div class="h-5 w-full">
<Logo />
</div>
</a>
{#each items as item, i (item.url)}
{@render link(item, i)}
{/each}
<div class="w-0.5 bg-separator h-full hidden md:flex"></div>
<Tooltip text={m["navbar.toggle_theme"]()} position="right">
<button
onclick={() => {
const isDark =
document.documentElement.classList.contains("dark");
setTheme(isDark ? "light" : "dark");
}}
class="w-14 h-full items-center justify-center hidden md:flex"
>
<SunIcon class="dynadark:hidden block" />
<MoonIcon class="dynadark:block hidden" />
</button>
</Tooltip>
</Panel>
</div>
<script lang="ts">
import { browser } from "$app/environment";
import { page } from "$app/state";
import { duration, fade } from "$lib/util/animation";
import {
effects,
files,
goingLeft,
setTheme,
} from "$lib/store/index.svelte";
import clsx from "clsx";
import {
InfoIcon,
MoonIcon,
RefreshCw,
SettingsIcon,
SunIcon,
UploadIcon,
type Icon as IconType,
} from "lucide-svelte";
import { quintOut } from "svelte/easing";
import Panel from "../../visual/Panel.svelte";
import Logo from "../../visual/svg/Logo.svelte";
import { beforeNavigate } from "$app/navigation";
import Tooltip from "$lib/components/visual/Tooltip.svelte";
import { m } from "$lib/paraglide/messages";
const items = $derived<
{
name: string;
url: string;
activeMatch: (pathname: string) => boolean;
icon: typeof IconType;
badge?: number;
}[]
>([
{
name: m["navbar.upload"](),
url: "/",
activeMatch: (pathname) => pathname === "/",
icon: UploadIcon,
},
{
name: m["navbar.convert"](),
url: "/convert/",
activeMatch: (pathname) =>
pathname === "/convert/" || pathname === "/convert",
icon: RefreshCw,
badge: files.files.length,
},
{
name: m["navbar.settings"](),
url: "/settings/",
activeMatch: (pathname) => pathname.startsWith("/settings"),
icon: SettingsIcon,
},
{
name: m["navbar.about"](),
url: "/about/",
activeMatch: (pathname) => pathname.startsWith("/about"),
icon: InfoIcon,
},
]);
let links = $state<HTMLAnchorElement[]>([]);
let container = $state<HTMLDivElement>();
let containerRect = $derived(container?.getBoundingClientRect());
let isInitialized = $state(false);
const linkRects = $derived(links.map((l) => l.getBoundingClientRect()));
const selectedIndex = $derived(
items.findIndex((i) => i.activeMatch(page.url.pathname)),
);
const isSecretPage = $derived(selectedIndex === -1);
$effect(() => {
if (containerRect && linkRects.length > 0 && links.length > 0) {
setTimeout(() => {
isInitialized = true;
}, 10);
} else {
isInitialized = false;
}
});
beforeNavigate((e) => {
const oldIndex = items.findIndex((i) =>
i.activeMatch(e.from?.url.pathname || ""),
);
const newIndex = items.findIndex((i) =>
i.activeMatch(e.to?.url.pathname || ""),
);
if (newIndex < oldIndex) {
goingLeft.set(true);
} else {
goingLeft.set(false);
}
});
</script>
{#snippet link(item: (typeof items)[0], index: number)}
{@const Icon = item.icon}
<a
bind:this={links[index]}
href={item.url}
aria-label={item.name}
class={clsx(
"min-w-16 md:min-w-32 h-full relative z-10 rounded-xl flex flex-1 items-center justify-center gap-3 overflow-hidden",
{
"bg-panel-highlight":
item.activeMatch(page.url.pathname) && !browser,
},
)}
draggable={false}
>
<div class="grid grid-rows-1 grid-cols-1">
{#key item.name}
<div
class="w-full row-start-1 col-start-1 h-full flex items-center justify-center gap-3"
in:fade={{
duration,
easing: quintOut,
}}
out:fade={{
duration,
easing: quintOut,
}}
>
<div class="relative">
<Icon />
{#if item.badge}
<div
class="absolute overflow-hidden grid grid-rows-1 grid-cols-1 -top-1 font-display -right-1 w-fit px-1.5 h-4 rounded-full bg-badge text-on-badge font-medium"
style="font-size: 0.7rem;"
transition:fade={{
duration,
easing: quintOut,
}}
>
{#key item.badge}
<div
class="flex items-center justify-center w-full h-full col-start-1 row-start-1"
in:fade={{
duration,
easing: quintOut,
}}
out:fade={{
duration,
easing: quintOut,
}}
>
{item.badge}
</div>
{/key}
</div>
{/if}
</div>
<p
class="font-medium hidden hyphens-auto break-all md:flex min-w-0"
>
{item.name}
</p>
</div>
{/key}
</div>
</a>
{/snippet}
<div bind:this={container}>
<Panel class="max-w-[778px] w-screen h-20 flex items-center gap-3 relative">
{@const linkRect = linkRects.at(selectedIndex) || linkRects[0]}
{#if linkRect && isInitialized}
<div
class="absolute bg-panel-highlight rounded-xl"
style="width: {linkRect.width}px; height: {linkRect.height}px; top: {linkRect.top -
(containerRect?.top || 0)}px; left: {linkRect.left -
(containerRect?.left || 0)}px; opacity: {isSecretPage
? 0
: 1}; {$effects
? `transition: left var(--transition) ${duration}ms, top var(--transition) ${duration}ms, opacity var(--transition) ${duration}ms;`
: ''}"
></div>
{/if}
<a
class="w-28 h-full bg-accent rounded-xl items-center justify-center hidden md:flex"
href="/"
>
<div class="h-5 w-full">
<Logo />
</div>
</a>
{#each items as item, i (item.url)}
{@render link(item, i)}
{/each}
<div class="w-0.5 bg-separator h-full hidden md:flex"></div>
<Tooltip text={m["navbar.toggle_theme"]()} position="right">
<button
onclick={() => {
const isDark =
document.documentElement.classList.contains("dark");
setTheme(isDark ? "light" : "dark");
}}
class="w-14 h-full items-center justify-center hidden md:flex"
>
<SunIcon class="dynadark:hidden block" />
<MoonIcon class="dynadark:block hidden" />
</button>
</Tooltip>
</Panel>
</div>

View File

@ -6,7 +6,12 @@ import type {
SettingDefinition,
} from "$lib/types/conversion-settings";
export type WorkerStatus = "not-ready" | "downloading" | "ready" | "partially-ready" | "error";
export type WorkerStatus =
| "not-ready"
| "downloading"
| "ready"
| "partially-ready"
| "error";
export class FormatInfo {
public name: string;
@ -56,7 +61,9 @@ export class Converter {
* Can be overridden per converter for format-specific settings.
* @param input The input file.
*/
public async getAvailableSettings(input?: VertFile): Promise<SettingDefinition[]> {
public async getAvailableSettings(
input?: VertFile,
): Promise<SettingDefinition[]> {
return [];
}
@ -64,7 +71,9 @@ export class Converter {
* Get default settings for a conversion.
* @param input The input file.
*/
public async getDefaultSettings(input?: VertFile): Promise<ConversionSettings> {
public async getDefaultSettings(
input?: VertFile,
): Promise<ConversionSettings> {
const defaults: ConversionSettings = {};
const settings = await this.getAvailableSettings(input);
settings.forEach((setting) => {

View File

@ -1,4 +1,7 @@
import { toArgs, animatedImageFormats } from "$lib/converters/ffmpeg/ffmpeg.codecs";
import {
toArgs,
animatedImageFormats,
} from "$lib/converters/ffmpeg/ffmpeg.codecs";
import type { ConversionSettings } from "$lib/types/conversion-settings";
import { videoFormats } from "../vertd/vertd.svelte";

View File

@ -27,7 +27,7 @@ export const converterCategories = {
video: ["mediabunny", "vertd"],
audio: ["ffmpeg"],
doc: ["pandoc"],
}
};
export function getConverterByFormat(format: string) {
for (const converter of converters) {

View File

@ -1,6 +1,10 @@
<script lang="ts">
import Panel from "$lib/components/visual/Panel.svelte";
import { CONTACT_EMAIL, DISCORD_URL, GITHUB_URL_VERT } from "$lib/util/consts";
import {
CONTACT_EMAIL,
DISCORD_URL,
GITHUB_URL_VERT,
} from "$lib/util/consts";
import { effects } from "$lib/store/index.svelte";
import {
GithubIcon,

View File

@ -48,12 +48,14 @@
</a>
</div>
<p class="text-muted">
{@html sanitize(link(
"discord_link",
m["about.sponsors.description"](),
DISCORD_URL,
true
))}
{@html sanitize(
link(
"discord_link",
m["about.sponsors.description"](),
DISCORD_URL,
true,
),
)}
<span class="inline-block mx-[2px] relative top-[2px]">
<button
id="email"

View File

@ -179,7 +179,8 @@
<div class="flex flex-col gap-2">
<p class="text-base font-bold">
{m["settings.appearance.language.title"]()}
{#if currentLocale !== "en"} (Language){/if}
{#if currentLocale !== "en"}
(Language){/if}
</p>
<p class="text-sm text-muted font-normal italic">
{m["settings.appearance.language.description"]()}

View File

@ -40,11 +40,11 @@
<div class="flex flex-col gap-4">
<div class="flex flex-col gap-2">
<p class="text-base font-bold">
{m["settings.conversion.filename.format"]()}
{m["settings.conversion.filename.format"]()}
</p>
<p class="text-sm text-muted font-normal">
{@html sanitize(
m["settings.conversion.filename.description"](),
m["settings.conversion.filename.description"](),
)}
</p>
</div>
@ -87,7 +87,9 @@
<div class="flex flex-col gap-4">
<div class="flex flex-col gap-2">
<p class="text-base font-bold">
{m["settings.conversion.default_format.label"]()}
{m[
"settings.conversion.default_format.label"
]()}
</p>
<p class="text-sm text-muted font-normal">
{m[
@ -226,7 +228,9 @@
size="24"
class="inline-block mr-2"
/>
{m["settings.conversion.metadata.keep"]()}
{m[
"settings.conversion.metadata.keep"
]()}
</button>
<button
@ -242,7 +246,9 @@
size="24"
class="inline-block mr-2"
/>
{m["settings.conversion.metadata.remove"]()}
{m[
"settings.conversion.metadata.remove"
]()}
</button>
</div>
</div>

View File

@ -76,7 +76,9 @@
m["settings.privacy.site_data.clear_all_data_confirm"](),
[
{
text: m["settings.privacy.site_data.clear_all_data_cancel"](),
text: m[
"settings.privacy.site_data.clear_all_data_cancel"
](),
action: () => {},
},
{
@ -95,7 +97,9 @@
ToastManager.add({
type: "success",
message:
m["settings.privacy.site_data.all_data_cleared"](),
m[
"settings.privacy.site_data.all_data_cleared"
](),
});
} catch (err) {
error(

View File

@ -11,11 +11,11 @@ export interface SettingDefinition {
min?: number;
max?: number;
step?: number;
options?: Array<{ value: any; label: any; }>; // for select/range types
options?: Array<{ value: any; label: any }>; // for select/range types
description?: string;
hasCustomInput?: boolean; // for select types with a "custom" option
customInputKey?: string; // key to use for custom input value in settings object
forceFullWidth?: boolean; // force setting to take up full width (usually grid 2)
forceFullWidth?: boolean; // force setting to take up full width (usually grid 2)
}
export interface ConversionSettings {

View File

@ -1,48 +1,50 @@
import { VertFile } from "./file.svelte";
interface ConvertMessage {
type: "convert";
input: {
file: File;
name: string;
from: string;
to: string;
} | VertFile;
to: string;
conversionSettings: string; // JSON stringified ConversionSettings
}
interface FinishedMessage {
type: "finished";
output: ArrayBufferLike | Uint8Array;
zip?: boolean;
}
interface LoadMessage {
type: "load";
wasm: ArrayBuffer;
}
interface LoadedMessage {
type: "loaded";
}
interface ReadyMessage {
type: "ready";
}
interface ErrorMessage {
type: "error";
error: string;
}
export type WorkerMessage = (
| ConvertMessage
| FinishedMessage
| LoadMessage
| LoadedMessage
| ReadyMessage
| ErrorMessage
) & {
id: string; // unused? rn just using file id, probably meant to be incrementing w/ every message posted?
};
import { VertFile } from "./file.svelte";
interface ConvertMessage {
type: "convert";
input:
| {
file: File;
name: string;
from: string;
to: string;
}
| VertFile;
to: string;
conversionSettings: string; // JSON stringified ConversionSettings
}
interface FinishedMessage {
type: "finished";
output: ArrayBufferLike | Uint8Array;
zip?: boolean;
}
interface LoadMessage {
type: "load";
wasm: ArrayBuffer;
}
interface LoadedMessage {
type: "loaded";
}
interface ReadyMessage {
type: "ready";
}
interface ErrorMessage {
type: "error";
error: string;
}
export type WorkerMessage = (
| ConvertMessage
| FinishedMessage
| LoadMessage
| LoadedMessage
| ReadyMessage
| ErrorMessage
) & {
id: string; // unused? rn just using file id, probably meant to be incrementing w/ every message posted?
};

View File

@ -89,4 +89,4 @@ export const formatBytes = (bytes: number): string => {
}
return `${value.toFixed(value >= 100 ? 0 : value >= 10 ? 1 : 2)} ${units[unitIndex]}`;
};
};

View File

@ -1,150 +1,150 @@
// THIS CODE IS FROM https://github.com/captbaritone/webamp/blob/15b0312cb794973a0e615d894df942452e920c36/packages/ani-cursor/src/parser.ts
// LICENSED UNDER MIT. (c) Jordan Eldredge and Webamp contributors
// this code is ripped from their project because i didn't want to
// re-invent the wheel, BUT the library they provide (ani-cursor)
// doesn't expose the internals.
import { RIFFFile } from "riff-file";
import { unpackArray, unpackString } from "byte-data";
type Chunk = {
format: string;
chunkId: string;
chunkData: {
start: number;
end: number;
};
subChunks: Chunk[];
};
// https://www.informit.com/articles/article.aspx?p=1189080&seqNum=3
type AniMetadata = {
cbSize: number; // Data structure size (in bytes)
nFrames: number; // Number of images (also known as frames) stored in the file
nSteps: number; // Number of frames to be displayed before the animation repeats
iWidth: number; // Width of frame (in pixels)
iHeight: number; // Height of frame (in pixels)
iBitCount: number; // Number of bits per pixel
nPlanes: number; // Number of color planes
iDispRate: number; // Default frame display rate (measured in 1/60th-of-a-second units)
bfAttributes: number; // ANI attribute bit flags
};
type ParsedAni = {
rate: number[] | null;
seq: number[] | null;
images: Uint8Array[];
metadata: AniMetadata;
artist: string | null;
title: string | null;
};
const DWORD = { bits: 32, be: false, signed: false, fp: false };
export function parseAni(arr: Uint8Array): ParsedAni {
const riff = new RIFFFile();
riff.setSignature(arr);
const signature = riff.signature as Chunk;
if (signature.format !== "ACON") {
throw new Error(
`Expected format. Expected "ACON", got "${signature.format}"`,
);
}
// Helper function to get a chunk by chunkId and transform it if it's non-null.
function mapChunk<T>(
chunkId: string,
mapper: (chunk: Chunk) => T,
): T | null {
const chunk = riff.findChunk(chunkId) as Chunk | null;
return chunk == null ? null : mapper(chunk);
}
function readImages(chunk: Chunk, frameCount: number): Uint8Array[] {
return chunk.subChunks.slice(0, frameCount).map((c) => {
if (c.chunkId !== "icon") {
throw new Error(`Unexpected chunk type in fram: ${c.chunkId}`);
}
return arr.slice(c.chunkData.start, c.chunkData.end);
});
}
const metadata = mapChunk("anih", (c) => {
const words = unpackArray(
arr,
DWORD,
c.chunkData.start,
c.chunkData.end,
);
return {
cbSize: words[0],
nFrames: words[1],
nSteps: words[2],
iWidth: words[3],
iHeight: words[4],
iBitCount: words[5],
nPlanes: words[6],
iDispRate: words[7],
bfAttributes: words[8],
};
});
if (metadata == null) {
throw new Error("Did not find anih");
}
const rate = mapChunk("rate", (c) => {
return unpackArray(arr, DWORD, c.chunkData.start, c.chunkData.end);
});
// chunkIds are always four chars, hence the trailing space.
const seq = mapChunk("seq ", (c) => {
return unpackArray(arr, DWORD, c.chunkData.start, c.chunkData.end);
});
const lists = riff.findChunk("LIST", true) as Chunk[] | null;
const imageChunk = lists?.find((c) => c.format === "fram");
if (imageChunk == null) {
throw new Error("Did not find fram LIST");
}
let images = readImages(imageChunk, metadata.nFrames);
let title = null;
let artist = null;
const infoChunk = lists?.find((c) => c.format === "INFO");
if (infoChunk != null) {
infoChunk.subChunks.forEach((c) => {
switch (c.chunkId) {
case "INAM":
title = unpackString(
arr,
c.chunkData.start,
c.chunkData.end,
);
break;
case "IART":
artist = unpackString(
arr,
c.chunkData.start,
c.chunkData.end,
);
break;
case "LIST":
// Some cursors with an artist of "Created with Take ONE 3.5 (unregisterred version)" seem to have their frames here for some reason?
if (c.format === "fram") {
images = readImages(c, metadata.nFrames);
}
break;
default:
// Unexpected subchunk
}
});
}
return { images, rate, seq, metadata, artist, title };
}
// THIS CODE IS FROM https://github.com/captbaritone/webamp/blob/15b0312cb794973a0e615d894df942452e920c36/packages/ani-cursor/src/parser.ts
// LICENSED UNDER MIT. (c) Jordan Eldredge and Webamp contributors
// this code is ripped from their project because i didn't want to
// re-invent the wheel, BUT the library they provide (ani-cursor)
// doesn't expose the internals.
import { RIFFFile } from "riff-file";
import { unpackArray, unpackString } from "byte-data";
type Chunk = {
format: string;
chunkId: string;
chunkData: {
start: number;
end: number;
};
subChunks: Chunk[];
};
// https://www.informit.com/articles/article.aspx?p=1189080&seqNum=3
type AniMetadata = {
cbSize: number; // Data structure size (in bytes)
nFrames: number; // Number of images (also known as frames) stored in the file
nSteps: number; // Number of frames to be displayed before the animation repeats
iWidth: number; // Width of frame (in pixels)
iHeight: number; // Height of frame (in pixels)
iBitCount: number; // Number of bits per pixel
nPlanes: number; // Number of color planes
iDispRate: number; // Default frame display rate (measured in 1/60th-of-a-second units)
bfAttributes: number; // ANI attribute bit flags
};
type ParsedAni = {
rate: number[] | null;
seq: number[] | null;
images: Uint8Array[];
metadata: AniMetadata;
artist: string | null;
title: string | null;
};
const DWORD = { bits: 32, be: false, signed: false, fp: false };
export function parseAni(arr: Uint8Array): ParsedAni {
const riff = new RIFFFile();
riff.setSignature(arr);
const signature = riff.signature as Chunk;
if (signature.format !== "ACON") {
throw new Error(
`Expected format. Expected "ACON", got "${signature.format}"`,
);
}
// Helper function to get a chunk by chunkId and transform it if it's non-null.
function mapChunk<T>(
chunkId: string,
mapper: (chunk: Chunk) => T,
): T | null {
const chunk = riff.findChunk(chunkId) as Chunk | null;
return chunk == null ? null : mapper(chunk);
}
function readImages(chunk: Chunk, frameCount: number): Uint8Array[] {
return chunk.subChunks.slice(0, frameCount).map((c) => {
if (c.chunkId !== "icon") {
throw new Error(`Unexpected chunk type in fram: ${c.chunkId}`);
}
return arr.slice(c.chunkData.start, c.chunkData.end);
});
}
const metadata = mapChunk("anih", (c) => {
const words = unpackArray(
arr,
DWORD,
c.chunkData.start,
c.chunkData.end,
);
return {
cbSize: words[0],
nFrames: words[1],
nSteps: words[2],
iWidth: words[3],
iHeight: words[4],
iBitCount: words[5],
nPlanes: words[6],
iDispRate: words[7],
bfAttributes: words[8],
};
});
if (metadata == null) {
throw new Error("Did not find anih");
}
const rate = mapChunk("rate", (c) => {
return unpackArray(arr, DWORD, c.chunkData.start, c.chunkData.end);
});
// chunkIds are always four chars, hence the trailing space.
const seq = mapChunk("seq ", (c) => {
return unpackArray(arr, DWORD, c.chunkData.start, c.chunkData.end);
});
const lists = riff.findChunk("LIST", true) as Chunk[] | null;
const imageChunk = lists?.find((c) => c.format === "fram");
if (imageChunk == null) {
throw new Error("Did not find fram LIST");
}
let images = readImages(imageChunk, metadata.nFrames);
let title = null;
let artist = null;
const infoChunk = lists?.find((c) => c.format === "INFO");
if (infoChunk != null) {
infoChunk.subChunks.forEach((c) => {
switch (c.chunkId) {
case "INAM":
title = unpackString(
arr,
c.chunkData.start,
c.chunkData.end,
);
break;
case "IART":
artist = unpackString(
arr,
c.chunkData.start,
c.chunkData.end,
);
break;
case "LIST":
// Some cursors with an artist of "Created with Take ONE 3.5 (unregisterred version)" seem to have their frames here for some reason?
if (c.format === "fram") {
images = readImages(c, metadata.nFrames);
}
break;
default:
// Unexpected subchunk
}
});
}
return { images, rate, seq, metadata, artist, title };
}

View File

@ -1,7 +1,9 @@
import { browser } from "$app/environment";
import { error } from "$lib/util/logger";
export function readSettings<T extends object = Record<string, unknown>>(): Partial<T> {
export function readSettings<
T extends object = Record<string, unknown>,
>(): Partial<T> {
if (!browser) return {};
const raw = localStorage.getItem("settings");
@ -20,4 +22,4 @@ export function readSettings<T extends object = Record<string, unknown>>(): Part
localStorage.removeItem("settings");
return {};
}
}
}

View File

@ -279,7 +279,10 @@ const pandocToFiles = (entries: PandocEntries, parent = ""): File[] => {
const nestedFiles = pandocToFiles(entry.entries, fullPath);
flattened.push(...nestedFiles);
} else {
const file = new File([new Uint8Array(Array.from(entry.data))], fullPath);
const file = new File(
[new Uint8Array(Array.from(entry.data))],
fullPath,
);
flattened.push(file);
}
}

View File

@ -3,7 +3,10 @@
import { goto, beforeNavigate, afterNavigate } from "$app/navigation";
import { PUB_PLAUSIBLE_URL, PUB_HOSTNAME } from "$env/static/public";
import { DISABLE_ALL_EXTERNAL_REQUESTS, VERT_NAME } from "$lib/util/consts.js";
import {
DISABLE_ALL_EXTERNAL_REQUESTS,
VERT_NAME,
} from "$lib/util/consts.js";
import * as Layout from "$lib/components/layout";
import * as Navbar from "$lib/components/layout/Navbar";
import { Settings } from "$lib/sections/settings/index.svelte";
@ -96,7 +99,10 @@
// detect if insecure context
if (!window.isSecureContext) {
log(["layout"], "Insecure context (HTTP) detected, some features may not work as expected -- you may want to enable \"PUB_DISABLE_FAILURE_BLOCKS\" on local deployments.");
log(
["layout"],
'Insecure context (HTTP) detected, some features may not work as expected -- you may want to enable "PUB_DISABLE_FAILURE_BLOCKS" on local deployments.',
);
ToastManager.add({
type: "warning",
message: m["toast.insecure_context"](),
@ -155,7 +161,10 @@
property="twitter:description"
content="With VERT, you can quickly convert any image, video, audio, and document file. No ads, no tracking, open source, and all processing is done on your device."
/>
<meta property="twitter:image" content="https://vert.sh/VERT_Feature.webp" />
<meta
property="twitter:image"
content="https://vert.sh/VERT_Feature.webp"
/>
<link rel="manifest" href="/manifest.json" />
<link rel="canonical" href="https://vert.sh/" />
{#if enablePlausible}

View File

@ -37,7 +37,10 @@
link(
["about_link", "stripe_link"],
m["privacy.donations.description"](),
["/about", "https://stripe.com/docs/disputes/prevention/advanced-fraud-detection"],
[
"/about",
"https://stripe.com/docs/disputes/prevention/advanced-fraud-detection",
],
[false, true],
),
)}

View File

@ -26,7 +26,10 @@
}
const parsedSettings = readSavedSettings();
if (parsedSettings && JSON.stringify(parsedSettings) === JSON.stringify(settings))
if (
parsedSettings &&
JSON.stringify(parsedSettings) === JSON.stringify(settings)
)
return;
try {