Add new utils to api

This commit is contained in:
Zack Rauen 2019-03-13 12:08:45 -04:00
parent 136a0dacd7
commit 6e6c9e1c2a
3 changed files with 41 additions and 3 deletions

View File

@ -9,8 +9,8 @@
*/
import { EmoteModule } from 'builtin';
import { SettingsSet, SettingsCategory, Setting, SettingsScheme } from 'structs';
import { BdMenu, Modals, DOM, DOMObserver, VueInjector, Toasts, Notifications, BdContextMenu, DiscordContextMenu } from 'ui';
import { SettingsSet, SettingsCategory, Setting, SettingsScheme, Screen } from 'structs';
import { BdMenu, Modals, DOM, DOMObserver, VueInjector, Toasts, Notifications, BdContextMenu, DiscordContextMenu, Tooltip } from 'ui';
import * as CommonComponents from 'commoncomponents';
import { default as Components } from '../ui/components/generic';
import { Utils, Filters, ClientLogger as Logger, ClientIPC, AsyncEventEmitter } from 'common';
@ -75,6 +75,7 @@ export default class PluginApi {
get Reflection() { return Reflection }
get DOM() { return DOM }
get VueInjector() { return VueInjector }
get Screen() { return Screen }
get observer() {
return this._observer || (this._observer = new DOMObserver());
@ -113,7 +114,12 @@ export default class PluginApi {
wait: (...args) => Utils.wait.apply(Utils, args),
until: (...args) => Utils.until.apply(Utils, args),
findInTree: (...args) => Utils.findInTree.apply(Utils, args),
findInReactTree: (...args) => Utils.findInReactTree.apply(Utils, args)
findInReactTree: (...args) => Utils.findInReactTree.apply(Utils, args),
formatString: (...args) => Utils.formatString.apply(Utils, args),
getNestedProp: (...args) => Utils.getNestedProp.apply(Utils, args),
extend: (...args) => Utils.extend.apply(Utils, args),
memoizeObject: (...args) => Utils.memoizeObject.apply(Utils, args),
stableSort: (...args) => Utils.stableSort.apply(Utils, args)
};
}
@ -356,6 +362,17 @@ export default class PluginApi {
};
}
/**
* Tooltips
*/
addTooltip(node, text, options = {}) {
return new Tooltip(node, text, options);
}
get Tooltip() {
return Tooltip;
}
/**
* Notifications
*/
@ -550,6 +567,26 @@ export default class PluginApi {
};
}
/**
* NodeModules
*/
getNodeModule(module_id) {
return {}; // Don't give open access, when plugin permissions available remove this line
// This should require extra permissions
//return require(module_id);
}
listNodeModules() {
return []; // Don't give open access, when plugin permissions available implement this properly
}
get NodeModules() {
return {
getModule: this.getNodeModule.bind(this),
listModules: this.listNodeModules.bind(this)
// path: path (Perhaps we add this stuff here as well)
};
}
/**
* Patcher
*/

View File

@ -3,6 +3,7 @@ export { default as BdUI } from './bdui';
export { default as BdMenu, BdMenuItems } from './bdmenu';
export { default as Modals } from './modals';
export { default as Toasts } from './toasts';
export { default as Tooltip } from './tooltip';
export { default as Notifications } from './notifications';
export * from './contextmenus';