decord/source/modules/image_proxy/ImageProxyUtils.tsx

64 lines
2.2 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 4512
// Function ID: 4513
2026-07-20 16:05:17 +00:00
// Name: isImageProxyURL
2026-08-24 06:08:38 +00:00
// Dependencies: [4513, 1487, 1469, 2]
2026-07-29 08:29:29 +00:00
// Exports: getSizedImageProxyURL, isImageProxyURL
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 4512 (isImageProxyURL)
import handleImageLoad from "handleImageLoad" /* 1469 */;
import isDiscordProxiedAssetUrlDefault from "isDiscordProxiedAssetUrl" /* 1487 */;
import getHostWithoutPort from "getHostWithoutPort" /* 4513 */;
import set from "set" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-07-29 08:29:29 +00:00
let parts;
if (window.GLOBAL_ENV.IMAGE_PROXY_ENDPOINTS != null) {
parts = str.split(",");
}
if (parts == null) {
parts = [];
}
2026-07-20 16:05:17 +00:00
function isImageProxyURL(hostname) {
2026-07-29 08:29:29 +00:00
let startsWithResult = set.has(hostname.hostname);
if (startsWithResult) {
2026-07-20 16:05:17 +00:00
const pathname = hostname.pathname;
startsWithResult = pathname.startsWith("/external/");
}
return startsWithResult;
}
const mapped = parts.map((str) => str.substring(2));
2026-08-24 06:08:38 +00:00
const mapped1 = mapped.map(getHostWithoutPort.getHostWithoutPort);
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) {
({ size, keepAspectRatio } = arg1);
2026-08-24 06:08:38 +00:00
const str = isDiscordProxiedAssetUrlDefault.toURLSafe(value);
2026-07-20 16:05:17 +00:00
if (null != str) {
2026-07-29 08:29:29 +00:00
let startsWithResult = set.has(str.hostname);
if (startsWithResult) {
const pathname = str.pathname;
startsWithResult = pathname.startsWith("/external/");
}
if (startsWithResult) {
2026-07-20 16:05:17 +00:00
if (null != size) {
const _String = String;
2026-08-24 06:08:38 +00:00
const obj2 = handleImageLoad;
const StringResult = String(obj2.getBestMediaProxySize(size * handleImageLoad.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-08-24 06:08:38 +00:00
const obj3 = handleImageLoad;
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;
};