259 lines
13 KiB
TypeScript
259 lines
13 KiB
TypeScript
/* Metro module 25; source: modules/gateway/native/fast_connect.tsx; dependencies: [26, 27, 476, 3, 477, 479, 480, 660, 12525, 5231, 12507, 12494, 20, 14, 2] */
|
|
function _fun1094(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#1094, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:30:6, offset: 0x00c531c6, size: 291 bytes, params: 8, frame: 20
|
|
const env0_0 = require;
|
|
const closure = createFastConnectSocket;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
require(26) /* metro dependency 26: checkEnv */;
|
|
let value = require(27) /* metro dependency 27 */;
|
|
const env0_4 = value.NativeModules;
|
|
const AppState = value.AppState;
|
|
const env0_6 = (require(476) /* metro dependency 476: KvCacheVersionConstants */).VERSION_TO_FORCE_RESYNCING_ALL_DATA;
|
|
value = importDefault(3) /* metro dependency 3: Logger */;
|
|
value = new value('FAST CONNECT');
|
|
value.info('initial app state (import time)', AppState.currentState);
|
|
closure();
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/gateway/native/fast_connect.tsx');
|
|
exports.createFastConnectSocket = closure;
|
|
exports.closeFastConnectSocket = closeFastConnectSocket;
|
|
exports.getLastFastConnectIdentifyUserId = getLastFastConnectIdentifyUserId;
|
|
exports.identifyWebSocket = identifyWebSocket;
|
|
}
|
|
|
|
function prepareIdentify(a0, a1, a2) { // fn#1095, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:30:224, offset: 0x00c532e9, size: 715 bytes, params: 4, frame: 25
|
|
var r5;
|
|
var r6;
|
|
var DCDFastConnectManager;
|
|
var analyticsInstallation;
|
|
var defaultImport;
|
|
var value3;
|
|
var useChannelObfuscation;
|
|
var defaultImport2;
|
|
var prepareIdentify;
|
|
var moduleValue7;
|
|
var defaultImport3;
|
|
var float;
|
|
var moduleValue8;
|
|
const binding = env0_7;
|
|
binding.info('prepareIdentify: app state: ', AppState.currentState);
|
|
const value2 = undefined;
|
|
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
|
|
if (platformUtilsModule.isAndroid()) {
|
|
defaultImport = importDefault(479) /* metro dependency 479: NativeFastConnectModule */;
|
|
analyticsInstallation = defaultImport.getConstants().analyticsInstallation;
|
|
value3 = null;
|
|
r5 = value3 != analyticsInstallation ? analyticsInstallation : value3;
|
|
} else {
|
|
r5 = NativeModules.DCDFastConnectManager.analyticsInstallation;
|
|
}
|
|
const object3 = {token: a2};
|
|
const object4 = {};
|
|
const analyticsUtilsModule = importAll(480) /* metro dependency 480: AnalyticsUtils */;
|
|
const getSuperProperties = analyticsUtilsModule.getSuperProperties;
|
|
copyDataProperties(object4, Reflect.apply(getSuperProperties, analyticsUtilsModule, []), undefined);
|
|
object4['client_app_state'] = AppState.currentState;
|
|
object4['is_fast_connect'] = true;
|
|
object4['gateway_connect_reasons'] = (importAll(660) /* metro dependency 660: RequestGatewaySocket */).describeConnectionReasons();
|
|
const value5 = null;
|
|
let r3 = value5 != r5 ? {installation_id: r5} : {};
|
|
copyDataProperties(object4, r3, undefined);
|
|
object3.properties = object4;
|
|
const gatewayCapabilitiesModule = require(12525) /* metro dependency 12525: GatewayCapabilities */;
|
|
const getClientCapabilities = gatewayCapabilitiesModule.getClientCapabilities;
|
|
const moduleValue5 = platformUtilsModule;
|
|
if (moduleValue5.isAndroid()) {
|
|
defaultImport2 = importDefault(479) /* metro dependency 479: NativeFastConnectModule */;
|
|
useChannelObfuscation = defaultImport2.getConstants().useChannelObfuscation;
|
|
r5 = value5 != useChannelObfuscation && useChannelObfuscation;
|
|
} else {
|
|
useChannelObfuscation = NativeModules.DCDFastConnectManager.useChannelObfuscation;
|
|
r5 = value5 != useChannelObfuscation && useChannelObfuscation;
|
|
}
|
|
object3.capabilities = Reflect.apply(getClientCapabilities, gatewayCapabilitiesModule,
|
|
[{useChannelObfuscation: r5}]);
|
|
object3.client_state = {guild_versions: {}};
|
|
const JSON = global.JSON;
|
|
const value8 = JSON.stringify({op: 2, d: object3});
|
|
const moduleValue6 = platformUtilsModule;
|
|
if (moduleValue6.isAndroid()) {
|
|
r3 = value5 == a1 ? value2 : a1.toString();
|
|
r6 = value5 != r3 ? r3 : value5;
|
|
defaultImport3 = importDefault(479) /* metro dependency 479: NativeFastConnectModule */;
|
|
prepareIdentify = defaultImport3.prepareIdentify;
|
|
float = global.parseFloat(a0);
|
|
moduleValue8 = require(5231) /* metro dependency 5231: isCacheEnabledNative */;
|
|
Reflect.apply(prepareIdentify, defaultImport3, [r6, value8, float,
|
|
moduleValue8.isCacheEnabled() ? VERSION_TO_FORCE_RESYNCING_ALL_DATA : value2]);
|
|
} else {
|
|
DCDFastConnectManager = NativeModules.DCDFastConnectManager;
|
|
prepareIdentify = DCDFastConnectManager.prepareIdentify;
|
|
moduleValue7 = require(5231) /* metro dependency 5231: isCacheEnabledNative */;
|
|
Reflect.apply(prepareIdentify, DCDFastConnectManager, [a1, value8, a0,
|
|
moduleValue7.isCacheEnabled() ? VERSION_TO_FORCE_RESYNCING_ALL_DATA : value5]);
|
|
}
|
|
return object3.client_state;
|
|
}
|
|
|
|
function createFastConnectSocket() { // fn#1096, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:30:1230, offset: 0x00c535b4, size: 63 bytes, params: 1, frame: 11
|
|
const WebSocket = global.window.WebSocket;
|
|
if (WebSocket != null) {
|
|
newWebSocket();
|
|
} else {
|
|
env0_7.log('Skipping fast_connect because `window.WebSocket` does not exist.');
|
|
}
|
|
}
|
|
|
|
function closeFastConnectSocket() { // fn#1101, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:30:2760, offset: 0x00c53966, size: 71 bytes, params: 1, frame: 11
|
|
let window = global.window;
|
|
if (window._ws != null) {
|
|
window = global.window;
|
|
window._ws.ws.close();
|
|
window = global.window;
|
|
window._ws = null;
|
|
}
|
|
}
|
|
|
|
function identifyWebSocket() { // fn#1103, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:30:2971, offset: 0x00c539b6, size: 99 bytes, params: 1, frame: 11
|
|
if (global.window._ws != null) {
|
|
(importDefault(14) /* metro dependency 14: TTITracker */).beginFastConnect.measure(_fun1104);
|
|
} else {
|
|
env0_7.log('Skipping identifyWebSocket because socket is null');
|
|
}
|
|
}
|
|
|
|
function newWebSocket() { // fn#1097, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:30:1288, owner: createFastConnectSocket.newWebSocket, offset: 0x00c535f3, size: 599 bytes, params: 1, frame: 25
|
|
var environment;
|
|
var supportsZstd;
|
|
var defaultImport;
|
|
var isAndroid2;
|
|
var object2;
|
|
var closure;
|
|
const value = environment.__proto__;
|
|
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
|
|
if (platformUtilsModule.isAndroid()) {
|
|
defaultImport = importDefault(12507) /* metro dependency 12507: NativeCompressionModule */;
|
|
supportsZstd = defaultImport.getConstants().supportsZstd;
|
|
} else {
|
|
supportsZstd = NativeModules.DCDCompressionManager.supportsZstd;
|
|
}
|
|
const r12 = supportsZstd ? 'zstd-stream' : 'zlib-stream';
|
|
let GLOBAL_ENV = global.window.GLOBAL_ENV;
|
|
const GATEWAY_ENDPOINT = GLOBAL_ENV.GATEWAY_ENDPOINT;
|
|
GLOBAL_ENV = global.window.GLOBAL_ENV;
|
|
const API_VERSION = GLOBAL_ENV.API_VERSION;
|
|
const value4 = '' + GATEWAY_ENDPOINT + '/?encoding=json&v=' + API_VERSION + '&compress=' + r12;
|
|
let binding = env1_7;
|
|
binding.log('[FAST CONNECT] ' + value4);
|
|
const Date = global.Date;
|
|
const env0_0 = Date.now();
|
|
const value5 = (importDefault(12494) /* metro dependency 12494: createWebSocketAndroid */)(value4);
|
|
const float = global.parseFloat(value5._socketId);
|
|
if (global.isNaN(float)) {
|
|
binding = env1_7;
|
|
binding.log('[FAST CONNECT] Unable to create socketId from NaN value ', value5._socketId);
|
|
} else {
|
|
isAndroid2 = platformUtilsModule.isAndroid();
|
|
if (supportsZstd) {
|
|
if (isAndroid2) {
|
|
(importDefault(12507) /* metro dependency 12507: NativeCompressionModule */).enableZstdStreamSupport(float);
|
|
} else {
|
|
NativeModules.DCDCompressionManager.enableZstdStreamSupport(float, 0);
|
|
}
|
|
} else if (isAndroid2) {
|
|
(importDefault(12507) /* metro dependency 12507: NativeCompressionModule */).enableZlibStreamSupport(float);
|
|
} else {
|
|
NativeModules.DCDCompressionManager.enableZlibStreamSupport(float);
|
|
}
|
|
object2 = {'open': false, 'gateway': null, 'identify': false, 'messages': null, 'clientState': null,
|
|
'userId': null};
|
|
object2.gateway = value4;
|
|
object2.messages = [];
|
|
value5.onopen = onopen;
|
|
closure = onerror_1099;
|
|
value5.onerror = closure;
|
|
value5.onclose = closure;
|
|
value5.onmessage = onmessage_1100;
|
|
global.window._ws = {ws: value5, state: object2};
|
|
(importDefault(20) /* metro dependency 20: AppStartPerformance */).mark('🌐', 'Fastconnect socket created');
|
|
}
|
|
}
|
|
|
|
function _fun1104() { // fn#1104, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:30:3052, offset: 0x00c53a19, size: 278 bytes, params: 1, frame: 20
|
|
var environment;
|
|
var userId;
|
|
var r7;
|
|
var _ws;
|
|
var ws;
|
|
var state;
|
|
var _socketId;
|
|
var moduleValue;
|
|
var defaultImport;
|
|
let value = environment.__proto__;
|
|
const value2 = (importDefault(14) /* metro dependency 14: TTITracker */).loadFastConnectNativeModule.measure(_fun1105);
|
|
const value3 = null;
|
|
if (value3 == value2) {
|
|
env1_7.log('Skipping fast_connect because we could not find a token to connect with.');
|
|
} else if (value2 !== '') {
|
|
_ws = global.window._ws;
|
|
ws = _ws.ws;
|
|
state = _ws.state;
|
|
_socketId = ws._socketId;
|
|
moduleValue = require(477) /* metro dependency 477: PlatformUtils */;
|
|
if (moduleValue.isAndroid()) {
|
|
defaultImport = importDefault(479) /* metro dependency 479: NativeFastConnectModule */;
|
|
userId = defaultImport.getConstants().userId;
|
|
} else {
|
|
userId = NativeModules.DCDFastConnectManager.userId;
|
|
}
|
|
r7 = value3 != userId ? userId : value3;
|
|
r7 = value3 != userId ? userId : value3;
|
|
state.userId = r7;
|
|
value = prepareIdentify(_socketId, value3 != userId ? userId : value3, value2);
|
|
state.identify = true;
|
|
state.clientState = value;
|
|
} else {
|
|
env1_7.log('Skipping fast_connect because we could not find a token to connect with.');
|
|
}
|
|
}
|
|
|
|
function newWebSocketOnopen() { // fn#1098, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:30:2035, owner: createFastConnectSocket.newWebSocket.onopen, offset: 0x00c5384a, size: 144 bytes, params: 1, frame: 19
|
|
let value = environment.__proto__.__proto__;
|
|
(importDefault(20) /* metro dependency 20: AppStartPerformance */).mark('🌐', 'Fastconnect socket opened');
|
|
const binding = env2_7;
|
|
const log = binding.log;
|
|
const Date = global.Date;
|
|
value = Date.now();
|
|
value -= env0_0;
|
|
Reflect.apply(log, binding, ['connected and identified in ' + value + 'ms didIdentify:' + env0_1.identify]);
|
|
env0_1.open = true;
|
|
}
|
|
|
|
function newWebSocketOnclose() { // fn#1099, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:30:2202, owner: createFastConnectSocket.newWebSocket.onclose, offset: 0x00c538da, size: 65 bytes, params: 1, frame: 14
|
|
const value = environment.__proto__.__proto__;
|
|
(importDefault(20) /* metro dependency 20: AppStartPerformance */).mark('🌐', 'Fastconnect socket close');
|
|
global.window._ws = null;
|
|
}
|
|
|
|
function newWebSocketOnmessage(a0) { // fn#1100, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:30:2285, owner: createFastConnectSocket.newWebSocket.onmessage, offset: 0x00c5391b, size: 75 bytes, params: 2, frame: 14
|
|
const value = environment.__proto__.__proto__;
|
|
(importDefault(20) /* metro dependency 20: AppStartPerformance */).mark('🌐', 'Fastconnect socket message');
|
|
env0_1.messages.push(a0);
|
|
}
|
|
|
|
function _fun1105() { // fn#1105, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:30:3109, offset: 0x00c53b2f, size: 109 bytes, params: 1, frame: 13
|
|
var r0;
|
|
var token;
|
|
let value = environment.__proto__.__proto__;
|
|
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
|
|
if (platformUtilsModule.isAndroid()) {
|
|
value = importDefault(479) /* metro dependency 479: NativeFastConnectModule */;
|
|
token = value.getConstants().token;
|
|
value = null;
|
|
r0 = value != token ? token : value;
|
|
} else {
|
|
r0 = NativeModules.DCDFastConnectManager.token;
|
|
}
|
|
return r0;
|
|
}
|
|
|