feat(lib/modules/common)!: export more commons
This commit is contained in:
parent
54b45dfd93
commit
87ff29a36a
7 changed files with 40 additions and 4 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { ReactNative } from '@revenge-mod/modules/common'
|
||||
import { ReactNative } from '@revenge-mod/modules/common/react'
|
||||
|
||||
import { _assets } from './_internal'
|
||||
import { AssetRegistry } from './patches'
|
||||
|
|
|
|||
|
|
@ -7,7 +7,13 @@
|
|||
"default": "./src/index.ts"
|
||||
},
|
||||
"./common": {
|
||||
"default": "./src/common.ts"
|
||||
"default": "./src/common/index.ts"
|
||||
},
|
||||
"./common/discord": {
|
||||
"default": "./src/common/discord/index.ts"
|
||||
},
|
||||
"./common/react": {
|
||||
"default": "./src/common/react.ts"
|
||||
},
|
||||
"./finders": {
|
||||
"default": "./src/finders/index.ts"
|
||||
|
|
|
|||
16
lib/modules/src/common/discord/flux.ts
Normal file
16
lib/modules/src/common/discord/flux.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { waitForModules } from '../../finders'
|
||||
import { byProps } from '../../finders/filters'
|
||||
|
||||
import type { DiscordModules } from '../../../types'
|
||||
|
||||
waitForModules(byProps<DiscordModules.Flux.Store>('_dispatchToken'), (_, store) => {
|
||||
const name = store.getName()
|
||||
_stores[name] = store
|
||||
})
|
||||
|
||||
const _stores: Record<string, any> = {}
|
||||
|
||||
export const stores = new Proxy(_stores, {
|
||||
ownKeys: () => Reflect.ownKeys(_stores),
|
||||
get: (_, name) => Reflect.get(_stores, name),
|
||||
})
|
||||
11
lib/modules/src/common/discord/index.ts
Normal file
11
lib/modules/src/common/discord/index.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { lookupModule } from '../../finders'
|
||||
import { byName, byProps } from '../../finders/filters'
|
||||
|
||||
import type { DiscordModules } from '../../../types/discord'
|
||||
|
||||
export * as flux from './flux'
|
||||
|
||||
// ../discord_common/js/shared/Logger.tsx
|
||||
export const Logger = lookupModule(byName<DiscordModules.Logger>('Logger'))!
|
||||
// ../discord_common/js/packages/tokens/native.tsx
|
||||
export const tokens = lookupModule(byProps('RawColor'))!
|
||||
2
lib/modules/src/common/index.ts
Normal file
2
lib/modules/src/common/index.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export * as discord from './discord'
|
||||
export * as react from './react'
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { yielded } from '@revenge-mod/utils/generators'
|
||||
|
||||
import { lookupModuleId, lookupModuleIds } from './finders'
|
||||
import { byProps } from './finders/filters'
|
||||
import { lookupModuleId, lookupModuleIds } from '../finders'
|
||||
import { byProps } from '../finders/filters'
|
||||
|
||||
export const ReactModuleId = yielded(lookupModuleIds(byProps<typeof import('react')>('useState')), 1)!
|
||||
export const ReactNativeModuleId = lookupModuleId(byProps<typeof import('react-native')>('AppRegistry'))!
|
||||
|
|
@ -31,6 +31,7 @@ export namespace DiscordModules {
|
|||
_isInitialized: boolean
|
||||
_version: number
|
||||
_reactChangeCallbacks: StoreChangeCallbacks
|
||||
_dispatchToken: string
|
||||
}
|
||||
|
||||
export interface Dispatcher {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue