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 = {
|
2021-04-04 17:18:00 +00:00
|
|
|
getModule: (filter, retry, _forever) => { // Ignoring retry and forever arguments for basic implementation
|
2021-04-04 12:47:36 +00:00
|
|
|
filter = makeFinalFilter(filter);
|
|
|
|
|
2021-04-04 17:18:00 +00:00
|
|
|
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)
|
|
|
|
};
|