Fix getComponentByRegex and add Filters to the plugin API

This commit is contained in:
Samuel Elliott 2018-04-27 16:06:51 +01:00
parent 1e643b8164
commit 504221ce28
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
2 changed files with 21 additions and 12 deletions

View File

@ -18,7 +18,7 @@ import PluginManager from './pluginmanager';
import ThemeManager from './thememanager';
import Events from './events';
import EventsWrapper from './eventswrapper';
import { WebpackModules } from './webpackmodules';
import { WebpackModules, Filters } from './webpackmodules';
import DiscordApi from './discordapi';
import { ReactComponents } from './reactcomponents';
import { Patcher, MonkeyPatch } from './patcher';
@ -437,21 +437,30 @@ export default class PluginApi {
});
}
/**
* Filters
*/
get Filters() { return Filters }
/**
* DiscordApi
*/
get Discord() {
return DiscordApi;
}
get Discord() { return DiscordApi }
get DiscordApi() { return DiscordApi }
get ReactComponents() {
return ReactComponents;
}
/**
* ReactComponents
*/
get Reflection() {
return Reflection;
}
get ReactComponents() { return ReactComponents }
/**
* Reflection
*/
get Reflection() { return Reflection }
/**
* Patcher

View File

@ -159,8 +159,8 @@ export default function (node) {
getComponentByPrototypes(props, selector) {
return Reflection.findComponent(this.node, Filters.byPrototypeFields(props, selector));
}
getComponentByRegex(filter) {
return Reflection.findComponent(this.node, Filters.byCode(displayName));
getComponentByRegex(regex, selector) {
return Reflection.findComponent(this.node, Filters.byCode(regex, selector));
}
getComponentByDisplayName(name) {
return Reflection.findComponent(this.node, Filters.byDisplayName(name));