More re-ordering

This commit is contained in:
Nuckyz 2024-06-12 17:36:43 -03:00
parent 853585c0bc
commit 6d587e6530
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -138,39 +138,6 @@ const moduleFactoriesHandler: ProxyHandler<PatchedModuleFactories> = {
} }
}; };
/**
* Define the getter for returning the patched version of the module factory.
*
* If eagerPatches is enabled, the factory argument should already be the patched version, else it will be the original
* and only be patched when accessed for the first time.
*
* @param id The id of the module
* @param factory The original or patched module factory
*/
function defineModulesFactoryGetter(id: PropertyKey, factory: PatchedModuleFactory) {
// Define the getter in all the module factories objects. Patches are only executed once, so make sure all module factories object
// have the patched version
for (const wreq of allWebpackInstances) {
define(wreq.m, id, {
get() {
// $$vencordOriginal means the factory is already patched
if (factory.$$vencordOriginal != null) {
return factory;
}
return (factory = patchFactory(id, factory));
},
set(v: AnyModuleFactory) {
if (factory.$$vencordOriginal != null) {
factory.$$vencordOriginal = v;
} else {
factory = v;
}
}
});
}
}
/** /**
* Update a factory that exists in any Webpack instance with a new original factory. * Update a factory that exists in any Webpack instance with a new original factory.
* *
@ -218,6 +185,39 @@ function notifyFactoryListeners(factory: AnyModuleFactory) {
} }
} }
/**
* Define the getter for returning the patched version of the module factory.
*
* If eagerPatches is enabled, the factory argument should already be the patched version, else it will be the original
* and only be patched when accessed for the first time.
*
* @param id The id of the module
* @param factory The original or patched module factory
*/
function defineModulesFactoryGetter(id: PropertyKey, factory: PatchedModuleFactory) {
// Define the getter in all the module factories objects. Patches are only executed once, so make sure all module factories object
// have the patched version
for (const wreq of allWebpackInstances) {
define(wreq.m, id, {
get() {
// $$vencordOriginal means the factory is already patched
if (factory.$$vencordOriginal != null) {
return factory;
}
return (factory = patchFactory(id, factory));
},
set(v: AnyModuleFactory) {
if (factory.$$vencordOriginal != null) {
factory.$$vencordOriginal = v;
} else {
factory = v;
}
}
});
}
}
/** /**
* Patches a module factory. * Patches a module factory.
* *