uneeq-js 3.6.4 → 3.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,263 @@
1
+ import { Subject } from 'rxjs';
2
+ /**
3
+ * Enum representing all possible connection states
4
+ */
5
+ export declare enum ConnectionState {
6
+ /** No connection initiated */
7
+ Idle = "Idle",
8
+ /** Initial connection attempt in progress */
9
+ Connecting = "Connecting",
10
+ /** Video stream has been initialized */
11
+ VideoInitializing = "VideoInitializing",
12
+ /** Connection fully established and ready for interaction */
13
+ Connected = "Connected",
14
+ /** Attempting to reconnect after unexpected disconnection (hard switch) */
15
+ Reconnecting = "Reconnecting",
16
+ /** Planned renderer replacement in progress (soft switch) */
17
+ SoftSwitching = "SoftSwitching",
18
+ /** Connection failed permanently */
19
+ Failed = "Failed",
20
+ /** Connection intentionally closed */
21
+ Disconnected = "Disconnected"
22
+ }
23
+ /**
24
+ * Represents readiness flags that must all be true before connection is considered ready
25
+ */
26
+ export interface ReadinessFlags {
27
+ videoInitialized: boolean;
28
+ dataChannelOpen: boolean;
29
+ sceneReady: boolean;
30
+ }
31
+ /**
32
+ * Represents a pending switch request
33
+ */
34
+ export interface PendingSwitchRequest {
35
+ type: 'soft' | 'hard';
36
+ reason: string;
37
+ requestedAt: number;
38
+ }
39
+ /**
40
+ * Context information for the current state
41
+ */
42
+ export interface StateContext {
43
+ /** Current readiness flags */
44
+ readiness: ReadinessFlags;
45
+ /** Number of reconnection attempts made (0-based) */
46
+ reconnectionAttempts: number;
47
+ /** Maximum allowed reconnection attempts */
48
+ maxReconnectionAttempts: number;
49
+ /** Whether reconnection is allowed */
50
+ allowReconnection: boolean;
51
+ /** Current switch request information */
52
+ switchContext?: {
53
+ /** Type of switch: 'soft' (planned) or 'hard' (unexpected) */
54
+ type: 'soft' | 'hard';
55
+ /** ID of the new signaling instance */
56
+ newSignalingId: string;
57
+ /** ID of the old signaling instance */
58
+ oldSignalingId?: string;
59
+ /** Timestamp when switch started */
60
+ startedAt: number;
61
+ };
62
+ /** Queue of pending switch requests */
63
+ pendingSwitchRequests: PendingSwitchRequest[];
64
+ /** Error message if in Failed state */
65
+ errorMessage?: string;
66
+ /** Timestamp of last state change */
67
+ lastStateChange: number;
68
+ /** History of state transitions for debugging */
69
+ stateHistory: Array<{
70
+ from: ConnectionState;
71
+ to: ConnectionState;
72
+ timestamp: number;
73
+ reason?: string;
74
+ }>;
75
+ }
76
+ /**
77
+ * Represents a state change event
78
+ */
79
+ export interface ConnectionStateChange {
80
+ from: ConnectionState;
81
+ to: ConnectionState;
82
+ timestamp: number;
83
+ reason?: string;
84
+ context: StateContext;
85
+ }
86
+ /**
87
+ * Manages connection state machine for renderer connections
88
+ * Handles soft switching, hard switching (reconnection), and queuing of multiple switch requests
89
+ */
90
+ export declare class ConnectionStateManager {
91
+ private currentState;
92
+ private context;
93
+ /** Observable stream of state changes */
94
+ readonly stateChanges: Subject<ConnectionStateChange>;
95
+ /** Observable stream of pending switch requests that need to be processed */
96
+ readonly pendingRequestsToProcess: Subject<PendingSwitchRequest>;
97
+ /** Timeout in milliseconds for switch operations (30 seconds) */
98
+ private readonly switchTimeoutMs;
99
+ /** Handle for the current timeout timer */
100
+ private timeoutHandle?;
101
+ /** Stability window in milliseconds before resetting reconnection counter (3 seconds) */
102
+ private readonly reconnectionStabilityWindowMs;
103
+ /** Handle for the reconnection stability timer */
104
+ private stabilityTimerHandle?;
105
+ /**
106
+ * @param maxReconnectionAttempts Maximum number of reconnection attempts allowed (default: 3)
107
+ */
108
+ constructor(maxReconnectionAttempts?: number);
109
+ /**
110
+ * Get the current state
111
+ */
112
+ getState(): ConnectionState;
113
+ /**
114
+ * Get the full state context
115
+ */
116
+ getContext(): Readonly<StateContext>;
117
+ /**
118
+ * Check if currently in a specific state
119
+ */
120
+ isInState(state: ConnectionState): boolean;
121
+ /**
122
+ * Check if all readiness flags are true
123
+ */
124
+ isFullyReady(): boolean;
125
+ /**
126
+ * Check if connection is in an interactive state (can send messages)
127
+ */
128
+ isInteractive(): boolean;
129
+ /**
130
+ * Check if currently switching (soft or hard)
131
+ */
132
+ isSwitching(): boolean;
133
+ /**
134
+ * Check the type of switching in progress
135
+ */
136
+ isSwitchingType(type: 'soft' | 'hard'): boolean;
137
+ /**
138
+ * Get the current reconnection attempt number (1-based for logging)
139
+ */
140
+ getReconnectionAttempt(): number;
141
+ /**
142
+ * Check if reconnection is allowed
143
+ */
144
+ canReconnect(): boolean;
145
+ /**
146
+ * Get a human-readable summary of the current state
147
+ */
148
+ getStateSummary(): string;
149
+ /**
150
+ * Start a new connection
151
+ */
152
+ startConnection(): void;
153
+ /**
154
+ * Set video initialized flag
155
+ */
156
+ setVideoInitialized(initialized: boolean): void;
157
+ /**
158
+ * Set data channel open flag
159
+ */
160
+ setDataChannelOpen(open: boolean): void;
161
+ /**
162
+ * Set scene ready flag
163
+ */
164
+ setSceneReady(ready: boolean): void;
165
+ /**
166
+ * Start a soft switch (planned renderer replacement)
167
+ * @param newSignalingId ID of the new signaling instance
168
+ * @param oldSignalingId ID of the old signaling instance (optional)
169
+ * @returns true if switch started, false if already switching
170
+ */
171
+ startSoftSwitch(newSignalingId: string, oldSignalingId?: string): boolean;
172
+ /**
173
+ * Start reconnection after unexpected disconnection (hard switch)
174
+ * @param reason Reason for reconnection
175
+ * @returns true if reconnection started, false if not allowed
176
+ */
177
+ startReconnection(reason: string): boolean;
178
+ /**
179
+ * Mark reconnection as succeeded
180
+ * NOTE: The reconnection attempt counter will only be reset after the stability window passes
181
+ * This prevents infinite loops when the connection repeatedly succeeds then immediately fails
182
+ */
183
+ reconnectionSucceeded(): void;
184
+ /**
185
+ * Mark reconnection as failed
186
+ * @param reason Reason for failure (optional)
187
+ */
188
+ reconnectionFailed(reason?: string): void;
189
+ /**
190
+ * Complete the current switching operation
191
+ */
192
+ completeSwitching(): void;
193
+ /**
194
+ * Disconnect the session
195
+ * @param reason Reason for disconnection
196
+ */
197
+ disconnect(reason: string): void;
198
+ /**
199
+ * Mark the connection as failed
200
+ * @param reason Reason for failure
201
+ */
202
+ fail(reason: string): void;
203
+ /**
204
+ * Handle a generic error
205
+ * @param reason Error message
206
+ */
207
+ error(reason: string): void;
208
+ /**
209
+ * Reset all readiness flags to false
210
+ */
211
+ private resetReadinessFlags;
212
+ /**
213
+ * Check if all readiness flags are true and transition to Connected if appropriate
214
+ */
215
+ private checkFullyReady;
216
+ /**
217
+ * Transition to a new state
218
+ * @param newState The target state
219
+ * @param reason Reason for transition (optional)
220
+ */
221
+ private transition;
222
+ /**
223
+ * Check if a state transition is valid
224
+ */
225
+ private isValidTransition;
226
+ /**
227
+ * Start a timeout for the current switch operation
228
+ */
229
+ private startSwitchTimeout;
230
+ /**
231
+ * Cancel the current switch timeout
232
+ */
233
+ private cancelSwitchTimeout;
234
+ /**
235
+ * Start the reconnection stability timer
236
+ * Only resets the reconnection attempt counter after the connection has been stable
237
+ * for the configured duration. This prevents infinite loops when connections
238
+ * repeatedly succeed then immediately fail.
239
+ */
240
+ private startReconnectionStabilityTimer;
241
+ /**
242
+ * Cancel the reconnection stability timer
243
+ * Called when the connection fails before the stability window completes
244
+ */
245
+ private cancelReconnectionStabilityTimer;
246
+ /**
247
+ * Process any pending switch requests
248
+ */
249
+ private processPendingSwitchRequests;
250
+ /**
251
+ * Clear all pending switch requests (useful when disconnecting)
252
+ */
253
+ clearPendingSwitchRequests(): void;
254
+ /**
255
+ * Get the state history for debugging
256
+ */
257
+ getStateHistory(): ReadonlyArray<{
258
+ from: ConnectionState;
259
+ to: ConnectionState;
260
+ timestamp: number;
261
+ reason?: string;
262
+ }>;
263
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -37,7 +37,6 @@ export declare class DeepgramSTT {
37
37
  private reconnectAttempts;
38
38
  private reconnectDelay;
39
39
  private reconnectTimeoutId;
40
- private wasActiveBeforeReconnect;
41
40
  private digitalHumanSpeaking;
42
41
  private isUserCurrentlySpeaking;
43
42
  private isUiShowingSpeaking;