/** * @fileoverview Service to manage React and ReactDOM instances with proper lifecycle. * Bridges Angular components with React rendering capabilities. * @module @memberjunction/ng-react */ import { OnDestroy } from '@angular/core'; import { AngularAdapterService } from './angular-adapter.service'; import { RuntimeContext } from '@memberjunction/react-runtime'; import * as i0 from "@angular/core"; /** * Service to manage React and ReactDOM instances with proper lifecycle. * Provides methods for creating and managing React roots in Angular applications. */ export declare class ReactBridgeService implements OnDestroy { private adapter; private reactRoots; private reactReadySubject; reactReady$: import("rxjs").Observable; private firstComponentAttempted; private maxWaitTime; private checkInterval; private maxBootstrapRetries; private retryBaseDelay; debug: boolean; private bootstrapPromise; constructor(adapter: AngularAdapterService); ngOnDestroy(): void; /** * Bootstrap React from CDN with automatic retries. * Deduplicates: concurrent callers share the same in-flight promise. * On failure, clears the promise so the next call can retry. */ private bootstrapWithRetries; /** * Attempt to load the React ecosystem from CDN, retrying with exponential * backoff if the CDN is unreachable or returns an error. */ private doBootstrapWithRetries; /** * Wait for React to be ready, with special handling for first component. * If bootstrap succeeded but createRoot isn't usable (stale browser cache), * forces a re-bootstrap and retries. */ waitForReactReady(): Promise; /** * Poll for ReactDOM.createRoot availability. If the poll window expires * (bootstrap succeeded but createRoot is broken, e.g. stale cache), * force a fresh re-bootstrap and retry. */ private pollForReactReadyWithRetries; /** * Poll for ReactDOM.createRoot for up to maxWaitTime ms. * @returns true if createRoot became available, false if the poll window expired. */ private pollForCreateRoot; /** * Get the current React context if loaded. * Awaits the bootstrap (with retries) rather than calling adapter.initialize() independently. * @returns React context with React, ReactDOM, Babel, and libraries */ getReactContext(): Promise; /** * Get the current React context synchronously * @returns React context or null if not loaded */ getCurrentContext(): RuntimeContext | null; /** * Create a React root for rendering * @param container - DOM element to render into * @returns React root instance */ createRoot(container: HTMLElement): any; /** * Unmount and clean up a React root * @param root - React root to unmount */ unmountRoot(root: any): void; /** * Transpile JSX code to JavaScript * @param code - JSX code to transpile * @param filename - Optional filename for error messages * @returns Transpiled JavaScript code */ transpileJSX(code: string, filename: string): string; /** * Clean up all React roots and reset context */ private cleanup; /** * Check if React is currently ready * @returns true if React is ready */ isReady(): boolean; /** * Get the number of active React roots * @returns Number of active roots */ getActiveRootsCount(): number; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; }