/** * Registration state for extension registration lifecycle */ export type RegistrationState = 'unregistered' | 'registering' | 'registered'; /** * Creates a registration control system to prevent race conditions between multiple hook instances. * Uses closure to encapsulate state and provide controlled access. * * CRITICAL: Must use module-level closure approach for race prevention. Context-based coordination * fails because React context updates are async/batched, creating race windows where multiple * components can read identical state and all proceed with registration simultaneously. * Only synchronous, module-level state can provide atomic coordination across component instances. * * @param extensionName - The name of the extension being registered * @returns Registration control interface with methods to manage concurrent registrations */ declare function createRegistrationControl(): { /** * Checks if a registration is currently in progress * @returns True if registration is active, false otherwise */ isCurrentlyRegistering(): boolean; /** * Starts a registration process, ensuring only one can run at a time * @param registrationFn - The async function to execute for registration * @returns Promise that resolves when registration completes */ startRegistration(registrationFn: () => Promise): Promise; /** * Resets the registration state (useful when bridge becomes unavailable) */ reset(): void; }; /** * Gets or creates a registration control for a specific extension * @param extensionName - The name of the extension * @returns Registration control instance for the extension */ declare function getRegistrationControl(extensionName: string): ReturnType; export { createRegistrationControl, getRegistrationControl }; /** * Configuration for the extension registration hook */ export interface UseRegisterExtensionConfig { /** * The name of the extension to register (e.g., 'blue-dot', 'dynamic-focus') */ extensionName: string; /** * Function that returns the registration script for the extension */ getRegistrationScript: () => string; /** * Optional logger for debugging */ logger?: { log: (...messages: string[]) => void; error: (message: string, error?: unknown) => void; }; } /** * React hook for registering extensions with the WebView bridge * * This hook handles the complete extension registration lifecycle: * - Monitors bridge readiness state * - Checks if extension is already registered to avoid duplicates * - Injects registration script when needed * - Updates extension state in shared context * - Handles all registration errors gracefully * * Multiple hooks can use this safely - the registration logic is idempotent * and will only register the extension once per bridge lifecycle. * * @param config - Configuration for the extension registration * @returns void - Hook performs registration as side effect only * * @example * ```tsx * function MyExtensionHook() { * useRegisterExtension({ * extensionName: 'my-extension', * getRegistrationScript: () => 'extension script here' * }); * * // Read isReady from context extensions * const { extensions } = useContext(MappedinContext); * const isReady = extensions?.['my-extension']?.isReady || false; * } * ``` */ export declare function useRegisterExtension(config: UseRegisterExtensionConfig): void; //# sourceMappingURL=use-register-extension.d.ts.map