mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-13 08:33:01 -04:00
Clean up circular imports fixes
This commit is contained in:
parent
d542095993
commit
8c7225d106
3 changed files with 33 additions and 22 deletions
|
@ -24,16 +24,20 @@ export const Menu = {} as t.Menu;
|
||||||
|
|
||||||
// Relies on .name properties added by the MenuItemDemanglerAPI
|
// Relies on .name properties added by the MenuItemDemanglerAPI
|
||||||
waitFor(m => m.name === "MenuCheckboxItem", (_, id) => {
|
waitFor(m => m.name === "MenuCheckboxItem", (_, id) => {
|
||||||
// we have to do this manual require by ID because m is in this case the MenuCheckBoxItem instead of the entire module
|
// We have to do this manual require by ID because m in this case is the MenuCheckBoxItem instead of the entire module
|
||||||
const module = wreq(id);
|
const exports = wreq(id);
|
||||||
|
|
||||||
for (const key in module) {
|
for (const exportKey in exports) {
|
||||||
|
// Some exports might have not been initialized yet due to circular imports, so try catch it.
|
||||||
try {
|
try {
|
||||||
const e = module[key];
|
var exportValue = exports[exportKey];
|
||||||
if (typeof e === "function" && e.name.startsWith("Menu")) {
|
} catch {
|
||||||
Menu[e.name] = e;
|
continue;
|
||||||
}
|
}
|
||||||
} catch { }
|
|
||||||
|
if (typeof exportValue === "function" && exportValue.name.startsWith("Menu")) {
|
||||||
|
Menu[exportValue.name] = exportValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -412,12 +412,9 @@ function runFactoryWithWrap(patchedFactory: PatchedModuleFactory, thisArg: unkno
|
||||||
exports = module.exports;
|
exports = module.exports;
|
||||||
|
|
||||||
if (typeof require === "function" && require.c) {
|
if (typeof require === "function" && require.c) {
|
||||||
// module might not have been fully initialised yet
|
if (_blacklistBadModules(require.c, exports, module.id)) {
|
||||||
try {
|
return factoryReturn;
|
||||||
if (_blacklistBadModules(require.c, exports, module.id)) {
|
}
|
||||||
return factoryReturn;
|
|
||||||
}
|
|
||||||
} catch { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exports == null) {
|
if (exports == null) {
|
||||||
|
@ -445,15 +442,18 @@ function runFactoryWithWrap(patchedFactory: PatchedModuleFactory, thisArg: unkno
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const exportKey in exports) {
|
for (const exportKey in exports) {
|
||||||
|
// Some exports might have not been initialized yet due to circular imports, so try catch it.
|
||||||
try {
|
try {
|
||||||
const exportValue = exports[exportKey];
|
var exportValue = exports[exportKey];
|
||||||
|
} catch {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (exportValue != null && filter(exportValue)) {
|
if (exportValue != null && filter(exportValue)) {
|
||||||
waitForSubscriptions.delete(filter);
|
waitForSubscriptions.delete(filter);
|
||||||
callback(exportValue, module.id);
|
callback(exportValue, module.id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch { }
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error("Error while firing callback for Webpack waitFor subscription:\n", err, filter, callback);
|
logger.error("Error while firing callback for Webpack waitFor subscription:\n", err, filter, callback);
|
||||||
|
|
|
@ -156,7 +156,14 @@ export function _blacklistBadModules(requireCache: NonNullable<AnyWebpackRequire
|
||||||
|
|
||||||
let hasOnlyBadProperties = true;
|
let hasOnlyBadProperties = true;
|
||||||
for (const exportKey in exports) {
|
for (const exportKey in exports) {
|
||||||
if (shouldIgnoreValue(exports[exportKey])) {
|
// Some exports might have not been initialized yet due to circular imports, so try catch it.
|
||||||
|
try {
|
||||||
|
var exportValue = exports[exportKey];
|
||||||
|
} catch {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldIgnoreValue(exportValue)) {
|
||||||
makePropertyNonEnumerable(exports, exportKey);
|
makePropertyNonEnumerable(exports, exportKey);
|
||||||
} else {
|
} else {
|
||||||
hasOnlyBadProperties = false;
|
hasOnlyBadProperties = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue