426 lines
17 KiB
TypeScript
426 lines
17 KiB
TypeScript
/* Metro module 12590; source: stores/ActivityTrackingStore.tsx; dependencies: [6, 7, 15, 17, 18, 4266, 1348, 1226, 4267, 4270, 4294, 1934, 661, 672, 587, 4278, 11328, 4041, 4482, 566, 694, 2] */
|
|
function _fun96464(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#96464, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:6, offset: 0x0215ecdf, size: 654 bytes, params: 8, frame: 22
|
|
const env0_0 = require;
|
|
const _arrayLikeToArray_96470 = function(a0, a1) {
|
|
var r0;
|
|
var r1;
|
|
var r2;
|
|
var value3;
|
|
var length;
|
|
var value5;
|
|
var value = undefined;
|
|
var value2 = value == null;
|
|
reducibleJoin2: while (true) {
|
|
if (value2) {
|
|
r0 = value2;
|
|
break reducibleJoin2;
|
|
}
|
|
value3 = value > a0.length;
|
|
r0 = value3;
|
|
break reducibleJoin2;
|
|
}
|
|
reducibleJoin4: while (true) {
|
|
if (r0) {
|
|
length = a0.length;
|
|
r1 = length;
|
|
break reducibleJoin4;
|
|
}
|
|
r1 = value;
|
|
break reducibleJoin4;
|
|
}
|
|
value = (0, global.Array)(r1);
|
|
var value4 = 0;
|
|
if (value4 < r1) {
|
|
r2 = value4;
|
|
reducibleLoop5: while (true) {
|
|
value[r2] = a0[r2];
|
|
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
|
|
if (value5 < r1) {
|
|
r2 = value5;
|
|
continue reducibleLoop5;
|
|
}
|
|
break reducibleLoop5;
|
|
}
|
|
}
|
|
return value;
|
|
};
|
|
const closure = LOGOUT_96475;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_3 = importDefault(6) /* metro dependency 6 */;
|
|
const env0_4 = importDefault(7) /* metro dependency 7 */;
|
|
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 runningGameStoreNative = importDefault(4266) /* metro dependency 4266: RunningGameStoreNative */;
|
|
const userSettingsProtoStore = importDefault(1348) /* metro dependency 1348: UserSettingsProtoStore */;
|
|
const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */;
|
|
const detectableGameStore = importDefault(4267) /* metro dependency 4267: DetectableGameStore */;
|
|
const libraryApplicationStore = importDefault(4270) /* metro dependency 4270: LibraryApplicationStore */;
|
|
const rtcConnectionStore = importDefault(4294) /* metro dependency 4294: RTCConnectionStore */;
|
|
const selectedChannelStore = importDefault(1934) /* metro dependency 1934: SelectedChannelStore */;
|
|
const env0_15 = (require(661) /* metro dependency 661: Constants */).Distributors;
|
|
let Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
|
|
let MINUTE = Millis.MINUTE;
|
|
const env0_17 = 30 * MINUTE;
|
|
Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
|
|
MINUTE = Millis.MINUTE;
|
|
const env0_18 = 5 * MINUTE;
|
|
const Storage = (require(587) /* metro dependency 587: Storage */).Storage;
|
|
const env0_19 = Storage.get('ActivityTrackingStore') ?? ({});
|
|
const env0_20 = {};
|
|
const Store = (importDefault(566) /* metro dependency 566: flux */).Store;
|
|
_fun96476(Store).displayName = 'ActivityTrackingStore';
|
|
value = new value(importDefault(694) /* metro dependency 694: Dispatcher */, {RUNNING_GAMES_CHANGE: function() {
|
|
handleRunningGamesChange();
|
|
}, CONNECTION_OPEN: CONNECTION_OPEN_96481, CONNECTION_CLOSED: CONNECTION_CLOSED_96482, LOGOUT: closure,
|
|
ACTIVITY_UPDATE_SUCCESS: ACTIVITY_UPDATE_SUCCESS, ACTIVITY_UPDATE_FAIL: ACTIVITY_UPDATE_FAIL});
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('stores/ActivityTrackingStore.tsx');
|
|
exports.default = value;
|
|
}
|
|
|
|
function _isNativeReflectConstruct_96465() { // fn#96465, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:253, offset: 0x0215ef6d, 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_96465_isNativeReflectConstruct = function() {
|
|
return !!result;
|
|
})();
|
|
}
|
|
|
|
function _createForOfIteratorHelperLoose_96468(a0, a1) { // fn#96468, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:446, offset: 0x0215efcf, size: 372 bytes, params: 3, frame: 20
|
|
var r6;
|
|
var r9;
|
|
var r5;
|
|
var value3;
|
|
var regexp;
|
|
const env0_0 = a0;
|
|
const Symbol = global.Symbol;
|
|
let value = typeof Symbol !== 'undefined';
|
|
let r1 = value && a0[global.Symbol.iterator];
|
|
r1 = !r1 ? a0['@@iterator'] : r1;
|
|
if (r1) {
|
|
value = r1.call(a0);
|
|
return value.next.bind(value);
|
|
}
|
|
const Array = global.Array;
|
|
if (Array.isArray(a0)) {
|
|
if (r1) {
|
|
}
|
|
return _fun96469;
|
|
}
|
|
value = undefined;
|
|
if (a0) {
|
|
if (typeof a0 === 'string') {
|
|
value = _arrayLikeToArray_96470(a0, value);
|
|
r5 = value;
|
|
} else {
|
|
value3 = ({}).toString.call(a0).slice(8, -1);
|
|
r6 = value3 === 'Object' && a0.constructor;
|
|
r9 = r6 ? a0.constructor.name : value3;
|
|
if (r9 === 'Map') {
|
|
r6 = global.Array.from(a0);
|
|
} else if (r9 === 'Set') {
|
|
r6 = global.Array.from(a0);
|
|
} else if (r9 === 'Arguments') {
|
|
value = _arrayLikeToArray_96470(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
|
|
if (regexp.test(r9)) {
|
|
value = _arrayLikeToArray_96470(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
r6 = value;
|
|
}
|
|
}
|
|
r5 = r6;
|
|
}
|
|
} else {
|
|
r5 = value;
|
|
}
|
|
if (r5) {
|
|
if (r5) {
|
|
}
|
|
return _fun96469;
|
|
}
|
|
const TypeError = global.TypeError;
|
|
throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
|
|
}
|
|
|
|
function stopActivity(a0) { // fn#96471, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:1493, offset: 0x0215f143, size: 137 bytes, params: 2, frame: 14
|
|
const value = a1;
|
|
if (!(value !== undefined) || value) {
|
|
updateActivity_96472(a0, true);
|
|
}
|
|
const property = env0_20[a0.applicationId];
|
|
if (property != null) {
|
|
property.stop();
|
|
delete env0_20[a0.applicationId];
|
|
}
|
|
delete env0_19[a0.applicationId];
|
|
const Storage = (require(587) /* metro dependency 587: Storage */).Storage;
|
|
Storage.set(env0_16, env0_19);
|
|
}
|
|
|
|
function updateActivity_96472(a0) { // fn#96472, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:1671, offset: 0x0215f1cc, size: 483 bytes, params: 2, frame: 27
|
|
var interval;
|
|
var start;
|
|
var Storage;
|
|
var set;
|
|
let value = a1;
|
|
const env0_0 = a0;
|
|
const r2 = value !== undefined ? value : false;
|
|
const Date = global.Date;
|
|
value = Date.now();
|
|
const updatedAt = a0.updatedAt;
|
|
const value2 = 0;
|
|
let r16 = updatedAt != null ? value - a0.updatedAt : value2;
|
|
let binding = env0_17;
|
|
r16 = r16 > binding + env0_18 ? value2 : r16;
|
|
const libraryApplicationUtilsModule = require(4278) /* metro dependency 4278: LibraryApplicationUtils */;
|
|
const shouldShareApplicationActivity = libraryApplicationUtilsModule.shouldShareApplicationActivity;
|
|
let applicationId = a0.applicationId;
|
|
const shouldShareApplicationActivity2 = Reflect.apply(shouldShareApplicationActivity, libraryApplicationUtilsModule,
|
|
[applicationId, LibraryApplicationStore]);
|
|
const voiceChannelId = SelectedChannelStore.getVoiceChannelId();
|
|
const sessionId = AuthenticationStore.getSessionId();
|
|
const mediaSessionId = RTCConnectionStore.getMediaSessionId();
|
|
const defaultImport = importDefault(11328) /* metro dependency 11328: ActivitiesActionCreators */;
|
|
const updateActivity = defaultImport.updateActivity;
|
|
const object2 = {};
|
|
object2.applicationId = a0.applicationId;
|
|
object2.distributor = a0.isDiscordApplication ? Distributors.DISCORD : a0.distributor;
|
|
object2.shareActivity = shouldShareApplicationActivity2;
|
|
object2.token = a0.token;
|
|
const Math = global.Math;
|
|
object2.duration = Math.floor(r16 / 1000);
|
|
object2.closed = r2;
|
|
object2.exePath = a0.exePath;
|
|
object2.voiceChannelId = voiceChannelId;
|
|
object2.sessionId = sessionId;
|
|
object2.mediaSessionId = mediaSessionId;
|
|
Reflect.apply(updateActivity, defaultImport, [object2]);
|
|
a0.updatedAt = value;
|
|
binding = env0_20;
|
|
applicationId = a0.applicationId;
|
|
if (binding[applicationId] == null) {
|
|
binding = env0_20;
|
|
applicationId = a0.applicationId;
|
|
interval = new (require(4041) /* metro dependency 4041: Timers */).Interval();
|
|
binding[applicationId] = interval;
|
|
start = interval.start;
|
|
binding = env0_17;
|
|
Reflect.apply(start, interval, [binding, _fun96473]);
|
|
}
|
|
if (!r2) {
|
|
binding = env0_19;
|
|
binding[a0.applicationId] = a0;
|
|
Storage = (require(587) /* metro dependency 587: Storage */).Storage;
|
|
set = Storage.set;
|
|
binding = env0_16;
|
|
Reflect.apply(set, Storage, [binding, env0_19]);
|
|
}
|
|
}
|
|
|
|
function handleRunningGamesChange() { // fn#96474, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:2329, offset: 0x0215f3af, size: 368 bytes, params: 1, frame: 28
|
|
var r7;
|
|
var r15;
|
|
var r2;
|
|
var value8;
|
|
var game;
|
|
var add;
|
|
var id;
|
|
var updateActivity_96472Binding;
|
|
var object2;
|
|
var Date;
|
|
var distributor;
|
|
var moduleValue;
|
|
var removeExecutablePathPrefix;
|
|
var exePath;
|
|
var value9;
|
|
var property;
|
|
var has;
|
|
var value12;
|
|
const value = a0;
|
|
const r6 = !(value !== undefined) || value;
|
|
const visibleRunningGames = RunningGameStoreNative.getVisibleRunningGames();
|
|
const Set = global.Set;
|
|
const set = new Set();
|
|
const value5 = _createForOfIteratorHelperLoose_96468(visibleRunningGames);
|
|
const value6 = value5();
|
|
let done = value6.done;
|
|
if (!done) {
|
|
r7 = value6;
|
|
while (true) {
|
|
value8 = r7.value;
|
|
game = DetectableGameStore.findGame(value8);
|
|
if (game != null) {
|
|
add = set.add;
|
|
id = game.id;
|
|
Reflect.apply(add, set, [id]);
|
|
id = game.id;
|
|
if (id in env0_19) {
|
|
break;
|
|
}
|
|
updateActivity_96472Binding = updateActivity_96472;
|
|
object2 = {};
|
|
id = game.id;
|
|
object2.applicationId = id;
|
|
Date = global.Date;
|
|
object2.updatedAt = Date.now();
|
|
distributor = value8.distributor;
|
|
object2.distributor = distributor;
|
|
moduleValue = require(4482) /* metro dependency 4482: GameAnalyticsUtils */;
|
|
removeExecutablePathPrefix = moduleValue.removeExecutablePathPrefix;
|
|
exePath = value8.exePath;
|
|
if (exePath != null) {
|
|
r15 = exePath;
|
|
continue;
|
|
}
|
|
r15 = '';
|
|
continue;
|
|
object2.exePath = Reflect.apply(removeExecutablePathPrefix, moduleValue, [r15]);
|
|
updateActivity_96472Binding(object2);
|
|
break;
|
|
}
|
|
value9 = value5();
|
|
done = value9.done;
|
|
if (done) {
|
|
break;
|
|
}
|
|
r7 = value9;
|
|
continue;
|
|
}
|
|
}
|
|
const Object = global.Object;
|
|
const value10 = Object.keys(env0_19);
|
|
let length = value10.length;
|
|
const value11 = 0;
|
|
if (value11 < length) {
|
|
r2 = value11;
|
|
while (true) {
|
|
property = value10[r2];
|
|
has = set.has;
|
|
if (!Reflect.apply(has, set, [property])) {
|
|
stopActivity(env0_19[property], r6);
|
|
}
|
|
value12 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
|
|
length = value10.length;
|
|
if (value12 < length) {
|
|
r2 = value12;
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
function LOGOUT_96475() { // fn#96475, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:2780, offset: 0x0215f51f, size: 82 bytes, params: 1, frame: 15
|
|
var r3;
|
|
var property;
|
|
var value4;
|
|
const Object = global.Object;
|
|
const value2 = Object.keys(env0_19);
|
|
let length = value2.length;
|
|
const value3 = 0;
|
|
if (value3 < length) {
|
|
for (r3 = value3; true; r3 = value4) {
|
|
property = value2[r3];
|
|
stopActivity(env0_19[property]);
|
|
value4 = typeof r3 === 'bigint' ? r3 + 1n : +r3 + 1;
|
|
length = value2.length;
|
|
if (!(value4 < length)) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function _fun96476(a0) { // fn#96476, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:2890, offset: 0x0215f571, size: 97 bytes, params: 2, frame: 16
|
|
const closure = ActivityTrackingStore;
|
|
env0_7(closure, a0);
|
|
return env0_4(closure, [{key: 'initialize', value: function() {
|
|
this.waitFor(AuthenticationStore, DetectableGameStore, LibraryApplicationStore, RTCConnectionStore,
|
|
RunningGameStoreNative, SelectedChannelStore, UserSettingsProtoStore);
|
|
this.syncWith([UserSettingsProtoStore], handleRunningGamesChange);
|
|
}}, {key: 'getActivities', value: value_96479}]);
|
|
}
|
|
|
|
function CONNECTION_OPEN_96481() { // fn#96481, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:3506, offset: 0x0215f620, size: 104 bytes, params: 1, frame: 15
|
|
var r3;
|
|
var property;
|
|
var value4;
|
|
if (env0_21) {
|
|
return false;
|
|
}
|
|
const Object = global.Object;
|
|
const value2 = Object.keys(env0_19);
|
|
let length = value2.length;
|
|
const value3 = 0;
|
|
if (value3 < length) {
|
|
r3 = value3;
|
|
reducibleLoop2: while (true) {
|
|
property = value2[r3];
|
|
updateActivity_96472(env0_19[property]);
|
|
value4 = typeof r3 === 'bigint' ? r3 + 1n : +r3 + 1;
|
|
length = value2.length;
|
|
if (value4 < length) {
|
|
r3 = value4;
|
|
continue reducibleLoop2;
|
|
}
|
|
break reducibleLoop2;
|
|
}
|
|
}
|
|
handleRunningGamesChange(false);
|
|
}
|
|
|
|
function CONNECTION_CLOSED_96482({code}) { // fn#96482, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:3682, offset: 0x0215f688, size: 35 bytes, params: 2, frame: 9
|
|
if (code === 4004) {
|
|
LOGOUT_96475();
|
|
}
|
|
}
|
|
|
|
function ACTIVITY_UPDATE_SUCCESS({applicationId, token}) { // fn#96483, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:3794, offset: 0x0215f6ab, size: 90 bytes, params: 2, frame: 14
|
|
const property = env0_19[applicationId];
|
|
if (property == null) {
|
|
return false;
|
|
}
|
|
property.token = token;
|
|
const Storage = (require(587) /* metro dependency 587: Storage */).Storage;
|
|
Storage.set(env0_16, env0_19);
|
|
}
|
|
|
|
function ACTIVITY_UPDATE_FAIL({applicationId}) { // fn#96484, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12780:3941, offset: 0x0215f705, size: 90 bytes, params: 2, frame: 14
|
|
const property = env0_19[applicationId];
|
|
if (property == null) {
|
|
return false;
|
|
}
|
|
property.token = null;
|
|
property.updatedAt = null;
|
|
const Storage = (require(587) /* metro dependency 587: Storage */).Storage;
|
|
Storage.set(env0_16, env0_19);
|
|
}
|
|
|