111 lines
5.6 KiB
TypeScript
111 lines
5.6 KiB
TypeScript
/* Metro module 1477; source: utils/native/ImageUtils.tsx; dependencies: [57, 27, 661, 1478, 1468, 22, 1426, 1423, 2] */
|
|
import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */
|
|
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as ReactNativeModule from '../../by-id/module-00027-ReactNative.js'; /* Metro dependency 27 */
|
|
import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */
|
|
import * as UseWindowDimensionsNativeModule from '../../modules/screen/useWindowDimensions.native.tsx'; /* Metro dependency 1478 */
|
|
|
|
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
|
|
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 getSrcWithWidthAndHeight_169332 = getSrcWithWidthAndHeight_16933;
|
|
const getMobileOptimizedSrc2 = 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});
|
|
let value = ReactNativeModule;
|
|
const env0_4 = value.NativeModules;
|
|
const env0_5 = value.PixelRatio;
|
|
const regexp = RegExp('\\.(gif)$', 'i');
|
|
const regexp2 = RegExp('\\.(avif)$', 'i');
|
|
object = {getMobileOptimizedSrc: getMobileOptimizedSrc2, getPaletteForAvatarMobile: closure3};
|
|
(FileImportTrackerModule).fileFinishedImporting('utils/native/ImageUtils.tsx');
|
|
exports.default = object;
|
|
exports.GIF_RE = regexp;
|
|
exports.AVIF_RE = regexp2;
|
|
exports.getSrcWithWidthAndHeight = getSrcWithWidthAndHeight_169332;
|
|
exports.getMobileOptimizedSrc = getMobileOptimizedSrc2;
|
|
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 = Module00057(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 = Module00057(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 = (UseWindowDimensionsNativeModule).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});
|
|
}
|
|
|
|
}
|
|
|
|
global.__d(_fun16931, 1477, [57, 27, 661, 1478, 1468, 22, 1426, 1423,
|
|
2]) /* metro module 1477, dependencies: [57, 27, 661, 1478, 1468, 22, 1426, 1423, 2] */;
|