@@ -21,7 +21,7 @@ export let modules = new Map<ModuleID, Module>();
2121function initModuleCache ( ) {
2222 const startTime = performance . now ( ) ;
2323 logger . group ( 'Webpack Module Init' ) ;
24- // Webpack 5, currently on beta
24+ // Webpack 5
2525 // Generate a fake module ID
2626 const id = Symbol ( "@decky/ui" ) ;
2727 let webpackRequire ! : ( ( id : any ) => Module ) & { m : object } ;
@@ -70,15 +70,22 @@ export const findModuleDetailsByExport = (
7070 for ( const [ id , m ] of modules ) {
7171 if ( ! m ) continue ;
7272 for ( const mod of [ m . default , m ] ) {
73+ // special cases
7374 if ( typeof mod !== 'object' ) continue ;
75+ if ( mod == window ) continue ; // wtf
7476 if ( minExports && Object . keys ( mod ) . length < minExports ) continue ;
77+
7578 for ( let exportName in mod ) {
7679 if ( mod ?. [ exportName ] ) {
77- const filterRes = filter ( mod [ exportName ] , exportName ) ;
78- if ( filterRes ) {
79- return [ mod , mod [ exportName ] , exportName , id ] ;
80- } else {
81- continue ;
80+ try {
81+ const filterRes = filter ( mod [ exportName ] , exportName ) ;
82+ if ( filterRes ) {
83+ return [ mod , mod [ exportName ] , exportName , id ] ;
84+ } else {
85+ continue ;
86+ }
87+ } catch ( e ) {
88+ logger . warn ( "Webpack filter threw exception: " , e ) ;
8289 }
8390 }
8491 }
@@ -99,6 +106,7 @@ export const findModuleExport = (filter: ExportFilterFn, minExports?: number) =>
99106 * @deprecated use findModuleExport instead
100107 */
101108export const findModuleChild = ( filter : FindFn ) => {
109+ logger . warn ( "findModuleChild is deprecated and will be removed soon. Use findModuleExport instead. Used in:" , new Error ( ) . stack ?. substring ( 5 ) )
102110 for ( const m of modules . values ( ) ) {
103111 for ( const mod of [ m . default , m ] ) {
104112 const filterRes = filter ( mod ) ;
@@ -115,6 +123,7 @@ export const findModuleChild = (filter: FindFn) => {
115123 * @deprecated use createModuleMapping instead
116124 */
117125export const findAllModules = ( filter : FilterFn ) => {
126+ logger . warn ( "findAllModules is deprecated and will be removed soon. Use createModuleMapping instead. Used in:" , new Error ( ) . stack ?. substring ( 5 ) )
118127 const out = [ ] ;
119128
120129 for ( const m of modules . values ( ) ) {
0 commit comments