import type { TEvents } from '@mappedin/mappedin-js'; /** * # Event Management System * * The React Native SDK uses a sophisticated event management system that bridges events * between the WebView (where the actual map runs) and the React Native application. * * ## Architecture Overview * * The event system follows a hub-and-spoke pattern with these key principles: * * ### 1. Single WebView Subscription Per Event Type * - The WebView only maintains **one subscription** per event type (e.g., 'click', 'hover') * - This prevents duplicate event listeners and reduces overhead in the WebView * - Event subscription is managed via the bridge communication layer * * ### 2. Multiple React Native Callbacks Per Event * - Multiple React Native components can register callbacks for the same event type * - When the WebView event fires, React Native receives it via the bridge * - React Native then fires **all registered callbacks** for that event type * * ### 3. Extension Event Support * - The system also supports extension events with the pattern `extensionname:eventname` * - Extension events are handled the same way as regular events but with prefixed keys * - Examples: `'dynamic-focus:focus'`, `'hover-tooltip:show'` * * ## Event Flow * * ``` * ┌─────────────────┐ ┌──────────────────┐ ┌─────────────────────┐ * │ React Native │ │ Bridge │ │ WebView │ * │ Components │ │ Communication │ │ (Mappedin SDK) │ * └─────────────────┘ └──────────────────┘ └─────────────────────┘ * │ │ │ * │ useEvent('click', cb1)│ │ * ├──────────────────────>│ │ * │ │ │ * │ │ Subscribe to 'click' │ * │ ├─────────────────────-─>│ * │ │ │ * │ │ │ (Only once per * │ useEvent('click', cb2)│ │ event type) * ├──────────────────────>│ │ * │ │ │ * │ │ (No new subscription) │ * │ │ Click Event Fired │ * │ │<────────────────────-──┤ * │ cb1(eventData) │ │ * │<──────────────────────┤ │ * │ cb2(eventData) │ │ * │<──────────────────────┤ │ * ``` * @internal This module is used internally by the SDK */ /** * Supported event types - includes regular map events and extension events * @internal */ export type SupportedEvents = keyof TEvents | `${string}:${string}`; /** * Extract payload type for regular events * @internal */ export type TEventPayload = TEvents[EventName] extends { data: null; } ? TEvents[EventName]['data'] : TEvents[EventName]; /** * Unified event callback type that handles both regular events and extension events * @internal */ export type EventCallback = T extends keyof TEvents ? (payload: TEventPayload) => void : (payload: any) => void; /** * Creates an event control system for managing event callbacks. * This is used internally to manage event subscriptions and callbacks. * * @internal */ export declare function createEventControl(): { /** * Register a callback for a specific event type (regular or extension event) * @internal */ registerEventCallback(event: T, callback: EventCallback): void; /** * Unregister a callback for a specific event type (regular or extension event) * @internal */ unregisterEventCallback(event: T, callback: EventCallback): void; /** * Check if there are any callbacks registered for a specific event type (regular or extension event) * @internal */ hasEventCallbacks(event: T): boolean; /** * Trigger all callbacks for a specific event with the given payload (regular or extension event) * @internal */ handleEvent(event: T, payload: T extends keyof TEvents ? TEventPayload : any): void; /** * Destroy all event callbacks * @internal */ destroy(): void; }; export type EventControl = ReturnType; //# sourceMappingURL=event-control.d.ts.map