diff --git a/lib/react/src/jsx-runtime/index.ts b/lib/react/src/jsx-runtime/index.ts index ffe0bb4..82bdda3 100644 --- a/lib/react/src/jsx-runtime/index.ts +++ b/lib/react/src/jsx-runtime/index.ts @@ -14,7 +14,7 @@ export type InsteadJSXCallback = ( ) => ReturnType | null export type AfterJSXCallback = ( - fiber: ReactElement, E>, + element: ReactElement, E>, ) => ReturnType | null type ElementTypeProps = E extends ElementType< diff --git a/lib/react/src/jsx-runtime/patches.ts b/lib/react/src/jsx-runtime/patches.ts index 190d4e6..848dbee 100644 --- a/lib/react/src/jsx-runtime/patches.ts +++ b/lib/react/src/jsx-runtime/patches.ts @@ -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) diff --git a/lib/utils/src/react.ts b/lib/utils/src/react.ts index 56fe5ea..9876883 100644 --- a/lib/utils/src/react.ts +++ b/lib/utils/src/react.ts @@ -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( - fiber: Extract, + fiber: ReactElement, filter: F, ) { return findInTree(fiber, filter, { diff --git a/src/plugins/start/settings/index.ts b/src/plugins/start/settings/index.ts index 50c7440..f4a5d1c 100644 --- a/src/plugins/start/settings/index.ts +++ b/src/plugins/start/settings/index.ts @@ -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 }, ) } diff --git a/src/plugins/start/user-badges/index.tsx b/src/plugins/start/user-badges/index.tsx index b7122a9..ddcda33 100644 --- a/src/plugins/start/user-badges/index.tsx +++ b/src/plugins/start/user-badges/index.tsx @@ -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>, ): 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 => node.type?.render, ) @@ -172,7 +172,7 @@ function patchProfileBadge( if (bnw) { const image = findInReactFiber( - fiber as ReactElement, + el as ReactElement, (node): node is ReactElement => node.type === Image, ) @@ -185,7 +185,7 @@ function patchProfileBadge( } } - return fiber + return el }) } diff --git a/src/plugins/start/user-badges/utils.ts b/src/plugins/start/user-badges/utils.ts index f34cec4..7dada49 100644 --- a/src/plugins/start/user-badges/utils.ts +++ b/src/plugins/start/user-badges/utils.ts @@ -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>, - 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), )