337 lines
14 KiB
TypeScript
337 lines
14 KiB
TypeScript
/* Metro module 1457; source: modules/image_upload/ImageLoaderUtils.tsx; dependencies: [57, 5, 661, 1393, 561, 1458, 1468, 1471, 1475, 22, 1852, 2] */
|
|
function _fun16687(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#16687, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:6, offset: 0x00e57b5b, size: 373 bytes, params: 8, frame: 20
|
|
let env0_0 = require;
|
|
const loadImageAsset = function(a0) {
|
|
var env0_0 = a0;
|
|
var Image = global.Image;
|
|
var value2 = new Image();
|
|
var env0_1 = value2;
|
|
value2.onerror = _fun16689(a0, value2);
|
|
value2.onload = _fun16693;
|
|
value2.src = a0.url;
|
|
};
|
|
const closure = getSrcWithWidthAndHeight;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_3 = importDefault(57) /* metro dependency 57 */;
|
|
const env0_4 = importDefault(5) /* metro dependency 5 */;
|
|
let value = require(661) /* metro dependency 661: Constants */;
|
|
const env0_5 = value.NOOP;
|
|
const env0_6 = value.MEDIA_PROXY_MAX_TARGET_RESOLUTION;
|
|
const env0_7 = RegExp('\\.webp($|\\?|#)', 'i');
|
|
const env0_8 = RegExp('\\.avif($|\\?|#)', 'i');
|
|
const env0_9 = [16, 20, 22, 24, 28, 32, 40, 44, 48, 56, 60, 64, 80, 96, 100, 128, 160, 240, 256, 300, 320, 480, 512,
|
|
600, 640, 1024, 1280, 1536, 2048, 3072, 4096];
|
|
value = importDefault(1393) /* metro dependency 1393 */;
|
|
value = new value({max: 1000});
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/image_upload/ImageLoaderUtils.tsx');
|
|
exports.getDevicePixelRatio = importDefault(1852) /* metro dependency 1852: getDevicePixelRatioNative */;
|
|
exports.isImageLoaded = isImageLoaded;
|
|
exports.loadImage = loadImage;
|
|
exports.getBestMediaProxySize = getBestMediaProxySize;
|
|
exports.getSrcWithWidthAndHeight = closure;
|
|
exports.getSizedImageSrc = getSizedImageSrc;
|
|
exports.getImageSrc = getImageSrc;
|
|
}
|
|
|
|
function loadImageAsset(a0) { // fn#16688, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:359, offset: 0x00e57cd0, size: 84 bytes, params: 2, frame: 14
|
|
const env0_0 = a0;
|
|
const Image = global.Image;
|
|
const image = new Image();
|
|
image.onerror = getOnError(a0, image);
|
|
image.onload = onload;
|
|
image.src = a0.url;
|
|
}
|
|
|
|
function handleImageLoad(a0, a1, a2) { // fn#16694, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:707, offset: 0x00e57e66, size: 131 bytes, params: 4, frame: 16
|
|
const env0_0 = a0;
|
|
const env0_1 = a1;
|
|
const callbacks = a1.callbacks;
|
|
const url = a1.url;
|
|
if (a0) {
|
|
env0_10.del(url);
|
|
} else {
|
|
env0_10.set(url, {url: url, loaded: true, width: a2.width, height: a2.height});
|
|
}
|
|
if (callbacks != null) {
|
|
callbacks.forEach(_fun16695);
|
|
}
|
|
}
|
|
|
|
function splitURL(a0) { // fn#16696, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:893, offset: 0x00e57f01, size: 95 bytes, params: 2, frame: 15
|
|
let value = a0.split('?');
|
|
value = env0_3(value, 2);
|
|
const property = value[0];
|
|
const property2 = value[1];
|
|
const items2 = [property];
|
|
value = importDefault(1468) /* metro dependency 1468 */;
|
|
items2[1] = value.parse(property2);
|
|
return items2;
|
|
}
|
|
|
|
function getSrcWithWidthAndHeight({src, sourceWidth, sourceHeight, targetWidth, targetHeight, format, quality, animated, srcIsAnimated}) { // fn#16697, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:983, offset: 0x00e57f60, size: 472 bytes, params: 2, frame: 24
|
|
var value;
|
|
format = format === undefined ? null : format;
|
|
quality = quality === undefined ? null : quality;
|
|
animated = !(animated === undefined) && animated;
|
|
srcIsAnimated = !(srcIsAnimated === undefined) && srcIsAnimated;
|
|
if (src.startsWith('data:image')) {
|
|
return src;
|
|
}
|
|
const defaultImport = importDefault(1471) /* metro dependency 1471: URLUtils */;
|
|
if (defaultImport.isDiscordCdnUrl(src)) {
|
|
return src;
|
|
}
|
|
const value3 = env0_3(splitURL(src), 2);
|
|
const property = value3[0];
|
|
const property2 = value3[1];
|
|
if (format != null) {
|
|
property2.format = format;
|
|
}
|
|
if (quality != null) {
|
|
property2.quality = quality;
|
|
}
|
|
let r1 = animated && srcIsAnimated && (env0_7.test(src) || env0_8.test(src));
|
|
if (r1) {
|
|
property2.animated = true;
|
|
}
|
|
const binding = env0_8;
|
|
if (binding.test(src)) {
|
|
property2.format = 'webp';
|
|
}
|
|
const {width, height} = (require(1475) /* metro dependency 1475: ImageUtils */).fit({width: targetWidth,
|
|
height: targetHeight, maxWidth: MEDIA_PROXY_MAX_TARGET_RESOLUTION,
|
|
maxHeight: MEDIA_PROXY_MAX_TARGET_RESOLUTION});
|
|
if (!(width === sourceWidth && height === sourceHeight)) {
|
|
property2.width = width | 0;
|
|
property2.height = height | 0;
|
|
}
|
|
const defaultImport2 = importDefault(22) /* metro dependency 22 */;
|
|
if (defaultImport2.isEmpty(property2)) {
|
|
r1 = property;
|
|
} else {
|
|
value = importDefault(1468) /* metro dependency 1468 */;
|
|
value = value.stringify(property2);
|
|
value = property + ('?' + value);
|
|
r1 = value;
|
|
}
|
|
return r1;
|
|
}
|
|
|
|
function isImageLoaded(a0) { // fn#16698, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:1679, offset: 0x00e58138, size: 37 bytes, params: 2, frame: 11
|
|
const value = env0_10.get(a0);
|
|
return value != null && value.loaded;
|
|
}
|
|
|
|
function loadImage(a0, a1) { // fn#16699, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:1758, offset: 0x00e5815d, size: 243 bytes, params: 3, frame: 18
|
|
var r0;
|
|
var object2;
|
|
var set;
|
|
var callbacks;
|
|
var Set;
|
|
var value3;
|
|
const env0_0 = a0;
|
|
var value;
|
|
const value2 = env0_10.get(a0);
|
|
if (value2 == null) {
|
|
if (value2 != null) {
|
|
r0 = value2;
|
|
} else {
|
|
object2 = {url: a0, loaded: false};
|
|
env0_10.set(a0, object2);
|
|
loadImageAsset(object2);
|
|
r0 = object2;
|
|
}
|
|
if (a1 != null) {
|
|
value = a1.bind(null);
|
|
callbacks = r0.callbacks;
|
|
if (callbacks == null) {
|
|
Set = global.Set;
|
|
value3 = Object.create(Set.prototype, {constructor: {value: Set}});
|
|
set = new Set();
|
|
r0.callbacks = set instanceof Object ? set : value3;
|
|
}
|
|
callbacks = r0.callbacks;
|
|
callbacks.add(value);
|
|
}
|
|
r0 = _fun16702;
|
|
} else if (value2.loaded) {
|
|
if (a1 != null) {
|
|
(importDefault(1458) /* metro dependency 1458: NetworkUtils */).awaitOnline().then(_fun16700);
|
|
}
|
|
r0 = NOOP;
|
|
} else {
|
|
if (value2 != null) {
|
|
r0 = value2;
|
|
} else {
|
|
object2 = {url: a0, loaded: false};
|
|
env0_10.set(a0, object2);
|
|
loadImageAsset(object2);
|
|
r0 = object2;
|
|
}
|
|
if (a1 != null) {
|
|
value = a1.bind(null);
|
|
callbacks = r0.callbacks;
|
|
if (callbacks == null) {
|
|
Set = global.Set;
|
|
value3 = Object.create(Set.prototype, {constructor: {value: Set}});
|
|
set = new Set();
|
|
r0.callbacks = set instanceof Object ? set : value3;
|
|
}
|
|
callbacks = r0.callbacks;
|
|
callbacks.add(value);
|
|
}
|
|
r0 = _fun16702;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function getBestMediaProxySize(a0) { // fn#16703, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:2245, offset: 0x00e58334, size: 132 bytes, params: 2, frame: 13
|
|
var environment;
|
|
var binding;
|
|
var value2;
|
|
let value = a1;
|
|
const env0_0 = a0;
|
|
if (value !== undefined ? value : false) {
|
|
binding = env0_9;
|
|
value = binding.filter(_fun16704);
|
|
value = value.pop();
|
|
if (value == null) {
|
|
value = environment;
|
|
return env0_9.find(_fun16705) ?? env0_9[env0_9.length - 1];
|
|
}
|
|
if (a0 / value <= 1.25) {
|
|
return value;
|
|
}
|
|
binding = env0_9;
|
|
value2 = binding.find(_fun16705);
|
|
} else {
|
|
value2 = env0_9.find(_fun16705);
|
|
}
|
|
return value2 ?? env0_9[env0_9.length - 1];
|
|
}
|
|
|
|
function getSizedImageSrc(a0, a1, a2) { // fn#16706, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:2482, offset: 0x00e583d8, size: 225 bytes, params: 4, frame: 21
|
|
let value = a3;
|
|
const r6 = value !== undefined ? value : 'webp';
|
|
const value2 = (importDefault(1852) /* metro dependency 1852: getDevicePixelRatioNative */)();
|
|
let Math = global.Math;
|
|
const value3 = Math.ceil(a1 * value2);
|
|
Math = global.Math;
|
|
const value4 = Math.ceil(a2 * value2);
|
|
value = env0_3(splitURL(a0), 2);
|
|
const property = value[0];
|
|
const property2 = value[1];
|
|
const stringify = (importDefault(1468) /* metro dependency 1468 */).stringify;
|
|
const object2 = {};
|
|
copyDataProperties(object2, property2, undefined);
|
|
object2['width'] = value3 | 0;
|
|
object2['height'] = value4 | 0;
|
|
object2['format'] = r6;
|
|
value = Reflect.apply(stringify, value, [object2]);
|
|
return '' + property + '?' + value;
|
|
}
|
|
|
|
function getImageSrc({src, width, height, maxWidth, maxHeight, ratio, format, quality, animated, srcIsAnimated}) { // fn#16707, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:2703, offset: 0x00e584b9, size: 294 bytes, params: 2, frame: 26
|
|
var r7;
|
|
var r14;
|
|
var value;
|
|
var Math;
|
|
ratio = ratio === undefined ? 1 : ratio;
|
|
format = format === undefined ? null : format;
|
|
quality = quality === undefined ? null : quality;
|
|
animated = !(animated === undefined) && animated;
|
|
srcIsAnimated = !(srcIsAnimated === undefined) && srcIsAnimated;
|
|
if (ratio < 1) {
|
|
Math = global.Math;
|
|
value = Math.round(width * ratio);
|
|
Math = global.Math;
|
|
r7 = Math.round(height * ratio);
|
|
r14 = value;
|
|
} else {
|
|
r7 = height;
|
|
r14 = width;
|
|
}
|
|
const r9 = maxWidth == null ? r14 : global.Math.min(r14, maxWidth);
|
|
const r8 = maxHeight == null ? r7 : global.Math.min(r7, maxHeight);
|
|
const value3 = (importDefault(1852) /* metro dependency 1852: getDevicePixelRatioNative */)();
|
|
return getSrcWithWidthAndHeight({src: src, sourceWidth: width, sourceHeight: height, targetWidth: r9 * value3,
|
|
targetHeight: r8 * value3, format: format, quality: quality, animated: animated, srcIsAnimated: srcIsAnimated});
|
|
}
|
|
|
|
function getOnError(a0, a1) { // fn#16689, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:412, owner: loadImageAsset.getOnError, offset: 0x00e57d24, size: 110 bytes, params: 3, frame: 13
|
|
var environment;
|
|
var value;
|
|
const env0_0 = a0;
|
|
const env0_1 = a1;
|
|
let backoff = a0.backoff;
|
|
if (backoff == null) {
|
|
value = environment.__proto__;
|
|
value = importDefault(561) /* metro dependency 561: Backoff */;
|
|
value = new value();
|
|
a0.backoff = value;
|
|
}
|
|
backoff = a0.backoff;
|
|
value = environment.__proto__;
|
|
return env1_4(_fun16691);
|
|
}
|
|
|
|
function loadImageAssetOnload() { // fn#16693, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:628, owner: loadImageAsset.onload, offset: 0x00e57e2d, size: 57 bytes, params: 1, frame: 15
|
|
const backoff = env0_0.backoff;
|
|
if (backoff != null) {
|
|
backoff.succeed();
|
|
}
|
|
handleImageLoad(false, env0_0, env0_1);
|
|
}
|
|
|
|
function _fun16700() { // fn#16700, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:1862, offset: 0x00e58250, size: 64 bytes, params: 1, frame: 12
|
|
if (env0_2 != null && env0_2.callbacks != null) {
|
|
env0_2.callbacks.forEach(_fun16701);
|
|
}
|
|
}
|
|
|
|
function _fun16702() { // fn#16702, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:2116, offset: 0x00e582cd, size: 103 bytes, params: 1, frame: 13
|
|
if (env0_1 != null && env0_2 != null) {
|
|
if (env0_2.callbacks != null) {
|
|
env0_2.callbacks.delete(env0_1);
|
|
}
|
|
if (env0_2.backoff != null) {
|
|
env0_2.backoff.cancel();
|
|
}
|
|
}
|
|
}
|
|
|
|
function _fun16704(a0) { // fn#16704, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:2312, offset: 0x00e583b8, size: 16 bytes, params: 2, frame: 2
|
|
return a0 <= env0_0;
|
|
}
|
|
|
|
function* _fun16691() { // fn#16691, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:505, offset: 0x00e57d9b, size: 123 bytes, params: 1, frame: 18
|
|
var environment;
|
|
if (true) {
|
|
value = environment.__proto__.__proto__.__proto__;
|
|
var value3 = env3_1(env3_2[5]);
|
|
yield value3.isOnline();
|
|
if (false) {
|
|
return undefined;
|
|
}
|
|
if (env1_2.fails < 5) {
|
|
env1_2.fail(_fun16692);
|
|
} else {
|
|
env3_12(true, env1_0, env1_1);
|
|
}
|
|
}
|
|
}
|
|
|
|
function _fun16701(a0) { // fn#16701, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:1916, offset: 0x00e58290, size: 61 bytes, params: 2, frame: 14
|
|
if (env1_2 != null) {
|
|
a0(false, env1_2);
|
|
} else {
|
|
a0(true, {url: env1_0, loaded: true});
|
|
}
|
|
}
|
|
|
|
function _fun16692() { // fn#16692, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1584:560, offset: 0x00e57e16, size: 23 bytes, params: 1, frame: 11
|
|
env4_11(env2_0);
|
|
}
|
|
|