import { HydrationContextValue, HydrationSchedulerConfig, HydrationMetricsSnapshot, HydrationBoundaryId, HydrationPriority, HydrationStatus } from '../types'; /** * Return type for the useHydration hook. */ export interface UseHydrationReturn { /** * Whether the hydration system is initialized. */ readonly isInitialized: boolean; /** * Whether the hydration scheduler is currently paused. */ readonly isPaused: boolean; /** * Pauses the hydration scheduler. * Pending tasks remain in queue but processing stops. */ readonly pause: () => void; /** * Resumes a paused hydration scheduler. */ readonly resume: () => void; /** * Forces immediate hydration of a specific boundary. * * @param boundaryId - ID of the boundary to hydrate */ readonly forceHydrate: (boundaryId: HydrationBoundaryId) => Promise; /** * Forces hydration of all pending boundaries. */ readonly forceHydrateAll: () => Promise; /** * Gets the current status of a hydration boundary. * * @param boundaryId - ID of the boundary to check * @returns The hydration status, or undefined if not found */ readonly getStatus: (boundaryId: HydrationBoundaryId) => HydrationStatus | undefined; /** * Updates the priority of a hydration boundary. * * @param boundaryId - ID of the boundary to update * @param priority - New priority level */ readonly updatePriority: (boundaryId: HydrationBoundaryId, priority: HydrationPriority) => void; /** * Gets the current hydration metrics snapshot. * * @returns Aggregated hydration metrics */ readonly getMetrics: () => HydrationMetricsSnapshot; /** * Gets the current hydration configuration. */ readonly config: HydrationSchedulerConfig; } /** * Options for the useHydration hook. */ export interface UseHydrationOptions { /** * Whether to throw an error if used outside HydrationProvider. * If false, returns null-safe defaults when no provider is present. * * @default true */ readonly throwIfNoProvider?: boolean; } /** * Primary hook for accessing the hydration system. * * Provides access to global hydration controls, metrics, and configuration. * Must be used within a HydrationProvider unless `throwIfNoProvider` is false. * * @param options - Hook options * @returns Hydration system interface * @throws If used outside HydrationProvider and throwIfNoProvider is true * * @example * ```tsx * // Basic usage * function MyComponent() { * const { getMetrics, isPaused, pause, resume } = useHydration(); * * const metrics = getMetrics(); * console.log(`${metrics.hydratedCount} of ${metrics.totalBoundaries} hydrated`); * * return ( * * ); * } * * // Safe usage outside provider * function SafeComponent() { * const hydration = useHydration({ throwIfNoProvider: false }); * * // hydration will have null-safe defaults if no provider * return
Hydrated: {hydration.getMetrics().hydratedCount}
; * } * ``` */ export declare function useHydration(options?: UseHydrationOptions): UseHydrationReturn; /** * Hook to check if hydration context is available. * * Useful for conditional rendering based on hydration support. * * @returns true if within a HydrationProvider * * @example * ```tsx * function ConditionalFeature() { * const hasHydration = useHasHydrationContext(); * * if (!hasHydration) { * return ; * } * * return ; * } * ``` */ export declare function useHasHydrationContext(): boolean; export type { HydrationContextValue };