Files
discord-decomp/sources/modules/game_console/GameConsoleManager.tsx
T
2026-07-27 16:20:00 +03:00

418 lines
22 KiB
TypeScript

/* Metro module 15716; source: modules/game_console/GameConsoleManager.tsx; dependencies: [7, 6, 15, 17, 18, 5, 1226, 4259, 4294, 4296, 4297, 4295, 9340, 4291, 3, 44, 8899, 10838, 4041, 9422, 1360, 4647, 1244, 15717, 9425, 4860, 2] */
function _fun120629(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#120629, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:6, offset: 0x02531865, size: 460 bytes, params: 8, frame: 19
const env0_0 = require;
const syncLocalState = function() {
return _syncLocalState.apply(this, arguments);
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_3 = importDefault(7) /* metro dependency 7 */;
const env0_4 = importDefault(6) /* metro dependency 6 */;
const env0_5 = importDefault(15) /* metro dependency 15 */;
const env0_6 = importDefault(17) /* metro dependency 17 */;
const env0_7 = importDefault(18) /* metro dependency 18 */;
const env0_8 = importDefault(5) /* metro dependency 5 */;
const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */;
const mediaEngineStore = importDefault(4259) /* metro dependency 4259: MediaEngineStore */;
const rtcConnectionStore = importDefault(4294) /* metro dependency 4294: RTCConnectionStore */;
const sessionsStore = importDefault(4296) /* metro dependency 4296: SessionsStore */;
const voiceStateStore = importDefault(4297) /* metro dependency 4297: VoiceStateStore */;
const gameConsoleStore = importDefault(4295) /* metro dependency 4295: GameConsoleStore */;
let value = require(9340) /* metro dependency 9340: GameConsoleConstants */;
const env0_15 = value.GAME_CONSOLE_SESSIONS;
const env0_16 = value.USER_ACTION_REQUIRED_ERROR_CODES;
const env0_17 = (require(4291) /* metro dependency 4291: Constants */).MediaEngineContextTypes;
value = importDefault(3) /* metro dependency 3: Logger */;
value = new value('GameConsoleManager');
value = importDefault(4860) /* metro dependency 4860: AutomaticLifecycleManager */;
value = _fun120637(value);
value = new value();
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/game_console/GameConsoleManager.tsx');
exports.default = value;
}
function _isNativeReflectConstruct_120630() { // fn#120630, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:329, offset: 0x02531a31, size: 98 bytes, params: 1, frame: 18
var Boolean;
var prototype;
var valueOf;
var call;
var Reflect;
var construct;
var closure;
var value;
var error;
try {
Boolean = global.Boolean;
prototype = Boolean.prototype;
valueOf = prototype.valueOf;
call = valueOf.call;
Reflect = global.Reflect;
construct = Reflect.construct;
Boolean = global.Boolean;
closure = function() {
};
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
value = Reflect.apply(call, valueOf, [value]);
var result = !value;
} catch (error) {
}
return (_isNativeReflectConstruct_120630_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _syncLocalState() { // fn#120634, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:635, offset: 0x02531a93, size: 50 bytes, params: 1, frame: 14
return env0_8(_fun120636).apply(this, arguments);
}
function _fun120637(a0) { // fn#120637, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:962, offset: 0x02531ba9, size: 42 bytes, params: 2, frame: 14
const closure = GameConsoleManager;
env0_7(closure, a0);
return env0_3(closure);
}
function* _fun120636(a0) { // fn#120636, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:688, offset: 0x02531ad0, size: 217 bytes, params: 2, frame: 17
var selfDeaf;
if (true) {
value = environment.__proto__.__proto__;
var binding = env2_11;
env2_1(env2_2[15])(binding.getChannelId() == null, 'Syncing to remote while in voice!');
if (a0.selfMute === Reflect.apply(env2_10.isSelfMute, binding, [])) {
selfDeaf = a0.selfDeaf;
binding = env2_10;
if (selfDeaf !== binding.isSelfDeaf()) {
env2_1(env2_2[16]).toggleSelfDeaf({syncRemote: false});
}
} else {
binding = env2_1;
var value5 = binding(env2_2[16]);
yield value5.toggleSelfMute({syncRemote: false});
if (false) {
return undefined;
}
selfDeaf = a0.selfDeaf;
binding = env2_10;
if (selfDeaf !== binding.isSelfDeaf()) {
env2_1(env2_2[16]).toggleSelfDeaf({syncRemote: false});
}
}
}
}
function GameConsoleManager(a0) { // fn#120638, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:974, offset: 0x02531bd3, size: 434 bytes, params: 2, frame: 21
var r0;
var Reflect;
let value = copyRestArgs(0, undefined);
let binding = env1_4;
binding(this, GameConsoleManager);
const items = [];
arraySpread(items, value, 0, items);
value = env1_6(GameConsoleManager);
binding = env1_5;
if (_isNativeReflectConstruct_120630()) {
Reflect = global.Reflect;
value = Reflect.construct(value, items, env1_6(this).constructor);
r0 = value;
} else {
value = value.apply(this, items);
r0 = value;
}
value = binding(this, r0);
const Timeout = (require(4041) /* metro dependency 4041: Timers */).Timeout;
const value4 = Object.create(Timeout.prototype, {constructor: {value: Timeout}});
let timeout = new Timeout();
value.rollbackCommandTimeout = timeout instanceof Object ? timeout : value4;
const value6 = Object.create(Timeout.prototype, {constructor: {value: Timeout}});
timeout = new Timeout();
value.awaitRemoteTimeout = timeout instanceof Object ? timeout : value6;
value.actions = {WAIT_FOR_REMOTE_SESSION: WAIT_FOR_REMOTE_SESSION_120639,
POST_CONNECTION_OPEN: POST_CONNECTION_OPEN_120640, SESSIONS_REPLACE: SESSIONS_REPLACE,
AUDIO_TOGGLE_SELF_DEAF: AUDIO_TOGGLE_SELF_DEAF_120642, AUDIO_TOGGLE_SELF_MUTE: AUDIO_TOGGLE_SELF_MUTE_120643,
VOICE_STATE_UPDATES: VOICE_STATE_UPDATES_120644, CONSOLE_COMMAND_UPDATE: CONSOLE_COMMAND_UPDATE,
PASSIVE_UPDATE_V2: PASSIVE_UPDATE_V2_120646, REMOTE_SESSION_DISCONNECT: REMOTE_SESSION_DISCONNECT_120647};
value.maybeConnect = maybeConnect;
value.handleAudioStateToggle = handleAudioStateToggle;
value.handleVoiceStateUpdates = handleVoiceStateUpdates_120653;
value.handleSessionsChanged = handleSessionsChanged;
value.handleWaitForRemoteSession = handleWaitForRemoteSession;
value.handleConsoleCommandUpdate = handleConsoleCommandUpdate;
value.handleRemoteSessionDisconnect = handleRemoteSessionDisconnect;
return value;
}
function GameConsoleManagerWAIT_FOR_REMOTE_SESSION() { // fn#120639, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:1339, owner: GameConsoleManager.WAIT_FOR_REMOTE_SESSION, offset: 0x02531d85, size: 19 bytes, params: 1, frame: 9
return env0_0.handleWaitForRemoteSession();
}
function GameConsoleManagerPOST_CONNECTION_OPEN() { // fn#120640, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:1395, owner: GameConsoleManager.POST_CONNECTION_OPEN, offset: 0x02531d98, size: 19 bytes, params: 1, frame: 9
return env0_0.handleSessionsChanged();
}
function GameConsoleManagerAUDIO_TOGGLE_SELF_DEAF(a0) { // fn#120642, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:1495, owner: GameConsoleManager.AUDIO_TOGGLE_SELF_DEAF, offset: 0x02531dab, size: 23 bytes, params: 2, frame: 11
return env0_0.handleAudioStateToggle(a0);
}
function GameConsoleManagerVOICE_STATE_UPDATES(a0) { // fn#120644, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:1600, owner: GameConsoleManager.VOICE_STATE_UPDATES, offset: 0x02531dc2, size: 23 bytes, params: 2, frame: 11
return env0_0.handleVoiceStateUpdates(a0);
}
function CONSOLE_COMMAND_UPDATE(a0) { // fn#120645, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:1655, owner: GameConsoleManager.CONSOLE_COMMAND_UPDATE, offset: 0x02531dd9, size: 23 bytes, params: 2, frame: 11
return env0_0.handleConsoleCommandUpdate(a0);
}
function GameConsoleManagerREMOTE_SESSION_DISCONNECT() { // fn#120647, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:1766, owner: GameConsoleManager.REMOTE_SESSION_DISCONNECT, offset: 0x02531df0, size: 19 bytes, params: 1, frame: 9
return env0_0.handleRemoteSessionDisconnect();
}
function maybeConnect(a0) { // fn#120648, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:1820, owner: GameConsoleManager.maybeConnect, offset: 0x02531e03, size: 141 bytes, params: 2, frame: 17
let value = ((a0) => {
var env0_0 = GameConsoleStore.getAwaitingRemoteSessionInfo();
return a0.find(_fun120650);
})(a0);
if (value == null) {
return null;
}
env0_0.awaitRemoteTimeout.stop();
const gameConsoleActionCreatorsModule = require(9422) /* metro dependency 9422: GameConsoleActionCreators */;
gameConsoleActionCreatorsModule.connectToRemote(value.sessionId);
value = VoiceStateStore.getVoiceStateForSession(AuthenticationStore.getId(), value.sessionId);
if (value != null) {
syncLocalState(value);
}
}
function handleAudioStateToggle({syncRemote, context}) { // fn#120651, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:2301, owner: GameConsoleManager.handleAudioStateToggle, offset: 0x02531f5e, size: 246 bytes, params: 2, frame: 19
var environment;
var value;
var isSelfDeaf2;
var isSelfMute2;
var id;
var remoteSessionId;
var voiceStateForSession;
if (syncRemote) {
value = environment.__proto__.__proto__;
if (context === MediaEngineContextTypes.DEFAULT) {
isSelfDeaf2 = MediaEngineStore.isSelfDeaf();
isSelfMute2 = MediaEngineStore.isSelfMute();
id = AuthenticationStore.getId();
remoteSessionId = GameConsoleStore.getRemoteSessionId();
if (remoteSessionId != null) {
voiceStateForSession = VoiceStateStore.getVoiceStateForSession(id, remoteSessionId);
if (voiceStateForSession != null) {
if (!(voiceStateForSession.selfDeaf === isSelfDeaf2 && voiceStateForSession.selfMute === isSelfMute2)) {
value = require(9422) /* metro dependency 9422: GameConsoleActionCreators */;
value.remoteVoiceStateUpdate(remoteSessionId, {selfDeaf: isSelfDeaf2, selfMute: isSelfMute2});
voiceStateForSession.rollbackCommandTimeout.start(3000, _fun120652);
}
}
}
}
}
}
function GameConsoleManagerHandleVoiceStateUpdates({voiceStates}) { // fn#120653, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:2670, owner: GameConsoleManager.handleVoiceStateUpdates, offset: 0x0253206b, size: 173 bytes, params: 2, frame: 14
var environment;
var value5;
const value = environment.__proto__.__proto__;
const remoteSessionId = GameConsoleStore.getRemoteSessionId();
const env0_0 = remoteSessionId;
if (remoteSessionId == null) {
value5 = voiceStates.map(_fun120654);
return env0_0.maybeConnect(value5.filter((require(1360) /* metro dependency 1360: GlobalUtils */).isNotNullish));
}
const value3 = voiceStates.find(_fun120655);
if (value3 != null) {
env0_0.rollbackCommandTimeout.stop();
syncLocalState(value3);
}
}
function handleSessionsChanged() { // fn#120656, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:2976, owner: GameConsoleManager.handleSessionsChanged, offset: 0x02532154, size: 138 bytes, params: 1, frame: 14
var binding;
var maybeConnect;
var Object;
const remoteSessionId = GameConsoleStore.getRemoteSessionId();
if (remoteSessionId != null && SessionsStore.getSessionById(remoteSessionId) == null) {
(require(9422) /* metro dependency 9422: GameConsoleActionCreators */).disconnectRemote();
}
if (remoteSessionId == null) {
binding = env0_0;
maybeConnect = binding.maybeConnect;
Object = global.Object;
Reflect.apply(maybeConnect, binding, [Object.values(SessionsStore.getSessions())]);
}
}
function handleWaitForRemoteSession() { // fn#120657, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:3160, owner: GameConsoleManager.handleWaitForRemoteSession, offset: 0x025321de, size: 43 bytes, params: 1, frame: 13
env0_0.awaitRemoteTimeout.start(60000, _fun120658);
}
function handleConsoleCommandUpdate({id, result, error}) { // fn#120659, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:3371, owner: GameConsoleManager.handleConsoleCommandUpdate, offset: 0x025322b2, size: 527 bytes, params: 2, frame: 26
var environment;
var r5;
var type;
var value2;
var awaitingRemoteSessionInfo;
var value4;
var getDevice;
var value6;
var defaultImport;
var object2;
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
var value7;
var awaitRemoteTimeout;
const value = result === 'failed';
if (value) {
if (error != null) {
value2 = environment.__proto__.__proto__;
env2_18.info('Console command Error result:', result, error);
awaitingRemoteSessionInfo = GameConsoleStore.getAwaitingRemoteSessionInfo();
value4 = undefined;
if ((awaitingRemoteSessionInfo == null ? value4 : awaitingRemoteSessionInfo.commandId) === id) {
getDevice = GameConsoleStore.getDevice;
type = awaitingRemoteSessionInfo.type;
r5 = awaitingRemoteSessionInfo.deviceId ?? '';
value6 = Reflect.apply(getDevice, GameConsoleStore, [type, r5]);
defaultImport = importDefault(15717) /* metro dependency 15717: getErrorMessageForCommandResult */;
if (value6 != null) {
r5 = value6;
} else {
object2 = {id: 'id'};
object2.platform = intl.string(t['UQMV/E']);
object2.name = intl.string(t['UQMV/E']);
r5 = object2;
}
value7 = defaultImport(r5, result, error);
if (value7 != null) {
(importDefault(9425) /* metro dependency 9425: GameConsoleAlertUtils */).showSelfDismissableAlert({title: value7.title,
body: value7.body, errorCodeMessage: value7.errorCodeMessage,
reconnectPlatformType: value7.isAccountLinkError ? awaitingRemoteSessionInfo.type : value4});
}
if (USER_ACTION_REQUIRED_ERROR_CODES.has(error.code)) {
awaitRemoteTimeout = env0_0.awaitRemoteTimeout;
if (awaitRemoteTimeout.isStarted()) {
env0_0.awaitRemoteTimeout.start(180000, _fun120660, true);
} else if (value) {
(require(9422) /* metro dependency 9422: GameConsoleActionCreators */).disconnectRemote();
}
} else if (value) {
(require(9422) /* metro dependency 9422: GameConsoleActionCreators */).disconnectRemote();
}
}
}
} else if (result === 'n/a') {
if (error != null) {
value2 = environment.__proto__.__proto__;
env2_18.info('Console command Error result:', result, error);
awaitingRemoteSessionInfo = GameConsoleStore.getAwaitingRemoteSessionInfo();
value4 = undefined;
if ((awaitingRemoteSessionInfo == null ? value4 : awaitingRemoteSessionInfo.commandId) === id) {
getDevice = GameConsoleStore.getDevice;
type = awaitingRemoteSessionInfo.type;
r5 = awaitingRemoteSessionInfo.deviceId ?? '';
value6 = Reflect.apply(getDevice, GameConsoleStore, [type, r5]);
defaultImport = importDefault(15717) /* metro dependency 15717: getErrorMessageForCommandResult */;
if (value6 != null) {
r5 = value6;
} else {
object2 = {id: 'id'};
object2.platform = intl.string(t['UQMV/E']);
object2.name = intl.string(t['UQMV/E']);
r5 = object2;
}
value7 = defaultImport(r5, result, error);
if (value7 != null) {
(importDefault(9425) /* metro dependency 9425: GameConsoleAlertUtils */).showSelfDismissableAlert({title: value7.title,
body: value7.body, errorCodeMessage: value7.errorCodeMessage,
reconnectPlatformType: value7.isAccountLinkError ? awaitingRemoteSessionInfo.type : value4});
}
if (USER_ACTION_REQUIRED_ERROR_CODES.has(error.code)) {
awaitRemoteTimeout = env0_0.awaitRemoteTimeout;
if (awaitRemoteTimeout.isStarted()) {
env0_0.awaitRemoteTimeout.start(180000, _fun120660, true);
} else if (value) {
(require(9422) /* metro dependency 9422: GameConsoleActionCreators */).disconnectRemote();
}
} else if (value) {
(require(9422) /* metro dependency 9422: GameConsoleActionCreators */).disconnectRemote();
}
}
}
}
}
function handleRemoteSessionDisconnect() { // fn#120661, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:4112, owner: GameConsoleManager.handleRemoteSessionDisconnect, offset: 0x025324e6, size: 27 bytes, params: 1, frame: 9
env0_0.awaitRemoteTimeout.stop();
}
function findRemoteSession(a0) { // fn#120649, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:1830, owner: GameConsoleManager.maybeConnect.findRemoteSession, offset: 0x02531e90, size: 46 bytes, params: 2, frame: 12
const env0_0 = GameConsoleStore.getAwaitingRemoteSessionInfo();
return a0.find(_fun120650);
}
function _fun120652() { // fn#120652, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:2613, offset: 0x02532054, size: 23 bytes, params: 1, frame: 11
syncLocalState(env0_0);
}
function _fun120654({sessionId}) { // fn#120654, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:2744, offset: 0x02532118, size: 38 bytes, params: 2, frame: 12
var r0;
let value = null;
if (value != sessionId) {
value = environment.__proto__.__proto__.__proto__;
value = SessionsStore.getSessionById(sessionId);
r0 = value;
} else {
r0 = value;
}
return r0;
}
function _fun120655({sessionId}) { // fn#120655, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:2865, offset: 0x0253213e, size: 22 bytes, params: 2, frame: 2
return sessionId === env0_0;
}
function _fun120658() { // fn#120658, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:3197, offset: 0x02532209, size: 169 bytes, params: 1, frame: 18
let value = environment.__proto__.__proto__.__proto__;
(require(9422) /* metro dependency 9422: GameConsoleActionCreators */).disconnectRemote();
value = importDefault(4647) /* metro dependency 4647: AlertActionCreators */;
const show = value.show;
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
const string = intl.string;
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
Reflect.apply(show, value, [{title: Reflect.apply(string, intl, [t.wGMxr3]), body: intl.string(t.i5k8b5)}]);
}
function _fun120660() { // fn#120660, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:3998, offset: 0x025324c1, size: 37 bytes, params: 1, frame: 11
const value = environment.__proto__.__proto__.__proto__;
return (require(9422) /* metro dependency 9422: GameConsoleActionCreators */).disconnectRemote();
}
function _fun120650(a0) { // fn#120650, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15924:1914, offset: 0x02531ebe, size: 160 bytes, params: 2, frame: 17
var r2;
let value = environment.__proto__.__proto__.__proto__.__proto__;
const value2 = GAME_CONSOLE_SESSIONS.has(a0.clientInfo.os);
const getVoiceStateForSession = VoiceStateStore.getVoiceStateForSession;
const value5 = Reflect.apply(getVoiceStateForSession, VoiceStateStore, [AuthenticationStore.getId(),
a0.sessionId]) != null;
const value7 = env0_0 == null;
if (value7) {
r2 = value7;
} else {
value = require(10838) /* metro dependency 10838: coercePlatformTypeToConsoleType */;
value = value.coercePlatformTypeToConsoleType(env0_0.type);
value = value === a0.clientInfo.os;
r2 = value;
}
return value2 && r2 && value5;
}