Limit warning logs from webpack

This commit is contained in:
Zack Rauen 2022-08-05 19:25:16 -04:00
parent 9f2298e6cd
commit 69e17b1dbd
3 changed files with 18 additions and 12 deletions

View File

@ -4,7 +4,7 @@
"node": true
},
"parserOptions": {
"ecmaVersion": 2020,
"ecmaVersion": 2022,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true

View File

@ -443,57 +443,59 @@ BdApi.openDialog = async function (options) {
* `AddonAPI` is a utility class for working with plugins and themes. Instances are accessible through the {@link BdApi}.
*/
class AddonAPI {
constructor(manager) {this.manager = manager;}
#manager;
constructor(manager) {this.#manager = manager;}
/**
* The path to the addon folder.
* @type string
*/
get folder() {return this.manager.addonFolder;}
get folder() {return this.#manager.addonFolder;}
/**
* Determines if a particular adon is enabled.
* @param {string} idOrFile Addon id or filename.
* @returns {boolean}
*/
isEnabled(idOrFile) {return this.manager.isEnabled(idOrFile);}
isEnabled(idOrFile) {return this.#manager.isEnabled(idOrFile);}
/**
* Enables the given addon.
* @param {string} idOrFile Addon id or filename.
*/
enable(idOrAddon) {return this.manager.enableAddon(idOrAddon);}
enable(idOrAddon) {return this.#manager.enableAddon(idOrAddon);}
/**
* Disables the given addon.
* @param {string} idOrFile Addon id or filename.
*/
disable(idOrAddon) {return this.manager.disableAddon(idOrAddon);}
disable(idOrAddon) {return this.#manager.disableAddon(idOrAddon);}
/**
* Toggles if a particular addon is enabled.
* @param {string} idOrFile Addon id or filename.
*/
toggle(idOrAddon) {return this.manager.toggleAddon(idOrAddon);}
toggle(idOrAddon) {return this.#manager.toggleAddon(idOrAddon);}
/**
* Reloads if a particular addon is enabled.
* @param {string} idOrFile Addon id or filename.
*/
reload(idOrFileOrAddon) {return this.manager.reloadAddon(idOrFileOrAddon);}
reload(idOrFileOrAddon) {return this.#manager.reloadAddon(idOrFileOrAddon);}
/**
* Gets a particular addon.
* @param {string} idOrFile Addon id or filename.
* @returns {object} Addon instance
*/
get(idOrFile) {return this.manager.getAddon(idOrFile);}
get(idOrFile) {return this.#manager.getAddon(idOrFile);}
/**
* Gets all addons of this type.
* @returns {Array<object>} Array of all addon instances
*/
getAll() {return this.manager.addonList.map(a => this.manager.getAddon(a.id));}
getAll() {return this.#manager.addonList.map(a => this.#manager.getAddon(a.id));}
}
/**

View File

@ -132,6 +132,8 @@ const protect = theModule => {
return proxy;
};
const hasThrown = new Set();
export default class WebpackModules {
static find(filter, first = true) {return this.getModule(filter, {first});}
static findAll(filter) {return this.getModule(filter, {first: false});}
@ -153,7 +155,8 @@ export default class WebpackModules {
return filter(exports, module, moduleId);
}
catch (err) {
Logger.warn("WebpackModules~getModule", "Module filter threw an exception.", filter, err);
if (!hasThrown.has(filter)) Logger.warn("WebpackModules~getModule", "Module filter threw an exception.", filter, err);
hasThrown.add(filter);
return false;
}
};
@ -209,7 +212,8 @@ export default class WebpackModules {
return filter(ex, mod, moduleId);
}
catch (err) {
Logger.warn("WebpackModules~getModule", "Module filter threw an exception.", filter, err);
if (!hasThrown.has(filter)) Logger.warn("WebpackModules~getBulk", "Module filter threw an exception.", filter, err);
hasThrown.add(filter);
return false;
}
};