@reactoo/watchtogether-sdk-js 2.4.31 → 2.4.35
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 +10 -10
- package/dist/watchtogether-sdk.min.js +2 -2
- package/example/index.html +3 -7
- package/package.json +7 -7
- package/src/index.js +2 -2
- package/src/models/room-session.js +0 -60
- package/src/models/room.js +16 -2
- package/src/modules/wt-auth.js +2 -2
- package/src/modules/wt-room.js +30 -58
package/example/index.html
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
<script>
|
|
27
27
|
|
|
28
|
-
let roomId = '
|
|
28
|
+
let roomId = 'fc2d34f2-de58-42a0-9312-5cd40f2d754e'; //It will create room automatically if not set
|
|
29
29
|
let pinHash = undefined;//'967ca05f-7fab-a205-5913-39393bbbe923';
|
|
30
30
|
|
|
31
31
|
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
console.log('Iot message:', r);
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
Instance.auth.
|
|
126
|
+
Instance.auth.deviceLogin() // login as browser
|
|
127
127
|
.then(r => Instance.iot.iotLogin()) // login to mqtt
|
|
128
128
|
.then(r => {
|
|
129
129
|
|
|
@@ -154,11 +154,7 @@
|
|
|
154
154
|
.then(r => Instance.room.createSession({roomId:r.roomId, pinHash: r.pinHash})) // pin hash is not needed if you're owner of the room
|
|
155
155
|
.then(session => {
|
|
156
156
|
Instance.user.getUserSelf().then(r => {
|
|
157
|
-
Instance.
|
|
158
|
-
"operation": "auth",
|
|
159
|
-
uuid: r.data._id,
|
|
160
|
-
username: r.data.displayname
|
|
161
|
-
})
|
|
157
|
+
Instance.room.getRoomChatList()
|
|
162
158
|
.then(r => console.log('wooo',r))
|
|
163
159
|
|
|
164
160
|
})
|
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.35",
|
|
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
|
}))
|
|
@@ -155,6 +159,16 @@ let room = function () {
|
|
|
155
159
|
}))
|
|
156
160
|
},
|
|
157
161
|
|
|
162
|
+
getRoomChatList: ({roomId, type = "normal", size = 50, startKey = null} = {}) => {
|
|
163
|
+
let apiParams = {
|
|
164
|
+
roomId, type,
|
|
165
|
+
size,
|
|
166
|
+
...(startKey && {startKey})
|
|
167
|
+
};
|
|
168
|
+
return this.__privates.auth.__client
|
|
169
|
+
.then(client => client.apis.wt.getRoomChatList(apiParams))
|
|
170
|
+
},
|
|
171
|
+
|
|
158
172
|
getRoomsList: ({
|
|
159
173
|
type = 'participant',
|
|
160
174
|
activeOnly = null,
|
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-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
|
}
|