225 lines
9.0 KiB
TypeScript
225 lines
9.0 KiB
TypeScript
/* Metro module 4102; source: modules/build_overrides/BuildOverrideUtils.tsx; dependencies: [4103, 661, 1582, 477, 1471, 507, 1473, 4104, 2] */
|
|
function _fun33617(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#33617, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4260:6, offset: 0x01035f18, size: 525 bytes, params: 8, frame: 24
|
|
var Version;
|
|
var r6;
|
|
var value5;
|
|
const env0_0 = require;
|
|
const closure = function(a0) {
|
|
return '' + global.location.protocol + '//' + global.location.host + a0;
|
|
};
|
|
const closure2 = isManualBuildOverrideLink;
|
|
const closure3 = manualOverrideLinkMeta;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const value = undefined;
|
|
const env0_4 = (require(4103) /* metro dependency 4103: BuildOverrideConstants */).BUILD_OVERRIDE_COOKIE_NAME;
|
|
(require(661) /* metro dependency 661: Constants */).PRIMARY_DOMAIN;
|
|
const constants = (require(1582) /* metro dependency 1582: ClientInfoUtils */).getConstants();
|
|
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
|
|
if (platformUtilsModule.isAndroid()) {
|
|
Version = constants.Version;
|
|
r6 = Version.split(' - ')[0];
|
|
} else {
|
|
value5 = platformUtilsModule;
|
|
r6 = value5.isIOS() ? constants.Version : value;
|
|
}
|
|
let RegExp = global.RegExp;
|
|
let regExp = new RegExp('^https://(?:ptb\\.|canary\\.)?(discordapp|discord)\\.com/__development/link?[\\S]+$', 'i');
|
|
RegExp = global.RegExp;
|
|
regExp = new RegExp('^dev://branch/([\\w-./]+)$', 'i');
|
|
let Set = global.Set;
|
|
let set = new Set(['canary.discord.com', 'ptb.discord.com', 'discord.com', 'canary.discordapp.com',
|
|
'ptb.discordapp.com', 'discordapp.com']);
|
|
Set = global.Set;
|
|
set = new Set(['/__development/link', '/__development/link/']);
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/build_overrides/BuildOverrideUtils.tsx');
|
|
exports.APP_VERSION = r6;
|
|
exports.getAPIEndpoint = closure;
|
|
exports.getBuildOverride = getBuildOverride;
|
|
exports.getBuildOverrideMeta = getBuildOverrideMeta;
|
|
exports.probablyHasBuildOverride = probablyHasBuildOverride;
|
|
exports.getBuildOverrideExperiments = getBuildOverrideExperiments;
|
|
exports.isBuildOverrideLink = isBuildOverrideLink;
|
|
exports.isManualBuildOverrideLink = closure2;
|
|
exports.manualOverrideLinkMeta = closure3;
|
|
exports.validateURL = validateURL;
|
|
return value;
|
|
}
|
|
|
|
function manualOverrideLinkMeta(a0) { // fn#33620, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4260:567, offset: 0x0103617c, size: 157 bytes, params: 2, frame: 15
|
|
const value2 = a0.match(env0_7);
|
|
if (value2 == null) {
|
|
return null;
|
|
}
|
|
if (value2.length !== 2) {
|
|
return null;
|
|
}
|
|
let value = require(477) /* metro dependency 477: PlatformUtils */;
|
|
value = value.getNativePlatform();
|
|
const property = value2[1];
|
|
value = 'discord_' + value;
|
|
return {targetBuildOverride: {[value]: {type: 'branch', id: property}}, validForUserIds: [],
|
|
expiresAt: 'Mon, 1 Jan 2038 00:00:00 GMT'};
|
|
}
|
|
|
|
function getBuildOverride() { // fn#33621, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4260:1165, offset: 0x01036219, size: 211 bytes, params: 1, frame: 19
|
|
var r0;
|
|
var HTTP;
|
|
var get;
|
|
var object2;
|
|
var value;
|
|
const defaultImport = importDefault(1471) /* metro dependency 1471: URLUtils */;
|
|
const value2 = defaultImport.safeParseWithQuery(getAPIEndpoint('/__development/build_overrides'));
|
|
if (value2 == null) {
|
|
r0 = global.Promise.resolve(null);
|
|
} else {
|
|
value2.search = null;
|
|
if (env0_5) {
|
|
value2.query.version = env0_5;
|
|
}
|
|
HTTP = (require(507) /* metro dependency 507: HTTPUtils */).HTTP;
|
|
get = HTTP.get;
|
|
object2 = {'url': null, 'oldFormErrors': true, 'rejectWithError': false};
|
|
value = importAll(1473) /* metro dependency 1473 */;
|
|
object2.url = value.format(value2);
|
|
value = Reflect.apply(get, HTTP, [object2]);
|
|
value = value.then(function({body}) {
|
|
return body || null;
|
|
}, _fun33623);
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function getBuildOverrideMeta(a0) { // fn#33624, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4260:1490, offset: 0x010362fb, size: 284 bytes, params: 2, frame: 21
|
|
var r1;
|
|
var HTTP;
|
|
var get;
|
|
var object2;
|
|
var Promise;
|
|
var value;
|
|
if (isManualBuildOverrideLink(a0)) {
|
|
Promise = global.Promise;
|
|
return Promise.resolve(manualOverrideLinkMeta(a0));
|
|
}
|
|
const value2 = (importDefault(1471) /* metro dependency 1471: URLUtils */).safeParseWithQuery(a0);
|
|
if (value2 == null) {
|
|
r1 = global.Promise.resolve(null);
|
|
} else {
|
|
value2.search = null;
|
|
value2.query.meta = 'true';
|
|
if (env0_5) {
|
|
value2.query.version = env0_5;
|
|
}
|
|
value2.host = global.window.location.host;
|
|
HTTP = (require(507) /* metro dependency 507: HTTPUtils */).HTTP;
|
|
get = HTTP.get;
|
|
object2 = {'url': null, 'oldFormErrors': true, 'rejectWithError': false};
|
|
value = importAll(1473) /* metro dependency 1473 */;
|
|
object2.url = value.format(value2);
|
|
value = Reflect.apply(get, HTTP, [object2]);
|
|
value = value.then(function({body}) {
|
|
return body || null;
|
|
}, _fun33626);
|
|
r1 = value;
|
|
}
|
|
return r1;
|
|
}
|
|
|
|
function probablyHasBuildOverride() { // fn#33627, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4260:1907, offset: 0x01036417, size: 75 bytes, params: 1, frame: 15
|
|
return global.window.document.cookie.indexOf('' + BUILD_OVERRIDE_COOKIE_NAME + '=') !== -1;
|
|
}
|
|
|
|
function getBuildOverrideExperiments() { // fn#33628, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4260:2026, offset: 0x01036462, size: 181 bytes, params: 1, frame: 18
|
|
var r0;
|
|
var value;
|
|
var property;
|
|
var defaultImport;
|
|
var parse;
|
|
var window;
|
|
var document;
|
|
var cookie;
|
|
var value2;
|
|
var JSON;
|
|
var atob;
|
|
var substring;
|
|
var $meta;
|
|
var experiments;
|
|
var error;
|
|
try {
|
|
value = environment;
|
|
property = dependencyMap[7];
|
|
defaultImport = importDefault(property);
|
|
parse = defaultImport.parse;
|
|
window = global.window;
|
|
document = window.document;
|
|
cookie = document.cookie;
|
|
value2 = Reflect.apply(parse, defaultImport, [cookie]);
|
|
property = value2[BUILD_OVERRIDE_COOKIE_NAME];
|
|
value = property == null;
|
|
if (value) {
|
|
r0 = {};
|
|
} else {
|
|
JSON = global.JSON;
|
|
parse = JSON.parse;
|
|
atob = global.atob;
|
|
substring = property.substring;
|
|
value = property.indexOf('.');
|
|
value += 1;
|
|
value = Reflect.apply(substring, property, [value]);
|
|
value = atob(value);
|
|
value = Reflect.apply(parse, JSON, [value]);
|
|
$meta = value.$meta;
|
|
experiments = $meta.experiments;
|
|
value = experiments != null;
|
|
r0 = value ? experiments : {};
|
|
}
|
|
} catch (error) {
|
|
return {};
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function validateURL(a0) { // fn#33630, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4260:2438, offset: 0x01036517, size: 241 bytes, params: 2, frame: 21
|
|
var r7;
|
|
var query;
|
|
var propertyName;
|
|
var propertyName2;
|
|
var query2;
|
|
var object2;
|
|
if (isManualBuildOverrideLink(a0)) {
|
|
return {payload: null, url: a0};
|
|
}
|
|
const value2 = (importDefault(1471) /* metro dependency 1471: URLUtils */).safeParseWithQuery(a0);
|
|
if (value2 != null) {
|
|
var binding = env0_8;
|
|
if (binding.has(value2.hostname)) {
|
|
query = value2.query;
|
|
if ('s' in query) {
|
|
binding = env0_9;
|
|
if (binding.has(value2.pathname)) {
|
|
query = value2.query;
|
|
for (propertyName in query) {
|
|
if (propertyName === 's') {
|
|
r7 = propertyName2;
|
|
continue;
|
|
}
|
|
query2 = value2.query;
|
|
delete query2[propertyName];
|
|
r7 = propertyName2;
|
|
}
|
|
object2 = {};
|
|
query = value2.query;
|
|
object2.payload = query.s;
|
|
object2.url = (importAll(1473) /* metro dependency 1473 */).format(value2);
|
|
return object2;
|
|
}
|
|
return null;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|