@signalwire/js 3.6.0 → 3.7.0-dev.202201061621.3f851e2.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.
Files changed (72) hide show
  1. package/dist/core/src/BaseComponent.d.ts +3 -3
  2. package/dist/core/src/chat/BaseChat.d.ts +4 -4
  3. package/dist/core/src/chat/BaseChat.d.ts.map +1 -1
  4. package/dist/core/src/chat/ChatMember.d.ts +9 -0
  5. package/dist/core/src/chat/ChatMember.d.ts.map +1 -0
  6. package/dist/core/src/chat/ChatMessage.d.ts +2 -2
  7. package/dist/core/src/chat/ChatMessage.d.ts.map +1 -1
  8. package/dist/core/src/chat/methods.d.ts +14 -0
  9. package/dist/core/src/chat/methods.d.ts.map +1 -1
  10. package/dist/core/src/chat/utils/index.d.ts +3 -0
  11. package/dist/core/src/chat/utils/index.d.ts.map +1 -0
  12. package/dist/core/src/chat/utils/toInternalChatChannels.d.ts +3 -0
  13. package/dist/core/src/chat/utils/toInternalChatChannels.d.ts.map +1 -0
  14. package/dist/core/src/chat/utils/toInternalChatChannels.test.d.ts +2 -0
  15. package/dist/core/src/chat/utils/toInternalChatChannels.test.d.ts.map +1 -0
  16. package/dist/core/src/chat/workers.d.ts.map +1 -1
  17. package/dist/core/src/redux/connect.d.ts.map +1 -1
  18. package/dist/core/src/redux/features/component/componentSaga.d.ts +4 -0
  19. package/dist/core/src/redux/features/component/componentSaga.d.ts.map +1 -0
  20. package/dist/core/src/redux/features/component/componentSaga.test.d.ts +2 -0
  21. package/dist/core/src/redux/features/component/componentSaga.test.d.ts.map +1 -0
  22. package/dist/core/src/redux/features/component/componentSelectors.d.ts +6 -2
  23. package/dist/core/src/redux/features/component/componentSelectors.d.ts.map +1 -1
  24. package/dist/core/src/redux/features/component/componentSelectors.test.d.ts +2 -0
  25. package/dist/core/src/redux/features/component/componentSelectors.test.d.ts.map +1 -0
  26. package/dist/core/src/redux/features/component/componentSlice.d.ts +4 -0
  27. package/dist/core/src/redux/features/component/componentSlice.d.ts.map +1 -1
  28. package/dist/core/src/redux/features/session/sessionSaga.d.ts.map +1 -1
  29. package/dist/core/src/redux/index.d.ts +4 -4
  30. package/dist/core/src/redux/index.d.ts.map +1 -1
  31. package/dist/core/src/redux/interfaces.d.ts +1 -0
  32. package/dist/core/src/redux/interfaces.d.ts.map +1 -1
  33. package/dist/core/src/redux/rootSaga.d.ts +1 -1
  34. package/dist/core/src/redux/rootSaga.d.ts.map +1 -1
  35. package/dist/core/src/testUtils.d.ts +4 -3
  36. package/dist/core/src/testUtils.d.ts.map +1 -1
  37. package/dist/core/src/types/chat.d.ts +85 -17
  38. package/dist/core/src/types/chat.d.ts.map +1 -1
  39. package/dist/core/src/types/index.d.ts +2 -0
  40. package/dist/core/src/types/index.d.ts.map +1 -1
  41. package/dist/core/src/types/utils.d.ts +8 -4
  42. package/dist/core/src/types/utils.d.ts.map +1 -1
  43. package/dist/core/src/types/videoRoomSession.d.ts +4 -1
  44. package/dist/core/src/types/videoRoomSession.d.ts.map +1 -1
  45. package/dist/index.esm.js +6 -8
  46. package/dist/index.esm.js.map +2 -2
  47. package/dist/index.js +36 -35
  48. package/dist/index.js.map +2 -2
  49. package/dist/index.umd.js +3 -3
  50. package/dist/index.umd.js.map +1 -1
  51. package/dist/js/src/JWTSession.d.ts.map +1 -1
  52. package/dist/js/src/RoomSession.docs.d.ts +5 -0
  53. package/dist/js/src/RoomSession.docs.d.ts.map +1 -1
  54. package/dist/js/src/RoomSessionDevice.docs.d.ts +2 -0
  55. package/dist/js/src/RoomSessionDevice.docs.d.ts.map +1 -1
  56. package/dist/js/src/RoomSessionScreenShare.docs.d.ts +2 -0
  57. package/dist/js/src/RoomSessionScreenShare.docs.d.ts.map +1 -1
  58. package/dist/js/src/createClient.d.ts +1 -21
  59. package/dist/js/src/createClient.d.ts.map +1 -1
  60. package/dist/js/src/testUtils.d.ts +4 -4
  61. package/dist/js/tsconfig.build.tsbuildinfo +1 -1
  62. package/dist/webrtc/src/BaseConnection.d.ts +2 -0
  63. package/dist/webrtc/src/BaseConnection.d.ts.map +1 -1
  64. package/dist/webrtc/src/utils/webrtcHelpers.native.d.ts +2 -2
  65. package/dist/webrtc/src/utils/webrtcHelpers.native.d.ts.map +1 -1
  66. package/package.json +3 -3
  67. package/src/RoomSession.docs.ts +6 -0
  68. package/src/RoomSessionDevice.docs.ts +3 -0
  69. package/src/RoomSessionScreenShare.docs.ts +3 -0
  70. package/src/chat/Chat.test.ts +413 -26
  71. package/src/createClient.ts +1 -21
  72. package/src/utils/constants.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"BaseConnection.d.ts","sourceRoot":"","sources":["../../../../webrtc/src/BaseConnection.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,aAAa,EAEb,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,EACL,cAAc,EACd,YAAY,EACZ,sBAAsB,EACvB,MAAM,kBAAkB,CAAA;AACzB,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAqBtD,aAAK,oBAAoB,GAAG,MAAM,CAAC,mBAAmB,EAAE,MAAM,IAAI,CAAC,GACjE,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,CAAA;AAE5B,oBAAY,6BAA6B,GAAG;KACzC,CAAC,IAAI,mBAAmB,GAAG,oBAAoB,CAAC,CAAC,CAAC;CACpD,CAAA;AAED,oBAAY,qBAAqB,CAC/B,UAAU,SAAS,YAAY,CAAC,eAAe,IAC7C,iBAAiB,GACnB,oBAAoB,CAAC,UAAU,GAAG,6BAA6B,CAAC,CAAA;AAElE,qBAAa,cAAc,CAAC,UAAU,SAAS,YAAY,CAAC,eAAe,CACzE,SAAQ,aAAa,CAAC,UAAU,GAAG,6BAA6B,CAChE,YACE,KAAK,CAAC,iBAAiB,CAAC,UAAU,GAAG,6BAA6B,CAAC,EACnE,sBAAsB,CAAC,UAAU,GAAG,6BAA6B,C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;IAChB,oBAAoB;IAMpB,gBAAgB;IAChB,iBAAiB;IAMjB,gBAAgB;IAChB,oBAAoB;IAMpB,gBAAgB;IAChB,QAAQ,CAAC,KAAK,EAAE,mBAAmB;IAyBnC,gBAAgB;IAChB,OAAO,CAAC,OAAO;IAgBf,gBAAgB;IAChB,SAAS,CAAC,SAAS;CAWpB"}
