@supabase/realtime-js 2.100.0-rc.0 → 2.100.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.
Files changed (52) hide show
  1. package/dist/main/RealtimeChannel.d.ts +54 -2
  2. package/dist/main/RealtimeChannel.d.ts.map +1 -1
  3. package/dist/main/RealtimeChannel.js +213 -2
  4. package/dist/main/RealtimeChannel.js.map +1 -1
  5. package/dist/main/RealtimeClient.d.ts +39 -4
  6. package/dist/main/RealtimeClient.d.ts.map +1 -1
  7. package/dist/main/RealtimeClient.js +41 -5
  8. package/dist/main/RealtimeClient.js.map +1 -1
  9. package/dist/main/RealtimePresence.d.ts +3 -1
  10. package/dist/main/RealtimePresence.d.ts.map +1 -1
  11. package/dist/main/RealtimePresence.js +3 -1
  12. package/dist/main/RealtimePresence.js.map +1 -1
  13. package/dist/main/lib/constants.d.ts +2 -2
  14. package/dist/main/lib/constants.d.ts.map +1 -1
  15. package/dist/main/lib/version.d.ts +1 -1
  16. package/dist/main/lib/version.d.ts.map +1 -1
  17. package/dist/main/lib/version.js +1 -1
  18. package/dist/main/lib/version.js.map +1 -1
  19. package/dist/main/lib/websocket-factory.d.ts +14 -5
  20. package/dist/main/lib/websocket-factory.d.ts.map +1 -1
  21. package/dist/main/lib/websocket-factory.js +14 -5
  22. package/dist/main/lib/websocket-factory.js.map +1 -1
  23. package/dist/module/RealtimeChannel.d.ts +54 -2
  24. package/dist/module/RealtimeChannel.d.ts.map +1 -1
  25. package/dist/module/RealtimeChannel.js +213 -2
  26. package/dist/module/RealtimeChannel.js.map +1 -1
  27. package/dist/module/RealtimeClient.d.ts +39 -4
  28. package/dist/module/RealtimeClient.d.ts.map +1 -1
  29. package/dist/module/RealtimeClient.js +41 -5
  30. package/dist/module/RealtimeClient.js.map +1 -1
  31. package/dist/module/RealtimePresence.d.ts +3 -1
  32. package/dist/module/RealtimePresence.d.ts.map +1 -1
  33. package/dist/module/RealtimePresence.js +3 -1
  34. package/dist/module/RealtimePresence.js.map +1 -1
  35. package/dist/module/lib/constants.d.ts +2 -2
  36. package/dist/module/lib/constants.d.ts.map +1 -1
  37. package/dist/module/lib/version.d.ts +1 -1
  38. package/dist/module/lib/version.d.ts.map +1 -1
  39. package/dist/module/lib/version.js +1 -1
  40. package/dist/module/lib/version.js.map +1 -1
  41. package/dist/module/lib/websocket-factory.d.ts +14 -5
  42. package/dist/module/lib/websocket-factory.d.ts.map +1 -1
  43. package/dist/module/lib/websocket-factory.js +14 -5
  44. package/dist/module/lib/websocket-factory.js.map +1 -1
  45. package/dist/tsconfig.module.tsbuildinfo +1 -1
  46. package/dist/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +2 -2
  48. package/src/RealtimeChannel.ts +213 -2
  49. package/src/RealtimeClient.ts +43 -12
  50. package/src/RealtimePresence.ts +3 -1
  51. package/src/lib/version.ts +1 -1
  52. package/src/lib/websocket-factory.ts +14 -5
