ModuleBuilder/moduleWrappers/powercord/webpack.js

34 lines
934 B
JavaScript
Raw Normal View History

2021-04-04 12:47:36 +00:00
const makeFinalFilter = (filter) => {
if (Array.isArray(filter)) {
const subs = filter;
filter = (mod) => subs.every((s) => mod[s] || (mod.__proto__ && mod.__proto__[s]));
}
return filter;
};
module.exports = {
getModule: (filter, retry, _forever) => { // Ignoring retry and forever arguments for basic implementation
2021-04-04 12:47:36 +00:00
filter = makeFinalFilter(filter);
const result = goosemodScope.webpackModules.find(filter);
if (!retry) { // retry = false: sync, retry = true: async (returns Promise)
return result;
}
return new Promise((res) => res(result));
2021-04-04 12:47:36 +00:00
},
getAllModules: (filter) => {
filter = makeFinalFilter(filter);
return goosemodScope.webpackModules.findAll(filter);
},
getModuleByDisplayName: (displayName) => {
return goosemodScope.webpackModules.findByDisplayName(displayName);
},
...goosemodScope.webpackModules.common // Export common modules (eg: React)
};