@@ -5,10 +5,10 @@ export declare const supportsGetUserMedia: () => boolean;
5
5
  export declare const supportsGetDisplayMedia: () => boolean;
6
6
  export declare const enumerateDevices: () => any;
7
7
  export declare const enumerateDevicesByKind: (filterByKind: string) => Promise<MediaDeviceInfo[]>;
8
- export declare const streamIsValid: (stream: any) => any;
8
+ export declare const streamIsValid: (stream: RNMediaStream) => any;
9
9
  export declare const getSupportedConstraints: () => {};
10
10
  export declare const setMediaElementSinkId: (_htmlElementId: string, _deviceId: string) => Promise<boolean>;
11
11
  export declare const sdpToJsonHack: (sdp: any) => any;
12
- export declare const stopStream: (stream: any) => void;
12
+ export declare const stopStream: (stream: RNMediaStream) => void;
13
13
  export declare const stopTrack: (track: MediaStreamTrack) => void;
14
14
  //# sourceMappingURL=webrtcHelpers.native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webrtcHelpers.native.d.ts","sourceRoot":"","sources":["../../../../../webrtc/src/utils/webrtcHelpers.native.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB,WAAY,gBAAgB,QAGzD,CAAA;AAED,eAAO,MAAM,YAAY,gBAAiB,sBAAsB,QAE/D,CAAA;AAED,eAAO,MAAM,eAAe,gBAAiB,sBAAsB,QAElE,CAAA;AAED,eAAO,MAAM,oBAAoB,eAEhC,CAAA;AAED,eAAO,MAAM,uBAAuB,eAEnC,CAAA;AAED,eAAO,MAAM,gBAAgB,WAA0C,CAAA;AAEvE,eAAO,MAAM,sBAAsB,iBAAwB,MAAM,+BAQhE,CAAA;AAED,eAAO,MAAM,aAAa,sBACiB,CAAA;AAE3C,eAAO,MAAM,uBAAuB,UAAa,CAAA;AAEjD,eAAO,MAAM,qBAAqB,mBAChB,MAAM,aACX,MAAM,KAChB,QAAQ,OAAO,CAA2B,CAAA;AAE7C,eAAO,MAAM,aAAa,QAAS,GAAG,QAGrC,CAAA;AAED,eAAO,MAAM,UAAU,uBAKtB,CAAA;AAED,eAAO,MAAM,SAAS,UAAW,gBAAgB,SAKhD,CAAA"}
