@reactoo/watchtogether-sdk-js 2.4.16 → 2.4.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.4.16",
3
+ "version": "2.4.20",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "src/index.js",
6
6
  "unpkg": "dist/watchtogether-sdk.min.js",
@@ -25,11 +25,11 @@
25
25
  },
26
26
  "homepage": "https://github.com/picitujeromanov/WR-SDK",
27
27
  "devDependencies": {
28
- "@babel/core": "^7.15.5",
28
+ "@babel/core": "^7.15.8",
29
29
  "@babel/plugin-proposal-class-properties": "^7.14.5",
30
30
  "@babel/plugin-proposal-optional-chaining": "^7.14.5",
31
31
  "@babel/plugin-proposal-private-property-in-object": "^7.15.4",
32
- "@babel/preset-env": "^7.15.6",
32
+ "@babel/preset-env": "^7.15.8",
33
33
  "acorn": "^6.4.2",
34
34
  "babel-core": "^6.26.3",
35
35
  "babel-loader": "^8.2.2",
@@ -14,14 +14,14 @@ let auth = function () {
14
14
  })
15
15
  },
16
16
 
17
- providerLogin: (domain, token, displayname) => {
17
+ providerLogin: (domain, token, displayname, deviceId) => {
18
18
 
19
19
  if(!token && typeof this.__privates.providerAuth === 'function') {
20
20
  ({token, displayname} = this.__privates.providerAuth());
21
21
  }
22
22
 
23
23
  return this.__privates.auth.__client
24
- .then(client => client.apis.auth.providerSignIn({},{requestBody:{domain, token, ...(displayname !== null && {displayname})}}))
24
+ .then(client => client.apis.auth.providerSignIn({},{requestBody:{domain, token, ...(displayname && {displayname}), ...(deviceId !== null && {deviceId})}}))
25
25
  .then(response => {
26
26
  this.userId = response.data.userId;
27
27
  this.username = response.data.username;
@@ -83,7 +83,7 @@ let roomSession = function ({roomId, pinHash, isTalkback, isMonitor, isInstructo
83
83
  isInstructor
84
84
  }), wt.user.getUserSelf()])
85
85
  .then(([roomData, userData]) => Promise.all([roomData, userData, this.setRoomVars()]))
86
- .then(([roomData, userData, _]) => room.connect(roomData.data.roomId, roomData.data.pin, roomData.data.href, roomData.data.iceServers, roomData.data.accessToken, (isMonitor || isInstructor) ? roomData.data.userId : userData.data._id, roomData.data.webrtcVersion, (roomData.data.bitrate ? parseInt(roomData.data.bitrate) : 0), isMonitor, roomData.data.recordingFilename))
86
+ .then(([roomData, userData, _]) => room.connect(roomData.data.roomId, roomData.data.pin, roomData.data.href, roomData.data.iceServers, roomData.data.accessToken, (isMonitor || isInstructor || isTalkback) ? roomData.data.userId : userData.data._id, roomData.data.webrtcVersion, (roomData.data.bitrate ? parseInt(roomData.data.bitrate) : 0), isMonitor, roomData.data.recordingFilename))
87
87
  .finally(() => {
88
88
  emitter.emit('connecting', false);
89
89
  })
@@ -207,19 +207,32 @@ const syncVodDashJs = function ({room, wt, roomSession, emitter} = {}) {
207
207
  }
208
208
  };
209
209
 
210
- const parseIotEvents = (data) => {
210
+ const executePlayerIotEvents = (data) => {
211
211
  let rid = _roomId || room.roomId;
212
+ if(data.attributeName === 'playerReplay' && (!rid || data?.roomId === rid)) {
213
+ seekTo(0).then(() => playMedia());
214
+ }
215
+
216
+ if(data.attributeName === 'playerPlay' && (!rid || data?.roomId === rid)) {
217
+ playMedia();
218
+ }
219
+
220
+ if(data.attributeName === 'playerPause' && (!rid || data?.roomId === rid)) {
221
+ pauseMedia();
222
+ }
223
+ };
224
+
225
+ const parseIotEvents = (data) => {
212
226
  if(data.event === 'template_updated') {
213
- if(data.operation === 'sendMessage' && data.attributeName === 'playerReplay' && (!rid || data?.roomId === rid)) {
214
- seekTo(0).then(() => playMedia());
215
- }
216
-
217
- if(data.operation === 'sendMessage' && data.attributeName === 'playerPlay' && (!rid || data?.roomId === rid)) {
218
- playMedia();
227
+ if(data.operation === 'multi') {
228
+ (data.value || []).forEach(event => {
229
+ if (event.operation === 'sendMessage') {
230
+ executePlayerIotEvents({...event, roomId: data.roomId, userId: data.userId});
231
+ }
232
+ })
219
233
  }
220
-
221
- if(data.operation === 'sendMessage' && data.attributeName === 'playerPause' && (!rid || data?.roomId === rid)) {
222
- pauseMedia();
234
+ if(data.operation === 'sendMessage') {
235
+ executePlayerIotEvents(data);
223
236
  }
224
237
  }
225
238
  };
@@ -207,19 +207,32 @@ const syncVodHlsJs = function ({room, wt, roomSession, emitter} = {}) {
207
207
  }
208
208
  };
209
209
 
210
- const parseIotEvents = (data) => {
210
+ const executePlayerIotEvents = (data) => {
211
211
  let rid = _roomId || room.roomId;
212
+ if(data.attributeName === 'playerReplay' && (!rid || data?.roomId === rid)) {
213
+ seekTo(0).then(() => playMedia());
214
+ }
215
+
216
+ if(data.attributeName === 'playerPlay' && (!rid || data?.roomId === rid)) {
217
+ playMedia();
218
+ }
219
+
220
+ if(data.attributeName === 'playerPause' && (!rid || data?.roomId === rid)) {
221
+ pauseMedia();
222
+ }
223
+ };
224
+
225
+ const parseIotEvents = (data) => {
212
226
  if(data.event === 'template_updated') {
213
- if(data.operation === 'sendMessage' && data.attributeName === 'playerReplay' && (!rid || data?.roomId === rid)) {
214
- seekTo(0).then(() => playMedia());
215
- }
216
-
217
- if(data.operation === 'sendMessage' && data.attributeName === 'playerPlay' && (!rid || data?.roomId === rid)) {
218
- playMedia();
227
+ if(data.operation === 'multi') {
228
+ (data.value || []).forEach(event => {
229
+ if (event.operation === 'sendMessage') {
230
+ executePlayerIotEvents({...event, roomId: data.roomId, userId: data.userId});
231
+ }
232
+ })
219
233
  }
220
-
221
- if(data.operation === 'sendMessage' && data.attributeName === 'playerPause' && (!rid || data?.roomId === rid)) {
222
- pauseMedia();
234
+ if(data.operation === 'sendMessage') {
235
+ executePlayerIotEvents(data);
223
236
  }
224
237
  }
225
238
  };
@@ -199,19 +199,32 @@ const syncVodHlsJs = function ({room, wt, roomSession, emitter} = {}) {
199
199
  return room._isDataChannelOpen && room._hasJoined;
200
200
  };
201
201
 
202
- const parseIotEvents = (data) => {
202
+ const executePlayerIotEvents = (data) => {
203
203
  let rid = _roomId || room.roomId;
204
+ if(data.attributeName === 'playerReplay' && (!rid || data?.roomId === rid)) {
205
+ seekTo(0).then(() => playMedia());
206
+ }
207
+
208
+ if(data.attributeName === 'playerPlay' && (!rid || data?.roomId === rid)) {
209
+ playMedia();
210
+ }
211
+
212
+ if(data.attributeName === 'playerPause' && (!rid || data?.roomId === rid)) {
213
+ pauseMedia();
214
+ }
215
+ };
216
+
217
+ const parseIotEvents = (data) => {
204
218
  if(data.event === 'template_updated') {
205
- if(data.operation === 'sendMessage' && data.attributeName === 'playerReplay' && (!rid || data?.roomId === rid)) {
206
- seekTo(0).then(() => playMedia());
207
- }
208
-
209
- if(data.operation === 'sendMessage' && data.attributeName === 'playerPlay' && (!rid || data?.roomId === rid)) {
210
- playMedia();
219
+ if(data.operation === 'multi') {
220
+ (data.value || []).forEach(event => {
221
+ if (event.operation === 'sendMessage') {
222
+ executePlayerIotEvents({...event, roomId: data.roomId, userId: data.userId});
223
+ }
224
+ })
211
225
  }
212
-
213
- if(data.operation === 'sendMessage' && data.attributeName === 'playerPause' && (!rid || data?.roomId === rid)) {
214
- pauseMedia();
226
+ if(data.operation === 'sendMessage') {
227
+ executePlayerIotEvents(data);
215
228
  }
216
229
  }
217
230
  };
@@ -205,19 +205,32 @@ const syncVodShakaDash = function ({room, wt, roomSession, emitter} = {}) {
205
205
  }
206
206
  };
207
207
 
208
- const parseIotEvents = (data) => {
208
+ const executePlayerIotEvents = (data) => {
209
209
  let rid = _roomId || room.roomId;
210
+ if(data.attributeName === 'playerReplay' && (!rid || data?.roomId === rid)) {
211
+ seekTo(0).then(() => playMedia());
212
+ }
213
+
214
+ if(data.attributeName === 'playerPlay' && (!rid || data?.roomId === rid)) {
215
+ playMedia();
216
+ }
217
+
218
+ if(data.attributeName === 'playerPause' && (!rid || data?.roomId === rid)) {
219
+ pauseMedia();
220
+ }
221
+ };
222
+
223
+ const parseIotEvents = (data) => {
210
224
  if(data.event === 'template_updated') {
211
- if(data.operation === 'sendMessage' && data.attributeName === 'playerReplay' && (!rid || data?.roomId === rid)) {
212
- seekTo(0).then(() => playMedia());
213
- }
214
-
215
- if(data.operation === 'sendMessage' && data.attributeName === 'playerPlay' && (!rid || data?.roomId === rid)) {
216
- playMedia();
225
+ if(data.operation === 'multi') {
226
+ (data.value || []).forEach(event => {
227
+ if (event.operation === 'sendMessage') {
228
+ executePlayerIotEvents({...event, roomId: data.roomId, userId: data.userId});
229
+ }
230
+ })
217
231
  }
218
-
219
- if(data.operation === 'sendMessage' && data.attributeName === 'playerPause' && (!rid || data?.roomId === rid)) {
220
- pauseMedia();
232
+ if(data.operation === 'sendMessage') {
233
+ executePlayerIotEvents(data);
221
234
  }
222
235
  }
223
236
  };