fix(lib)!: move modules/native/discord and its types to discord/native

This commit is contained in:
PalmDevs 2025-04-29 18:41:22 +07:00
parent 00b45b9487
commit 20af127254
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA
21 changed files with 30 additions and 27 deletions

View file

@ -5,6 +5,15 @@
"exports": {
".": {
"default": "./src/index.ts"
},
"./flux": {
"default": "./src/flux.ts"
},
"./native": {
"default": "./src/native.ts"
},
"./types": {
"types": "./types/index.ts"
}
}
}

View file

@ -1,7 +1,7 @@
import { waitForModules } from '@revenge-mod/modules/finders'
import { byProps } from '@revenge-mod/modules/finders/filters'
import type { DiscordModules } from '@revenge-mod/modules/types/discord'
import type { DiscordModules } from '../types'
waitForModules(byProps<DiscordModules.Flux.Store>('_dispatchToken'), (_, store) => {
const name = store.getName()

View file

@ -1,9 +1,10 @@
import { lookupModule } from '@revenge-mod/modules/finders'
import { byName, byProps } from '@revenge-mod/modules/finders/filters'
import type { DiscordModules } from '@revenge-mod/modules/types/discord'
import type { DiscordModules } from '../types'
export * as flux from './flux'
export * as native from './native'
// ../discord_common/js/shared/Logger.tsx
export const Logger = lookupModule(byName<DiscordModules.Logger>('Logger'))!

View file

@ -1,4 +1,4 @@
import type { DiscordNativeModules } from '../../types/discord.native'
import type { DiscordNativeModules } from '../types/native'
/**
* Naming conventions:

View file

@ -1,3 +1,5 @@
export * from './native'
export namespace DiscordModules {
export namespace Flux {
export type DispatcherPayload = any

View file

@ -39,9 +39,9 @@ function runCatching<F extends (...args: any[]) => any>(fn: F) {
try {
fn(...args)
} catch (e) {
const { ClientInfoModule, DeviceModule } = require('@revenge-mod/modules/native/discord') as
const { ClientInfoModule, DeviceModule } = require('@revenge-mod/discord/native') as
// biome-ignore format: Don't format this please
typeof import('@revenge-mod/modules/native/discord')
typeof import('@revenge-mod/discord/native')
// TODO(init): Move to use native module
alert(

View file

@ -19,20 +19,13 @@
"default": "./src/metro/subscriptions/index.ts"
},
"./native": {
"default": "./src/native/index.ts"
},
"./native/discord": {
"default": "./src/native/discord.ts"
"default": "./src/native.ts"
},
"./preinit": {
"default": "./src/preinit.ts"
},
"./types": {
"default": "./types/index.ts"
},
"./types/*": {
"default": "./types/*.ts",
"types": "./types/*.ts"
"default": "./types.ts"
},
"./_/metro": {
"default": "./src/metro/_internal.ts"

View file

@ -1,7 +1,7 @@
import { isModuleExportBad } from '../metro'
import type { If } from '@revenge-mod/utils/types'
import type { Metro } from '../../types/metro'
import type { Metro } from '../../types'
import type { Filter } from './filters'
export type RunFilterOptions = {

View file

@ -3,7 +3,7 @@ import { _mInited } from '../metro/_internal'
import { getModuleDependencies, initializedModuleHasBadExports, isModuleInitialized } from '../metro'
import type { If, LogicalOr } from '@revenge-mod/utils/types'
import type { Metro } from '../../types/metro'
import type { Metro } from '../../types'
export type FilterResult<F> = F extends Filter<infer R, boolean> ? R : never

View file

@ -3,7 +3,7 @@ import { type LookupModulesOptions, lookupModule, lookupModuleByImportedPath, lo
import { type WaitForModulesOptions, waitForModuleByImportedPath, waitForModules } from './wait'
import type { LookupModuleIdsOptions, MaybeDefaultExportMatched } from '.'
import type { Metro } from '../../types/metro'
import type { Metro } from '../../types'
import type { Filter, FilterResult } from './filters'
import type { RunFilterReturnExportsOptions } from './_internal'
import type { If } from '@revenge-mod/utils/types'

View file

@ -9,7 +9,7 @@ import {
import { getInitializedModuleExports } from '../metro'
import type { MaybeDefaultExportMatched } from '.'
import type { Metro } from '../../types/metro'
import type { Metro } from '../../types'
import type { Filter, FilterResult } from './filters'
import type { If } from '@revenge-mod/utils/types'

View file

@ -7,7 +7,7 @@ import {
} from '../metro'
import type { MaybeDefaultExportMatched } from '.'
import type { Metro } from '../../types/metro'
import type { Metro } from '../../types'
import type { Filter, FilterResult } from './filters'
export type BaseWaitForModulesOptions<IncludeAll extends boolean = boolean> = {

View file

@ -1,7 +1,7 @@
import { _executeInitializedSubscription, _executeRequiredSubscription } from './subscriptions/_internal'
import { isModuleExportsBad } from './utils'
import type { Metro } from '../../types/metro'
import type { Metro } from '../../types'
/** Initializing ID */
export let _mInitingId = -1

View file

@ -1,7 +1,7 @@
import { _mInitingId } from '../_internal'
import type { ModuleInitializedCallback, ModuleRequiredCallback, ModuleWithImportedPathInitializedCallback } from '.'
import type { Metro } from '../../../types/metro'
import type { Metro } from '../../../types'
export const _reqAll = new Set<ModuleRequiredCallback>()
export const _reqSpecific = new Map<Metro.ModuleID, Set<ModuleRequiredCallback>>()

View file

@ -1,7 +1,7 @@
import { _initAll, _importedPath, _initSpecific, _reqSpecific, _reqAll } from './_internal'
import type { initializedModuleHasBadExports } from '../utils'
import type { Metro } from '../../../types/metro'
import type { Metro } from '../../../types'
export type ModuleRequiredCallback = (id: Metro.ModuleID) => void
export type ModuleInitializedCallback = (id: Metro.ModuleID, exports: Metro.ModuleExports) => void

View file

@ -1,7 +1,7 @@
import { isProxy } from '@revenge-mod/utils/proxy'
import { _mInited, _mMd, _mUninited } from './_internal'
import type { Metro } from '../../types/metro'
import type { Metro } from '../../types'
/**
* Returns whether an uninitialized module has bad exports.

View file

@ -0,0 +1,2 @@
// TODO(modules/native): add support for native modules interop
export {}

View file

@ -1 +0,0 @@
export * as discord from './discord'

View file

@ -1,3 +0,0 @@
export * from './discord'
export * from './discord.native'
export * from './metro'