246 lines
12 KiB
TypeScript
246 lines
12 KiB
TypeScript
/* Metro module 4658; source: lib/uploader/UploadUtils.tsx; dependencies: [6, 7, 4650, 507, 4659, 1873, 2] */
|
|
import ClassCallCheck from '../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
|
|
import CreateClass from '../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
|
|
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as ShimNativeModule from '../../external/discord_common/js/packages/libdiscore/js_shim/js/shim.native.tsx'; /* Metro dependency 1873 */
|
|
import * as UploadModule from './Upload.tsx'; /* Metro dependency 4650 */
|
|
|
|
function _fun40246(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#40246, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4836:6, offset: 0x010fa529, size: 180 bytes, params: 8, frame: 19
|
|
const env0_0 = require;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
let value = _fun40247();
|
|
const value2 = _fun40251();
|
|
(FileImportTrackerModule).fileFinishedImporting('lib/uploader/UploadUtils.tsx');
|
|
exports.doesImageMatchUpload = doesImageMatchUpload;
|
|
exports.calculateProgress = function(a0, a1) {
|
|
var value = 0;
|
|
return value === a1 ? value : global.Math.min(global.Math.floor(a0 / a1 * 100), 100);
|
|
};
|
|
exports.DefaultHttpClient = value;
|
|
exports.canUploadNatively = canUploadNatively;
|
|
exports.LibdiscoreHttpClient = value2;
|
|
function _fun40247() { // fn#40247, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4836:122, offset: 0x010fa5dd, size: 80 bytes, params: 1, frame: 15
|
|
return CreateClass(DefaultHttpClient, [{key: 'sliceBody', value: function(a0, a1) {
|
|
var r0;
|
|
var value = a0;
|
|
if (value instanceof global.File) {
|
|
value = value.slice(a1);
|
|
r0 = value;
|
|
} else {
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}}, {key: 'doUpload', value: function(a0, a1) {
|
|
if (a1?.fileByteRange != null) {
|
|
a0.body = this.sliceBody(a0.body, a1.fileByteRange.start);
|
|
}
|
|
return require(dependencyMap[3]).HTTP.put(a0);
|
|
}}]);
|
|
function DefaultHttpClient() { // fn#40248, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4836:143, offset: 0x00c618a4, size: 27 bytes, params: 1, frame: 13
|
|
env1_2(this, DefaultHttpClient);
|
|
}
|
|
|
|
}
|
|
|
|
function _fun40251() { // fn#40251, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4836:448, offset: 0x010fa6be, size: 55 bytes, params: 1, frame: 14
|
|
return CreateClass(LibdiscoreHttpClient, [{key: 'doUpload', value: value_40253}]);
|
|
function LibdiscoreHttpClient() { // fn#40252, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4836:469, offset: 0x010fa6f5, size: 96 bytes, params: 1, frame: 14
|
|
let value = environment.__proto__;
|
|
env1_2(this, LibdiscoreHttpClient);
|
|
value = require(1873) /* metro dependency 1873: shimNative */;
|
|
if (value.isLibdiscoreInitialized()) {
|
|
return undefined;
|
|
}
|
|
const Error = global.Error;
|
|
throw new Error('Libdiscore is not loaded');
|
|
}
|
|
|
|
function value_40253(a0, a1) { // fn#40253, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4836:637, offset: 0x010fa755, size: 426 bytes, params: 3, frame: 20
|
|
var environment;
|
|
var r1;
|
|
var value5;
|
|
let env0_0 = a0;
|
|
let value = environment.__proto__;
|
|
value = undefined;
|
|
const httpClientAPI = (ShimNativeModule).getHttpClientAPI();
|
|
if (httpClientAPI == null) {
|
|
throw new global.Error('Libdiscore client is not available');
|
|
}
|
|
let body = a0.body;
|
|
let uri = body == null ? value : body.uri;
|
|
if (value !== uri && typeof a0.body.uri === 'string') {
|
|
body = a0.body;
|
|
uri = body.uri;
|
|
value5 = uri.startsWith('file://');
|
|
body = a0.body;
|
|
uri = body.uri;
|
|
r1 = value5 ? uri.slice(7) : uri;
|
|
} else {
|
|
r1 = value;
|
|
}
|
|
if (value === r1) {
|
|
throw new global.Error('No file path found in request body');
|
|
}
|
|
if (r1 === '') {
|
|
throw new global.Error('No file path found in request body');
|
|
}
|
|
let env0_2 = httpClientAPI.httpRequest(a0.url, {method: 'PUT', body: {path: r1,
|
|
byteRangeStart: a1 == null || a1.fileByteRange == null ? value : a1.fileByteRange.start,
|
|
byteRangeEnd: a1 == null || a1.fileByteRange == null ? value : a1.fileByteRange.end}, headers: a0.headers});
|
|
const Promise = global.Promise;
|
|
value = Object.create(Promise.prototype, {constructor: {value: Promise}});
|
|
const promise = new Promise(function(a0, a1) {
|
|
var env0_0 = a0;
|
|
var env0_1 = a1;
|
|
var closure = _fun40255;
|
|
var env0_2 = closure;
|
|
closure();
|
|
});
|
|
return promise instanceof Object ? promise : value;
|
|
function _fun40254(a0, a1) { // fn#40254, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4836:1196, offset: 0x010fa8ff, size: 33 bytes, params: 3, frame: 9
|
|
const env0_0 = a0;
|
|
const env0_1 = a1;
|
|
pollStatus();
|
|
function pollStatus() { // fn#40255, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4836:1219, offset: 0x010fa920, size: 491 bytes, params: 1, frame: 18
|
|
var binding;
|
|
var httpRequestStatus;
|
|
var Error;
|
|
var error;
|
|
var object;
|
|
var response;
|
|
var value5;
|
|
const value = environment.__proto__;
|
|
const signal = env1_0.signal;
|
|
if (signal == null) {
|
|
httpRequestStatus = env1_1.getHttpRequestStatus(env1_2);
|
|
} else {
|
|
if (signal.aborted) {
|
|
Error = global.Error;
|
|
value5 = Object.create(Error.prototype, {constructor: {value: Error}});
|
|
error = new Error('Request cancelled');
|
|
require(error instanceof Object ? error : value5);
|
|
env1_1.cancelHttpRequest(env1_2);
|
|
return undefined;
|
|
}
|
|
httpRequestStatus = env1_1.getHttpRequestStatus(env1_2);
|
|
}
|
|
const value3 = undefined;
|
|
if ((httpRequestStatus == null ? value3 : httpRequestStatus.status) === 'success') {
|
|
binding = env0_0;
|
|
object = {};
|
|
response = httpRequestStatus.response;
|
|
object.status = response == null ? value3 : response.status;
|
|
response = httpRequestStatus.response;
|
|
object.headers = response == null ? value3 : response.headers;
|
|
response = httpRequestStatus.response;
|
|
object.text = response == null ? value3 : response.body;
|
|
binding(object);
|
|
} else if ((httpRequestStatus == null ? value3 : httpRequestStatus.status) === 'error') {
|
|
Error = global.Error;
|
|
error = httpRequestStatus.error;
|
|
error = new Error();
|
|
require(error);
|
|
} else if ((httpRequestStatus == null ? value3 : httpRequestStatus.status) === 'progressing') {
|
|
if (value3 !== env1_0.onRequestProgress) {
|
|
if (httpRequestStatus.uploaded_bytes != null) {
|
|
if (httpRequestStatus.uploaded_bytes > 0) {
|
|
env1_0.onRequestProgress({loaded: httpRequestStatus.uploaded_bytes,
|
|
total: httpRequestStatus.total_bytes});
|
|
}
|
|
}
|
|
}
|
|
global.setTimeout(pollStatus, 50);
|
|
} else {
|
|
require(new global.Error('Unknown upload status'));
|
|
}
|
|
return value3;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function doesImageMatchUpload(a0, a1) { // fn#40256, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4836:1993, offset: 0x010fab0b, size: 176 bytes, params: 3, frame: 15
|
|
var item;
|
|
const UploadPlatform = (UploadModule).UploadPlatform;
|
|
var filename;
|
|
var originalUri;
|
|
if (a1.id === a0.uri) {
|
|
return true;
|
|
}
|
|
if (a1.id == null) {
|
|
item = a1.item;
|
|
if (item.platform === UploadPlatform.REACT_NATIVE) {
|
|
item = a1.item;
|
|
filename = a0.filename;
|
|
originalUri = item.originalUri;
|
|
if (originalUri === a0.uri) {
|
|
return true;
|
|
}
|
|
if (filename == null) {
|
|
return false;
|
|
}
|
|
originalUri = item.originalUri;
|
|
if (originalUri == null) {
|
|
return false;
|
|
}
|
|
if (originalUri.includes(filename)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
} else {
|
|
if (a1.id === a0.id) {
|
|
return true;
|
|
}
|
|
item = a1.item;
|
|
if (item.platform === UploadPlatform.REACT_NATIVE) {
|
|
item = a1.item;
|
|
filename = a0.filename;
|
|
originalUri = item.originalUri;
|
|
if (originalUri === a0.uri) {
|
|
return true;
|
|
}
|
|
if (filename == null) {
|
|
return false;
|
|
}
|
|
originalUri = item.originalUri;
|
|
if (originalUri == null) {
|
|
return false;
|
|
}
|
|
if (originalUri.includes(filename)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function canUploadNatively(a0) { // fn#40258, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4836:2423, offset: 0x010fabf8, size: 138 bytes, params: 2, frame: 15
|
|
var moduleValue;
|
|
const platform = a0.platform;
|
|
var value;
|
|
const UploadPlatform = (UploadModule).UploadPlatform;
|
|
const REACT_NATIVE = UploadPlatform.REACT_NATIVE;
|
|
let r0 = platform === REACT_NATIVE && a0.uri != null;
|
|
if (r0) {
|
|
moduleValue = require(4659) /* metro dependency 4659: AttachmentFileNative */;
|
|
r0 = moduleValue.fileIsInAppDir(a0.uri);
|
|
}
|
|
if (r0) {
|
|
value = require(1873) /* metro dependency 1873: shimNative */;
|
|
value = value.isLibdiscoreInitialized();
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
}
|
|
|
|
global.__d(_fun40246, 4658, [6, 7, 4650, 507, 4659, 1873,
|
|
2]) /* metro module 4658, dependencies: [6, 7, 4650, 507, 4659, 1873, 2] */;
|