decord/source/modules/image_proxy/ImageProxyUtils.tsx

65 lines
2 KiB
TypeScript
Raw Normal View History

2026-07-28 08:39:19 +00:00
// Module ID: 4196
// Function ID: 35262
2026-07-20 16:05:17 +00:00
// Name: isImageProxyURL
2026-07-23 10:11:24 +00:00
// Dependencies: [1443, 1426, 2]
2026-07-20 16:05:17 +00:00
// Exports: getSizedImageProxyURL
2026-07-28 08:39:19 +00:00
// Module 4196 (isImageProxyURL)
2026-07-23 10:11:24 +00:00
import set from "set";
2026-07-20 16:05:17 +00:00
function isImageProxyURL(hostname) {
const tmp = !set.has(hostname.hostname);
let startsWithResult = !tmp;
if (!tmp) {
const pathname = hostname.pathname;
startsWithResult = pathname.startsWith("/external/");
}
return startsWithResult;
}
let parts;
if (null != window.GLOBAL_ENV.IMAGE_PROXY_ENDPOINTS) {
parts = str.split(",");
}
if (null == parts) {
parts = [];
}
const mapped = parts.map((str) => str.substring(2));
const mapped1 = mapped.map(function getHostWithoutPort(arg0) {
let first;
if (null != arg0) {
first = arg0.split(":")[0];
}
return first;
});
2026-07-23 10:11:24 +00:00
let set = new Set(mapped1.filter(Boolean));
let result = set.fileFinishedImporting("modules/image_proxy/ImageProxyUtils.tsx");
2026-07-20 16:05:17 +00:00
export { isImageProxyURL };
export const getSizedImageProxyURL = function getSizedImageProxyURL(value, arg1) {
let keepAspectRatio;
let size;
({ size, keepAspectRatio } = arg1);
2026-07-23 10:11:24 +00:00
const str = importDefault(1443).toURLSafe(value);
2026-07-20 16:05:17 +00:00
if (null != str) {
if (isImageProxyURL(str)) {
if (null != size) {
const _String = String;
2026-07-23 10:11:24 +00:00
const obj2 = require(1426) /* isAttachmentLadderEnabled */;
const StringResult = String(obj2.getBestMediaProxySize(size * require(1426) /* isAttachmentLadderEnabled */.getDevicePixelRatio()));
2026-07-20 16:05:17 +00:00
const searchParams = str.searchParams;
const result = searchParams.set("width", StringResult);
const searchParams2 = str.searchParams;
const result1 = searchParams2.set("height", StringResult);
2026-07-23 10:11:24 +00:00
const obj3 = require(1426) /* isAttachmentLadderEnabled */;
2026-07-20 16:05:17 +00:00
}
if (null != keepAspectRatio) {
const searchParams3 = str.searchParams;
const _String2 = String;
const result2 = searchParams3.set("keep_aspect_ratio", String(keepAspectRatio));
}
return str.toString();
}
}
return value;
};