@@ -210,7 +210,9 @@ export default class RealtimeChannel {
210
210
  * The topic determines which realtime stream you are subscribing to. Config options let you
211
211
  * enable acknowledgement for broadcasts, presence tracking, or private channels.
212
212
  *
213
- * @example
213
+ * @category Realtime
214
+ *
215
+ * @example Example for a public channel
214
216
  * ```ts
215
217
  * import RealtimeClient from '@supabase/realtime-js'
216
218
  *
@@ -253,7 +255,10 @@ export default class RealtimeChannel {
253
255
  }
254
256
  }
255
257
 
256
- /** Subscribe registers your client with the server */
258
+ /**
259
+ * Subscribe registers your client with the server
260
+ * @category Realtime
261
+ */
257
262
  subscribe(
258
263
  callback?: (status: REALTIME_SUBSCRIBE_STATES, err?: Error) => void,
259
264
  timeout = this.timeout
@@ -372,6 +377,8 @@ export default class RealtimeChannel {
372
377
  *
373
378
  * The shape is a map keyed by presence key (for example a user id) where each entry contains the
374
379
  * tracked metadata for that user.
380
+ *
381
+ * @category Realtime
375
382
  */
376
383
  presenceState<T extends { [key: string]: any } = {}>(): RealtimePresenceState<T> {
377
384
  return this.presence.state as RealtimePresenceState<T>
@@ -380,6 +387,8 @@ export default class RealtimeChannel {
380
387
  /**
381
388
  * Sends the supplied payload to the presence tracker so other subscribers can see that this
382
389
  * client is online. Use `untrack` to stop broadcasting presence for the same key.
390
+ *
391
+ * @category Realtime
383
392
  */
384
393
  async track(
385
394
  payload: { [key: string]: any },
@@ -397,6 +406,8 @@ export default class RealtimeChannel {
397
406
 
398
407
  /**
399
408
  * Removes the current presence state for this client.
409
+ *
410
+ * @category Realtime
400
411
  */
401
412
  async untrack(opts: { [key: string]: any } = {}): Promise<RealtimeChannelSendResponse> {
402
413
  return await this.send(
@@ -529,6 +540,165 @@ export default class RealtimeChannel {
529
540
  filter: {},
530
541
  callback: (payload: any) => void
531
542
  ): RealtimeChannel
543
+ /**
544
+ * Listen to realtime events on this channel.
545
+ * @category Realtime
546
+ *
547
+ * @remarks
548
+ * - By default, Broadcast and Presence are enabled for all projects.
549
+ * - By default, listening to database changes is disabled for new projects due to database performance and security concerns. You can turn it on by managing Realtime's [replication](/docs/guides/api#realtime-api-overview).
550
+ * - You can receive the "previous" data for updates and deletes by setting the table's `REPLICA IDENTITY` to `FULL` (e.g., `ALTER TABLE your_table REPLICA IDENTITY FULL;`).
551
+ * - Row level security is not applied to delete statements. When RLS is enabled and replica identity is set to full, only the primary key is sent to clients.
552
+ *
553
+ * @example Listen to broadcast messages
554
+ * ```js
555
+ * const channel = supabase.channel("room1")
556
+ *
557
+ * channel.on("broadcast", { event: "cursor-pos" }, (payload) => {
558
+ * console.log("Cursor position received!", payload);
559
+ * }).subscribe((status) => {
560
+ * if (status === "SUBSCRIBED") {
561
+ * channel.send({
562
+ * type: "broadcast",
563
+ * event: "cursor-pos",
564
+ * payload: { x: Math.random(), y: Math.random() },
565
+ * });
566
+ * }
567
+ * });
568
+ * ```
569
+ *
570
+ * @example Listen to presence sync
571
+ * ```js
572
+ * const channel = supabase.channel('room1')
573
+ * channel
574
+ * .on('presence', { event: 'sync' }, () => {
575
+ * console.log('Synced presence state: ', channel.presenceState())
576
+ * })
577
+ * .subscribe(async (status) => {
578
+ * if (status === 'SUBSCRIBED') {
579
+ * await channel.track({ online_at: new Date().toISOString() })
580
+ * }
581
+ * })
582
+ * ```
583
+ *
584
+ * @example Listen to presence join
585
+ * ```js
586
+ * const channel = supabase.channel('room1')
587
+ * channel
588
+ * .on('presence', { event: 'join' }, ({ newPresences }) => {
589
+ * console.log('Newly joined presences: ', newPresences)
590
+ * })
591
+ * .subscribe(async (status) => {
592
+ * if (status === 'SUBSCRIBED') {
593
+ * await channel.track({ online_at: new Date().toISOString() })
594
+ * }
595
+ * })
596
+ * ```
597
+ *
598
+ * @example Listen to presence leave
599
+ * ```js
600
+ * const channel = supabase.channel('room1')
601
+ * channel
602
+ * .on('presence', { event: 'leave' }, ({ leftPresences }) => {
603
+ * console.log('Newly left presences: ', leftPresences)
604
+ * })
605
+ * .subscribe(async (status) => {
606
+ * if (status === 'SUBSCRIBED') {
607
+ * await channel.track({ online_at: new Date().toISOString() })
608
+ * await channel.untrack()
609
+ * }
610
+ * })
611
+ * ```
612
+ *
613
+ * @example Listen to all database changes
614
+ * ```js
615
+ * supabase
616
+ * .channel('room1')
617
+ * .on('postgres_changes', { event: '*', schema: '*' }, payload => {
618
+ * console.log('Change received!', payload)
619
+ * })
620
+ * .subscribe()
621
+ * ```
622
+ *
623
+ * @example Listen to a specific table
624
+ * ```js
625
+ * supabase
626
+ * .channel('room1')
627
+ * .on('postgres_changes', { event: '*', schema: 'public', table: 'countries' }, payload => {
628
+ * console.log('Change received!', payload)
629
+ * })
630
+ * .subscribe()
631
+ * ```
632
+ *
633
+ * @example Listen to inserts
634
+ * ```js
635
+ * supabase
636
+ * .channel('room1')
637
+ * .on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'countries' }, payload => {
638
+ * console.log('Change received!', payload)
639
+ * })
640
+ * .subscribe()
641
+ * ```
642
+ *
643
+ * @exampleDescription Listen to updates
644
+ * By default, Supabase will send only the updated record. If you want to receive the previous values as well you can
645
+ * enable full replication for the table you are listening to:
646
+ *
647
+ * ```sql
648
+ * alter table "your_table" replica identity full;
649
+ * ```
650
+ *
651
+ * @example Listen to updates
652
+ * ```js
653
+ * supabase
654
+ * .channel('room1')
655
+ * .on('postgres_changes', { event: 'UPDATE', schema: 'public', table: 'countries' }, payload => {
656
+ * console.log('Change received!', payload)
657
+ * })
658
+ * .subscribe()
659
+ * ```
660
+ *
661
+ * @exampleDescription Listen to deletes
662
+ * By default, Supabase does not send deleted records. If you want to receive the deleted record you can
663
+ * enable full replication for the table you are listening to:
664
+ *
665
+ * ```sql
666
+ * alter table "your_table" replica identity full;
667
+ * ```
668
+ *
669
+ * @example Listen to deletes
670
+ * ```js
671
+ * supabase
672
+ * .channel('room1')
673
+ * .on('postgres_changes', { event: 'DELETE', schema: 'public', table: 'countries' }, payload => {
674
+ * console.log('Change received!', payload)
675
+ * })
676
+ * .subscribe()
677
+ * ```
678
+ *
679
+ * @exampleDescription Listen to multiple events
680
+ * You can chain listeners if you want to listen to multiple events for each table.
681
+ *
682
+ * @example Listen to multiple events
683
+ * ```js
684
+ * supabase
685
+ * .channel('room1')
686
+ * .on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'countries' }, handleRecordInserted)
687
+ * .on('postgres_changes', { event: 'DELETE', schema: 'public', table: 'countries' }, handleRecordDeleted)
688
+ * .subscribe()
689
+ * ```
690
+ *
691
+ * @exampleDescription Listen to row level changes
692
+ * You can listen to individual rows using the format `{table}:{col}=eq.{val}` - where `{col}` is the column name, and `{val}` is the value which you want to match.
693
+ *
694
+ * @example Listen to row level changes
695
+ * ```js
696
+ * supabase
697
+ * .channel('room1')
698
+ * .on('postgres_changes', { event: 'UPDATE', schema: 'public', table: 'countries', filter: 'id=eq.200' }, handleRecordUpdated)
699
+ * .subscribe()
700
+ * ```
701
+ */
532
702
  on(
533
703
  type: `${REALTIME_LISTEN_TYPES}`,
534
704
  filter: { event: string; [key: string]: string },
@@ -550,6 +720,8 @@ export default class RealtimeChannel {
550
720
  * @param payload Payload to be sent (required)
551
721
  * @param opts Options including timeout
552
722
  * @returns Promise resolving to object with success status, and error details if failed
723
+ *
724
+ * @category Realtime
553
725
  */
554
726
  async httpSend(
555
727
  event: string,
@@ -611,6 +783,39 @@ export default class RealtimeChannel {
611
783
  * @param args.event The name of the event being sent
612
784
  * @param args.payload Payload to be sent
613
785
  * @param opts Options to be used during the send process
786
+ *
787
+ * @category Realtime
788
+ *
789
+ * @remarks
790
+ * - When using REST you don't need to subscribe to the channel
791
+ * - REST calls are only available from 2.37.0 onwards
792
+ *
793
+ * @example Send a message via websocket
794
+ * ```js
795
+ * const channel = supabase.channel('room1')
796
+ *
797
+ * channel.subscribe((status) => {
798
+ * if (status === 'SUBSCRIBED') {
799
+ * channel.send({
800
+ * type: 'broadcast',
801
+ * event: 'cursor-pos',
802
+ * payload: { x: Math.random(), y: Math.random() },
803
+ * })
804
+ * }
805
+ * })
806
+ * ```
807
+ *
808
+ * @exampleResponse Send a message via websocket
809
+ * ```js
810
+ * ok | timed out | error
811
+ * ```
812
+ *
813
+ * @example Send a message via REST
814
+ * ```js
815
+ * supabase
816
+ * .channel('room1')
817
+ * .httpSend('cursor-pos', { x: Math.random(), y: Math.random() })
818
+ * ```
614
819
  */
615
820
  async send(
616
821
  args: {
@@ -687,6 +892,8 @@ export default class RealtimeChannel {
687
892
  /**
688
893
  * Updates the payload that will be sent the next time the channel joins (reconnects).
689
894
  * Useful for rotating access tokens or updating config without re-creating the channel.
895
+ *
896
+ * @category Realtime
690
897
  */
691
898
  updateJoinPayload(payload: Record<string, any>) {
692
899
  this.channelAdapter.updateJoinPayload(payload)
@@ -700,6 +907,8 @@ export default class RealtimeChannel {
700
907
  *
701
908
  * To receive leave acknowledgements, use the a `receive` hook to bind to the server ack, ie:
702
909
  * channel.unsubscribe().receive("ok", () => alert("left!") )
910
+ *
911
+ * @category Realtime
703
912
  */
704
913
  async unsubscribe(timeout = this.timeout) {
705
914
  return new Promise<RealtimeChannelSendResponse>((resolve) => {
@@ -713,6 +922,8 @@ export default class RealtimeChannel {
713
922
 
714
923
  /**
715
924
  * Destroys and stops related timers.
925
+ *
926
+ * @category Realtime
716
927
  */
717
928
  teardown() {
718
929
  this.channelAdapter.teardown()
@@ -15,14 +15,7 @@ import { httpEndpointURL } from './lib/transformers'
15
15
  import RealtimeChannel from './RealtimeChannel'
16
16
  import type { RealtimeChannelOptions } from './RealtimeChannel'
17
17
  import SocketAdapter from './phoenix/socketAdapter'
18
- import type {
19
- Message,
20
- SocketOptions,
21
- HeartbeatCallback,
22
- Encode,
23
- Decode,
24
- Vsn,
25
- } from './phoenix/types'
18
+ import type { Message, SocketOptions, HeartbeatCallback, Encode, Decode } from './phoenix/types'
26
19
 
27
20
  type Fetch = typeof fetch
28
21
 
@@ -65,7 +58,7 @@ export type RealtimeClientOptions = {
65
58
  timeout?: number
66
59
  heartbeatIntervalMs?: number
67
60
  heartbeatCallback?: (status: HeartbeatStatus, latency?: number) => void
68
- vsn?: Vsn
61
+ vsn?: string
69
62
  logger?: (kind: string, msg: string, data?: any) => void
70
63
  encode?: Encode<void>
71
64
  decode?: Decode<void>
@@ -204,7 +197,10 @@ export default class RealtimeClient {
204
197
  * @param options.worker Use Web Worker to set a side flow. Defaults to false.
205
198
  * @param options.workerUrl The URL of the worker script. Defaults to https://realtime.supabase.com/worker.js that includes a heartbeat event call to keep the connection alive.
206
199
  * @param options.vsn The protocol version to use when connecting. Supported versions are "1.0.0" and "2.0.0". Defaults to "2.0.0".
207
- * @example
200
+ *
201
+ * @category Realtime
202
+ *
203
+ * @example Example for a public channel
208
204
  * ```ts
