515 lines
19 KiB
TypeScript
515 lines
19 KiB
TypeScript
/* Metro module 1926; source: modules/app_database/system/DatabaseManager.tsx; dependencies: [5, 6, 7, 15, 17, 18, 1226, 3, 694, 1927, 1911, 566, 2] */
|
|
function _fun21293(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#21293, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:6, offset: 0x00eed014, size: 349 bytes, params: 8, frame: 19
|
|
const env0_0 = require;
|
|
const _arrayLikeToArray_21296 = 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 _databaseName = function(a0) {
|
|
return '@account.' + a0;
|
|
};
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_4 = importDefault(5) /* metro dependency 5 */;
|
|
const env0_5 = importDefault(6) /* metro dependency 6 */;
|
|
const env0_6 = importDefault(7) /* metro dependency 7 */;
|
|
const env0_7 = importDefault(15) /* metro dependency 15 */;
|
|
const env0_8 = importDefault(17) /* metro dependency 17 */;
|
|
const env0_9 = importDefault(18) /* metro dependency 18 */;
|
|
const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */;
|
|
let value = importDefault(3) /* metro dependency 3: Logger */;
|
|
value = new value('DatabaseManager');
|
|
const Store = (importDefault(566) /* metro dependency 566: flux */).Store;
|
|
value = _fun21304(Store);
|
|
value = new value();
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/app_database/system/DatabaseManager.tsx');
|
|
exports.default = value;
|
|
}
|
|
|
|
function _createForOfIteratorHelperLoose_21294(a0, a1) { // fn#21294, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:178, offset: 0x00eed171, size: 370 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 _fun21295;
|
|
}
|
|
value = undefined;
|
|
if (a0) {
|
|
if (typeof a0 === 'string') {
|
|
value = _arrayLikeToArray_21296(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_21296(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
|
|
if (regexp.test(r9)) {
|
|
value = _arrayLikeToArray_21296(a0, value);
|
|
r6 = value;
|
|
} else {
|
|
r6 = value;
|
|
}
|
|
}
|
|
r5 = r6;
|
|
}
|
|
} else {
|
|
r5 = value;
|
|
}
|
|
if (r5) {
|
|
if (r5) {
|
|
}
|
|
return _fun21295;
|
|
}
|
|
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 _isNativeReflectConstruct_21297() { // fn#21297, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:1088, offset: 0x00eed2e3, size: 94 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_21297_isNativeReflectConstruct = function() {
|
|
return !!result;
|
|
})();
|
|
}
|
|
|
|
function _trySpeculativelyOpenDatabaseAsync() { // fn#21301, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:4788, offset: 0x00eed35e, size: 48 bytes, params: 1, frame: 14
|
|
return env0_4(_fun21303).apply(this, arguments);
|
|
}
|
|
|
|
function _fun21304(a0) { // fn#21304, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:1322, offset: 0x00eed432, size: 297 bytes, params: 2, frame: 17
|
|
const closure = DatabaseManager;
|
|
env0_9(closure, a0);
|
|
const binding = env0_6;
|
|
const items2 = [{key: 'initialize', value: value_21310}];
|
|
items2[1] = {key: 'databaseName', value: function(a0) {
|
|
return _databaseName(a0);
|
|
}};
|
|
items2[2] = {key: 'database', value: function(a0) {
|
|
var r0;
|
|
var value2;
|
|
var value = null;
|
|
if (value != a0) {
|
|
value2 = this.databases.get(a0);
|
|
r0 = value != value2 ? value2 : value;
|
|
} else {
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}};
|
|
items2[3] = {key: 'carefullyOpenDatabase', value: value_21314};
|
|
items2[4] = {key: 'replaceDisableAllDatabases', value: value_21317};
|
|
items2[5] = {key: 'remove', value: value_21318};
|
|
items2[6] = {key: 'handleClearCaches', value: function(a0) {
|
|
if (a0.preventWritingCachesAgainThisSession) {
|
|
this.preventWritingCachesAgainThisSession = true;
|
|
}
|
|
this.replaceDisableAllDatabases('DatabaseManager (' + a0.reason + ')');
|
|
}};
|
|
items2[7] = {key: 'handleConnectionOpen', value: value_21320};
|
|
items2[8] = {key: 'handleAuthenticationStoreChanged', value: value_21321};
|
|
const env0_0 = env0_4(_fun21323);
|
|
items2[9] = {key: 'carefullySpeculativelyOpen', value: value_21325};
|
|
return binding(closure, items2);
|
|
}
|
|
|
|
function* _fun21303(a0) { // fn#21303, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:4879, offset: 0x00eed397, size: 155 bytes, params: 2, frame: 18
|
|
var binding2;
|
|
var property;
|
|
var value4;
|
|
var Database;
|
|
var open;
|
|
var value5;
|
|
var value6;
|
|
var value7;
|
|
var error;
|
|
if (false) {
|
|
return undefined;
|
|
}
|
|
value = environment.__proto__.__proto__;
|
|
const value3 = env2_15(a0);
|
|
let binding = env2_11;
|
|
binding.verbose('speculatively opening ' + value3);
|
|
try {
|
|
binding = env2_0;
|
|
} catch (error) {
|
|
binding = env2_11;
|
|
binding.warn("couldn't speculatively open database.", error);
|
|
return null;
|
|
}
|
|
try {
|
|
binding2 = env2_3;
|
|
} catch (error) {
|
|
binding = env2_11;
|
|
binding.warn("couldn't speculatively open database.", error);
|
|
return null;
|
|
}
|
|
try {
|
|
property = binding2[10];
|
|
} catch (error) {
|
|
binding = env2_11;
|
|
binding.warn("couldn't speculatively open database.", error);
|
|
return null;
|
|
}
|
|
try {
|
|
value4 = binding(property);
|
|
} catch (error) {
|
|
binding = env2_11;
|
|
binding.warn("couldn't speculatively open database.", error);
|
|
return null;
|
|
}
|
|
try {
|
|
Database = value4.Database;
|
|
} catch (error) {
|
|
binding = env2_11;
|
|
binding.warn("couldn't speculatively open database.", error);
|
|
return null;
|
|
}
|
|
try {
|
|
open = Database.open;
|
|
} catch (error) {
|
|
binding = env2_11;
|
|
binding.warn("couldn't speculatively open database.", error);
|
|
return null;
|
|
}
|
|
try {
|
|
value5 = Reflect.apply(open, Database, [value3]);
|
|
} catch (error) {
|
|
binding = env2_11;
|
|
binding.warn("couldn't speculatively open database.", error);
|
|
return null;
|
|
}
|
|
yield value5;
|
|
try {
|
|
value6 = undefined;
|
|
value7 = false;
|
|
} catch (error) {
|
|
binding = env2_11;
|
|
binding.warn("couldn't speculatively open database.", error);
|
|
return null;
|
|
}
|
|
return value7 ? value6 : value6;
|
|
}
|
|
|
|
function DatabaseManager() { // fn#21305, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:1334, offset: 0x00eed55b, size: 263 bytes, params: 1, frame: 20
|
|
var environment;
|
|
let value = environment.__proto__;
|
|
env1_5(this, DatabaseManager);
|
|
const items2 = [importDefault(694) /* metro dependency 694: Dispatcher */];
|
|
items2[1] = {CLEAR_CACHES: CLEAR_CACHES_21306, CONNECTION_CLOSED: CONNECTION_CLOSED_21307,
|
|
CONNECTION_OPEN: CONNECTION_OPEN_21308, LOGOUT: LOGOUT_21309};
|
|
const DispatchBand = (require(694) /* metro dependency 694: Dispatcher */).DispatchBand;
|
|
const Early = DispatchBand.Early;
|
|
items2[2] = Early;
|
|
const value3 = env1_8(DatabaseManager);
|
|
value = env1_7(this, _isNativeReflectConstruct_21297() ? global.Reflect.construct(value3, items2,
|
|
env1_8(this).constructor) : value3.apply(this, items2));
|
|
const Map = global.Map;
|
|
const value4 = Object.create(Map.prototype, {constructor: {value: Map}});
|
|
const map = new Map();
|
|
value.databases = map instanceof Object ? map : value4;
|
|
value.activeUserId = null;
|
|
value.preventWritingCachesAgainThisSession = false;
|
|
return value;
|
|
}
|
|
|
|
function value_21310() { // fn#21310, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:1941, offset: 0x00eed6a1, size: 100 bytes, params: 1, frame: 15
|
|
var environment;
|
|
const waitFor = this.waitFor;
|
|
let value = environment.__proto__;
|
|
Reflect.apply(waitFor, this, [AuthenticationStore]);
|
|
const carefullySpeculativelyOpen = this.carefullySpeculativelyOpen;
|
|
value = importAll(1927) /* metro dependency 1927: StartupDataNative */;
|
|
const getUserId = value.getUserId;
|
|
Reflect.apply(carefullySpeculativelyOpen, this, [Reflect.apply(getUserId, value, [])]);
|
|
this.handleAuthenticationStoreChanged();
|
|
AuthenticationStore.addChangeListener(_fun21311);
|
|
}
|
|
|
|
function value_21314(a0) { // fn#21314, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:2327, offset: 0x00eed747, size: 184 bytes, params: 2, frame: 20
|
|
var environment;
|
|
var databases;
|
|
var value;
|
|
var value2;
|
|
if (this.preventWritingCachesAgainThisSession) {
|
|
value = environment.__proto__;
|
|
env1_11.verbose('Not opening database because caches have been manually cleared.');
|
|
return null;
|
|
}
|
|
if (a0 != null) {
|
|
databases = this.databases;
|
|
if (!databases.has(a0)) {
|
|
value = tryOpenDatabase(a0);
|
|
value2 = environment.__proto__;
|
|
env1_11.verbose('added database (' + a0 + ' → ' + value + ')');
|
|
this.databases.set(a0, value);
|
|
this.emitChange();
|
|
}
|
|
}
|
|
return this.database(a0);
|
|
}
|
|
|
|
function value_21317(a0) { // fn#21317, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:2954, offset: 0x00eed8c8, size: 189 bytes, params: 2, frame: 18
|
|
var r3;
|
|
var value3;
|
|
var value4;
|
|
var value5;
|
|
let value = environment.__proto__;
|
|
env1_11.info('disabling and nulling all databases (reason: ' + a0 + ')');
|
|
const _createForOfIteratorHelperLoose_21294Binding = _createForOfIteratorHelperLoose_21294;
|
|
let databases = this.databases;
|
|
value = databases.keys();
|
|
value = _createForOfIteratorHelperLoose_21294Binding(value);
|
|
const value2 = value();
|
|
let done = value2.done;
|
|
if (!done) {
|
|
r3 = value2;
|
|
while (true) {
|
|
value3 = r3.value;
|
|
databases = this.databases;
|
|
value4 = databases.get(value3);
|
|
if (value4 != null) {
|
|
value4.disable(a0);
|
|
}
|
|
if (value4 == null) {
|
|
continue;
|
|
}
|
|
value4.close();
|
|
databases = this.databases;
|
|
databases.set(value3, null);
|
|
value5 = value();
|
|
done = value5.done;
|
|
if (done) {
|
|
break;
|
|
}
|
|
r3 = value5;
|
|
continue;
|
|
}
|
|
}
|
|
this.emitChange();
|
|
}
|
|
|
|
function value_21318(a0) { // fn#21318, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:3256, offset: 0x00eed985, size: 127 bytes, params: 2, frame: 20
|
|
const value = this.databases.get(a0);
|
|
env1_11.log('removing database (user: ' + a0 + ', database: ' + value + ')');
|
|
if (value != null) {
|
|
value.close();
|
|
}
|
|
this.databases.delete(a0);
|
|
this.emitChange();
|
|
}
|
|
|
|
function value_21320() { // fn#21320, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:3647, offset: 0x00eeda4f, size: 128 bytes, params: 1, frame: 16
|
|
const value = environment.__proto__;
|
|
const id = AuthenticationStore.getId();
|
|
const value3 = this.databases.get(id);
|
|
const value4 = undefined;
|
|
if (value3 == null && (value3 == null ? value4 : value3.state()) !== (require(1911) /* metro dependency 1911: js */).DatabaseState.Open) {
|
|
this.remove(id);
|
|
}
|
|
this.carefullyOpenDatabase(id);
|
|
return value4;
|
|
}
|
|
|
|
function value_21321() { // fn#21321, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:3861, offset: 0x00eedacf, size: 189 bytes, params: 1, frame: 24
|
|
var databases;
|
|
var value3;
|
|
const value = environment.__proto__;
|
|
const id = AuthenticationStore.getId();
|
|
const activeUserId = this.activeUserId;
|
|
if (id !== activeUserId) {
|
|
databases = this.databases;
|
|
value3 = databases.get(activeUserId);
|
|
env1_11.verbose('active user changed (now: ' + id + ', was: ' + activeUserId + ', was: ' + value3 + ')');
|
|
if (value3 != null) {
|
|
value3.close();
|
|
}
|
|
(importAll(1927) /* metro dependency 1927: StartupDataNative */).setUserId(id);
|
|
this.activeUserId = id;
|
|
databases = this.databases;
|
|
databases.delete(activeUserId);
|
|
}
|
|
}
|
|
|
|
function* _fun21323(a0) { // fn#21323, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:4148, offset: 0x00eedb95, size: 285 bytes, params: 2, frame: 22
|
|
var environment;
|
|
var databases;
|
|
var value4;
|
|
var value5;
|
|
let value = undefined;
|
|
if (false) {
|
|
return value;
|
|
}
|
|
if (this.preventWritingCachesAgainThisSession) {
|
|
value = environment.__proto__.__proto__;
|
|
env2_11.verbose('Not opening database because caches have been manually cleared.');
|
|
} else {
|
|
if (a0 == null) {
|
|
return undefined;
|
|
}
|
|
yield trySpeculativelyOpenDatabaseAsync(a0);
|
|
value = undefined;
|
|
if (false) {
|
|
return value;
|
|
}
|
|
if (value == null) {
|
|
value5 = environment.__proto__.__proto__;
|
|
env2_11.verbose('discarding speculative database (' + a0 + ' → ' + value + ')');
|
|
if (value != null) {
|
|
value.close();
|
|
}
|
|
} else {
|
|
databases = this.databases;
|
|
if (databases.has(a0)) {
|
|
value5 = environment.__proto__.__proto__;
|
|
env2_11.verbose('discarding speculative database (' + a0 + ' → ' + value + ')');
|
|
if (value != null) {
|
|
value.close();
|
|
}
|
|
} else {
|
|
value4 = environment.__proto__.__proto__;
|
|
env2_11.verbose('added speculative database (' + a0 + ' → ' + value + ')');
|
|
this.databases.set(a0, value);
|
|
this.emitChange();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function DatabaseManagerCLEAR_CACHES(a0) { // fn#21306, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:1578, owner: DatabaseManager.CLEAR_CACHES, offset: 0x00eed662, size: 25 bytes, params: 2, frame: 11
|
|
return env0_0.handleClearCaches(a0);
|
|
}
|
|
|
|
function DatabaseManagerCONNECTION_CLOSED() { // fn#21307, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:1622, owner: DatabaseManager.CONNECTION_CLOSED, offset: 0x00eed67b, size: 19 bytes, params: 1, frame: 9
|
|
return env0_0.handleAuthenticationStoreChanged();
|
|
}
|
|
|
|
function tryOpenDatabase(a0) { // fn#21315, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:2515, owner: value_21314.tryOpenDatabase, offset: 0x00eed7ff, size: 140 bytes, params: 2, frame: 23
|
|
var r0;
|
|
var value4;
|
|
var error;
|
|
var error2;
|
|
var value5;
|
|
var value6;
|
|
const value2 = _databaseName(a0);
|
|
let binding = env2_11;
|
|
const verbose = binding.verbose;
|
|
let HermesInternal = global.HermesInternal;
|
|
Reflect.apply(verbose, binding, ['synchronously opening ' + value2]);
|
|
const closure = _fun21316;
|
|
let r7 = 0;
|
|
exceptionMain1: while (true) {
|
|
try {
|
|
value4 = closure();
|
|
} catch (error) {
|
|
while (true) {
|
|
binding = env2_11;
|
|
error2 = binding.error;
|
|
HermesInternal = global.HermesInternal;
|
|
concat = HermesInternal.concat;
|
|
Reflect.apply(error2, binding, ['tryUntil ' + r7, error]);
|
|
value5 = typeof r7 === 'bigint' ? r7 + 1n : +r7 + 1;
|
|
value6 = null;
|
|
if (value5 < 50) {
|
|
r7 = value5;
|
|
break;
|
|
}
|
|
r0 = value6;
|
|
continue;
|
|
return r0;
|
|
continue exceptionMain1;
|
|
}
|
|
}
|
|
r0 = value4;
|
|
return r0;
|
|
}
|
|
}
|
|
|
|
function _fun21316() { // fn#21316, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2053:2724, offset: 0x00eed88b, size: 61 bytes, params: 1, frame: 14
|
|
const Database = (require(1911) /* metro dependency 1911: js */).Database;
|
|
return Database.openSyncUnsafe(env0_0, {invalidateDisabledHandles: true});
|
|
}
|
|
|