import { type Fiber, type FiberRoot, type ReactNode } from '../../../core'; import { drainReplayQueue } from '../../event-replay'; export { drainReplayQueue }; /** * Preserve the user's scroll position across hydration. If the user scrolled * between SSR paint and hydrate (common in dev where JS takes seconds to * load), libraries that wire scroll-restoration into a `useLayoutEffect` * near the root (e.g. TanStack Router) will run during our synchronous * hydrate and call `window.scrollTo(savedFromLastVisit)` — overwriting the * user's fresh scroll. We install a short-lived wrapper around scrollTo that * suppresses programmatic calls when a user-initiated scroll happened * recently. Only runs in the hydration feature — the stub skips it. */ export declare function installHydrationScrollGuard(): void; /** * Hydration cursor: walks existing DOM children in document order so we can * adopt them during fiber tree construction. One cursor per host parent. * * `endBefore` scopes the cursor to a subrange — used by rehydrateBoundary() * so we only adopt DOM up to the closing `/$` marker for that boundary. */ export declare class HydrationCursor { n: ChildNode | null; p: Node; e: ChildNode | null; constructor(parent: Node, start?: ChildNode | null, endBefore?: ChildNode | null); take(): ChildNode | null; /** * Position-insensitive lookup for head/html adoption. Scans forward past * non-matching nodes without removing them, matching by tag AND the key * attributes that identify head elements uniquely (rel/href for links, * name/property for meta, src for script). Non-matching nodes stay in * place so the SSR'd stylesheet/script order is preserved. */ head(tag: string, props: Record): ChildNode | null; has(): boolean; } export interface HydrationBailoutError extends Error { f: Fiber | null; } export declare function isHydrationBailout(error: unknown): error is HydrationBailoutError; export declare function abortHydration(cause: unknown, fiber?: Fiber | null): never; interface HydrateRootOptions { identifierPrefix?: string; onRecoverableError?: (error: unknown) => void; onCaughtError?: (error: unknown) => void; onUncaughtError?: (error: unknown) => void; } interface HydratedRoot { render(children: ReactNode): void; unmount(): void; } export declare function hydrateRootImpl(container: Element | Document, initialChildren: ReactNode, options: HydrateRootOptions): HydratedRoot; export declare function beginHydration(root: FiberRoot): void; export declare function endHydration(root: FiberRoot): void; /** * Inspect the current cursor position for a streaming-suspense boundary * marker emitted by the server. Returns info + advances the cursor past the * marker pair (start comment + fallback/real content + end comment). */ export type BoundaryInfo = [0 | 1, number, Comment, Comment]; export declare function tryConsumeBoundary(parent: Fiber): BoundaryInfo | null; export declare function advanceCursorPast(parent: Fiber, node: Node): void; export declare function getHydrationCursor(hostFiber: Fiber): HydrationCursor | undefined; export declare function setHydrationCursor(hostFiber: Fiber, cursor: HydrationCursor): void; export declare function clearHydrationCursor(hostFiber: Fiber): void; /** * Try to adopt a DOM node for this host fiber. Returns true if adopted. * Attaches existing attrs/children via separate hydrate pass. */ export declare function adoptHostDom(fiber: Fiber, parent: Fiber): boolean; export declare function adoptTextDom(fiber: Fiber, parent: Fiber, text: string): boolean; export declare function findHostParent(fiber: Fiber): Fiber;