mirror of
https://github.com/CaramelFur/Picsur.git
synced 2026-05-07 05:07:40 +02:00
Add frontend qoi rendering
This commit is contained in:
33
shared/src/dto/mimes.dto.ts
Normal file
33
shared/src/dto/mimes.dto.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
// Config
|
||||
export enum ImageMime {
|
||||
JPEG = 'image/jpeg',
|
||||
PNG = 'image/png',
|
||||
WEBP = 'image/webp',
|
||||
TIFF = 'image/tiff',
|
||||
BMP = 'image/bmp',
|
||||
ICO = 'image/x-icon',
|
||||
}
|
||||
|
||||
export enum AnimMime {
|
||||
APNG = 'image/apng',
|
||||
GIF = 'image/gif',
|
||||
}
|
||||
|
||||
export const SupportedMime = { ...ImageMime, ...AnimMime };
|
||||
|
||||
// Derivatives
|
||||
|
||||
export const SupportedImageMimes: string[] = Object.values(ImageMime);
|
||||
export const SupportedAnimMimes: string[] = Object.values(AnimMime);
|
||||
export const SupportedMimes: string[] = Object.values(SupportedMime);
|
||||
|
||||
export enum SupportedMimeCategory {
|
||||
Image = 'image',
|
||||
Animation = 'anim',
|
||||
}
|
||||
|
||||
export interface FullMime {
|
||||
mime: string;
|
||||
type: SupportedMimeCategory;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
export const AlphaNumeric = /^[a-zA-Z0-9]+$/;
|
||||
export const SHA256 = /^[a-f0-9A-F]{64}$/;
|
||||
export const SemVer = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
||||
export const URLRegex =
|
||||
/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/;
|
||||
|
||||
12
shared/src/util/parse-mime.ts
Normal file
12
shared/src/util/parse-mime.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { FullMime, SupportedAnimMimes, SupportedImageMimes, SupportedMimeCategory } from '../dto/mimes.dto';
|
||||
import { Fail, Failable } from '../types';
|
||||
|
||||
export function ParseMime(mime: string): Failable<FullMime> {
|
||||
if (SupportedImageMimes.includes(mime)) {
|
||||
return { mime, type: SupportedMimeCategory.Image };
|
||||
}
|
||||
if (SupportedAnimMimes.includes(mime)) {
|
||||
return { mime, type: SupportedMimeCategory.Animation };
|
||||
}
|
||||
return Fail('Unsupported mime type');
|
||||
}
|
||||
Reference in New Issue
Block a user