// @ts-expect-error untyped import { __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE as ReactSharedInternals_ } from "react"; import type { ActivityProps, ComponentType, ConsumerProps, Context, Dispatch, ExoticComponent, ForwardRefExoticComponent, FragmentProps, LazyExoticComponent, MemoExoticComponent, ProfilerProps, ProviderExoticComponent, ProviderProps, ReactNode, SetStateAction, SuspenseProps, Usable, } from "react"; // SharedInternals var ReactSharedInternals: SharedStateClient = ReactSharedInternals_; export type StartTransitionOptions = { name?: string; }; export type TransitionStatus = unknown; export type Dispatcher = { use: (arg0: Usable) => T; readContext(context: Context): T; useState(initialState: (() => S) | S): [S, Dispatch>]; useReducer( reducer: (arg0: S, arg1: A) => S, initialArg: I, init?: (arg0: I) => S, ): [S, Dispatch]; useContext(context: Context): T; useRef(initialValue: T): { current: T; }; useEffect( create: () => (() => void) | void, deps: Array | void | null, ): void; useEffectEvent: ) => unknown>( callback: F, ) => F; useInsertionEffect( create: () => (() => void) | void, deps: Array | void | null, ): void; useLayoutEffect( create: () => (() => void) | void, deps: Array | void | null, ): void; useCallback(callback: T, deps: Array | void | null): T; useMemo(nextCreate: () => T, deps: Array | void | null): T; useImperativeHandle( ref: | { current: T | null; } | ((inst: T | null) => unknown) | null | void, create: () => T, deps: Array | void | null, ): void; useDebugValue( value: T, formatterFn: ((value: T) => unknown) | null | undefined, ): void; useDeferredValue(value: T, initialValue?: T): T; useTransition(): [ boolean, (callback: () => void, options?: StartTransitionOptions) => void, ]; useSyncExternalStore( subscribe: (arg0: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T, ): T; useId(): string; useCacheRefresh: () => ( arg0: (() => T) | null | undefined, arg1: T | null | undefined, ) => void; useMemoCache: (size: number) => Array; useHostTransitionStatus: () => TransitionStatus; useOptimistic: ( passthrough: S, reducer: ((arg0: S, arg1: A) => S) | null | undefined, ) => [S, (arg0: A) => void]; useFormState: ( action: (arg0: Awaited, arg1: P) => S, initialState: Awaited, permalink?: string, ) => [Awaited, (arg0: P) => void, boolean]; useActionState: ( action: (arg0: Awaited, arg1: P) => S, initialState: Awaited, permalink?: string, ) => [Awaited, (arg0: P) => void, boolean]; }; export type AsyncDispatcher = { getCacheForType: (resourceType: () => T) => T; cacheSignal: () => null | AbortSignal; // DEV-only getOwner: () => null; }; export type TransitionTypes = Array; export type Transition = { types: null | TransitionTypes; // enableViewTransition gesture: null | GestureProvider; // enableGestureTransition name: null | string; // enableTransitionTracing only startTime: number; // enableTransitionTracing only _updatedFibers: Set; // DEV-only }; export type GestureProvider = any; export type GestureOptions = { rangeStart?: number; rangeEnd?: number; }; type onStartTransitionFinish = (arg0: Transition, arg1: unknown) => void; type onStartGestureTransitionFinish = ( arg0: Transition, arg1: GestureProvider, arg2: GestureOptions | null | undefined, ) => () => void; export type SharedStateClient = { H: null | Dispatcher; // ReactCurrentDispatcher for Hooks A: null | AsyncDispatcher; // ReactCurrentCache for Cache T: null | Transition; // ReactCurrentBatchConfig for Transitions S: null | onStartTransitionFinish; G: null | onStartGestureTransitionFinish; // DEV-only // ReactCurrentActQueue actQueue: null | Array; // When zero this means we're outside an async startTransition. asyncTransitions: number; // Used to reproduce behavior of `batchedUpdates` in legacy mode. isBatchingLegacy: boolean; didScheduleLegacyUpdate: boolean; // Tracks whether something called `use` during the current batch of work. // Determines whether we should yield to microtasks to unwrap already resolved // promises without suspending. didUsePromise: boolean; // Track first uncaught error within this act thrownErrors: Array; // ReactDebugCurrentFrame getCurrentStack: null | (() => string); // ReactOwnerStackReset recentlyCreatedOwnerStacks: 0; }; export type RendererTask = (arg0: boolean) => RendererTask | null; export var runWithDispatcher = (dispatcher: Dispatcher, fn: () => T): T => { const prevDispatcher = ReactSharedInternals.H; try { ReactSharedInternals.H = dispatcher; return fn(); } finally { ReactSharedInternals.H = prevDispatcher; } }; // Extra Types /*export interface ExoticComponentMap { // $$typeof [REACT_CONSUMER_TYPE]: ExoticComponent>; [REACT_CONTEXT_TYPE]: ProviderExoticComponent>; [REACT_FORWARD_REF_TYPE]: ForwardRefExoticComponent; [REACT_LAZY_TYPE]: LazyExoticComponent>; [REACT_MEMO_TYPE]: MemoExoticComponent>; [REACT_PORTAL_TYPE]: ExoticComponent<{ children: ReactNode }>; // literal [REACT_ACTIVITY_TYPE]: ExoticComponent; [REACT_FRAGMENT_TYPE]: ExoticComponent; [REACT_PROFILER_TYPE]: ExoticComponent; [REACT_STRICT_MODE_TYPE]: ExoticComponent< { children?: ReactNode | UNDEFINED } >; [REACT_SUSPENSE_LIST_TYPE]: ExoticComponent; [REACT_SUSPENSE_TYPE]: ExoticComponent; } */