Files
discord-decomp/sources/modules/profiling/ComponentProfiler.tsx
T
2026-07-28 01:06:53 +03:00

198 lines
9.4 KiB
TypeScript

/* Metro module 11222; source: modules/profiling/ComponentProfiler.tsx; dependencies: [6, 7, 31, 33, 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 ReactModule from '../../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as JsxRuntimeModule from '../../by-id/module-00033-JsxRuntime.js'; /* Metro dependency 33 */
function _fun85775(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#85775, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11408:6, offset: 0x01f7b755, size: 297 bytes, params: 8, frame: 20
const formatString_85776 = function(a0, a1) {
var value = a1;
return a0.substring(0, a0.length > value ? value : a0.length).padEnd(value, ' ');
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = _fun85777();
let env0_5 = {};
(FileImportTrackerModule).fileFinishedImporting('modules/profiling/ComponentProfiler.tsx');
exports.default = ComponentProfiler;
exports.StatCollector = value;
exports.clearComponentRenderStats = function() {
env0_5 = {};
};
exports.getComponentRenderStats = getComponentRenderStats;
exports.serializeComponentRenderAverages = serializeComponentRenderAverages;
exports.resetComponentProfiler = function() {
env0_5 = {};
};
exports.pauseComponentProfiler = function() {
env0_6 = false;
};
exports.resumeComponentProfiler = function() {
env0_6 = true;
};
exports.dumpStats = dumpStats;
function _fun85777() { // fn#85777, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11408:142, offset: 0x01f7b8b7, size: 84 bytes, params: 1, frame: 15
return CreateClass(StatCollector, [{key: 'addValue', value: value_85779}, {key: 'mean', get: function() {
return this.totalMicroseconds / this.count;
}}]);
function StatCollector() { // fn#85778, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11408:163, offset: 0x01f7b90b, size: 55 bytes, params: 1, frame: 13
env1_0(this, StatCollector);
this.totalMicroseconds = 0;
this.count = 0;
this.minMicroseconds = null;
this.maxMicroseconds = null;
}
}
function ComponentProfiler({id, children}) { // fn#85781, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11408:851, offset: 0x01f7b9f6, size: 79 bytes, params: 2, frame: 16
const value2 = ReactModule.useCallback(_fun85782, []);
const Profiler = ReactModule.Profiler;
return (
<Profiler id={id} onRender={value2}>
{children}
</Profiler>
);
function _fun85782(a0, a1, a2) { // fn#85782, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11408:918, offset: 0x01f7ba45, size: 231 bytes, params: 4, frame: 17
var binding;
var object;
var binding2;
var prototype;
var value2;
var binding22;
var value5;
var binding23;
var value8;
var binding24;
if (env1_6) {
if (!(a0 in env1_5)) {
binding = env1_5;
object = {};
binding2 = env1_4;
prototype = binding2.prototype;
value2 = Object.create(prototype, {constructor: {value: binding2}});
binding22 = new binding2();
object.mount = binding22 instanceof Object ? binding22 : value2;
prototype = binding2.prototype;
value5 = Object.create(prototype, {constructor: {value: binding2}});
binding23 = new binding2();
object.update = binding23 instanceof Object ? binding23 : value5;
prototype = binding2.prototype;
value8 = Object.create(prototype, {constructor: {value: binding2}});
binding24 = new binding2();
object.nestedUpdate = binding24 instanceof Object ? binding24 : value8;
binding[a0] = object;
}
if (a1 === 'mount') {
env1_5[a0].mount.addValue(a2);
} else if (a1 === 'update') {
env1_5[a0].update.addValue(a2);
} else if (a1 === 'nested-update') {
env1_5[a0].nestedUpdate.addValue(a2);
}
}
}
}
function getComponentRenderStats() { // fn#85784, offset: 0x00d9d76b, size: 9 bytes, params: 1, frame: 1
return env0_5;
}
function serializeComponentRenderAverages() { // fn#85785, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11408:1391, offset: 0x01f7bb2c, size: 242 bytes, params: 1, frame: 34
var r0;
var formatString_85776Binding;
var value11;
const Object = global.Object;
const keys = Object.keys;
var value;
if (Reflect.apply(keys, Object, [env0_5]).length === 0) {
r0 = '';
} else {
formatString_85776Binding = formatString_85776;
value11 = 'Component Render Stats (microseconds):\n' + ('|' + formatString_85776Binding('id',
20) + '|' + formatString_85776Binding('Mounts', 8) + '|' + formatString_85776Binding('Mount Mean',
20) + '|' + formatString_85776Binding('Updates', 8) + '|' + formatString_85776Binding('Update Mean',
20) + '|' + formatString_85776Binding('Nested', 8) + '|' + formatString_85776Binding('Nested Mean',
20) + '|\n');
value = global.Object.entries(env0_5);
value = value11 + value.map(_fun85786);
r0 = value;
}
return r0;
function _fun85786(a0) { // fn#85786, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11408:1754, offset: 0x01f7bc1e, size: 294 bytes, params: 2, frame: 33
var r0;
var r1;
var r2;
var item3;
var value3;
const iterator = a0[Symbol.iterator]();
const iterator2 = iterator.next;
let item2 = Reflect.apply(iterator2, iterator, []);
let item = item2.value;
item2 = item2.done ? undefined : iterator;
const value = undefined;
const value2 = item2 === value;
const r4 = value2 ? value : item;
if (value2) {
r0 = value;
r1 = item2;
r2 = value2;
} else {
item3 = Reflect.apply(iterator2, item2, []);
item = item3.value;
item3 = item3.done ? undefined : item2;
value3 = item3 === value;
if (value3) {
r0 = value;
r1 = item3;
r2 = value3;
} else {
r0 = item;
r1 = item3;
r2 = value3;
}
}
if (!r2) {
r1.return();
}
const formatString_85776Binding = formatString_85776;
const value5 = formatString_85776Binding(r4, 20);
let count = r0.mount.count;
const value7 = formatString_85776Binding(count.toString(), 8);
let mean = r0.mount.mean;
const value8 = formatString_85776Binding(mean.toString(), 20);
count = r0.update.count;
const value9 = formatString_85776Binding(count.toString(), 8);
mean = r0.update.mean;
const value10 = formatString_85776Binding(mean.toString(), 20);
count = r0.nestedUpdate.count;
const value11 = formatString_85776Binding(count.toString(), 8);
mean = r0.nestedUpdate.mean;
return '|' + value5 + '|' + value7 + '|' + value8 + '|' + value9 + '|' + value10 + '|' + value11 + '|' + formatString_85776Binding(mean.toString(),
20) + '|\n';
}
}
function dumpStats() { // fn#85790, offset: 0x00d9d76b, size: 9 bytes, params: 1, frame: 1
return env0_5;
}
}
function value_85779(a0) { // fn#85779, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11408:325, offset: 0x01f7b942, size: 160 bytes, params: 2, frame: 17
const count = this.count;
this.count = typeof count === 'bigint' ? count + 1n : +count + 1;
let Math = global.Math;
const value = Math.round(1000 * a0);
this.totalMicroseconds = this.totalMicroseconds + value;
Math = global.Math;
this.minMicroseconds = Math.min(this.minMicroseconds ?? global.Number.MAX_SAFE_INTEGER, value);
Math = global.Math;
this.maxMicroseconds = Math.max(this.maxMicroseconds ?? global.Number.MIN_SAFE_INTEGER, value);
}
global.__d(_fun85775, 11222, [6, 7, 31, 33, 2]) /* metro module 11222, dependencies: [6, 7, 31, 33, 2] */;