@supabase/realtime-js
Advanced tools
Comparing version 1.7.3 to 1.7.4
import * as Transformers from './lib/transformers'; | ||
import RealtimeClient, { Options as RealtimeClientOptions } from './RealtimeClient'; | ||
import RealtimeSubscription from './RealtimeSubscription'; | ||
import RealtimeChannel from './RealtimeChannel'; | ||
import RealtimePresence from './RealtimePresence'; | ||
export { RealtimeClient, RealtimeClientOptions, RealtimeSubscription, RealtimeChannel, RealtimePresence, Transformers, }; | ||
export { RealtimeClient, RealtimeClientOptions, RealtimeSubscription, Transformers, }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -25,3 +25,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Transformers = exports.RealtimePresence = exports.RealtimeChannel = exports.RealtimeSubscription = exports.RealtimeClient = void 0; | ||
exports.Transformers = exports.RealtimeSubscription = exports.RealtimeClient = void 0; | ||
const Transformers = __importStar(require("./lib/transformers")); | ||
@@ -33,6 +33,2 @@ exports.Transformers = Transformers; | ||
exports.RealtimeSubscription = RealtimeSubscription_1.default; | ||
const RealtimeChannel_1 = __importDefault(require("./RealtimeChannel")); | ||
exports.RealtimeChannel = RealtimeChannel_1.default; | ||
const RealtimePresence_1 = __importDefault(require("./RealtimePresence")); | ||
exports.RealtimePresence = RealtimePresence_1.default; | ||
//# sourceMappingURL=index.js.map |
@@ -1,5 +0,4 @@ | ||
import RealtimeChannel from '../RealtimeChannel'; | ||
import RealtimeSubscription from '../RealtimeSubscription'; | ||
export default class Push { | ||
channel: RealtimeSubscription | RealtimeChannel; | ||
channel: RealtimeSubscription; | ||
event: string; | ||
@@ -30,3 +29,3 @@ payload: { | ||
*/ | ||
constructor(channel: RealtimeSubscription | RealtimeChannel, event: string, payload?: { | ||
constructor(channel: RealtimeSubscription, event: string, payload?: { | ||
[key: string]: unknown; | ||
@@ -33,0 +32,0 @@ }, timeout?: number); |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const constants_1 = require("../lib/constants"); | ||
const RealtimeSubscription_1 = __importDefault(require("../RealtimeSubscription")); | ||
class Push { | ||
@@ -74,8 +70,3 @@ /** | ||
}; | ||
if (this.channel instanceof RealtimeSubscription_1.default) { | ||
this.channel.on(this.refEvent, callback); | ||
} | ||
else { | ||
this.channel.on(this.refEvent, {}, callback); | ||
} | ||
this.channel.on(this.refEvent, callback); | ||
this.timeoutTimer = setTimeout(() => { | ||
@@ -97,8 +88,3 @@ this.trigger('timeout', {}); | ||
} | ||
if (this.channel instanceof RealtimeSubscription_1.default) { | ||
this.channel.off(this.refEvent); | ||
} | ||
else { | ||
this.channel.off(this.refEvent, {}); | ||
} | ||
this.channel.off(this.refEvent); | ||
} | ||
@@ -105,0 +91,0 @@ _cancelTimeout() { |
@@ -1,2 +0,2 @@ | ||
export declare const version = "1.7.3"; | ||
export declare const version = "1.7.4"; | ||
//# sourceMappingURL=version.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = '1.7.3'; | ||
exports.version = '1.7.4'; | ||
//# sourceMappingURL=version.js.map |
@@ -5,3 +5,2 @@ import { CONNECTION_STATE } from './lib/constants'; | ||
import RealtimeSubscription from './RealtimeSubscription'; | ||
import RealtimeChannel from './RealtimeChannel'; | ||
export declare type Options = { | ||
@@ -35,3 +34,3 @@ transport?: WebSocket; | ||
accessToken: string | null; | ||
channels: (RealtimeSubscription | RealtimeChannel)[]; | ||
channels: RealtimeSubscription[]; | ||
endPoint: string; | ||
@@ -150,4 +149,4 @@ headers?: { | ||
*/ | ||
remove(channel: RealtimeSubscription | RealtimeChannel): void; | ||
channel(topic: string, chanParams?: ChannelParams): RealtimeChannel | RealtimeSubscription; | ||
remove(channel: RealtimeSubscription): void; | ||
channel(topic: string, chanParams?: ChannelParams): RealtimeSubscription; | ||
/** | ||
@@ -154,0 +153,0 @@ * Push out a message if the socket is connected. |
@@ -11,13 +11,2 @@ "use strict"; | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -32,3 +21,2 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const RealtimeSubscription_1 = __importDefault(require("./RealtimeSubscription")); | ||
const RealtimeChannel_1 = __importDefault(require("./RealtimeChannel")); | ||
const noop = () => { }; | ||
@@ -232,30 +220,3 @@ class RealtimeClient { | ||
channel(topic, chanParams = {}) { | ||
var _a; | ||
const { selfBroadcast } = chanParams, params = __rest(chanParams, ["selfBroadcast"]); | ||
if (selfBroadcast) { | ||
params.self_broadcast = selfBroadcast; | ||
} | ||
const chan = ((_a = this.params) === null || _a === void 0 ? void 0 : _a.vsndate) ? new RealtimeChannel_1.default(topic, params, this) | ||
: new RealtimeSubscription_1.default(topic, params, this); | ||
if (chan instanceof RealtimeChannel_1.default) { | ||
chan.presence.onJoin((key, currentPresences, newPresences) => { | ||
chan.trigger('presence', { | ||
event: 'JOIN', | ||
key, | ||
currentPresences, | ||
newPresences, | ||
}); | ||
}); | ||
chan.presence.onLeave((key, currentPresences, leftPresences) => { | ||
chan.trigger('presence', { | ||
event: 'LEAVE', | ||
key, | ||
currentPresences, | ||
leftPresences, | ||
}); | ||
}); | ||
chan.presence.onSync(() => { | ||
chan.trigger('presence', { event: 'SYNC' }); | ||
}); | ||
} | ||
const chan = new RealtimeSubscription_1.default(topic, chanParams, this); | ||
this.channels.push(chan); | ||
@@ -262,0 +223,0 @@ return chan; |
import * as Transformers from './lib/transformers'; | ||
import RealtimeClient, { Options as RealtimeClientOptions } from './RealtimeClient'; | ||
import RealtimeSubscription from './RealtimeSubscription'; | ||
import RealtimeChannel from './RealtimeChannel'; | ||
import RealtimePresence from './RealtimePresence'; | ||
export { RealtimeClient, RealtimeClientOptions, RealtimeSubscription, RealtimeChannel, RealtimePresence, Transformers, }; | ||
export { RealtimeClient, RealtimeClientOptions, RealtimeSubscription, Transformers, }; | ||
//# sourceMappingURL=index.d.ts.map |
import * as Transformers from './lib/transformers'; | ||
import RealtimeClient from './RealtimeClient'; | ||
import RealtimeSubscription from './RealtimeSubscription'; | ||
import RealtimeChannel from './RealtimeChannel'; | ||
import RealtimePresence from './RealtimePresence'; | ||
export { RealtimeClient, RealtimeSubscription, RealtimeChannel, RealtimePresence, Transformers, }; | ||
export { RealtimeClient, RealtimeSubscription, Transformers, }; | ||
//# sourceMappingURL=index.js.map |
@@ -1,5 +0,4 @@ | ||
import RealtimeChannel from '../RealtimeChannel'; | ||
import RealtimeSubscription from '../RealtimeSubscription'; | ||
export default class Push { | ||
channel: RealtimeSubscription | RealtimeChannel; | ||
channel: RealtimeSubscription; | ||
event: string; | ||
@@ -30,3 +29,3 @@ payload: { | ||
*/ | ||
constructor(channel: RealtimeSubscription | RealtimeChannel, event: string, payload?: { | ||
constructor(channel: RealtimeSubscription, event: string, payload?: { | ||
[key: string]: unknown; | ||
@@ -33,0 +32,0 @@ }, timeout?: number); |
import { DEFAULT_TIMEOUT } from '../lib/constants'; | ||
import RealtimeSubscription from '../RealtimeSubscription'; | ||
export default class Push { | ||
@@ -69,8 +68,3 @@ /** | ||
}; | ||
if (this.channel instanceof RealtimeSubscription) { | ||
this.channel.on(this.refEvent, callback); | ||
} | ||
else { | ||
this.channel.on(this.refEvent, {}, callback); | ||
} | ||
this.channel.on(this.refEvent, callback); | ||
this.timeoutTimer = setTimeout(() => { | ||
@@ -92,8 +86,3 @@ this.trigger('timeout', {}); | ||
} | ||
if (this.channel instanceof RealtimeSubscription) { | ||
this.channel.off(this.refEvent); | ||
} | ||
else { | ||
this.channel.off(this.refEvent, {}); | ||
} | ||
this.channel.off(this.refEvent); | ||
} | ||
@@ -100,0 +89,0 @@ _cancelTimeout() { |
@@ -1,2 +0,2 @@ | ||
export declare const version = "1.7.3"; | ||
export declare const version = "1.7.4"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export const version = '1.7.3'; | ||
export const version = '1.7.4'; | ||
//# sourceMappingURL=version.js.map |
@@ -5,3 +5,2 @@ import { CONNECTION_STATE } from './lib/constants'; | ||
import RealtimeSubscription from './RealtimeSubscription'; | ||
import RealtimeChannel from './RealtimeChannel'; | ||
export declare type Options = { | ||
@@ -35,3 +34,3 @@ transport?: WebSocket; | ||
accessToken: string | null; | ||
channels: (RealtimeSubscription | RealtimeChannel)[]; | ||
channels: RealtimeSubscription[]; | ||
endPoint: string; | ||
@@ -150,4 +149,4 @@ headers?: { | ||
*/ | ||
remove(channel: RealtimeSubscription | RealtimeChannel): void; | ||
channel(topic: string, chanParams?: ChannelParams): RealtimeChannel | RealtimeSubscription; | ||
remove(channel: RealtimeSubscription): void; | ||
channel(topic: string, chanParams?: ChannelParams): RealtimeSubscription; | ||
/** | ||
@@ -154,0 +153,0 @@ * Push out a message if the socket is connected. |
@@ -10,13 +10,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
import { w3cwebsocket } from 'websocket'; | ||
@@ -27,3 +16,2 @@ import { VSN, CHANNEL_EVENTS, TRANSPORTS, SOCKET_STATES, DEFAULT_TIMEOUT, WS_CLOSE_NORMAL, DEFAULT_HEADERS, CONNECTION_STATE, } from './lib/constants'; | ||
import RealtimeSubscription from './RealtimeSubscription'; | ||
import RealtimeChannel from './RealtimeChannel'; | ||
const noop = () => { }; | ||
@@ -227,30 +215,3 @@ export default class RealtimeClient { | ||
channel(topic, chanParams = {}) { | ||
var _a; | ||
const { selfBroadcast } = chanParams, params = __rest(chanParams, ["selfBroadcast"]); | ||
if (selfBroadcast) { | ||
params.self_broadcast = selfBroadcast; | ||
} | ||
const chan = ((_a = this.params) === null || _a === void 0 ? void 0 : _a.vsndate) ? new RealtimeChannel(topic, params, this) | ||
: new RealtimeSubscription(topic, params, this); | ||
if (chan instanceof RealtimeChannel) { | ||
chan.presence.onJoin((key, currentPresences, newPresences) => { | ||
chan.trigger('presence', { | ||
event: 'JOIN', | ||
key, | ||
currentPresences, | ||
newPresences, | ||
}); | ||
}); | ||
chan.presence.onLeave((key, currentPresences, leftPresences) => { | ||
chan.trigger('presence', { | ||
event: 'LEAVE', | ||
key, | ||
currentPresences, | ||
leftPresences, | ||
}); | ||
}); | ||
chan.presence.onSync(() => { | ||
chan.trigger('presence', { event: 'SYNC' }); | ||
}); | ||
} | ||
const chan = new RealtimeSubscription(topic, chanParams, this); | ||
this.channels.push(chan); | ||
@@ -257,0 +218,0 @@ return chan; |
{ | ||
"name": "@supabase/realtime-js", | ||
"version": "1.7.3", | ||
"version": "1.7.4", | ||
"description": "Listen to realtime updates to your PostgreSQL database", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -6,4 +6,2 @@ import * as Transformers from './lib/transformers' | ||
import RealtimeSubscription from './RealtimeSubscription' | ||
import RealtimeChannel from './RealtimeChannel' | ||
import RealtimePresence from './RealtimePresence' | ||
@@ -14,5 +12,3 @@ export { | ||
RealtimeSubscription, | ||
RealtimeChannel, | ||
RealtimePresence, | ||
Transformers, | ||
} |
import { DEFAULT_TIMEOUT } from '../lib/constants' | ||
import RealtimeChannel from '../RealtimeChannel' | ||
import RealtimeSubscription from '../RealtimeSubscription' | ||
@@ -28,3 +27,3 @@ | ||
constructor( | ||
public channel: RealtimeSubscription | RealtimeChannel, | ||
public channel: RealtimeSubscription, | ||
public event: string, | ||
@@ -86,7 +85,3 @@ public payload: { [key: string]: unknown } = {}, | ||
if (this.channel instanceof RealtimeSubscription) { | ||
this.channel.on(this.refEvent, callback) | ||
} else { | ||
this.channel.on(this.refEvent, {}, callback) | ||
} | ||
this.channel.on(this.refEvent, callback) | ||
@@ -112,7 +107,3 @@ this.timeoutTimer = <any>setTimeout(() => { | ||
if (this.channel instanceof RealtimeSubscription) { | ||
this.channel.off(this.refEvent) | ||
} else { | ||
this.channel.off(this.refEvent, {}) | ||
} | ||
this.channel.off(this.refEvent) | ||
} | ||
@@ -119,0 +110,0 @@ |
@@ -1,1 +0,1 @@ | ||
export const version = '1.7.3' | ||
export const version = '1.7.4' |
@@ -15,3 +15,2 @@ import { w3cwebsocket } from 'websocket' | ||
import RealtimeSubscription from './RealtimeSubscription' | ||
import RealtimeChannel from './RealtimeChannel' | ||
@@ -46,3 +45,3 @@ export type Options = { | ||
accessToken: string | null = null | ||
channels: (RealtimeSubscription | RealtimeChannel)[] = [] | ||
channels: RealtimeSubscription[] = [] | ||
endPoint: string = '' | ||
@@ -261,47 +260,10 @@ headers?: { [key: string]: string } = DEFAULT_HEADERS | ||
*/ | ||
remove(channel: RealtimeSubscription | RealtimeChannel) { | ||
remove(channel: RealtimeSubscription) { | ||
this.channels = this.channels.filter( | ||
(c: RealtimeSubscription | RealtimeChannel) => | ||
c.joinRef() !== channel.joinRef() | ||
(c: RealtimeSubscription) => c.joinRef() !== channel.joinRef() | ||
) | ||
} | ||
channel( | ||
topic: string, | ||
chanParams: ChannelParams = {} | ||
): RealtimeChannel | RealtimeSubscription { | ||
const { selfBroadcast, ...params } = chanParams | ||
if (selfBroadcast) { | ||
params.self_broadcast = selfBroadcast | ||
} | ||
const chan = this.params?.vsndate | ||
? new RealtimeChannel(topic, params, this) | ||
: new RealtimeSubscription(topic, params, this) | ||
if (chan instanceof RealtimeChannel) { | ||
chan.presence.onJoin((key, currentPresences, newPresences) => { | ||
chan.trigger('presence', { | ||
event: 'JOIN', | ||
key, | ||
currentPresences, | ||
newPresences, | ||
}) | ||
}) | ||
chan.presence.onLeave((key, currentPresences, leftPresences) => { | ||
chan.trigger('presence', { | ||
event: 'LEAVE', | ||
key, | ||
currentPresences, | ||
leftPresences, | ||
}) | ||
}) | ||
chan.presence.onSync(() => { | ||
chan.trigger('presence', { event: 'SYNC' }) | ||
}) | ||
} | ||
channel(topic: string, chanParams: ChannelParams = {}): RealtimeSubscription { | ||
const chan = new RealtimeSubscription(topic, chanParams, this) | ||
this.channels.push(chan) | ||
@@ -350,6 +312,4 @@ return chan | ||
this.channels | ||
.filter((channel: RealtimeSubscription | RealtimeChannel) => | ||
channel.isMember(topic) | ||
) | ||
.forEach((channel: RealtimeSubscription | RealtimeChannel) => | ||
.filter((channel: RealtimeSubscription) => channel.isMember(topic)) | ||
.forEach((channel: RealtimeSubscription) => | ||
channel.trigger(event, payload, ref) | ||
@@ -442,3 +402,3 @@ ) | ||
private _triggerChanError() { | ||
this.channels.forEach((channel: RealtimeSubscription | RealtimeChannel) => | ||
this.channels.forEach((channel: RealtimeSubscription) => | ||
channel.trigger(CHANNEL_EVENTS.error) | ||
@@ -445,0 +405,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
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
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
219626
84
3951