@supabase/realtime-js 2.12.2 → 2.14.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/dist/main/RealtimeChannel.d.ts.map +1 -1
- package/dist/main/RealtimeChannel.js +10 -1
- package/dist/main/RealtimeChannel.js.map +1 -1
- package/dist/main/RealtimeClient.d.ts +13 -2
- package/dist/main/RealtimeClient.d.ts.map +1 -1
- package/dist/main/RealtimeClient.js +311 -115
- package/dist/main/RealtimeClient.js.map +1 -1
- package/dist/main/index.d.ts +2 -1
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +3 -1
- package/dist/main/index.js.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/main/lib/websocket-factory.d.ts +41 -0
- package/dist/main/lib/websocket-factory.d.ts.map +1 -0
- package/dist/main/lib/websocket-factory.js +132 -0
- package/dist/main/lib/websocket-factory.js.map +1 -0
- package/dist/module/RealtimeChannel.d.ts.map +1 -1
- package/dist/module/RealtimeChannel.js +10 -1
- package/dist/module/RealtimeChannel.js.map +1 -1
- package/dist/module/RealtimeClient.d.ts +13 -2
- package/dist/module/RealtimeClient.d.ts.map +1 -1
- package/dist/module/RealtimeClient.js +312 -115
- package/dist/module/RealtimeClient.js.map +1 -1
- package/dist/module/index.d.ts +2 -1
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +2 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/module/lib/websocket-factory.d.ts +41 -0
- package/dist/module/lib/websocket-factory.d.ts.map +1 -0
- package/dist/module/lib/websocket-factory.js +128 -0
- package/dist/module/lib/websocket-factory.js.map +1 -0
- package/package.json +3 -4
- package/src/RealtimeChannel.ts +12 -1
- package/src/RealtimeClient.ts +358 -132
- package/src/index.ts +3 -0
- package/src/lib/version.ts +1 -1
- package/src/lib/websocket-factory.ts +189 -0
package/dist/module/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import RealtimeClient from './RealtimeClient';
|
|
2
2
|
import RealtimeChannel, { REALTIME_LISTEN_TYPES, REALTIME_POSTGRES_CHANGES_LISTEN_EVENT, REALTIME_SUBSCRIBE_STATES, REALTIME_CHANNEL_STATES, } from './RealtimeChannel';
|
|
3
3
|
import RealtimePresence, { REALTIME_PRESENCE_LISTEN_EVENTS, } from './RealtimePresence';
|
|
4
|
-
|
|
4
|
+
import WebSocketFactory from './lib/websocket-factory';
|
|
5
|
+
export { RealtimePresence, RealtimeChannel, RealtimeClient, REALTIME_LISTEN_TYPES, REALTIME_POSTGRES_CHANGES_LISTEN_EVENT, REALTIME_PRESENCE_LISTEN_EVENTS, REALTIME_SUBSCRIBE_STATES, REALTIME_CHANNEL_STATES, WebSocketFactory, };
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/dist/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAIN,MAAM,kBAAkB,CAAA;AACzB,OAAO,eAAe,EAAE,EAQtB,qBAAqB,EACrB,sCAAsC,EACtC,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,gBAAgB,EAAE,EAIvB,+BAA+B,GAChC,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAIN,MAAM,kBAAkB,CAAA;AACzB,OAAO,eAAe,EAAE,EAQtB,qBAAqB,EACrB,sCAAsC,EACtC,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,gBAAgB,EAAE,EAIvB,+BAA+B,GAChC,MAAM,oBAAoB,CAAA;AAC3B,OAAO,gBAAmC,MAAM,yBAAyB,CAAA;AAEzE,OAAO,EACL,gBAAgB,EAChB,eAAe,EAGf,cAAc,EAYd,qBAAqB,EACrB,sCAAsC,EACtC,+BAA+B,EAC/B,yBAAyB,EACzB,uBAAuB,EACvB,gBAAgB,GAEjB,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "2.
|
|
1
|
+
export declare const version = "2.14.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.14.0';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface WebSocketLike {
|
|
2
|
+
readonly CONNECTING: number;
|
|
3
|
+
readonly OPEN: number;
|
|
4
|
+
readonly CLOSING: number;
|
|
5
|
+
readonly CLOSED: number;
|
|
6
|
+
readonly readyState: number;
|
|
7
|
+
readonly url: string;
|
|
8
|
+
readonly protocol: string;
|
|
9
|
+
close(code?: number, reason?: string): void;
|
|
10
|
+
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
|
|
11
|
+
onopen: ((this: any, ev: Event) => any) | null;
|
|
12
|
+
onmessage: ((this: any, ev: MessageEvent) => any) | null;
|
|
13
|
+
onclose: ((this: any, ev: CloseEvent) => any) | null;
|
|
14
|
+
onerror: ((this: any, ev: Event) => any) | null;
|
|
15
|
+
addEventListener(type: string, listener: EventListener): void;
|
|
16
|
+
removeEventListener(type: string, listener: EventListener): void;
|
|
17
|
+
binaryType?: string;
|
|
18
|
+
bufferedAmount?: number;
|
|
19
|
+
extensions?: string;
|
|
20
|
+
dispatchEvent?: (event: Event) => boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface WebSocketEnvironment {
|
|
23
|
+
type: 'native' | 'ws' | 'cloudflare' | 'unsupported';
|
|
24
|
+
constructor?: any;
|
|
25
|
+
error?: string;
|
|
26
|
+
workaround?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare class WebSocketFactory {
|
|
29
|
+
/**
|
|
30
|
+
* Dynamic require that works in both CJS and ESM environments
|
|
31
|
+
* Bulletproof against strict ESM environments where require might not be in scope
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
private static dynamicRequire;
|
|
35
|
+
private static detectEnvironment;
|
|
36
|
+
static getWebSocketConstructor(): typeof WebSocket;
|
|
37
|
+
static createWebSocket(url: string | URL, protocols?: string | string[]): WebSocketLike;
|
|
38
|
+
static isWebSocketSupported(): boolean;
|
|
39
|
+
}
|
|
40
|
+
export default WebSocketFactory;
|
|
41
|
+
//# sourceMappingURL=websocket-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-factory.d.ts","sourceRoot":"","sources":["../../../src/lib/websocket-factory.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3C,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,GAAG,eAAe,GAAG,IAAI,CAAA;IAEnE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,KAAK,GAAG,CAAC,GAAG,IAAI,CAAA;IAC9C,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,YAAY,KAAK,GAAG,CAAC,GAAG,IAA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ESM environments where require might not be in scope
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
7
|
+
static dynamicRequire(moduleId) {
|
|
8
|
+
try {
|
|
9
|
+
// Check if we're in a Node.js environment first
|
|
10
|
+
if (typeof process !== 'undefined' &&
|
|
11
|
+
process.versions &&
|
|
12
|
+
process.versions.node) {
|
|
13
|
+
// In Node.js, both CJS and ESM support require for dynamic imports
|
|
14
|
+
// Wrap in try/catch to handle strict ESM environments
|
|
15
|
+
if (typeof require !== 'undefined') {
|
|
16
|
+
return require(moduleId);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
catch (_a) {
|
|
22
|
+
// Catches any error from typeof require OR require() call in strict ESM
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
static detectEnvironment() {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
if (typeof WebSocket !== 'undefined') {
|
|
29
|
+
return { type: 'native', constructor: WebSocket };
|
|
30
|
+
}
|
|
31
|
+
if (typeof globalThis !== 'undefined' &&
|
|
32
|
+
typeof globalThis.WebSocket !== 'undefined') {
|
|
33
|
+
return { type: 'native', constructor: globalThis.WebSocket };
|
|
34
|
+
}
|
|
35
|
+
if (typeof global !== 'undefined' &&
|
|
36
|
+
typeof global.WebSocket !== 'undefined') {
|
|
37
|
+
return { type: 'native', constructor: global.WebSocket };
|
|
38
|
+
}
|
|
39
|
+
if (typeof globalThis !== 'undefined' &&
|
|
40
|
+
typeof globalThis.WebSocketPair !== 'undefined' &&
|
|
41
|
+
typeof globalThis.WebSocket === 'undefined') {
|
|
42
|
+
return {
|
|
43
|
+
type: 'cloudflare',
|
|
44
|
+
error: 'Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.',
|
|
45
|
+
workaround: 'Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime.',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if ((typeof globalThis !== 'undefined' && globalThis.EdgeRuntime) ||
|
|
49
|
+
(typeof navigator !== 'undefined' &&
|
|
50
|
+
((_a = navigator.userAgent) === null || _a === void 0 ? void 0 : _a.includes('Vercel-Edge')))) {
|
|
51
|
+
return {
|
|
52
|
+
type: 'unsupported',
|
|
53
|
+
error: 'Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.',
|
|
54
|
+
workaround: 'Use serverless functions or a different deployment target for WebSocket functionality.',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (typeof process !== 'undefined' &&
|
|
58
|
+
process.versions &&
|
|
59
|
+
process.versions.node) {
|
|
60
|
+
const nodeVersion = parseInt(process.versions.node.split('.')[0]);
|
|
61
|
+
if (nodeVersion >= 22) {
|
|
62
|
+
try {
|
|
63
|
+
if (typeof globalThis.WebSocket !== 'undefined') {
|
|
64
|
+
return { type: 'native', constructor: globalThis.WebSocket };
|
|
65
|
+
}
|
|
66
|
+
const undici = this.dynamicRequire('undici');
|
|
67
|
+
if (undici && undici.WebSocket) {
|
|
68
|
+
return { type: 'native', constructor: undici.WebSocket };
|
|
69
|
+
}
|
|
70
|
+
throw new Error('undici not available');
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
return {
|
|
74
|
+
type: 'unsupported',
|
|
75
|
+
error: `Node.js ${nodeVersion} detected but native WebSocket not found.`,
|
|
76
|
+
workaround: 'Install the "ws" package or check your Node.js installation.',
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
// Use dynamic require to work in both CJS and ESM environments
|
|
82
|
+
const ws = this.dynamicRequire('ws');
|
|
83
|
+
if (ws) {
|
|
84
|
+
return { type: 'ws', constructor: (_b = ws.WebSocket) !== null && _b !== void 0 ? _b : ws };
|
|
85
|
+
}
|
|
86
|
+
throw new Error('ws package not available');
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
return {
|
|
90
|
+
type: 'unsupported',
|
|
91
|
+
error: `Node.js ${nodeVersion} detected without WebSocket support.`,
|
|
92
|
+
workaround: 'Install the "ws" package: npm install ws',
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
type: 'unsupported',
|
|
98
|
+
error: 'Unknown JavaScript runtime without WebSocket support.',
|
|
99
|
+
workaround: "Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation.",
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
static getWebSocketConstructor() {
|
|
103
|
+
const env = this.detectEnvironment();
|
|
104
|
+
if (env.constructor) {
|
|
105
|
+
return env.constructor;
|
|
106
|
+
}
|
|
107
|
+
let errorMessage = env.error || 'WebSocket not supported in this environment.';
|
|
108
|
+
if (env.workaround) {
|
|
109
|
+
errorMessage += `\n\nSuggested solution: ${env.workaround}`;
|
|
110
|
+
}
|
|
111
|
+
throw new Error(errorMessage);
|
|
112
|
+
}
|
|
113
|
+
static createWebSocket(url, protocols) {
|
|
114
|
+
const WS = this.getWebSocketConstructor();
|
|
115
|
+
return new WS(url, protocols);
|
|
116
|
+
}
|
|
117
|
+
static isWebSocketSupported() {
|
|
118
|
+
try {
|
|
119
|
+
const env = this.detectEnvironment();
|
|
120
|
+
return env.type === 'native' || env.type === 'ws';
|
|
121
|
+
}
|
|
122
|
+
catch (_a) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export default WebSocketFactory;
|
|
128
|
+
//# sourceMappingURL=websocket-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-factory.js","sourceRoot":"","sources":["../../../src/lib/websocket-factory.ts"],"names":[],"mappings":"AAkCA,MAAM,OAAO,gBAAgB;IAC3B;;;;OAIG;IACK,MAAM,CAAC,cAAc,CAAC,QAAgB;QAC5C,IAAI,CAAC;YACH,gDAAgD;YAChD,IACE,OAAO,OAAO,KAAK,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,IAAI,KAAK,IAAI,CAAA;QACnD,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;CACF;AAED,eAAe,gBAAgB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supabase/realtime-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"description": "Listen to realtime updates to your PostgreSQL database",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"realtime",
|
|
@@ -40,9 +40,8 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@supabase/node-fetch": "^2.6.13",
|
|
42
42
|
"@types/phoenix": "^1.6.6",
|
|
43
|
-
"
|
|
44
|
-
"@types/ws": "^8.18.1"
|
|
45
|
-
"ws": "^8.18.2"
|
|
43
|
+
"ws": "^8.18.2",
|
|
44
|
+
"@types/ws": "^8.18.1"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
47
|
"@arethetypeswrong/cli": "^0.16.4",
|
package/src/RealtimeChannel.ts
CHANGED
|
@@ -198,6 +198,15 @@ export default class RealtimeChannel {
|
|
|
198
198
|
this.state = CHANNEL_STATES.errored
|
|
199
199
|
this.rejoinTimer.scheduleTimeout()
|
|
200
200
|
})
|
|
201
|
+
|
|
202
|
+
this.joinPush.receive('error', (reason: any) => {
|
|
203
|
+
if (this._isLeaving() || this._isClosed()) {
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
this.socket.log('channel', `error ${this.topic}`, reason)
|
|
207
|
+
this.state = CHANNEL_STATES.errored
|
|
208
|
+
this.rejoinTimer.scheduleTimeout()
|
|
209
|
+
})
|
|
201
210
|
this._on(CHANNEL_EVENTS.reply, {}, (payload: any, ref: string) => {
|
|
202
211
|
this._trigger(this._replyEventName(ref), payload)
|
|
203
212
|
})
|
|
@@ -225,7 +234,9 @@ export default class RealtimeChannel {
|
|
|
225
234
|
const postgres_changes =
|
|
226
235
|
this.bindings.postgres_changes?.map((r) => r.filter) ?? []
|
|
227
236
|
|
|
228
|
-
const presence_enabled =
|
|
237
|
+
const presence_enabled =
|
|
238
|
+
!!this.bindings[REALTIME_LISTEN_TYPES.PRESENCE] &&
|
|
239
|
+
this.bindings[REALTIME_LISTEN_TYPES.PRESENCE].length > 0
|
|
229
240
|
const accessTokenPayload: { access_token?: string } = {}
|
|
230
241
|
const config = {
|
|
231
242
|
broadcast,
|