2021-01-14 18:07:05 +00:00
|
|
|
// Copyright 2018-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-04-13 21:54:53 +00:00
|
|
|
import * as MIME from '../types/MIME';
|
2018-04-09 23:27:40 +00:00
|
|
|
|
2021-01-14 18:07:05 +00:00
|
|
|
type MIMETypeSupportMap = Record<string, boolean>;
|
2018-04-09 23:27:40 +00:00
|
|
|
|
|
|
|
// See: https://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support
|
|
|
|
const SUPPORTED_IMAGE_MIME_TYPES: MIMETypeSupportMap = {
|
|
|
|
'image/bmp': true,
|
|
|
|
'image/gif': true,
|
|
|
|
'image/jpeg': true,
|
2018-06-16 00:49:35 +00:00
|
|
|
// No need to support SVG
|
|
|
|
'image/svg+xml': false,
|
2018-04-09 23:27:40 +00:00
|
|
|
'image/webp': true,
|
|
|
|
'image/x-xbitmap': true,
|
|
|
|
// ICO
|
|
|
|
'image/vnd.microsoft.icon': true,
|
|
|
|
'image/ico': true,
|
|
|
|
'image/icon': true,
|
|
|
|
'image/x-icon': true,
|
|
|
|
// PNG
|
|
|
|
'image/apng': true,
|
|
|
|
'image/png': true,
|
|
|
|
};
|
|
|
|
|
|
|
|
export const isImageTypeSupported = (mimeType: MIME.MIMEType): boolean =>
|
2018-04-13 20:25:52 +00:00
|
|
|
SUPPORTED_IMAGE_MIME_TYPES[mimeType] === true;
|
2018-04-09 23:27:40 +00:00
|
|
|
|
|
|
|
const SUPPORTED_VIDEO_MIME_TYPES: MIMETypeSupportMap = {
|
|
|
|
'video/mp4': true,
|
|
|
|
'video/ogg': true,
|
|
|
|
'video/webm': true,
|
|
|
|
};
|
|
|
|
|
|
|
|
// See: https://www.chromium.org/audio-video
|
|
|
|
export const isVideoTypeSupported = (mimeType: MIME.MIMEType): boolean =>
|
2018-04-13 20:25:52 +00:00
|
|
|
SUPPORTED_VIDEO_MIME_TYPES[mimeType] === true;
|