diff --git a/src/deck-components/ButtonItem.tsx b/src/deck-components/ButtonItem.tsx index 773edee..d96a615 100644 --- a/src/deck-components/ButtonItem.tsx +++ b/src/deck-components/ButtonItem.tsx @@ -9,5 +9,5 @@ export interface ButtonItemProps extends ItemProps { } export const ButtonItem = Object.values(CommonUIModule).find((mod: any) => - mod?.render?.toString()?.includes('childrenContainerWidth:"min"'), + mod?.render?.toString()?.includes('"highlightOnFocus","childrenContainerWidth"'), ) as FC; diff --git a/src/webpack.ts b/src/webpack.ts index 3025d22..73a5aac 100644 --- a/src/webpack.ts +++ b/src/webpack.ts @@ -1,6 +1,7 @@ declare global { interface Window { webpackJsonp: any; + webpackChunksteamui: any; } } @@ -9,14 +10,33 @@ export type Module = any; type FilterFn = (module: any) => boolean; type FindFn = (module: any) => any; -const wpRequire = window.webpackJsonp.push([ - [], - { get_require: (mod: any, _exports: any, wpRequire: any) => (mod.exports = wpRequire) }, - [['get_require']], -]); +export let webpackCache: any = {}; +let hasWebpack5 = false; -export const allModules: Module[] = Object.keys(wpRequire.c) - .map((x) => wpRequire.c[x].exports) +if (window.webpackJsonp && !window.webpackJsonp.deckyShimmed) { + // Webpack 4, currently on stable + const wpRequire = window.webpackJsonp.push([ + [], + { get_require: (mod: any, _exports: any, wpRequire: any) => (mod.exports = wpRequire) }, + [['get_require']], + ]); + + delete wpRequire.m.get_require; + delete wpRequire.c.get_require; + webpackCache = wpRequire.c; +} else { + // Webpack 5, currently on beta + hasWebpack5 = true; + const id = Math.random(); + let initReq: any; + window.webpackChunksteamui.push([[ id ], {}, (r: any) => { initReq = r }]); + for (let i of Object.keys(initReq.m)) { + webpackCache[i] = initReq(i) + } +} + +export const allModules: Module[] = hasWebpack5 ? Object.values(webpackCache).filter((x) => x) : Object.keys(webpackCache) + .map((x) => webpackCache[x].exports) .filter((x) => x); export const findModule = (filter: FilterFn) => {