Merge pull request #4 from JsSucks/global

Global
This commit is contained in:
Alexei Stukov 2018-01-16 07:02:01 +02:00 committed by GitHub
commit 02df356931
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 796 additions and 682 deletions

File diff suppressed because it is too large Load Diff

View File

@ -10,12 +10,11 @@
'use strict'; 'use strict';
const { Logger, Utils, PluginManager, BDIpc, WebpackModules, SocketProxy, Global } = require('./modules'); const { Global, Logger, Utils, PluginManager, BDIpc, WebpackModules, SocketProxy } = require('./modules');
class BetterDiscord { class BetterDiscord {
constructor() { constructor() {
Global.first();
window.bdUtils = Utils; window.bdUtils = Utils;
window.wpm = WebpackModules; window.wpm = WebpackModules;
} }

View File

@ -10,9 +10,15 @@
const { Module } = require('./modulebase'); const { Module } = require('./modulebase');
const { Events } = require('./events'); const { Events } = require('./events');
const { BDIpc } = require('./bdipc');
class Global extends Module { class Global extends Module {
constructor(args) {
super(args);
this.first();
}
bindings() { bindings() {
this.first = this.first.bind(this); this.first = this.first.bind(this);
this.setWS = this.setWS.bind(this); this.setWS = this.setWS.bind(this);
@ -20,6 +26,11 @@ class Global extends Module {
} }
first() { first() {
(async () => {
const config = await BDIpc.send('getConfig');
this.setState(config);
})();
if (window.__bd) { if (window.__bd) {
this.setState(window.__bd); this.setState(window.__bd);
window.__bd = { window.__bd = {

View File

@ -1,8 +1,8 @@
export { Global } from './global';
export { Logger, Utils, FileUtils } from './utils'; export { Logger, Utils, FileUtils } from './utils';
export { PluginManager } from './pluginmanager'; export { PluginManager } from './pluginmanager';
export { Pluging } from './plugin'; export { Pluging } from './plugin';
export { BDIpc } from './bdipc'; export { BDIpc } from './bdipc';
export { WebpackModules } from './webpackmodules'; export { WebpackModules } from './webpackmodules';
export { Global } from './global';
export { Events } from './events'; export { Events } from './events';
export { SocketProxy } from './discordsocket'; export { SocketProxy } from './discordsocket';

View File

@ -31,9 +31,9 @@ const Common = {};
const dummyArgs = { const dummyArgs = {
'version': '0.3.1', 'version': '0.3.1',
'paths': [ 'paths': [
{ 'base': 'basePath' }, { 'id': 'base', 'path': 'basePath' },
{ 'plugins': __pluginPath }, { 'id': 'plugins', 'path': __pluginPath },
{ 'themes': __themePath } { 'id': 'themes', 'path': __themePath }
] ]
}; };