1
+ {"version":3,"file":"webrtcHelpers.native.d.ts","sourceRoot":"","sources":["../../../../../webrtc/src/utils/webrtcHelpers.native.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB,WAAY,gBAAgB,QAGzD,CAAA;AAED,eAAO,MAAM,YAAY,gBAAiB,sBAAsB,QAE/D,CAAA;AAED,eAAO,MAAM,eAAe,gBAAiB,sBAAsB,QAElE,CAAA;AAED,eAAO,MAAM,oBAAoB,eAEhC,CAAA;AAED,eAAO,MAAM,uBAAuB,eAEnC,CAAA;AAED,eAAO,MAAM,gBAAgB,WAA0C,CAAA;AAEvE,eAAO,MAAM,sBAAsB,iBAAwB,MAAM,+BAQhE,CAAA;AAED,eAAO,MAAM,aAAa,gCACiB,CAAA;AAE3C,eAAO,MAAM,uBAAuB,UAAa,CAAA;AAEjD,eAAO,MAAM,qBAAqB,mBAChB,MAAM,aACX,MAAM,KAChB,QAAQ,OAAO,CAA2B,CAAA;AAE7C,eAAO,MAAM,aAAa,QAAS,GAAG,QAGrC,CAAA;AAED,eAAO,MAAM,UAAU,iCAKtB,CAAA;AAED,eAAO,MAAM,SAAS,UAAW,gBAAgB,SAKhD,CAAA"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "SignalWire JS SDK",
4
4
  "author": "SignalWire Team <open.source@signalwire.com>",
5
5
  "license": "MIT",
6
- "version": "3.6.0",
6
+ "version": "3.7.0-dev.202201061621.3f851e2.0",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.esm.js",
9
9
  "unpkg": "dist/index.umd.js",
@@ -43,8 +43,8 @@
43
43
  "prepublishOnly": "npm run build"
44
44
  },
45
45
  "dependencies": {
46
- "@signalwire/core": "3.4.0",
47
- "@signalwire/webrtc": "3.2.0"
46
+ "@signalwire/core": "3.4.1-dev.202201061621.3f851e2.0",
47
+ "@signalwire/webrtc": "3.3.0-dev.202201061621.3f851e2.0"
48
48
  },
49
49
  "types": "dist/js/src/index.d.ts"
50
50
  }
