@supabase/realtime-js 1.6.2 → 1.7.2
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 +12 -3
- package/dist/main/RealtimeChannel.d.ts.map +1 -1
- package/dist/main/RealtimeChannel.js +18 -10
- package/dist/main/RealtimeChannel.js.map +1 -1
- package/dist/main/RealtimeClient.d.ts +28 -9
- package/dist/main/RealtimeClient.d.ts.map +1 -1
- package/dist/main/RealtimeClient.js +38 -26
- package/dist/main/RealtimeClient.js.map +1 -1
- package/dist/main/RealtimePresence.d.ts +12 -8
- package/dist/main/RealtimePresence.d.ts.map +1 -1
- package/dist/main/RealtimePresence.js +12 -8
- package/dist/main/RealtimePresence.js.map +1 -1
- package/dist/main/lib/constants.d.ts +6 -0
- package/dist/main/lib/constants.d.ts.map +1 -1
- package/dist/main/lib/constants.js +8 -1
- package/dist/main/lib/constants.js.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/module/RealtimeChannel.d.ts +12 -3
- package/dist/module/RealtimeChannel.d.ts.map +1 -1
- package/dist/module/RealtimeChannel.js +18 -10
- package/dist/module/RealtimeChannel.js.map +1 -1
- package/dist/module/RealtimeClient.d.ts +28 -9
- package/dist/module/RealtimeClient.d.ts.map +1 -1
- package/dist/module/RealtimeClient.js +39 -27
- package/dist/module/RealtimeClient.js.map +1 -1
- package/dist/module/RealtimePresence.d.ts +12 -8
- package/dist/module/RealtimePresence.d.ts.map +1 -1
- package/dist/module/RealtimePresence.js +12 -8
- package/dist/module/RealtimePresence.js.map +1 -1
- package/dist/module/lib/constants.d.ts +6 -0
- package/dist/module/lib/constants.d.ts.map +1 -1
- package/dist/module/lib/constants.js +7 -0
- package/dist/module/lib/constants.js.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/RealtimeChannel.ts +29 -25
- package/src/RealtimeClient.ts +58 -34
- package/src/RealtimePresence.ts +12 -8
- package/src/lib/constants.ts +7 -0
- package/src/lib/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealtimePresence.js","sourceRoot":"","sources":["../../src/RealtimePresence.ts"],"names":[],"mappings":"AAAA;;;EAGE;AAuCF,MAAM,CAAC,OAAO,OAAO,gBAAgB;IAcnC
|
|
1
|
+
{"version":3,"file":"RealtimePresence.js","sourceRoot":"","sources":["../../src/RealtimePresence.ts"],"names":[],"mappings":"AAAA;;;EAGE;AAuCF,MAAM,CAAC,OAAO,OAAO,gBAAgB;IAcnC;;;;;;OAMG;IACH,YAAmB,OAAwB,EAAE,IAAmB;QAA7C,YAAO,GAAP,OAAO,CAAiB;QApB3C,UAAK,GAAkB,EAAE,CAAA;QACzB,iBAAY,GAAsB,EAAE,CAAA;QACpC,YAAO,GAAkB,IAAI,CAAA;QAC7B,WAAM,GAIF;YACF,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;YAChB,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;YACjB,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;SACjB,CAAA;QAUC,MAAM,MAAM,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,KAAI;YAC7B,KAAK,EAAE,gBAAgB;YACvB,IAAI,EAAE,eAAe;SACtB,CAAA;QAED,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,QAA0B,EAAE,EAAE;YAC/D,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;YAE/C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAA;YAErC,IAAI,CAAC,KAAK,GAAG,gBAAgB,CAAC,SAAS,CACrC,IAAI,CAAC,KAAK,EACV,QAAQ,EACR,M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,CAAC,CAAA;IACjD,CAAC;IAEO,kBAAkB;QACxB,OAAO,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAA;IACjE,CAAC;CACF"}
|
|
@@ -28,4 +28,10 @@ export declare enum CHANNEL_EVENTS {
|
|
|
28
28
|
export declare enum TRANSPORTS {
|
|
29
29
|
websocket = "websocket"
|
|
30
30
|
}
|
|
31
|
+
export declare enum CONNECTION_STATE {
|
|
32
|
+
Connecting = "connecting",
|
|
33
|
+
Open = "open",
|
|
34
|
+
Closing = "closing",
|
|
35
|
+
Closed = "closed"
|
|
36
|
+
}
|
|
31
37
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;CAAgD,CAAA;AAE5E,eAAO,MAAM,GAAG,EAAE,MAAgB,CAAA;AAElC,eAAO,MAAM,eAAe,QAAQ,CAAA;AAEpC,eAAO,MAAM,eAAe,OAAO,CAAA;AAEnC,oBAAY,aAAa;IACvB,UAAU,IAAI;IACd,IAAI,IAAI;IACR,OAAO,IAAI;IACX,MAAM,IAAI;CACX;AAED,oBAAY,cAAc;IACxB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,oBAAY,cAAc;IACxB,KAAK,cAAc;IACnB,KAAK,cAAc;IACnB,IAAI,aAAa;IACjB,KAAK,cAAc;IACnB,KAAK,cAAc;IACnB,YAAY,iBAAiB;CAC9B;AAED,oBAAY,UAAU;IACpB,SAAS,cAAc;CACxB"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;CAAgD,CAAA;AAE5E,eAAO,MAAM,GAAG,EAAE,MAAgB,CAAA;AAElC,eAAO,MAAM,eAAe,QAAQ,CAAA;AAEpC,eAAO,MAAM,eAAe,OAAO,CAAA;AAEnC,oBAAY,aAAa;IACvB,UAAU,IAAI;IACd,IAAI,IAAI;IACR,OAAO,IAAI;IACX,MAAM,IAAI;CACX;AAED,oBAAY,cAAc;IACxB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,oBAAY,cAAc;IACxB,KAAK,cAAc;IACnB,KAAK,cAAc;IACnB,IAAI,aAAa;IACjB,KAAK,cAAc;IACnB,KAAK,cAAc;IACnB,YAAY,iBAAiB;CAC9B;AAED,oBAAY,UAAU;IACpB,SAAS,cAAc;CACxB;AAED,oBAAY,gBAAgB;IAC1B,UAAU,eAAe;IACzB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB"}
|
|
@@ -31,4 +31,11 @@ export var TRANSPORTS;
|
|
|
31
31
|
(function (TRANSPORTS) {
|
|
32
32
|
TRANSPORTS["websocket"] = "websocket";
|
|
33
33
|
})(TRANSPORTS || (TRANSPORTS = {}));
|
|
34
|
+
export var CONNECTION_STATE;
|
|
35
|
+
(function (CONNECTION_STATE) {
|
|
36
|
+
CONNECTION_STATE["Connecting"] = "connecting";
|
|
37
|
+
CONNECTION_STATE["Open"] = "open";
|
|
38
|
+
CONNECTION_STATE["Closing"] = "closing";
|
|
39
|
+
CONNECTION_STATE["Closed"] = "closed";
|
|
40
|
+
})(CONNECTION_STATE || (CONNECTION_STATE = {}));
|
|
34
41
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,CAAC,MAAM,eAAe,GAAG,E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AAEnC,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,6DAAc,CAAA;IACd,iDAAQ,CAAA;IACR,uDAAW,CAAA;IACX,qDAAU,CAAA;AACZ,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB;AAED,MAAM,CAAN,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,mCAAiB,CAAA;IACjB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;IACjB,qCAAmB,CAAA;IACnB,qCAAmB,CAAA;AACrB,CAAC,EANW,cAAc,KAAd,cAAc,QAMzB;AAED,MAAM,CAAN,IAAY,cAOX;AAPD,WAAY,cAAc;IACxB,qCAAmB,CAAA;IACnB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;IACjB,qCAAmB,CAAA;IACnB,qCAAmB,CAAA;IACnB,+CAA6B,CAAA;AAC/B,CAAC,EAPW,cAAc,KAAd,cAAc,QAOzB;AAED,MAAM,CAAN,IAAY,UAEX;AAFD,WAAY,UAAU;IACpB,qCAAuB,CAAA;AACzB,CAAC,EAFW,UAAU,KAAV,UAAU,QAErB;AAED,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,6CAAyB,CAAA;IACzB,iCAAa,CAAA;IACb,uCAAmB,CAAA;IACnB,qCAAiB,CAAA;AACnB,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.7.2";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '1.
|
|
1
|
+
export const version = '1.7.2';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
package/src/RealtimeChannel.ts
CHANGED
|
@@ -108,36 +108,40 @@ export default class RealtimeChannel {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Registers a callback that will be executed when the channel closes.
|
|
113
|
+
*/
|
|
111
114
|
onClose(callback: Function) {
|
|
112
115
|
this.on(CHANNEL_EVENTS.close, {}, callback)
|
|
113
116
|
}
|
|
114
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Registers a callback that will be executed when the channel encounteres an error.
|
|
120
|
+
*/
|
|
115
121
|
onError(callback: Function) {
|
|
116
122
|
this.on(CHANNEL_EVENTS.error, {}, (reason: string) => callback(reason))
|
|
117
123
|
}
|
|
118
124
|
|
|
119
|
-
on(
|
|
120
|
-
type: string,
|
|
121
|
-
eventFilter?: { [key: string]: string },
|
|
122
|
-
callback?: Function
|
|
123
|
-
) {
|
|
125
|
+
on(type: string, filter?: { [key: string]: string }, callback?: Function) {
|
|
124
126
|
this.bindings.push({
|
|
125
127
|
type,
|
|
126
|
-
|
|
128
|
+
filter: filter ?? {},
|
|
127
129
|
callback: callback ?? (() => {}),
|
|
128
130
|
})
|
|
129
131
|
}
|
|
130
132
|
|
|
131
|
-
off(type: string,
|
|
133
|
+
off(type: string, filter: { [key: string]: any }) {
|
|
132
134
|
this.bindings = this.bindings.filter((bind) => {
|
|
133
135
|
return !(
|
|
134
|
-
bind.type === type &&
|
|
135
|
-
RealtimeChannel.isEqual(bind.eventFilter, eventFilter)
|
|
136
|
+
bind.type === type && RealtimeChannel.isEqual(bind.filter, filter)
|
|
136
137
|
)
|
|
137
138
|
})
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Returns `true` if the socket is connected and the channel has been joined.
|
|
143
|
+
*/
|
|
144
|
+
canPush(): boolean {
|
|
141
145
|
return this.socket.isConnected() && this.isJoined()
|
|
142
146
|
}
|
|
143
147
|
|
|
@@ -161,7 +165,7 @@ export default class RealtimeChannel {
|
|
|
161
165
|
}
|
|
162
166
|
|
|
163
167
|
/**
|
|
164
|
-
* Leaves the channel
|
|
168
|
+
* Leaves the channel.
|
|
165
169
|
*
|
|
166
170
|
* Unsubscribes from server events, and instructs channel to terminate on server.
|
|
167
171
|
* Triggers onClose() hooks.
|
|
@@ -169,16 +173,16 @@ export default class RealtimeChannel {
|
|
|
169
173
|
* To receive leave acknowledgements, use the a `receive` hook to bind to the server ack, ie:
|
|
170
174
|
* channel.unsubscribe().receive("ok", () => alert("left!") )
|
|
171
175
|
*/
|
|
172
|
-
unsubscribe(timeout = this.timeout) {
|
|
176
|
+
unsubscribe(timeout = this.timeout): Push {
|
|
173
177
|
this.state = CHANNEL_STATES.leaving
|
|
174
|
-
|
|
178
|
+
const onClose = () => {
|
|
175
179
|
this.socket.log('channel', `leave ${this.topic}`)
|
|
176
180
|
this.trigger(CHANNEL_EVENTS.close, 'leave', this.joinRef())
|
|
177
181
|
}
|
|
178
182
|
// Destroy joinPush to avoid connection timeouts during unscription phase
|
|
179
183
|
this.joinPush.destroy()
|
|
180
184
|
|
|
181
|
-
|
|
185
|
+
const leavePush = new Push(this, CHANNEL_EVENTS.leave, {}, timeout)
|
|
182
186
|
leavePush.receive('ok', () => onClose()).receive('timeout', () => onClose())
|
|
183
187
|
leavePush.send()
|
|
184
188
|
if (!this.canPush()) {
|
|
@@ -198,15 +202,15 @@ export default class RealtimeChannel {
|
|
|
198
202
|
return payload
|
|
199
203
|
}
|
|
200
204
|
|
|
201
|
-
isMember(topic: string) {
|
|
205
|
+
isMember(topic: string): boolean {
|
|
202
206
|
return this.topic === topic
|
|
203
207
|
}
|
|
204
208
|
|
|
205
|
-
joinRef() {
|
|
209
|
+
joinRef(): string {
|
|
206
210
|
return this.joinPush.ref
|
|
207
211
|
}
|
|
208
212
|
|
|
209
|
-
rejoin(timeout = this.timeout) {
|
|
213
|
+
rejoin(timeout = this.timeout): void {
|
|
210
214
|
if (this.isLeaving()) {
|
|
211
215
|
return
|
|
212
216
|
}
|
|
@@ -230,8 +234,8 @@ export default class RealtimeChannel {
|
|
|
230
234
|
.filter((bind) => {
|
|
231
235
|
return (
|
|
232
236
|
bind?.type === type &&
|
|
233
|
-
(bind?.
|
|
234
|
-
bind?.
|
|
237
|
+
(bind?.filter?.event === '*' ||
|
|
238
|
+
bind?.filter?.event === payload?.event)
|
|
235
239
|
)
|
|
236
240
|
})
|
|
237
241
|
.map((bind) => bind.callback(handledPayload, ref))
|
|
@@ -246,23 +250,23 @@ export default class RealtimeChannel {
|
|
|
246
250
|
})
|
|
247
251
|
}
|
|
248
252
|
|
|
249
|
-
replyEventName(ref: string) {
|
|
253
|
+
replyEventName(ref: string): string {
|
|
250
254
|
return `chan_reply_${ref}`
|
|
251
255
|
}
|
|
252
256
|
|
|
253
|
-
isClosed() {
|
|
257
|
+
isClosed(): boolean {
|
|
254
258
|
return this.state === CHANNEL_STATES.closed
|
|
255
259
|
}
|
|
256
|
-
isErrored() {
|
|
260
|
+
isErrored(): boolean {
|
|
257
261
|
return this.state === CHANNEL_STATES.errored
|
|
258
262
|
}
|
|
259
|
-
isJoined() {
|
|
263
|
+
isJoined(): boolean {
|
|
260
264
|
return this.state === CHANNEL_STATES.joined
|
|
261
265
|
}
|
|
262
|
-
isJoining() {
|
|
266
|
+
isJoining(): boolean {
|
|
263
267
|
return this.state === CHANNEL_STATES.joining
|
|
264
268
|
}
|
|
265
|
-
isLeaving() {
|
|
269
|
+
isLeaving(): boolean {
|
|
266
270
|
return this.state === CHANNEL_STATES.leaving
|
|
267
271
|
}
|
|
268
272
|
|
package/src/RealtimeClient.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
DEFAULT_TIMEOUT,
|
|
8
8
|
WS_CLOSE_NORMAL,
|
|
9
9
|
DEFAULT_HEADERS,
|
|
10
|
+
CONNECTION_STATE,
|
|
10
11
|
} from './lib/constants'
|
|
11
12
|
import Timer from './lib/timer'
|
|
12
13
|
import Serializer from './lib/serializer'
|
|
@@ -32,6 +33,11 @@ type Message = {
|
|
|
32
33
|
ref: string
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
type ChannelParams = {
|
|
37
|
+
selfBroadcast?: boolean
|
|
38
|
+
[key: string]: any
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
const noop = () => {}
|
|
36
42
|
|
|
37
43
|
export default class RealtimeClient {
|
|
@@ -68,7 +74,7 @@ export default class RealtimeClient {
|
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
/**
|
|
71
|
-
* Initializes the Socket
|
|
77
|
+
* Initializes the Socket.
|
|
72
78
|
*
|
|
73
79
|
* @param endPoint The string WebSocket endpoint, ie, "ws://example.com/socket", "wss://example.com", "/socket" (inherited host & protocol)
|
|
74
80
|
* @param options.transport The Websocket Transport, for example WebSocket.
|
|
@@ -115,14 +121,15 @@ export default class RealtimeClient {
|
|
|
115
121
|
}
|
|
116
122
|
|
|
117
123
|
/**
|
|
118
|
-
* Connects the socket.
|
|
124
|
+
* Connects the socket, unless already connected.
|
|
119
125
|
*/
|
|
120
|
-
connect() {
|
|
126
|
+
connect(): void {
|
|
121
127
|
if (this.conn) {
|
|
122
128
|
return
|
|
123
129
|
}
|
|
124
130
|
|
|
125
131
|
this.conn = new this.transport(this.endPointURL(), [], null, this.headers)
|
|
132
|
+
|
|
126
133
|
if (this.conn) {
|
|
127
134
|
// this.conn.timeout = this.longpollerTimeout // TYPE ERROR
|
|
128
135
|
this.conn.binaryType = 'arraybuffer'
|
|
@@ -165,7 +172,9 @@ export default class RealtimeClient {
|
|
|
165
172
|
}
|
|
166
173
|
|
|
167
174
|
/**
|
|
168
|
-
* Logs the message.
|
|
175
|
+
* Logs the message.
|
|
176
|
+
*
|
|
177
|
+
* For customized logging, `this.logger` can be overriden.
|
|
169
178
|
*/
|
|
170
179
|
log(kind: string, msg: string, data?: any) {
|
|
171
180
|
this.logger(kind, msg, data)
|
|
@@ -173,6 +182,7 @@ export default class RealtimeClient {
|
|
|
173
182
|
|
|
174
183
|
/**
|
|
175
184
|
* Registers a callback for connection state change event.
|
|
185
|
+
*
|
|
176
186
|
* @param callback A function to be called when the event occurs.
|
|
177
187
|
*
|
|
178
188
|
* @example
|
|
@@ -183,7 +193,8 @@ export default class RealtimeClient {
|
|
|
183
193
|
}
|
|
184
194
|
|
|
185
195
|
/**
|
|
186
|
-
* Registers a
|
|
196
|
+
* Registers a callback for connection state change events.
|
|
197
|
+
*
|
|
187
198
|
* @param callback A function to be called when the event occurs.
|
|
188
199
|
*
|
|
189
200
|
* @example
|
|
@@ -195,6 +206,7 @@ export default class RealtimeClient {
|
|
|
195
206
|
|
|
196
207
|
/**
|
|
197
208
|
* Registers a callback for connection state change events.
|
|
209
|
+
*
|
|
198
210
|
* @param callback A function to be called when the event occurs.
|
|
199
211
|
*
|
|
200
212
|
* @example
|
|
@@ -206,6 +218,7 @@ export default class RealtimeClient {
|
|
|
206
218
|
|
|
207
219
|
/**
|
|
208
220
|
* Calls a function any time a message is received.
|
|
221
|
+
*
|
|
209
222
|
* @param callback A function to be called when the event occurs.
|
|
210
223
|
*
|
|
211
224
|
* @example
|
|
@@ -218,24 +231,24 @@ export default class RealtimeClient {
|
|
|
218
231
|
/**
|
|
219
232
|
* Returns the current state of the socket.
|
|
220
233
|
*/
|
|
221
|
-
connectionState() {
|
|
234
|
+
connectionState(): CONNECTION_STATE {
|
|
222
235
|
switch (this.conn && this.conn.readyState) {
|
|
223
236
|
case SOCKET_STATES.connecting:
|
|
224
|
-
return
|
|
237
|
+
return CONNECTION_STATE.Connecting
|
|
225
238
|
case SOCKET_STATES.open:
|
|
226
|
-
return
|
|
239
|
+
return CONNECTION_STATE.Open
|
|
227
240
|
case SOCKET_STATES.closing:
|
|
228
|
-
return
|
|
241
|
+
return CONNECTION_STATE.Closing
|
|
229
242
|
default:
|
|
230
|
-
return
|
|
243
|
+
return CONNECTION_STATE.Closed
|
|
231
244
|
}
|
|
232
245
|
}
|
|
233
246
|
|
|
234
247
|
/**
|
|
235
248
|
* Retuns `true` is the connection is open.
|
|
236
249
|
*/
|
|
237
|
-
isConnected() {
|
|
238
|
-
return this.connectionState() ===
|
|
250
|
+
isConnected(): boolean {
|
|
251
|
+
return this.connectionState() === CONNECTION_STATE.Open
|
|
239
252
|
}
|
|
240
253
|
|
|
241
254
|
/**
|
|
@@ -252,13 +265,17 @@ export default class RealtimeClient {
|
|
|
252
265
|
|
|
253
266
|
channel(
|
|
254
267
|
topic: string,
|
|
255
|
-
chanParams:
|
|
256
|
-
) {
|
|
257
|
-
const {
|
|
268
|
+
chanParams: ChannelParams = {}
|
|
269
|
+
): RealtimeChannel | RealtimeSubscription {
|
|
270
|
+
const { selfBroadcast, ...params } = chanParams
|
|
271
|
+
|
|
272
|
+
if (selfBroadcast) {
|
|
273
|
+
params.self_broadcast = selfBroadcast
|
|
274
|
+
}
|
|
258
275
|
|
|
259
|
-
const chan =
|
|
260
|
-
? new RealtimeChannel(topic,
|
|
261
|
-
: new RealtimeSubscription(topic,
|
|
276
|
+
const chan = this.params?.vsndate
|
|
277
|
+
? new RealtimeChannel(topic, params, this)
|
|
278
|
+
: new RealtimeSubscription(topic, params, this)
|
|
262
279
|
|
|
263
280
|
if (chan instanceof RealtimeChannel) {
|
|
264
281
|
chan.presence.onJoin((key, currentPresences, newPresences) => {
|
|
@@ -288,8 +305,13 @@ export default class RealtimeClient {
|
|
|
288
305
|
return chan
|
|
289
306
|
}
|
|
290
307
|
|
|
291
|
-
|
|
292
|
-
|
|
308
|
+
/**
|
|
309
|
+
* Push out a message if the socket is connected.
|
|
310
|
+
*
|
|
311
|
+
* If the socket is not connected, the message gets enqueued within a local buffer, and sent out when a connection is next established.
|
|
312
|
+
*/
|
|
313
|
+
push(data: Message): void {
|
|
314
|
+
const { topic, event, payload, ref } = data
|
|
293
315
|
let callback = () => {
|
|
294
316
|
this.encode(data, (result: any) => {
|
|
295
317
|
this.conn?.send(result)
|
|
@@ -303,7 +325,7 @@ export default class RealtimeClient {
|
|
|
303
325
|
}
|
|
304
326
|
}
|
|
305
327
|
|
|
306
|
-
onConnMessage(rawMessage: any) {
|
|
328
|
+
onConnMessage(rawMessage: { data: any }) {
|
|
307
329
|
this.decode(rawMessage.data, (msg: Message) => {
|
|
308
330
|
let { topic, event, payload, ref } = msg
|
|
309
331
|
|
|
@@ -335,7 +357,7 @@ export default class RealtimeClient {
|
|
|
335
357
|
/**
|
|
336
358
|
* Returns the URL of the websocket.
|
|
337
359
|
*/
|
|
338
|
-
endPointURL() {
|
|
360
|
+
endPointURL(): string {
|
|
339
361
|
return this._appendParams(
|
|
340
362
|
this.endPoint,
|
|
341
363
|
Object.assign({}, this.params, { vsn: VSN })
|
|
@@ -345,7 +367,7 @@ export default class RealtimeClient {
|
|
|
345
367
|
/**
|
|
346
368
|
* Return the next message ref, accounting for overflows
|
|
347
369
|
*/
|
|
348
|
-
makeRef() {
|
|
370
|
+
makeRef(): string {
|
|
349
371
|
let newRef = this.ref + 1
|
|
350
372
|
if (newRef === this.ref) {
|
|
351
373
|
this.ref = 0
|
|
@@ -364,19 +386,18 @@ export default class RealtimeClient {
|
|
|
364
386
|
setAuth(token: string | null) {
|
|
365
387
|
this.accessToken = token
|
|
366
388
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
token && channel.updateJoinPayload({ user_token: token })
|
|
389
|
+
this.channels.forEach((channel) => {
|
|
390
|
+
token && channel.updateJoinPayload({ user_token: token })
|
|
370
391
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
} catch (error) {
|
|
376
|
-
console.log('setAuth error', error)
|
|
377
|
-
}
|
|
392
|
+
if (channel.joinedOnce && channel.isJoined()) {
|
|
393
|
+
channel.push(CHANNEL_EVENTS.access_token, { access_token: token })
|
|
394
|
+
}
|
|
395
|
+
})
|
|
378
396
|
}
|
|
379
397
|
|
|
398
|
+
/**
|
|
399
|
+
* Unsubscribe from channels with the specified topic.
|
|
400
|
+
*/
|
|
380
401
|
leaveOpenTopic(topic: string): void {
|
|
381
402
|
let dupChannel = this.channels.find(
|
|
382
403
|
(c) => c.topic === topic && (c.isJoined() || c.isJoining())
|
|
@@ -419,7 +440,10 @@ export default class RealtimeClient {
|
|
|
419
440
|
)
|
|
420
441
|
}
|
|
421
442
|
|
|
422
|
-
private _appendParams(
|
|
443
|
+
private _appendParams(
|
|
444
|
+
url: string,
|
|
445
|
+
params: { [key: string]: string }
|
|
446
|
+
): string {
|
|
423
447
|
if (Object.keys(params).length === 0) {
|
|
424
448
|
return url
|
|
425
449
|
}
|
package/src/RealtimePresence.ts
CHANGED
|
@@ -55,7 +55,8 @@ export default class RealtimePresence {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* Initializes the Presence
|
|
58
|
+
* Initializes the Presence.
|
|
59
|
+
*
|
|
59
60
|
* @param channel - The RealtimeSubscription
|
|
60
61
|
* @param opts - The options,
|
|
61
62
|
* for example `{events: {state: 'state', diff: 'diff'}}`
|
|
@@ -111,9 +112,11 @@ export default class RealtimePresence {
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
/**
|
|
114
|
-
* Used to sync the list of presences on the server
|
|
115
|
-
*
|
|
116
|
-
*
|
|
115
|
+
* Used to sync the list of presences on the server with the
|
|
116
|
+
* client's state.
|
|
117
|
+
*
|
|
118
|
+
* An optional `onJoin` and `onLeave` callback can be provided to
|
|
119
|
+
* react to changes in the client's local presences across
|
|
117
120
|
* disconnects and reconnects with the server.
|
|
118
121
|
*/
|
|
119
122
|
static syncState(
|
|
@@ -164,11 +167,12 @@ export default class RealtimePresence {
|
|
|
164
167
|
}
|
|
165
168
|
|
|
166
169
|
/**
|
|
170
|
+
* Used to sync a diff of presence join and leave events from the
|
|
171
|
+
* server, as they happen.
|
|
167
172
|
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
* joining or leaving from a device.
|
|
173
|
+
* Like `syncState`, `syncDiff` accepts optional `onJoin` and
|
|
174
|
+
* `onLeave` callbacks to react to a user joining or leaving from a
|
|
175
|
+
* device.
|
|
172
176
|
*/
|
|
173
177
|
static syncDiff(
|
|
174
178
|
state: PresenceState,
|
package/src/lib/constants.ts
CHANGED
package/src/lib/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.
|
|
1
|
+
export const version = '1.7.2'
|