From 6bc2e0cca51baa7a6b8e378795bb15aafb27228f Mon Sep 17 00:00:00 2001 From: Jiiks Date: Thu, 15 Mar 2018 13:47:40 -0300 Subject: [PATCH] Export Filters from WebpackModules --- client/src/modules/discordapi.js | 2 +- client/src/modules/eventhook.js | 2 +- client/src/modules/modules.js | 2 +- client/src/modules/patcher.js | 2 +- client/src/modules/pluginapi.js | 2 +- client/src/modules/reactcomponents.js | 31 +-------------------------- client/src/modules/vendor.js | 2 +- client/src/modules/webpackmodules.js | 4 ++-- 8 files changed, 9 insertions(+), 38 deletions(-) diff --git a/client/src/modules/discordapi.js b/client/src/modules/discordapi.js index 645d04ef..fffe261b 100644 --- a/client/src/modules/discordapi.js +++ b/client/src/modules/discordapi.js @@ -1,4 +1,4 @@ -import WebpackModules from './webpackmodules'; +import { WebpackModules } from './webpackmodules'; import { $ } from 'vendor'; class List extends Array { diff --git a/client/src/modules/eventhook.js b/client/src/modules/eventhook.js index b5789163..9ae647f4 100644 --- a/client/src/modules/eventhook.js +++ b/client/src/modules/eventhook.js @@ -11,7 +11,7 @@ import EventListener from './eventlistener'; import { Utils } from 'common'; import Events from './events'; -import WebpackModules from './webpackmodules'; +import { WebpackModules } from './webpackmodules'; import * as SocketStructs from '../structs/socketstructs'; diff --git a/client/src/modules/modules.js b/client/src/modules/modules.js index c6311c53..99e14d98 100644 --- a/client/src/modules/modules.js +++ b/client/src/modules/modules.js @@ -6,7 +6,7 @@ export { default as PluginManager } from './pluginmanager'; export { default as ThemeManager } from './thememanager'; export { default as Globals } from './globals'; export { default as Vendor } from './vendor'; -export { default as WebpackModules } from './webpackmodules'; +export * from './webpackmodules'; export { default as ModuleManager } from './modulemanager'; export { default as EventListener } from './eventlistener'; export { default as SocketProxy } from './socketproxy'; diff --git a/client/src/modules/patcher.js b/client/src/modules/patcher.js index 2b10ed9f..d4cf07d4 100644 --- a/client/src/modules/patcher.js +++ b/client/src/modules/patcher.js @@ -8,7 +8,7 @@ * LICENSE file in the root directory of this source tree. */ -import WebpackModules from './webpackmodules'; +import { WebpackModules } from './webpackmodules'; import { ClientLogger as Logger } from 'common'; export default class Patcher { diff --git a/client/src/modules/pluginapi.js b/client/src/modules/pluginapi.js index b95c84b9..139bcaab 100644 --- a/client/src/modules/pluginapi.js +++ b/client/src/modules/pluginapi.js @@ -15,7 +15,7 @@ import PluginManager from './pluginmanager'; import ThemeManager from './thememanager'; import Events from './events'; import EventsWrapper from './eventswrapper'; -import WebpackModules from './webpackmodules'; +import { WebpackModules } from './webpackmodules'; import { SettingsSet, SettingsCategory, Setting, SettingsScheme } from 'structs'; import { BdMenuItems, Modals, DOM } from 'ui'; import SettingsModal from '../ui/components/bd/modals/SettingsModal.vue'; diff --git a/client/src/modules/reactcomponents.js b/client/src/modules/reactcomponents.js index 0f1bc7fe..a9402163 100644 --- a/client/src/modules/reactcomponents.js +++ b/client/src/modules/reactcomponents.js @@ -10,40 +10,11 @@ */ import Patcher from './patcher'; -import WebpackModules from './webpackmodules'; +import { WebpackModules, Filters } from './webpackmodules'; import DiscordApi from './discordapi'; import { EmoteModule } from 'builtin'; import { Reflection } from 'ui'; -class Filters { - static get byPrototypeFields() { - return (fields, selector = x => x) => (module) => { - const component = selector(module); - if (!component) return false; - if (!component.prototype) return false; - for (const field of fields) { - if (!component.prototype[field]) return false; - } - return true; - } - } - static get byCode() { - return (search, selector = x => x) => (module) => { - const method = selector(module); - if (!method) return false; - return method.toString().search(search) !== -1; - } - } - static get and() { - return (...filters) => (module) => { - for (const filter of filters) { - if (!filter(module)) return false; - } - return true; - } - } -} - class Helpers { static get plannedActions() { return this._plannedActions || (this._plannedActions = new Map()); diff --git a/client/src/modules/vendor.js b/client/src/modules/vendor.js index 7ddfc045..7ce84fa1 100644 --- a/client/src/modules/vendor.js +++ b/client/src/modules/vendor.js @@ -8,7 +8,7 @@ * LICENSE file in the root directory of this source tree. */ -import WebpackModules from './webpackmodules'; +import { WebpackModules } from './webpackmodules'; import jQuery from 'jquery'; import lodash from 'lodash'; diff --git a/client/src/modules/webpackmodules.js b/client/src/modules/webpackmodules.js index 0faaa844..82906d67 100644 --- a/client/src/modules/webpackmodules.js +++ b/client/src/modules/webpackmodules.js @@ -8,7 +8,7 @@ * LICENSE file in the root directory of this source tree. */ -class Filters { +export class Filters { static byProperties(props, selector = m => m) { return module => { const component = selector(module); @@ -205,7 +205,7 @@ const KnownModules = { ExternalLink: Filters.byCode(/\.trusted\b/) }; -export default class WebpackModules { +export class WebpackModules { /** * Finds a module using a filter function.