organize
This commit is contained in:
parent
de4743828a
commit
ba6d3c7e60
|
@ -85,6 +85,7 @@ function makeShortcuts() {
|
||||||
wpex: extract,
|
wpex: extract,
|
||||||
wpexs: (code: string) => extract(Webpack.cacheFindModuleId(code)!),
|
wpexs: (code: string) => extract(Webpack.cacheFindModuleId(code)!),
|
||||||
loadLazyChunks: IS_DEV ? loadLazyChunks : () => { throw new Error("loadLazyChunks is dev only."); },
|
loadLazyChunks: IS_DEV ? loadLazyChunks : () => { throw new Error("loadLazyChunks is dev only."); },
|
||||||
|
filters,
|
||||||
find,
|
find,
|
||||||
findAll: cacheFindAll,
|
findAll: cacheFindAll,
|
||||||
findByProps,
|
findByProps,
|
||||||
|
|
|
@ -788,6 +788,55 @@ export function extractAndLoadChunksLazy(code: string | string[], matcher: RegEx
|
||||||
return extractAndLoadChunks;
|
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 = {} as Record<number, Function>;
|
||||||
|
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] as Function;
|
||||||
|
if (!factory) return;
|
||||||
|
|
||||||
|
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 = (0, eval)(code);
|
||||||
|
return extracted as Function;
|
||||||
|
}
|
||||||
|
|
||||||
function deprecatedRedirect<T extends (...args: any[]) => any>(oldMethod: string, newMethod: string, redirect: T): T {
|
function deprecatedRedirect<T extends (...args: any[]) => any>(oldMethod: string, newMethod: string, redirect: T): T {
|
||||||
return ((...args: Parameters<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`);
|
logger.warn(`Method ${oldMethod} is deprecated. Use ${newMethod} instead. For more information read https://github.com/Vendicated/Vencord/pull/2409#issue-2277161516`);
|
||||||
|
@ -914,52 +963,3 @@ export const findBulk = deprecatedRedirect("findBulk", "cacheFindBulk", cacheFin
|
||||||
* @returns string or null
|
* @returns string or null
|
||||||
*/
|
*/
|
||||||
export const findModuleId = deprecatedRedirect("findModuleId", "cacheFindModuleId", cacheFindModuleId);
|
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 = {} as Record<number, Function>;
|
|
||||||
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] as Function;
|
|
||||||
if (!factory) return;
|
|
||||||
|
|
||||||
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 = (0, eval)(code);
|
|
||||||
return extracted as Function;
|
|
||||||
}
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line path-alias/no-relative
|
// eslint-disable-next-line path-alias/no-relative
|
||||||
import { find, findByProps } from "../webpack";
|
import { find, findByProps } from "../api";
|
||||||
import * as t from "./types/classes";
|
import * as t from "./types/classes";
|
||||||
|
|
||||||
export const ModalImageClasses = find<t.ImageModalClasses>(m => m.image && m.modal && !m.applicationIcon);
|
export const ModalImageClasses = find<t.ImageModalClasses>(m => m.image && m.modal && !m.applicationIcon);
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import { NoopComponent } from "@utils/react";
|
import { NoopComponent } from "@utils/react";
|
||||||
|
|
||||||
// eslint-disable-next-line path-alias/no-relative
|
// 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";
|
import * as t from "./types/components";
|
||||||
|
|
||||||
export let Card: t.Card = NoopComponent as any;
|
export let Card: t.Card = NoopComponent as any;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line path-alias/no-relative
|
// 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";
|
import type * as t from "./types/menu";
|
||||||
|
|
||||||
export const Menu = findByProps<t.Menu>("MenuItem", "MenuSliderControl");
|
export const Menu = findByProps<t.Menu>("MenuItem", "MenuSliderControl");
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line path-alias/no-relative
|
// 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 useState: typeof React.useState;
|
||||||
export let useEffect: typeof React.useEffect;
|
export let useEffect: typeof React.useEffect;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line path-alias/no-relative
|
// 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";
|
import * as t from "./types/stores";
|
||||||
|
|
||||||
export const Flux = findByProps<t.Flux>("connectStores");
|
export const Flux = findByProps<t.Flux>("connectStores");
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line path-alias/no-relative
|
// eslint-disable-next-line path-alias/no-relative
|
||||||
import { find } from "../webpack";
|
import { find } from "../api";
|
||||||
|
|
||||||
export const UserSettingsActionCreators = {
|
export const UserSettingsActionCreators = {
|
||||||
FrecencyUserSettingsActionCreators: find(m => m.ProtoClass?.typeName?.endsWith(".FrecencyUserSettings")),
|
FrecencyUserSettingsActionCreators: find(m => m.ProtoClass?.typeName?.endsWith(".FrecencyUserSettings")),
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { canonicalizeMatch } from "@utils/patches";
|
||||||
import { Channel } from "discord-types/general";
|
import { Channel } from "discord-types/general";
|
||||||
|
|
||||||
// eslint-disable-next-line path-alias/no-relative
|
// 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";
|
import type * as t from "./types/utils";
|
||||||
|
|
||||||
export const FluxDispatcher = find<t.FluxDispatcher>(filters.byProps("dispatch", "subscribe"), (m: t.FluxDispatcher) => {
|
export const FluxDispatcher = find<t.FluxDispatcher>(filters.byProps("dispatch", "subscribe"), (m: t.FluxDispatcher) => {
|
||||||
|
|
|
@ -16,5 +16,5 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
export * from "./api";
|
||||||
export * as Common from "./common";
|
export * as Common from "./common";
|
||||||
export * from "./webpack";
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
"@shared/*": ["./shared/*"],
|
"@shared/*": ["./shared/*"],
|
||||||
"@webpack/types": ["./webpack/common/types"],
|
"@webpack/types": ["./webpack/common/types"],
|
||||||
"@webpack/common": ["./webpack/common"],
|
"@webpack/common": ["./webpack/common"],
|
||||||
"@webpack": ["./webpack/webpack"]
|
"@webpack": ["./webpack/api"]
|
||||||
},
|
},
|
||||||
|
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
|
Loading…
Reference in a new issue