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

180 lines
8.0 KiB
TypeScript

/* Metro module 660; source: modules/gateway/RequestGatewaySocket.tsx; dependencies: [5, 661, 681, 683, 2] */
import Module00005 from '../../by-id/module-00005.js'; /* Metro dependency 5 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */
import * as RequestSafeIdleCallbackModule from '../../external/discord_common/js/packages/design/utils/requestSafeIdleCallback.tsx'; /* Metro dependency 681 */
function _fun7401(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#7401, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:710:6, offset: 0x00d1a81a, size: 309 bytes, params: 8, frame: 24
let env0_0 = require;
const makeBridgeToken = function(a0) {
return 'BRIDGE:' + a0;
};
const isRequested2 = isRequested;
const closure2 = function(a0) {
var env0_0 = a0;
withStateTransitions(_fun7407);
};
const closure3 = function(a0) {
var env0_0 = a0;
withStateTransitions(_fun7409);
};
const withStateTransitions = function(a0) {
var isRequestedBinding = isRequested;
isRequestedBinding();
env0_6 = false;
a0();
isRequestedBinding();
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_5 = ['COLD_START'];
const Map = global.Map;
const map = new Map();
(FileImportTrackerModule).fileFinishedImporting('modules/gateway/RequestGatewaySocket.tsx');
exports.isRequested = isRequested2;
exports.recordStartHeadlessTask = function() {
env0_6 = false;
};
exports.describeConnectionReasons = describeConnectionReasons;
exports.setRequestedBy = closure2;
exports.startBridgeTo = startBridgeTo;
exports.stopRequest = closure3;
exports.withRequest = function() {
return _withRequest.apply(this, arguments);
};
function addToken(a0) { // fn#7402, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:710:163, offset: 0x00d1a94f, size: 60 bytes, params: 2, frame: 14
env0_7.set(a0, (env0_7.get(a0) ?? 0) + 1);
}
function deleteToken(a0) { // fn#7403, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:710:228, offset: 0x00d1a98b, size: 82 bytes, params: 2, frame: 15
const value2 = env0_7.get(a0);
const value3 = 0;
const value4 = (value2 ?? value3) - 1;
if (value4 <= value3) {
env0_7.delete(a0);
} else {
env0_7.set(a0, value4);
}
}
function isRequested() { // fn#7405, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:710:363, offset: 0x00d1a9fa, size: 27 bytes, params: 1, frame: 3
return env0_7.size > 0 || env0_6;
}
function setRequestedBy(a0) { // fn#7406, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:710:405, offset: 0x00d1aa15, size: 30 bytes, params: 2, frame: 11
const env0_0 = a0;
withStateTransitions(_fun7407);
function _fun7407() { // fn#7407, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:710:454, offset: 0x00d1aa33, size: 41 bytes, params: 1, frame: 12
const addTokenBinding = addToken;
const binding = env0_0;
addTokenBinding(binding);
deleteToken(makeBridgeToken(binding));
}
}
function stopRequest(a0) { // fn#7408, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:710:506, offset: 0x00d1aa5c, size: 30 bytes, params: 2, frame: 11
const env0_0 = a0;
withStateTransitions(_fun7409);
function _fun7409() { // fn#7409, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:710:552, offset: 0x00d1aa7a, size: 23 bytes, params: 1, frame: 11
deleteToken(env0_0);
}
}
function _withRequest() { // fn#7410, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:710:573, offset: 0x00d1aa91, size: 48 bytes, params: 1, frame: 14
return Module00005(_fun7412).apply(this, arguments);
function* _fun7412(a0, a1) { // fn#7412, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:710:620, offset: 0x00d1aaca, size: 98 bytes, params: 3, frame: 15
var binding;
var value3;
var value4;
var value5;
var error;
if (false) {
return undefined;
}
value = environment.__proto__.__proto__;
try {
binding = env2_12;
} catch (error) {
env2_13(a0);
throw error;
}
try {
binding(a0);
} catch (error) {
env2_13(a0);
throw error;
}
try {
value3 = a1();
} catch (error) {
env2_13(a0);
throw error;
}
yield value3;
try {
value4 = undefined;
value5 = false;
} catch (error) {
env2_13(a0);
throw error;
}
if (value5) {
}
env2_13(a0);
return value4;
}
}
function describeConnectionReasons() { // fn#7415, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:710:989, offset: 0x00d1ab59, size: 102 bytes, params: 1, frame: 15
var r0;
var value;
const r3 = env0_6 ? env0_5 : [];
const items2 = [];
const value2 = arraySpread(items2, r3, 0, undefined);
const binding = env0_7;
arraySpread(items2, binding.keys(), value2, binding);
if (items2.sort().length > 0) {
value = value.join(',');
r0 = value;
} else {
r0 = 'NO_REASONS';
}
return r0;
}
function startBridgeTo(a0) { // fn#7416, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:710:1155, offset: 0x00d1abbf, size: 110 bytes, params: 2, frame: 15
const env0_0 = makeBridgeToken(a0);
const env0_1 = global.performance.now();
withStateTransitions(_fun7417);
(RequestSafeIdleCallbackModule).requestSafeIdleCallback(_fun7418,
{timeout: 5000});
function _fun7417() { // fn#7417, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:710:1248, offset: 0x00d1ac2d, size: 23 bytes, params: 1, frame: 11
addToken(env0_0);
}
function _fun7418() { // fn#7418, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:710:1299, offset: 0x00d1ac44, size: 128 bytes, params: 1, frame: 17
var defaultImport;
var track;
var GATEWAY_BRIDGE_TIMEOUT;
var object;
const binding = env1_7;
if (binding.has(env0_0)) {
defaultImport = importDefault(683) /* metro dependency 683: AnalyticsUtils */;
track = defaultImport.track;
GATEWAY_BRIDGE_TIMEOUT = AnalyticEvents.GATEWAY_BRIDGE_TIMEOUT;
object = {bridge_token: env0_0};
object.cleared_after = global.performance.now() - env0_1;
Reflect.apply(track, defaultImport, [GATEWAY_BRIDGE_TIMEOUT, object]);
}
stopRequest(env0_0);
}
}
}
global.__d(_fun7401, 660, [5, 661, 681, 683, 2]) /* metro module 660, dependencies: [5, 661, 681, 683, 2] */;