@reactoo/watchtogether-sdk-js 2.5.11 → 2.5.15
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 +5 -5
- package/dist/watchtogether-sdk.min.js +2 -2
- package/example/audio_controls/audio_controls.html +200 -0
- package/example/audio_controls/audiocontrols.js +217 -0
- package/package.json +1 -1
- package/src/index.js +2 -2
- package/src/models/room-session.js +3 -10
- package/src/models/utils.js +26 -38
- package/src/modules/wt-auth.js +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @reactoo/watchtogether-sdk-js
|
|
3
|
-
* @version 2.5.
|
|
3
|
+
* @version 2.5.15
|
|
4
4
|
*/
|
|
5
5
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
6
6
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -8258,7 +8258,7 @@ eval("module.exports = extend;\nvar hasOwnProperty = Object.prototype.hasOwnProp
|
|
|
8258
8258
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
8259
8259
|
|
|
8260
8260
|
"use strict";
|
|
8261
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _modules_wt_room__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./modules/wt-room */ \"./src/modules/wt-room.js\");\n/* harmony import */ var _modules_wt_auth__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./modules/wt-auth */ \"./src/modules/wt-auth.js\");\n/* harmony import */ var _modules_wt_iot__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./modules/wt-iot */ \"./src/modules/wt-iot.js\");\n/* harmony import */ var _models_auth__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./models/auth */ \"./src/models/auth.js\");\n/* harmony import */ var _models_room__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./models/room */ \"./src/models/room.js\");\n/* harmony import */ var _models_user__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./models/user */ \"./src/models/user.js\");\n/* harmony import */ var _models_asset__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./models/asset */ \"./src/models/asset.js\");\n/* harmony import */ var _models_system__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./models/system */ \"./src/models/system.js\");\n/* harmony import */ var _models_utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./models/utils */ \"./src/models/utils.js\");\n/* harmony import */ var _models_iot__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./models/iot */ \"./src/models/iot.js\");\n\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n\n\n\n\n\n\n\n\n\n\n\nfunction WatchTogether() {\n var _this = this;\n\n var modules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var instanceType = arguments.length > 1 ? arguments[1] : undefined;\n var debug = arguments.length > 2 ? arguments[2] : undefined;\n var playerFactory = arguments.length > 3 ? arguments[3] : undefined;\n var providerAuth = arguments.length > 4 ? arguments[4] : undefined;\n this.username = null;\n this.userId = null;\n this.__instanceType = instanceType;\n this.__debug = debug;\n this.__privates = {\n playerFactory: playerFactory,\n providerAuth: providerAuth,\n room: modules.room,\n auth: modules.auth,\n iot: modules.iot\n };\n\n this.setInstanceType = function (newInstanceType) {\n return _this.__instanceType = newInstanceType;\n };\n\n this.isReady = modules.room.whenInitialized;\n this.browser = modules.room.browser;\n this.browserDetails = modules.room.browserDetails;\n this.auth = _objectSpread({}, _models_auth__WEBPACK_IMPORTED_MODULE_3__[\"default\"].call(this));\n this.user = _objectSpread({}, _models_user__WEBPACK_IMPORTED_MODULE_5__[\"default\"].call(this));\n this.room = _objectSpread({}, _models_room__WEBPACK_IMPORTED_MODULE_4__[\"default\"].call(this));\n this.asset = _objectSpread({}, _models_asset__WEBPACK_IMPORTED_MODULE_6__[\"default\"].call(this));\n this.system = _objectSpread({}, _models_system__WEBPACK_IMPORTED_MODULE_7__[\"default\"].call(this));\n this.iot = _objectSpread({}, _models_iot__WEBPACK_IMPORTED_MODULE_9__[\"default\"].call(this));\n this.utils = _models_utils__WEBPACK_IMPORTED_MODULE_8__[\"default\"];\n}\n\nvar watchTogether = function watchTogether() {\n var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref$debug = _ref.debug,\n debug = _ref$debug === void 0 ? true : _ref$debug,\n _ref$
|
|
8261
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _modules_wt_room__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./modules/wt-room */ \"./src/modules/wt-room.js\");\n/* harmony import */ var _modules_wt_auth__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./modules/wt-auth */ \"./src/modules/wt-auth.js\");\n/* harmony import */ var _modules_wt_iot__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./modules/wt-iot */ \"./src/modules/wt-iot.js\");\n/* harmony import */ var _models_auth__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./models/auth */ \"./src/models/auth.js\");\n/* harmony import */ var _models_room__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./models/room */ \"./src/models/room.js\");\n/* harmony import */ var _models_user__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./models/user */ \"./src/models/user.js\");\n/* harmony import */ var _models_asset__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./models/asset */ \"./src/models/asset.js\");\n/* harmony import */ var _models_system__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./models/system */ \"./src/models/system.js\");\n/* harmony import */ var _models_utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./models/utils */ \"./src/models/utils.js\");\n/* harmony import */ var _models_iot__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./models/iot */ \"./src/models/iot.js\");\n\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n\n\n\n\n\n\n\n\n\n\n\nfunction WatchTogether() {\n var _this = this;\n\n var modules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var instanceType = arguments.length > 1 ? arguments[1] : undefined;\n var debug = arguments.length > 2 ? arguments[2] : undefined;\n var playerFactory = arguments.length > 3 ? arguments[3] : undefined;\n var providerAuth = arguments.length > 4 ? arguments[4] : undefined;\n this.username = null;\n this.userId = null;\n this.__instanceType = instanceType;\n this.__debug = debug;\n this.__privates = {\n playerFactory: playerFactory,\n providerAuth: providerAuth,\n room: modules.room,\n auth: modules.auth,\n iot: modules.iot\n };\n\n this.setInstanceType = function (newInstanceType) {\n return _this.__instanceType = newInstanceType;\n };\n\n this.isReady = modules.room.whenInitialized;\n this.browser = modules.room.browser;\n this.browserDetails = modules.room.browserDetails;\n this.auth = _objectSpread({}, _models_auth__WEBPACK_IMPORTED_MODULE_3__[\"default\"].call(this));\n this.user = _objectSpread({}, _models_user__WEBPACK_IMPORTED_MODULE_5__[\"default\"].call(this));\n this.room = _objectSpread({}, _models_room__WEBPACK_IMPORTED_MODULE_4__[\"default\"].call(this));\n this.asset = _objectSpread({}, _models_asset__WEBPACK_IMPORTED_MODULE_6__[\"default\"].call(this));\n this.system = _objectSpread({}, _models_system__WEBPACK_IMPORTED_MODULE_7__[\"default\"].call(this));\n this.iot = _objectSpread({}, _models_iot__WEBPACK_IMPORTED_MODULE_9__[\"default\"].call(this));\n this.utils = _models_utils__WEBPACK_IMPORTED_MODULE_8__[\"default\"];\n}\n\nvar watchTogether = function watchTogether() {\n var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref$debug = _ref.debug,\n debug = _ref$debug === void 0 ? true : _ref$debug,\n _ref$language = _ref.language,\n language = _ref$language === void 0 ? 'en-GB' : _ref$language,\n _ref$storagePrefix = _ref.storagePrefix,\n storagePrefix = _ref$storagePrefix === void 0 ? \"reactoo_\" : _ref$storagePrefix,\n _ref$apiUrl = _ref.apiUrl,\n apiUrl = _ref$apiUrl === void 0 ? null : _ref$apiUrl;\n\n var room = new _modules_wt_room__WEBPACK_IMPORTED_MODULE_0__[\"default\"](debug);\n var auth = new _modules_wt_auth__WEBPACK_IMPORTED_MODULE_1__[\"default\"](debug, language, storagePrefix, apiUrl);\n var iot = new _modules_wt_iot__WEBPACK_IMPORTED_MODULE_2__[\"default\"](debug);\n return function () {\n var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref2$instanceType = _ref2.instanceType,\n instanceType = _ref2$instanceType === void 0 ? 'reactooDemo' : _ref2$instanceType,\n _ref2$playerFactory = _ref2.playerFactory,\n playerFactory = _ref2$playerFactory === void 0 ? null : _ref2$playerFactory,\n _ref2$providerAuth = _ref2.providerAuth,\n providerAuth = _ref2$providerAuth === void 0 ? null : _ref2$providerAuth;\n\n return new WatchTogether({\n room: room,\n auth: auth,\n iot: iot\n }, instanceType, debug, playerFactory, providerAuth);\n };\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (watchTogether);\n\n//# sourceURL=webpack://WatchTogetherSDK/./src/index.js?");
|
|
8262
8262
|
|
|
8263
8263
|
/***/ }),
|
|
8264
8264
|
|
|
@@ -8306,7 +8306,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n\n\nfunction _toConsumableArr
|
|
|
8306
8306
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
8307
8307
|
|
|
8308
8308
|
"use strict";
|
|
8309
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _modules_wt_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../modules/wt-utils */ \"./src/modules/wt-utils.js\");\n/* harmony import */ var _modules_wt_emitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../modules/wt-emitter */ \"./src/modules/wt-emitter.js\");\n/* harmony import */ var _modules_sync_modules_sync_hls__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../modules/sync-modules/sync-hls */ \"./src/modules/sync-modules/sync-hls.js\");\n/* harmony import */ var _modules_sync_modules_sync_hls_vod__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../modules/sync-modules/sync-hls-vod */ \"./src/modules/sync-modules/sync-hls-vod.js\");\n/* harmony import */ var _modules_sync_modules_sync_native_hls_vod__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../modules/sync-modules/sync-native-hls-vod */ \"./src/modules/sync-modules/sync-native-hls-vod.js\");\n/* harmony import */ var _modules_sync_modules_sync_native_hls__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../modules/sync-modules/sync-native-hls */ \"./src/modules/sync-modules/sync-native-hls.js\");\n/* harmony import */ var _modules_sync_modules_sync_shaka_dash__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../modules/sync-modules/sync-shaka-dash */ \"./src/modules/sync-modules/sync-shaka-dash.js\");\n/* harmony import */ var _modules_sync_modules_sync_shaka_dash_vod__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../modules/sync-modules/sync-shaka-dash-vod */ \"./src/modules/sync-modules/sync-shaka-dash-vod.js\");\n/* harmony import */ var _modules_sync_modules_sync_dash__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../modules/sync-modules/sync-dash */ \"./src/modules/sync-modules/sync-dash.js\");\n/* harmony import */ var _modules_sync_modules_sync_dash_vod__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../modules/sync-modules/sync-dash-vod */ \"./src/modules/sync-modules/sync-dash-vod.js\");\n/* harmony import */ var _modules_sync_modules_sync_doris__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../modules/sync-modules/sync-doris */ \"./src/modules/sync-modules/sync-doris.js\");\n/* harmony import */ var _modules_sync_modules_sync_disabled__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../modules/sync-modules/sync-disabled */ \"./src/modules/sync-modules/sync-disabled.js\");\n/* harmony import */ var _modules_sync_modules_sync_dazn_dash__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../modules/sync-modules/sync-dazn-dash */ \"./src/modules/sync-modules/sync-dazn-dash.js\");\n/* harmony import */ var _modules_sync_modules_sync_universal__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../modules/sync-modules/sync-universal */ \"./src/modules/sync-modules/sync-universal.js\");\n\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== \"undefined\" && arr[Symbol.iterator] || arr[\"@@iterator\"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\n\n // SYNCHRONISATION MODULES\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar roomSession = function roomSession(_ref, room, wt) {\n var _this4 = this;\n\n var roomId = _ref.roomId,\n pinHash = _ref.pinHash,\n isTalkback = _ref.isTalkback,\n isMonitor = _ref.isMonitor,\n isInstructor = _ref.isInstructor;\n var primaryRoomId = roomId;\n var publicCustomEvents = ['changePlayerSource', 'chatMessage', 'userUpdate', 'reconnecting', 'connecting', 'remoteMuted', 'scaling'];\n\n var addEvents = function addEvents(events) {\n publicCustomEvents = [].concat(_toConsumableArray(publicCustomEvents), _toConsumableArray(events));\n };\n\n var removeEvents = function removeEvents(events) {\n publicCustomEvents = publicCustomEvents.filter(function (ev) {\n return events.indexOf(ev) === -1;\n });\n };\n\n var emitter = Object(_modules_wt_emitter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])();\n\n var alpTimeoutId = null;\n\n var ___; // return object\n\n\n room.on('addLocalParticipant', function () {\n // TODO: this doesnt seem to be fixable until we switch to differen type of messaging\n // At some random case we don't get message back if we don't wait\n clearTimeout(alpTimeoutId);\n alpTimeoutId = setTimeout(function () {\n ___.__requestMuteStatus();\n }, 2000);\n });\n room.on('localMuted', function (_ref2) {\n var type = _ref2.type,\n value = _ref2.value;\n\n ___.sendSystemMessage('remote_muted', {\n type: type,\n value: value\n });\n });\n room.on('data', function (data) {\n ___.__parseDataEvents(data);\n });\n return ___ = {\n syncModule: null,\n playerInterface: null,\n\n get userId() {\n return room.userId;\n },\n\n get roomId() {\n return roomId;\n },\n\n get sessionId() {\n return room.sessionId;\n },\n\n get constructId() {\n return room.constructId;\n },\n\n destroy: function destroy() {\n var _this = this;\n\n clearTimeout(alpTimeoutId);\n this.detachPlayer();\n return room.destroy().finally(function () {\n _this.$clear();\n\n return true;\n });\n },\n iceRestart: function iceRestart() {\n return room._iceRestart(room.handleId);\n },\n connect: function connect() {\n var _this2 = this;\n\n var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref3$reactooRoomId = _ref3.reactooRoomId,\n reactooRoomId = _ref3$reactooRoomId === void 0 ? null : _ref3$reactooRoomId;\n\n emitter.emit('connecting', true);\n clearTimeout(alpTimeoutId);\n return Promise.all([wt.room.__joinRoom({\n roomId: reactooRoomId || primaryRoomId,\n pinHash: pinHash,\n isTalkback: isTalkback,\n isMonitor: isMonitor,\n isInstructor: isInstructor\n }), wt.user.getUserSelf()]).then(function (_ref4) {\n var _roomData$data;\n\n var _ref5 = _slicedToArray(_ref4, 2),\n roomData = _ref5[0],\n userData = _ref5[1];\n\n // Happens when we reroute user to a different room\n if ((roomData === null || roomData === void 0 ? void 0 : (_roomData$data = roomData.data) === null || _roomData$data === void 0 ? void 0 : _roomData$data.reactooRoomId) !== roomId) {\n roomId = roomData.data.reactooRoomId;\n emitter.emit('changeRoomId', roomId);\n }\n\n return Promise.all([roomData, userData]);\n }).then(function (_ref6) {\n var _ref7 = _slicedToArray(_ref6, 2),\n roomData = _ref7[0],\n userData = _ref7[1];\n\n return Promise.all([roomData, userData, _this2.setRoomVars()]);\n }).then(function (_ref8) {\n var _ref9 = _slicedToArray(_ref8, 3),\n roomData = _ref9[0],\n userData = _ref9[1],\n _ = _ref9[2];\n\n return Promise.all([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)]);\n }).finally(function () {\n emitter.emit('connecting', false);\n });\n },\n disconnect: function disconnect(dontWaitForResponses) {\n clearTimeout(alpTimeoutId);\n return room.disconnect(dontWaitForResponses);\n },\n //TODO: refactor restart method\n restart: function restart() {\n var _handle$webrtcStuff,\n _this3 = this;\n\n var _ref10 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref10$isObserver = _ref10.isObserver,\n isObserver = _ref10$isObserver === void 0 ? false : _ref10$isObserver,\n _ref10$reactooRoomId = _ref10.reactooRoomId,\n reactooRoomId = _ref10$reactooRoomId === void 0 ? null : _ref10$reactooRoomId;\n\n emitter.emit('reconnecting', true);\n room.isRestarting = true;\n var wasPublished = room._isPublished;\n\n var handle = room._getHandle(room.handleId);\n\n var stream = null;\n\n if (handle !== null && handle !== void 0 && (_handle$webrtcStuff = handle.webrtcStuff) !== null && _handle$webrtcStuff !== void 0 && _handle$webrtcStuff.stream && wasPublished) {\n stream = handle.webrtcStuff.stream;\n }\n\n return this.disconnect().then(function () {\n return Object(_modules_wt_utils__WEBPACK_IMPORTED_MODULE_0__[\"wait\"])(1000);\n }) //TODO: remove 1000ms wait by waiting for proper events from janus\n .then(function () {\n return _this3.connect({\n reactooRoomId: reactooRoomId\n });\n }).then(function () {\n if (isObserver) {\n return _this3.publishLocal(null, {\n getStreamIfEmpty: false,\n unpublishFirst: true\n });\n } else if (stream) {\n return _this3.publishLocal(stream);\n } else return Promise.resolve();\n }).then(function () {\n room.isRestarting = false;\n emitter.emit('reconnecting', false);\n return 1;\n }).catch(function (error) {\n room.isRestarting = false;\n emitter.emit('reconnecting', false);\n emitter.emit('error', {\n type: 'error',\n id: 26,\n message: 'reconnecting failed',\n data: error\n });\n return Promise.reject(0);\n });\n },\n getStats: function getStats() {\n var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n return room._getStats(type);\n },\n getRoomParticipants: function getRoomParticipants() {\n return room._participants;\n },\n __parseDataEvents: function __parseDataEvents() {\n var msg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n if (msg.videoroom === 'message') {\n if (msg.action === 'pending_shutdown' || msg.action === 'shutting_down') {\n emitter.emit('scaling');\n this.restart(); // current videoroom was reassigned to a different WebRTC instance\n } else if (msg.action === 'force_restart') {\n this.restart();\n } else if (msg.action === 'user_update_displayname' || msg.action === 'user_update_avatar' || msg.action === 'user_update_customattributes' || msg.action === 'user_update_privateattributes') {\n emitter.emit('userUpdate', msg.text);\n } else if (msg.action === 'observer_connecting' || msg.action === 'talkback_connecting' || msg.action === 'instructor_connecting') {\n this.setRoomVars(null, msg.action === 'observer_connecting').catch(function (e) {\n room._log('Setting observers failed, this will cause issues', e);\n });\n } else if (msg.action === 'bitrate_changed') {\n this.setBitrateCap(msg.text);\n } else if (msg.user_action === 'chat_message') {\n emitter.emit('chatMessage', msg);\n } else if (msg.user_action === 'remote_muted') {\n if (msg.from !== room.userId) {\n emitter.emit('remoteMuted', _objectSpread({\n userId: msg.from\n }, msg.text && JSON.parse(msg.text)));\n }\n } else if (msg.user_action === 'remote_muted_request') {\n if (msg.from !== room.userId) {\n this.__sendMuteStatus();\n }\n }\n }\n },\n renderPlayer: function renderPlayer(playerWrapper, fullscreenElement) {\n try {\n this.syncModule = Object(_modules_sync_modules_sync_universal__WEBPACK_IMPORTED_MODULE_13__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n this.playerInterface = wt.__privates.playerFactory(playerWrapper, fullscreenElement, this.syncModule.getHandlers(), {\n roomId: room.roomId\n });\n this.syncModule.initialize({\n playerInterface: this.playerInterface\n });\n return true;\n } catch (e) {\n return false;\n }\n },\n attachPlayer: function attachPlayer(type, inputs) {\n this.detachPlayer();\n\n if (type === 'hlsjs') {\n this.syncModule = Object(_modules_sync_modules_sync_hls__WEBPACK_IMPORTED_MODULE_2__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'hlsjs-vod') {\n this.syncModule = Object(_modules_sync_modules_sync_hls_vod__WEBPACK_IMPORTED_MODULE_3__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'hlsnative-vod') {\n this.syncModule = Object(_modules_sync_modules_sync_native_hls_vod__WEBPACK_IMPORTED_MODULE_4__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'hlsnative') {\n this.syncModule = Object(_modules_sync_modules_sync_native_hls__WEBPACK_IMPORTED_MODULE_5__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'shaka-dash-vod') {\n this.syncModule = Object(_modules_sync_modules_sync_shaka_dash_vod__WEBPACK_IMPORTED_MODULE_7__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'shaka-dash') {\n this.syncModule = Object(_modules_sync_modules_sync_shaka_dash__WEBPACK_IMPORTED_MODULE_6__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'dashjs') {\n this.syncModule = Object(_modules_sync_modules_sync_dash__WEBPACK_IMPORTED_MODULE_8__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'dashjs-vod') {\n this.syncModule = Object(_modules_sync_modules_sync_dash_vod__WEBPACK_IMPORTED_MODULE_9__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'doris') {\n this.syncModule = Object(_modules_sync_modules_sync_doris__WEBPACK_IMPORTED_MODULE_10__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'dazn-dash') {\n this.syncModule = Object(_modules_sync_modules_sync_dazn_dash__WEBPACK_IMPORTED_MODULE_12__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'disabled') {\n this.syncModule = Object(_modules_sync_modules_sync_disabled__WEBPACK_IMPORTED_MODULE_11__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else {\n room._log('Synchronisation type not recognised');\n }\n },\n detachPlayer: function detachPlayer() {\n if (this.syncModule) {\n this.playerInterface = null;\n this.syncModule.destroy();\n\n if (this.syncModule.__events) {\n removeEvents(this.syncModule.__events);\n }\n\n this.syncModule = null;\n }\n },\n setRoomVars: function setRoomVars() {\n var observerIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var emit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;\n return wt.room.getRoomById(roomId, pinHash).then(function (r) {\n var _r$data$classroom;\n\n if (emit) {\n // emiting \"fake\" playerSource event\n //TODO: somehow push into sync modules instead\n emitter.emit('changePlayerSource', r.data.wtChannelId, true);\n } // setting observers userId's so we can ignore them when creating participant\n\n\n room.setObserverIds(r.data.allowedObservers);\n room.setTalkbackIds(r.data.allowedTalkbacks);\n room.setInstructorId((_r$data$classroom = r.data.classroom) === null || _r$data$classroom === void 0 ? void 0 : _r$data$classroom.instructorUserId);\n });\n },\n publishLocal: function publishLocal() {\n var stream = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n\n var _ref11 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n _ref11$keepAudio = _ref11.keepAudio,\n keepAudio = _ref11$keepAudio === void 0 ? false : _ref11$keepAudio,\n _ref11$keepVideo = _ref11.keepVideo,\n keepVideo = _ref11$keepVideo === void 0 ? false : _ref11$keepVideo,\n _ref11$getStreamIfEmp = _ref11.getStreamIfEmpty,\n getStreamIfEmpty = _ref11$getStreamIfEmp === void 0 ? true : _ref11$getStreamIfEmp,\n _ref11$askVideo = _ref11.askVideo,\n askVideo = _ref11$askVideo === void 0 ? true : _ref11$askVideo;\n\n return stream || !getStreamIfEmpty ? room.publishLocal(stream, {\n keepAudio: keepAudio,\n keepVideo: keepVideo\n }) : wt.utils.getUserStream(askVideo).then(function (stream) {\n return room.publishLocal(stream);\n });\n },\n unpublishLocal: function unpublishLocal() {\n return room.unpublishLocal();\n },\n toggleAudio: function toggleAudio(value) {\n return room.toggleAudio(value);\n },\n toggleVideo: function toggleVideo() {\n return room.toggleVideo();\n },\n setBitrateCap: function setBitrateCap(bitrate) {\n if (isInstructor) {\n return;\n }\n\n return room.sendMessage(room.handleId, {\n \"body\": {\n \"request\": \"configure\",\n \"bitrate\": parseInt(bitrate)\n }\n }).catch(function () {\n return null;\n });\n },\n switchChannel: function switchChannel(channelId) {\n return room.sendMessage(room.handleId, {\n body: {\n request: \"sync_source_set\",\n room: room.roomId,\n timestamp: new Date().getTime(),\n wt_channel_id: channelId,\n fragment: \"0\",\n fragment_pos: 0\n }\n });\n },\n sendSystemMessage: function sendSystemMessage(action) {\n var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var to = arguments.length > 2 ? arguments[2] : undefined;\n var set_master = arguments.length > 3 ? arguments[3] : undefined;\n return room.sendMessage(room.handleId, {\n body: _objectSpread(_objectSpread({\n action: action,\n request: \"message\",\n room: room.roomId,\n timestamp: new Date().getTime(),\n text: JSON.stringify(value)\n }, to && Array.isArray(to) ? {\n tos: to\n } : {\n to: to\n }), set_master && {\n set_master: set_master\n })\n });\n },\n sendChatMessage: function sendChatMessage(text, to) {\n return room.sendMessage(room.handleId, {\n body: _objectSpread({\n action: \"chat_message\",\n request: \"message\",\n room: room.roomId,\n timestamp: new Date().getTime(),\n text: text\n }, to && Array.isArray(to) ? {\n tos: to\n } : {\n to: to\n })\n });\n },\n __requestMuteStatus: function __requestMuteStatus() {\n this.sendSystemMessage('remote_muted_request');\n },\n __sendMuteStatus: function __sendMuteStatus() {\n this.sendSystemMessage('remote_muted', {\n type: 'video',\n value: room.isVideoMuted\n });\n this.sendSystemMessage('remote_muted', {\n type: 'audio',\n value: room.isAudioMuted\n });\n },\n $on: function $on(key, callback, that) {\n emitter.on(key, callback, that || _this4);\n room.on(key, callback, that || _this4);\n },\n $off: function $off(key, callback, that) {\n emitter.on(key, callback, that || _this4);\n room.on(key, callback, that || _this4);\n },\n $clear: function $clear() {\n room.clear();\n emitter.clear();\n }\n };\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (roomSession);\n\n//# sourceURL=webpack://WatchTogetherSDK/./src/models/room-session.js?");
|
|
8309
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _modules_wt_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../modules/wt-utils */ \"./src/modules/wt-utils.js\");\n/* harmony import */ var _modules_wt_emitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../modules/wt-emitter */ \"./src/modules/wt-emitter.js\");\n/* harmony import */ var _modules_sync_modules_sync_hls__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../modules/sync-modules/sync-hls */ \"./src/modules/sync-modules/sync-hls.js\");\n/* harmony import */ var _modules_sync_modules_sync_hls_vod__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../modules/sync-modules/sync-hls-vod */ \"./src/modules/sync-modules/sync-hls-vod.js\");\n/* harmony import */ var _modules_sync_modules_sync_native_hls_vod__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../modules/sync-modules/sync-native-hls-vod */ \"./src/modules/sync-modules/sync-native-hls-vod.js\");\n/* harmony import */ var _modules_sync_modules_sync_native_hls__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../modules/sync-modules/sync-native-hls */ \"./src/modules/sync-modules/sync-native-hls.js\");\n/* harmony import */ var _modules_sync_modules_sync_shaka_dash__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../modules/sync-modules/sync-shaka-dash */ \"./src/modules/sync-modules/sync-shaka-dash.js\");\n/* harmony import */ var _modules_sync_modules_sync_shaka_dash_vod__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../modules/sync-modules/sync-shaka-dash-vod */ \"./src/modules/sync-modules/sync-shaka-dash-vod.js\");\n/* harmony import */ var _modules_sync_modules_sync_dash__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../modules/sync-modules/sync-dash */ \"./src/modules/sync-modules/sync-dash.js\");\n/* harmony import */ var _modules_sync_modules_sync_dash_vod__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../modules/sync-modules/sync-dash-vod */ \"./src/modules/sync-modules/sync-dash-vod.js\");\n/* harmony import */ var _modules_sync_modules_sync_doris__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../modules/sync-modules/sync-doris */ \"./src/modules/sync-modules/sync-doris.js\");\n/* harmony import */ var _modules_sync_modules_sync_disabled__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../modules/sync-modules/sync-disabled */ \"./src/modules/sync-modules/sync-disabled.js\");\n/* harmony import */ var _modules_sync_modules_sync_dazn_dash__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../modules/sync-modules/sync-dazn-dash */ \"./src/modules/sync-modules/sync-dazn-dash.js\");\n/* harmony import */ var _modules_sync_modules_sync_universal__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../modules/sync-modules/sync-universal */ \"./src/modules/sync-modules/sync-universal.js\");\n\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== \"undefined\" && arr[Symbol.iterator] || arr[\"@@iterator\"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\n\n // SYNCHRONISATION MODULES\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar roomSession = function roomSession(_ref, room, wt) {\n var _this4 = this;\n\n var roomId = _ref.roomId,\n pinHash = _ref.pinHash,\n isTalkback = _ref.isTalkback,\n isMonitor = _ref.isMonitor,\n isInstructor = _ref.isInstructor;\n var primaryRoomId = roomId;\n var publicCustomEvents = ['changePlayerSource', 'chatMessage', 'userUpdate', 'reconnecting', 'connecting', 'remoteMuted', 'scaling'];\n\n var addEvents = function addEvents(events) {\n publicCustomEvents = [].concat(_toConsumableArray(publicCustomEvents), _toConsumableArray(events));\n };\n\n var removeEvents = function removeEvents(events) {\n publicCustomEvents = publicCustomEvents.filter(function (ev) {\n return events.indexOf(ev) === -1;\n });\n };\n\n var emitter = Object(_modules_wt_emitter__WEBPACK_IMPORTED_MODULE_1__[\"default\"])();\n\n var alpTimeoutId = null;\n\n var ___; // return object\n\n\n room.on('addLocalParticipant', function () {\n // TODO: this doesnt seem to be fixable until we switch to differen type of messaging\n // At some random case we don't get message back if we don't wait\n clearTimeout(alpTimeoutId);\n alpTimeoutId = setTimeout(function () {\n ___.__requestMuteStatus();\n }, 2000);\n });\n room.on('localMuted', function (_ref2) {\n var type = _ref2.type,\n value = _ref2.value;\n\n ___.sendSystemMessage('remote_muted', {\n type: type,\n value: value\n });\n });\n room.on('data', function (data) {\n ___.__parseDataEvents(data);\n });\n return ___ = {\n syncModule: null,\n playerInterface: null,\n\n get userId() {\n return room.userId;\n },\n\n get roomId() {\n return roomId;\n },\n\n get sessionId() {\n return room.sessionId;\n },\n\n get constructId() {\n return room.constructId;\n },\n\n destroy: function destroy() {\n var _this = this;\n\n clearTimeout(alpTimeoutId);\n this.detachPlayer();\n return room.destroy().finally(function () {\n _this.$clear();\n\n return true;\n });\n },\n iceRestart: function iceRestart() {\n return room._iceRestart(room.handleId);\n },\n connect: function connect() {\n var _this2 = this;\n\n var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref3$reactooRoomId = _ref3.reactooRoomId,\n reactooRoomId = _ref3$reactooRoomId === void 0 ? null : _ref3$reactooRoomId;\n\n emitter.emit('connecting', true);\n clearTimeout(alpTimeoutId);\n return Promise.all([wt.room.__joinRoom({\n roomId: reactooRoomId || primaryRoomId,\n pinHash: pinHash,\n isTalkback: isTalkback,\n isMonitor: isMonitor,\n isInstructor: isInstructor\n }), wt.user.getUserSelf()]).then(function (_ref4) {\n var _roomData$data;\n\n var _ref5 = _slicedToArray(_ref4, 2),\n roomData = _ref5[0],\n userData = _ref5[1];\n\n // Happens when we reroute user to a different room\n if ((roomData === null || roomData === void 0 ? void 0 : (_roomData$data = roomData.data) === null || _roomData$data === void 0 ? void 0 : _roomData$data.reactooRoomId) !== roomId) {\n roomId = roomData.data.reactooRoomId;\n emitter.emit('changeRoomId', roomId);\n }\n\n return Promise.all([roomData, userData]);\n }).then(function (_ref6) {\n var _ref7 = _slicedToArray(_ref6, 2),\n roomData = _ref7[0],\n userData = _ref7[1];\n\n return Promise.all([roomData, userData, _this2.setRoomVars()]);\n }).then(function (_ref8) {\n var _ref9 = _slicedToArray(_ref8, 3),\n roomData = _ref9[0],\n userData = _ref9[1],\n _ = _ref9[2];\n\n return Promise.all([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)]);\n }).finally(function () {\n emitter.emit('connecting', false);\n });\n },\n disconnect: function disconnect(dontWaitForResponses) {\n clearTimeout(alpTimeoutId);\n return room.disconnect(dontWaitForResponses);\n },\n //TODO: refactor restart method\n restart: function restart() {\n var _handle$webrtcStuff,\n _this3 = this;\n\n var _ref10 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref10$isObserver = _ref10.isObserver,\n isObserver = _ref10$isObserver === void 0 ? false : _ref10$isObserver,\n _ref10$reactooRoomId = _ref10.reactooRoomId,\n reactooRoomId = _ref10$reactooRoomId === void 0 ? null : _ref10$reactooRoomId;\n\n emitter.emit('reconnecting', true);\n room.isRestarting = true;\n var wasPublished = room._isPublished;\n\n var handle = room._getHandle(room.handleId);\n\n var stream = null;\n\n if (handle !== null && handle !== void 0 && (_handle$webrtcStuff = handle.webrtcStuff) !== null && _handle$webrtcStuff !== void 0 && _handle$webrtcStuff.stream && wasPublished) {\n stream = handle.webrtcStuff.stream;\n }\n\n return this.disconnect().then(function () {\n return Object(_modules_wt_utils__WEBPACK_IMPORTED_MODULE_0__[\"wait\"])(1000);\n }) //TODO: remove 1000ms wait by waiting for proper events from janus\n .then(function () {\n return _this3.connect({\n reactooRoomId: reactooRoomId\n });\n }).then(function () {\n if (isObserver) {\n return _this3.publishLocal(null);\n } else if (stream) {\n return _this3.publishLocal(stream);\n } else return Promise.resolve();\n }).then(function () {\n room.isRestarting = false;\n emitter.emit('reconnecting', false);\n return 1;\n }).catch(function (error) {\n room.isRestarting = false;\n emitter.emit('reconnecting', false);\n emitter.emit('error', {\n type: 'error',\n id: 26,\n message: 'reconnecting failed',\n data: error\n });\n return Promise.reject(0);\n });\n },\n getStats: function getStats() {\n var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n return room._getStats(type);\n },\n getRoomParticipants: function getRoomParticipants() {\n return room._participants;\n },\n __parseDataEvents: function __parseDataEvents() {\n var msg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n if (msg.videoroom === 'message') {\n if (msg.action === 'pending_shutdown' || msg.action === 'shutting_down') {\n emitter.emit('scaling');\n this.restart(); // current videoroom was reassigned to a different WebRTC instance\n } else if (msg.action === 'force_restart') {\n this.restart();\n } else if (msg.action === 'user_update_displayname' || msg.action === 'user_update_avatar' || msg.action === 'user_update_customattributes' || msg.action === 'user_update_privateattributes') {\n emitter.emit('userUpdate', msg.text);\n } else if (msg.action === 'observer_connecting' || msg.action === 'talkback_connecting' || msg.action === 'instructor_connecting') {\n this.setRoomVars(null, msg.action === 'observer_connecting').catch(function (e) {\n room._log('Setting observers failed, this will cause issues', e);\n });\n } else if (msg.action === 'bitrate_changed') {\n this.setBitrateCap(msg.text);\n } else if (msg.user_action === 'chat_message') {\n emitter.emit('chatMessage', msg);\n } else if (msg.user_action === 'remote_muted') {\n if (msg.from !== room.userId) {\n emitter.emit('remoteMuted', _objectSpread({\n userId: msg.from\n }, msg.text && JSON.parse(msg.text)));\n }\n } else if (msg.user_action === 'remote_muted_request') {\n if (msg.from !== room.userId) {\n this.__sendMuteStatus();\n }\n }\n }\n },\n renderPlayer: function renderPlayer(playerWrapper, fullscreenElement) {\n try {\n this.syncModule = Object(_modules_sync_modules_sync_universal__WEBPACK_IMPORTED_MODULE_13__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n this.playerInterface = wt.__privates.playerFactory(playerWrapper, fullscreenElement, this.syncModule.getHandlers(), {\n roomId: room.roomId\n });\n this.syncModule.initialize({\n playerInterface: this.playerInterface\n });\n return true;\n } catch (e) {\n return false;\n }\n },\n attachPlayer: function attachPlayer(type, inputs) {\n this.detachPlayer();\n\n if (type === 'hlsjs') {\n this.syncModule = Object(_modules_sync_modules_sync_hls__WEBPACK_IMPORTED_MODULE_2__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'hlsjs-vod') {\n this.syncModule = Object(_modules_sync_modules_sync_hls_vod__WEBPACK_IMPORTED_MODULE_3__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'hlsnative-vod') {\n this.syncModule = Object(_modules_sync_modules_sync_native_hls_vod__WEBPACK_IMPORTED_MODULE_4__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'hlsnative') {\n this.syncModule = Object(_modules_sync_modules_sync_native_hls__WEBPACK_IMPORTED_MODULE_5__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'shaka-dash-vod') {\n this.syncModule = Object(_modules_sync_modules_sync_shaka_dash_vod__WEBPACK_IMPORTED_MODULE_7__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'shaka-dash') {\n this.syncModule = Object(_modules_sync_modules_sync_shaka_dash__WEBPACK_IMPORTED_MODULE_6__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'dashjs') {\n this.syncModule = Object(_modules_sync_modules_sync_dash__WEBPACK_IMPORTED_MODULE_8__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'dashjs-vod') {\n this.syncModule = Object(_modules_sync_modules_sync_dash_vod__WEBPACK_IMPORTED_MODULE_9__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'doris') {\n this.syncModule = Object(_modules_sync_modules_sync_doris__WEBPACK_IMPORTED_MODULE_10__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'dazn-dash') {\n this.syncModule = Object(_modules_sync_modules_sync_dazn_dash__WEBPACK_IMPORTED_MODULE_12__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else if (type === 'disabled') {\n this.syncModule = Object(_modules_sync_modules_sync_disabled__WEBPACK_IMPORTED_MODULE_11__[\"default\"])({\n room: room,\n wt: wt,\n roomSession: this,\n emitter: emitter\n });\n\n if (this.syncModule.__events) {\n addEvents(this.syncModule.__events);\n }\n\n this.syncModule.initialize(inputs);\n } else {\n room._log('Synchronisation type not recognised');\n }\n },\n detachPlayer: function detachPlayer() {\n if (this.syncModule) {\n this.playerInterface = null;\n this.syncModule.destroy();\n\n if (this.syncModule.__events) {\n removeEvents(this.syncModule.__events);\n }\n\n this.syncModule = null;\n }\n },\n setRoomVars: function setRoomVars() {\n var observerIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var emit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;\n return wt.room.getRoomById(roomId, pinHash).then(function (r) {\n var _r$data$classroom;\n\n if (emit) {\n // emiting \"fake\" playerSource event\n //TODO: somehow push into sync modules instead\n emitter.emit('changePlayerSource', r.data.wtChannelId, true);\n } // setting observers userId's so we can ignore them when creating participant\n\n\n room.setObserverIds(r.data.allowedObservers);\n room.setTalkbackIds(r.data.allowedTalkbacks);\n room.setInstructorId((_r$data$classroom = r.data.classroom) === null || _r$data$classroom === void 0 ? void 0 : _r$data$classroom.instructorUserId);\n });\n },\n publishLocal: function publishLocal() {\n var stream = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n\n var _ref11 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},\n _ref11$keepAudio = _ref11.keepAudio,\n keepAudio = _ref11$keepAudio === void 0 ? false : _ref11$keepAudio,\n _ref11$keepVideo = _ref11.keepVideo,\n keepVideo = _ref11$keepVideo === void 0 ? false : _ref11$keepVideo;\n\n return room.publishLocal(stream, {\n keepAudio: keepAudio,\n keepVideo: keepVideo\n });\n },\n unpublishLocal: function unpublishLocal() {\n return room.unpublishLocal();\n },\n toggleAudio: function toggleAudio(value) {\n return room.toggleAudio(value);\n },\n toggleVideo: function toggleVideo() {\n return room.toggleVideo();\n },\n setBitrateCap: function setBitrateCap(bitrate) {\n if (isInstructor) {\n return;\n }\n\n return room.sendMessage(room.handleId, {\n \"body\": {\n \"request\": \"configure\",\n \"bitrate\": parseInt(bitrate)\n }\n }).catch(function () {\n return null;\n });\n },\n switchChannel: function switchChannel(channelId) {\n return room.sendMessage(room.handleId, {\n body: {\n request: \"sync_source_set\",\n room: room.roomId,\n timestamp: new Date().getTime(),\n wt_channel_id: channelId,\n fragment: \"0\",\n fragment_pos: 0\n }\n });\n },\n sendSystemMessage: function sendSystemMessage(action) {\n var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var to = arguments.length > 2 ? arguments[2] : undefined;\n var set_master = arguments.length > 3 ? arguments[3] : undefined;\n return room.sendMessage(room.handleId, {\n body: _objectSpread(_objectSpread({\n action: action,\n request: \"message\",\n room: room.roomId,\n timestamp: new Date().getTime(),\n text: JSON.stringify(value)\n }, to && Array.isArray(to) ? {\n tos: to\n } : {\n to: to\n }), set_master && {\n set_master: set_master\n })\n });\n },\n sendChatMessage: function sendChatMessage(text, to) {\n return room.sendMessage(room.handleId, {\n body: _objectSpread({\n action: \"chat_message\",\n request: \"message\",\n room: room.roomId,\n timestamp: new Date().getTime(),\n text: text\n }, to && Array.isArray(to) ? {\n tos: to\n } : {\n to: to\n })\n });\n },\n __requestMuteStatus: function __requestMuteStatus() {\n this.sendSystemMessage('remote_muted_request');\n },\n __sendMuteStatus: function __sendMuteStatus() {\n this.sendSystemMessage('remote_muted', {\n type: 'video',\n value: room.isVideoMuted\n });\n this.sendSystemMessage('remote_muted', {\n type: 'audio',\n value: room.isAudioMuted\n });\n },\n $on: function $on(key, callback, that) {\n emitter.on(key, callback, that || _this4);\n room.on(key, callback, that || _this4);\n },\n $off: function $off(key, callback, that) {\n emitter.on(key, callback, that || _this4);\n room.on(key, callback, that || _this4);\n },\n $clear: function $clear() {\n room.clear();\n emitter.clear();\n }\n };\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (roomSession);\n\n//# sourceURL=webpack://WatchTogetherSDK/./src/models/room-session.js?");
|
|
8310
8310
|
|
|
8311
8311
|
/***/ }),
|
|
8312
8312
|
|
|
@@ -8366,7 +8366,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _mod
|
|
|
8366
8366
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
8367
8367
|
|
|
8368
8368
|
"use strict";
|
|
8369
|
-
eval("__webpack_require__.r(__webpack_exports__);\n\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n getUserStream: function getUserStream(
|
|
8369
|
+
eval("__webpack_require__.r(__webpack_exports__);\n\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n getUserStream: function getUserStream() {\n var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n hasVideo = _ref.hasVideo,\n isHd = _ref.isHd,\n aDeviceId = _ref.aDeviceId,\n vDeviceId = _ref.vDeviceId,\n lfps = _ref.lfps,\n _ref$autoGainControl = _ref.autoGainControl,\n autoGainControl = _ref$autoGainControl === void 0 ? false : _ref$autoGainControl,\n _ref$muteAudio = _ref.muteAudio,\n muteAudio = _ref$muteAudio === void 0 ? false : _ref$muteAudio,\n _ref$muteVideo = _ref.muteVideo,\n muteVideo = _ref$muteVideo === void 0 ? false : _ref$muteVideo;\n\n var fullConstraints = {\n audio: _objectSpread(_objectSpread({}, aDeviceId && {\n deviceId: {\n exact: aDeviceId\n }\n }), {}, {\n autoGainControl: autoGainControl,\n echoCancellation: true,\n noiseSuppression: true,\n channelCount: 1\n }),\n video: _objectSpread(_objectSpread(_objectSpread({}, vDeviceId && {\n deviceId: {\n exact: vDeviceId\n }\n }), {}, {\n facingMode: {\n ideal: \"user\"\n }\n }, lfps ? {\n frameRate: {\n ideal: 10,\n max: 30\n }\n } : {\n frameRate: {\n ideal: 24,\n max: 30\n }\n }), {}, {\n width: {\n ideal: isHd ? 1280 : 320\n },\n height: {\n ideal: isHd ? 720 : 240\n }\n })\n };\n var audioOnlyConstraints = {\n audio: _objectSpread(_objectSpread({}, aDeviceId && {\n deviceId: {\n exact: aDeviceId\n }\n }), {}, {\n autoGainControl: autoGainControl,\n echoCancellation: true,\n noiseSuppression: true,\n channelCount: 1\n })\n };\n return navigator.mediaDevices.getUserMedia(hasVideo ? fullConstraints : audioOnlyConstraints).then(function (stream) {\n if (muteAudio) {\n stream.getAudioTracks().forEach(function (track) {\n return track.enabled = false;\n });\n }\n\n if (muteVideo) {\n stream.getVideoTracks().forEach(function (track) {\n return track.enabled = false;\n });\n }\n\n return stream;\n });\n }\n});\n\n//# sourceURL=webpack://WatchTogetherSDK/./src/models/utils.js?");
|
|
8370
8370
|
|
|
8371
8371
|
/***/ }),
|
|
8372
8372
|
|
|
@@ -8522,7 +8522,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _wt_
|
|
|
8522
8522
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
8523
8523
|
|
|
8524
8524
|
"use strict";
|
|
8525
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* WEBPACK VAR INJECTION */(function(Buffer) {/* harmony import */ var swagger_client__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! swagger-client */ \"./node_modules/swagger-client/es/index.js\");\n/* harmony import */ var _wt_config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./wt-config */ \"./src/modules/wt-config.js\");\n/* harmony import */ var _wt_emitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./wt-emitter */ \"./src/modules/wt-emitter.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\n\n\n\n\n\nvar Auth = /*#__PURE__*/function () {\n function Auth(enableDebugFlag) {\n var isProduction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;\n var language = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'en-GB';\n var storagePrefix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : \"\";\n var apiUrl = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;\n\n _classCallCheck(this, Auth);\n\n this.ID_TOKEN = \"\".concat(storagePrefix !== \"\" ? storagePrefix + '_' : '', \"rwt_idToken\");\n this.ACCESS_TOKEN = \"\".concat(storagePrefix !== \"\" ? storagePrefix + '_' : '', \"rwt_accessToken\");\n this.REFRESH_TOKEN = \"\".concat(storagePrefix !== \"\" ? storagePrefix + '_' : '', \"rwt_refreshToken\");\n Object.assign(this, Object(_wt_emitter__WEBPACK_IMPORTED_MODULE_2__[\"default\"])());\n this.__log = Auth.noop;\n\n if (enableDebugFlag) {\n this._enableDebug();\n }\n\n this.__language = language;\n this.__refreshTokenPromise = null;\n this.__isRefreshing = false;\n this.__isLogged = null;\n this.__parsedJwt = null;\n this.__specUrl = apiUrl ? apiUrl : isProduction === true ? _wt_config__WEBPACK_IMPORTED_MODULE_1__[\"default\"].apiUrl : _wt_config__WEBPACK_IMPORTED_MODULE_1__[\"default\"].devApiUrl;\n this.__client = this.initialize(true);\n }\n\n _createClass(Auth, [{\n key: \"_enableDebug\",\n value: function _enableDebug() {\n this.__log = console.log.bind(console);\n }\n }, {\n key: \"_requestInterceptor\",\n value: function _requestInterceptor(req) {\n if (!req.headers) {\n req.headers = {};\n }\n\n req.headers['Accept-Language'] = this.__language;\n return req;\n }\n }, {\n key: \"_responseInterceptor\",\n value: function _responseInterceptor(res, req) {\n var _this = this;\n\n if (res.status === 401) {\n if (this.__isLogged) {\n var rt = localStorage.getItem(this.REFRESH_TOKEN);\n this.__refreshTokenPromise = this.__isRefreshing ? this.__refreshTokenPromise : this.__client.then(function (client) {\n _this.__isRefreshing = true;\n return client.apis.auth.refreshToken({}, {\n requestBody: {\n refreshToken: localStorage.getItem(_this.REFRESH_TOKEN)\n }\n });\n }).then(function (r) {\n _this.__isRefreshing = false;\n return _this.login(r.data.idToken, r.data.accessToken, rt, true);\n }).catch(function (e) {\n _this.__isRefreshing = false;\n\n _this.logout();\n\n return Promise.reject(e);\n });\n return this.__refreshTokenPromise.then(function () {\n return swagger_client__WEBPACK_IMPORTED_MODULE_0__[\"default\"].http(_objectSpread(_objectSpread({}, req), {}, {\n headers: _objectSpread(_objectSpread({}, req.headers), {}, {\n Authorization: 'Bearer ' + localStorage.getItem(_this.ID_TOKEN)\n })\n }));\n }).then(function (res) {\n if (_typeof(res.obj) === 'object' && res.obj !== null) {\n res.data = res.obj;\n }\n\n return res;\n });\n }\n }\n\n if (_typeof(res.obj) === 'object' && res.obj !== null) {\n res.data = res.obj;\n }\n\n return res;\n }\n }, {\n key: \"initialize\",\n value: function initialize() {\n var _this2 = this;\n\n var isInitialEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n var isReauth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var idToken = localStorage.getItem(this.ID_TOKEN);\n var authorizations = {};\n\n if (idToken) {\n authorizations['bearer'] = '' + idToken;\n }\n\n this.__isLogged = !!idToken;\n\n var _that = this;\n\n return new swagger_client__WEBPACK_IMPORTED_MODULE_0__[\"default\"](this.__specUrl, {\n authorizations: authorizations,\n requestInterceptor: this._requestInterceptor.bind(this),\n responseInterceptor: function responseInterceptor(res) {\n return _that._responseInterceptor(res, this);\n }\n }).then(function (client) {\n _this2.__isLogged = !!idToken;\n _this2.__parsedJwt = _this2.parseJwt(idToken);\n\n _this2.emit(_this2.__isLogged ? 'login' : 'logout', {\n client: client,\n isInitialEvent: isInitialEvent,\n isLoggedInAsDevice: _this2.isLoggedInAs(_this2.__parsedJwt, 'device'),\n isLoggedInAsObserver: _this2.isLoggedInAs(_this2.__parsedJwt, 'observer'),\n isLoggedInAsInstanceAdmin: _this2.isLoggedInAs(_this2.__parsedJwt, 'instanceAdmin'),\n isLoggedInAsAdmin: _this2.isLoggedInAs(_this2.__parsedJwt, 'admin'),\n domain: _this2.getDomain(_this2.__parsedJwt),\n isReauth: isReauth\n });\n\n return client;\n }).catch(function (e) {\n _this2.__isLogged = false;\n\n _this2.emit('logout', {\n client: null,\n isInitialEvent: isInitialEvent,\n isLoggedInAsDevice: false,\n isLoggedInAsObserver: false,\n isLoggedInAsInstanceAdmin: false,\n isLoggedInAsAdmin: false,\n isReauth: isReauth\n });\n\n return Promise.reject(e);\n });\n }\n }, {\n key: \"login\",\n value: function login(idToken, accessToken, refreshToken) {\n var isReauth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;\n localStorage.setItem(this.ID_TOKEN, idToken);\n localStorage.setItem(this.ACCESS_TOKEN, accessToken);\n localStorage.setItem(this.REFRESH_TOKEN, refreshToken);\n return this.__client = this.initialize(false, isReauth);\n }\n }, {\n key: \"logout\",\n value: function logout() {\n localStorage.removeItem(this.ID_TOKEN);\n localStorage.removeItem(this.ACCESS_TOKEN);\n localStorage.removeItem(this.REFRESH_TOKEN);\n return this.__client = this.initialize();\n }\n }, {\n key: \"isLoggedIn\",\n value: function isLoggedIn() {\n return this.__isLogged;\n }\n }, {\n key: \"isLoggedInAs\",\n value: function isLoggedInAs(parsedJwt) {\n var as = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'device';\n parsedJwt = parsedJwt || this.__parsedJwt;\n return !!(parsedJwt && parsedJwt['cognito:groups'] && parsedJwt['cognito:groups'].includes(as));\n }\n }, {\n key: \"setLanguage\",\n value: function setLanguage(language) {\n this.__language = language;\n return this.__language;\n }\n }, {\n key: \"getDomain\",\n value: function getDomain(parsedJwt) {\n parsedJwt = parsedJwt || this.__parsedJwt;\n return parsedJwt['custom:domain'];\n }\n }, {\n key: \"parseJwt\",\n value: function parseJwt(jwt) {\n if (!jwt || typeof jwt !== \"string\") return false;\n var match = jwt.match(/^(([0-9a-zA-Z]*)\\.){2}[\\w-]*$/);\n if (!match || !match[2]) return false;\n\n try {\n match = new Buffer(match[2], 'base64').toString('binary');\n return JSON.parse(match);\n } catch (e) {\n return false;\n }\n }\n }], [{\n key: \"noop\",\n value: function noop() {}\n }]);\n\n return Auth;\n}();\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Auth);\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/node-libs-browser/node_modules/buffer/index.js */ \"./node_modules/node-libs-browser/node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack://WatchTogetherSDK/./src/modules/wt-auth.js?");
|
|
8525
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* WEBPACK VAR INJECTION */(function(Buffer) {/* harmony import */ var swagger_client__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! swagger-client */ \"./node_modules/swagger-client/es/index.js\");\n/* harmony import */ var _wt_config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./wt-config */ \"./src/modules/wt-config.js\");\n/* harmony import */ var _wt_emitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./wt-emitter */ \"./src/modules/wt-emitter.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\n\n\n\n\n\nvar Auth = /*#__PURE__*/function () {\n function Auth(enableDebugFlag) {\n var language = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-GB';\n var storagePrefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : \"\";\n var apiUrl = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;\n\n _classCallCheck(this, Auth);\n\n this.ID_TOKEN = \"\".concat(storagePrefix !== \"\" ? storagePrefix + '_' : '', \"rwt_idToken\");\n this.ACCESS_TOKEN = \"\".concat(storagePrefix !== \"\" ? storagePrefix + '_' : '', \"rwt_accessToken\");\n this.REFRESH_TOKEN = \"\".concat(storagePrefix !== \"\" ? storagePrefix + '_' : '', \"rwt_refreshToken\");\n Object.assign(this, Object(_wt_emitter__WEBPACK_IMPORTED_MODULE_2__[\"default\"])());\n this.__log = Auth.noop;\n\n if (enableDebugFlag) {\n this._enableDebug();\n }\n\n this.__language = language;\n this.__refreshTokenPromise = null;\n this.__isRefreshing = false;\n this.__isLogged = null;\n this.__parsedJwt = null;\n this.__specUrl = apiUrl ? apiUrl : _wt_config__WEBPACK_IMPORTED_MODULE_1__[\"default\"].apiUrl;\n this.__client = this.initialize(true);\n }\n\n _createClass(Auth, [{\n key: \"_enableDebug\",\n value: function _enableDebug() {\n this.__log = console.log.bind(console);\n }\n }, {\n key: \"_requestInterceptor\",\n value: function _requestInterceptor(req) {\n if (!req.headers) {\n req.headers = {};\n }\n\n req.headers['Accept-Language'] = this.__language;\n return req;\n }\n }, {\n key: \"_responseInterceptor\",\n value: function _responseInterceptor(res, req) {\n var _this = this;\n\n if (res.status === 401) {\n if (this.__isLogged) {\n var rt = localStorage.getItem(this.REFRESH_TOKEN);\n this.__refreshTokenPromise = this.__isRefreshing ? this.__refreshTokenPromise : this.__client.then(function (client) {\n _this.__isRefreshing = true;\n return client.apis.auth.refreshToken({}, {\n requestBody: {\n refreshToken: localStorage.getItem(_this.REFRESH_TOKEN)\n }\n });\n }).then(function (r) {\n _this.__isRefreshing = false;\n return _this.login(r.data.idToken, r.data.accessToken, rt, true);\n }).catch(function (e) {\n _this.__isRefreshing = false;\n\n _this.logout();\n\n return Promise.reject(e);\n });\n return this.__refreshTokenPromise.then(function () {\n return swagger_client__WEBPACK_IMPORTED_MODULE_0__[\"default\"].http(_objectSpread(_objectSpread({}, req), {}, {\n headers: _objectSpread(_objectSpread({}, req.headers), {}, {\n Authorization: 'Bearer ' + localStorage.getItem(_this.ID_TOKEN)\n })\n }));\n }).then(function (res) {\n if (_typeof(res.obj) === 'object' && res.obj !== null) {\n res.data = res.obj;\n }\n\n return res;\n });\n }\n }\n\n if (_typeof(res.obj) === 'object' && res.obj !== null) {\n res.data = res.obj;\n }\n\n return res;\n }\n }, {\n key: \"initialize\",\n value: function initialize() {\n var _this2 = this;\n\n var isInitialEvent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n var isReauth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var idToken = localStorage.getItem(this.ID_TOKEN);\n var authorizations = {};\n\n if (idToken) {\n authorizations['bearer'] = '' + idToken;\n }\n\n this.__isLogged = !!idToken;\n\n var _that = this;\n\n return new swagger_client__WEBPACK_IMPORTED_MODULE_0__[\"default\"](this.__specUrl, {\n authorizations: authorizations,\n requestInterceptor: this._requestInterceptor.bind(this),\n responseInterceptor: function responseInterceptor(res) {\n return _that._responseInterceptor(res, this);\n }\n }).then(function (client) {\n _this2.__isLogged = !!idToken;\n _this2.__parsedJwt = _this2.parseJwt(idToken);\n\n _this2.emit(_this2.__isLogged ? 'login' : 'logout', {\n client: client,\n isInitialEvent: isInitialEvent,\n isLoggedInAsDevice: _this2.isLoggedInAs(_this2.__parsedJwt, 'device'),\n isLoggedInAsObserver: _this2.isLoggedInAs(_this2.__parsedJwt, 'observer'),\n isLoggedInAsInstanceAdmin: _this2.isLoggedInAs(_this2.__parsedJwt, 'instanceAdmin'),\n isLoggedInAsAdmin: _this2.isLoggedInAs(_this2.__parsedJwt, 'admin'),\n domain: _this2.getDomain(_this2.__parsedJwt),\n isReauth: isReauth\n });\n\n return client;\n }).catch(function (e) {\n _this2.__isLogged = false;\n\n _this2.emit('logout', {\n client: null,\n isInitialEvent: isInitialEvent,\n isLoggedInAsDevice: false,\n isLoggedInAsObserver: false,\n isLoggedInAsInstanceAdmin: false,\n isLoggedInAsAdmin: false,\n isReauth: isReauth\n });\n\n return Promise.reject(e);\n });\n }\n }, {\n key: \"login\",\n value: function login(idToken, accessToken, refreshToken) {\n var isReauth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;\n localStorage.setItem(this.ID_TOKEN, idToken);\n localStorage.setItem(this.ACCESS_TOKEN, accessToken);\n localStorage.setItem(this.REFRESH_TOKEN, refreshToken);\n return this.__client = this.initialize(false, isReauth);\n }\n }, {\n key: \"logout\",\n value: function logout() {\n localStorage.removeItem(this.ID_TOKEN);\n localStorage.removeItem(this.ACCESS_TOKEN);\n localStorage.removeItem(this.REFRESH_TOKEN);\n return this.__client = this.initialize();\n }\n }, {\n key: \"isLoggedIn\",\n value: function isLoggedIn() {\n return this.__isLogged;\n }\n }, {\n key: \"isLoggedInAs\",\n value: function isLoggedInAs(parsedJwt) {\n var as = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'device';\n parsedJwt = parsedJwt || this.__parsedJwt;\n return !!(parsedJwt && parsedJwt['cognito:groups'] && parsedJwt['cognito:groups'].includes(as));\n }\n }, {\n key: \"setLanguage\",\n value: function setLanguage(language) {\n this.__language = language;\n return this.__language;\n }\n }, {\n key: \"getDomain\",\n value: function getDomain(parsedJwt) {\n parsedJwt = parsedJwt || this.__parsedJwt;\n return parsedJwt['custom:domain'];\n }\n }, {\n key: \"parseJwt\",\n value: function parseJwt(jwt) {\n if (!jwt || typeof jwt !== \"string\") return false;\n var match = jwt.match(/^(([0-9a-zA-Z]*)\\.){2}[\\w-]*$/);\n if (!match || !match[2]) return false;\n\n try {\n match = new Buffer(match[2], 'base64').toString('binary');\n return JSON.parse(match);\n } catch (e) {\n return false;\n }\n }\n }], [{\n key: \"noop\",\n value: function noop() {}\n }]);\n\n return Auth;\n}();\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Auth);\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/node-libs-browser/node_modules/buffer/index.js */ \"./node_modules/node-libs-browser/node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack://WatchTogetherSDK/./src/modules/wt-auth.js?");
|
|
8526
8526
|
|
|
8527
8527
|
/***/ }),
|
|
8528
8528
|
|