@blinkdotnew/sdk 2.3.4 → 2.3.5

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.
package/dist/index.d.mts CHANGED
@@ -3488,27 +3488,93 @@ declare class BlinkAIImpl implements BlinkAI {
3488
3488
  }
3489
3489
 
3490
3490
  /**
3491
- * Blink Realtime Module - Real-time messaging and presence
3492
- * Provides pub/sub messaging, presence tracking, and live updates
3491
+ * Blink Realtime Connection - Single WebSocket connection manager
3492
+ * Handles connection lifecycle, message routing, and reconnection for all channels
3493
3493
  */
3494
3494
 
3495
- declare class BlinkRealtimeChannel implements RealtimeChannel {
3496
- private channelName;
3495
+ interface ChannelHandler {
3496
+ onMessage: (message: any) => void;
3497
+ onPresence: (users: any[]) => void;
3498
+ onSubscribed: () => void;
3499
+ onError: (error: string) => void;
3500
+ }
3501
+ declare class RealtimeConnection {
3497
3502
  private httpClient;
3498
3503
  private projectId;
3499
- private messageCallbacks;
3500
- private presenceCallbacks;
3501
3504
  private websocket;
3502
- private isSubscribed;
3503
3505
  private isConnected;
3504
3506
  private isConnecting;
3505
3507
  private reconnectTimer;
3506
3508
  private heartbeatTimer;
3507
3509
  private reconnectAttempts;
3508
- private messageQueue;
3509
- private pendingSubscription;
3510
3510
  private connectionPromise;
3511
- constructor(channelName: string, httpClient: HttpClient, projectId: string);
3511
+ private channels;
3512
+ private pendingSubscriptions;
3513
+ private messageQueue;
3514
+ constructor(httpClient: HttpClient, projectId: string);
3515
+ /**
3516
+ * Check if connection is ready
3517
+ */
3518
+ isReady(): boolean;
3519
+ /**
3520
+ * Ensure WebSocket connection is established
3521
+ */
3522
+ connect(): Promise<void>;
3523
+ /**
3524
+ * Join a channel (subscribe)
3525
+ */
3526
+ joinChannel(channelName: string, handler: ChannelHandler, options?: {
3527
+ userId?: string;
3528
+ metadata?: Record<string, any>;
3529
+ }): Promise<void>;
3530
+ /**
3531
+ * Leave a channel (unsubscribe)
3532
+ */
3533
+ leaveChannel(channelName: string): Promise<void>;
3534
+ /**
3535
+ * Send a message to a channel
3536
+ */
3537
+ send(channelName: string, type: string, data: any, options?: {
3538
+ userId?: string;
3539
+ metadata?: Record<string, any>;
3540
+ }): Promise<string>;
3541
+ /**
3542
+ * Disconnect and cleanup
3543
+ */
3544
+ disconnect(): void;
3545
+ /**
3546
+ * Get count of active channels
3547
+ */
3548
+ getChannelCount(): number;
3549
+ private connectWebSocket;
3550
+ private handleMessage;
3551
+ private sendRaw;
3552
+ private sendWithResponse;
3553
+ private flushMessageQueue;
3554
+ private rejectQueuedMessages;
3555
+ private startHeartbeat;
3556
+ private scheduleReconnect;
3557
+ private resubscribeAllChannels;
3558
+ }
3559
+
3560
+ /**
3561
+ * Blink Realtime Module - Real-time messaging and presence
3562
+ * Provides pub/sub messaging, presence tracking, and live updates
3563
+ *
3564
+ * Architecture: Single WebSocket connection per client, multiplexed channels
3565
+ * (Industry standard - matches Supabase, Firebase, Pusher)
3566
+ */
3567
+
3568
+ declare class BlinkRealtimeChannel implements RealtimeChannel {
3569
+ private channelName;
3570
+ private connection;
3571
+ private httpClient;
3572
+ private projectId;
3573
+ private messageCallbacks;
3574
+ private presenceCallbacks;
3575
+ private isSubscribed;
3576
+ private subscribeOptions;
3577
+ constructor(channelName: string, connection: RealtimeConnection, httpClient: HttpClient, projectId: string);
3512
3578
  /**
3513
3579
  * Check if channel is ready for publishing
3514
3580
  */
@@ -3530,35 +3596,12 @@ declare class BlinkRealtimeChannel implements RealtimeChannel {
3530
3596
  before?: string;
3531
3597
  after?: string;
3532
3598
  }): Promise<RealtimeMessage[]>;
3533
- /**
3534
- * Ensure WebSocket connection is established and ready
3535
- */
3536
- private ensureConnected;
3537
- /**
3538
- * Send a message, queuing if socket not ready
3539
- */
3540
- private sendMessage;
3541
- /**
3542
- * Send a queued message and set up response handling
3543
- */
3544
- private sendQueuedMessage;
3545
- /**
3546
- * Flush all queued messages when connection becomes ready
3547
- */
3548
- private flushMessageQueue;
3549
- private connectWebSocket;
3550
- /**
3551
- * Reject all queued messages with the given error
3552
- */
3553
- private rejectQueuedMessages;
3554
- private handleWebSocketMessage;
3555
- private startHeartbeat;
3556
- private scheduleReconnect;
3557
3599
  private cleanup;
3558
3600
  }
