Webpackmodules

This commit is contained in:
Jiiks 2018-01-11 17:22:49 +02:00
parent 03505fcdb6
commit 662329c5e9
4 changed files with 151 additions and 5 deletions

View File

@ -26595,15 +26595,14 @@ return jQuery;
const { Logger, PluginManager, BDIpc } = __webpack_require__(123);
window.bdipc = BDIpc;
const { Logger, PluginManager, BDIpc, WebpackModules } = __webpack_require__(123);
class BetterDiscord {
constructor() {
Logger.log('main', 'Init');
window.pm = PluginManager;
window.wpm = WebpackModules;
}
}
@ -26639,6 +26638,10 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__bdipc__ = __webpack_require__(129);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__bdipc___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3__bdipc__);
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_3__bdipc__, "BDIpc")) __webpack_require__.d(__webpack_exports__, "BDIpc", function() { return __WEBPACK_IMPORTED_MODULE_3__bdipc__["BDIpc"]; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__webpackmodules__ = __webpack_require__(131);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__webpackmodules___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4__webpackmodules__);
/* harmony reexport (binding) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_4__webpackmodules__, "WebpackModules")) __webpack_require__.d(__webpack_exports__, "WebpackModules", function() { return __WEBPACK_IMPORTED_MODULE_4__webpackmodules__["WebpackModules"]; });
@ -27089,5 +27092,76 @@ module.exports = { BDIpc };
module.exports = window.require("electron");
/***/ }),
/* 131 */
/***/ (function(module, exports, __webpack_require__) {
/**
* BetterDiscord Client WebpackModules 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.
*/
class WebpackModules {
static async getModuleByProps(props) {
const modules = await this.getAllModules();
return new Promise((resolve, reject) => {
for (let index in modules) {
if (!modules.hasOwnProperty(index)) continue;
const module = modules[index];
const { exports } = module;
if (!exports || typeof exports !== 'object') continue;
if (!(props in exports)) continue;
resolve(module.exports);
break;
}
reject(null);
});
}
/*This will most likely not work for most modules*/
static async getModuleByName(name) {
const modules = await this.getAllModules();
return new Promise((resolve, reject) => {
for (let index in modules) {
if (!modules.hasOwnProperty(index)) continue;
if (typeof exports === 'object' && name in exports) {
resolve(module.exports);
break;
} else if (false) {
resolve(module.exports);
break;
}
}
reject(null);
});
}
static async getAllModules() {
return new Promise(resolve => {
const id = 'bd-webpackmodules';
window['webpackJsonp']([], {
[id]: (module, exports, __webpack_require__) => {
delete __webpack_require__.c[id];
delete __webpack_require__.m[id];
resolve(__webpack_require__.c);
}
}, [id]);
});
}
}
module.exports = { WebpackModules };
/***/ })
/******/ ]);

View File

@ -10,13 +10,14 @@
'use strict';
const { Logger, PluginManager, BDIpc } = require('./modules');
const { Logger, PluginManager, BDIpc, WebpackModules } = require('./modules');
class BetterDiscord {
constructor() {
Logger.log('main', 'Init');
window.pm = PluginManager;
window.wpm = WebpackModules;
}
}

View File

@ -1,4 +1,5 @@
export { Logger } from './utils';
export { PluginManager } from './pluginmanager';
export { Pluging } from './plugin';
export { BDIpc } from './bdipc';
export { BDIpc } from './bdipc';
export { WebpackModules } from './webpackmodules';

View File

@ -0,0 +1,70 @@
/**
* BetterDiscord Client WebpackModules 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.
*/
class WebpackModules {
static async getModuleByProps(props) {
const modules = await this.getAllModules();
return new Promise((resolve, reject) => {
for (let index in modules) {
if (!modules.hasOwnProperty(index)) continue;
const module = modules[index];
const { exports } = module;
if (!exports || typeof exports !== 'object') continue;
if (!(props in exports)) continue;
resolve(module.exports);
break;
}
reject(null);
});
}
/*This will most likely not work for most modules*/
static async getModuleByName(name) {
const modules = await this.getAllModules();
return new Promise((resolve, reject) => {
for (let index in modules) {
if (!modules.hasOwnProperty(index)) continue;
if (typeof exports === 'object' && name in exports) {
resolve(module.exports);
break;
} else if (typeof exports === 'function' && exports.name === name) {
resolve(module.exports);
break;
}
}
reject(null);
});
}
static async getAllModules() {
return new Promise(resolve => {
const id = 'bd-webpackmodules';
window['webpackJsonp'](
[],
{
[id]: (module, exports, __webpack_require__) => {
delete __webpack_require__.c[id];
delete __webpack_require__.m[id];
resolve(__webpack_require__.c);
}
},
[id]
);
});
}
}
module.exports = { WebpackModules };