chore: fix pre-existing biome formatting issues

This commit is contained in:
ashim-hq
2026-04-21 23:25:41 +08:00
parent afac4b9870
commit 7920fbfd20
5 changed files with 33 additions and 18 deletions
+3 -5
View File
@@ -70,11 +70,9 @@ async function decodeIco(buffer: Buffer): Promise<Buffer> {
try { try {
await writeFile(inputPath, buffer); await writeFile(inputPath, buffer);
// ICO contains multiple sizes; extract the largest by sorting // ICO contains multiple sizes; extract the largest by sorting
await execFileAsync( await execFileAsync(cmd, magickArgs(cmd, [`${inputPath}[-1]`, `png:${outputPath}`]), {
cmd, timeout: 120_000,
magickArgs(cmd, [`${inputPath}[-1]`, `png:${outputPath}`]), });
{ timeout: 120_000 },
);
return await readFile(outputPath); return await readFile(outputPath);
} finally { } finally {
await rm(inputPath, { force: true }).catch(() => {}); await rm(inputPath, { force: true }).catch(() => {});
+15 -8
View File
@@ -1,14 +1,21 @@
import { formatHeaders } from "@/lib/api"; import { formatHeaders } from "@/lib/api";
const SERVER_PREVIEW_EXTENSIONS = new Set([ const SERVER_PREVIEW_EXTENSIONS = new Set([
"heic", "heif", "hif", // HEIF "heic",
"jxl", // JPEG XL (Chrome dropped support) "heif",
"ico", // ICO (Sharp can't decode) "hif", // HEIF
"dng", "cr2", "nef", "arw", "orf", "rw2", // Camera RAW "jxl", // JPEG XL (Chrome dropped support)
"tga", // Targa "ico", // ICO (Sharp can't decode)
"psd", // Photoshop "dng",
"exr", // OpenEXR "cr2",
"hdr", // Radiance HDR "nef",
"arw",
"orf",
"rw2", // Camera RAW
"tga", // Targa
"psd", // Photoshop
"exr", // OpenEXR
"hdr", // Radiance HDR
]); ]);
export function needsServerPreview(file: File): boolean { export function needsServerPreview(file: File): boolean {
+2 -1
View File
@@ -250,7 +250,8 @@ export function ToolPage() {
const input = document.createElement("input"); const input = document.createElement("input");
input.type = "file"; input.type = "file";
input.multiple = true; input.multiple = true;
input.accept = "image/*,.heic,.heif,.hif,.jxl,.dng,.cr2,.nef,.arw,.orf,.rw2,.tga,.psd,.exr,.hdr"; input.accept =
"image/*,.heic,.heif,.hif,.jxl,.dng,.cr2,.nef,.arw,.orf,.rw2,.tga,.psd,.exr,.hdr";
input.onchange = (e) => { input.onchange = (e) => {
const newFiles = Array.from((e.target as HTMLInputElement).files || []); const newFiles = Array.from((e.target as HTMLInputElement).files || []);
if (newFiles.length > 0) addFiles(newFiles); if (newFiles.length > 0) addFiles(newFiles);
@@ -22,9 +22,9 @@ export async function compress(image: Sharp, options: CompressOptions): Promise<
const metadata = await image.metadata(); const metadata = await image.metadata();
const detected = metadata.format ?? "jpeg"; const detected = metadata.format ?? "jpeg";
const outputFormat = ( const outputFormat = (FORMAT_MAP[format ?? ""] ??
FORMAT_MAP[format ?? ""] ?? FORMAT_MAP[detected] ?? detected FORMAT_MAP[detected] ??
) as keyof import("sharp").FormatEnum; detected) as keyof import("sharp").FormatEnum;
if (targetSizeBytes !== undefined) { if (targetSizeBytes !== undefined) {
if (targetSizeBytes <= 0) { if (targetSizeBytes <= 0) {
+10 -1
View File
@@ -17,7 +17,16 @@ export interface OperationResult {
info: ImageInfo; info: ImageInfo;
} }
export type OutputFormat = "jpg" | "png" | "webp" | "avif" | "tiff" | "gif" | "heic" | "heif" | "jxl"; export type OutputFormat =
| "jpg"
| "png"
| "webp"
| "avif"
| "tiff"
| "gif"
| "heic"
| "heif"
| "jxl";
export interface ResizeOptions { export interface ResizeOptions {
width?: number; width?: number;