2018-01-10 21:48:10 +01:00
|
|
|
/**
|
|
|
|
* BetterDiscord Client Core
|
2018-01-29 19:15:58 +01:00
|
|
|
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
|
2018-01-10 21:48:10 +01:00
|
|
|
* All rights reserved.
|
2018-01-29 19:15:58 +01:00
|
|
|
* https://betterdiscord.net
|
2018-01-10 21:48:10 +01:00
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
2018-01-27 15:40:35 +01:00
|
|
|
* LICENSE file in the root directory of this source tree.
|
2018-01-10 21:48:10 +01:00
|
|
|
*/
|
|
|
|
|
2018-02-13 17:57:05 +01:00
|
|
|
import { DOM, BdUI, Modals } from 'ui';
|
2018-01-29 18:34:31 +01:00
|
|
|
import BdCss from './styles/index.scss';
|
2018-02-13 23:17:02 +01:00
|
|
|
import { Events, CssEditor, Globals, ExtModuleManager, PluginManager, ThemeManager, ModuleManager, WebpackModules, Settings } from 'modules';
|
2018-02-11 15:59:55 +01:00
|
|
|
import { ClientLogger as Logger, ClientIPC } from 'common';
|
2018-01-11 00:46:05 +01:00
|
|
|
|
2018-01-10 21:48:10 +01:00
|
|
|
class BetterDiscord {
|
2018-01-31 14:35:22 +01:00
|
|
|
|
2018-01-10 21:48:10 +01:00
|
|
|
constructor() {
|
2018-02-14 21:15:27 +01:00
|
|
|
window.bdglobals = Globals;
|
2018-02-11 15:59:55 +01:00
|
|
|
window.ClientIPC = ClientIPC;
|
2018-02-07 17:02:27 +01:00
|
|
|
window.css = CssEditor;
|
2018-02-03 10:25:34 +01:00
|
|
|
window.pm = PluginManager;
|
2018-03-03 02:43:54 +01:00
|
|
|
window.tm = ThemeManager;
|
2018-02-02 13:45:06 +01:00
|
|
|
window.events = Events;
|
|
|
|
window.wpm = WebpackModules;
|
2018-02-12 16:19:11 +01:00
|
|
|
window.bdsettings = Settings;
|
2018-02-13 17:57:05 +01:00
|
|
|
window.bdmodals = Modals;
|
2018-02-15 18:00:21 +01:00
|
|
|
window.bdlogs = Logger;
|
|
|
|
|
2018-01-29 18:34:31 +01:00
|
|
|
DOM.injectStyle(BdCss, 'bdmain');
|
2018-01-29 18:56:48 +01:00
|
|
|
Events.on('global-ready', this.globalReady.bind(this));
|
|
|
|
}
|
|
|
|
|
2018-01-30 16:59:27 +01:00
|
|
|
async init() {
|
2018-02-12 16:19:11 +01:00
|
|
|
await Settings.loadSettings();
|
2018-02-02 13:45:06 +01:00
|
|
|
await ModuleManager.initModules();
|
2018-02-13 23:17:02 +01:00
|
|
|
await ExtModuleManager.loadAllModules(true);
|
2018-02-13 17:57:05 +01:00
|
|
|
await PluginManager.loadAllPlugins(true);
|
|
|
|
await ThemeManager.loadAllThemes(true);
|
|
|
|
Modals.showContentManagerErrors();
|
2018-01-30 16:59:27 +01:00
|
|
|
Events.emit('ready');
|
2018-02-02 13:45:06 +01:00
|
|
|
Events.emit('discord-ready');
|
2018-01-30 16:59:27 +01:00
|
|
|
}
|
|
|
|
|
2018-01-29 18:56:48 +01:00
|
|
|
globalReady() {
|
2018-01-31 16:45:25 +01:00
|
|
|
BdUI.initUiEvents();
|
2018-01-29 19:00:31 +01:00
|
|
|
this.vueInstance = BdUI.injectUi();
|
2018-01-30 16:59:27 +01:00
|
|
|
(async () => {
|
|
|
|
this.init();
|
|
|
|
})();
|
2018-01-25 12:03:12 +01:00
|
|
|
}
|
2018-01-10 21:48:10 +01:00
|
|
|
}
|
|
|
|
|
2018-01-11 00:07:35 +01:00
|
|
|
if (window.BetterDiscord) {
|
2018-01-11 07:02:11 +01:00
|
|
|
Logger.log('main', 'Attempting to inject again?');
|
2018-01-11 00:07:35 +01:00
|
|
|
} else {
|
|
|
|
let bdInstance = new BetterDiscord();
|
2018-01-29 19:15:58 +01:00
|
|
|
}
|