|
1 | | -declare const _default: ViroEventsManager; |
2 | | -export default _default; |
| 1 | +/** |
| 2 | + * ViroEventsManager.ts |
| 3 | + * TypeScript integration for ViroEventsTurboModule |
| 4 | + * |
| 5 | + * This module provides the TypeScript interface for handling |
| 6 | + * Viro JSI events through the TurboModule system |
| 7 | + */ |
| 8 | +interface EventData { |
| 9 | + [key: string]: any; |
| 10 | +} |
| 11 | +type EventCallback = (data: EventData) => void; |
| 12 | +type JSICallback = (data?: EventData) => void; |
3 | 13 | declare class ViroEventsManager { |
4 | | - eventEmitter: NativeEventEmitter; |
5 | | - listeners: Map<any, any>; |
6 | | - callbackRegistry: Map<any, any>; |
7 | | - setupEventListeners(): void; |
| 14 | + private eventEmitter; |
| 15 | + private listeners; |
| 16 | + private callbackRegistry; |
| 17 | + constructor(); |
| 18 | + private setupEventListeners; |
8 | 19 | /** |
9 | 20 | * Register a callback for JSI events |
10 | | - * @param {string} callbackId - The callback ID from JSI |
11 | | - * @param {function} callback - The JavaScript callback function |
| 21 | + * @param callbackId - The callback ID from JSI |
| 22 | + * @param callback - The JavaScript callback function |
12 | 23 | */ |
13 | | - registerJSICallback(callbackId: string, callback: Function): void; |
| 24 | + registerJSICallback(callbackId: string, callback: JSICallback): void; |
14 | 25 | /** |
15 | 26 | * Unregister a JSI callback |
16 | | - * @param {string} callbackId - The callback ID to remove |
| 27 | + * @param callbackId - The callback ID to unregister |
17 | 28 | */ |
18 | 29 | unregisterJSICallback(callbackId: string): void; |
19 | 30 | /** |
20 | | - * Register a listener for node events |
21 | | - * @param {string} nodeId - The node ID |
22 | | - * @param {string} eventName - The event name |
23 | | - * @param {function} callback - The callback function |
| 31 | + * Handle incoming JSI callbacks |
| 32 | + * @param event - The callback event |
24 | 33 | */ |
25 | | - registerNodeEventListener(nodeId: string, eventName: string, callback: Function): void; |
| 34 | + private handleJSICallback; |
26 | 35 | /** |
27 | | - * Register a listener for scene events |
28 | | - * @param {string} sceneId - The scene ID |
29 | | - * @param {string} eventName - The event name |
30 | | - * @param {function} callback - The callback function |
| 36 | + * Register an event listener for a specific node |
| 37 | + * @param nodeId - The node ID |
| 38 | + * @param eventName - The event name |
| 39 | + * @param callback - The callback function |
| 40 | + * @returns The listener key for removal |
31 | 41 | */ |
32 | | - registerSceneEventListener(sceneId: string, eventName: string, callback: Function): void; |
| 42 | + registerNodeEventListener(nodeId: string, eventName: string, callback: EventCallback): string; |
33 | 43 | /** |
34 | | - * Handle JSI callback events |
35 | | - * @private |
| 44 | + * Unregister a node event listener |
| 45 | + * @param listenerKey - The listener key returned from registration |
36 | 46 | */ |
37 | | - private handleJSICallback; |
| 47 | + unregisterNodeEventListener(listenerKey: string): void; |
38 | 48 | /** |
39 | | - * Handle node events |
40 | | - * @private |
| 49 | + * Handle incoming node events |
| 50 | + * @param event - The node event |
41 | 51 | */ |
42 | 52 | private handleNodeEvent; |
43 | 53 | /** |
44 | | - * Handle scene events |
45 | | - * @private |
| 54 | + * Register an event listener for a specific scene |
| 55 | + * @param sceneId - The scene ID |
| 56 | + * @param eventName - The event name |
| 57 | + * @param callback - The callback function |
| 58 | + * @returns The listener key for removal |
46 | 59 | */ |
47 | | - private handleSceneEvent; |
| 60 | + registerSceneEventListener(sceneId: string, eventName: string, callback: EventCallback): string; |
48 | 61 | /** |
49 | | - * Check if the event system is ready |
50 | | - * @returns {boolean} |
| 62 | + * Unregister a scene event listener |
| 63 | + * @param listenerKey - The listener key returned from registration |
51 | 64 | */ |
52 | | - isEventSystemReady(): boolean; |
| 65 | + unregisterSceneEventListener(listenerKey: string): void; |
| 66 | + /** |
| 67 | + * Handle incoming scene events |
| 68 | + * @param event - The scene event |
| 69 | + */ |
| 70 | + private handleSceneEvent; |
53 | 71 | /** |
54 | 72 | * Get the number of active listeners |
55 | | - * @returns {number} |
| 73 | + * @returns The count of active listeners |
56 | 74 | */ |
57 | 75 | getActiveListenerCount(): number; |
58 | 76 | /** |
59 | 77 | * Manually emit a JSI callback (for testing) |
60 | | - * @param {string} callbackId - The callback ID |
61 | | - * @param {object} eventData - The event data |
| 78 | + * @param callbackId - The callback ID |
| 79 | + * @param eventData - The event data |
62 | 80 | */ |
63 | | - emitJSICallback(callbackId: string, eventData?: object): void; |
| 81 | + emitJSICallback(callbackId: string, eventData?: EventData): void; |
64 | 82 | /** |
65 | 83 | * Manually emit a node event (for testing) |
66 | | - * @param {string} nodeId - The node ID |
67 | | - * @param {string} eventName - The event name |
68 | | - * @param {object} eventData - The event data |
| 84 | + * @param nodeId - The node ID |
| 85 | + * @param eventName - The event name |
| 86 | + * @param eventData - The event data |
69 | 87 | */ |
70 | | - emitNodeEvent(nodeId: string, eventName: string, eventData?: object): void; |
| 88 | + emitNodeEvent(nodeId: string, eventName: string, eventData?: EventData): void; |
71 | 89 | /** |
72 | 90 | * Manually emit a scene event (for testing) |
73 | | - * @param {string} sceneId - The scene ID |
74 | | - * @param {string} eventName - The event name |
75 | | - * @param {object} eventData - The event data |
| 91 | + * @param sceneId - The scene ID |
| 92 | + * @param eventName - The event name |
| 93 | + * @param eventData - The event data |
76 | 94 | */ |
77 | | - emitSceneEvent(sceneId: string, eventName: string, eventData?: object): void; |
| 95 | + emitSceneEvent(sceneId: string, eventName: string, eventData?: EventData): void; |
78 | 96 | /** |
79 | 97 | * Clean up all listeners and callbacks |
80 | 98 | */ |
81 | 99 | cleanup(): void; |
82 | 100 | } |
83 | | -import { NativeEventEmitter } from "react-native"; |
| 101 | +declare const _default: ViroEventsManager; |
| 102 | +export default _default; |
0 commit comments