@reactoo/watchtogether-sdk-js 2.4.30 → 2.4.34
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/watchtogether-sdk.js +11 -11
- package/dist/watchtogether-sdk.min.js +2 -2
- package/package.json +7 -7
- package/src/index.js +2 -2
- package/src/models/room-session.js +0 -60
- package/src/models/room.js +6 -2
- package/src/modules/wt-auth.js +2 -2
- package/src/modules/wt-iot2.js +1 -1
- package/src/modules/wt-room.js +30 -58
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactoo/watchtogether-sdk-js",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.34",
|
|
4
4
|
"description": "Javascript SDK for Reactoo",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"unpkg": "dist/watchtogether-sdk.min.js",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/picitujeromanov/WR-SDK",
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@babel/core": "^7.
|
|
29
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
30
|
-
"@babel/plugin-proposal-optional-chaining": "^7.
|
|
31
|
-
"@babel/plugin-proposal-private-property-in-object": "^7.
|
|
32
|
-
"@babel/preset-env": "^7.
|
|
28
|
+
"@babel/core": "^7.16.0",
|
|
29
|
+
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
30
|
+
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
31
|
+
"@babel/plugin-proposal-private-property-in-object": "^7.16.0",
|
|
32
|
+
"@babel/preset-env": "^7.16.4",
|
|
33
33
|
"acorn": "^6.4.2",
|
|
34
34
|
"babel-core": "^6.26.3",
|
|
35
|
-
"babel-loader": "^8.2.
|
|
35
|
+
"babel-loader": "^8.2.3",
|
|
36
36
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
37
37
|
"babel-preset-env": "^1.7.0",
|
|
38
38
|
"babel-preset-minify": "^0.5.1",
|
package/src/index.js
CHANGED
|
@@ -39,9 +39,9 @@ function WatchTogether(modules = {}, instanceType, debug, playerFactory, provide
|
|
|
39
39
|
this.utils = utils;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
let watchTogether = function ({debug = true, isProduction = true, language = 'en-GB', storagePrefix = ""} = {}) {
|
|
42
|
+
let watchTogether = function ({debug = true, isProduction = true, language = 'en-GB', storagePrefix = "", apiUrl = null} = {}) {
|
|
43
43
|
let room = new Room(debug);
|
|
44
|
-
let auth = new Auth(debug, isProduction, language, storagePrefix);
|
|
44
|
+
let auth = new Auth(debug, isProduction, language, storagePrefix, apiUrl);
|
|
45
45
|
// let iot = new Iot(debug);
|
|
46
46
|
let iot = new Iot2(debug);
|
|
47
47
|
|
|
@@ -280,26 +280,6 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
280
280
|
},
|
|
281
281
|
|
|
282
282
|
publishLocal: function (stream = null, {
|
|
283
|
-
keepAudio = false,
|
|
284
|
-
keepVideo = false,
|
|
285
|
-
getStreamIfEmpty = true,
|
|
286
|
-
askVideo = true,
|
|
287
|
-
unpublishFirst = false
|
|
288
|
-
} = {}) {
|
|
289
|
-
if (room.isLegacy) {
|
|
290
|
-
return this.publishLocalLegacy(stream, {
|
|
291
|
-
keepAudio,
|
|
292
|
-
keepVideo,
|
|
293
|
-
getStreamIfEmpty,
|
|
294
|
-
askVideo,
|
|
295
|
-
unpublishFirst
|
|
296
|
-
})
|
|
297
|
-
} else {
|
|
298
|
-
return this.publishLocalNew(stream, {keepAudio, keepVideo, getStreamIfEmpty, askVideo, unpublishFirst})
|
|
299
|
-
}
|
|
300
|
-
},
|
|
301
|
-
|
|
302
|
-
publishLocalNew: function (stream = null, {
|
|
303
283
|
keepAudio = false,
|
|
304
284
|
keepVideo = false,
|
|
305
285
|
getStreamIfEmpty = true,
|
|
@@ -310,46 +290,6 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
|
|
|
310
290
|
: wt.utils.getUserStream(askVideo).then(stream => room.publishLocal(stream)))
|
|
311
291
|
},
|
|
312
292
|
|
|
313
|
-
publishLocalLegacy: function (stream = null, {
|
|
314
|
-
keepAudio = false,
|
|
315
|
-
keepVideo = false,
|
|
316
|
-
getStreamIfEmpty = true,
|
|
317
|
-
askVideo = true,
|
|
318
|
-
unpublishFirst = false
|
|
319
|
-
} = {}) {
|
|
320
|
-
return (unpublishFirst
|
|
321
|
-
? new Promise((resolve, reject) => {
|
|
322
|
-
emitter.emit('reconnecting', true);
|
|
323
|
-
room.isRestarting = true;
|
|
324
|
-
this.unpublishLocal()
|
|
325
|
-
.then(() => wait(500)) //TODO: remove 500ms wait by waiting for proper events from janus
|
|
326
|
-
.finally(() => {
|
|
327
|
-
emitter.emit('reconnecting', false);
|
|
328
|
-
room.isRestarting = false;
|
|
329
|
-
resolve()
|
|
330
|
-
})
|
|
331
|
-
})
|
|
332
|
-
: Promise.resolve())
|
|
333
|
-
.then(() => (
|
|
334
|
-
stream || !getStreamIfEmpty
|
|
335
|
-
? room.publishLocal(stream, {keepAudio, keepVideo})
|
|
336
|
-
: wt.utils.getUserStream(askVideo).then(stream => room.publishLocal(stream))))
|
|
337
|
-
.then(r => {
|
|
338
|
-
publishRetry = 0;
|
|
339
|
-
return r;
|
|
340
|
-
})
|
|
341
|
-
.catch(e => {
|
|
342
|
-
room._log(e);
|
|
343
|
-
if (e && e.id === 27 && publishRetry < maxPublishRetry) {
|
|
344
|
-
publishRetry++;
|
|
345
|
-
return this.restart('firefox', true);
|
|
346
|
-
} else {
|
|
347
|
-
publishRetry = 0;
|
|
348
|
-
return Promise.reject(e);
|
|
349
|
-
}
|
|
350
|
-
})
|
|
351
|
-
},
|
|
352
|
-
|
|
353
293
|
unpublishLocal: () => {
|
|
354
294
|
return room.unpublishLocal();
|
|
355
295
|
},
|
package/src/models/room.js
CHANGED
|
@@ -48,7 +48,8 @@ let room = function () {
|
|
|
48
48
|
reduceRoomControls,
|
|
49
49
|
muteParticipantOnJoin,
|
|
50
50
|
hasStudioChat,
|
|
51
|
-
maxParticipants
|
|
51
|
+
maxParticipants,
|
|
52
|
+
customAttributes
|
|
52
53
|
} = {}) => {
|
|
53
54
|
return this.__privates.auth.__client
|
|
54
55
|
.then(client => client.apis.wt.createRoom({}, {
|
|
@@ -66,7 +67,8 @@ let room = function () {
|
|
|
66
67
|
reduceRoomControls,
|
|
67
68
|
muteParticipantOnJoin,
|
|
68
69
|
hasStudioChat,
|
|
69
|
-
maxParticipants
|
|
70
|
+
maxParticipants,
|
|
71
|
+
customAttributes
|
|
70
72
|
}
|
|
71
73
|
}))
|
|
72
74
|
},
|
|
@@ -90,6 +92,7 @@ let room = function () {
|
|
|
90
92
|
muteParticipantOnJoin,
|
|
91
93
|
disableSync,
|
|
92
94
|
defaultRegion,
|
|
95
|
+
customAttributes,
|
|
93
96
|
dotAttribute
|
|
94
97
|
} = {}) => {
|
|
95
98
|
let _da = dotAttribute
|
|
@@ -115,6 +118,7 @@ let room = function () {
|
|
|
115
118
|
muteParticipantOnJoin,
|
|
116
119
|
disableSync,
|
|
117
120
|
defaultRegion,
|
|
121
|
+
customAttributes,
|
|
118
122
|
wtChannelId, ...(setInstanceType && {instanceType: setInstanceType === true ? this.__instanceType : setInstanceType}), ...(allowedParticipants && {allowedParticipants}), ...(recordings && {recordings})
|
|
119
123
|
}
|
|
120
124
|
}))
|
package/src/modules/wt-auth.js
CHANGED
|
@@ -4,7 +4,7 @@ import emitter from './wt-emitter';
|
|
|
4
4
|
|
|
5
5
|
class Auth {
|
|
6
6
|
|
|
7
|
-
constructor(enableDebugFlag, isProduction = true, language = 'en-GB', storagePrefix = "") {
|
|
7
|
+
constructor(enableDebugFlag, isProduction = true, language = 'en-GB', storagePrefix = "", apiUrl = null) {
|
|
8
8
|
|
|
9
9
|
this.ID_TOKEN = `${storagePrefix !== "" ? storagePrefix+'_':''}rwt_idToken`;
|
|
10
10
|
this.ACCESS_TOKEN = `${storagePrefix !== "" ? storagePrefix+'_':''}rwt_accessToken`;
|
|
@@ -22,7 +22,7 @@ class Auth {
|
|
|
22
22
|
this.__isRefreshing = false;
|
|
23
23
|
this.__isLogged = null;
|
|
24
24
|
this.__parsedJwt = null;
|
|
25
|
-
this.__specUrl = isProduction === true ? config.apiUrl : config.devApiUrl;
|
|
25
|
+
this.__specUrl = apiUrl ? apiUrl : (isProduction === true ? config.apiUrl : config.devApiUrl);
|
|
26
26
|
this.__client = this.initialize(true);
|
|
27
27
|
}
|
|
28
28
|
|
package/src/modules/wt-iot2.js
CHANGED
|
@@ -213,7 +213,7 @@ class Iot2 {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
else if(topic[1] === 'instanceroom') { // instance
|
|
216
|
-
if(event === 'add_room' || event === 'remove_room' || event === 'set_room' || event === "instance_homepage_changed") {
|
|
216
|
+
if(event === 'add_room' || event === 'remove_room' || event === 'set_room' || event === "instance_homepage_changed" || event === 'instance_settings_changed') {
|
|
217
217
|
this.emit('message', {event, ...payload});
|
|
218
218
|
}
|
|
219
219
|
}
|
package/src/modules/wt-room.js
CHANGED
|
@@ -166,7 +166,8 @@ class RoomSession {
|
|
|
166
166
|
|
|
167
167
|
constructor(enableDebugFlag, type = 'reactooroom', options = {
|
|
168
168
|
classroomObserverSubscribeToInstructor: false,
|
|
169
|
-
classroomInstructorSubscribeToParticipants: false
|
|
169
|
+
classroomInstructorSubscribeToParticipants: false,
|
|
170
|
+
safariBugHotfixEnabled: true
|
|
170
171
|
}) {
|
|
171
172
|
|
|
172
173
|
this.server = null;
|
|
@@ -177,7 +178,6 @@ class RoomSession {
|
|
|
177
178
|
this.pin = null;
|
|
178
179
|
this.userId = null;
|
|
179
180
|
this.sessiontype = type;
|
|
180
|
-
this.isLegacy = false;
|
|
181
181
|
this.initialBitrate = 0;
|
|
182
182
|
this.isMonitor = false; // currently used just for classroom context so monitor user only subscribes to participants and not trainer (for other monitor this flag is not necessary)
|
|
183
183
|
this.recordingFilename = null;
|
|
@@ -532,32 +532,16 @@ class RoomSession {
|
|
|
532
532
|
this._log('Creating user: ', userId);
|
|
533
533
|
this._createParticipant(userId, id)
|
|
534
534
|
.then(handle => {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
"private_id": this.privateId,
|
|
546
|
-
pin: this.pin
|
|
547
|
-
}
|
|
548
|
-
})
|
|
549
|
-
} else {
|
|
550
|
-
return this.sendMessage(handle.handleId, {
|
|
551
|
-
body: {
|
|
552
|
-
"request": "join",
|
|
553
|
-
"room": this.roomId,
|
|
554
|
-
"ptype": "subscriber",
|
|
555
|
-
"feed": id,
|
|
556
|
-
"private_id": this.privateId,
|
|
557
|
-
pin: this.pin
|
|
558
|
-
}
|
|
559
|
-
})
|
|
560
|
-
}
|
|
535
|
+
return this.sendMessage(handle.handleId, {
|
|
536
|
+
body: {
|
|
537
|
+
"request": "join",
|
|
538
|
+
"room": this.roomId,
|
|
539
|
+
"ptype": "subscriber",
|
|
540
|
+
"feed": id,
|
|
541
|
+
"private_id": this.privateId,
|
|
542
|
+
pin: this.pin
|
|
543
|
+
}
|
|
544
|
+
})
|
|
561
545
|
})
|
|
562
546
|
.catch(err => {
|
|
563
547
|
this.emit('error', err);
|
|
@@ -642,32 +626,16 @@ class RoomSession {
|
|
|
642
626
|
this._log('Creating user: ', userId);
|
|
643
627
|
this._createParticipant(userId, id)
|
|
644
628
|
.then(handle => {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
"private_id": this.privateId,
|
|
656
|
-
pin: this.pin
|
|
657
|
-
}
|
|
658
|
-
})
|
|
659
|
-
} else {
|
|
660
|
-
return this.sendMessage(handle.handleId, {
|
|
661
|
-
body: {
|
|
662
|
-
"request": "join",
|
|
663
|
-
"room": this.roomId,
|
|
664
|
-
"ptype": "subscriber",
|
|
665
|
-
"feed": id,
|
|
666
|
-
"private_id": this.privateId,
|
|
667
|
-
pin: this.pin
|
|
668
|
-
}
|
|
669
|
-
})
|
|
670
|
-
}
|
|
629
|
+
return this.sendMessage(handle.handleId, {
|
|
630
|
+
body: {
|
|
631
|
+
"request": "join",
|
|
632
|
+
"room": this.roomId,
|
|
633
|
+
"ptype": "subscriber",
|
|
634
|
+
"feed": id,
|
|
635
|
+
"private_id": this.privateId,
|
|
636
|
+
pin: this.pin
|
|
637
|
+
}
|
|
638
|
+
})
|
|
671
639
|
})
|
|
672
640
|
.catch(err => {
|
|
673
641
|
this.emit('error', err);
|
|
@@ -1047,7 +1015,6 @@ class RoomSession {
|
|
|
1047
1015
|
this._wipeListeners();
|
|
1048
1016
|
}
|
|
1049
1017
|
this._stopKeepAlive();
|
|
1050
|
-
this.isLegacy = webrtcVersion < 104;
|
|
1051
1018
|
this.disconnectingPromise = null;
|
|
1052
1019
|
this.sessionId = null;
|
|
1053
1020
|
this.server = server;
|
|
@@ -1452,7 +1419,7 @@ class RoomSession {
|
|
|
1452
1419
|
this._handleDataEvents(handleId, 'error', error);
|
|
1453
1420
|
};
|
|
1454
1421
|
// Until we implement the proxying of open requests within the Janus core, we open a channel ourselves whatever the case
|
|
1455
|
-
config.dataChannel = config.pc.createDataChannel(defaultDataChannelLabel, {ordered:
|
|
1422
|
+
config.dataChannel = config.pc.createDataChannel(defaultDataChannelLabel, {ordered: true});
|
|
1456
1423
|
config.dataChannel.onmessage = onDataChannelMessage;
|
|
1457
1424
|
config.dataChannel.onopen = onDataChannelStateChange;
|
|
1458
1425
|
config.dataChannel.onclose = onDataChannelStateChange;
|
|
@@ -2033,14 +2000,19 @@ class RoomSession {
|
|
|
2033
2000
|
return Promise.reject({type: 'error', id: 21, message: 'no local id, connect first', data: null})
|
|
2034
2001
|
}
|
|
2035
2002
|
let config = handle.webrtcStuff;
|
|
2036
|
-
|
|
2003
|
+
|
|
2004
|
+
if(this.options.safariBugHotfixEnabled && adapter.browserDetails.browser === 'safari') {
|
|
2005
|
+
this.isVideoMuted = !this.isVideoMuted;
|
|
2006
|
+
}
|
|
2007
|
+
else if (this.isUnifiedPlan) {
|
|
2037
2008
|
let transceiver = config.pc.getTransceivers()
|
|
2038
2009
|
.find(t => t.sender && t.sender.track && t.receiver.track.kind === "video" && t.stopped === false);
|
|
2039
2010
|
if (transceiver) {
|
|
2040
2011
|
transceiver.sender.track.enabled = !transceiver.sender.track.enabled;
|
|
2041
2012
|
}
|
|
2042
2013
|
this.isVideoMuted = !transceiver || !transceiver.sender.track.enabled;
|
|
2043
|
-
}
|
|
2014
|
+
}
|
|
2015
|
+
else {
|
|
2044
2016
|
if (config.stream && config.stream.getVideoTracks().length) {
|
|
2045
2017
|
config.stream.getVideoTracks()[0].enabled = !config.stream.getVideoTracks()[0].enabled;
|
|
2046
2018
|
}
|