106 lines
4.8 KiB
TypeScript
106 lines
4.8 KiB
TypeScript
/* Metro module 1477; source: utils/native/ImageUtils.tsx; dependencies: [57, 27, 661, 1478, 1468, 22, 1426, 1423, 2] */
|
|
function _fun16931(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#16931, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1604:6, offset: 0x00e5f2fc, size: 275 bytes, params: 8, frame: 22
|
|
var object2;
|
|
const env0_0 = require;
|
|
const clampDimension = function(a0) {
|
|
var value = a0;
|
|
return value > MEDIA_PROXY_MAX_TARGET_RESOLUTION ? MEDIA_PROXY_MAX_TARGET_RESOLUTION : value;
|
|
};
|
|
const closure = getSrcWithWidthAndHeight_16933;
|
|
const closure2 = getMobileOptimizedSrc;
|
|
const closure3 = function(a0) {
|
|
var value2 = require(dependencyMap[6]).ensureAvatarSource(require(dependencyMap[7]).makeSource(a0));
|
|
var ImageManager = NativeModules.ImageManager;
|
|
return ImageManager.getDominantColors(value2);
|
|
};
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_3 = importDefault(57) /* metro dependency 57 */;
|
|
let value = require(27) /* metro dependency 27 */;
|
|
const env0_4 = value.NativeModules;
|
|
const env0_5 = value.PixelRatio;
|
|
const env0_6 = (require(661) /* metro dependency 661: Constants */).MEDIA_PROXY_MAX_TARGET_RESOLUTION;
|
|
const regexp = RegExp('\\.(gif)$', 'i');
|
|
const regexp2 = RegExp('\\.(avif)$', 'i');
|
|
object2 = {getMobileOptimizedSrc: closure2, getPaletteForAvatarMobile: closure3};
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('utils/native/ImageUtils.tsx');
|
|
exports.default = object2;
|
|
exports.GIF_RE = regexp;
|
|
exports.AVIF_RE = regexp2;
|
|
exports.getSrcWithWidthAndHeight = closure;
|
|
exports.getMobileOptimizedSrc = closure2;
|
|
exports.getPaletteForAvatarMobile = closure3;
|
|
}
|
|
|
|
function getSrcWithWidthAndHeight_16933({src, sourceWidth, sourceHeight, targetWidth, targetHeight, format, animated}) { // fn#16933, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1604:264, offset: 0x00e5f423, size: 339 bytes, params: 2, frame: 26
|
|
var r0;
|
|
format = format === undefined ? null : format;
|
|
animated = !(animated === undefined) && animated;
|
|
let value = src.split('?');
|
|
value = env0_3(value, 2);
|
|
let property = value[0];
|
|
const property2 = value[1];
|
|
const items2 = [property];
|
|
value = importDefault(1468) /* metro dependency 1468 */;
|
|
items2[1] = value.parse(property2);
|
|
value = env0_3(items2, 2);
|
|
property = value[0];
|
|
const property3 = value[1];
|
|
const binding = env0_8;
|
|
if (binding.test(property)) {
|
|
property3.format = 'webp';
|
|
} else if (format != null) {
|
|
property3.format = format;
|
|
}
|
|
const clampDimensionBinding = clampDimension;
|
|
value = clampDimensionBinding(targetWidth);
|
|
const value3 = clampDimensionBinding(targetHeight);
|
|
if (!(value === sourceWidth && value3 === sourceHeight)) {
|
|
property3.width = value | 0;
|
|
property3.height = value3 | 0;
|
|
}
|
|
if (animated) {
|
|
property3.animated = true;
|
|
}
|
|
if (Reflect.apply((importDefault(22) /* metro dependency 22 */).isEmpty, value, [property3])) {
|
|
r0 = property;
|
|
} else {
|
|
value = importDefault(1468) /* metro dependency 1468 */;
|
|
value = property + ('?' + value.stringify(property3));
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function getMobileOptimizedSrc(a0, a1, a2) { // fn#16934, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1604:727, offset: 0x00e5f576, size: 268 bytes, params: 4, frame: 22
|
|
var r4;
|
|
var value15;
|
|
const value = a1;
|
|
const value2 = a2;
|
|
const value3 = a3;
|
|
const r3 = value3 !== undefined ? value3 : null;
|
|
const value6 = env0_7.test(a0);
|
|
const value7 = 1;
|
|
let r5 = value6 ? 0.3 : value7;
|
|
const windowDimensions = (require(1478) /* metro dependency 1478: useWindowDimensionsNative */).getWindowDimensions();
|
|
let getPixelSizeForLayoutSize = PixelRatio.getPixelSizeForLayoutSize;
|
|
const value10 = Reflect.apply(getPixelSizeForLayoutSize, PixelRatio, [windowDimensions.width]) * r5;
|
|
getPixelSizeForLayoutSize = PixelRatio.getPixelSizeForLayoutSize;
|
|
r5 = value > value2 ? value10 / value : Reflect.apply(getPixelSizeForLayoutSize, PixelRatio, [windowDimensions.height / 2]) * r5 / value2;
|
|
let Math = global.Math;
|
|
const value14 = Math.min(r5, value7);
|
|
if (value14 < value7) {
|
|
Math = global.Math;
|
|
value15 = Math.ceil(value * value14);
|
|
Math = global.Math;
|
|
r4 = Math.ceil(value2 * value14);
|
|
r5 = value15;
|
|
} else {
|
|
r4 = value2;
|
|
r5 = value;
|
|
}
|
|
return getSrcWithWidthAndHeight_16933({src: a0, sourceWidth: value, sourceHeight: value2, targetWidth: r5,
|
|
targetHeight: r4, format: r3});
|
|
}
|
|
|