BetterDiscordApp-v2/client/src/index.js

59 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-01-10 21:48:10 +01:00
/**
* BetterDiscord Client Core
* 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.
* https://betterdiscord.net
2018-01-10 21:48:10 +01:00
*
* This source code is licensed under the MIT license found in the
* 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;
window.pm = PluginManager;
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();
}