From 066001c57ac39bd4facf66987a2fe115ea6e02de Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 21 Jun 2024 04:45:16 -0300 Subject: [PATCH 1/2] Add wreq.j --- src/plugins/consoleShortcuts/index.ts | 1 + src/webpack/webpack.ts | 6 ++--- src/webpack/wreq.d.ts | 32 ++++++++++++++------------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/plugins/consoleShortcuts/index.ts b/src/plugins/consoleShortcuts/index.ts index 4be2e2ee8..5703f7f53 100644 --- a/src/plugins/consoleShortcuts/index.ts +++ b/src/plugins/consoleShortcuts/index.ts @@ -85,6 +85,7 @@ function makeShortcuts() { wpex: extract, wpexs: (code: string) => extract(findModuleId(code)!), loadLazyChunks: IS_DEV ? loadLazyChunks : () => { throw new Error("loadLazyChunks is dev only."); }, + filters, find, findAll: findAll, findByProps, diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index 989c239fd..bbe8ab513 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -453,14 +453,14 @@ export function findExportedComponentLazy(...props: stri * closeModal: filters.byCode("key==") * }) */ -export const mapMangledModule = traceFunction("mapMangledModule", function mapMangledModule(code: string, mappers: Record): Record { - const exports = {} as Record; +export const mapMangledModule = traceFunction("mapMangledModule", function mapMangledModule(code: string, mappers: Record): Record { + const exports = {} as Record; const id = findModuleId(code); if (id === null) return exports; - const mod = wreq(id as any); + const mod = wreq(id); outer: for (const key in mod) { const member = mod[key]; diff --git a/src/webpack/wreq.d.ts b/src/webpack/wreq.d.ts index 648ce839c..3416bbfbb 100644 --- a/src/webpack/wreq.d.ts +++ b/src/webpack/wreq.d.ts @@ -58,21 +58,21 @@ export type WebpackRequire = ((moduleId: PropertyKey) => ModuleExports) & { m: Record; /** The module cache, where all modules which have been WebpackRequire'd are stored */ c: Record; - /** - * Export star. Sets properties of "fromObject" to "toObject" as getters that return the value from "fromObject", like this: - * @example - * const fromObject = { a: 1 }; - * Object.keys(fromObject).forEach(key => { - * if (key !== "default" && !Object.hasOwn(toObject, key)) { - * Object.defineProperty(toObject, key, { - * get: () => fromObject[key], - * enumerable: true - * }); - * } - * }); - * @returns fromObject - */ - es: (this: WebpackRequire, fromObject: Record, toObject: Record) => Record; + // /** + // * Export star. Sets properties of "fromObject" to "toObject" as getters that return the value from "fromObject", like this: + // * @example + // * const fromObject = { a: 1 }; + // * Object.keys(fromObject).forEach(key => { + // * if (key !== "default" && !Object.hasOwn(toObject, key)) { + // * Object.defineProperty(toObject, key, { + // * get: () => fromObject[key], + // * enumerable: true + // * }); + // * } + // * }); + // * @returns fromObject + // */ + // es: (this: WebpackRequire, fromObject: Record, toObject: Record) => Record; /** * Creates an async module. A module that exports something that is a Promise, or requires an export from an async module. * @@ -179,6 +179,8 @@ export type WebpackRequire = ((moduleId: PropertyKey) => ModuleExports) & { v: (this: WebpackRequire, exports: ModuleExports, wasmModuleId: any, wasmModuleHash: string, importsObj?: WebAssembly.Imports) => Promise; /** Bundle public path, where chunk files are stored. Used by other methods which load chunks to obtain the full asset url */ p: string; + /** The runtime id of the current runtime */ + j: string; /** Document baseURI or WebWorker location.href */ b: string; }; From 343e2802c30bfca8bf8c6a0efd8772731760209b Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 21 Jun 2024 04:52:08 -0300 Subject: [PATCH 2/2] boop --- src/webpack/webpack.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index bbe8ab513..b5f0ab620 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -630,15 +630,15 @@ export function search(...filters: Array) { * @param id The id of the module to extract */ export function extract(id: PropertyKey) { - const mod = wreq.m[id]; - if (!mod) return null; + 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(mod)} +0,${String(factory)} //# sourceURL=ExtractedWebpackModule${String(id)} `; const extracted: ModuleFactory = (0, eval)(code);