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

View File

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