@aws-amplify/pubsub 4.2.6-custom-pk.97 → 4.2.6-custom-pk.98
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/CHANGELOG.md +28 -108
- package/dist/aws-amplify-pubsub.js +506 -141
- package/dist/aws-amplify-pubsub.js.map +1 -1
- package/dist/aws-amplify-pubsub.min.js +2 -2
- package/dist/aws-amplify-pubsub.min.js.map +1 -1
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +4 -1
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +41 -12
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/lib/Providers/MqttOverWSProvider.d.ts +1 -0
- package/lib/Providers/MqttOverWSProvider.js +23 -1
- package/lib/Providers/MqttOverWSProvider.js.map +1 -1
- package/lib/Providers/{AWSAppSyncRealTimeProvider/constants.d.ts → constants.d.ts} +4 -0
- package/lib/Providers/{AWSAppSyncRealTimeProvider/constants.js → constants.js} +4 -0
- package/lib/Providers/constants.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/types/index.d.ts +11 -0
- package/lib/types/index.js +36 -0
- package/lib/types/index.js.map +1 -1
- package/lib/utils/ConnectionStateMonitor.d.ts +40 -0
- package/lib/utils/ConnectionStateMonitor.js +157 -0
- package/lib/utils/ConnectionStateMonitor.js.map +1 -0
- package/lib/utils/ReachabilityMonitor/index.d.ts +3 -0
- package/lib/utils/ReachabilityMonitor/index.js +5 -0
- package/lib/utils/ReachabilityMonitor/index.js.map +1 -0
- package/lib/utils/ReachabilityMonitor/index.native.d.ts +3 -0
- package/lib/utils/ReachabilityMonitor/index.native.js +11 -0
- package/lib/utils/ReachabilityMonitor/index.native.js.map +1 -0
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +4 -1
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +42 -13
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/lib-esm/Providers/MqttOverWSProvider.d.ts +1 -0
- package/lib-esm/Providers/MqttOverWSProvider.js +24 -2
- package/lib-esm/Providers/MqttOverWSProvider.js.map +1 -1
- package/lib-esm/Providers/{AWSAppSyncRealTimeProvider/constants.d.ts → constants.d.ts} +4 -0
- package/lib-esm/Providers/{AWSAppSyncRealTimeProvider/constants.js → constants.js} +4 -0
- package/lib-esm/Providers/constants.js.map +1 -0
- package/lib-esm/index.d.ts +2 -0
- package/lib-esm/index.js +2 -0
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/types/index.d.ts +11 -0
- package/lib-esm/types/index.js +36 -0
- package/lib-esm/types/index.js.map +1 -1
- package/lib-esm/utils/ConnectionStateMonitor.d.ts +40 -0
- package/lib-esm/utils/ConnectionStateMonitor.js +152 -0
- package/lib-esm/utils/ConnectionStateMonitor.js.map +1 -0
- package/lib-esm/utils/ReachabilityMonitor/index.d.ts +3 -0
- package/lib-esm/utils/ReachabilityMonitor/index.js +3 -0
- package/lib-esm/utils/ReachabilityMonitor/index.js.map +1 -0
- package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +3 -0
- package/lib-esm/utils/ReachabilityMonitor/index.native.js +6 -0
- package/lib-esm/utils/ReachabilityMonitor/index.native.js.map +1 -0
- package/package.json +5 -5
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +67 -15
- package/src/Providers/MqttOverWSProvider.ts +43 -2
- package/src/Providers/{AWSAppSyncRealTimeProvider/constants.ts → constants.ts} +5 -0
- package/src/index.ts +3 -0
- package/src/types/index.ts +36 -0
- package/src/utils/ConnectionStateMonitor.ts +192 -0
- package/src/utils/ReachabilityMonitor/index.native.ts +5 -0
- package/src/utils/ReachabilityMonitor/index.ts +3 -0
- package/lib/Providers/AWSAppSyncRealTimeProvider/constants.js.map +0 -1
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js.map +0 -1
|
@@ -7612,131 +7612,6 @@ function (_super) {
|
|
|
7612
7612
|
|
|
7613
7613
|
|
|
7614
7614
|
|
|
7615
|
-
/***/ }),
|
|
7616
|
-
|
|
7617
|
-
/***/ "./lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js":
|
|
7618
|
-
/*!*******************************************************************!*\
|
|
7619
|
-
!*** ./lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js ***!
|
|
7620
|
-
\*******************************************************************/
|
|
7621
|
-
/*! exports provided: MAX_DELAY_MS, NON_RETRYABLE_CODES, MESSAGE_TYPES, SUBSCRIPTION_STATUS, SOCKET_STATUS, AMPLIFY_SYMBOL, AWS_APPSYNC_REALTIME_HEADERS, CONNECTION_INIT_TIMEOUT, START_ACK_TIMEOUT, DEFAULT_KEEP_ALIVE_TIMEOUT */
|
|
7622
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
7623
|
-
|
|
7624
|
-
"use strict";
|
|
7625
|
-
__webpack_require__.r(__webpack_exports__);
|
|
7626
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MAX_DELAY_MS", function() { return MAX_DELAY_MS; });
|
|
7627
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NON_RETRYABLE_CODES", function() { return NON_RETRYABLE_CODES; });
|
|
7628
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MESSAGE_TYPES", function() { return MESSAGE_TYPES; });
|
|
7629
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SUBSCRIPTION_STATUS", function() { return SUBSCRIPTION_STATUS; });
|
|
7630
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SOCKET_STATUS", function() { return SOCKET_STATUS; });
|
|
7631
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMPLIFY_SYMBOL", function() { return AMPLIFY_SYMBOL; });
|
|
7632
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AWS_APPSYNC_REALTIME_HEADERS", function() { return AWS_APPSYNC_REALTIME_HEADERS; });
|
|
7633
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_INIT_TIMEOUT", function() { return CONNECTION_INIT_TIMEOUT; });
|
|
7634
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "START_ACK_TIMEOUT", function() { return START_ACK_TIMEOUT; });
|
|
7635
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_TIMEOUT; });
|
|
7636
|
-
var MAX_DELAY_MS = 5000;
|
|
7637
|
-
var NON_RETRYABLE_CODES = [400, 401, 403];
|
|
7638
|
-
var MESSAGE_TYPES;
|
|
7639
|
-
|
|
7640
|
-
(function (MESSAGE_TYPES) {
|
|
7641
|
-
/**
|
|
7642
|
-
* Client -> Server message.
|
|
7643
|
-
* This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
|
|
7644
|
-
*/
|
|
7645
|
-
MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
|
|
7646
|
-
/**
|
|
7647
|
-
* Server -> Client message
|
|
7648
|
-
* This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
|
|
7649
|
-
*/
|
|
7650
|
-
|
|
7651
|
-
MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
|
|
7652
|
-
/**
|
|
7653
|
-
* Server -> Client message.
|
|
7654
|
-
* This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
|
|
7655
|
-
*/
|
|
7656
|
-
|
|
7657
|
-
MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
|
|
7658
|
-
/**
|
|
7659
|
-
* Client -> Server message.
|
|
7660
|
-
* This message type is for register subscriptions with AWS AppSync RealTime
|
|
7661
|
-
*/
|
|
7662
|
-
|
|
7663
|
-
MESSAGE_TYPES["GQL_START"] = "start";
|
|
7664
|
-
/**
|
|
7665
|
-
* Server -> Client message.
|
|
7666
|
-
* This message type is for the ack response from AWS AppSync RealTime for GQL_START message
|
|
7667
|
-
*/
|
|
7668
|
-
|
|
7669
|
-
MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
|
|
7670
|
-
/**
|
|
7671
|
-
* Server -> Client message.
|
|
7672
|
-
* This message type is for subscription message from AWS AppSync RealTime
|
|
7673
|
-
*/
|
|
7674
|
-
|
|
7675
|
-
MESSAGE_TYPES["GQL_DATA"] = "data";
|
|
7676
|
-
/**
|
|
7677
|
-
* Server -> Client message.
|
|
7678
|
-
* This message type helps the client to know is still receiving messages from AWS AppSync RealTime
|
|
7679
|
-
*/
|
|
7680
|
-
|
|
7681
|
-
MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
|
|
7682
|
-
/**
|
|
7683
|
-
* Client -> Server message.
|
|
7684
|
-
* This message type is for unregister subscriptions with AWS AppSync RealTime
|
|
7685
|
-
*/
|
|
7686
|
-
|
|
7687
|
-
MESSAGE_TYPES["GQL_STOP"] = "stop";
|
|
7688
|
-
/**
|
|
7689
|
-
* Server -> Client message.
|
|
7690
|
-
* This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
|
|
7691
|
-
*/
|
|
7692
|
-
|
|
7693
|
-
MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
|
|
7694
|
-
/**
|
|
7695
|
-
* Server -> Client message.
|
|
7696
|
-
* This message type is for sending error messages from AWS AppSync RealTime to the client
|
|
7697
|
-
*/
|
|
7698
|
-
|
|
7699
|
-
MESSAGE_TYPES["GQL_ERROR"] = "error";
|
|
7700
|
-
})(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
|
|
7701
|
-
|
|
7702
|
-
var SUBSCRIPTION_STATUS;
|
|
7703
|
-
|
|
7704
|
-
(function (SUBSCRIPTION_STATUS) {
|
|
7705
|
-
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
|
|
7706
|
-
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
|
|
7707
|
-
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
|
|
7708
|
-
})(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
|
|
7709
|
-
|
|
7710
|
-
var SOCKET_STATUS;
|
|
7711
|
-
|
|
7712
|
-
(function (SOCKET_STATUS) {
|
|
7713
|
-
SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
|
|
7714
|
-
SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
|
|
7715
|
-
SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
|
|
7716
|
-
})(SOCKET_STATUS || (SOCKET_STATUS = {}));
|
|
7717
|
-
|
|
7718
|
-
var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
|
|
7719
|
-
var AWS_APPSYNC_REALTIME_HEADERS = {
|
|
7720
|
-
accept: 'application/json, text/javascript',
|
|
7721
|
-
'content-encoding': 'amz-1.0',
|
|
7722
|
-
'content-type': 'application/json; charset=UTF-8'
|
|
7723
|
-
};
|
|
7724
|
-
/**
|
|
7725
|
-
* Time in milleseconds to wait for GQL_CONNECTION_INIT message
|
|
7726
|
-
*/
|
|
7727
|
-
|
|
7728
|
-
var CONNECTION_INIT_TIMEOUT = 15000;
|
|
7729
|
-
/**
|
|
7730
|
-
* Time in milleseconds to wait for GQL_START_ACK message
|
|
7731
|
-
*/
|
|
7732
|
-
|
|
7733
|
-
var START_ACK_TIMEOUT = 15000;
|
|
7734
|
-
/**
|
|
7735
|
-
* Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
|
|
7736
|
-
*/
|
|
7737
|
-
|
|
7738
|
-
var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
|
|
7739
|
-
|
|
7740
7615
|
/***/ }),
|
|
7741
7616
|
|
|
7742
7617
|
/***/ "./lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js":
|
|
@@ -7766,7 +7641,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
7766
7641
|
/* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7__);
|
|
7767
7642
|
/* harmony import */ var _PubSubProvider__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PubSubProvider */ "./lib-esm/Providers/PubSubProvider.js");
|
|
7768
7643
|
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../index */ "./lib-esm/index.js");
|
|
7769
|
-
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*!
|
|
7644
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../constants */ "./lib-esm/Providers/constants.js");
|
|
7645
|
+
/* harmony import */ var _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../utils/ConnectionStateMonitor */ "./lib-esm/utils/ConnectionStateMonitor.js");
|
|
7770
7646
|
var __extends = undefined && undefined.__extends || function () {
|
|
7771
7647
|
var _extendStatics = function extendStatics(d, b) {
|
|
7772
7648
|
_extendStatics = Object.setPrototypeOf || {
|
|
@@ -8003,6 +7879,7 @@ var __read = undefined && undefined.__read || function (o, n) {
|
|
|
8003
7879
|
|
|
8004
7880
|
|
|
8005
7881
|
|
|
7882
|
+
|
|
8006
7883
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Logger"]('AWSAppSyncRealTimeProvider');
|
|
8007
7884
|
|
|
8008
7885
|
var dispatchApiEvent = function dispatchApiEvent(event, data, message) {
|
|
@@ -8021,13 +7898,26 @@ var AWSAppSyncRealTimeProvider =
|
|
|
8021
7898
|
function (_super) {
|
|
8022
7899
|
__extends(AWSAppSyncRealTimeProvider, _super);
|
|
8023
7900
|
|
|
8024
|
-
function AWSAppSyncRealTimeProvider() {
|
|
8025
|
-
|
|
7901
|
+
function AWSAppSyncRealTimeProvider(options) {
|
|
7902
|
+
if (options === void 0) {
|
|
7903
|
+
options = {};
|
|
7904
|
+
}
|
|
7905
|
+
|
|
7906
|
+
var _this = _super.call(this, options) || this;
|
|
8026
7907
|
|
|
8027
7908
|
_this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
|
|
8028
7909
|
_this.keepAliveTimeout = _constants__WEBPACK_IMPORTED_MODULE_10__["DEFAULT_KEEP_ALIVE_TIMEOUT"];
|
|
8029
7910
|
_this.subscriptionObserverMap = new Map();
|
|
8030
7911
|
_this.promiseArray = [];
|
|
7912
|
+
_this.connectionStateMonitor = new _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["ConnectionStateMonitor"](); // Monitor the connection state and pass changes along to Hub
|
|
7913
|
+
|
|
7914
|
+
_this.connectionStateMonitor.connectionStateObservable.subscribe(function (ConnectionState) {
|
|
7915
|
+
dispatchApiEvent(_index__WEBPACK_IMPORTED_MODULE_9__["CONNECTION_STATE_CHANGE"], {
|
|
7916
|
+
provider: _this,
|
|
7917
|
+
connectionState: ConnectionState
|
|
7918
|
+
}, "Connection state is " + ConnectionState);
|
|
7919
|
+
});
|
|
7920
|
+
|
|
8031
7921
|
return _this;
|
|
8032
7922
|
}
|
|
8033
7923
|
|
|
@@ -8077,6 +7967,9 @@ function (_super) {
|
|
|
8077
7967
|
observer.error({
|
|
8078
7968
|
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].REALTIME_SUBSCRIPTION_INIT_ERROR + ": " + err))]
|
|
8079
7969
|
});
|
|
7970
|
+
|
|
7971
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
7972
|
+
|
|
8080
7973
|
observer.complete();
|
|
8081
7974
|
});
|
|
8082
7975
|
|
|
@@ -8221,6 +8114,7 @@ function (_super) {
|
|
|
8221
8114
|
case 3:
|
|
8222
8115
|
_k.trys.push([3, 5,, 6]);
|
|
8223
8116
|
|
|
8117
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].OPENING_CONNECTION);
|
|
8224
8118
|
return [4
|
|
8225
8119
|
/*yield*/
|
|
8226
8120
|
, this._initializeWebSocketConnection({
|
|
@@ -8244,6 +8138,7 @@ function (_super) {
|
|
|
8244
8138
|
err: err_2
|
|
8245
8139
|
});
|
|
8246
8140
|
message = (_b = err_2['message']) !== null && _b !== void 0 ? _b : '';
|
|
8141
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
8247
8142
|
observer.error({
|
|
8248
8143
|
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + message))]
|
|
8249
8144
|
});
|
|
@@ -8362,12 +8257,22 @@ function (_super) {
|
|
|
8362
8257
|
return;
|
|
8363
8258
|
}
|
|
8364
8259
|
|
|
8260
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSING_CONNECTION);
|
|
8261
|
+
|
|
8365
8262
|
if (this.awsRealTimeSocket.bufferedAmount > 0) {
|
|
8366
8263
|
// Still data on the WebSocket
|
|
8367
8264
|
setTimeout(this._closeSocketIfRequired.bind(this), 1000);
|
|
8368
8265
|
} else {
|
|
8369
8266
|
logger.debug('closing WebSocket...');
|
|
8370
|
-
|
|
8267
|
+
|
|
8268
|
+
if (this.keepAliveTimeoutId) {
|
|
8269
|
+
clearTimeout(this.keepAliveTimeoutId);
|
|
8270
|
+
}
|
|
8271
|
+
|
|
8272
|
+
if (this.keepAliveAlertTimeoutId) {
|
|
8273
|
+
clearTimeout(this.keepAliveAlertTimeoutId);
|
|
8274
|
+
}
|
|
8275
|
+
|
|
8371
8276
|
var tempSocket = this.awsRealTimeSocket; // Cleaning callbacks to avoid race condition, socket still exists
|
|
8372
8277
|
|
|
8373
8278
|
tempSocket.onclose = null;
|
|
@@ -8375,10 +8280,13 @@ function (_super) {
|
|
|
8375
8280
|
tempSocket.close(1000);
|
|
8376
8281
|
this.awsRealTimeSocket = undefined;
|
|
8377
8282
|
this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
|
|
8283
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
8378
8284
|
}
|
|
8379
8285
|
};
|
|
8380
8286
|
|
|
8381
8287
|
AWSAppSyncRealTimeProvider.prototype._handleIncomingSubscriptionMessage = function (message) {
|
|
8288
|
+
var _this = this;
|
|
8289
|
+
|
|
8382
8290
|
logger.debug("subscription message from AWS AppSync RealTime: " + message.data);
|
|
8383
8291
|
|
|
8384
8292
|
var _a = JSON.parse(message.data),
|
|
@@ -8442,15 +8350,22 @@ function (_super) {
|
|
|
8442
8350
|
subscriptionReadyCallback: subscriptionReadyCallback,
|
|
8443
8351
|
subscriptionFailedCallback: subscriptionFailedCallback
|
|
8444
8352
|
});
|
|
8445
|
-
}
|
|
8446
|
-
|
|
8353
|
+
}
|
|
8447
8354
|
|
|
8355
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CONNECTION_ESTABLISHED);
|
|
8448
8356
|
return;
|
|
8449
8357
|
}
|
|
8450
8358
|
|
|
8451
8359
|
if (type === _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_CONNECTION_KEEP_ALIVE) {
|
|
8452
8360
|
if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
|
|
8453
|
-
|
|
8361
|
+
if (this.keepAliveAlertTimeoutId) clearTimeout(this.keepAliveAlertTimeoutId);
|
|
8362
|
+
this.keepAliveTimeoutId = setTimeout(function () {
|
|
8363
|
+
return _this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].TIMEOUT_DISCONNECT);
|
|
8364
|
+
}, this.keepAliveTimeout);
|
|
8365
|
+
this.keepAliveAlertTimeoutId = setTimeout(function () {
|
|
8366
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].KEEP_ALIVE_MISSED);
|
|
8367
|
+
}, _constants__WEBPACK_IMPORTED_MODULE_10__["DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT"]);
|
|
8368
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].KEEP_ALIVE);
|
|
8454
8369
|
return;
|
|
8455
8370
|
}
|
|
8456
8371
|
|
|
@@ -8494,6 +8409,7 @@ function (_super) {
|
|
|
8494
8409
|
this.subscriptionObserverMap.clear();
|
|
8495
8410
|
|
|
8496
8411
|
if (this.awsRealTimeSocket) {
|
|
8412
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
8497
8413
|
this.awsRealTimeSocket.close();
|
|
8498
8414
|
}
|
|
8499
8415
|
|
|
@@ -8692,6 +8608,8 @@ function (_super) {
|
|
|
8692
8608
|
};
|
|
8693
8609
|
|
|
8694
8610
|
newSocket.onclose = function () {
|
|
8611
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CONNECTION_FAILED);
|
|
8612
|
+
|
|
8695
8613
|
rej(new Error('Connection handshake error'));
|
|
8696
8614
|
};
|
|
8697
8615
|
|
|
@@ -8778,13 +8696,17 @@ function (_super) {
|
|
|
8778
8696
|
|
|
8779
8697
|
_this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
|
|
8780
8698
|
|
|
8781
|
-
|
|
8782
|
-
|
|
8699
|
+
var checkAckOk_1 = function checkAckOk_1(ackOk) {
|
|
8700
|
+
if (!ackOk) {
|
|
8701
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CONNECTION_FAILED);
|
|
8783
8702
|
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8703
|
+
rej(new Error("Connection timeout: ack from AWSAppSyncRealTime was not received after " + _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"] + " ms"));
|
|
8704
|
+
}
|
|
8705
|
+
};
|
|
8706
|
+
|
|
8707
|
+
setTimeout(function () {
|
|
8708
|
+
return checkAckOk_1(ackOk_1);
|
|
8709
|
+
}, _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"]);
|
|
8788
8710
|
}
|
|
8789
8711
|
});
|
|
8790
8712
|
}()];
|
|
@@ -9351,6 +9273,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
9351
9273
|
/* harmony import */ var _PubSubProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./PubSubProvider */ "./lib-esm/Providers/PubSubProvider.js");
|
|
9352
9274
|
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
|
|
9353
9275
|
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__);
|
|
9276
|
+
/* harmony import */ var _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/ConnectionStateMonitor */ "./lib-esm/utils/ConnectionStateMonitor.js");
|
|
9277
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./constants */ "./lib-esm/Providers/constants.js");
|
|
9278
|
+
/* harmony import */ var ___WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! .. */ "./lib-esm/index.js");
|
|
9354
9279
|
function _typeof(obj) {
|
|
9355
9280
|
"@babel/helpers - typeof";
|
|
9356
9281
|
|
|
@@ -9577,6 +9502,9 @@ var __rest = undefined && undefined.__rest || function (s, e) {
|
|
|
9577
9502
|
|
|
9578
9503
|
|
|
9579
9504
|
|
|
9505
|
+
|
|
9506
|
+
|
|
9507
|
+
|
|
9580
9508
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__["ConsoleLogger"]('MqttOverWSProvider');
|
|
9581
9509
|
function mqttTopicMatch(filter, topic) {
|
|
9582
9510
|
var filterArray = filter.split('/');
|
|
@@ -9642,6 +9570,14 @@ function () {
|
|
|
9642
9570
|
return ClientsQueue;
|
|
9643
9571
|
}();
|
|
9644
9572
|
|
|
9573
|
+
var dispatchPubSubEvent = function dispatchPubSubEvent(event, data, message) {
|
|
9574
|
+
_aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__["Hub"].dispatch('pubsub', {
|
|
9575
|
+
event: event,
|
|
9576
|
+
data: data,
|
|
9577
|
+
message: message
|
|
9578
|
+
}, 'PubSub', _constants__WEBPACK_IMPORTED_MODULE_6__["AMPLIFY_SYMBOL"]);
|
|
9579
|
+
};
|
|
9580
|
+
|
|
9645
9581
|
var topicSymbol = typeof Symbol !== 'undefined' ? Symbol('topic') : '@@topic';
|
|
9646
9582
|
|
|
9647
9583
|
var MqttOverWSProvider =
|
|
@@ -9659,8 +9595,17 @@ function (_super) {
|
|
|
9659
9595
|
})) || this;
|
|
9660
9596
|
|
|
9661
9597
|
_this._clientsQueue = new ClientsQueue();
|
|
9598
|
+
_this.connectionStateMonitor = new _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["ConnectionStateMonitor"]();
|
|
9662
9599
|
_this._topicObservers = new Map();
|
|
9663
|
-
_this._clientIdObservers = new Map();
|
|
9600
|
+
_this._clientIdObservers = new Map(); // Monitor the connection health state and pass changes along to Hub
|
|
9601
|
+
|
|
9602
|
+
_this.connectionStateMonitor.connectionStateObservable.subscribe(function (connectionStateChange) {
|
|
9603
|
+
dispatchPubSubEvent(___WEBPACK_IMPORTED_MODULE_7__["CONNECTION_STATE_CHANGE"], {
|
|
9604
|
+
provider: _this,
|
|
9605
|
+
connectionState: connectionStateChange
|
|
9606
|
+
}, "Connection state is " + connectionStateChange);
|
|
9607
|
+
});
|
|
9608
|
+
|
|
9664
9609
|
return _this;
|
|
9665
9610
|
}
|
|
9666
9611
|
|
|
@@ -9757,6 +9702,7 @@ function (_super) {
|
|
|
9757
9702
|
switch (_b.label) {
|
|
9758
9703
|
case 0:
|
|
9759
9704
|
logger.debug('Creating new MQTT client', clientId);
|
|
9705
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].OPENING_CONNECTION);
|
|
9760
9706
|
client = new paho_mqtt__WEBPACK_IMPORTED_MODULE_0__["Client"](url, clientId); // client.trace = (args) => logger.debug(clientId, JSON.stringify(args, null, 2));
|
|
9761
9707
|
|
|
9762
9708
|
client.onMessageArrived = function (_a) {
|
|
@@ -9774,6 +9720,8 @@ function (_super) {
|
|
|
9774
9720
|
clientId: clientId,
|
|
9775
9721
|
errorCode: errorCode
|
|
9776
9722
|
}, args));
|
|
9723
|
+
|
|
9724
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].CLOSED);
|
|
9777
9725
|
};
|
|
9778
9726
|
|
|
9779
9727
|
return [4
|
|
@@ -9785,13 +9733,18 @@ function (_super) {
|
|
|
9785
9733
|
onSuccess: function onSuccess() {
|
|
9786
9734
|
return resolve(client);
|
|
9787
9735
|
},
|
|
9788
|
-
onFailure:
|
|
9736
|
+
onFailure: function onFailure() {
|
|
9737
|
+
reject();
|
|
9738
|
+
|
|
9739
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].CONNECTION_FAILED);
|
|
9740
|
+
}
|
|
9789
9741
|
});
|
|
9790
9742
|
})];
|
|
9791
9743
|
|
|
9792
9744
|
case 1:
|
|
9793
9745
|
_b.sent();
|
|
9794
9746
|
|
|
9747
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].CONNECTION_ESTABLISHED);
|
|
9795
9748
|
return [2
|
|
9796
9749
|
/*return*/
|
|
9797
9750
|
, client];
|
|
@@ -9843,6 +9796,7 @@ function (_super) {
|
|
|
9843
9796
|
|
|
9844
9797
|
if (client && client.isConnected()) {
|
|
9845
9798
|
client.disconnect();
|
|
9799
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].CLOSED);
|
|
9846
9800
|
}
|
|
9847
9801
|
|
|
9848
9802
|
this.clientsQueue.remove(clientId);
|
|
@@ -10023,6 +9977,8 @@ function (_super) {
|
|
|
10023
9977
|
(_a = _this._clientIdObservers.get(clientId)) === null || _a === void 0 ? void 0 : _a["delete"](observer); // No more observers per client => client not needed anymore
|
|
10024
9978
|
|
|
10025
9979
|
if (((_b = _this._clientIdObservers.get(clientId)) === null || _b === void 0 ? void 0 : _b.size) === 0) {
|
|
9980
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].CLOSING_CONNECTION);
|
|
9981
|
+
|
|
10026
9982
|
_this.disconnect(clientId);
|
|
10027
9983
|
|
|
10028
9984
|
_this._clientIdObservers["delete"](clientId);
|
|
@@ -10122,6 +10078,137 @@ function () {
|
|
|
10122
10078
|
|
|
10123
10079
|
|
|
10124
10080
|
|
|
10081
|
+
/***/ }),
|
|
10082
|
+
|
|
10083
|
+
/***/ "./lib-esm/Providers/constants.js":
|
|
10084
|
+
/*!****************************************!*\
|
|
10085
|
+
!*** ./lib-esm/Providers/constants.js ***!
|
|
10086
|
+
\****************************************/
|
|
10087
|
+
/*! exports provided: MAX_DELAY_MS, NON_RETRYABLE_CODES, MESSAGE_TYPES, SUBSCRIPTION_STATUS, SOCKET_STATUS, AMPLIFY_SYMBOL, AWS_APPSYNC_REALTIME_HEADERS, CONNECTION_INIT_TIMEOUT, START_ACK_TIMEOUT, DEFAULT_KEEP_ALIVE_TIMEOUT, DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT */
|
|
10088
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
10089
|
+
|
|
10090
|
+
"use strict";
|
|
10091
|
+
__webpack_require__.r(__webpack_exports__);
|
|
10092
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MAX_DELAY_MS", function() { return MAX_DELAY_MS; });
|
|
10093
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NON_RETRYABLE_CODES", function() { return NON_RETRYABLE_CODES; });
|
|
10094
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MESSAGE_TYPES", function() { return MESSAGE_TYPES; });
|
|
10095
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SUBSCRIPTION_STATUS", function() { return SUBSCRIPTION_STATUS; });
|
|
10096
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SOCKET_STATUS", function() { return SOCKET_STATUS; });
|
|
10097
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMPLIFY_SYMBOL", function() { return AMPLIFY_SYMBOL; });
|
|
10098
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AWS_APPSYNC_REALTIME_HEADERS", function() { return AWS_APPSYNC_REALTIME_HEADERS; });
|
|
10099
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_INIT_TIMEOUT", function() { return CONNECTION_INIT_TIMEOUT; });
|
|
10100
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "START_ACK_TIMEOUT", function() { return START_ACK_TIMEOUT; });
|
|
10101
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_TIMEOUT; });
|
|
10102
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT; });
|
|
10103
|
+
var MAX_DELAY_MS = 5000;
|
|
10104
|
+
var NON_RETRYABLE_CODES = [400, 401, 403];
|
|
10105
|
+
var MESSAGE_TYPES;
|
|
10106
|
+
|
|
10107
|
+
(function (MESSAGE_TYPES) {
|
|
10108
|
+
/**
|
|
10109
|
+
* Client -> Server message.
|
|
10110
|
+
* This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
|
|
10111
|
+
*/
|
|
10112
|
+
MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
|
|
10113
|
+
/**
|
|
10114
|
+
* Server -> Client message
|
|
10115
|
+
* This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
|
|
10116
|
+
*/
|
|
10117
|
+
|
|
10118
|
+
MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
|
|
10119
|
+
/**
|
|
10120
|
+
* Server -> Client message.
|
|
10121
|
+
* This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
|
|
10122
|
+
*/
|
|
10123
|
+
|
|
10124
|
+
MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
|
|
10125
|
+
/**
|
|
10126
|
+
* Client -> Server message.
|
|
10127
|
+
* This message type is for register subscriptions with AWS AppSync RealTime
|
|
10128
|
+
*/
|
|
10129
|
+
|
|
10130
|
+
MESSAGE_TYPES["GQL_START"] = "start";
|
|
10131
|
+
/**
|
|
10132
|
+
* Server -> Client message.
|
|
10133
|
+
* This message type is for the ack response from AWS AppSync RealTime for GQL_START message
|
|
10134
|
+
*/
|
|
10135
|
+
|
|
10136
|
+
MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
|
|
10137
|
+
/**
|
|
10138
|
+
* Server -> Client message.
|
|
10139
|
+
* This message type is for subscription message from AWS AppSync RealTime
|
|
10140
|
+
*/
|
|
10141
|
+
|
|
10142
|
+
MESSAGE_TYPES["GQL_DATA"] = "data";
|
|
10143
|
+
/**
|
|
10144
|
+
* Server -> Client message.
|
|
10145
|
+
* This message type helps the client to know is still receiving messages from AWS AppSync RealTime
|
|
10146
|
+
*/
|
|
10147
|
+
|
|
10148
|
+
MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
|
|
10149
|
+
/**
|
|
10150
|
+
* Client -> Server message.
|
|
10151
|
+
* This message type is for unregister subscriptions with AWS AppSync RealTime
|
|
10152
|
+
*/
|
|
10153
|
+
|
|
10154
|
+
MESSAGE_TYPES["GQL_STOP"] = "stop";
|
|
10155
|
+
/**
|
|
10156
|
+
* Server -> Client message.
|
|
10157
|
+
* This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
|
|
10158
|
+
*/
|
|
10159
|
+
|
|
10160
|
+
MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
|
|
10161
|
+
/**
|
|
10162
|
+
* Server -> Client message.
|
|
10163
|
+
* This message type is for sending error messages from AWS AppSync RealTime to the client
|
|
10164
|
+
*/
|
|
10165
|
+
|
|
10166
|
+
MESSAGE_TYPES["GQL_ERROR"] = "error";
|
|
10167
|
+
})(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
|
|
10168
|
+
|
|
10169
|
+
var SUBSCRIPTION_STATUS;
|
|
10170
|
+
|
|
10171
|
+
(function (SUBSCRIPTION_STATUS) {
|
|
10172
|
+
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
|
|
10173
|
+
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
|
|
10174
|
+
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
|
|
10175
|
+
})(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
|
|
10176
|
+
|
|
10177
|
+
var SOCKET_STATUS;
|
|
10178
|
+
|
|
10179
|
+
(function (SOCKET_STATUS) {
|
|
10180
|
+
SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
|
|
10181
|
+
SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
|
|
10182
|
+
SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
|
|
10183
|
+
})(SOCKET_STATUS || (SOCKET_STATUS = {}));
|
|
10184
|
+
|
|
10185
|
+
var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
|
|
10186
|
+
var AWS_APPSYNC_REALTIME_HEADERS = {
|
|
10187
|
+
accept: 'application/json, text/javascript',
|
|
10188
|
+
'content-encoding': 'amz-1.0',
|
|
10189
|
+
'content-type': 'application/json; charset=UTF-8'
|
|
10190
|
+
};
|
|
10191
|
+
/**
|
|
10192
|
+
* Time in milleseconds to wait for GQL_CONNECTION_INIT message
|
|
10193
|
+
*/
|
|
10194
|
+
|
|
10195
|
+
var CONNECTION_INIT_TIMEOUT = 15000;
|
|
10196
|
+
/**
|
|
10197
|
+
* Time in milleseconds to wait for GQL_START_ACK message
|
|
10198
|
+
*/
|
|
10199
|
+
|
|
10200
|
+
var START_ACK_TIMEOUT = 15000;
|
|
10201
|
+
/**
|
|
10202
|
+
* Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
|
|
10203
|
+
*/
|
|
10204
|
+
|
|
10205
|
+
var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
|
|
10206
|
+
/**
|
|
10207
|
+
* Default Time in milleseconds to alert for missed GQL_CONNECTION_KEEP_ALIVE message
|
|
10208
|
+
*/
|
|
10209
|
+
|
|
10210
|
+
var DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = 65 * 1000;
|
|
10211
|
+
|
|
10125
10212
|
/***/ }),
|
|
10126
10213
|
|
|
10127
10214
|
/***/ "./lib-esm/Providers/index.js":
|
|
@@ -10555,11 +10642,12 @@ _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Amplify"].register(PubSub);
|
|
|
10555
10642
|
/*!**************************!*\
|
|
10556
10643
|
!*** ./lib-esm/index.js ***!
|
|
10557
10644
|
\**************************/
|
|
10558
|
-
/*! exports provided: AbstractPubSubProvider, AWSAppSyncProvider, AWSAppSyncRealTimeProvider, AWSIoTProvider, mqttTopicMatch, MqttOverWSProvider, PubSub, CONTROL_MSG, default */
|
|
10645
|
+
/*! exports provided: AbstractPubSubProvider, AWSAppSyncProvider, AWSAppSyncRealTimeProvider, AWSIoTProvider, mqttTopicMatch, MqttOverWSProvider, CONNECTION_STATE_CHANGE, ConnectionState, PubSub, CONTROL_MSG, default */
|
|
10559
10646
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
10560
10647
|
|
|
10561
10648
|
"use strict";
|
|
10562
10649
|
__webpack_require__.r(__webpack_exports__);
|
|
10650
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_STATE_CHANGE", function() { return CONNECTION_STATE_CHANGE; });
|
|
10563
10651
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONTROL_MSG", function() { return CONTROL_MSG; });
|
|
10564
10652
|
/* harmony import */ var _PubSub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PubSub */ "./lib-esm/PubSub.js");
|
|
10565
10653
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PubSub", function() { return _PubSub__WEBPACK_IMPORTED_MODULE_0__["PubSub"]; });
|
|
@@ -10577,6 +10665,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
10577
10665
|
|
|
10578
10666
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MqttOverWSProvider", function() { return _Providers__WEBPACK_IMPORTED_MODULE_1__["MqttOverWSProvider"]; });
|
|
10579
10667
|
|
|
10668
|
+
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types */ "./lib-esm/types/index.js");
|
|
10669
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConnectionState", function() { return _types__WEBPACK_IMPORTED_MODULE_2__["ConnectionState"]; });
|
|
10670
|
+
|
|
10580
10671
|
/*
|
|
10581
10672
|
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
10582
10673
|
*
|
|
@@ -10601,6 +10692,8 @@ var CONTROL_MSG;
|
|
|
10601
10692
|
CONTROL_MSG["TIMEOUT_DISCONNECT"] = "Timeout disconnect";
|
|
10602
10693
|
})(CONTROL_MSG || (CONTROL_MSG = {}));
|
|
10603
10694
|
|
|
10695
|
+
var CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
|
|
10696
|
+
|
|
10604
10697
|
|
|
10605
10698
|
/**
|
|
10606
10699
|
* @deprecated use named import
|
|
@@ -10610,6 +10703,278 @@ var CONTROL_MSG;
|
|
|
10610
10703
|
|
|
10611
10704
|
/***/ }),
|
|
10612
10705
|
|
|
10706
|
+
/***/ "./lib-esm/types/index.js":
|
|
10707
|
+
/*!********************************!*\
|
|
10708
|
+
!*** ./lib-esm/types/index.js ***!
|
|
10709
|
+
\********************************/
|
|
10710
|
+
/*! exports provided: ConnectionState */
|
|
10711
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
10712
|
+
|
|
10713
|
+
"use strict";
|
|
10714
|
+
__webpack_require__.r(__webpack_exports__);
|
|
10715
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConnectionState", function() { return ConnectionState; });
|
|
10716
|
+
/** @enum {string} */
|
|
10717
|
+
var ConnectionState;
|
|
10718
|
+
|
|
10719
|
+
(function (ConnectionState) {
|
|
10720
|
+
/*
|
|
10721
|
+
* The connection is alive and healthy
|
|
10722
|
+
*/
|
|
10723
|
+
ConnectionState["Connected"] = "Connected";
|
|
10724
|
+
/*
|
|
10725
|
+
* The connection is alive, but the connection is offline
|
|
10726
|
+
*/
|
|
10727
|
+
|
|
10728
|
+
ConnectionState["ConnectedPendingNetwork"] = "ConnectedPendingNetwork";
|
|
10729
|
+
/*
|
|
10730
|
+
* The connection has been disconnected while in use
|
|
10731
|
+
*/
|
|
10732
|
+
|
|
10733
|
+
ConnectionState["ConnectionDisrupted"] = "ConnectionDisrupted";
|
|
10734
|
+
/*
|
|
10735
|
+
* The connection has been disconnected and the network is offline
|
|
10736
|
+
*/
|
|
10737
|
+
|
|
10738
|
+
ConnectionState["ConnectionDisruptedPendingNetwork"] = "ConnectionDisruptedPendingNetwork";
|
|
10739
|
+
/*
|
|
10740
|
+
* The connection is in the process of connecting
|
|
10741
|
+
*/
|
|
10742
|
+
|
|
10743
|
+
ConnectionState["Connecting"] = "Connecting";
|
|
10744
|
+
/*
|
|
10745
|
+
* The connection is not in use and is being disconnected
|
|
10746
|
+
*/
|
|
10747
|
+
|
|
10748
|
+
ConnectionState["ConnectedPendingDisconnect"] = "ConnectedPendingDisconnect";
|
|
10749
|
+
/*
|
|
10750
|
+
* The connection is not in use and has been disconnected
|
|
10751
|
+
*/
|
|
10752
|
+
|
|
10753
|
+
ConnectionState["Disconnected"] = "Disconnected";
|
|
10754
|
+
/*
|
|
10755
|
+
* The connection is alive, but a keep alive message has been missed
|
|
10756
|
+
*/
|
|
10757
|
+
|
|
10758
|
+
ConnectionState["ConnectedPendingKeepAlive"] = "ConnectedPendingKeepAlive";
|
|
10759
|
+
})(ConnectionState || (ConnectionState = {}));
|
|
10760
|
+
|
|
10761
|
+
/***/ }),
|
|
10762
|
+
|
|
10763
|
+
/***/ "./lib-esm/utils/ConnectionStateMonitor.js":
|
|
10764
|
+
/*!*************************************************!*\
|
|
10765
|
+
!*** ./lib-esm/utils/ConnectionStateMonitor.js ***!
|
|
10766
|
+
\*************************************************/
|
|
10767
|
+
/*! exports provided: CONNECTION_CHANGE, ConnectionStateMonitor */
|
|
10768
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
10769
|
+
|
|
10770
|
+
"use strict";
|
|
10771
|
+
__webpack_require__.r(__webpack_exports__);
|
|
10772
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_CHANGE", function() { return CONNECTION_CHANGE; });
|
|
10773
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConnectionStateMonitor", function() { return ConnectionStateMonitor; });
|
|
10774
|
+
/* harmony import */ var zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! zen-observable-ts */ "../../node_modules/zen-observable-ts/lib/bundle.esm.js");
|
|
10775
|
+
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index */ "./lib-esm/index.js");
|
|
10776
|
+
/* harmony import */ var _ReachabilityMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ReachabilityMonitor */ "./lib-esm/utils/ReachabilityMonitor/index.js");
|
|
10777
|
+
/*
|
|
10778
|
+
* Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
10779
|
+
*
|
|
10780
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
10781
|
+
* the License. A copy of the License is located at
|
|
10782
|
+
*
|
|
10783
|
+
* http://aws.amazon.com/apache2.0/
|
|
10784
|
+
*
|
|
10785
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
10786
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
10787
|
+
* and limitations under the License.
|
|
10788
|
+
*/
|
|
10789
|
+
var __assign = undefined && undefined.__assign || function () {
|
|
10790
|
+
__assign = Object.assign || function (t) {
|
|
10791
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
10792
|
+
s = arguments[i];
|
|
10793
|
+
|
|
10794
|
+
for (var p in s) {
|
|
10795
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
10796
|
+
}
|
|
10797
|
+
}
|
|
10798
|
+
|
|
10799
|
+
return t;
|
|
10800
|
+
};
|
|
10801
|
+
|
|
10802
|
+
return __assign.apply(this, arguments);
|
|
10803
|
+
};
|
|
10804
|
+
|
|
10805
|
+
|
|
10806
|
+
|
|
10807
|
+
|
|
10808
|
+
var CONNECTION_CHANGE = {
|
|
10809
|
+
KEEP_ALIVE_MISSED: {
|
|
10810
|
+
keepAliveState: 'unhealthy'
|
|
10811
|
+
},
|
|
10812
|
+
KEEP_ALIVE: {
|
|
10813
|
+
keepAliveState: 'healthy'
|
|
10814
|
+
},
|
|
10815
|
+
CONNECTION_ESTABLISHED: {
|
|
10816
|
+
connectionState: 'connected'
|
|
10817
|
+
},
|
|
10818
|
+
CONNECTION_FAILED: {
|
|
10819
|
+
intendedConnectionState: 'disconnected',
|
|
10820
|
+
connectionState: 'disconnected'
|
|
10821
|
+
},
|
|
10822
|
+
CLOSING_CONNECTION: {
|
|
10823
|
+
intendedConnectionState: 'disconnected'
|
|
10824
|
+
},
|
|
10825
|
+
OPENING_CONNECTION: {
|
|
10826
|
+
intendedConnectionState: 'connected',
|
|
10827
|
+
connectionState: 'connecting'
|
|
10828
|
+
},
|
|
10829
|
+
CLOSED: {
|
|
10830
|
+
connectionState: 'disconnected'
|
|
10831
|
+
},
|
|
10832
|
+
ONLINE: {
|
|
10833
|
+
networkState: 'connected'
|
|
10834
|
+
},
|
|
10835
|
+
OFFLINE: {
|
|
10836
|
+
networkState: 'disconnected'
|
|
10837
|
+
}
|
|
10838
|
+
};
|
|
10839
|
+
|
|
10840
|
+
var ConnectionStateMonitor =
|
|
10841
|
+
/** @class */
|
|
10842
|
+
function () {
|
|
10843
|
+
function ConnectionStateMonitor() {
|
|
10844
|
+
var _this = this;
|
|
10845
|
+
|
|
10846
|
+
this._networkMonitoringSubscription = undefined;
|
|
10847
|
+
this._linkedConnectionState = {
|
|
10848
|
+
networkState: 'connected',
|
|
10849
|
+
connectionState: 'disconnected',
|
|
10850
|
+
intendedConnectionState: 'disconnected',
|
|
10851
|
+
keepAliveState: 'healthy'
|
|
10852
|
+
};
|
|
10853
|
+
this._linkedConnectionStateObservable = new zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__["default"](function (connectionStateObserver) {
|
|
10854
|
+
connectionStateObserver.next(_this._linkedConnectionState);
|
|
10855
|
+
_this._linkedConnectionStateObserver = connectionStateObserver;
|
|
10856
|
+
});
|
|
10857
|
+
}
|
|
10858
|
+
/**
|
|
10859
|
+
* Turn network state monitoring on if it isn't on already
|
|
10860
|
+
*/
|
|
10861
|
+
|
|
10862
|
+
|
|
10863
|
+
ConnectionStateMonitor.prototype.enableNetworkMonitoring = function () {
|
|
10864
|
+
var _this = this; // Maintain the network state based on the reachability monitor
|
|
10865
|
+
|
|
10866
|
+
|
|
10867
|
+
if (this._networkMonitoringSubscription === undefined) {
|
|
10868
|
+
this._networkMonitoringSubscription = Object(_ReachabilityMonitor__WEBPACK_IMPORTED_MODULE_2__["ReachabilityMonitor"])().subscribe(function (_a) {
|
|
10869
|
+
var online = _a.online;
|
|
10870
|
+
|
|
10871
|
+
_this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);
|
|
10872
|
+
});
|
|
10873
|
+
}
|
|
10874
|
+
};
|
|
10875
|
+
/**
|
|
10876
|
+
* Turn network state monitoring off if it isn't off already
|
|
10877
|
+
*/
|
|
10878
|
+
|
|
10879
|
+
|
|
10880
|
+
ConnectionStateMonitor.prototype.disableNetworkMonitoring = function () {
|
|
10881
|
+
var _a;
|
|
10882
|
+
|
|
10883
|
+
(_a = this._networkMonitoringSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
10884
|
+
this._networkMonitoringSubscription = undefined;
|
|
10885
|
+
};
|
|
10886
|
+
|
|
10887
|
+
Object.defineProperty(ConnectionStateMonitor.prototype, "connectionStateObservable", {
|
|
10888
|
+
/**
|
|
10889
|
+
* Get the observable that allows us to monitor the connection state
|
|
10890
|
+
*
|
|
10891
|
+
* @returns {Observable<ConnectionState>} - The observable that emits ConnectionState updates
|
|
10892
|
+
*/
|
|
10893
|
+
get: function get() {
|
|
10894
|
+
var _this = this;
|
|
10895
|
+
|
|
10896
|
+
var previous; // The linked state aggregates state changes to any of the network, connection,
|
|
10897
|
+
// intendedConnection and keepAliveHealth. Some states will change these independent
|
|
10898
|
+
// states without changing the overall connection state.
|
|
10899
|
+
// After translating from linked states to ConnectionState, then remove any duplicates
|
|
10900
|
+
|
|
10901
|
+
return this._linkedConnectionStateObservable.map(function (value) {
|
|
10902
|
+
return _this.connectionStatesTranslator(value);
|
|
10903
|
+
}).filter(function (current) {
|
|
10904
|
+
var toInclude = current !== previous;
|
|
10905
|
+
previous = current;
|
|
10906
|
+
return toInclude;
|
|
10907
|
+
});
|
|
10908
|
+
},
|
|
10909
|
+
enumerable: true,
|
|
10910
|
+
configurable: true
|
|
10911
|
+
});
|
|
10912
|
+
/*
|
|
10913
|
+
* Updates local connection state and emits the full state to the observer.
|
|
10914
|
+
*/
|
|
10915
|
+
|
|
10916
|
+
ConnectionStateMonitor.prototype.record = function (statusUpdates) {
|
|
10917
|
+
// Maintain the network monitor
|
|
10918
|
+
if (statusUpdates.intendedConnectionState === 'connected') {
|
|
10919
|
+
this.enableNetworkMonitoring();
|
|
10920
|
+
} else if (statusUpdates.intendedConnectionState === 'disconnected') {
|
|
10921
|
+
this.disableNetworkMonitoring();
|
|
10922
|
+
} // Maintain the socket state
|
|
10923
|
+
|
|
10924
|
+
|
|
10925
|
+
var newSocketStatus = __assign(__assign({}, this._linkedConnectionState), statusUpdates);
|
|
10926
|
+
|
|
10927
|
+
this._linkedConnectionState = __assign({}, newSocketStatus);
|
|
10928
|
+
|
|
10929
|
+
this._linkedConnectionStateObserver.next(this._linkedConnectionState);
|
|
10930
|
+
};
|
|
10931
|
+
/*
|
|
10932
|
+
* Translate the ConnectionState structure into a specific ConnectionState string literal union
|
|
10933
|
+
*/
|
|
10934
|
+
|
|
10935
|
+
|
|
10936
|
+
ConnectionStateMonitor.prototype.connectionStatesTranslator = function (_a) {
|
|
10937
|
+
var connectionState = _a.connectionState,
|
|
10938
|
+
networkState = _a.networkState,
|
|
10939
|
+
intendedConnectionState = _a.intendedConnectionState,
|
|
10940
|
+
keepAliveState = _a.keepAliveState;
|
|
10941
|
+
if (connectionState === 'connected' && networkState === 'disconnected') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectedPendingNetwork;
|
|
10942
|
+
if (connectionState === 'connected' && intendedConnectionState === 'disconnected') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectedPendingDisconnect;
|
|
10943
|
+
if (connectionState === 'disconnected' && intendedConnectionState === 'connected' && networkState === 'disconnected') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectionDisruptedPendingNetwork;
|
|
10944
|
+
if (connectionState === 'disconnected' && intendedConnectionState === 'connected') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectionDisrupted;
|
|
10945
|
+
if (connectionState === 'connected' && keepAliveState === 'unhealthy') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectedPendingKeepAlive; // All remaining states directly correspond to the connection state
|
|
10946
|
+
|
|
10947
|
+
if (connectionState === 'connecting') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].Connecting;
|
|
10948
|
+
if (connectionState === 'disconnected') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].Disconnected;
|
|
10949
|
+
return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].Connected;
|
|
10950
|
+
};
|
|
10951
|
+
|
|
10952
|
+
return ConnectionStateMonitor;
|
|
10953
|
+
}();
|
|
10954
|
+
|
|
10955
|
+
|
|
10956
|
+
|
|
10957
|
+
/***/ }),
|
|
10958
|
+
|
|
10959
|
+
/***/ "./lib-esm/utils/ReachabilityMonitor/index.js":
|
|
10960
|
+
/*!****************************************************!*\
|
|
10961
|
+
!*** ./lib-esm/utils/ReachabilityMonitor/index.js ***!
|
|
10962
|
+
\****************************************************/
|
|
10963
|
+
/*! exports provided: ReachabilityMonitor */
|
|
10964
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
10965
|
+
|
|
10966
|
+
"use strict";
|
|
10967
|
+
__webpack_require__.r(__webpack_exports__);
|
|
10968
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReachabilityMonitor", function() { return ReachabilityMonitor; });
|
|
10969
|
+
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
|
|
10970
|
+
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__);
|
|
10971
|
+
|
|
10972
|
+
var ReachabilityMonitor = function ReachabilityMonitor() {
|
|
10973
|
+
return new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Reachability"]().networkMonitor();
|
|
10974
|
+
};
|
|
10975
|
+
|
|
10976
|
+
/***/ }),
|
|
10977
|
+
|
|
10613
10978
|
/***/ "@aws-amplify/auth":
|
|
10614
10979
|
/*!***********************************!*\
|
|
10615
10980
|
!*** external "aws_amplify_auth" ***!
|