209
205
  * import RealtimeClient from '@supabase/realtime-js'
210
206
  *
@@ -231,6 +227,8 @@ export default class RealtimeClient {
231
227
 
232
228
  /**
233
229
  * Connects the socket, unless already connected.
230
+ *
231
+ * @category Realtime
234
232
  */
235
233
  connect(): void {
236
234
  // Skip if already connecting, disconnecting, or connected
@@ -276,6 +274,8 @@ export default class RealtimeClient {
276
274
  /**
277
275
  * Returns the URL of the websocket.
278
276
  * @returns string The URL of the websocket.
277
+ *
278
+ * @category Realtime
279
279
  */
280
280
  endpointURL(): string {
281
281
  return this.socketAdapter.endPointURL()
@@ -286,6 +286,8 @@ export default class RealtimeClient {
286
286
  *
287
287
  * @param code A numeric status code to send on disconnect.
288
288
  * @param reason A custom reason for the disconnect.
289
+ *
290
+ * @category Realtime
289
291
  */
290
292
  async disconnect(code?: number, reason?: string) {
291
293
  if (this.isDisconnecting()) {
@@ -303,6 +305,8 @@ export default class RealtimeClient {
303
305
 
304
306
  /**
305
307
  * Returns all created channels
308
+ *
309
+ * @category Realtime
306
310
  */
307
311
  getChannels(): RealtimeChannel[] {
308
312
  return this.channels
@@ -311,6 +315,8 @@ export default class RealtimeClient {
311
315
  /**
312
316
  * Unsubscribes, removes and tears down a single channel
313
317
  * @param channel A RealtimeChannel instance
318
+ *
319
+ * @category Realtime
314
320
  */
315
321
  async removeChannel(channel: RealtimeChannel): Promise<RealtimeRemoveChannelResponse> {
316
322
  const status = await channel.unsubscribe()
@@ -328,6 +334,8 @@ export default class RealtimeClient {
328
334
 
329
335
  /**
330
336
  * Unsubscribes, removes and tears down all channels
337
+ *
338
+ * @category Realtime
331
339
  */
332
340
  async removeAllChannels(): Promise<RealtimeRemoveChannelResponse[]> {
333
341
  const promises = this.channels.map(async (channel) => {
@@ -345,6 +353,8 @@ export default class RealtimeClient {
345
353
  * Logs the message.
346
354
  *
347
355
  * For customized logging, `this.logger` can be overridden in Client constructor.
356
+ *
357
+ * @category Realtime
348
358
  */
349
359
  log(kind: string, msg: string, data?: any) {
350
360
  this.socketAdapter.log(kind, msg, data)
@@ -352,6 +362,8 @@ export default class RealtimeClient {
352
362
 
353
363
  /**
354
364
  * Returns the current state of the socket.
365
+ *
366
+ * @category Realtime
355
367
  */
356
368
  connectionState() {
357
369
  return this.socketAdapter.connectionState() || CONNECTION_STATE.closed
@@ -359,6 +371,8 @@ export default class RealtimeClient {
359
371
 
360
372
  /**
361
373
  * Returns `true` is the connection is open.
374
+ *
375
+ * @category Realtime
362
376
  */
363
377
  isConnected(): boolean {
364
378
  return this.socketAdapter.isConnected()
@@ -366,6 +380,8 @@ export default class RealtimeClient {
366
380
 
367
381
  /**
368
382
  * Returns `true` if the connection is currently connecting.
383
+ *
384
+ * @category Realtime
369
385
  */
370
386
  isConnecting(): boolean {
371
387
  return this.socketAdapter.isConnecting()
@@ -373,6 +389,8 @@ export default class RealtimeClient {
373
389
 
374
390
  /**
375
391
  * Returns `true` if the connection is currently disconnecting.
392
+ *
393
+ * @category Realtime
376
394
  */
377
395
  isDisconnecting(): boolean {
378
396
  return this.socketAdapter.isDisconnecting()
@@ -384,6 +402,8 @@ export default class RealtimeClient {
384
402
  * Topics are automatically prefixed with `realtime:` to match the Realtime service.
385
403
  * If a channel with the same topic already exists it will be returned instead of creating
386
404
  * a duplicate connection.
405
+ *
406
+ * @category Realtime
387
407
  */
388
408
  channel(topic: string, params: RealtimeChannelOptions = { config: {} }): RealtimeChannel {
389
409
  const realtimeTopic = `realtime:${topic}`
@@ -403,6 +423,8 @@ export default class RealtimeClient {
403
423
  * Push out a message if the socket is connected.
404
424
  *
405
425
  * If the socket is not connected, the message gets enqueued within a local buffer, and sent out when a connection is next established.
426
+ *
427
+ * @category Realtime
406
428
  */
407
429
  push(data: RealtimeMessage): void {
408
430
  this.socketAdapter.push(data)
@@ -427,6 +449,8 @@ export default class RealtimeClient {
427
449
  *
428
450
  * // Switch back to using the accessToken callback
429
451
  * client.realtime.setAuth()
452
+ *
453
+ * @category Realtime
430
454
  */
431
455
  async setAuth(token: string | null = null): Promise<void> {
432
456
  this._authPromise = this._performAuth(token)
@@ -448,6 +472,8 @@ export default class RealtimeClient {
448
472
 
449
473
  /**
450
474
  * Sends a heartbeat message if the socket is connected.
475
+ *
476
+ * @category Realtime
451
477
  */
452
478
  async sendHeartbeat() {
453
479
  this.socketAdapter.sendHeartbeat()
@@ -456,6 +482,8 @@ export default class RealtimeClient {
456
482
  /**
457
483
  * Sets a callback that receives lifecycle events for internal heartbeat messages.
458
484
  * Useful for instrumenting connection health (e.g. sent/ok/timeout/disconnected).
485
+ *
486
+ * @category Realtime
459
487
  */
460
488
  onHeartbeat(callback: HeartbeatCallback) {
461
489
  this.socketAdapter.heartbeatCallback = this._wrapHeartbeatCallback(callback)
@@ -672,7 +700,7 @@ export default class RealtimeClient {
672
700
  result.timeout = options?.timeout ?? DEFAULT_TIMEOUT
673
701
  result.heartbeatIntervalMs =
674
702
  options?.heartbeatIntervalMs ?? CONNECTION_TIMEOUTS.HEARTBEAT_INTERVAL
675
- result.vsn = options?.vsn ?? DEFAULT_VSN
703
+
676
704
  // @ts-ignore - mismatch between phoenix and supabase
677
705
  result.transport = options?.transport ?? WebSocketFactory.getWebSocketConstructor()
678
706
  result.params = options?.params
@@ -687,7 +715,9 @@ export default class RealtimeClient {
687
715
  let defaultEncode: Encode<void>
688
716
  let defaultDecode: Decode<void>
689
717
 
690
- switch (result.vsn) {
718
+ const vsn = options?.vsn ?? DEFAULT_VSN
719
+
720
+ switch (vsn) {
691
721
  case VSN_1_0_0:
692
722
  defaultEncode = (payload, callback) => {
693
723
  return callback(JSON.stringify(payload))
@@ -704,6 +734,7 @@ export default class RealtimeClient {
704
734
  throw new Error(`Unsupported serializer version: ${result.vsn}`)
705
735
  }
706
736
 
737
+ result.vsn = vsn
707
738
  result.encode = options?.encode ?? defaultEncode
708
739
  result.decode = options?.decode ?? defaultDecode
709
740
 
@@ -51,7 +51,9 @@ export default class RealtimePresence {
51
51
  * @param channel - The realtime channel to bind to.
52
52
  * @param opts - Optional custom event names, e.g. `{ events: { state: 'state', diff: 'diff' } }`.
53
53
  *
54
- * @example
54
+ * @category Realtime
55
+ *
56
+ * @example Example for a presence channel
55
57
  * ```ts
56
58
  * const presence = new RealtimePresence(channel)
57
59
  *
@@ -4,4 +4,4 @@
4
4
  // - Debugging and support (identifying which version is running)
5
5
  // - Telemetry and logging (version reporting in errors/analytics)
6
6
  // - Ensuring build artifacts match the published package version
7
- export const version = '2.100.0-rc.0'
7
+ export const version = '2.100.0'
@@ -138,10 +138,16 @@ export class WebSocketFactory {
138
138
  /**
139
139
  * Returns the best available WebSocket constructor for the current runtime.
140
140
  *
141
- * @example
141
+ * @category Realtime
142
+ *
143
+ * @example Example with error handling
142
144
  * ```ts
143
- * const WS = WebSocketFactory.getWebSocketConstructor()
144
- * const socket = new WS('wss://realtime.supabase.co/socket')
145
+ * try {
146
+ * const WS = WebSocketFactory.getWebSocketConstructor()
147
+ * const socket = new WS('wss://example.com/socket')
148
+ * } catch (error) {
149
+ * console.error('WebSocket not available in this environment.', error)
150
+ * }
145
151
  * ```
146
152
  */
147
153
  public static getWebSocketConstructor(): typeof WebSocket {
@@ -159,10 +165,13 @@ export class WebSocketFactory {
159
165
  /**
160
166
  * Detects whether the runtime can establish WebSocket connections.
161
167
  *
162
- * @example
168
+ * @category Realtime
169
+ *
170
+ * @example Example in a Node.js script
163
171
  * ```ts
164
172
  * if (!WebSocketFactory.isWebSocketSupported()) {
165
- * console.warn('Falling back to long polling')
173
+ * console.error('WebSockets are required for this script.')
174
+ * process.exitCode = 1
166
175
  * }
167
176
  * ```
168
177
  */