From 772bd2a283bec607a208788718bca488d0fad1db Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Wed, 29 Oct 2025 19:34:38 +0700 Subject: [PATCH] fix(lib): use new nested `withDependencies` filters everywhere --- lib/assets/src/preinit.ts | 13 +++-------- lib/discord/src/common/utils.ts | 7 ++---- lib/discord/src/flux/stores.ts | 31 +++++++++------------------ lib/externals/src/react-navigation.ts | 8 +++---- 4 files changed, 19 insertions(+), 40 deletions(-) diff --git a/lib/assets/src/preinit.ts b/lib/assets/src/preinit.ts index 6b4c71a..cd2d406 100644 --- a/lib/assets/src/preinit.ts +++ b/lib/assets/src/preinit.ts @@ -1,8 +1,4 @@ -import { - lookupModule, - lookupModules, - waitForModules, -} from '@revenge-mod/modules/finders' +import { lookupModules, waitForModules } from '@revenge-mod/modules/finders' import { withDependencies, withName, @@ -22,13 +18,10 @@ import type { Asset, PackagerAsset } from './types' const { relative } = withDependencies -const [, _classCallCheckId] = lookupModule(withName('_classCallCheck')) -const [, _createClassId] = lookupModule(withName('_createClass')) - // https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Image/AssetSourceResolver.js const withAssetSourceResolver = withDependencies([ - _classCallCheckId, - _createClassId, + withName('_classCallCheck'), + withName('_createClass'), relative(1), relative(2), null, diff --git a/lib/discord/src/common/utils.ts b/lib/discord/src/common/utils.ts index bfdfd4e..de93ab8 100644 --- a/lib/discord/src/common/utils.ts +++ b/lib/discord/src/common/utils.ts @@ -6,9 +6,6 @@ import { import { proxify } from '@revenge-mod/utils/proxy' import type { DiscordModules } from '../types' -const [, _createClassModuleId] = lookupModule(withName('_createClass')) -const [, _classCallCheckModuleId] = lookupModule(withName('_classCallCheck')) - // ../discord_common/js/shared/utils/TypedEventEmitter.tsx /** * Do not use the `error` event, as the module will handle it specially for some reason. @@ -20,8 +17,8 @@ export let TypedEventEmitter: typeof DiscordModules.Utils.TypedEventEmitter = 'TypedEventEmitter', ).and( withDependencies([ - _classCallCheckModuleId, - _createClassModuleId, + withName('_classCallCheck'), + withName('_createClass'), [], 2, ]), diff --git a/lib/discord/src/flux/stores.ts b/lib/discord/src/flux/stores.ts index d756c19..7e2cb0b 100644 --- a/lib/discord/src/flux/stores.ts +++ b/lib/discord/src/flux/stores.ts @@ -5,6 +5,7 @@ import { } from '@revenge-mod/modules/finders' import { createFilterGenerator, + withDependencies, withName, } from '@revenge-mod/modules/finders/filters' import { getModuleDependencies } from '@revenge-mod/modules/metro/utils' @@ -76,23 +77,15 @@ export function getStore( ] */ -const [, _createClassModuleId] = lookupModule(withName('_createClass')) -const [, _classCallCheckModuleId] = lookupModule(withName('_classCallCheck')) -const [, _possibleConstructorReturnModuleId] = lookupModule( - withName('_possibleConstructorReturn'), +const withLeadingFluxStoreDeps = withDependencies( + withDependencies.loose([ + withName('_classCallCheck'), + withName('_createClass'), + withName('_possibleConstructorReturn'), + withName('bound getPrototypeOf'), + withName('_inherits'), + ]), ) -const [, _bound_getPrototypeOfModuleId] = lookupModule( - withName('bound getPrototypeOf'), -) -const [, _inheritsModuleId] = lookupModule(withName('_inherits')) - -const FluxStoreLeadingDeps = [ - _classCallCheckModuleId, - _createClassModuleId, - _possibleConstructorReturnModuleId, - _bound_getPrototypeOfModuleId, - _inheritsModuleId, -] export type WithStore = FilterGenerator< () => Filter<{ @@ -112,12 +105,8 @@ export const withStore = createFilterGenerator( (_, id, exports) => { if (exports) return Boolean(exports._dispatchToken) else { + if (!withLeadingFluxStoreDeps(id)) return false const deps = getModuleDependencies(id)! - if (deps.length < FluxStoreLeadingDeps.length) return false - - for (let i = 0; i < FluxStoreLeadingDeps.length; i++) - if (deps[i] !== FluxStoreLeadingDeps[i]) return false - return deps[deps.length - 1] === 2 } }, diff --git a/lib/externals/src/react-navigation.ts b/lib/externals/src/react-navigation.ts index 78aa94e..3871a58 100644 --- a/lib/externals/src/react-navigation.ts +++ b/lib/externals/src/react-navigation.ts @@ -9,9 +9,6 @@ import { proxify } from '@revenge-mod/utils/proxy' const { loose, relative } = withDependencies -const [, _createClassModuleId] = lookupModule(withName('_createClass')) -const [, _classCallCheckModuleId] = lookupModule(withName('_classCallCheck')) - export let ReactNavigationNative: typeof import('@react-navigation/native') = proxify( () => { @@ -21,7 +18,10 @@ export let ReactNavigationNative: typeof import('@react-navigation/native') = loose([ [], loose([ - [_createClassModuleId, _classCallCheckModuleId], + [ + withName('_createClass'), + withName('_classCallCheck'), + ], ]), ]), ),