@@ -71,6 +71,12 @@ export interface RoomSessionDocs<T>
71
71
  /** Contains any local screen shares added to the room via {@link startScreenShare}. */
72
72
  readonly screenShareList: RoomSessionScreenShare[]
73
73
 
74
+ /**
75
+ * If the Room has been created with the property `enable_room_previews` set
76
+ * to `true`, this field contains the URL to the room preview.
77
+ */
78
+ readonly previewUrl?: string
79
+
74
80
  /**
75
81
  * Joins the room session.
76
82
  */
@@ -11,6 +11,9 @@ export interface RoomSessionDeviceDocs
11
11
  /** Detaches this device from the room session. */
12
12
  leave(): Promise<void>
13
13
 
14
+ /** @ignore */
15
+ readonly previewUrl?: string
16
+
14
17
  /**
15
18
  * Replaces the current camera stream with the one coming from a different
16
19
  * device.
@@ -11,6 +11,9 @@ export interface RoomSessionScreenShareDocs
11
11
  /** Detaches this device from the room session. */
12
12
  leave(): Promise<void>
13
13
 
14
+ /** @ignore */
15
+ readonly previewUrl?: string
16
+
14
17
  /**
15
18
  * Replaces the current camera stream with the one coming from a different
16
19
  * device.
@@ -4,6 +4,14 @@ import { Chat } from './Chat'
4
4
  describe('Chat Object', () => {
5
5
  const host = 'ws://localhost:1234'
6
6
  const token = '<jwt>'
7
+ const messages = [
8
+ {
9
+ id: '5fdc8fc5-b7fe-4fbd-8204-f2310dec2614',
10
+ sender_id: '1507e5f9-075c-463d-94ba-a8f9ec0c7d4e',
11
+ content: 'hello world',
12
+ published_at: 1641393396.153,
13
+ },
14
+ ]
7
15
 
8
16
  let server: WS
9
17
  beforeEach(async () => {
@@ -12,13 +20,96 @@ describe('Chat Object', () => {
12
20
  socket.on('message', (data: any) => {
13
21
  const parsedData = JSON.parse(data)
14
22
 
15
- socket.send(
16
- JSON.stringify({
17
- jsonrpc: '2.0',
18
- id: parsedData.id,
19
- result: {},
20
- })
21
- )
23
+ // The error message is not important for the test.
24
+ // The idea is just to document what's the expected
25
+ // behavior (reject) or not (resolve).
26
+ if (
27
+ parsedData.method === 'chat.unsubscribe' &&
28
+ (parsedData.params.channels.length === 0 ||
29
+ parsedData.params.channels.some((ch: any) =>
30
+ ch.name.endsWith('_error')
31
+ ))
32
+ ) {
33
+ socket.send(
34
+ JSON.stringify({
35
+ jsonrpc: '2.0',
36
+ id: parsedData.id,
37
+ error: { code: -32600, message: 'Invalid Request' },
38
+ })
39
+ )
40
+ } else if (parsedData.method === 'chat.messages.get') {
41
+ socket.send(
42
+ JSON.stringify({
43
+ jsonrpc: '2.0',
44
+ id: parsedData.id,
45
+ result: {
46
+ code: '200',
47
+ message: 'OK',
48
+ messages,
49
+ cursor: {
50
+ before: 'before',
51
+ after: 'after',
52
+ },
53
+ },
54
+ })
55
+ )
56
+ } else if (parsedData.method === 'chat.members.get') {
57
+ socket.send(
58
+ JSON.stringify({
59
+ jsonrpc: '2.0',
60
+ id: parsedData.id,
61
+ result: {
62
+ code: '200',
63
+ message: 'Success',
64
+ members: [
65
+ {
66
+ id: '1507e5f9-075c-463d-94ba-a8f9ec0c7d4e',
67
+ },
68
+ ],
69
+ },
70
+ })
71
+ )
72
+ } else if (parsedData.method === 'chat.presence.set_state') {
73
+ socket.send(
74
+ JSON.stringify({
75
+ jsonrpc: '2.0',
76
+ id: parsedData.id,
77
+ result: {
78
+ code: '200',
79
+ message: 'Success',
80
+ },
81
+ })
82
+ )
83
+ } else if (parsedData.method === 'chat.presence.get_state') {
84
+ socket.send(
85
+ JSON.stringify({
86
+ jsonrpc: '2.0',
87
+ id: parsedData.id,
88
+ result: {
89
+ code: '200',
90
+ message: 'Success',
91
+ channels: {
92
+ lobby: {
93
+ state: {
94
+ typing: true,
95
+ },
96
+ },
97
+ },
98
+ member: {
99
+ id: '1507e5f9-075c-463d-94ba-a8f9ec0c7d4e',
100
+ },
101
+ },
102
+ })
103
+ )
104
+ } else {
105
+ socket.send(
106
+ JSON.stringify({
107
+ jsonrpc: '2.0',
108
+ id: parsedData.id,
109
+ result: {},
110
+ })
111
+ )
112
+ }
22
113
  })
23
114
  })
24
115
  })
@@ -71,6 +162,191 @@ describe('Chat Object', () => {
71
162
  ).toBe(1)
72
163
  })
73
164
 
165
+ describe('message handler', () => {
166
+ it('should return a ChatMessage object', (done) => {
167
+ WS.clean()
168
+ server = new WS(host)
169
+ server.on('connection', (socket) => {
170
+ socket.on('message', (data: any) => {
171
+ const parsedData = JSON.parse(data)
172
+ socket.send(
173
+ JSON.stringify({
174
+ jsonrpc: '2.0',
175
+ id: parsedData.id,
176
+ result: {},
177
+ })
178
+ )
179
+
180
+ if (parsedData.method === 'chat.subscribe') {
181
+ socket.send(
182
+ JSON.stringify({
183
+ jsonrpc: '2.0',
184
+ id: '7a5cbfac-d1f8-4e7f-b1cf-9e1f7cdc6b54',
185
+ method: 'signalwire.event',
186
+ params: {
187
+ event_type: 'chat.channel.message',
188
+ event_channel: 'chat',
189
+ params: {
190
+ channel: 'lobby',
191
+ message: {
192
+ id: 'f5511ad5-4dc2-4d28-a449-cc39909093b9',
193
+ sender_id: '1507e5f9-075c-463d-94ba-a8f9ec0c7d4e',
194
+ content: 'Hello World!',
195
+ published_at: 1641405257.795,
196
+ },
197
+ },
198
+ timestamp: 1641405258.253,
199
+ },
200
+ })
201
+ )
202
+ }
203
+ })
204
+ })
205
+
206
+ const chat = new Chat({
207
+ host,
208
+ token,
209
+ })
210
+ chat.on('message', (message) => {
211
+ expect(message.channel).toBe('lobby')
212
+ expect(message.id).toBe('f5511ad5-4dc2-4d28-a449-cc39909093b9')
213
+ expect(message.senderId).toBe('1507e5f9-075c-463d-94ba-a8f9ec0c7d4e')
214
+ expect(message.content).toBe('Hello World!')
215
+ expect(message.publishedAt).toStrictEqual(
216
+ new Date(1641405257.795 * 1000)
217
+ )
218
+
219
+ done()
220
+ })
221
+ chat.subscribe(['test1'])
222
+ })
223
+ })
224
+
225
+ describe('member event handlers', () => {
226
+ const _setupMockWS = (eventPayload: any) => {
227
+ WS.clean()
228
+ server = new WS(host)
229
+ server.on('connection', (socket) => {
230
+ socket.on('message', (data: any) => {
231
+ const parsedData = JSON.parse(data)
232
+ socket.send(
233
+ JSON.stringify({
234
+ jsonrpc: '2.0',
235
+ id: parsedData.id,
236
+ result: {},
237
+ })
238
+ )
239
+
240
+ if (parsedData.method === 'chat.subscribe') {
241
+ socket.send(JSON.stringify(eventPayload))
242
+ }
243
+ })
244
+ })
245
+ }
246
+
247
+ it('should return a ChatMember object on member.joined', (done) => {
248
+ _setupMockWS({
249
+ jsonrpc: '2.0',
250
+ id: '45266133-cdfe-4e99-a257-1ea77572f1d9',
251
+ method: 'signalwire.event',
252
+ params: {
253
+ event_type: 'chat.member.joined',
254
+ event_channel: 'chat',
255
+ params: {
256
+ channel: 'lobby',
257
+ member: {
258
+ id: '1507e5f9-075c-463d-94ba-a8f9ec0c7d4e',
259
+ },
260
+ },
261
+ timestamp: 1641468229.28,
262
+ },
263
+ })
264
+
265
+ const chat = new Chat({
266
+ host,
267
+ token,
268
+ })
269
+ chat.on('member.joined', (member) => {
270
+ expect(member.channel).toBe('lobby')
271
+ expect(member.id).toBe('1507e5f9-075c-463d-94ba-a8f9ec0c7d4e')
272
+
273
+ done()
274
+ })
275
+
276
+ chat.subscribe(['test1'])
277
+ })
278
+
279
+ it('should return a ChatMember object on member.updated', (done) => {
280
+ _setupMockWS({
281
+ jsonrpc: '2.0',
282
+ id: 'f734e59a-dea2-4de2-8369-7f6df4bf3016',
283
+ method: 'signalwire.event',
284
+ params: {
285
+ event_type: 'chat.member.updated',
286
+ event_channel: 'chat',
287
+ params: {
288
+ channel: 'lobby',
289
+ member: {
290
+ id: '1507e5f9-075c-463d-94ba-a8f9ec0c7d4e',
291
+ },
292
+ state: {
293
+ typing: true,
294
+ },
295
+ },
296
+ timestamp: 1641468242.538,
297
+ },
298
+ })
299
+
300
+ const chat = new Chat({
301
+ host,
302
+ token,
303
+ })
304
+ chat.on('member.updated', (member) => {
305
+ expect(member.channel).toBe('lobby')
306
+ expect(member.id).toBe('1507e5f9-075c-463d-94ba-a8f9ec0c7d4e')
307
+ expect(member.state).toStrictEqual({
308
+ typing: true,
309
+ })
310
+
311
+ done()
312
+ })
313
+
314
+ chat.subscribe(['test1'])
315
+ })
316
+
317
+ it('should return a ChatMember object on member.left', (done) => {
318
+ _setupMockWS({
319
+ jsonrpc: '2.0',
320
+ id: '45266133-cdfe-4e99-a257-1ea77572f1d9',
321
+ method: 'signalwire.event',
322
+ params: {
323
+ event_type: 'chat.member.left',
324
+ event_channel: 'chat',
325
+ params: {
326
+ channel: 'lobby',
327
+ member: {
328
+ id: '1507e5f9-075c-463d-94ba-a8f9ec0c7d4e',
329
+ },
330
+ },
331
+ timestamp: 1641468229.28,
332
+ },
333
+ })
334
+
335
+ const chat = new Chat({
336
+ host,
337
+ token,
338
+ })
339
+ chat.on('member.left', (member) => {
340
+ expect(member.channel).toBe('lobby')
341
+ expect(member.id).toBe('1507e5f9-075c-463d-94ba-a8f9ec0c7d4e')
342
+
343
+ done()
344
+ })
345
+
346
+ chat.subscribe(['test1'])
347
+ })
348
+ })
349
+
74
350
  describe('Subscribe', () => {
75
351
  it('should convert channels into the internal channel notation when calling .subscribe()', async () => {
76
352
  const chat = new Chat({
@@ -118,7 +394,7 @@ describe('Chat Object', () => {
118
394
  })
119
395
 
120
396
  describe('Unsubscribe', () => {
121
- it('should convert channels into the internal channel notation when calling .unsubscribe()', async () => {
397
+ it('should convert channels into the internal channel notation', async () => {
122
398
  const chat = new Chat({
123
399
  host,
124
400
  token,
@@ -154,7 +430,7 @@ describe('Chat Object', () => {
154
430
  ).toBeUndefined()
155
431
  })
156
432
 
157
- it('should throw if the user calls .unsubscribe() before the session is authorized', async () => {
433
+ it('should reject if its called before the session is authorized', async () => {
158
434
  expect.assertions(1)
159
435
  const chat = new Chat({
160
436
  host,
@@ -172,7 +448,7 @@ describe('Chat Object', () => {
172
448
  }
173
449
  })
174
450
 
175
- it('should throw if the user calls .unsubscribe() without being subscribed to channels', async () => {
451
+ it("should reject if it's called without channels", async () => {
176
452
  expect.assertions(1)
177
453
  const chat = new Chat({
178
454
  host,
@@ -188,16 +464,10 @@ describe('Chat Object', () => {
188
464
  message: 'test',
189
465
  })
190
466
 
191
- try {
192
- await chat.unsubscribe(['test1'])
193
- } catch (err) {
194
- expect(err.message).toBe(
195
- 'You must subscribe to at least one channel before calling unsubscribe()'
196
- )
197
- }
467
+ await expect(() => chat.unsubscribe(['test1_error'])).rejects.toBeTruthy()
198
468
  })
199
469
 
200
- it('should throw if the user calls .unsubscribe() with channels different than the ones they are subscribed to', async () => {
470
+ it('should reject if the user calls .unsubscribe() with channels different than the ones they are subscribed to', async () => {
201
471
  expect.assertions(1)
202
472
  const chat = new Chat({
203
473
  host,
@@ -206,14 +476,131 @@ describe('Chat Object', () => {
206
476
 
207
477
  chat.on('message', () => {})
208
478
 
209
- try {
210
- await chat.subscribe(['test1', 'test2', 'test3', 'test4'])
211
- await chat.unsubscribe(['test1', 'test5'])
212
- } catch (err) {
213
- expect(err.message).toBe(
214
- `You can't unsubscribe from a channel that you didn't subscribe to. You're subscribed to the following channels: test1, test2, test3, test4 but tried to unsubscribe from: test1, test5`
215
- )
216
- }
479
+ await chat.subscribe(['test1', 'test2', 'test3', 'test4'])
480
+ await expect(() =>
481
+ chat.unsubscribe(['test1', 'test5_error'])
482
+ ).rejects.toBeTruthy()
483
+ })
484
+ })
485
+
486
+ describe('getMembers', () => {
487
+ it('should send the proper RPC and format the response', async () => {
488
+ const chat = new Chat({
489
+ host,
490
+ token,
491
+ })
492
+ chat.on('message', () => {})
493
+ await chat.subscribe(['test1'])
494
+
495
+ const response = await chat.getMembers({ channel: 'test1' })
496
+
497
+ const request = JSON.parse(server.messages[2].toString())
498
+ expect(request.method).toEqual('chat.members.get')
499
+ expect(request.params).toStrictEqual({ channel: 'test1' })
500
+
501
+ expect(response).toStrictEqual({
502
+ members: [
503
+ {
504
+ id: '1507e5f9-075c-463d-94ba-a8f9ec0c7d4e',
505
+ },
506
+ ],
507
+ })
508
+ })
509
+ })
510
+
511
+ describe('getMessages', () => {
512
+ it('should send the proper RPC and format the response', async () => {
513
+ const chat = new Chat({
514
+ host,
515
+ token,
516
+ })
517
+ chat.on('message', () => {})
518
+ await chat.subscribe(['test1'])
519
+
520
+ const response = await chat.getMessages({
521
+ channel: 'test1',
522
+ cursor: { before: 'before' },
523
+ })
524
+
525
+ const request = JSON.parse(server.messages[2].toString())
526
+ expect(request.method).toEqual('chat.messages.get')
527
+ expect(request.params).toStrictEqual({
528
+ channel: 'test1',
529
+ cursor: { before: 'before' },
530
+ })
531
+
532
+ expect(response).toStrictEqual({
533
+ messages: [
534
+ {
535
+ id: '5fdc8fc5-b7fe-4fbd-8204-f2310dec2614',
536
+ senderId: '1507e5f9-075c-463d-94ba-a8f9ec0c7d4e',
537
+ content: 'hello world',
538
+ publishedAt: new Date(1641393396.153 * 1000),
539
+ },
540
+ ],
541
+ cursor: {
542
+ before: 'before',
543
+ after: 'after',
544
+ },
545
+ })
546
+ })
547
+ })
548
+
549
+ describe('setState', () => {
550
+ it('should send the proper RPC and format the response', async () => {
551
+ const chat = new Chat({
552
+ host,
553
+ token,
554
+ })
555
+ chat.on('message', () => {})
556
+ await chat.subscribe(['test1'])
557
+
558
+ const response = await chat.setState({
559
+ channels: 'test1',
560
+ state: { typing: true },
561
+ })
562
+
563
+ const request = JSON.parse(server.messages[2].toString())
564
+ expect(request.method).toEqual('chat.presence.set_state')
565
+ expect(request.params).toStrictEqual({
566
+ channels: [{ name: 'test1' }],
567
+ state: { typing: true },
568
+ })
569
+
570
+ expect(response).toStrictEqual(undefined)
571
+ })
572
+ })
573
+
574
+ describe('getState', () => {
575
+ it('should send the proper RPC and format the response', async () => {
576
+ const chat = new Chat({
577
+ host,
578
+ token,
579
+ })
580
+ chat.on('message', () => {})
581
+ await chat.subscribe(['test1'])
582
+
583
+ const response = await chat.getState({
584
+ memberId: 'memberId',
585
+ channels: 'test1',
586
+ })
587
+
588
+ const request = JSON.parse(server.messages[2].toString())
589
+ expect(request.method).toEqual('chat.presence.get_state')
590
+ expect(request.params).toStrictEqual({
591
+ channels: [{ name: 'test1' }],
592
+ member_id: 'memberId',
593
+ })
594
+
595
+ expect(response).toStrictEqual({
596
+ channels: {
597
+ lobby: {
598
+ state: {
599
+ typing: true,
600
+ },
601
+ },
602
+ },
603
+ })
217
604
  })
218
605
  })
219
606
  })
@@ -16,30 +16,10 @@ import { JWTSession } from './JWTSession'
16
16
  * Create a client
17
17
  *
18
18
  * @example
19
- * With autoConnect true the client is ready to be used.
20
19
  * ```js
21
20
  * try {
22
- * const client = await Video.createClient({
23
- * token: '<YourToken>',
24
- * })
25
- *
26
- * // Your client is already connected..
27
- * } catch (error) {
28
- * console.error('Auth Error', error)
29
- * }
30
- * ```
31
- *
32
- * @example
33
- * With autoConnect false you can attach additional handlers.
34
- * ```js
35
- * try {
36
- * const client = await Video.createClient({
21
+ * const client = Video.createClient({
37
22
  * token: '<YourJWT>',
38
- * autoConnect: false,
39
- * })
40
- *
41
- * client.on('socket.closed', () => {
42
- * // The WebSocket connection is closed
43
23
  * })
44
24
  *
45
25
  * await client.connect()
@@ -10,8 +10,8 @@ export const ROOM_COMPONENT_LISTENERS = {
10
10
 
11
11
  export const SCREENSHARE_AUDIO_CONSTRAINTS: MediaTrackConstraints = {
12
12
  echoCancellation: false,
13
- // @ts-expect-error
14
13
  noiseSuppression: false,
15
14
  autoGainControl: false,
15
+ // @ts-expect-error
16
16
  googAutoGainControl: false,
17
17
  }