decord/alpha/source/lib/uploader/imageFilename.tsx
2026-10-12 06:59:38 +00:00

93 lines
2.5 KiB
TypeScript

// Module ID: 7788
// Function ID: 7789
// Name: imageFilename
// Dependencies: [2]
// Exports: heicMimeType, isHeicFile, isJxrFile, jxrMimeType, renameToJpegExtension
// Module 7788 (imageFilename)
import size from "module_2" /* 2 */;
const set = new Set(["image/heic", "image/heif", "image/heic-sequence", "image/heif-sequence"]);
const set1 = new Set([".heic", ".heif", ".hif"]);
const re2 = /\.(heic|heif|hif)$/i;
const set2 = new Set(["image/jxr", "image/vnd.ms-photo"]);
const set3 = new Set([".jxr", ".wdp", ".hdp"]);
const re5 = /\.(jxr|wdp|hdp)$/i;
const result = size.fileFinishedImporting("lib/uploader/imageFilename.tsx");
export const isHeicFile = function isHeicFile(type) {
if (set.has(type.type)) {
return true;
} else {
let str = "";
if (typeof type.name === "string") {
str = type.name;
}
const lastIndexOfResult = str.lastIndexOf(".");
let formatted = null;
if (lastIndexOfResult >= 0) {
const str3 = str.slice(lastIndexOfResult);
formatted = str3.toLowerCase();
}
const hasItem = null != formatted && set1.has(formatted);
return hasItem;
}
};
export const isJxrFile = function isJxrFile(file) {
if (set2.has(file.type)) {
return true;
} else {
let str = "";
if (typeof file.name === "string") {
str = file.name;
}
const lastIndexOfResult = str.lastIndexOf(".");
let formatted = null;
if (lastIndexOfResult >= 0) {
const str3 = str.slice(lastIndexOfResult);
formatted = str3.toLowerCase();
}
const hasItem = null != formatted && set3.has(formatted);
return hasItem;
}
};
export const heicMimeType = function heicMimeType(file) {
let str3;
let str = "";
if ("" !== file.type) {
str3 = file.type;
} else {
if (typeof file.name === "string") {
str = file.name;
}
const formatted = str.toLowerCase();
str3 = "image/heif";
if (formatted.endsWith(".heic")) {
str3 = "image/heic";
}
}
return str3;
};
export const jxrMimeType = function jxrMimeType(file) {
let str = "image/jxr";
if ("" !== file.type) {
str = file.type;
}
return str;
};
export const renameToJpegExtension = function renameToJpegExtension(name) {
let replaced;
const tmp = re2;
if (re2.test(name)) {
replaced = name.replace(tmp, ".jpg");
} else {
const tmp2 = re5;
if (re5.test(name)) {
replaced = name.replace(tmp2, ".jpg");
} else {
const _HermesInternal = HermesInternal;
replaced = "" + name + ".jpg";
}
}
return replaced;
};