Extract global BetterDiscord.vendor into separate module, so it can be used through require
This commit is contained in:
parent
d980a23dd3
commit
63c239f36f
|
@ -5,13 +5,13 @@
|
|||
* https://github.com/JsSucks - https://betterdiscord.net
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const styles = require('./styles/index.scss');
|
||||
const { Global, Logger, Utils, PluginManager, BDIpc, WebpackModules, SocketProxy, Events } = require('./modules');
|
||||
const { Global, Logger, Utils, PluginManager, BDIpc, WebpackModules, SocketProxy, Events, Vendor } = require('./modules');
|
||||
//const { UI } = require('./modules/ui/index.jsx');
|
||||
|
||||
class BetterDiscord {
|
||||
|
@ -50,11 +50,5 @@ if (window.BetterDiscord) {
|
|||
Logger.log('main', 'Attempting to inject again?');
|
||||
} else {
|
||||
let bdInstance = new BetterDiscord();
|
||||
window.BetterDiscord = {
|
||||
'vendor': {
|
||||
jQuery: require('jquery'),
|
||||
$: require('jquery'),
|
||||
moment: WebpackModules.getModuleByName('Moment')
|
||||
}
|
||||
};
|
||||
window.BetterDiscord = {'vendor': Vendor};
|
||||
}
|
|
@ -5,10 +5,11 @@
|
|||
* https://github.com/JsSucks - https://betterdiscord.net
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const { Module } = require('./modulebase');
|
||||
const { Vendor } = require('./vendor');
|
||||
const fs = window.require('fs');
|
||||
const path = window.require('path');
|
||||
|
||||
|
@ -29,7 +30,7 @@ class Logger {
|
|||
}
|
||||
level = this.parseLevel(level);
|
||||
console[level]('[%cBetter%cDiscord:%s] %s', 'color: #3E82E5', '', `${module}${level === 'debug' ? '|DBG' : ''}`, message);
|
||||
logs.push(`[${BetterDiscord.vendor.moment().format('DD/MM/YY hh:mm:ss')}|${module}|${level}] ${message}`);
|
||||
logs.push(`[${Vendor.moment().format('DD/MM/YY hh:mm:ss')}|${module}|${level}] ${message}`);
|
||||
window.bdlogs = logs;
|
||||
}
|
||||
|
||||
|
@ -78,7 +79,7 @@ class Utils {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class FileUtils {
|
||||
|
@ -208,13 +209,13 @@ class Filters {
|
|||
};
|
||||
}
|
||||
|
||||
static byDisplayName(name) {
|
||||
static byDisplayName(name) {
|
||||
return module => {
|
||||
return module && module.displayName === name;
|
||||
};
|
||||
}
|
||||
|
||||
static combine(...filters) {
|
||||
static combine(...filters) {
|
||||
return module => {
|
||||
return filters.every(filter => filter(module));
|
||||
};
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* BetterDiscord Client Utils Module
|
||||
* Copyright (c) 2015-present JsSucks - https://github.com/JsSucks
|
||||
* All rights reserved.
|
||||
* https://github.com/JsSucks - https://betterdiscord.net
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const {WebpackModules} = require('./webpackmodules');
|
||||
const jQuery = require('jquery');
|
||||
|
||||
class Vendor {
|
||||
|
||||
static get jQuery() {
|
||||
return jQuery;
|
||||
}
|
||||
|
||||
static get $() {
|
||||
return jQuery;
|
||||
}
|
||||
|
||||
static get moment() {
|
||||
return WebpackModules.getModuleByName('Moment');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = {Vendor};
|
|
@ -7,4 +7,5 @@ export { WebpackModules } from './core/webpackmodules';
|
|||
export { Events } from './core/events';
|
||||
export { SocketProxy } from './core/discordsocket';
|
||||
export { CssEditor } from './core/csseditor';
|
||||
export { Settings } from './core/settings';
|
||||
export { Settings } from './core/settings';
|
||||
export { Vendor } from './core/vendor';
|
||||
|
|
Loading…
Reference in New Issue