decord/source/modules/media_uploads/native/ImageConversionDecision.tsx

139 lines
3.7 KiB
TypeScript
Raw Normal View History

// Module ID: 5243
// Function ID: 5244
// Name: ImageConversionDecision
// Dependencies: [1364, 5244, 2]
2026-07-29 08:29:29 +00:00
// Exports: isHeicUTI, isPhotoKitAsset, shouldConvertToJPG, shouldForceConvertToJPG
2026-07-20 16:05:17 +00:00
// Module 5243 (ImageConversionDecision)
import PlatformUtils from "PlatformUtils" /* 1364 */;
import IosImageTypesManagerDefault from "IosImageTypesManager" /* 5244 */;
import size from "module_2" /* 2 */;
2026-07-29 08:29:29 +00:00
const result = size.fileFinishedImporting("modules/media_uploads/native/ImageConversionDecision.tsx");
2026-08-24 06:08:38 +00:00
export const isPhotoKitAsset = function isPhotoKitAsset(str, arg1) {
let tmp = null != str.match(/^ph:\/\//i);
2026-07-20 16:05:17 +00:00
if (tmp) {
tmp = null != arg1;
2026-07-20 16:05:17 +00:00
}
return tmp;
2026-07-29 08:29:29 +00:00
};
export const isHeicUTI = function isHeicUTI(str) {
2026-07-20 16:05:17 +00:00
if (null == str) {
return false;
} else {
const formatted = str.toLowerCase();
let hasItem = formatted.includes("heic");
if (!hasItem) {
hasItem = formatted.includes("heif");
}
return hasItem;
}
2026-07-29 08:29:29 +00:00
};
export const shouldForceConvertToJPG = function shouldForceConvertToJPG(str, str2, str3) {
let isIOSResult = PlatformUtils.isIOS();
2026-07-29 08:29:29 +00:00
if (isIOSResult) {
let flag = false;
if (null != str3) {
const formatted = str3.toLowerCase();
2026-07-29 08:29:29 +00:00
let hasItem = formatted.includes("heic");
if (!hasItem) {
hasItem = formatted.includes("heif");
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
flag = hasItem;
}
if (flag) {
isIOSResult = tmp5;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
if (tmp8) {
let match;
if (str2 != null) {
match = str2.match(/\.HEI[CF]$/i);
2026-07-29 08:29:29 +00:00
}
let tmp9 = null != match;
} else {
tmp9 = null != str.match(/^(assets-library|file):\/\/.+(&ext=|\.)(HEI[CF])$/i);
2026-07-29 08:29:29 +00:00
}
tmp8 = null != str.match(/^ph:\/\//i) && null != str2;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
return isIOSResult;
2026-07-20 16:05:17 +00:00
};
export const shouldConvertToJPG = function shouldConvertToJPG(str, arr, arg2, arg3, arg4) {
let flag = arg4;
if (arg4 === undefined) {
2026-07-20 16:05:17 +00:00
flag = true;
}
if (obj.isIOS()) {
2026-07-29 08:29:29 +00:00
let num;
if (arr != null) {
num = arr.lastIndexOf(".");
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (num == null) {
num = -1;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (-1 !== num) {
const formatted = arr.substring(num + 1).toLowerCase();
const str2 = arr.substring(num + 1);
2026-07-20 16:05:17 +00:00
}
const match = str.match;
2026-07-20 16:05:17 +00:00
if (flag) {
2026-07-29 08:29:29 +00:00
if (tmp8) {
2026-07-20 16:05:17 +00:00
if (null == formatted) {
return false;
} else {
if ("png" === formatted) {
if (arg3) {
2026-07-20 16:05:17 +00:00
return true;
} else if (arg2) {
2026-07-20 16:05:17 +00:00
return true;
}
} else {
if (obj2.isExtensionAnimated(formatted)) {
return false;
} else {
const supportedExtensions = tmp14(5244).getSupportedExtensions();
2026-07-20 16:05:17 +00:00
if (null !== supportedExtensions) {
if (supportedExtensions.has(formatted)) {
return true;
}
}
const tmp14Result = tmp14(5244);
2026-07-20 16:05:17 +00:00
}
obj2 = IosImageTypesManagerDefault;
2026-07-29 08:29:29 +00:00
tmp14 = importDefault;
2026-07-20 16:05:17 +00:00
}
return false;
}
} else {
let tmp11 = null != str.match(/^(assets-library|file):\/\/.+(&ext=|\.)(hei[cf]|jpe?g|dng)$/i);
2026-07-29 08:29:29 +00:00
if (!tmp11) {
let tmp12 = null == str.match(/^(assets-library|file):\/\/.+(&ext=|\.)png$/i);
2026-07-29 08:29:29 +00:00
if (!tmp12) {
let tmp13 = !arg2;
if (!arg2) {
tmp13 = !arg3;
2026-07-29 08:29:29 +00:00
}
tmp12 = tmp13;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp11 = !tmp12;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp11;
2026-07-20 16:05:17 +00:00
}
tmp8 = null != match(/^ph:\/\//i) && null != arr;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
let tmp7 = "heic" === formatted;
if (!tmp7) {
tmp7 = "heif" === formatted;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (!tmp7) {
tmp7 = tmp6;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp7;
2026-07-20 16:05:17 +00:00
}
} else {
return false;
}
obj = PlatformUtils;
2026-07-20 16:05:17 +00:00
};