@reactoo/watchtogether-sdk-js 2.6.23 → 2.6.24
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @reactoo/watchtogether-sdk-js
|
|
3
|
-
* @version 2.6.
|
|
3
|
+
* @version 2.6.24
|
|
4
4
|
*/
|
|
5
5
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
6
6
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -10252,7 +10252,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _mod
|
|
|
10252
10252
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
10253
10253
|
|
|
10254
10254
|
"use strict";
|
|
10255
|
-
eval("__webpack_require__.r(__webpack_exports__);\n\n\nlet iot = function () {\n var _this = this;\n let __currentTopics = [];\n let __ = null;\n return {\n __promise: null,\n __reconnect: err => {\n this.__privates.iot.log('MQTT Error:', err, `Is event error: ${err instanceof Event}`);\n if (err instanceof Event && err.type === 'error') {\n this.__privates.iot.log('SDK MQTT Reconnection attempt');\n clearTimeout(__);\n __ = setTimeout(() => {\n this.iot.iotLogin(true, true).catch(e => this.__privates.iot.log('MQTT Connection Error:', e));\n }, 1000);\n }\n },\n __updateCredentials: () => {\n this.iot.getCredentials().then(response => this.__privates.iot.updateWebSocketCredentials(response.data.credentials.accessKeyId, response.data.credentials.secretAccessKey, response.data.credentials.sessionToken, response.data.credentials.expiration));\n },\n getCredentials: () => {\n return this.__privates.auth.__client.then(client => client.apis.auth.iotSignIn({}, {\n requestBody: {\n suggestedTopics: true,\n domain: location.hostname\n }\n }));\n },\n iotLogin: function () {\n let subscribeToSuggestedTopics = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n let forceDisconnect = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n _this.iot.$off('error', _this.iot.__reconnect, _this);\n _this.iot.__promise = new Promise((resolve, reject) => {\n _this.iot.getCredentials().then(response => {\n return Promise.all([response.data.suggestedTopics, _this.__privates.iot.connect(response.data.endpoint, response.data.clientId, response.data.region, response.data.credentials.accessKeyId, response.data.credentials.secretAccessKey, response.data.credentials.sessionToken, response.data.credentials.expiration, forceDisconnect)]);\n }).then(resolve).catch(reject);\n });\n let __currentTopicsCopy = [...__currentTopics];\n __currentTopics.length = 0;\n _this.iot.__promise.then(_ref => {\n let [suggestedTopic, instance] = _ref;\n if (!subscribeToSuggestedTopics) {\n return Promise.resolve(instance);\n }\n
|
|
10255
|
+
eval("__webpack_require__.r(__webpack_exports__);\n\n\nlet iot = function () {\n var _this = this;\n let __currentTopics = [];\n let __ = null;\n return {\n __promise: null,\n __reconnect: err => {\n this.__privates.iot.log('MQTT Error:', err, `Is event error: ${err instanceof Event}`);\n if (err instanceof Event && err.type === 'error') {\n this.__privates.iot.log('SDK MQTT Reconnection attempt');\n clearTimeout(__);\n __ = setTimeout(() => {\n this.iot.iotLogin(true, true).catch(e => this.__privates.iot.log('MQTT Connection Error:', e));\n }, 1000);\n }\n },\n __updateCredentials: () => {\n this.iot.getCredentials().then(response => this.__privates.iot.updateWebSocketCredentials(response.data.credentials.accessKeyId, response.data.credentials.secretAccessKey, response.data.credentials.sessionToken, response.data.credentials.expiration));\n },\n getCredentials: () => {\n return this.__privates.auth.__client.then(client => client.apis.auth.iotSignIn({}, {\n requestBody: {\n suggestedTopics: true,\n domain: location.hostname\n }\n }));\n },\n iotLogin: function () {\n let subscribeToSuggestedTopics = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;\n let forceDisconnect = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n _this.iot.$off('error', _this.iot.__reconnect, _this);\n _this.iot.__promise = new Promise((resolve, reject) => {\n _this.iot.getCredentials().then(response => {\n return Promise.all([response.data.suggestedTopics, _this.__privates.iot.connect(response.data.endpoint, response.data.clientId, response.data.region, response.data.credentials.accessKeyId, response.data.credentials.secretAccessKey, response.data.credentials.sessionToken, response.data.credentials.expiration, forceDisconnect)]);\n }).then(resolve).catch(reject);\n });\n let __currentTopicsCopy = [...__currentTopics];\n __currentTopics.length = 0;\n _this.iot.__promise.then(_ref => {\n let [suggestedTopic, instance] = _ref;\n if (!subscribeToSuggestedTopics) {\n return Promise.resolve(instance);\n }\n let topics = [...suggestedTopic, ...__currentTopicsCopy];\n topics = topics.filter((c, index) => {\n return topics.indexOf(c) === index;\n });\n return Promise.all(topics.map(topic => _this.iot.subscribe(topic))).then(() => instance);\n }).then(instance => {\n _this.iot.$on('error', _this.iot.__reconnect, _this);\n _this.iot.$on('updateCredentials', _this.iot.__updateCredentials, _this);\n return instance;\n });\n return _this.iot.__promise;\n },\n iotLogout: function () {\n let keepCurrentTopics = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n _this.iot.$off('error', _this.iot.__reconnect, _this);\n _this.iot.$off('updateCredentials', _this.iot.__updateCredentials, _this);\n if (!keepCurrentTopics) {\n __currentTopics.length = 0;\n }\n return _this.__privates.iot.disconnect().then(() => {\n _this.iot.__promise = null;\n return true;\n });\n },\n isConnected: () => {\n return this.__privates.iot.isConnected();\n },\n subscribe: topic => {\n if (__currentTopics.indexOf(topic) === -1) {\n __currentTopics.push(topic);\n if (!this.iot.__promise) return Promise.resolve('not_connected');\n return this.iot.__promise.then(() => this.__privates.iot.subscribe(topic));\n }\n },\n unsubscribe: topic => {\n let index = __currentTopics.indexOf(topic);\n index > -1 && __currentTopics.splice(index, 1);\n if (!this.iot.__promise) return Promise.resolve('not_connected');\n return this.iot.__promise.then(() => this.__privates.iot.unsubscribe(topic));\n },\n send: (topic, message) => {\n return this.iot.__promise.then(() => this.__privates.iot.send(topic, message));\n },\n $once: (key, callback, that) => {\n return this.__privates.iot.once(key, callback, that || this);\n },\n $on: (key, callback, that) => {\n return this.__privates.iot.on(key, callback, that || this);\n },\n $off: (key, callback, that) => {\n return this.__privates.iot.off(key, callback, that || this);\n },\n $clear: () => {\n return this.__privates.iot.clear();\n }\n };\n};\n/* harmony default export */ __webpack_exports__[\"default\"] = (iot);\n\n//# sourceURL=webpack://WatchTogetherSDK/./src/models/iot.js?");
|
|
10256
10256
|
|
|
10257
10257
|
/***/ }),
|
|
10258
10258
|
|