fix(lib): use new nested withDependencies filters everywhere

This commit is contained in:
PalmDevs 2025-10-29 19:34:38 +07:00
parent 8e2abb9e6f
commit 772bd2a283
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA
4 changed files with 19 additions and 40 deletions

View file

@ -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,

View file

@ -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,
]),

View file

@ -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<T>(
]
*/
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<
<T>() => 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
}
},

View file

@ -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'),
],
]),
]),
),