246 lines
11 KiB
TypeScript
246 lines
11 KiB
TypeScript
/* Metro module 4651; source: utils/UploadUtils.tsx; dependencies: [4503, 4652, 4650, 2] */
|
|
function _fun40131(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#40131, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4829:6, offset: 0x010f7156, size: 786 bytes, params: 8, frame: 19
|
|
let env0_0 = require;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_2 = (require(4503) /* metro dependency 4503: MessageConstants */).SPOILER_ATTACHMENT_PREFIX;
|
|
const items2 = [{reName: RegExp('\\.jpe?g$', 'i'), name: function(a0) {
|
|
return 'image' + a0 + '.jpg';
|
|
}, type: 'image/jpeg'}];
|
|
items2[1] = {reName: RegExp('\\.jfif$', 'i'), name: function(a0) {
|
|
return 'image' + a0 + '.jpg';
|
|
}, type: 'image/jpeg'};
|
|
items2[2] = {reName: RegExp('\\.png$', 'i'), name: function(a0) {
|
|
return 'image' + a0 + '.png';
|
|
}, type: 'image/png'};
|
|
items2[3] = {reName: RegExp('\\.gif$', 'i'), name: function(a0) {
|
|
return 'image' + a0 + '.gif';
|
|
}, type: 'image/gif'};
|
|
items2[4] = {reName: RegExp('\\.webp$', 'i'), name: function(a0) {
|
|
return 'image' + a0 + '.webp';
|
|
}, type: 'image/webp'};
|
|
items2[5] = {reName: RegExp('\\.avif$', 'i'), name: function(a0) {
|
|
return 'image' + a0 + '.avif';
|
|
}, type: 'image/avif'};
|
|
items2[6] = {reName: RegExp('\\.heic$', 'i'), name: function(a0) {
|
|
return 'image' + a0 + '.heic';
|
|
}, type: 'image/heic'};
|
|
items2[7] = {reName: RegExp('\\.heif$', 'i'), name: function(a0) {
|
|
return 'image' + a0 + '.heif';
|
|
}, type: 'image/heif'};
|
|
items2[8] = {reName: RegExp('\\.dng$', 'i'), name: function(a0) {
|
|
return 'image' + a0 + '.dng';
|
|
}, type: 'image/x-adobe-dng'};
|
|
items2[9] = {reName: RegExp('\\.mov$', 'i'), name: function(a0) {
|
|
return 'video' + a0 + '.mov';
|
|
}, type: 'video/quicktime'};
|
|
items2[10] = {reName: RegExp('\\.qt$', 'i'), name: function(a0) {
|
|
return 'video' + a0 + '.qt';
|
|
}, type: 'video/quicktime'};
|
|
items2[11] = {reName: RegExp('\\.avi$', 'i'), name: function(a0) {
|
|
return 'video' + a0 + '.avi';
|
|
}, type: 'video/x-msvideo'};
|
|
items2[12] = {reName: RegExp('\\.mp4$', 'i'), name: function(a0) {
|
|
return 'video' + a0 + '.mp4';
|
|
}, type: 'video/mp4'};
|
|
items2[13] = {reName: RegExp('\\.webm$', 'i'), name: function(a0) {
|
|
return 'video' + a0 + '.webm';
|
|
}, type: 'image/webm'};
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('utils/UploadUtils.tsx');
|
|
exports.MAX_TOTAL_ATTACHMENT_SIZE = 524288000;
|
|
exports.MAX_TOTAL_ATTACHMENT_SIZE_MB = 500;
|
|
exports.getAttachmentPayload = getAttachmentPayload;
|
|
exports.getFileData = function(a0) {
|
|
var env0_0 = a0;
|
|
var property = global.XMLHttpRequest;
|
|
var env0_1 = new property();
|
|
property = global.Promise;
|
|
value2 = Object.create(property.prototype, {constructor: {value: property}});
|
|
var value3 = new property(_fun40148);
|
|
return value3 instanceof Object ? value3 : value2;
|
|
};
|
|
exports.getFileContentLength = function(a0) {
|
|
var env0_0 = a0;
|
|
var Promise = global.Promise;
|
|
var value = Object.create(Promise.prototype, {constructor: {value: Promise}});
|
|
var value2 = new Promise(_fun40154);
|
|
return value2 instanceof Object ? value2 : value;
|
|
};
|
|
exports.getFile = getFile;
|
|
}
|
|
|
|
function getAttachmentPayload(a0) { // fn#40146, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4829:1171, offset: 0x010f7622, size: 600 bytes, params: 2, frame: 19
|
|
var clip;
|
|
var getClipCreatedAt;
|
|
var getClipParticipantIds;
|
|
var getClipEventsTimeline;
|
|
let value = a1;
|
|
const value2 = a2;
|
|
const value3 = undefined;
|
|
const r5 = value !== value3 ? value : null;
|
|
const object2 = {};
|
|
let r2 = r5 == null ? value3 : r5.toString();
|
|
r2 = r2 ?? a0.id;
|
|
object2.id = r2;
|
|
if (a0.description != null) {
|
|
object2.description = a0.description;
|
|
}
|
|
let spoiler = a0.spoiler;
|
|
spoiler = ({spoiler: spoiler}).spoiler;
|
|
value = '';
|
|
object2.filename = value + (spoiler ? SPOILER_ATTACHMENT_PREFIX : value) + (value2 ?? a0.filename);
|
|
object2.uploaded_filename = a0.uploadedFilename;
|
|
if ('durationSecs' in a0 && a0.durationSecs != null) {
|
|
object2.duration_secs = a0.durationSecs;
|
|
}
|
|
if ('waveform' in a0 && a0.waveform != null) {
|
|
object2.waveform = a0.waveform;
|
|
}
|
|
if ('isThumbnail' in a0 && a0.isThumbnail === true) {
|
|
object2.is_thumbnail = a0.isThumbnail;
|
|
}
|
|
if ('clip' in a0 && a0.clip != null) {
|
|
object2.is_clip = true;
|
|
clip = a0.clip;
|
|
object2.title = clip.name;
|
|
clip = a0.clip;
|
|
object2.application_id = clip.applicationId;
|
|
value = require(4652) /* metro dependency 4652: clipPayloadUtils */;
|
|
getClipCreatedAt = value.getClipCreatedAt;
|
|
clip = a0.clip;
|
|
object2.clip_created_at = Reflect.apply(getClipCreatedAt, value, [clip.createdAt]);
|
|
value = require(4652) /* metro dependency 4652: clipPayloadUtils */;
|
|
getClipParticipantIds = value.getClipParticipantIds;
|
|
clip = a0.clip;
|
|
object2.clip_participant_ids = Reflect.apply(getClipParticipantIds, value, [clip.users]);
|
|
clip = a0.clip;
|
|
object2.clip_remote_id = clip.remoteClipId;
|
|
value = require(4652) /* metro dependency 4652: clipPayloadUtils */;
|
|
getClipEventsTimeline = value.getClipEventsTimeline;
|
|
clip = a0.clip;
|
|
object2.clip_events_timeline = Reflect.apply(getClipEventsTimeline, value, [clip]);
|
|
}
|
|
r2 = 'item' in a0 && a0.item != null && a0.item.platform === (require(4650) /* metro dependency 4650: Upload */).UploadPlatform.WEB;
|
|
r2 = r2 && 'mimeType' in a0 && a0.mimeType != null;
|
|
if (r2) {
|
|
object2.original_content_type = a0.mimeType;
|
|
}
|
|
return object2;
|
|
}
|
|
|
|
function getFileData(a0) { // fn#40147, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4829:2181, offset: 0x010f787a, size: 74 bytes, params: 2, frame: 12
|
|
const env0_0 = a0;
|
|
const XMLHttpRequest = global.XMLHttpRequest;
|
|
let xMLHttpRequest = new XMLHttpRequest();
|
|
const Promise = global.Promise;
|
|
xMLHttpRequest = Object.create(Promise.prototype, {constructor: {value: Promise}});
|
|
const promise = new Promise(_fun40148);
|
|
return promise instanceof Object ? promise : xMLHttpRequest;
|
|
}
|
|
|
|
function getFileContentLength(a0) { // fn#40153, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4829:2466, offset: 0x010f7972, size: 44 bytes, params: 2, frame: 11
|
|
const env0_0 = a0;
|
|
const Promise = global.Promise;
|
|
const value = Object.create(Promise.prototype, {constructor: {value: Promise}});
|
|
const promise = new Promise(_fun40154);
|
|
return promise instanceof Object ? promise : value;
|
|
}
|
|
|
|
function getFile({uri, i, overrideFilename, overrideType}) { // fn#40156, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4829:2877, offset: 0x010f7af5, size: 536 bytes, params: 2, frame: 25
|
|
var value12;
|
|
var value13;
|
|
let value = uri.split('/');
|
|
value = value[value.length - 1].split('?');
|
|
let r7 = value == null || value[0] == null ? undefined : value[0].toLowerCase();
|
|
value = '';
|
|
let r2 = r7 ?? value;
|
|
const value4 = env0_3.find(_fun40157);
|
|
let r9 = value4 == null && overrideFilename != null;
|
|
r7 = r9 ? env0_3.find(function({reName}) {
|
|
return reName.test(overrideFilename);
|
|
}) : value4;
|
|
if (r7 == null) {
|
|
r2 = r7 != null ? r7.name(i) : overrideFilename ?? 'unknown';
|
|
} else if (overrideFilename != null) {
|
|
value12 = r7.name(i).split('.').pop();
|
|
value13 = overrideFilename.lastIndexOf('.');
|
|
r2 = value13 !== -1 ? value + overrideFilename.substr(0,
|
|
value13) + '.' + value12 : value + overrideFilename + '.' + value12;
|
|
} else {
|
|
r2 = r7 != null ? r7.name(i) : overrideFilename ?? 'unknown';
|
|
}
|
|
const object2 = {uri: uri, filename: r2};
|
|
object2.type = overrideType ?? r7?.type ?? 'unknown';
|
|
r9 = overrideType ?? r7?.name(i) ?? value;
|
|
object2.isVideo = r9.indexOf('video') !== -1;
|
|
const r4 = overrideType ?? r7?.name(i) ?? value;
|
|
object2.isImage = r4.indexOf('image') !== -1;
|
|
return object2;
|
|
}
|
|
|
|
function _fun40148(a0, a1) { // fn#40148, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4829:2250, offset: 0x010f78c4, size: 116 bytes, params: 3, frame: 16
|
|
const env0_0 = a0;
|
|
const binding = a1;
|
|
binding.open('GET', env0_0, true);
|
|
binding.responseType = 'blob';
|
|
binding.onabort = function(a0) {
|
|
return require(a0);
|
|
};
|
|
binding.onerror = function(a0) {
|
|
return require(a0);
|
|
};
|
|
binding.ontimeout = function(a0) {
|
|
return require(a0);
|
|
};
|
|
binding.onload = onload_40152;
|
|
binding.send();
|
|
}
|
|
|
|
function _fun40154(a0, a1) { // fn#40154, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4829:2519, offset: 0x010f799e, size: 119 bytes, params: 3, frame: 17
|
|
const env0_0 = a0;
|
|
const env0_1 = a1;
|
|
const XMLHttpRequest = global.XMLHttpRequest;
|
|
const xMLHttpRequest = new XMLHttpRequest();
|
|
xMLHttpRequest.open('HEAD', env0_0, true);
|
|
xMLHttpRequest.onload = onload_40155;
|
|
xMLHttpRequest.onerror = a1;
|
|
xMLHttpRequest.onabort = a1;
|
|
xMLHttpRequest.ontimeout = a1;
|
|
xMLHttpRequest.send();
|
|
}
|
|
|
|
function _fun40157({reName}) { // fn#40157, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4829:3087, offset: 0x010f7d0d, size: 28 bytes, params: 2, frame: 11
|
|
return reName.test(env0_1);
|
|
}
|
|
|
|
function onload_40152() { // fn#40152, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4829:2364, offset: 0x010f7938, size: 58 bytes, params: 1, frame: 14
|
|
return env0_0(env1_1 == null || env1_1.response == null ? undefined : env1_1.response.data);
|
|
}
|
|
|
|
function onload_40155() { // fn#40155, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4829:2581, offset: 0x010f7a15, size: 224 bytes, params: 1, frame: 15
|
|
var Error;
|
|
var responseHeader;
|
|
var value;
|
|
if (env0_2.status >= 200) {
|
|
if (env0_2.status < 300) {
|
|
responseHeader = env0_2.getResponseHeader('Content-Length');
|
|
if (responseHeader == null) {
|
|
require(new global.Error('Content-Length header is missing'));
|
|
} else if (responseHeader !== '') {
|
|
env0_0(global.parseInt(responseHeader, 10));
|
|
} else {
|
|
require(new global.Error('Content-Length header is missing'));
|
|
}
|
|
} else {
|
|
Error = global.Error;
|
|
value = 'HTTP request failed with status code ' + env0_2.status;
|
|
require(new Error());
|
|
}
|
|
} else {
|
|
Error = global.Error;
|
|
value = 'HTTP request failed with status code ' + env0_2.status;
|
|
require(new Error());
|
|
}
|
|
}
|
|
|