3559
3601
  declare class BlinkRealtimeImpl implements BlinkRealtime {
3560
3602
  private httpClient;
3561
3603
  private projectId;
3604
+ private connection;
3562
3605
  private channels;
3563
3606
  private handlers;
3564
3607
  constructor(httpClient: HttpClient, projectId: string);
@@ -3567,6 +3610,14 @@ declare class BlinkRealtimeImpl implements BlinkRealtime {
3567
3610
  publish(channelName: string, type: string, data: any, options?: RealtimePublishOptions): Promise<string>;
3568
3611
  presence(channelName: string): Promise<PresenceUser[]>;
3569
3612
  onPresence(channelName: string, callback: (users: PresenceUser[]) => void): () => void;
3613
+ /**
3614
+ * Get the number of active WebSocket connections (should always be 0 or 1)
3615
+ */
3616
+ getConnectionCount(): number;
3617
+ /**
3618
+ * Get the number of active channels
3619
+ */
3620
+ getChannelCount(): number;
3570
3621
  }
3571
3622
 
3572
3623
  declare class BlinkConnectorsImpl implements BlinkConnectors {
package/dist/index.d.ts CHANGED
@@ -3488,27 +3488,93 @@ declare class BlinkAIImpl implements BlinkAI {
3488
3488
  }
3489
3489
 
3490
3490
  /**
3491
- * Blink Realtime Module - Real-time messaging and presence
3492
- * Provides pub/sub messaging, presence tracking, and live updates
3491
+ * Blink Realtime Connection - Single WebSocket connection manager
3492
+ * Handles connection lifecycle, message routing, and reconnection for all channels
3493
3493
  */
3494
3494
 
3495
- declare class BlinkRealtimeChannel implements RealtimeChannel {
3496
- private channelName;
3495
+ interface ChannelHandler {
3496
+ onMessage: (message: any) => void;
3497
+ onPresence: (users: any[]) => void;
3498
+ onSubscribed: () => void;
3499
+ onError: (error: string) => void;
3500
+ }
3501
+ declare class RealtimeConnection {
3497
3502
  private httpClient;
3498
3503
  private projectId;
3499
- private messageCallbacks;
3500
- private presenceCallbacks;
3501
3504
  private websocket;
3502
- private isSubscribed;
3503
3505
  private isConnected;
3504
3506
  private isConnecting;
3505
3507
  private reconnectTimer;
3506
3508
  private heartbeatTimer;
3507
3509
  private reconnectAttempts;
3508
- private messageQueue;
3509
- private pendingSubscription;
3510
3510
  private connectionPromise;
3511
- constructor(channelName: string, httpClient: HttpClient, projectId: string);
3511
+ private channels;
3512
+ private pendingSubscriptions;
3513
+ private messageQueue;
3514
+ constructor(httpClient: HttpClient, projectId: string);
3515
+ /**
3516
+ * Check if connection is ready
3517
+ */
3518
+ isReady(): boolean;
3519
+ /**
3520
+ * Ensure WebSocket connection is established
3521
+ */
3522
+ connect(): Promise<void>;
3523
+ /**
3524
+ * Join a channel (subscribe)
3525
+ */
3526
+ joinChannel(channelName: string, handler: ChannelHandler, options?: {
3527
+ userId?: string;
3528
+ metadata?: Record<string, any>;
3529
+ }): Promise<void>;
3530
+ /**
3531
+ * Leave a channel (unsubscribe)
3532
+ */
3533
+ leaveChannel(channelName: string): Promise<void>;
3534
+ /**
3535
+ * Send a message to a channel
3536
+ */
3537
+ send(channelName: string, type: string, data: any, options?: {
3538
+ userId?: string;
3539
+ metadata?: Record<string, any>;
3540
+ }): Promise<string>;
3541
+ /**
3542
+ * Disconnect and cleanup
3543
+ */
3544
+ disconnect(): void;
3545
+ /**
3546
+ * Get count of active channels
3547
+ */
3548
+ getChannelCount(): number;
3549
+ private connectWebSocket;
3550
+ private handleMessage;
3551
+ private sendRaw;
3552
+ private sendWithResponse;
3553
+ private flushMessageQueue;
3554
+ private rejectQueuedMessages;
3555
+ private startHeartbeat;
3556
+ private scheduleReconnect;
3557
+ private resubscribeAllChannels;
3558
+ }
3559
+
3560
+ /**
3561
+ * Blink Realtime Module - Real-time messaging and presence
3562
+ * Provides pub/sub messaging, presence tracking, and live updates
3563
+ *
3564
+ * Architecture: Single WebSocket connection per client, multiplexed channels
3565
+ * (Industry standard - matches Supabase, Firebase, Pusher)
3566
+ */
3567
+
3568
+ declare class BlinkRealtimeChannel implements RealtimeChannel {
3569
+ private channelName;
3570
+ private connection;
3571
+ private httpClient;
3572
+ private projectId;
3573
+ private messageCallbacks;
3574
+ private presenceCallbacks;
3575
+ private isSubscribed;
3576
+ private subscribeOptions;
3577
+ constructor(channelName: string, connection: RealtimeConnection, httpClient: HttpClient, projectId: string);
3512
3578
  /**
3513
3579
  * Check if channel is ready for publishing
3514
3580
  */
@@ -3530,35 +3596,12 @@ declare class BlinkRealtimeChannel implements RealtimeChannel {
3530
3596
  before?: string;
3531
3597
  after?: string;
3532
3598
  }): Promise<RealtimeMessage[]>;
3533
- /**
3534
- * Ensure WebSocket connection is established and ready
3535
- */
3536
- private ensureConnected;
3537
- /**
3538
- * Send a message, queuing if socket not ready
3539
- */
3540
- private sendMessage;
3541
- /**
3542
- * Send a queued message and set up response handling
3543
- */
3544
- private sendQueuedMessage;
3545
- /**
3546
- * Flush all queued messages when connection becomes ready
3547
- */
3548
- private flushMessageQueue;
3549
- private connectWebSocket;
3550
- /**
3551
- * Reject all queued messages with the given error
3552
- */
3553
- private rejectQueuedMessages;
3554
- private handleWebSocketMessage;
3555
- private startHeartbeat;
3556
- private scheduleReconnect;
3557
3599
  private cleanup;
3558
3600
  }
3559
3601
  declare class BlinkRealtimeImpl implements BlinkRealtime {
3560
3602
  private httpClient;
3561
3603
  private projectId;
3604
+ private connection;
3562
3605
  private channels;
3563
3606
  private handlers;
3564
3607
  constructor(httpClient: HttpClient, projectId: string);
@@ -3567,6 +3610,14 @@ declare class BlinkRealtimeImpl implements BlinkRealtime {
3567
3610
  publish(channelName: string, type: string, data: any, options?: RealtimePublishOptions): Promise<string>;
3568
3611
  presence(channelName: string): Promise<PresenceUser[]>;
3569
3612
  onPresence(channelName: string, callback: (users: PresenceUser[]) => void): () => void;
3613
+ /**
3614
+ * Get the number of active WebSocket connections (should always be 0 or 1)
3615
+ */
3616
+ getConnectionCount(): number;
3617
+ /**
3618
+ * Get the number of active channels
3619
+ */
3620
+ getChannelCount(): number;
3570
3621
  }
3571
3622
 
3572
3623
  declare class BlinkConnectorsImpl implements BlinkConnectors {