/** * Hydration Strategies System * Load scopes smartly to improve initial page load performance * * Strategies: * - 'idle': Load when browser is idle (requestIdleCallback) * - 'visible': Load when scrolled into viewport (IntersectionObserver) * - 'interaction': Load on user interaction (mouseenter, touchstart, focus) * - 'media(query)': Load based on media query match * * @example * // Lazy load on scroll *
...
* * @example * // Load on interaction *
...
* * @example * // Load on mobile only *
...
*/ import { HydrationStrategy } from "../types"; /** * Hydration manager - Singleton class managing scope hydration */ declare class HydrationManager { private observers; private intersectionObserver?; private pending; /** * Setup hydration for element based on strategy * * @param el - Element to hydrate * @param strategy - Hydration strategy ('idle', 'visible', 'interaction', or 'media(query)') * @param callback - Function to call when hydration should occur * * @example * hydrationManager.setup(el, 'visible', () => { * mountScope(el); * }); */ setup(el: HTMLElement, strategy: HydrationStrategy, callback: () => void): void; /** * Hydrate when browser is idle (uses requestIdleCallback) * Falls back to setTimeout if requestIdleCallback not available * * @param callback - Function to call when browser is idle */ private hydrateOnIdle; /** * Hydrate when element becomes visible in viewport * Uses IntersectionObserver with 50px rootMargin for preloading * * @param el - Element to observe * @param callback - Function to call when element becomes visible */ private hydrateOnVisible; /** * Hydrate on user interaction (mouseenter, touchstart, or focus) * Automatically removes listeners after first interaction * * @param el - Element to attach interaction listeners to * @param callback - Function to call on first interaction */ private hydrateOnInteraction; /** * Hydrate based on media query match * Hydrates immediately if query matches, otherwise waits for match * * @param mediaQuery - CSS media query string (e.g., "(max-width: 768px)") * @param callback - Function to call when media query matches */ private hydrateOnMedia; private trackCleanup; /** * Cleanup observers for element (called on unmount) * * @param el - Element to cleanup */ cleanup(el: HTMLElement): void; } export declare const hydrationManager: HydrationManager; /** * Get hydration strategy from element's g-hydrate attribute * * @param el - Element to check * @returns Hydration strategy or null if not set * * @example *
...
* getHydrationStrategy(el) // Returns 'visible' */ export declare function getHydrationStrategy(el: HTMLElement): HydrationStrategy | null; export {}; //# sourceMappingURL=hydration.d.ts.map