fix: get turbo modules from turbo module proxy
This commit is contained in:
parent
c239c5b4f8
commit
8f0755c4e7
6 changed files with 131 additions and 118 deletions
|
|
@ -7,7 +7,7 @@ import type { Metro } from '@revenge-mod/modules/types'
|
|||
import type { Asset } from './types'
|
||||
|
||||
const Version = 1
|
||||
const Key = `${Version}.${ClientInfoModule.Build}`
|
||||
const Key = `${Version}.${ClientInfoModule.getConstants().Build}`
|
||||
|
||||
// In-memory cache
|
||||
export const cache: Cache = {}
|
||||
|
|
|
|||
|
|
@ -11,15 +11,20 @@ import type { DiscordNativeModules } from './types/native'
|
|||
|
||||
const nmp = nativeModuleProxy
|
||||
|
||||
export const CacheModule =
|
||||
nmp.NativeCacheModule as DiscordNativeModules.CacheModule
|
||||
export const FileModule =
|
||||
nmp.NativeFileModule as DiscordNativeModules.FileModule
|
||||
export const ClientInfoModule =
|
||||
nmp.NativeClientInfoModule as DiscordNativeModules.ClientInfoModule
|
||||
export const DeviceModule =
|
||||
nmp.NativeDeviceModule as DiscordNativeModules.DeviceModule
|
||||
export const CacheModule = __turboModuleProxy(
|
||||
'NativeCacheModule',
|
||||
) as DiscordNativeModules.CacheModule
|
||||
export const FileModule = __turboModuleProxy(
|
||||
'NativeFileModule',
|
||||
) as DiscordNativeModules.FileModule
|
||||
export const ClientInfoModule = __turboModuleProxy(
|
||||
'NativeClientInfoModule',
|
||||
) as DiscordNativeModules.ClientInfoModule
|
||||
export const DeviceModule = __turboModuleProxy(
|
||||
'NativeDeviceModule',
|
||||
) as DiscordNativeModules.DeviceModule
|
||||
export const BundleUpdaterManager =
|
||||
nmp.BundleUpdaterManager as DiscordNativeModules.BundleUpdaterManager
|
||||
export const ThemeModule =
|
||||
nmp.NativeThemeModule as DiscordNativeModules.ThemeModule
|
||||
export const ThemeModule = __turboModuleProxy(
|
||||
'NativeThemeModule',
|
||||
) as DiscordNativeModules.ThemeModule
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ export namespace DiscordNativeModules {
|
|||
storageDir: 'cache' | 'documents',
|
||||
path: string,
|
||||
): Promise<boolean>
|
||||
getConstants: () => {
|
||||
getConstants(): {
|
||||
/**
|
||||
* The path the `documents` storage dir (see {@link writeFile}) represents.
|
||||
*/
|
||||
|
|
@ -106,50 +106,52 @@ export namespace DiscordNativeModules {
|
|||
* Client information
|
||||
*/
|
||||
export interface ClientInfoModule {
|
||||
/**
|
||||
* Sentry ingestion DSN URL for alpha/beta builds
|
||||
*/
|
||||
SentryAlphaBetaDsn: string
|
||||
/**
|
||||
* Sentry ingestion DSN URL for staff builds (?)
|
||||
*/
|
||||
SentryStaffDsn: string
|
||||
/**
|
||||
* Sentry ingestion DSN URL for stable builds
|
||||
*/
|
||||
SentryDsn: string
|
||||
DeviceVendorID: string
|
||||
Manifest: string
|
||||
/**
|
||||
* Version code
|
||||
*
|
||||
* Follows the format of `{MINOR}{CHANNEL}{PATCH}` for `{MINOR}.{PATCH} ({CHANNEL})`
|
||||
* - `248200` for `248.0 (alpha)`
|
||||
* - `247105` for `247.5 (beta)`
|
||||
* - `246011` for `246.11 (stable)`
|
||||
*/
|
||||
Build: string
|
||||
/**
|
||||
* Version string
|
||||
*
|
||||
* Eg. `248.0`
|
||||
*/
|
||||
Version: string
|
||||
/**
|
||||
* Release channel
|
||||
*/
|
||||
ReleaseChannel: string
|
||||
/**
|
||||
* Matches `Version`
|
||||
*/
|
||||
OTABuild: string
|
||||
/**
|
||||
* Identifier for the installed client
|
||||
*
|
||||
* - **Android**: Package name
|
||||
* - **iOS**: Bundle ID
|
||||
*/
|
||||
Identifier: string
|
||||
getConstants(): {
|
||||
/**
|
||||
* Sentry ingestion DSN URL for alpha/beta builds
|
||||
*/
|
||||
SentryAlphaBetaDsn: string
|
||||
/**
|
||||
* Sentry ingestion DSN URL for staff builds (?)
|
||||
*/
|
||||
SentryStaffDsn: string
|
||||
/**
|
||||
* Sentry ingestion DSN URL for stable builds
|
||||
*/
|
||||
SentryDsn: string
|
||||
DeviceVendorID: string
|
||||
Manifest: string
|
||||
/**
|
||||
* Version code
|
||||
*
|
||||
* Follows the format of `{MINOR}{CHANNEL}{PATCH}` for `{MINOR}.{PATCH} ({CHANNEL})`
|
||||
* - `248200` for `248.0 (alpha)`
|
||||
* - `247105` for `247.5 (beta)`
|
||||
* - `246011` for `246.11 (stable)`
|
||||
*/
|
||||
Build: string
|
||||
/**
|
||||
* Version string
|
||||
*
|
||||
* Eg. `248.0`
|
||||
*/
|
||||
Version: string
|
||||
/**
|
||||
* Release channel
|
||||
*/
|
||||
ReleaseChannel: string
|
||||
/**
|
||||
* Matches `Version`
|
||||
*/
|
||||
OTABuild: string
|
||||
/**
|
||||
* Identifier for the installed client
|
||||
*
|
||||
* - **Android**: Package name
|
||||
* - **iOS**: Bundle ID
|
||||
*/
|
||||
Identifier: string
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -170,64 +172,66 @@ export namespace DiscordNativeModules {
|
|||
* Returns the screen size of the device
|
||||
*/
|
||||
getScreenSize(): { width: number; height: number }
|
||||
/**
|
||||
* Maximum CPU frequency
|
||||
* @example "2.00"
|
||||
*/
|
||||
maxCpuFreq: string
|
||||
/**
|
||||
* The brand of the device
|
||||
* - On Android, returns the value of `ro.product.brand`
|
||||
*/
|
||||
deviceBrand: string
|
||||
/**
|
||||
* Whether the device is using gesture navigation
|
||||
*/
|
||||
isGestureNavigationEnabled: boolean
|
||||
/**
|
||||
* The manufacturer of the device
|
||||
* - On Android, returns the value of `ro.product.manufacturer`
|
||||
*/
|
||||
deviceManufacturer: string
|
||||
/**
|
||||
* RAM size in gigabytes (most likely an approximation)
|
||||
* @example "3.62"
|
||||
*/
|
||||
ramSize: string
|
||||
/**
|
||||
* The device's DPI setting
|
||||
*/
|
||||
smallestScreenWidth: number
|
||||
/**
|
||||
* The version of the system
|
||||
* - On Android, returns the value of `ro.build.version.sdk`
|
||||
*/
|
||||
systemVersion: string
|
||||
/**
|
||||
* Whether the system taskbar navigation is enabled
|
||||
*/
|
||||
isTaskBarEnabled: boolean
|
||||
/**
|
||||
* The name of the device product
|
||||
* - On Android, returns the value of `ro.product.name`
|
||||
*/
|
||||
deviceProduct: string
|
||||
/**
|
||||
* The model of the device
|
||||
* - On Android, returns the value of `ro.product.model`
|
||||
*/
|
||||
deviceModel: string
|
||||
/**
|
||||
* The name of the device
|
||||
* - On Android, returns the value of `ro.product.device`
|
||||
*/
|
||||
device: string
|
||||
/**
|
||||
* The name of the device board
|
||||
* - On Android, returns the value of `{ro.product.manufacturer}_{ro.soc.model}`
|
||||
* @example "Google_Tensor G4" // ro.product.manufacturer=Google; ro.soc.model=Tensor G4
|
||||
*/
|
||||
socName: string
|
||||
getConstants(): {
|
||||
/**
|
||||
* Maximum CPU frequency
|
||||
* @example "2.00"
|
||||
*/
|
||||
maxCpuFreq: string
|
||||
/**
|
||||
* The brand of the device
|
||||
* - On Android, returns the value of `ro.product.brand`
|
||||
*/
|
||||
deviceBrand: string
|
||||
/**
|
||||
* Whether the device is using gesture navigation
|
||||
*/
|
||||
isGestureNavigationEnabled: boolean
|
||||
/**
|
||||
* The manufacturer of the device
|
||||
* - On Android, returns the value of `ro.product.manufacturer`
|
||||
*/
|
||||
deviceManufacturer: string
|
||||
/**
|
||||
* RAM size in gigabytes (most likely an approximation)
|
||||
* @example "3.62"
|
||||
*/
|
||||
ramSize: string
|
||||
/**
|
||||
* The device's DPI setting
|
||||
*/
|
||||
smallestScreenWidth: number
|
||||
/**
|
||||
* The version of the system
|
||||
* - On Android, returns the value of `ro.build.version.sdk`
|
||||
*/
|
||||
systemVersion: string
|
||||
/**
|
||||
* Whether the system taskbar navigation is enabled
|
||||
*/
|
||||
isTaskBarEnabled: boolean
|
||||
/**
|
||||
* The name of the device product
|
||||
* - On Android, returns the value of `ro.product.name`
|
||||
*/
|
||||
deviceProduct: string
|
||||
/**
|
||||
* The model of the device
|
||||
* - On Android, returns the value of `ro.product.model`
|
||||
*/
|
||||
deviceModel: string
|
||||
/**
|
||||
* The name of the device
|
||||
* - On Android, returns the value of `ro.product.device`
|
||||
*/
|
||||
device: string
|
||||
/**
|
||||
* The name of the device board
|
||||
* - On Android, returns the value of `{ro.product.manufacturer}_{ro.soc.model}`
|
||||
* @example "Google_Tensor G4" // ro.product.manufacturer=Google; ro.soc.model=Tensor G4
|
||||
*/
|
||||
socName: string
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import type { FilterResultFlag } from './finders/_internal'
|
|||
import type { Filter } from './finders/filters'
|
||||
|
||||
const Version = 1
|
||||
const Key = `${Version}.${ClientInfoModule.Build}`
|
||||
const Key = `${Version}.${ClientInfoModule.getConstants().Build}`
|
||||
|
||||
// In-memory cache
|
||||
export const cache: Cache = {}
|
||||
|
|
|
|||
3
lib/types/types.d.ts
vendored
3
lib/types/types.d.ts
vendored
|
|
@ -69,7 +69,6 @@ declare global {
|
|||
/// METRO
|
||||
|
||||
declare global {
|
||||
var nativeModuleProxy: Record<string, unknown>
|
||||
var __r: Metro.RequireFn
|
||||
var __c: Metro.ClearFn
|
||||
var __d: Metro.DefineFn
|
||||
|
|
@ -78,6 +77,8 @@ declare global {
|
|||
/// REACT NATIVE
|
||||
|
||||
declare global {
|
||||
var nativeModuleProxy: Record<string, unknown>
|
||||
function __turboModuleProxy(name: string): unknown
|
||||
function nativeLoggingHook(str: string, level: number): void
|
||||
function alert(message: unknown): void
|
||||
|
||||
|
|
|
|||
|
|
@ -58,10 +58,13 @@ function runCatching(fn: () => void) {
|
|||
const { ClientInfoModule, DeviceModule } =
|
||||
require('@revenge-mod/discord/native') as typeof import('@revenge-mod/discord/native')
|
||||
|
||||
const Client = ClientInfoModule.getConstants()
|
||||
const Device = DeviceModule.getConstants()
|
||||
|
||||
alert(
|
||||
`Failed to load Revenge (${__BUILD_VERSION__}-${__BUILD_COMMIT__}-${__BUILD_BRANCH__} (${__BUILD_ENV__}))\n` +
|
||||
`Discord: ${ClientInfoModule.Version} (${ClientInfoModule.Build})\n` +
|
||||
`Device: ${DeviceModule.deviceManufacturer} ${DeviceModule.deviceModel}\n\n` +
|
||||
`Discord: ${Client.Version} (${Client.Build})\n` +
|
||||
`Device: ${Device.deviceManufacturer} ${Device.deviceModel}\n\n` +
|
||||
getErrorStack(e),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue