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 { import { lookupModules, waitForModules } from '@revenge-mod/modules/finders'
lookupModule,
lookupModules,
waitForModules,
} from '@revenge-mod/modules/finders'
import { import {
withDependencies, withDependencies,
withName, withName,
@ -22,13 +18,10 @@ import type { Asset, PackagerAsset } from './types'
const { relative } = withDependencies 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 // https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Image/AssetSourceResolver.js
const withAssetSourceResolver = withDependencies([ const withAssetSourceResolver = withDependencies([
_classCallCheckId, withName('_classCallCheck'),
_createClassId, withName('_createClass'),
relative(1), relative(1),
relative(2), relative(2),
null, null,

View file

@ -6,9 +6,6 @@ import {
import { proxify } from '@revenge-mod/utils/proxy' import { proxify } from '@revenge-mod/utils/proxy'
import type { DiscordModules } from '../types' import type { DiscordModules } from '../types'
const [, _createClassModuleId] = lookupModule(withName('_createClass'))
const [, _classCallCheckModuleId] = lookupModule(withName('_classCallCheck'))
// ../discord_common/js/shared/utils/TypedEventEmitter.tsx // ../discord_common/js/shared/utils/TypedEventEmitter.tsx
/** /**
* Do not use the `error` event, as the module will handle it specially for some reason. * 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', 'TypedEventEmitter',
).and( ).and(
withDependencies([ withDependencies([
_classCallCheckModuleId, withName('_classCallCheck'),
_createClassModuleId, withName('_createClass'),
[], [],
2, 2,
]), ]),

View file

@ -5,6 +5,7 @@ import {
} from '@revenge-mod/modules/finders' } from '@revenge-mod/modules/finders'
import { import {
createFilterGenerator, createFilterGenerator,
withDependencies,
withName, withName,
} from '@revenge-mod/modules/finders/filters' } from '@revenge-mod/modules/finders/filters'
import { getModuleDependencies } from '@revenge-mod/modules/metro/utils' import { getModuleDependencies } from '@revenge-mod/modules/metro/utils'
@ -76,23 +77,15 @@ export function getStore<T>(
] ]
*/ */
const [, _createClassModuleId] = lookupModule(withName('_createClass')) const withLeadingFluxStoreDeps = withDependencies(
const [, _classCallCheckModuleId] = lookupModule(withName('_classCallCheck')) withDependencies.loose([
const [, _possibleConstructorReturnModuleId] = lookupModule( withName('_classCallCheck'),
withName('_possibleConstructorReturn'), 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< export type WithStore = FilterGenerator<
<T>() => Filter<{ <T>() => Filter<{
@ -112,12 +105,8 @@ export const withStore = createFilterGenerator(
(_, id, exports) => { (_, id, exports) => {
if (exports) return Boolean(exports._dispatchToken) if (exports) return Boolean(exports._dispatchToken)
else { else {
if (!withLeadingFluxStoreDeps(id)) return false
const deps = getModuleDependencies(id)! 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 return deps[deps.length - 1] === 2
} }
}, },

View file

@ -9,9 +9,6 @@ import { proxify } from '@revenge-mod/utils/proxy'
const { loose, relative } = withDependencies const { loose, relative } = withDependencies
const [, _createClassModuleId] = lookupModule(withName('_createClass'))
const [, _classCallCheckModuleId] = lookupModule(withName('_classCallCheck'))
export let ReactNavigationNative: typeof import('@react-navigation/native') = export let ReactNavigationNative: typeof import('@react-navigation/native') =
proxify( proxify(
() => { () => {
@ -21,7 +18,10 @@ export let ReactNavigationNative: typeof import('@react-navigation/native') =
loose([ loose([
[], [],
loose([ loose([
[_createClassModuleId, _classCallCheckModuleId], [
withName('_createClass'),
withName('_classCallCheck'),
],
]), ]),
]), ]),
), ),