Files
discord-decomp/sources/by-id/module-01124.jsx
T
2026-07-27 16:20:00 +03:00

563 lines
24 KiB
React

/* Metro module 1124; source: unknown; dependencies: [65, 27, 1010, 826, 1125, 1126, 1130, 1131, 1009, 1132] */
function _fun12555(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#12555, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:6, offset: 0x00dce54b, size: 204 bytes, params: 8, frame: 24
const env0_0 = require;
const closure = startProfiling_12556;
const closure2 = stopProfiling_12557;
const closure3 = function(a0, a1, a2) {
var Object = global.Object;
var Object2 = global.Object;
return Object.assign(Object2.assign({}, a1), {platform: 'android', js_profile: a0.profile,
duration_ns: a2.toString(10), active_thread_id: a0.transaction.active_thread_id});
};
const closure4 = addNativeProfileToHermesProfile;
const closure5 = addNativeThreadCpuProfileToHermes;
let Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_2 = importDefault(65) /* metro dependency 65 */;
(require(27) /* metro dependency 27 */).Platform;
object = {platformProfilers: true};
exports.hermesProfilingIntegration = hermesProfilingIntegration;
exports.startProfiling = closure;
exports.stopProfiling = closure2;
exports.createAndroidWithHermesProfile = closure3;
exports.addNativeProfileToHermesProfile = closure4;
exports.addNativeThreadCpuProfileToHermes = closure5;
}
function startProfiling_12556(a0) { // fn#12556, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:156, offset: 0x00dce617, size: 77 bytes, params: 2, frame: 12
const NATIVE = (require(1009) /* metro dependency 1009 */).NATIVE;
return NATIVE.startProfiling(a0) ? global.Date.now() * env0_3 : null;
}
function stopProfiling_12557(a0) { // fn#12557, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:241, offset: 0x00dce664, size: 220 bytes, params: 2, frame: 18
var value4;
var moduleValue;
var value5;
var hermesProfilingEvent;
const NATIVE = (require(1009) /* metro dependency 1009 */).NATIVE;
const value2 = NATIVE.stopProfiling();
if (value2) {
value4 = global.Date.now() * env0_3;
moduleValue = require(1132) /* metro dependency 1132 */;
value5 = moduleValue.convertToSentryProfile(value2.hermesProfile);
if (value5) {
hermesProfilingEvent = (require(1126) /* metro dependency 1126 */).createHermesProfilingEvent(value5);
if (hermesProfilingEvent) {
if (value2.androidProfile) {
return createAndroidWithHermesProfile(hermesProfilingEvent, value2.androidProfile, value4 - a0);
}
return value2.nativeProfile ? addNativeProfileToHermesProfile(hermesProfilingEvent,
value2.nativeProfile) : hermesProfilingEvent;
}
return null;
}
}
return null;
}
function addNativeProfileToHermesProfile(a0, a1) { // fn#12559, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:844, offset: 0x00dce7ae, size: 202 bytes, params: 3, frame: 24
const Object = global.Object;
const assign = Object.assign;
const Object2 = global.Object;
const assign2 = Object2.assign;
const Object3 = global.Object;
const assign3 = Object3.assign;
const Object4 = global.Object;
let value = Object4.assign({}, a0);
const object2 = {};
const addNativeThreadCpuProfileToHermesBinding = addNativeThreadCpuProfileToHermes;
const profile = a0.profile;
const profile2 = a1.profile;
const active_thread_id = a0.transaction.active_thread_id;
const value3 = undefined;
object2.profile = addNativeThreadCpuProfileToHermesBinding(profile, profile2, active_thread_id);
value = Reflect.apply(assign3, Object3, [value, object2]);
const debug_meta = a1.debug_meta;
value = Reflect.apply(assign2, Object2, [value,
(debug_meta === null || value3 === debug_meta ? value3 : debug_meta.images) ? {debug_meta: {images: a1.debug_meta.images}} : {}]);
return Reflect.apply(assign, Object, [value, {measurements: a1.measurements}]);
}
function addNativeThreadCpuProfileToHermes(a0, a1, a2) { // fn#12560, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:1193, offset: 0x00dce878, size: 437 bytes, params: 4, frame: 22
var environment;
var r3;
var r2;
var r12;
var r10;
var Object;
var assign;
var Object2;
var assign2;
var thread_metadata;
var value;
var Object3;
var assign3;
var queue_metadata;
var frames;
var length;
var stacks;
var iterator;
var iterator2;
var item;
var item2;
var push;
var object;
var property;
var instruction_addr;
var error;
var concat;
var binding;
var value2;
var map;
var samples;
var value3;
var filter;
exceptionSkip13: while (true) {
exceptionLanding13: while (true) {
var env0_0 = a2;
Object = global.Object;
assign = Object.assign;
Object2 = global.Object;
assign2 = Object2.assign;
thread_metadata = a1.thread_metadata;
value = Reflect.apply(assign2, Object2, [{}, thread_metadata]);
thread_metadata = a0.thread_metadata;
a0.thread_metadata = Reflect.apply(assign, Object, [value, thread_metadata]);
Object = global.Object;
assign = Object.assign;
Object3 = global.Object;
assign3 = Object3.assign;
queue_metadata = a1.queue_metadata;
value = Reflect.apply(assign3, Object3, [{}, queue_metadata]);
queue_metadata = a0.queue_metadata;
a0.queue_metadata = Reflect.apply(assign, Object, [value, queue_metadata]);
frames = a0.frames;
length = frames.length;
var env0_1 = length;
stacks = a0.stacks;
length = stacks.length;
var env0_2 = length;
frames = a1.frames;
if (frames) {
frames = a1.frames;
iterator = frames[Symbol.iterator]();
iterator2 = iterator.next;
for (r3 = iterator; true; r3 = item2) {
item2 = Reflect.apply(iterator2, r3, []);
item = item2.value;
item2 = item2.done ? undefined : r3;
if (item2 === undefined) {
break;
}
try {
frames = a0.frames;
} catch (error) {
break exceptionLanding13;
}
try {
push = frames.push;
} catch (error) {
break exceptionLanding13;
}
try {
object = {};
} catch (error) {
break exceptionLanding13;
}
try {
property = item.function;
} catch (error) {
break exceptionLanding13;
}
try {
object.function = property;
} catch (error) {
break exceptionLanding13;
}
try {
instruction_addr = item.instruction_addr;
} catch (error) {
break exceptionLanding13;
}
try {
object.instruction_addr = instruction_addr;
} catch (error) {
break exceptionLanding13;
}
try {
object.platform = undefined;
} catch (error) {
break exceptionLanding13;
}
try {
Reflect.apply(push, frames, [object]);
} catch (error) {
break exceptionLanding13;
}
}
}
object = [];
concat = object.concat;
value = environment;
binding = env0_2;
stacks = a0.stacks;
if (stacks) {
r2 = stacks;
} else {
r2 = [];
}
value2 = binding(r2);
binding = env0_2;
stacks = a1.stacks;
if (stacks) {
r12 = stacks;
} else {
r12 = [];
}
map = r12.map;
a0.stacks = Reflect.apply(concat, object, [value2, binding(Reflect.apply(map, r12, [function(a0) {
return a0.map(_fun12562);
}]))]);
object = [];
concat = object.concat;
binding = env0_2;
samples = a0.samples;
if (samples) {
r3 = samples;
} else {
r3 = [];
}
value3 = binding(r3);
binding = env0_2;
samples = a1.samples;
if (samples) {
r10 = samples;
} else {
r10 = [];
}
filter = r10.filter;
value = Reflect.apply(filter, r10, [_fun12563]);
map = value.map;
a0.samples = Reflect.apply(concat, object, [value3, binding(Reflect.apply(map, value, [_fun12564]))]);
return a0;
break exceptionSkip13;
}
try {
item2.return();
} catch {
}
throw error;
break exceptionSkip13;
}
}
function hermesProfilingIntegration() { // fn#12565, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:1918, offset: 0x00dceaac, size: 167 bytes, params: 1, frame: 6
const platformProfilers = (arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : env0_4).platformProfilers;
if (platformProfilers === null || platformProfilers === undefined) {
}
return {name: 'HermesProfiling', setupOnce: setupOnce_12574};
}
function _fun12561(a0) { // fn#12561, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:1641, offset: 0x00dcea2d, size: 22 bytes, params: 2, frame: 11
return a0.map(function(a0) {
return a0 + length;
});
}
function _fun12563({thread_id}) { // fn#12563, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:1761, offset: 0x00dcea53, size: 22 bytes, params: 2, frame: 2
return thread_id !== importDefault;
}
function _fun12564(a0) { // fn#12564, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:1804, offset: 0x00dcea69, size: 67 bytes, params: 2, frame: 15
const Object = global.Object;
const assign = Object.assign;
const Object2 = global.Object;
return Reflect.apply(assign, Object, [Object2.assign({}, a0), {stack_id: length + a0.stack_id}]);
}
function _startCurrentProfileForActiveTransaction() { // fn#12566, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:2078, owner: hermesProfilingIntegration._startCurrentProfileForActiveTransaction, offset: 0x00dceb53, size: 61 bytes, params: 1, frame: 12
var value2;
var activeSpan;
if (!env0_0) {
value2 = environment.__proto__;
activeSpan = (require(826) /* metro dependency 826 */).getActiveSpan();
if (activeSpan) {
_startCurrentProfile(activeSpan);
}
}
}
function _startCurrentProfile(a0) { // fn#12567, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:2179, owner: hermesProfilingIntegration._startCurrentProfile, offset: 0x00dceb90, size: 124 bytes, params: 2, frame: 17
const moduleValue = require(1130) /* metro dependency 1130 */;
if (moduleValue.isRootSpan(a0)) {
_finishCurrentProfile();
if (_shouldStartProfiling(a0)) {
env0_1 = global.setTimeout(_finishCurrentProfile,
(require(1131) /* metro dependency 1131 */).MAX_PROFILE_DURATION_MS);
_startNewProfile(a0);
}
}
}
function _shouldStartProfiling(a0) { // fn#12568, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:2305, owner: hermesProfilingIntegration._shouldStartProfiling, offset: 0x00dcec0c, size: 285 bytes, params: 2, frame: 15
var getOptions;
var r0;
var profilesSampleRate;
var client;
var Math;
var value6;
const value = environment.__proto__;
const value2 = undefined;
const value3 = (require(826) /* metro dependency 826 */).spanIsSampled(a0);
const moduleValue2 = require(826) /* metro dependency 826 */;
if (value3) {
client = moduleValue2.getClient();
getOptions = client == null ? value2 : client.getOptions;
r0 = getOptions === null || value2 === getOptions ? value2 : getOptions.call(client);
if (r0) {
profilesSampleRate = r0.profilesSampleRate;
profilesSampleRate = typeof profilesSampleRate !== 'number' ? value2 : r0.profilesSampleRate;
} else {
profilesSampleRate = value2;
}
if (value2 === profilesSampleRate) {
moduleValue2.debug.log('[Profiling] Profiling disabled, enable it by setting `profilesSampleRate` option to SDK init call.');
r0 = false;
} else {
Math = global.Math;
value6 = Math.random() > profilesSampleRate;
if (value6) {
(require(826) /* metro dependency 826 */).debug.log('[Profiling] Skip profiling transaction due to sampling.');
r0 = false;
} else {
r0 = !value6;
}
}
return r0;
}
moduleValue2.debug.log('[Profiling] Transaction is not sampled, skipping profiling');
return false;
}
function _startNewProfile(a0) { // fn#12569, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:2879, owner: hermesProfilingIntegration._startNewProfile, offset: 0x00dced29, size: 168 bytes, params: 2, frame: 19
var object2;
var setAttribute;
var profile_id;
var debug;
var log;
const value = environment.__proto__;
const value3 = startProfiling_12556(env0_2);
if (value3) {
object2 = {};
object2.span_id = a0.spanContext().spanId;
object2.profile_id = (require(826) /* metro dependency 826 */).uuid4();
object2.startTimestampNs = value3;
env0_0 = object2;
setAttribute = a0.setAttribute;
profile_id = object2.profile_id;
Reflect.apply(setAttribute, a0, ['profile_id', profile_id]);
debug = (require(826) /* metro dependency 826 */).debug;
log = debug.log;
profile_id = env0_0.profile_id;
Reflect.apply(log, debug, ['[Profiling] started profiling: ', profile_id]);
}
}
function _finishCurrentProfileForSpan(a0) { // fn#12570, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:3129, owner: hermesProfilingIntegration._finishCurrentProfileForSpan, offset: 0x00dcedd1, size: 222 bytes, params: 2, frame: 21
var debug;
const value2 = undefined;
const moduleValue = require(1130) /* metro dependency 1130 */;
if (moduleValue.isRootSpan(a0)) {
if (a0.spanContext().spanId === (env0_0 == null ? value2 : env0_0.span_id)) {
_finishCurrentProfile();
} else {
debug = (require(826) /* metro dependency 826 */).debug;
debug.log('[Profiling] Span (' + a0.spanContext().spanId + ') ended is not the currently profiled span (' + (env0_0 == null ? value2 : env0_0.span_id) + '). Not stopping profiling.');
}
}
return value2;
}
function _finishCurrentProfile() { // fn#12571, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:3416, owner: hermesProfilingIntegration._finishCurrentProfile, offset: 0x00dceeaf, size: 188 bytes, params: 1, frame: 17
const debug = (require(826) /* metro dependency 826 */).debug;
var PROFILE_QUEUE;
var add;
var profile_id;
var log;
_clearCurrentProfileTimeout();
if (env0_0 !== undefined) {
var value3 = stopProfiling_12557(env0_0.startTimestampNs);
if (value3) {
PROFILE_QUEUE = (require(1125) /* metro dependency 1125 */).PROFILE_QUEUE;
add = PROFILE_QUEUE.add;
profile_id = env0_0.profile_id;
Reflect.apply(add, PROFILE_QUEUE, [profile_id, value3]);
log = debug.log;
profile_id = env0_0.profile_id;
Reflect.apply(log, debug, ['[Profiling] finished profiling: ', profile_id]);
return undefined;
}
debug.warn('[Profiling] Stop failed. Cleaning up...');
}
}
function _createProfileEventFor(a0) { // fn#12572, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:3720, owner: hermesProfilingIntegration._createProfileEventFor, offset: 0x00dcef6b, size: 468 bytes, params: 2, frame: 23
const debug = (require(826) /* metro dependency 826 */).debug;
var value4;
var value5;
const value = undefined;
let contexts = a0 == null ? value : a0.contexts;
let trace = contexts === null || value === contexts ? value : contexts.trace;
let data = trace === null || value === trace ? value : trace.data;
const profile_id = data === null || value === data ? value : data.profile_id;
if (typeof profile_id !== 'string') {
value5 = environment.__proto__;
debug.log('[Profiling] cannot find profile for a transaction without a profile context');
} else {
contexts = a0 == null ? value : a0.contexts;
trace = contexts === null || value === contexts ? value : contexts.trace;
data = trace === null || value === trace ? value : trace.data;
if (data === null || value === data ? value : data.profile_id) {
delete a0.contexts.trace.data.profile_id;
}
var PROFILE_QUEUE = (require(1125) /* metro dependency 1125 */).PROFILE_QUEUE;
var value3 = PROFILE_QUEUE.get(profile_id);
PROFILE_QUEUE = (require(1125) /* metro dependency 1125 */).PROFILE_QUEUE;
PROFILE_QUEUE.delete(profile_id);
if (value3) {
value4 = (require(1126) /* metro dependency 1126 */).enrichCombinedProfileWithEventContext(profile_id,
value3,
a0);
debug.log('[Profiling] Created profile ' + profile_id + ' for transaction ' + a0.event_id);
return value4;
}
debug.log('[Profiling] cannot find profile ' + profile_id + ' for transaction ' + a0.event_id);
}
return null;
}
function _clearCurrentProfileTimeout() { // fn#12573, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:4563, owner: hermesProfilingIntegration._clearCurrentProfileTimeout, offset: 0x00dcf13f, size: 36 bytes, params: 1, frame: 12
if (env0_1 !== undefined) {
global.clearTimeout(env0_1);
}
}
function hermesProfilingIntegrationSetupOnce() { // fn#12574, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:4680, owner: hermesProfilingIntegration.setupOnce, offset: 0x00dcf163, size: 219 bytes, params: 1, frame: 15
var environment;
var value2;
var isHermesEnabled2;
var moduleValue2;
var client;
if (!env0_3) {
value2 = environment.__proto__;
isHermesEnabled2 = (require(1010) /* metro dependency 1010 */).isHermesEnabled();
moduleValue2 = require(826) /* metro dependency 826 */;
if (isHermesEnabled2) {
client = moduleValue2.getClient();
if (client && typeof client.on === 'function') {
_startCurrentProfileForActiveTransaction();
client.on('spanStart', _startCurrentProfile);
client.on('spanEnd', _finishCurrentProfileForSpan);
client.on('beforeEnvelope', _fun12575);
}
} else {
moduleValue2.debug.log('[Profiling] Hermes is not enabled, not adding profiling integration.');
}
}
}
function _fun12575(a0) { // fn#12575, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1251:4862, offset: 0x00dcf23e, size: 232 bytes, params: 2, frame: 21
var r6;
var value;
var PROFILE_QUEUE;
var size;
var moduleValue;
var findProfiledTransactionsFromEnvelope;
var profiledTransactionsFromEnvelope;
var length;
var debug;
var log;
var items2;
var iterator;
var iterator2;
var value2;
var item;
var item2;
var _createProfileEventForBinding;
var value3;
var push;
var error;
var addProfilesToEnvelope;
exceptionSkip12: while (true) {
exceptionLanding12: while (true) {
value = environment.__proto__.__proto__;
PROFILE_QUEUE = (require(1125) /* metro dependency 1125 */).PROFILE_QUEUE;
size = PROFILE_QUEUE.size;
if (Reflect.apply(size, PROFILE_QUEUE, [])) {
moduleValue = require(1126) /* metro dependency 1126 */;
findProfiledTransactionsFromEnvelope = moduleValue.findProfiledTransactionsFromEnvelope;
profiledTransactionsFromEnvelope = Reflect.apply(findProfiledTransactionsFromEnvelope, moduleValue,
[a0]);
length = profiledTransactionsFromEnvelope.length;
if (length) {
items2 = [];
iterator = profiledTransactionsFromEnvelope[Symbol.iterator]();
iterator2 = iterator.next;
value2 = environment.__proto__;
r6 = iterator;
while (true) {
item2 = Reflect.apply(iterator2, r6, []);
item = item2.value;
item2 = item2.done ? undefined : r6;
if (item2 === undefined) {
break;
}
try {
_createProfileEventForBinding = _createProfileEventFor;
} catch (error) {
break exceptionLanding12;
}
try {
value3 = _createProfileEventForBinding(item);
} catch (error) {
break exceptionLanding12;
}
if (!value3) {
r6 = item2;
continue;
}
try {
push = items2.push;
} catch (error) {
break exceptionLanding12;
}
try {
Reflect.apply(push, items2, [value3]);
} catch (error) {
break exceptionLanding12;
}
r6 = item2;
}
value = require(1126) /* metro dependency 1126 */;
addProfilesToEnvelope = value.addProfilesToEnvelope;
Reflect.apply(addProfilesToEnvelope, value, [a0, items2]);
break;
}
debug = (require(826) /* metro dependency 826 */).debug;
log = debug.log;
Reflect.apply(log, debug, ['[Profiling] no profiled transactions found in envelope']);
break;
}
return undefined;
break exceptionSkip12;
}
try {
item2.return();
} catch {
}
throw error;
break exceptionSkip12;
}
}