Merge branch 'immediate-finds' into immediate-finds-modules-proxy
This commit is contained in:
commit
9c21c23364
|
@ -794,6 +794,55 @@ export function extractAndLoadChunksLazy(code: string | string[], matcher: RegEx
|
|||
return extractAndLoadChunks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search modules by keyword. This searches the factory methods,
|
||||
* meaning you can search all sorts of things, methodName, strings somewhere in the code, etc.
|
||||
*
|
||||
* @param filters One or more strings or regexes
|
||||
* @returns Mapping of found modules
|
||||
*/
|
||||
export function search(...filters: Array<string | RegExp>) {
|
||||
const results: WebpackRequire["m"] = {};
|
||||
const factories = wreq.m;
|
||||
outer:
|
||||
for (const id in factories) {
|
||||
const factory = factories[id];
|
||||
const factoryStr = String(factory);
|
||||
for (const filter of filters) {
|
||||
if (typeof filter === "string" && !factoryStr.includes(filter)) continue outer;
|
||||
if (filter instanceof RegExp && !filter.test(factoryStr)) continue outer;
|
||||
}
|
||||
results[id] = factory;
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a specific module by id into its own Source File. This has no effect on
|
||||
* the code, it is only useful to be able to look at a specific module without having
|
||||
* to view a massive file. extract then returns the extracted module so you can jump to it.
|
||||
* As mentioned above, note that this extracted module is not actually used,
|
||||
* so putting breakpoints or similar will have no effect.
|
||||
*
|
||||
* @param id The id of the module to extract
|
||||
*/
|
||||
export function extract(id: PropertyKey) {
|
||||
const factory = wreq.m[id];
|
||||
if (!factory) return null;
|
||||
|
||||
const code = `
|
||||
// [EXTRACTED] WebpackModule${String(id)}
|
||||
// WARNING: This module was extracted to be more easily readable.
|
||||
// This module is NOT ACTUALLY USED! This means putting breakpoints will have NO EFFECT!!
|
||||
|
||||
0,${String(factory)}
|
||||
//# sourceURL=ExtractedWebpackModule${String(id)}
|
||||
`;
|
||||
const extracted: ModuleFactory = (0, eval)(code);
|
||||
return extracted;
|
||||
}
|
||||
|
||||
function deprecatedRedirect<T extends (...args: any[]) => any>(oldMethod: string, newMethod: string, redirect: T): T {
|
||||
return ((...args: Parameters<T>) => {
|
||||
logger.warn(`Method ${oldMethod} is deprecated. Use ${newMethod} instead. For more information read https://github.com/Vendicated/Vencord/pull/2409#issue-2277161516`);
|
||||
|
@ -920,52 +969,3 @@ export const findBulk = deprecatedRedirect("findBulk", "cacheFindBulk", cacheFin
|
|||
* @returns string or null
|
||||
*/
|
||||
export const findModuleId = deprecatedRedirect("findModuleId", "cacheFindModuleId", cacheFindModuleId);
|
||||
|
||||
/**
|
||||
* Search modules by keyword. This searches the factory methods,
|
||||
* meaning you can search all sorts of things, methodName, strings somewhere in the code, etc.
|
||||
*
|
||||
* @param filters One or more strings or regexes
|
||||
* @returns Mapping of found modules
|
||||
*/
|
||||
export function search(...filters: Array<string | RegExp>) {
|
||||
const results: WebpackRequire["m"] = {};
|
||||
const factories = wreq.m;
|
||||
outer:
|
||||
for (const id in factories) {
|
||||
const factory = factories[id];
|
||||
const factoryStr = String(factory);
|
||||
for (const filter of filters) {
|
||||
if (typeof filter === "string" && !factoryStr.includes(filter)) continue outer;
|
||||
if (filter instanceof RegExp && !filter.test(factoryStr)) continue outer;
|
||||
}
|
||||
results[id] = factory;
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a specific module by id into its own Source File. This has no effect on
|
||||
* the code, it is only useful to be able to look at a specific module without having
|
||||
* to view a massive file. extract then returns the extracted module so you can jump to it.
|
||||
* As mentioned above, note that this extracted module is not actually used,
|
||||
* so putting breakpoints or similar will have no effect.
|
||||
*
|
||||
* @param id The id of the module to extract
|
||||
*/
|
||||
export function extract(id: PropertyKey) {
|
||||
const factory = wreq.m[id];
|
||||
if (!factory) return null;
|
||||
|
||||
const code = `
|
||||
// [EXTRACTED] WebpackModule${String(id)}
|
||||
// WARNING: This module was extracted to be more easily readable.
|
||||
// This module is NOT ACTUALLY USED! This means putting breakpoints will have NO EFFECT!!
|
||||
|
||||
0,${String(factory)}
|
||||
//# sourceURL=ExtractedWebpackModule${String(id)}
|
||||
`;
|
||||
const extracted: ModuleFactory = (0, eval)(code);
|
||||
return extracted;
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
// eslint-disable-next-line path-alias/no-relative
|
||||
import { find, findByProps } from "../webpack";
|
||||
import { find, findByProps } from "../api";
|
||||
import * as t from "./types/classes";
|
||||
|
||||
export const ModalImageClasses = find<t.ImageModalClasses>(m => m.image && m.modal && !m.applicationIcon);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
import { NoopComponent } from "@utils/react";
|
||||
|
||||
// eslint-disable-next-line path-alias/no-relative
|
||||
import { filters, find, findComponent, findExportedComponent } from "../webpack";
|
||||
import { filters, find, findComponent, findExportedComponent } from "../api";
|
||||
import * as t from "./types/components";
|
||||
|
||||
export let Card: t.Card = NoopComponent as any;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
// eslint-disable-next-line path-alias/no-relative
|
||||
import { filters, findByProps, mapMangledModule } from "../webpack";
|
||||
import { filters, findByProps, mapMangledModule } from "../api";
|
||||
import type * as t from "./types/menu";
|
||||
|
||||
export const Menu = findByProps<t.Menu>("MenuItem", "MenuSliderControl");
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
// eslint-disable-next-line path-alias/no-relative
|
||||
import { filters, find, findByProps } from "../webpack";
|
||||
import { filters, find, findByProps } from "../api";
|
||||
|
||||
export let useState: typeof React.useState;
|
||||
export let useEffect: typeof React.useEffect;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
// eslint-disable-next-line path-alias/no-relative
|
||||
import { findByCode, findByProps, findStore } from "../webpack";
|
||||
import { findByCode, findByProps, findStore } from "../api";
|
||||
import * as t from "./types/stores";
|
||||
|
||||
export const Flux = findByProps<t.Flux>("connectStores");
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
// eslint-disable-next-line path-alias/no-relative
|
||||
import { find } from "../webpack";
|
||||
import { find } from "../api";
|
||||
|
||||
export const UserSettingsActionCreators = {
|
||||
FrecencyUserSettingsActionCreators: find(m => m.ProtoClass?.typeName?.endsWith(".FrecencyUserSettings")),
|
||||
|
|
|
@ -20,7 +20,7 @@ import { canonicalizeMatch } from "@utils/patches";
|
|||
import { Channel } from "discord-types/general";
|
||||
|
||||
// eslint-disable-next-line path-alias/no-relative
|
||||
import { _resolveDiscordLoaded, filters, find, findByCode, findByProps, mapMangledModule, waitFor } from "../webpack";
|
||||
import { _resolveDiscordLoaded, filters, find, findByCode, findByProps, mapMangledModule, waitFor } from "../api";
|
||||
import type * as t from "./types/utils";
|
||||
|
||||
export const FluxDispatcher = find<t.FluxDispatcher>(filters.byProps("dispatch", "subscribe"), (m: t.FluxDispatcher) => {
|
||||
|
|
|
@ -16,6 +16,6 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export * from "./api";
|
||||
export * as Common from "./common";
|
||||
export * from "./webpack";
|
||||
export * from "./wreq.d";
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
"@shared/*": ["./shared/*"],
|
||||
"@webpack/types": ["./webpack/common/types"],
|
||||
"@webpack/common": ["./webpack/common"],
|
||||
"@webpack": ["./webpack/webpack"]
|
||||
"@webpack": ["./webpack/api"]
|
||||
},
|
||||
|
||||
"plugins": [
|
||||
|
|
Loading…
Reference in a new issue