🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@supabase/realtime-js

Package Overview
Dependencies
Maintainers
13
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@supabase/realtime-js - npm Package Compare versions

Comparing version

to
2.11.6

2

dist/main/lib/version.d.ts

@@ -1,2 +0,2 @@

export declare const version = "2.11.5";
export declare const version = "2.11.6";
//# sourceMappingURL=version.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = '2.11.5';
exports.version = '2.11.6';
//# sourceMappingURL=version.js.map

@@ -23,2 +23,3 @@ import type { WebSocket as WSWebSocket } from 'ws';

export type RealtimeRemoveChannelResponse = 'ok' | 'timed out' | 'error';
export type HeartbeatStatus = 'sent' | 'ok' | 'error' | 'timeout' | 'disconnected';
export interface WebSocketLikeConstructor {

@@ -59,3 +60,3 @@ new (address: string | URL, _ignored?: any, options?: {

apiKey: string | null;
channels: RealtimeChannel[];
channels: Set<RealtimeChannel>;
endPoint: string;

@@ -74,2 +75,3 @@ httpEndpoint: string;

pendingHeartbeatRef: string | null;
heartbeatCallback: (status: HeartbeatStatus) => void;
ref: number;

@@ -179,2 +181,3 @@ reconnectTimer: Timer;

sendHeartbeat(): Promise<void>;
onHeartbeat(callback: (status: HeartbeatStatus) => void): void;
/**

@@ -181,0 +184,0 @@ * Flushes send buffer

@@ -75,3 +75,3 @@ "use strict";

this.apiKey = null;
this.channels = [];
this.channels = new Set();
this.endPoint = '';

@@ -85,2 +85,3 @@ this.httpEndpoint = '';

this.pendingHeartbeatRef = null;
this.heartbeatCallback = noop;
this.ref = 0;

@@ -233,3 +234,3 @@ this.logger = noop;

getChannels() {
return this.channels;
return Array.from(this.channels);
}

@@ -242,3 +243,3 @@ /**

const status = await channel.unsubscribe();
if (this.channels.length === 0) {
if (this.channels.size === 0) {
this.disconnect();

@@ -252,3 +253,6 @@ }

async removeAllChannels() {
const values_1 = await Promise.all(this.channels.map((channel) => channel.unsubscribe()));
const values_1 = await Promise.all(Array.from(this.channels).map((channel) => {
this.channels.delete(channel);
return channel.unsubscribe();
}));
this.disconnect();

@@ -287,5 +291,12 @@ return values_1;

channel(topic, params = { config: {} }) {
const chan = new RealtimeChannel_1.default(`realtime:${topic}`, params, this);
this.channels.push(chan);
return chan;
const realtimeTopic = `realtime:${topic}`;
const exists = this.getChannels().find((c) => c.topic === realtimeTopic);
if (!exists) {
const chan = new RealtimeChannel_1.default(`realtime:${topic}`, params, this);
this.channels.add(chan);
return chan;
}
else {
return exists;
}
}

@@ -348,2 +359,3 @@ /**

if (!this.isConnected()) {
this.heartbeatCallback('disconnected');
return;

@@ -354,2 +366,3 @@ }

this.log('transport', 'heartbeat timeout. Attempting to re-establish connection');
this.heartbeatCallback('timeout');
(_a = this.conn) === null || _a === void 0 ? void 0 : _a.close(constants_1.WS_CLOSE_NORMAL, 'hearbeat timeout');

@@ -365,4 +378,8 @@ return;

});
this.heartbeatCallback('sent');
await this.setAuth();
}
onHeartbeat(callback) {
this.heartbeatCallback = callback;
}
/**

@@ -398,3 +415,3 @@ * Flushes send buffer

_leaveOpenTopic(topic) {
let dupChannel = this.channels.find((c) => c.topic === topic && (c._isJoined() || c._isJoining()));
let dupChannel = Array.from(this.channels).find((c) => c.topic === topic && (c._isJoined() || c._isJoining()));
if (dupChannel) {

@@ -413,3 +430,3 @@ this.log('transport', `leaving duplicate topic "${topic}"`);

_remove(channel) {
this.channels = this.channels.filter((c) => c._joinRef() !== channel._joinRef());
this.channels.delete(channel);
}

@@ -434,2 +451,5 @@ /**

let { topic, event, payload, ref } = msg;
if (topic === 'phoenix' && event === 'phx_reply') {
this.heartbeatCallback(msg.payload.status == 'ok' ? 'ok' : 'error');
}
if (ref && ref === this.pendingHeartbeatRef) {

@@ -439,3 +459,3 @@ this.pendingHeartbeatRef = null;

this.log('receive', `${payload.status || ''} ${topic} ${event} ${(ref && '(' + ref + ')') || ''}`, payload);
this.channels
Array.from(this.channels)
.filter((channel) => channel._isMember(topic))

@@ -442,0 +462,0 @@ .forEach((channel) => channel._trigger(event, payload, ref));

@@ -1,2 +0,2 @@

export declare const version = "2.11.5";
export declare const version = "2.11.6";
//# sourceMappingURL=version.d.ts.map

@@ -1,2 +0,2 @@

export const version = '2.11.5';
export const version = '2.11.6';
//# sourceMappingURL=version.js.map

@@ -23,2 +23,3 @@ import type { WebSocket as WSWebSocket } from 'ws';

export type RealtimeRemoveChannelResponse = 'ok' | 'timed out' | 'error';
export type HeartbeatStatus = 'sent' | 'ok' | 'error' | 'timeout' | 'disconnected';
export interface WebSocketLikeConstructor {

@@ -59,3 +60,3 @@ new (address: string | URL, _ignored?: any, options?: {

apiKey: string | null;
channels: RealtimeChannel[];
channels: Set<RealtimeChannel>;
endPoint: string;

@@ -74,2 +75,3 @@ httpEndpoint: string;

pendingHeartbeatRef: string | null;
heartbeatCallback: (status: HeartbeatStatus) => void;
ref: number;

@@ -179,2 +181,3 @@ reconnectTimer: Timer;

sendHeartbeat(): Promise<void>;
onHeartbeat(callback: (status: HeartbeatStatus) => void): void;
/**

@@ -181,0 +184,0 @@ * Flushes send buffer

@@ -37,3 +37,3 @@ import { CHANNEL_EVENTS, CONNECTION_STATE, DEFAULT_HEADERS, DEFAULT_TIMEOUT, SOCKET_STATES, TRANSPORTS, VSN, WS_CLOSE_NORMAL, } from './lib/constants';

this.apiKey = null;
this.channels = [];
this.channels = new Set();
this.endPoint = '';

@@ -47,2 +47,3 @@ this.httpEndpoint = '';

this.pendingHeartbeatRef = null;
this.heartbeatCallback = noop;
this.ref = 0;

@@ -195,3 +196,3 @@ this.logger = noop;

getChannels() {
return this.channels;
return Array.from(this.channels);
}

@@ -204,3 +205,3 @@ /**

const status = await channel.unsubscribe();
if (this.channels.length === 0) {
if (this.channels.size === 0) {
this.disconnect();

@@ -214,3 +215,6 @@ }

async removeAllChannels() {
const values_1 = await Promise.all(this.channels.map((channel) => channel.unsubscribe()));
const values_1 = await Promise.all(Array.from(this.channels).map((channel) => {
this.channels.delete(channel);
return channel.unsubscribe();
}));
this.disconnect();

@@ -249,5 +253,12 @@ return values_1;

channel(topic, params = { config: {} }) {
const chan = new RealtimeChannel(`realtime:${topic}`, params, this);
this.channels.push(chan);
return chan;
const realtimeTopic = `realtime:${topic}`;
const exists = this.getChannels().find((c) => c.topic === realtimeTopic);
if (!exists) {
const chan = new RealtimeChannel(`realtime:${topic}`, params, this);
this.channels.add(chan);
return chan;
}
else {
return exists;
}
}

@@ -310,2 +321,3 @@ /**

if (!this.isConnected()) {
this.heartbeatCallback('disconnected');
return;

@@ -316,2 +328,3 @@ }

this.log('transport', 'heartbeat timeout. Attempting to re-establish connection');
this.heartbeatCallback('timeout');
(_a = this.conn) === null || _a === void 0 ? void 0 : _a.close(WS_CLOSE_NORMAL, 'hearbeat timeout');

@@ -327,4 +340,8 @@ return;

});
this.heartbeatCallback('sent');
await this.setAuth();
}
onHeartbeat(callback) {
this.heartbeatCallback = callback;
}
/**

@@ -360,3 +377,3 @@ * Flushes send buffer

_leaveOpenTopic(topic) {
let dupChannel = this.channels.find((c) => c.topic === topic && (c._isJoined() || c._isJoining()));
let dupChannel = Array.from(this.channels).find((c) => c.topic === topic && (c._isJoined() || c._isJoining()));
if (dupChannel) {

@@ -375,3 +392,3 @@ this.log('transport', `leaving duplicate topic "${topic}"`);

_remove(channel) {
this.channels = this.channels.filter((c) => c._joinRef() !== channel._joinRef());
this.channels.delete(channel);
}

@@ -396,2 +413,5 @@ /**

let { topic, event, payload, ref } = msg;
if (topic === 'phoenix' && event === 'phx_reply') {
this.heartbeatCallback(msg.payload.status == 'ok' ? 'ok' : 'error');
}
if (ref && ref === this.pendingHeartbeatRef) {

@@ -401,3 +421,3 @@ this.pendingHeartbeatRef = null;

this.log('receive', `${payload.status || ''} ${topic} ${event} ${(ref && '(' + ref + ')') || ''}`, payload);
this.channels
Array.from(this.channels)
.filter((channel) => channel._isMember(topic))

@@ -404,0 +424,0 @@ .forEach((channel) => channel._trigger(event, payload, ref));

{
"name": "@supabase/realtime-js",
"version": "2.11.5",
"version": "2.11.6",
"description": "Listen to realtime updates to your PostgreSQL database",

@@ -5,0 +5,0 @@ "keywords": [

@@ -1,1 +0,1 @@

export const version = '2.11.5'
export const version = '2.11.6'

@@ -41,2 +41,8 @@ import type { WebSocket as WSWebSocket } from 'ws'

export type RealtimeRemoveChannelResponse = 'ok' | 'timed out' | 'error'
export type HeartbeatStatus =
| 'sent'
| 'ok'
| 'error'
| 'timeout'
| 'disconnected'

@@ -90,3 +96,3 @@ const noop = () => {}

apiKey: string | null = null
channels: RealtimeChannel[] = []
channels: Set<RealtimeChannel> = new Set()
endPoint: string = ''

@@ -101,2 +107,3 @@ httpEndpoint: string = ''

pendingHeartbeatRef: string | null = null
heartbeatCallback: (status: HeartbeatStatus) => void = noop
ref: number = 0

@@ -274,3 +281,3 @@ reconnectTimer: Timer

getChannels(): RealtimeChannel[] {
return this.channels
return Array.from(this.channels)
}

@@ -286,3 +293,3 @@

const status = await channel.unsubscribe()
if (this.channels.length === 0) {
if (this.channels.size === 0) {
this.disconnect()

@@ -298,5 +305,9 @@ }

const values_1 = await Promise.all(
this.channels.map((channel) => channel.unsubscribe())
Array.from(this.channels).map((channel) => {
this.channels.delete(channel)
return channel.unsubscribe()
})
)
this.disconnect()
return values_1

@@ -341,5 +352,14 @@ }

): RealtimeChannel {
const chan = new RealtimeChannel(`realtime:${topic}`, params, this)
this.channels.push(chan)
return chan
const realtimeTopic = `realtime:${topic}`
const exists = this.getChannels().find(
(c: RealtimeChannel) => c.topic === realtimeTopic
)
if (!exists) {
const chan = new RealtimeChannel(`realtime:${topic}`, params, this)
this.channels.add(chan)
return chan
} else {
return exists
}
}

@@ -404,2 +424,3 @@

if (!this.isConnected()) {
this.heartbeatCallback('disconnected')
return

@@ -413,2 +434,3 @@ }

)
this.heartbeatCallback('timeout')
this.conn?.close(WS_CLOSE_NORMAL, 'hearbeat timeout')

@@ -424,5 +446,9 @@ return

})
this.heartbeatCallback('sent')
await this.setAuth()
}
onHeartbeat(callback: (status: HeartbeatStatus) => void): void {
this.heartbeatCallback = callback
}
/**

@@ -480,3 +506,3 @@ * Flushes send buffer

_leaveOpenTopic(topic: string): void {
let dupChannel = this.channels.find(
let dupChannel = Array.from(this.channels).find(
(c) => c.topic === topic && (c._isJoined() || c._isJoining())

@@ -498,5 +524,3 @@ )

_remove(channel: RealtimeChannel) {
this.channels = this.channels.filter(
(c: RealtimeChannel) => c._joinRef() !== channel._joinRef()
)
this.channels.delete(channel)
}

@@ -525,2 +549,6 @@

if (topic === 'phoenix' && event === 'phx_reply') {
this.heartbeatCallback(msg.payload.status == 'ok' ? 'ok' : 'error')
}
if (ref && ref === this.pendingHeartbeatRef) {

@@ -537,3 +565,4 @@ this.pendingHeartbeatRef = null

)
this.channels
Array.from(this.channels)
.filter((channel: RealtimeChannel) => channel._isMember(topic))

@@ -543,2 +572,3 @@ .forEach((channel: RealtimeChannel) =>

)
this.stateChangeCallbacks.message.forEach((callback) => callback(msg))

@@ -545,0 +575,0 @@ })

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet