@blinkdotnew/sdk 0.5.0 → 0.6.0

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/README.md CHANGED
@@ -64,6 +64,16 @@ const response = await blink.data.fetch({
64
64
  body: { /* email data */ }
65
65
  })
66
66
 
67
+ // Realtime operations (live messaging and presence)
68
+ const unsubscribe = await blink.realtime.subscribe('chat-room', (message) => {
69
+ console.log('New message:', message.data)
70
+ })
71
+
72
+ await blink.realtime.publish('chat-room', 'message', { text: 'Hello world!' })
73
+
74
+ const users = await blink.realtime.presence('chat-room')
75
+ console.log('Online users:', users.length)
76
+
67
77
  // Storage operations (instant - returns public URL directly)
68
78
  const { publicUrl } = await blink.storage.upload(
69
79
  file,
@@ -90,6 +100,7 @@ This SDK powers every Blink-generated app with:
90
100
  - **🤖 AI**: Text generation with web search, object generation, image creation, speech synthesis, and transcription
91
101
  - **📄 Data**: Extract text content from documents, secure API proxy with secret substitution, web scraping, screenshots, and web search
92
102
  - **📁 Storage**: File upload, download, and management
103
+ - **⚡ Realtime**: WebSocket-based pub/sub messaging, presence tracking, and live updates
93
104
  - **🌐 Universal**: Works on client-side and server-side
94
105
  - **📱 Framework Agnostic**: React, Vue, Svelte, vanilla JS, Node.js, Deno
95
106
  - **🔄 Real-time**: Built-in auth state management and token refresh
@@ -481,12 +492,150 @@ const { publicUrl } = await blink.storage.upload(
481
492
  await blink.storage.remove('file1.jpg', 'file2.jpg')
482
493
  ```
483
494
 
495
+ ### Realtime Operations
496
+
497
+ ```typescript
498
+ // 🔥 Real-time Messaging & Presence (NEW!)
499
+ // Perfect for chat apps, live collaboration, multiplayer games, and live updates
500
+
501
+ // Simple subscribe and publish (most common pattern)
502
+ const unsubscribe = await blink.realtime.subscribe('chat-room', (message) => {
503
+ console.log('New message:', message.data)
504
+ console.log('From user:', message.userId)
505
+ console.log('Message type:', message.type)
506
+ })
507
+
508
+ // Publish a message to all subscribers
509
+ const messageId = await blink.realtime.publish('chat-room', 'message', {
510
+ text: 'Hello everyone!',
511
+ timestamp: Date.now()
512
+ })
513
+
514
+ // Advanced channel usage with presence tracking
515
+ const channel = blink.realtime.channel('game-lobby')
516
+
517
+ // Subscribe with user metadata
518
+ await channel.subscribe({
519
+ userId: user.id,
520
+ metadata: {
521
+ displayName: user.name,
522
+ avatar: user.avatar,
523
+ status: 'online'
524
+ }
525
+ })
526
+
527
+ // Listen for messages
528
+ const unsubMessage = channel.onMessage((message) => {
529
+ if (message.type === 'chat') {
530
+ addChatMessage(message.data)
531
+ } else if (message.type === 'game-move') {
532
+ updateGameState(message.data)
533
+ }
534
+ })
535
+
536
+ // Listen for presence changes (who's online)
537
+ const unsubPresence = channel.onPresence((users) => {
538
+ console.log(`${users.length} users online:`)
539
+ users.forEach(user => {
540
+ console.log(`- ${user.metadata?.displayName} (${user.userId})`)
541
+ })
542
+ updateOnlineUsersList(users)
543
+ })
544
+
545
+ // Publish different types of messages
546
+ await channel.publish('chat', { text: 'Hello!' }, { userId: user.id })
547
+ await channel.publish('game-move', { x: 5, y: 3, piece: 'king' })
548
+ await channel.publish('typing', { isTyping: true })
549
+
550
+ // Get current presence (one-time check)
551
+ const currentUsers = await channel.getPresence()
552
+ console.log('Currently online:', currentUsers.length)
553
+
554
+ // Get message history
555
+ const recentMessages = await channel.getMessages({
556
+ limit: 50,
557
+ before: lastMessageId // Pagination support
558
+ })
559
+
560
+ // Cleanup when done
561
+ unsubMessage()
562
+ unsubPresence()
563
+ await channel.unsubscribe()
564
+
565
+ // Or use the simple unsubscribe from subscribe()
566
+ unsubscribe()
567
+
568
+ // Multiple channels for different features
569
+ const chatChannel = blink.realtime.channel('chat')
570
+ const notificationChannel = blink.realtime.channel('notifications')
571
+ const gameChannel = blink.realtime.channel('game-state')
572
+
573
+ // Each channel is independent with its own subscribers and presence
574
+ await chatChannel.subscribe({ userId: user.id })
575
+ await notificationChannel.subscribe({ userId: user.id })
576
+ await gameChannel.subscribe({ userId: user.id, metadata: { team: 'red' } })
577
+
578
+ // Real-time collaboration example
579
+ const docChannel = blink.realtime.channel(`document-${docId}`)
580
+
581
+ await docChannel.subscribe({
582
+ userId: user.id,
583
+ metadata: {
584
+ name: user.name,
585
+ cursor: { line: 1, column: 0 }
586
+ }
587
+ })
588
+
589
+ // Broadcast cursor movements
590
+ docChannel.onMessage((message) => {
591
+ if (message.type === 'cursor-move') {
592
+ updateUserCursor(message.userId, message.data.position)
593
+ } else if (message.type === 'text-change') {
594
+ applyTextChange(message.data.delta)
595
+ }
596
+ })
597
+
598
+ // Send cursor updates
599
+ await docChannel.publish('cursor-move', {
600
+ position: { line: 5, column: 10 }
601
+ }, { userId: user.id })
602
+
603
+ // Send text changes
604
+ await docChannel.publish('text-change', {
605
+ delta: { insert: 'Hello', retain: 5 },
606
+ timestamp: Date.now()
607
+ })
608
+
609
+ // Presence with live cursor positions
610
+ docChannel.onPresence((users) => {
611
+ users.forEach(user => {
612
+ if (user.metadata?.cursor) {
613
+ showUserCursor(user.userId, user.metadata.cursor)
614
+ }
615
+ })
616
+ })
617
+
618
+ // Auto-cleanup on page unload
619
+ window.addEventListener('beforeunload', () => {
620
+ docChannel.unsubscribe()
621
+ })
622
+
623
+ // Error handling
624
+ try {
625
+ await blink.realtime.publish('restricted-channel', 'message', { data: 'test' })
626
+ } catch (error) {
627
+ if (error instanceof BlinkRealtimeError) {
628
+ console.error('Realtime error:', error.message)
629
+ }
630
+ }
631
+ ```
632
+
484
633
  ## 🔧 Advanced Usage
485
634
 
486
635
  ### Error Handling
487
636
 
488
637
  ```typescript
489
- import { BlinkAuthError, BlinkAIError, BlinkStorageError, BlinkDataError } from '@blinkdotnew/sdk'
638
+ import { BlinkAuthError, BlinkAIError, BlinkStorageError, BlinkDataError, BlinkRealtimeError } from '@blinkdotnew/sdk'
490
639
 
491
640
  try {
492
641
  const user = await blink.auth.me()
@@ -710,6 +859,130 @@ function EmailSender() {
710
859
  </div>
711
860
  )
712
861
  }
862
+
863
+ // React example with realtime chat
864
+ function RealtimeChat() {
865
+ const [messages, setMessages] = useState([])
866
+ const [newMessage, setNewMessage] = useState('')
867
+ const [onlineUsers, setOnlineUsers] = useState([])
868
+ const [user] = useState({ id: 'user123', name: 'John Doe' }) // From auth
869
+
870
+ useEffect(() => {
871
+ const channel = blink.realtime.channel('chat-room')
872
+
873
+ // Subscribe and listen for messages
874
+ const setupRealtime = async () => {
875
+ await channel.subscribe({
876
+ userId: user.id,
877
+ metadata: { displayName: user.name, avatar: '/avatar.png' }
878
+ })
879
+
880
+ // Listen for new messages
881
+ channel.onMessage((message) => {
882
+ if (message.type === 'chat') {
883
+ setMessages(prev => [...prev, {
884
+ id: message.id,
885
+ text: message.data.text,
886
+ userId: message.userId,
887
+ timestamp: message.timestamp,
888
+ user: message.metadata?.displayName || 'Unknown'
889
+ }])
890
+ }
891
+ })
892
+
893
+ // Listen for presence changes
894
+ channel.onPresence((users) => {
895
+ setOnlineUsers(users.map(u => ({
896
+ id: u.userId,
897
+ name: u.metadata?.displayName || 'Anonymous',
898
+ avatar: u.metadata?.avatar
899
+ })))
900
+ })
901
+
902
+ // Load recent messages
903
+ const recentMessages = await channel.getMessages({ limit: 50 })
904
+ setMessages(recentMessages.map(msg => ({
905
+ id: msg.id,
906
+ text: msg.data.text,
907
+ userId: msg.userId,
908
+ timestamp: msg.timestamp,
909
+ user: msg.metadata?.displayName || 'Unknown'
910
+ })))
911
+ }
912
+
913
+ setupRealtime()
914
+
915
+ // Cleanup on unmount
916
+ return () => {
917
+ channel.unsubscribe()
918
+ }
919
+ }, [user.id, user.name])
920
+
921
+ const sendMessage = async () => {
922
+ if (!newMessage.trim()) return
923
+
924
+ try {
925
+ await blink.realtime.publish('chat-room', 'chat', {
926
+ text: newMessage,
927
+ timestamp: Date.now()
928
+ }, {
929
+ userId: user.id,
930
+ metadata: { displayName: user.name }
931
+ })
932
+
933
+ setNewMessage('')
934
+ } catch (error) {
935
+ console.error('Failed to send message:', error)
936
+ }
937
+ }
938
+
939
+ return (
940
+ <div style={{ display: 'flex', height: '400px' }}>
941
+ {/* Chat messages */}
942
+ <div style={{ flex: 1, padding: '1rem' }}>
943
+ <h3>Chat Room</h3>
944
+ <div style={{ height: '250px', overflowY: 'auto', border: '1px solid #ccc', padding: '0.5rem' }}>
945
+ {messages.map((msg) => (
946
+ <div key={msg.id} style={{ marginBottom: '0.5rem' }}>
947
+ <strong>{msg.user}:</strong> {msg.text}
948
+ <small style={{ color: '#666', marginLeft: '0.5rem' }}>
949
+ {new Date(msg.timestamp).toLocaleTimeString()}
950
+ </small>
951
+ </div>
952
+ ))}
953
+ </div>
954
+
955
+ <div style={{ marginTop: '1rem', display: 'flex' }}>
956
+ <input
957
+ value={newMessage}
958
+ onChange={(e) => setNewMessage(e.target.value)}
959
+ placeholder="Type a message..."
960
+ style={{ flex: 1, marginRight: '0.5rem' }}
961
+ onKeyPress={(e) => e.key === 'Enter' && sendMessage()}
962
+ />
963
+ <button onClick={sendMessage}>Send</button>
964
+ </div>
965
+ </div>
966
+
967
+ {/* Online users sidebar */}
968
+ <div style={{ width: '200px', borderLeft: '1px solid #ccc', padding: '1rem' }}>
969
+ <h4>Online ({onlineUsers.length})</h4>
970
+ {onlineUsers.map((user) => (
971
+ <div key={user.id} style={{ display: 'flex', alignItems: 'center', marginBottom: '0.5rem' }}>
972
+ <div style={{
973
+ width: '8px',
974
+ height: '8px',
975
+ backgroundColor: '#22c55e',
976
+ borderRadius: '50%',
977
+ marginRight: '0.5rem'
978
+ }} />
979
+ {user.name}
980
+ </div>
981
+ ))}
982
+ </div>
983
+ </div>
984
+ )
985
+ }
713
986
  ```
714
987
 
715
988
  ### Next.js API Routes
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, ScrapeResult, FetchRequest, FetchResponse, AsyncFetchResponse, SearchResponse, BlinkStorage, BlinkAI, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse } from '@blink/core';
2
- export { AuthState, AuthTokens, BlinkAI, BlinkClientConfig, BlinkData, BlinkStorage, BlinkUser, CreateOptions, DataExtraction, FileObject, FilterCondition, ImageGenerationRequest, ImageGenerationResponse, ListResponse, Message, ObjectGenerationRequest, ObjectGenerationResponse, QueryOptions, SpeechGenerationRequest, SpeechGenerationResponse, StorageUploadOptions, StorageUploadResponse, TableOperations, TextGenerationRequest, TextGenerationResponse, TokenUsage, TranscriptionRequest, TranscriptionResponse, UpdateOptions, UpsertOptions } from '@blink/core';
1
+ import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, ScrapeResult, FetchRequest, FetchResponse, AsyncFetchResponse, SearchResponse, BlinkStorage, BlinkAI, BlinkRealtime, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse, RealtimeChannel, RealtimeMessage, RealtimeSubscribeOptions, RealtimePublishOptions, PresenceUser } from '@blink/core';
2
+ export { AuthState, AuthTokens, BlinkAI, BlinkClientConfig, BlinkRealtime, BlinkRealtimeError, BlinkStorage, BlinkUser, CreateOptions, DataExtraction, FileObject, FilterCondition, ImageGenerationRequest, ImageGenerationResponse, ListResponse, Message, ObjectGenerationRequest, ObjectGenerationResponse, PresenceUser, QueryOptions, RealtimeChannel, RealtimeGetMessagesOptions, RealtimeMessage, RealtimePublishOptions, RealtimeSubscribeOptions, SearchRequest, SearchResponse, SpeechGenerationRequest, SpeechGenerationResponse, StorageUploadOptions, StorageUploadResponse, TableOperations, TextGenerationRequest, TextGenerationResponse, TokenUsage, TranscriptionRequest, TranscriptionResponse, UpdateOptions, UpsertOptions } from '@blink/core';
3
3
 
4
4
  /**
5
5
  * Blink Auth Module - Client-side authentication management
@@ -215,7 +215,7 @@ interface BlinkData {
215
215
  fetchAsync(request: Omit<FetchRequest, 'async'>): Promise<AsyncFetchResponse>;
216
216
  search(query: string, options?: {
217
217
  location?: string;
218
- type?: 'news' | 'images' | 'videos' | 'shopping';
218
+ type?: 'news' | 'images' | 'image' | 'videos' | 'video' | 'shopping' | 'shop';
219
219
  language?: string;
220
220
  limit?: number;
221
221
  }): Promise<SearchResponse>;
@@ -242,7 +242,7 @@ declare class BlinkDataImpl implements BlinkData {
242
242
  fetchAsync(request: Omit<FetchRequest, 'async'>): Promise<AsyncFetchResponse>;
243
243
  search(query: string, options?: {
244
244
  location?: string;
245
- type?: 'news' | 'images' | 'videos' | 'shopping';
245
+ type?: 'news' | 'images' | 'image' | 'videos' | 'video' | 'shopping' | 'shop';
246
246
  language?: string;
247
247
  limit?: number;
248
248
  }): Promise<SearchResponse>;
@@ -259,6 +259,7 @@ interface BlinkClient {
259
259
  storage: BlinkStorage;
260
260
  ai: BlinkAI;
261
261
  data: BlinkData;
262
+ realtime: BlinkRealtime;
262
263
  }
263
264
  /**
264
265
  * Create a new Blink client instance
@@ -665,4 +666,55 @@ declare class BlinkAIImpl implements BlinkAI {
665
666
  transcribeAudio(options: TranscriptionRequest): Promise<TranscriptionResponse>;
666
667
  }
667
668
 
668
- export { type AuthStateChangeCallback, BlinkAIImpl, type BlinkClient, BlinkDataImpl, BlinkDatabase, BlinkStorageImpl, BlinkTable, createClient };
669
+ /**
670
+ * Blink Realtime Module - Real-time messaging and presence
671
+ * Provides pub/sub messaging, presence tracking, and live updates
672
+ */
673
+
674
+ declare class BlinkRealtimeChannel implements RealtimeChannel {
675
+ private channelName;
676
+ private httpClient;
677
+ private projectId;
678
+ private messageCallbacks;
679
+ private presenceCallbacks;
680
+ private websocket;
681
+ private isSubscribed;
682
+ private reconnectTimer;
683
+ private heartbeatTimer;
684
+ constructor(channelName: string, httpClient: HttpClient, projectId: string);
685
+ subscribe(options?: {
686
+ userId?: string;
687
+ metadata?: Record<string, any>;
688
+ }): Promise<void>;
689
+ unsubscribe(): Promise<void>;
690
+ publish(type: string, data: any, options?: {
691
+ userId?: string;
692
+ metadata?: Record<string, any>;
693
+ }): Promise<string>;
694
+ onMessage(callback: (message: RealtimeMessage) => void): () => void;
695
+ onPresence(callback: (users: PresenceUser[]) => void): () => void;
696
+ getPresence(): Promise<PresenceUser[]>;
697
+ getMessages(options?: {
698
+ limit?: number;
699
+ before?: string;
700
+ after?: string;
701
+ }): Promise<RealtimeMessage[]>;
702
+ private connectWebSocket;
703
+ private handleWebSocketMessage;
704
+ private startHeartbeat;
705
+ private scheduleReconnect;
706
+ private cleanup;
707
+ }
708
+ declare class BlinkRealtimeImpl implements BlinkRealtime {
709
+ private httpClient;
710
+ private projectId;
711
+ private channels;
712
+ constructor(httpClient: HttpClient, projectId: string);
713
+ channel(name: string): RealtimeChannel;
714
+ subscribe(channelName: string, callback: (message: RealtimeMessage) => void, options?: RealtimeSubscribeOptions): Promise<() => void>;
715
+ publish(channelName: string, type: string, data: any, options?: RealtimePublishOptions): Promise<string>;
716
+ presence(channelName: string): Promise<PresenceUser[]>;
717
+ onPresence(channelName: string, callback: (users: PresenceUser[]) => void): () => void;
718
+ }
719
+
720
+ export { type AuthStateChangeCallback, BlinkAIImpl, type BlinkClient, type BlinkData, BlinkDataImpl, BlinkDatabase, BlinkRealtimeChannel, BlinkRealtimeImpl, BlinkStorageImpl, BlinkTable, createClient };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, ScrapeResult, FetchRequest, FetchResponse, AsyncFetchResponse, SearchResponse, BlinkStorage, BlinkAI, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse } from '@blink/core';
2
- export { AuthState, AuthTokens, BlinkAI, BlinkClientConfig, BlinkData, BlinkStorage, BlinkUser, CreateOptions, DataExtraction, FileObject, FilterCondition, ImageGenerationRequest, ImageGenerationResponse, ListResponse, Message, ObjectGenerationRequest, ObjectGenerationResponse, QueryOptions, SpeechGenerationRequest, SpeechGenerationResponse, StorageUploadOptions, StorageUploadResponse, TableOperations, TextGenerationRequest, TextGenerationResponse, TokenUsage, TranscriptionRequest, TranscriptionResponse, UpdateOptions, UpsertOptions } from '@blink/core';
1
+ import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, ScrapeResult, FetchRequest, FetchResponse, AsyncFetchResponse, SearchResponse, BlinkStorage, BlinkAI, BlinkRealtime, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse, RealtimeChannel, RealtimeMessage, RealtimeSubscribeOptions, RealtimePublishOptions, PresenceUser } from '@blink/core';
2
+ export { AuthState, AuthTokens, BlinkAI, BlinkClientConfig, BlinkRealtime, BlinkRealtimeError, BlinkStorage, BlinkUser, CreateOptions, DataExtraction, FileObject, FilterCondition, ImageGenerationRequest, ImageGenerationResponse, ListResponse, Message, ObjectGenerationRequest, ObjectGenerationResponse, PresenceUser, QueryOptions, RealtimeChannel, RealtimeGetMessagesOptions, RealtimeMessage, RealtimePublishOptions, RealtimeSubscribeOptions, SearchRequest, SearchResponse, SpeechGenerationRequest, SpeechGenerationResponse, StorageUploadOptions, StorageUploadResponse, TableOperations, TextGenerationRequest, TextGenerationResponse, TokenUsage, TranscriptionRequest, TranscriptionResponse, UpdateOptions, UpsertOptions } from '@blink/core';
3
3
 
4
4
  /**
5
5
  * Blink Auth Module - Client-side authentication management
@@ -215,7 +215,7 @@ interface BlinkData {
215
215
  fetchAsync(request: Omit<FetchRequest, 'async'>): Promise<AsyncFetchResponse>;
216
216
  search(query: string, options?: {
217
217
  location?: string;
218
- type?: 'news' | 'images' | 'videos' | 'shopping';
218
+ type?: 'news' | 'images' | 'image' | 'videos' | 'video' | 'shopping' | 'shop';
219
219
  language?: string;
220
220
  limit?: number;
221
221
  }): Promise<SearchResponse>;
@@ -242,7 +242,7 @@ declare class BlinkDataImpl implements BlinkData {
242
242
  fetchAsync(request: Omit<FetchRequest, 'async'>): Promise<AsyncFetchResponse>;
243
243
  search(query: string, options?: {
244
244
  location?: string;
245
- type?: 'news' | 'images' | 'videos' | 'shopping';
245
+ type?: 'news' | 'images' | 'image' | 'videos' | 'video' | 'shopping' | 'shop';
246
246
  language?: string;
247
247
  limit?: number;
248
248
  }): Promise<SearchResponse>;
@@ -259,6 +259,7 @@ interface BlinkClient {
259
259
  storage: BlinkStorage;
260
260
  ai: BlinkAI;
261
261
  data: BlinkData;
262
+ realtime: BlinkRealtime;
262
263
  }
263
264
  /**
264
265
  * Create a new Blink client instance
@@ -665,4 +666,55 @@ declare class BlinkAIImpl implements BlinkAI {
665
666
  transcribeAudio(options: TranscriptionRequest): Promise<TranscriptionResponse>;
666
667
  }
667
668
 
668
- export { type AuthStateChangeCallback, BlinkAIImpl, type BlinkClient, BlinkDataImpl, BlinkDatabase, BlinkStorageImpl, BlinkTable, createClient };
669
+ /**
670
+ * Blink Realtime Module - Real-time messaging and presence
671
+ * Provides pub/sub messaging, presence tracking, and live updates
672
+ */
673
+
674
+ declare class BlinkRealtimeChannel implements RealtimeChannel {
675
+ private channelName;
676
+ private httpClient;
677
+ private projectId;
678
+ private messageCallbacks;
679
+ private presenceCallbacks;
680
+ private websocket;
681
+ private isSubscribed;
682
+ private reconnectTimer;
683
+ private heartbeatTimer;
684
+ constructor(channelName: string, httpClient: HttpClient, projectId: string);
685
+ subscribe(options?: {
686
+ userId?: string;
687
+ metadata?: Record<string, any>;
688
+ }): Promise<void>;
689
+ unsubscribe(): Promise<void>;
690
+ publish(type: string, data: any, options?: {
691
+ userId?: string;
692
+ metadata?: Record<string, any>;
693
+ }): Promise<string>;
694
+ onMessage(callback: (message: RealtimeMessage) => void): () => void;
695
+ onPresence(callback: (users: PresenceUser[]) => void): () => void;
696
+ getPresence(): Promise<PresenceUser[]>;
697
+ getMessages(options?: {
698
+ limit?: number;
699
+ before?: string;
700
+ after?: string;
701
+ }): Promise<RealtimeMessage[]>;
702
+ private connectWebSocket;
703
+ private handleWebSocketMessage;
704
+ private startHeartbeat;
705
+ private scheduleReconnect;
706
+ private cleanup;
707
+ }
708
+ declare class BlinkRealtimeImpl implements BlinkRealtime {
709
+ private httpClient;
710
+ private projectId;
711
+ private channels;
712
+ constructor(httpClient: HttpClient, projectId: string);
713
+ channel(name: string): RealtimeChannel;
714
+ subscribe(channelName: string, callback: (message: RealtimeMessage) => void, options?: RealtimeSubscribeOptions): Promise<() => void>;
715
+ publish(channelName: string, type: string, data: any, options?: RealtimePublishOptions): Promise<string>;
716
+ presence(channelName: string): Promise<PresenceUser[]>;
717
+ onPresence(channelName: string, callback: (users: PresenceUser[]) => void): () => void;
718
+ }
719
+
720
+ export { type AuthStateChangeCallback, BlinkAIImpl, type BlinkClient, type BlinkData, BlinkDataImpl, BlinkDatabase, BlinkRealtimeChannel, BlinkRealtimeImpl, BlinkStorageImpl, BlinkTable, createClient };