UNPKG

@memberjunction/ng-react

Version:

Angular components for hosting React components in MemberJunction applications

77 lines (76 loc) 2.58 kB
/** * @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<boolean>; private firstComponentAttempted; private maxWaitTime; private checkInterval; constructor(adapter: AngularAdapterService); ngOnDestroy(): void; /** * Bootstrap React early during service initialization */ private bootstrapReact; /** * Wait for React to be ready, with special handling for first component */ waitForReactReady(): Promise<void>; /** * Get the current React context if loaded * @returns React context with React, ReactDOM, Babel, and libraries */ getReactContext(): Promise<RuntimeContext>; /** * 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<ReactBridgeService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<ReactBridgeService>; }