fix: correct misleading terms

This commit is contained in:
PalmDevs 2025-09-17 16:56:10 +07:00
parent 4f612edda4
commit 349c23eced
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA
6 changed files with 30 additions and 30 deletions

View file

@ -14,7 +14,7 @@ export type InsteadJSXCallback<E extends ElementType> = (
) => ReturnType<AnyJSXFactoryFunction> | null
export type AfterJSXCallback<E extends ElementType> = (
fiber: ReactElement<ElementTypeProps<E>, E>,
element: ReactElement<ElementTypeProps<E>, E>,
) => ReturnType<AnyJSXFactoryFunction> | null
type ElementTypeProps<E extends ElementType> = E extends ElementType<

View file

@ -18,16 +18,16 @@ const patch = (
if (before) for (const cb of before) args = cb(args)
let fiber: ReactElement | null | undefined
let el: ReactElement | null | undefined
// If there are instead patches, fiber will always be set by the instead patches
if (instead) for (const cb of instead) fiber = cb(args, jsx)
// If there aren't any instead patches, we compute the fiber normally, and it will be set
else fiber = Reflect.apply(orig, ReactJSXRuntime, args)
// If there are instead patches, el will always be set by the instead patches
if (instead) for (const cb of instead) el = cb(args, jsx)
// If there aren't any instead patches, we compute el normally, and it will be set
else el = Reflect.apply(orig, ReactJSXRuntime, args)
if (after) for (const cb of after) fiber = cb(fiber!)
if (after) for (const cb of after) el = cb(el!)
return fiber!
return el!
}
instead(ReactJSXRuntime, 'jsx', patch)

View file

@ -1,6 +1,6 @@
import { useEffect, useReducer } from 'react'
import { findInTree } from './tree'
import type { ReactNode } from 'react'
import type { ReactElement } from 'react'
import type { SearchFilter } from './tree'
export function useIsFirstRender() {
@ -21,7 +21,7 @@ export function useReRender() {
const ReactFiberWalkable = new Set(['props', 'children', 'child', 'sibling'])
export function findInReactFiber<F extends SearchFilter>(
fiber: Extract<ReactNode, object>,
fiber: ReactElement,
filter: F,
) {
return findInTree<F>(fiber, filter, {

View file

@ -77,9 +77,9 @@ function patchSettingsNavigator(exports: any) {
return Reflect.apply(orig, React, args)
})
const fiber = Reflect.apply(orig, undefined, args)
const el = Reflect.apply(orig, undefined, args)
unpatchMemo()
return fiber
return el
})
}
@ -133,9 +133,9 @@ function patchSettingsOverviewScreen(exports: any) {
return sections
})
const fiber = Reflect.apply(orig, undefined, args)
const el = Reflect.apply(orig, undefined, args)
unpatchMemo()
return fiber
return el
},
)
}

View file

@ -9,7 +9,7 @@ import { findInReactFiber } from '@revenge-mod/utils/react'
import { Image } from 'react-native'
import { Badges, UsersWithBadges } from './constants'
import { styles, useBadgeStyles } from './styles'
import { afterReconciled } from './utils'
import { afterRendered } from './utils'
import type { FC, ReactElement } from 'react'
import type {
ImageProps,
@ -81,9 +81,9 @@ registerPlugin(
)
cleanup(
afterJSX(ProfileBadgeRows, fiber => {
patchProfileBadgeRows(fiber)
return fiber
afterJSX(ProfileBadgeRows, el => {
patchProfileBadgeRows(el)
return el
}),
)
},
@ -103,15 +103,15 @@ registerPlugin(
function patchProfileBadgeRows(
element: ReactElement<ProfileBadgeRowsProps, FC<ProfileBadgeRowsProps>>,
): void {
const unpatch = afterReconciled(element, fiber => {
const unpatch = afterRendered(element, el => {
unpatch()
const container = findInReactFiber(
fiber as ReactElement,
el as ReactElement,
isViewContainingProfileBadgeElements,
)
if (!container) return fiber
if (!container) return el
const [{ type: ProfileBadge, props }] = container.props.children
const userBadges = UsersWithBadges[props.userId]
@ -139,7 +139,7 @@ function patchProfileBadgeRows(
if (props.id === DUMMY_SYMBOL) container.props.children.pop()
}
return fiber
return el
})
}
@ -152,7 +152,7 @@ function patchProfileBadge(
// Return early if we don't actually need to patch this badge
if (!bnw && !showDialog) return
const unpatch = afterReconciled(element, fiber => {
const unpatch = afterRendered(element, el => {
unpatch()
// This will not result in a conditional hook error because badges do not change flags during runtime
@ -160,7 +160,7 @@ function patchProfileBadge(
if (showDialog) {
const pressable = findInReactFiber(
fiber as ReactElement,
el as ReactElement,
(node): node is ReactElement<PressableProps> =>
node.type?.render,
)
@ -172,7 +172,7 @@ function patchProfileBadge(
if (bnw) {
const image = findInReactFiber(
fiber as ReactElement,
el as ReactElement,
(node): node is ReactElement<ImageProps> => node.type === Image,
)
@ -185,7 +185,7 @@ function patchProfileBadge(
}
}
return fiber
return el
})
}

View file

@ -1,10 +1,10 @@
import { after } from '@revenge-mod/patcher'
import type { FC, ReactElement, ReactNode } from 'react'
export const afterReconciled = (
export const afterRendered = (
el: ReactElement<any, FC<any>>,
hook: (fiber: ReactNode) => ReactNode,
hook: (el: ReactNode) => ReactNode,
) =>
after(el, 'type', fiber =>
fiber instanceof Promise ? fiber.then(hook) : hook(fiber),
after(el, 'type', el =>
el instanceof Promise ? el.then(hook) : hook(el),
)