import { ComponentType } from 'react'; import { VirtualNode, VNodeProps, VNodeCreateOptions, VDOMPoolConfig, VDOMPoolStats, ModuleId, VNodeType, HydrationState } from './types'; /** * Memory-efficient virtual node pool with automatic garbage collection. * Implements the Object Pool pattern for optimal performance. * * @example * ```typescript * const pool = new VDOMPool({ initialSize: 100, maxSize: 1000 }); * * // Acquire a node * const node = pool.acquire({ * type: VNodeType.ELEMENT, * tag: 'div', * props: { className: 'container' }, * }); * * // Use the node... * * // Release back to pool * pool.release(node); * ``` */ export declare class VDOMPool { /** Pool configuration */ private readonly config; /** Available (free) nodes */ private readonly freeNodes; /** In-use nodes (weak reference to allow GC) */ private readonly inUseNodes; /** All nodes in pool (for GC) */ private readonly allNodes; /** Current pool generation (increments on GC) */ private generation; /** Statistics tracking */ private stats; /** Memory pressure detector */ private readonly memoryDetector; /** GC interval handle */ private gcIntervalId; /** Whether pool is disposed */ private isDisposed; /** * Creates a new VDOM Pool. * @param config - Pool configuration (partial) */ constructor(config?: Partial); /** * Checks if pool is disposed. */ get disposed(): boolean; /** * Gets the current generation number. */ get currentGeneration(): number; /** * Acquires a virtual node from the pool. * @param options - Node creation options * @returns Virtual node instance */ acquire(options?: { type?: VNodeType; tag?: string | ComponentType; props?: VNodeProps; children?: (VirtualNode | string)[]; moduleId?: ModuleId; hydrationState?: HydrationState; }): VirtualNode; /** * Releases a virtual node back to the pool. * @param node - Node to release */ release(node: VirtualNode): void; /** * Releases multiple nodes at once. * @param nodes - Nodes to release */ releaseMany(nodes: VirtualNode[]): void; /** * Forces garbage collection of old nodes. */ gc(): void; /** * Gets current pool statistics. * @returns Pool statistics */ getStats(): VDOMPoolStats; /** * Clears all nodes from the pool. */ clear(): void; /** * Disposes the pool and releases all resources. */ dispose(): void; /** * Creates an element node. * @param tag - HTML tag name * @param props - Node properties * @param children - Child nodes * @param options - Additional options * @returns Element virtual node */ createElement(tag: string, props?: VNodeProps, children?: (VirtualNode | string)[], options?: VNodeCreateOptions): VirtualNode; /** * Creates a text node. * @param text - Text content * @param options - Additional options * @returns Text virtual node */ createText(text: string, options?: VNodeCreateOptions): VirtualNode; /** * Creates a fragment node. * @param children - Child nodes * @param options - Additional options * @returns Fragment virtual node */ createFragment(children?: (VirtualNode | string)[], options?: VNodeCreateOptions): VirtualNode; /** * Creates a component node. * @param component - React component * @param props - Component props * @param children - Child nodes * @param options - Additional options * @returns Component virtual node */ createComponent(component: ComponentType, props?: VNodeProps, children?: (VirtualNode | string)[], options?: VNodeCreateOptions): VirtualNode; /** * Creates a module boundary node. * @param moduleId - Module ID * @param children - Child nodes * @param options - Additional options * @returns Module boundary virtual node */ createModuleBoundary(moduleId: ModuleId, children?: (VirtualNode | string)[], options?: Omit): VirtualNode; /** * Clones a virtual node tree. * @param node - Node to clone * @param deep - Whether to clone children * @returns Cloned node */ clone(node: VirtualNode, deep?: boolean): VirtualNode; /** * Appends a child to a node. * @param parent - Parent node * @param child - Child to append */ appendChild(parent: VirtualNode, child: VirtualNode | string): void; /** * Removes a child from a node. * @param parent - Parent node * @param child - Child to remove */ removeChild(parent: VirtualNode, child: VirtualNode): void; /** * Replaces a child node. * @param parent - Parent node * @param oldChild - Child to replace * @param newChild - New child */ replaceChild(parent: VirtualNode, oldChild: VirtualNode, newChild: VirtualNode | string): void; /** * Expands the pool by creating new nodes. * @param count - Number of nodes to create */ private expand; /** * Expands the pool if needed. */ private maybeExpand; /** * Recalculates pool statistics. */ private recalculateStats; /** * Updates specific stats. * @param updates - Partial stats to update */ private updateStats; /** * Starts the GC interval. */ private startGCInterval; /** * Stops the GC interval. */ private stopGCInterval; } /** * Gets the default global VDOM pool. * @returns Default VDOMPool instance */ export declare function getDefaultPool(): VDOMPool; /** * Sets the default global VDOM pool. * @param pool - Pool to set as default */ export declare function setDefaultPool(pool: VDOMPool): void; /** * Resets the default global VDOM pool. */ export declare function resetDefaultPool(): void; /** * Creates a new VDOM pool with custom configuration. * @param config - Pool configuration * @returns New VDOMPool instance * * @example * ```typescript * const pool = createVDOMPool({ * initialSize: 200, * maxSize: 5000, * gcIntervalMs: 15000, * }); * ``` */ export declare function createVDOMPool(config?: Partial): VDOMPool; /** * Acquires a node from the default pool. * @param options - Node options * @returns Virtual node */ export declare function acquireNode(options?: Parameters[0]): VirtualNode; /** * Releases a node to the default pool. * @param node - Node to release */ export declare function releaseNode(node: VirtualNode): void;