fix(lib): use new nested withDependencies filters everywhere
This commit is contained in:
parent
8e2abb9e6f
commit
772bd2a283
4 changed files with 19 additions and 40 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
]),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
},
|
||||
|
|
|
|||
8
lib/externals/src/react-navigation.ts
vendored
8
lib/externals/src/react-navigation.ts
vendored
|
|
@ -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'),
|
||||
],
|
||||
]),
|
||||
]),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue