Use $$vencordOriginal as fallback
This commit is contained in:
parent
92653eaf96
commit
8d31f3cf62
|
@ -209,6 +209,7 @@ function defineModulesFactoryGetter(id: PropertyKey, factory: PatchedModuleFacto
|
||||||
},
|
},
|
||||||
set(v: AnyModuleFactory) {
|
set(v: AnyModuleFactory) {
|
||||||
if (factory.$$vencordOriginal != null) {
|
if (factory.$$vencordOriginal != null) {
|
||||||
|
factory.toString = v.toString.bind(v);
|
||||||
factory.$$vencordOriginal = v;
|
factory.$$vencordOriginal = v;
|
||||||
} else {
|
} else {
|
||||||
factory = v;
|
factory = v;
|
||||||
|
@ -367,7 +368,7 @@ function patchFactory(id: PropertyKey, factory: AnyModuleFactory) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_DEV) {
|
if (IS_DEV) {
|
||||||
return originalFactory.apply(this, args);
|
return patchedFactory.$$vencordOriginal?.apply(this, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,15 +378,19 @@ function patchFactory(id: PropertyKey, factory: AnyModuleFactory) {
|
||||||
factoryReturn = factory.apply(this, args);
|
factoryReturn = factory.apply(this, args);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Just re-throw Discord errors
|
// Just re-throw Discord errors
|
||||||
if (factory === originalFactory) throw err;
|
if (factory === originalFactory) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
logger.error("Error in patched module factory", err);
|
logger.error("Error in patched module factory", err);
|
||||||
return originalFactory.apply(this, args);
|
return patchedFactory.$$vencordOriginal?.apply(this, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Webpack sometimes sets the value of module.exports directly, so assign exports to it to make sure we properly handle it
|
// Webpack sometimes sets the value of module.exports directly, so assign exports to it to make sure we properly handle it
|
||||||
exports = module?.exports;
|
exports = module?.exports;
|
||||||
if (exports == null) return factoryReturn;
|
if (exports == null) {
|
||||||
|
return factoryReturn;
|
||||||
|
}
|
||||||
|
|
||||||
// There are (at the time of writing) 11 modules exporting the window
|
// There are (at the time of writing) 11 modules exporting the window
|
||||||
// Make these non enumerable to improve webpack search performance
|
// Make these non enumerable to improve webpack search performance
|
||||||
|
|
Loading…
Reference in a new issue