eshala dorost she
This commit is contained in:
+37
-17
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
@@ -39,21 +49,21 @@ var REALTIME_POSTGRES_CHANGES_LISTEN_EVENT;
|
||||
REALTIME_POSTGRES_CHANGES_LISTEN_EVENT["INSERT"] = "INSERT";
|
||||
REALTIME_POSTGRES_CHANGES_LISTEN_EVENT["UPDATE"] = "UPDATE";
|
||||
REALTIME_POSTGRES_CHANGES_LISTEN_EVENT["DELETE"] = "DELETE";
|
||||
})(REALTIME_POSTGRES_CHANGES_LISTEN_EVENT = exports.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT || (exports.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT = {}));
|
||||
})(REALTIME_POSTGRES_CHANGES_LISTEN_EVENT || (exports.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT = REALTIME_POSTGRES_CHANGES_LISTEN_EVENT = {}));
|
||||
var REALTIME_LISTEN_TYPES;
|
||||
(function (REALTIME_LISTEN_TYPES) {
|
||||
REALTIME_LISTEN_TYPES["BROADCAST"] = "broadcast";
|
||||
REALTIME_LISTEN_TYPES["PRESENCE"] = "presence";
|
||||
REALTIME_LISTEN_TYPES["POSTGRES_CHANGES"] = "postgres_changes";
|
||||
REALTIME_LISTEN_TYPES["SYSTEM"] = "system";
|
||||
})(REALTIME_LISTEN_TYPES = exports.REALTIME_LISTEN_TYPES || (exports.REALTIME_LISTEN_TYPES = {}));
|
||||
})(REALTIME_LISTEN_TYPES || (exports.REALTIME_LISTEN_TYPES = REALTIME_LISTEN_TYPES = {}));
|
||||
var REALTIME_SUBSCRIBE_STATES;
|
||||
(function (REALTIME_SUBSCRIBE_STATES) {
|
||||
REALTIME_SUBSCRIBE_STATES["SUBSCRIBED"] = "SUBSCRIBED";
|
||||
REALTIME_SUBSCRIBE_STATES["TIMED_OUT"] = "TIMED_OUT";
|
||||
REALTIME_SUBSCRIBE_STATES["CLOSED"] = "CLOSED";
|
||||
REALTIME_SUBSCRIBE_STATES["CHANNEL_ERROR"] = "CHANNEL_ERROR";
|
||||
})(REALTIME_SUBSCRIBE_STATES = exports.REALTIME_SUBSCRIBE_STATES || (exports.REALTIME_SUBSCRIBE_STATES = {}));
|
||||
})(REALTIME_SUBSCRIBE_STATES || (exports.REALTIME_SUBSCRIBE_STATES = REALTIME_SUBSCRIBE_STATES = {}));
|
||||
exports.REALTIME_CHANNEL_STATES = constants_1.CHANNEL_STATES;
|
||||
/** A channel is the basic building block of Realtime
|
||||
* and narrows the scope of data flow to subscribed clients.
|
||||
@@ -122,10 +132,7 @@ class RealtimeChannel {
|
||||
if (!this.socket.isConnected()) {
|
||||
this.socket.connect();
|
||||
}
|
||||
if (this.joinedOnce) {
|
||||
throw `tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance`;
|
||||
}
|
||||
else {
|
||||
if (this.state == constants_1.CHANNEL_STATES.closed) {
|
||||
const { config: { broadcast, presence, private: isPrivate }, } = this.params;
|
||||
this._onError((e) => callback === null || callback === void 0 ? void 0 : callback(REALTIME_SUBSCRIBE_STATES.CHANNEL_ERROR, e));
|
||||
this._onClose(() => callback === null || callback === void 0 ? void 0 : callback(REALTIME_SUBSCRIBE_STATES.CLOSED));
|
||||
@@ -167,6 +174,7 @@ class RealtimeChannel {
|
||||
}
|
||||
else {
|
||||
this.unsubscribe();
|
||||
this.state = constants_1.CHANNEL_STATES.errored;
|
||||
callback === null || callback === void 0 ? void 0 : callback(REALTIME_SUBSCRIBE_STATES.CHANNEL_ERROR, new Error('mismatch between server and client bindings for postgres changes'));
|
||||
return;
|
||||
}
|
||||
@@ -177,6 +185,7 @@ class RealtimeChannel {
|
||||
}
|
||||
})
|
||||
.receive('error', (error) => {
|
||||
this.state = constants_1.CHANNEL_STATES.errored;
|
||||
callback === null || callback === void 0 ? void 0 : callback(REALTIME_SUBSCRIBE_STATES.CHANNEL_ERROR, new Error(JSON.stringify(Object.values(error).join(', ') || 'error')));
|
||||
return;
|
||||
})
|
||||
@@ -285,11 +294,10 @@ class RealtimeChannel {
|
||||
this.socket.log('channel', `leave ${this.topic}`);
|
||||
this._trigger(constants_1.CHANNEL_EVENTS.close, 'leave', this._joinRef());
|
||||
};
|
||||
this.rejoinTimer.reset();
|
||||
// Destroy joinPush to avoid connection timeouts during unscription phase
|
||||
this.joinPush.destroy();
|
||||
let leavePush = null;
|
||||
return new Promise((resolve) => {
|
||||
const leavePush = new push_1.default(this, constants_1.CHANNEL_EVENTS.leave, {}, timeout);
|
||||
leavePush = new push_1.default(this, constants_1.CHANNEL_EVENTS.leave, {}, timeout);
|
||||
leavePush
|
||||
.receive('ok', () => {
|
||||
onClose();
|
||||
@@ -306,8 +314,20 @@ class RealtimeChannel {
|
||||
if (!this._canPush()) {
|
||||
leavePush.trigger('ok', {});
|
||||
}
|
||||
}).finally(() => {
|
||||
leavePush === null || leavePush === void 0 ? void 0 : leavePush.destroy();
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Teardown the channel.
|
||||
*
|
||||
* Destroys and stops related timers.
|
||||
*/
|
||||
teardown() {
|
||||
this.pushBuffer.forEach((push) => push.destroy());
|
||||
this.rejoinTimer && clearTimeout(this.rejoinTimer.timer);
|
||||
this.joinPush.destroy();
|
||||
}
|
||||
/** @internal */
|
||||
async _fetchWithTimeout(url, options, timeout) {
|
||||
const controller = new AbortController();
|
||||
|
||||
+101
-95
@@ -15,24 +15,34 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const isows_1 = require("isows");
|
||||
const constants_1 = require("./lib/constants");
|
||||
const serializer_1 = __importDefault(require("./lib/serializer"));
|
||||
const timer_1 = __importDefault(require("./lib/timer"));
|
||||
const transformers_1 = require("./lib/transformers");
|
||||
const RealtimeChannel_1 = __importDefault(require("./RealtimeChannel"));
|
||||
const noop = () => { };
|
||||
const NATIVE_WEBSOCKET_AVAILABLE = typeof WebSocket !== 'undefined';
|
||||
const WORKER_SCRIPT = `
|
||||
addEventListener("message", (e) => {
|
||||
if (e.data.event === "start") {
|
||||
@@ -45,12 +55,13 @@ class RealtimeClient {
|
||||
*
|
||||
* @param endPoint The string WebSocket endpoint, ie, "ws://example.com/socket", "wss://example.com", "/socket" (inherited host & protocol)
|
||||
* @param httpEndpoint The string HTTP endpoint, ie, "https://example.com", "/" (inherited host & protocol)
|
||||
* @param options.transport The Websocket Transport, for example WebSocket.
|
||||
* @param options.transport The Websocket Transport, for example WebSocket. This can be a custom implementation
|
||||
* @param options.timeout The default timeout in milliseconds to trigger push timeouts.
|
||||
* @param options.params The optional params to pass when connecting.
|
||||
* @param options.headers The optional headers to pass when connecting.
|
||||
* @param options.headers Deprecated: headers cannot be set on websocket connections and this option will be removed in the future.
|
||||
* @param options.heartbeatIntervalMs The millisec interval to send a heartbeat message.
|
||||
* @param options.logger The optional function for specialized logging, ie: logger: (kind, msg, data) => { console.log(`${kind}: ${msg}`, data) }
|
||||
* @param options.logLevel Sets the log level for Realtime
|
||||
* @param options.encode The function to encode outgoing messages. Defaults to JSON: (payload, callback) => callback(JSON.stringify(payload))
|
||||
* @param options.decode The function to decode incoming messages. Defaults to Serializer's decode.
|
||||
* @param options.reconnectAfterMs he optional function that returns the millsec reconnect interval. Defaults to stepped backoff off.
|
||||
@@ -61,15 +72,17 @@ class RealtimeClient {
|
||||
var _a;
|
||||
this.accessTokenValue = null;
|
||||
this.apiKey = null;
|
||||
this.channels = [];
|
||||
this.channels = new Array();
|
||||
this.endPoint = '';
|
||||
this.httpEndpoint = '';
|
||||
this.headers = constants_1.DEFAULT_HEADERS;
|
||||
/** @deprecated headers cannot be set on websocket connections */
|
||||
this.headers = {};
|
||||
this.params = {};
|
||||
this.timeout = constants_1.DEFAULT_TIMEOUT;
|
||||
this.heartbeatIntervalMs = 30000;
|
||||
this.heartbeatIntervalMs = 25000;
|
||||
this.heartbeatTimer = undefined;
|
||||
this.pendingHeartbeatRef = null;
|
||||
this.heartbeatCallback = noop;
|
||||
this.ref = 0;
|
||||
this.logger = noop;
|
||||
this.conn = null;
|
||||
@@ -93,7 +106,7 @@ class RealtimeClient {
|
||||
_fetch = customFetch;
|
||||
}
|
||||
else if (typeof fetch === 'undefined') {
|
||||
_fetch = (...args) => Promise.resolve().then(() => __importStar(require('@supabase/node-fetch'))).then(({ default: fetch }) => fetch(...args));
|
||||
_fetch = (...args) => Promise.resolve(`${'@supabase/node-fetch'}`).then(s => __importStar(require(s))).then(({ default: fetch }) => fetch(...args));
|
||||
}
|
||||
else {
|
||||
_fetch = fetch;
|
||||
@@ -110,12 +123,14 @@ class RealtimeClient {
|
||||
}
|
||||
if (options === null || options === void 0 ? void 0 : options.params)
|
||||
this.params = options.params;
|
||||
if (options === null || options === void 0 ? void 0 : options.headers)
|
||||
this.headers = Object.assign(Object.assign({}, this.headers), options.headers);
|
||||
if (options === null || options === void 0 ? void 0 : options.timeout)
|
||||
this.timeout = options.timeout;
|
||||
if (options === null || options === void 0 ? void 0 : options.logger)
|
||||
this.logger = options.logger;
|
||||
if ((options === null || options === void 0 ? void 0 : options.logLevel) || (options === null || options === void 0 ? void 0 : options.log_level)) {
|
||||
this.logLevel = options.logLevel || options.log_level;
|
||||
this.params = Object.assign(Object.assign({}, this.params), { log_level: this.logLevel });
|
||||
}
|
||||
if (options === null || options === void 0 ? void 0 : options.heartbeatIntervalMs)
|
||||
this.heartbeatIntervalMs = options.heartbeatIntervalMs;
|
||||
const accessTokenValue = (_a = options === null || options === void 0 ? void 0 : options.params) === null || _a === void 0 ? void 0 : _a.apikey;
|
||||
@@ -157,28 +172,14 @@ class RealtimeClient {
|
||||
if (this.conn) {
|
||||
return;
|
||||
}
|
||||
if (this.transport) {
|
||||
this.conn = new this.transport(this.endpointURL(), undefined, {
|
||||
headers: this.headers,
|
||||
});
|
||||
return;
|
||||
if (!this.transport) {
|
||||
this.transport = isows_1.WebSocket;
|
||||
}
|
||||
if (NATIVE_WEBSOCKET_AVAILABLE) {
|
||||
this.conn = new WebSocket(this.endpointURL());
|
||||
this.setupConnection();
|
||||
return;
|
||||
if (!this.transport) {
|
||||
throw new Error('No transport provided');
|
||||
}
|
||||
this.conn = new WSWebSocketDummy(this.endpointURL(), undefined, {
|
||||
close: () => {
|
||||
this.conn = null;
|
||||
},
|
||||
});
|
||||
Promise.resolve().then(() => __importStar(require('ws'))).then(({ default: WS }) => {
|
||||
this.conn = new WS(this.endpointURL(), undefined, {
|
||||
headers: this.headers,
|
||||
});
|
||||
this.setupConnection();
|
||||
});
|
||||
this.conn = new this.transport(this.endpointURL());
|
||||
this.setupConnection();
|
||||
}
|
||||
/**
|
||||
* Returns the URL of the websocket.
|
||||
@@ -206,6 +207,7 @@ class RealtimeClient {
|
||||
// remove open handles
|
||||
this.heartbeatTimer && clearInterval(this.heartbeatTimer);
|
||||
this.reconnectTimer.reset();
|
||||
this.channels.forEach((channel) => channel.teardown());
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -230,6 +232,7 @@ class RealtimeClient {
|
||||
*/
|
||||
async removeAllChannels() {
|
||||
const values_1 = await Promise.all(this.channels.map((channel) => channel.unsubscribe()));
|
||||
this.channels = [];
|
||||
this.disconnect();
|
||||
return values_1;
|
||||
}
|
||||
@@ -263,9 +266,16 @@ class RealtimeClient {
|
||||
return this.connectionState() === constants_1.CONNECTION_STATE.Open;
|
||||
}
|
||||
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.push(chan);
|
||||
return chan;
|
||||
}
|
||||
else {
|
||||
return exists;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Push out a message if the socket is connected.
|
||||
@@ -301,23 +311,14 @@ class RealtimeClient {
|
||||
let tokenToSend = token ||
|
||||
(this.accessToken && (await this.accessToken())) ||
|
||||
this.accessTokenValue;
|
||||
if (tokenToSend) {
|
||||
let parsed = null;
|
||||
try {
|
||||
parsed = JSON.parse(atob(tokenToSend.split('.')[1]));
|
||||
}
|
||||
catch (_error) { }
|
||||
if (parsed && parsed.exp) {
|
||||
let now = Math.floor(Date.now() / 1000);
|
||||
let valid = now - parsed.exp < 0;
|
||||
if (!valid) {
|
||||
this.log('auth', `InvalidJWTToken: Invalid value for JWT claim "exp" with value ${parsed.exp}`);
|
||||
return Promise.reject(`InvalidJWTToken: Invalid value for JWT claim "exp" with value ${parsed.exp}`);
|
||||
}
|
||||
}
|
||||
if (this.accessTokenValue != tokenToSend) {
|
||||
this.accessTokenValue = tokenToSend;
|
||||
this.channels.forEach((channel) => {
|
||||
tokenToSend && channel.updateJoinPayload({ access_token: tokenToSend });
|
||||
const payload = {
|
||||
access_token: tokenToSend,
|
||||
version: constants_1.DEFAULT_VERSION,
|
||||
};
|
||||
tokenToSend && channel.updateJoinPayload(payload);
|
||||
if (channel.joinedOnce && channel._isJoined()) {
|
||||
channel._push(constants_1.CHANNEL_EVENTS.access_token, {
|
||||
access_token: tokenToSend,
|
||||
@@ -332,11 +333,13 @@ class RealtimeClient {
|
||||
async sendHeartbeat() {
|
||||
var _a;
|
||||
if (!this.isConnected()) {
|
||||
this.heartbeatCallback('disconnected');
|
||||
return;
|
||||
}
|
||||
if (this.pendingHeartbeatRef) {
|
||||
this.pendingHeartbeatRef = null;
|
||||
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');
|
||||
return;
|
||||
}
|
||||
@@ -347,7 +350,11 @@ class RealtimeClient {
|
||||
payload: {},
|
||||
ref: this.pendingHeartbeatRef,
|
||||
});
|
||||
this.setAuth();
|
||||
this.heartbeatCallback('sent');
|
||||
await this.setAuth();
|
||||
}
|
||||
onHeartbeat(callback) {
|
||||
this.heartbeatCallback = callback;
|
||||
}
|
||||
/**
|
||||
* Flushes send buffer
|
||||
@@ -393,7 +400,7 @@ class RealtimeClient {
|
||||
* @internal
|
||||
*/
|
||||
_remove(channel) {
|
||||
this.channels = this.channels.filter((c) => c._joinRef() !== channel._joinRef());
|
||||
this.channels = this.channels.filter((c) => c.topic !== channel.topic);
|
||||
}
|
||||
/**
|
||||
* Sets up connection handlers.
|
||||
@@ -413,51 +420,64 @@ class RealtimeClient {
|
||||
_onConnMessage(rawMessage) {
|
||||
this.decode(rawMessage.data, (msg) => {
|
||||
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) {
|
||||
this.pendingHeartbeatRef = null;
|
||||
}
|
||||
this.log('receive', `${payload.status || ''} ${topic} ${event} ${(ref && '(' + ref + ')') || ''}`, payload);
|
||||
this.channels
|
||||
Array.from(this.channels)
|
||||
.filter((channel) => channel._isMember(topic))
|
||||
.forEach((channel) => channel._trigger(event, payload, ref));
|
||||
this.stateChangeCallbacks.message.forEach((callback) => callback(msg));
|
||||
});
|
||||
}
|
||||
/** @internal */
|
||||
async _onConnOpen() {
|
||||
_onConnOpen() {
|
||||
this.log('transport', `connected to ${this.endpointURL()}`);
|
||||
this.flushSendBuffer();
|
||||
this.reconnectTimer.reset();
|
||||
if (!this.worker) {
|
||||
this.heartbeatTimer && clearInterval(this.heartbeatTimer);
|
||||
this.heartbeatTimer = setInterval(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
|
||||
this._startHeartbeat();
|
||||
}
|
||||
else {
|
||||
if (this.workerUrl) {
|
||||
this.log('worker', `starting worker for from ${this.workerUrl}`);
|
||||
if (!this.workerRef) {
|
||||
this._startWorkerHeartbeat();
|
||||
}
|
||||
else {
|
||||
this.log('worker', `starting default worker`);
|
||||
}
|
||||
const objectUrl = this._workerObjectUrl(this.workerUrl);
|
||||
this.workerRef = new Worker(objectUrl);
|
||||
this.workerRef.onerror = (error) => {
|
||||
this.log('worker', 'worker error', error.message);
|
||||
this.workerRef.terminate();
|
||||
};
|
||||
this.workerRef.onmessage = (event) => {
|
||||
if (event.data.event === 'keepAlive') {
|
||||
this.sendHeartbeat();
|
||||
}
|
||||
};
|
||||
this.workerRef.postMessage({
|
||||
event: 'start',
|
||||
interval: this.heartbeatIntervalMs,
|
||||
});
|
||||
}
|
||||
this.stateChangeCallbacks.open.forEach((callback) => callback());
|
||||
}
|
||||
/** @internal */
|
||||
_startHeartbeat() {
|
||||
this.heartbeatTimer && clearInterval(this.heartbeatTimer);
|
||||
this.heartbeatTimer = setInterval(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
|
||||
}
|
||||
/** @internal */
|
||||
_startWorkerHeartbeat() {
|
||||
if (this.workerUrl) {
|
||||
this.log('worker', `starting worker for from ${this.workerUrl}`);
|
||||
}
|
||||
else {
|
||||
this.log('worker', `starting default worker`);
|
||||
}
|
||||
const objectUrl = this._workerObjectUrl(this.workerUrl);
|
||||
this.workerRef = new Worker(objectUrl);
|
||||
this.workerRef.onerror = (error) => {
|
||||
this.log('worker', 'worker error', error.message);
|
||||
this.workerRef.terminate();
|
||||
};
|
||||
this.workerRef.onmessage = (event) => {
|
||||
if (event.data.event === 'keepAlive') {
|
||||
this.sendHeartbeat();
|
||||
}
|
||||
};
|
||||
this.workerRef.postMessage({
|
||||
event: 'start',
|
||||
interval: this.heartbeatIntervalMs,
|
||||
});
|
||||
}
|
||||
/** @internal */
|
||||
_onConnClose(event) {
|
||||
this.log('transport', 'close', event);
|
||||
this._triggerChanError();
|
||||
@@ -467,7 +487,7 @@ class RealtimeClient {
|
||||
}
|
||||
/** @internal */
|
||||
_onConnError(error) {
|
||||
this.log('transport', error.message);
|
||||
this.log('transport', `${error}`);
|
||||
this._triggerChanError();
|
||||
this.stateChangeCallbacks.error.forEach((callback) => callback(error));
|
||||
}
|
||||
@@ -497,18 +517,4 @@ class RealtimeClient {
|
||||
}
|
||||
}
|
||||
exports.default = RealtimeClient;
|
||||
class WSWebSocketDummy {
|
||||
constructor(address, _protocols, options) {
|
||||
this.binaryType = 'arraybuffer';
|
||||
this.onclose = () => { };
|
||||
this.onerror = () => { };
|
||||
this.onmessage = () => { };
|
||||
this.onopen = () => { };
|
||||
this.readyState = constants_1.SOCKET_STATES.connecting;
|
||||
this.send = () => { };
|
||||
this.url = null;
|
||||
this.url = address;
|
||||
this.close = options.close;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=RealtimeClient.js.map
|
||||
+1
-1
@@ -10,7 +10,7 @@ var REALTIME_PRESENCE_LISTEN_EVENTS;
|
||||
REALTIME_PRESENCE_LISTEN_EVENTS["SYNC"] = "sync";
|
||||
REALTIME_PRESENCE_LISTEN_EVENTS["JOIN"] = "join";
|
||||
REALTIME_PRESENCE_LISTEN_EVENTS["LEAVE"] = "leave";
|
||||
})(REALTIME_PRESENCE_LISTEN_EVENTS = exports.REALTIME_PRESENCE_LISTEN_EVENTS || (exports.REALTIME_PRESENCE_LISTEN_EVENTS = {}));
|
||||
})(REALTIME_PRESENCE_LISTEN_EVENTS || (exports.REALTIME_PRESENCE_LISTEN_EVENTS = REALTIME_PRESENCE_LISTEN_EVENTS = {}));
|
||||
class RealtimePresence {
|
||||
/**
|
||||
* Initializes the Presence.
|
||||
|
||||
+17
-7
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
|
||||
+8
-7
@@ -1,9 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CONNECTION_STATE = exports.TRANSPORTS = exports.CHANNEL_EVENTS = exports.CHANNEL_STATES = exports.SOCKET_STATES = exports.WS_CLOSE_NORMAL = exports.DEFAULT_TIMEOUT = exports.VSN = exports.DEFAULT_HEADERS = void 0;
|
||||
exports.CONNECTION_STATE = exports.TRANSPORTS = exports.CHANNEL_EVENTS = exports.CHANNEL_STATES = exports.SOCKET_STATES = exports.WS_CLOSE_NORMAL = exports.DEFAULT_TIMEOUT = exports.VERSION = exports.VSN = exports.DEFAULT_VERSION = void 0;
|
||||
const version_1 = require("./version");
|
||||
exports.DEFAULT_HEADERS = { 'X-Client-Info': `realtime-js/${version_1.version}` };
|
||||
exports.DEFAULT_VERSION = `realtime-js/${version_1.version}`;
|
||||
exports.VSN = '1.0.0';
|
||||
exports.VERSION = version_1.version;
|
||||
exports.DEFAULT_TIMEOUT = 10000;
|
||||
exports.WS_CLOSE_NORMAL = 1000;
|
||||
var SOCKET_STATES;
|
||||
@@ -12,7 +13,7 @@ var SOCKET_STATES;
|
||||
SOCKET_STATES[SOCKET_STATES["open"] = 1] = "open";
|
||||
SOCKET_STATES[SOCKET_STATES["closing"] = 2] = "closing";
|
||||
SOCKET_STATES[SOCKET_STATES["closed"] = 3] = "closed";
|
||||
})(SOCKET_STATES = exports.SOCKET_STATES || (exports.SOCKET_STATES = {}));
|
||||
})(SOCKET_STATES || (exports.SOCKET_STATES = SOCKET_STATES = {}));
|
||||
var CHANNEL_STATES;
|
||||
(function (CHANNEL_STATES) {
|
||||
CHANNEL_STATES["closed"] = "closed";
|
||||
@@ -20,7 +21,7 @@ var CHANNEL_STATES;
|
||||
CHANNEL_STATES["joined"] = "joined";
|
||||
CHANNEL_STATES["joining"] = "joining";
|
||||
CHANNEL_STATES["leaving"] = "leaving";
|
||||
})(CHANNEL_STATES = exports.CHANNEL_STATES || (exports.CHANNEL_STATES = {}));
|
||||
})(CHANNEL_STATES || (exports.CHANNEL_STATES = CHANNEL_STATES = {}));
|
||||
var CHANNEL_EVENTS;
|
||||
(function (CHANNEL_EVENTS) {
|
||||
CHANNEL_EVENTS["close"] = "phx_close";
|
||||
@@ -29,16 +30,16 @@ var CHANNEL_EVENTS;
|
||||
CHANNEL_EVENTS["reply"] = "phx_reply";
|
||||
CHANNEL_EVENTS["leave"] = "phx_leave";
|
||||
CHANNEL_EVENTS["access_token"] = "access_token";
|
||||
})(CHANNEL_EVENTS = exports.CHANNEL_EVENTS || (exports.CHANNEL_EVENTS = {}));
|
||||
})(CHANNEL_EVENTS || (exports.CHANNEL_EVENTS = CHANNEL_EVENTS = {}));
|
||||
var TRANSPORTS;
|
||||
(function (TRANSPORTS) {
|
||||
TRANSPORTS["websocket"] = "websocket";
|
||||
})(TRANSPORTS = exports.TRANSPORTS || (exports.TRANSPORTS = {}));
|
||||
})(TRANSPORTS || (exports.TRANSPORTS = TRANSPORTS = {}));
|
||||
var CONNECTION_STATE;
|
||||
(function (CONNECTION_STATE) {
|
||||
CONNECTION_STATE["Connecting"] = "connecting";
|
||||
CONNECTION_STATE["Open"] = "open";
|
||||
CONNECTION_STATE["Closing"] = "closing";
|
||||
CONNECTION_STATE["Closed"] = "closed";
|
||||
})(CONNECTION_STATE = exports.CONNECTION_STATE || (exports.CONNECTION_STATE = {}));
|
||||
})(CONNECTION_STATE || (exports.CONNECTION_STATE = CONNECTION_STATE = {}));
|
||||
//# sourceMappingURL=constants.js.map
|
||||
+1
-1
@@ -32,7 +32,7 @@ var PostgresTypes;
|
||||
PostgresTypes["timetz"] = "timetz";
|
||||
PostgresTypes["tsrange"] = "tsrange";
|
||||
PostgresTypes["tstzrange"] = "tstzrange";
|
||||
})(PostgresTypes = exports.PostgresTypes || (exports.PostgresTypes = {}));
|
||||
})(PostgresTypes || (exports.PostgresTypes = PostgresTypes = {}));
|
||||
/**
|
||||
* Takes an array of columns and an object of string values then converts each string value
|
||||
* to its mapped type.
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.version = void 0;
|
||||
exports.version = '2.11.2';
|
||||
exports.version = '2.11.15';
|
||||
//# sourceMappingURL=version.js.map
|
||||
+15
-14
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@supabase/realtime-js",
|
||||
"version": "2.11.2",
|
||||
"version": "2.11.15",
|
||||
"description": "Listen to realtime updates to your PostgreSQL database",
|
||||
"keywords": [
|
||||
"realtime",
|
||||
@@ -38,16 +38,17 @@
|
||||
"ci": "run-s test coverage"
|
||||
},
|
||||
"dependencies": {
|
||||
"@supabase/node-fetch": "^2.6.14",
|
||||
"@types/phoenix": "^1.5.4",
|
||||
"@types/ws": "^8.5.10",
|
||||
"ws": "^8.18.0"
|
||||
"@supabase/node-fetch": "^2.6.13",
|
||||
"@types/phoenix": "^1.6.6",
|
||||
"isows": "^1.0.7",
|
||||
"@types/ws": "^8.18.1",
|
||||
"ws": "^8.18.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@arethetypeswrong/cli": "^0.16.2",
|
||||
"@types/sinon": "^17.0.3",
|
||||
"@vitest/coverage-v8": "^2.0.5",
|
||||
"eslint": "^7.0.0",
|
||||
"@arethetypeswrong/cli": "^0.16.4",
|
||||
"@types/sinon": "^17.0.4",
|
||||
"@vitest/coverage-v8": "^3.1.4",
|
||||
"eslint": "^9.27.0",
|
||||
"esm": "^3.2.25",
|
||||
"jsdom": "^16.7.0",
|
||||
"jsdom-global": "3.0.0",
|
||||
@@ -55,12 +56,12 @@
|
||||
"mock-socket": "^9.3.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"nyc": "^15.1.0",
|
||||
"prettier": "^2.1.2",
|
||||
"prettier": "^2.8.8",
|
||||
"semantic-release-plugin-update-version-in-files": "^1.1.0",
|
||||
"sinon": "^18.0.0",
|
||||
"typedoc": "^0.22.16",
|
||||
"typescript": "^4.0.3",
|
||||
"vitest": "^2.0.5",
|
||||
"sinon": "^18.0.1",
|
||||
"typedoc": "^0.27.9",
|
||||
"typescript": "^5.8.3",
|
||||
"vitest": "^3.1.4",
|
||||
"web-worker": "1.2.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user