@reactoo/watchtogether-sdk-js 2.7.34 → 2.7.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @reactoo/watchtogether-sdk-js
|
|
3
|
-
* @version 2.7.
|
|
3
|
+
* @version 2.7.34
|
|
4
4
|
*/
|
|
5
5
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
6
6
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -16725,11 +16725,9 @@ let iot = function () {
|
|
|
16725
16725
|
},
|
|
16726
16726
|
onConnect: () => {
|
|
16727
16727
|
this.__privates.iot.log('MQTT client connected');
|
|
16728
|
-
this.iot.setupVisibilityChangeListener();
|
|
16729
16728
|
},
|
|
16730
16729
|
onClosed: () => {
|
|
16731
16730
|
this.__privates.iot.log('MQTT client closed');
|
|
16732
|
-
this.iot.disableVisibilityChangeListener();
|
|
16733
16731
|
},
|
|
16734
16732
|
onError: () => {
|
|
16735
16733
|
this.__privates.iot.log('MQTT client error');
|
|
@@ -16758,6 +16756,7 @@ let iot = function () {
|
|
|
16758
16756
|
});
|
|
16759
16757
|
let __currentTopicsCopy = new Set(__currentTopics); // Keep this line
|
|
16760
16758
|
__currentTopics.clear();
|
|
16759
|
+
_this.iot.setupVisibilityChangeListener();
|
|
16761
16760
|
_this.iot.$on('connect', _this.iot.onConnect, _this);
|
|
16762
16761
|
_this.iot.$on('closed', _this.iot.onClosed, _this);
|
|
16763
16762
|
_this.iot.$on('error', _this.iot.onError, _this);
|
|
@@ -16788,6 +16787,7 @@ let iot = function () {
|
|
|
16788
16787
|
__currentTopics.clear();
|
|
16789
16788
|
}
|
|
16790
16789
|
return _this.__privates.iot.disconnect().then(() => {
|
|
16790
|
+
_this.iot.disableVisibilityChangeListener();
|
|
16791
16791
|
_this.iot.$off('connect', _this.iot.onConnect, _this);
|
|
16792
16792
|
_this.iot.$off('closed', _this.iot.onClosed, _this);
|
|
16793
16793
|
_this.iot.$off('error', _this.iot.onError, _this);
|
|
@@ -25213,7 +25213,6 @@ class Iot {
|
|
|
25213
25213
|
constructor(enableDebugFlag) {
|
|
25214
25214
|
Object.assign(this, (0,_wt_emitter__WEBPACK_IMPORTED_MODULE_0__["default"])());
|
|
25215
25215
|
this.decoder = new TextDecoder('utf-8');
|
|
25216
|
-
this.connectionActive = false;
|
|
25217
25216
|
this.log = Iot.noop;
|
|
25218
25217
|
// Remove: this.debugFlag = enableDebugFlag;
|
|
25219
25218
|
this.credentialsExpirationCheckIntervalId = null;
|
|
@@ -25229,41 +25228,6 @@ class Iot {
|
|
|
25229
25228
|
enableDebug() {
|
|
25230
25229
|
this.log = console.log.bind(console);
|
|
25231
25230
|
}
|
|
25232
|
-
onConnect() {
|
|
25233
|
-
this.connectionActive = true;
|
|
25234
|
-
this.emit('connect');
|
|
25235
|
-
}
|
|
25236
|
-
onClosed(error) {
|
|
25237
|
-
this.connectionActive = false;
|
|
25238
|
-
this.emit('closed', error);
|
|
25239
|
-
}
|
|
25240
|
-
onDisconnect() {
|
|
25241
|
-
this.connectionActive = false;
|
|
25242
|
-
this.emit('disconnect');
|
|
25243
|
-
}
|
|
25244
|
-
onError(error) {
|
|
25245
|
-
this.connectionActive = false;
|
|
25246
|
-
this.emit('error', error);
|
|
25247
|
-
}
|
|
25248
|
-
onInterrupt(error) {
|
|
25249
|
-
this.connectionActive = false;
|
|
25250
|
-
this.emit('interrupt', error);
|
|
25251
|
-
}
|
|
25252
|
-
onResume(r) {
|
|
25253
|
-
this.connectionActive = true;
|
|
25254
|
-
this.emit('resume', r);
|
|
25255
|
-
}
|
|
25256
|
-
onMessage(topic, payload) {
|
|
25257
|
-
this.handleMessage(topic, new Uint8Array(payload));
|
|
25258
|
-
}
|
|
25259
|
-
onConnectionSuccess(r) {
|
|
25260
|
-
this.connectionActive = true;
|
|
25261
|
-
this.emit('connection_success', r);
|
|
25262
|
-
}
|
|
25263
|
-
onConnectionFailure(error) {
|
|
25264
|
-
this.connectionActive = false;
|
|
25265
|
-
this.emit('connection_failure', error);
|
|
25266
|
-
}
|
|
25267
25231
|
connect(apiMqttUrl, apiMqttClientId, region, accessKeyId, secretAccessKey, sessionToken, expiration) {
|
|
25268
25232
|
this.log('iot connect called, we disconnect first just to be sure');
|
|
25269
25233
|
return this.disconnect().finally(() => {
|
|
@@ -25289,15 +25253,33 @@ class Iot {
|
|
|
25289
25253
|
const config = configBuilder.build();
|
|
25290
25254
|
const client = new aws_iot_device_sdk_v2__WEBPACK_IMPORTED_MODULE_2__.mqtt.MqttClient();
|
|
25291
25255
|
this.connection = client.new_connection(config);
|
|
25292
|
-
this.connection.on('connect',
|
|
25293
|
-
|
|
25294
|
-
|
|
25295
|
-
this.connection.on('
|
|
25296
|
-
|
|
25297
|
-
|
|
25298
|
-
this.connection.on('
|
|
25299
|
-
|
|
25300
|
-
|
|
25256
|
+
this.connection.on('connect', () => {
|
|
25257
|
+
this.emit('connect');
|
|
25258
|
+
});
|
|
25259
|
+
this.connection.on('closed', error => {
|
|
25260
|
+
this.emit('closed', error);
|
|
25261
|
+
});
|
|
25262
|
+
this.connection.on('disconnect', () => {
|
|
25263
|
+
this.emit('disconnect');
|
|
25264
|
+
});
|
|
25265
|
+
this.connection.on('error', error => {
|
|
25266
|
+
this.emit('error', error);
|
|
25267
|
+
});
|
|
25268
|
+
this.connection.on('interrupt', error => {
|
|
25269
|
+
this.emit('interrupt', error);
|
|
25270
|
+
});
|
|
25271
|
+
this.connection.on('resume', error => {
|
|
25272
|
+
this.emit('resume', error);
|
|
25273
|
+
});
|
|
25274
|
+
this.connection.on('message', (topic, payload) => {
|
|
25275
|
+
this.handleMessage(topic, new Uint8Array(payload));
|
|
25276
|
+
});
|
|
25277
|
+
this.connection.on('connection_success', error => {
|
|
25278
|
+
this.emit('connection_success', error);
|
|
25279
|
+
});
|
|
25280
|
+
this.connection.on('connection_failure', error => {
|
|
25281
|
+
this.emit('connection_failure', error);
|
|
25282
|
+
});
|
|
25301
25283
|
return this.connection.connect().then(() => {
|
|
25302
25284
|
this.startCredentialsExpirationCheck(expiration);
|
|
25303
25285
|
});
|
|
@@ -25307,12 +25289,11 @@ class Iot {
|
|
|
25307
25289
|
this.log('iot disconnect');
|
|
25308
25290
|
this.stopCredentialsExpirationCheck();
|
|
25309
25291
|
if (this.connection) {
|
|
25310
|
-
this.connectionActive = false;
|
|
25311
25292
|
return this.connection.disconnect();
|
|
25312
25293
|
} else return Promise.resolve();
|
|
25313
25294
|
}
|
|
25314
25295
|
isConnected() {
|
|
25315
|
-
return this.
|
|
25296
|
+
return this.connection && this.connection.currentState === 0 && this.connection.desiredState === 0;
|
|
25316
25297
|
}
|
|
25317
25298
|
subscribe(topic) {
|
|
25318
25299
|
this.log('iot subscribe', topic);
|
|
@@ -25441,7 +25422,8 @@ class Iot {
|
|
|
25441
25422
|
this.currentCredentialsExpirationStamp = new Date(expiration).getTime();
|
|
25442
25423
|
this.credentialsExpirationCheckIntervalId = setInterval(() => {
|
|
25443
25424
|
const currentTimeStamp = new Date().getTime();
|
|
25444
|
-
|
|
25425
|
+
// update 15 minutes before expiration
|
|
25426
|
+
if (this.currentCredentialsExpirationStamp - currentTimeStamp <= 900000) {
|
|
25445
25427
|
this.emit('updateCredentials');
|
|
25446
25428
|
}
|
|
25447
25429
|
}, 5000);
|
|
@@ -25468,7 +25450,7 @@ class Iot {
|
|
|
25468
25450
|
}
|
|
25469
25451
|
checkConnection() {
|
|
25470
25452
|
return new Promise((resolve, reject) => {
|
|
25471
|
-
if (!this.connection || !this.
|
|
25453
|
+
if (!this.connection || !(this.connection.currentState === 0 && this.connection.desiredState === 0)) {
|
|
25472
25454
|
reject(new Error('Not connected'));
|
|
25473
25455
|
return;
|
|
25474
25456
|
}
|