@aws-amplify/pubsub 4.4.9 → 4.4.10-next.13
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 +73 -0
- package/dist/aws-amplify-pubsub.js +713 -378
- package/dist/aws-amplify-pubsub.js.map +1 -1
- package/dist/aws-amplify-pubsub.min.js +3 -3
- package/dist/aws-amplify-pubsub.min.js.map +1 -1
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +10 -2
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +133 -90
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/lib/Providers/MqttOverWSProvider.d.ts +5 -1
- package/lib/Providers/MqttOverWSProvider.js +152 -87
- package/lib/Providers/MqttOverWSProvider.js.map +1 -1
- package/lib/Providers/PubSubProvider.d.ts +1 -1
- package/lib/Providers/{AWSAppSyncRealTimeProvider/constants.d.ts → constants.d.ts} +9 -0
- package/lib/Providers/{AWSAppSyncRealTimeProvider/constants.js → constants.js} +9 -0
- package/lib/Providers/constants.js.map +1 -0
- package/lib/index.d.ts +3 -10
- package/lib/index.js +3 -10
- package/lib/index.js.map +1 -1
- package/lib/types/Provider.d.ts +10 -1
- package/lib/types/PubSub.d.ts +22 -8
- package/lib/types/PubSub.js +56 -0
- package/lib/types/PubSub.js.map +1 -1
- package/lib/types/index.d.ts +0 -17
- package/lib/types/index.js +4 -36
- package/lib/types/index.js.map +1 -1
- package/lib/utils/ConnectionStateMonitor.d.ts +2 -1
- package/lib/utils/ConnectionStateMonitor.js +21 -13
- package/lib/utils/ConnectionStateMonitor.js.map +1 -1
- 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/utils/ReconnectionMonitor.d.ts +29 -0
- package/lib/utils/ReconnectionMonitor.js +73 -0
- package/lib/utils/ReconnectionMonitor.js.map +1 -0
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +10 -2
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +129 -86
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/lib-esm/Providers/MqttOverWSProvider.d.ts +5 -1
- package/lib-esm/Providers/MqttOverWSProvider.js +153 -88
- package/lib-esm/Providers/MqttOverWSProvider.js.map +1 -1
- package/lib-esm/Providers/PubSubProvider.d.ts +1 -1
- package/lib-esm/Providers/{AWSAppSyncRealTimeProvider/constants.d.ts → constants.d.ts} +9 -0
- package/lib-esm/Providers/{AWSAppSyncRealTimeProvider/constants.js → constants.js} +9 -0
- package/lib-esm/Providers/constants.js.map +1 -0
- package/lib-esm/index.d.ts +3 -10
- package/lib-esm/index.js +3 -11
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/types/Provider.d.ts +10 -1
- package/lib-esm/types/PubSub.d.ts +22 -8
- package/lib-esm/types/PubSub.js +56 -0
- package/lib-esm/types/PubSub.js.map +1 -1
- package/lib-esm/types/index.d.ts +0 -17
- package/lib-esm/types/index.js +1 -36
- package/lib-esm/types/index.js.map +1 -1
- package/lib-esm/utils/ConnectionStateMonitor.d.ts +2 -1
- package/lib-esm/utils/ConnectionStateMonitor.js +13 -5
- package/lib-esm/utils/ConnectionStateMonitor.js.map +1 -1
- 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/lib-esm/utils/ReconnectionMonitor.d.ts +29 -0
- package/lib-esm/utils/ReconnectionMonitor.js +71 -0
- package/lib-esm/utils/ReconnectionMonitor.js.map +1 -0
- package/package.json +5 -5
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +154 -90
- package/src/Providers/MqttOverWSProvider.ts +120 -53
- package/src/Providers/PubSubProvider.ts +1 -1
- package/src/Providers/{AWSAppSyncRealTimeProvider/constants.ts → constants.ts} +12 -0
- package/src/index.ts +3 -10
- package/src/types/Provider.ts +13 -1
- package/src/types/PubSub.ts +47 -8
- package/src/types/index.ts +0 -43
- package/src/utils/ConnectionStateMonitor.ts +20 -5
- package/src/utils/ReachabilityMonitor/index.native.ts +5 -0
- package/src/utils/ReachabilityMonitor/index.ts +3 -0
- package/src/utils/ReconnectionMonitor.ts +74 -0
- package/lib/Providers/AWSAppSyncRealTimeProvider/constants.js.map +0 -1
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js.map +0 -1
|
@@ -7612,137 +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, DEFAULT_KEEP_ALIVE_ALERT_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
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT; });
|
|
7637
|
-
var MAX_DELAY_MS = 5000;
|
|
7638
|
-
var NON_RETRYABLE_CODES = [400, 401, 403];
|
|
7639
|
-
var MESSAGE_TYPES;
|
|
7640
|
-
|
|
7641
|
-
(function (MESSAGE_TYPES) {
|
|
7642
|
-
/**
|
|
7643
|
-
* Client -> Server message.
|
|
7644
|
-
* This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
|
|
7645
|
-
*/
|
|
7646
|
-
MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
|
|
7647
|
-
/**
|
|
7648
|
-
* Server -> Client message
|
|
7649
|
-
* This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
|
|
7650
|
-
*/
|
|
7651
|
-
|
|
7652
|
-
MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
|
|
7653
|
-
/**
|
|
7654
|
-
* Server -> Client message.
|
|
7655
|
-
* This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
|
|
7656
|
-
*/
|
|
7657
|
-
|
|
7658
|
-
MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
|
|
7659
|
-
/**
|
|
7660
|
-
* Client -> Server message.
|
|
7661
|
-
* This message type is for register subscriptions with AWS AppSync RealTime
|
|
7662
|
-
*/
|
|
7663
|
-
|
|
7664
|
-
MESSAGE_TYPES["GQL_START"] = "start";
|
|
7665
|
-
/**
|
|
7666
|
-
* Server -> Client message.
|
|
7667
|
-
* This message type is for the ack response from AWS AppSync RealTime for GQL_START message
|
|
7668
|
-
*/
|
|
7669
|
-
|
|
7670
|
-
MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
|
|
7671
|
-
/**
|
|
7672
|
-
* Server -> Client message.
|
|
7673
|
-
* This message type is for subscription message from AWS AppSync RealTime
|
|
7674
|
-
*/
|
|
7675
|
-
|
|
7676
|
-
MESSAGE_TYPES["GQL_DATA"] = "data";
|
|
7677
|
-
/**
|
|
7678
|
-
* Server -> Client message.
|
|
7679
|
-
* This message type helps the client to know is still receiving messages from AWS AppSync RealTime
|
|
7680
|
-
*/
|
|
7681
|
-
|
|
7682
|
-
MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
|
|
7683
|
-
/**
|
|
7684
|
-
* Client -> Server message.
|
|
7685
|
-
* This message type is for unregister subscriptions with AWS AppSync RealTime
|
|
7686
|
-
*/
|
|
7687
|
-
|
|
7688
|
-
MESSAGE_TYPES["GQL_STOP"] = "stop";
|
|
7689
|
-
/**
|
|
7690
|
-
* Server -> Client message.
|
|
7691
|
-
* This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
|
|
7692
|
-
*/
|
|
7693
|
-
|
|
7694
|
-
MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
|
|
7695
|
-
/**
|
|
7696
|
-
* Server -> Client message.
|
|
7697
|
-
* This message type is for sending error messages from AWS AppSync RealTime to the client
|
|
7698
|
-
*/
|
|
7699
|
-
|
|
7700
|
-
MESSAGE_TYPES["GQL_ERROR"] = "error";
|
|
7701
|
-
})(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
|
|
7702
|
-
|
|
7703
|
-
var SUBSCRIPTION_STATUS;
|
|
7704
|
-
|
|
7705
|
-
(function (SUBSCRIPTION_STATUS) {
|
|
7706
|
-
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
|
|
7707
|
-
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
|
|
7708
|
-
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
|
|
7709
|
-
})(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
|
|
7710
|
-
|
|
7711
|
-
var SOCKET_STATUS;
|
|
7712
|
-
|
|
7713
|
-
(function (SOCKET_STATUS) {
|
|
7714
|
-
SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
|
|
7715
|
-
SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
|
|
7716
|
-
SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
|
|
7717
|
-
})(SOCKET_STATUS || (SOCKET_STATUS = {}));
|
|
7718
|
-
|
|
7719
|
-
var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
|
|
7720
|
-
var AWS_APPSYNC_REALTIME_HEADERS = {
|
|
7721
|
-
accept: 'application/json, text/javascript',
|
|
7722
|
-
'content-encoding': 'amz-1.0',
|
|
7723
|
-
'content-type': 'application/json; charset=UTF-8'
|
|
7724
|
-
};
|
|
7725
|
-
/**
|
|
7726
|
-
* Time in milleseconds to wait for GQL_CONNECTION_INIT message
|
|
7727
|
-
*/
|
|
7728
|
-
|
|
7729
|
-
var CONNECTION_INIT_TIMEOUT = 15000;
|
|
7730
|
-
/**
|
|
7731
|
-
* Time in milleseconds to wait for GQL_START_ACK message
|
|
7732
|
-
*/
|
|
7733
|
-
|
|
7734
|
-
var START_ACK_TIMEOUT = 15000;
|
|
7735
|
-
/**
|
|
7736
|
-
* Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
|
|
7737
|
-
*/
|
|
7738
|
-
|
|
7739
|
-
var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
|
|
7740
|
-
/**
|
|
7741
|
-
* Default Time in milleseconds to alert for missed GQL_CONNECTION_KEEP_ALIVE message
|
|
7742
|
-
*/
|
|
7743
|
-
|
|
7744
|
-
var DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = 65 * 1000;
|
|
7745
|
-
|
|
7746
7615
|
/***/ }),
|
|
7747
7616
|
|
|
7748
7617
|
/***/ "./lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js":
|
|
@@ -7771,9 +7640,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
7771
7640
|
/* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
|
|
7772
7641
|
/* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7__);
|
|
7773
7642
|
/* harmony import */ var _PubSubProvider__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PubSubProvider */ "./lib-esm/Providers/PubSubProvider.js");
|
|
7774
|
-
/* harmony import */ var
|
|
7775
|
-
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*!
|
|
7643
|
+
/* harmony import */ var _types_PubSub__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../types/PubSub */ "./lib-esm/types/PubSub.js");
|
|
7644
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../constants */ "./lib-esm/Providers/constants.js");
|
|
7776
7645
|
/* harmony import */ var _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../utils/ConnectionStateMonitor */ "./lib-esm/utils/ConnectionStateMonitor.js");
|
|
7646
|
+
/* harmony import */ var _utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../utils/ReconnectionMonitor */ "./lib-esm/utils/ReconnectionMonitor.js");
|
|
7777
7647
|
var __extends = undefined && undefined.__extends || function () {
|
|
7778
7648
|
var _extendStatics = function extendStatics(d, b) {
|
|
7779
7649
|
_extendStatics = Object.setPrototypeOf || {
|
|
@@ -8011,6 +7881,7 @@ var __read = undefined && undefined.__read || function (o, n) {
|
|
|
8011
7881
|
|
|
8012
7882
|
|
|
8013
7883
|
|
|
7884
|
+
|
|
8014
7885
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Logger"]('AWSAppSyncRealTimeProvider');
|
|
8015
7886
|
|
|
8016
7887
|
var dispatchApiEvent = function dispatchApiEvent(event, data, message) {
|
|
@@ -8040,17 +7911,42 @@ function (_super) {
|
|
|
8040
7911
|
_this.keepAliveTimeout = _constants__WEBPACK_IMPORTED_MODULE_10__["DEFAULT_KEEP_ALIVE_TIMEOUT"];
|
|
8041
7912
|
_this.subscriptionObserverMap = new Map();
|
|
8042
7913
|
_this.promiseArray = [];
|
|
8043
|
-
_this.connectionStateMonitor = new _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["ConnectionStateMonitor"]();
|
|
7914
|
+
_this.connectionStateMonitor = new _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["ConnectionStateMonitor"]();
|
|
7915
|
+
_this.reconnectionMonitor = new _utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_12__["ReconnectionMonitor"](); // Monitor the connection state and pass changes along to Hub
|
|
8044
7916
|
|
|
8045
|
-
_this.connectionStateMonitor.connectionStateObservable.subscribe(function (
|
|
8046
|
-
dispatchApiEvent(
|
|
7917
|
+
_this.connectionStateMonitorSubscription = _this.connectionStateMonitor.connectionStateObservable.subscribe(function (connectionState) {
|
|
7918
|
+
dispatchApiEvent(_constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_STATE_CHANGE"], {
|
|
8047
7919
|
provider: _this,
|
|
8048
|
-
connectionState:
|
|
8049
|
-
}, "Connection state is " +
|
|
8050
|
-
|
|
7920
|
+
connectionState: connectionState
|
|
7921
|
+
}, "Connection state is " + connectionState);
|
|
7922
|
+
_this.connectionState = connectionState; // Trigger START_RECONNECT when the connection is disrupted
|
|
8051
7923
|
|
|
7924
|
+
if (connectionState === _types_PubSub__WEBPACK_IMPORTED_MODULE_9__["ConnectionState"].ConnectionDisrupted) {
|
|
7925
|
+
_this.reconnectionMonitor.record(_utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_12__["ReconnectEvent"].START_RECONNECT);
|
|
7926
|
+
} // Trigger HALT_RECONNECT to halt reconnection attempts when the state is anything other than
|
|
7927
|
+
// ConnectionDisrupted or Connecting
|
|
7928
|
+
|
|
7929
|
+
|
|
7930
|
+
if ([_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["ConnectionState"].Connected, _types_PubSub__WEBPACK_IMPORTED_MODULE_9__["ConnectionState"].ConnectedPendingDisconnect, _types_PubSub__WEBPACK_IMPORTED_MODULE_9__["ConnectionState"].ConnectedPendingKeepAlive, _types_PubSub__WEBPACK_IMPORTED_MODULE_9__["ConnectionState"].ConnectedPendingNetwork, _types_PubSub__WEBPACK_IMPORTED_MODULE_9__["ConnectionState"].ConnectedPendingNetwork, _types_PubSub__WEBPACK_IMPORTED_MODULE_9__["ConnectionState"].ConnectionDisruptedPendingNetwork, _types_PubSub__WEBPACK_IMPORTED_MODULE_9__["ConnectionState"].Disconnected].includes(connectionState)) {
|
|
7931
|
+
_this.reconnectionMonitor.record(_utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_12__["ReconnectEvent"].HALT_RECONNECT);
|
|
7932
|
+
}
|
|
7933
|
+
});
|
|
8052
7934
|
return _this;
|
|
8053
7935
|
}
|
|
7936
|
+
/**
|
|
7937
|
+
* Mark the socket closed and release all active listeners
|
|
7938
|
+
*/
|
|
7939
|
+
|
|
7940
|
+
|
|
7941
|
+
AWSAppSyncRealTimeProvider.prototype.close = function () {
|
|
7942
|
+
// Mark the socket closed both in status and the connection monitor
|
|
7943
|
+
this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
|
|
7944
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CONNECTION_FAILED); // Turn off the subscription monitor Hub publishing
|
|
7945
|
+
|
|
7946
|
+
this.connectionStateMonitorSubscription.unsubscribe(); // Complete all reconnect observers
|
|
7947
|
+
|
|
7948
|
+
this.reconnectionMonitor.close();
|
|
7949
|
+
};
|
|
8054
7950
|
|
|
8055
7951
|
AWSAppSyncRealTimeProvider.prototype.getNewWebSocket = function (url, protocol) {
|
|
8056
7952
|
return new WebSocket(url, protocol);
|
|
@@ -8088,36 +7984,56 @@ function (_super) {
|
|
|
8088
7984
|
});
|
|
8089
7985
|
observer.complete();
|
|
8090
7986
|
} else {
|
|
7987
|
+
var subscriptionStartActive_1 = false;
|
|
8091
7988
|
var subscriptionId_1 = Object(uuid__WEBPACK_IMPORTED_MODULE_3__["v4"])();
|
|
8092
7989
|
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
subscriptionId: subscriptionId_1
|
|
8097
|
-
})["catch"](function (err) {
|
|
8098
|
-
observer.error({
|
|
8099
|
-
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].REALTIME_SUBSCRIPTION_INIT_ERROR + ": " + err))]
|
|
8100
|
-
});
|
|
7990
|
+
var startSubscription_1 = function startSubscription_1() {
|
|
7991
|
+
if (!subscriptionStartActive_1) {
|
|
7992
|
+
subscriptionStartActive_1 = true;
|
|
8101
7993
|
|
|
8102
|
-
|
|
7994
|
+
var startSubscriptionPromise = _this._startSubscriptionWithAWSAppSyncRealTime({
|
|
7995
|
+
options: options,
|
|
7996
|
+
observer: observer,
|
|
7997
|
+
subscriptionId: subscriptionId_1
|
|
7998
|
+
})["catch"](function (err) {
|
|
7999
|
+
logger.debug(_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].REALTIME_SUBSCRIPTION_INIT_ERROR + ": " + err);
|
|
8103
8000
|
|
|
8104
|
-
|
|
8105
|
-
|
|
8001
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
8002
|
+
});
|
|
8003
|
+
|
|
8004
|
+
startSubscriptionPromise["finally"](function () {
|
|
8005
|
+
subscriptionStartActive_1 = false;
|
|
8006
|
+
});
|
|
8007
|
+
}
|
|
8008
|
+
};
|
|
8106
8009
|
|
|
8010
|
+
var reconnectSubscription_1; // Add an observable to the reconnection list to manage reconnection for this subscription
|
|
8011
|
+
|
|
8012
|
+
reconnectSubscription_1 = new zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__["default"](function (observer) {
|
|
8013
|
+
_this.reconnectionMonitor.addObserver(observer);
|
|
8014
|
+
}).subscribe(function () {
|
|
8015
|
+
startSubscription_1();
|
|
8016
|
+
});
|
|
8017
|
+
startSubscription_1();
|
|
8107
8018
|
return function () {
|
|
8108
8019
|
return __awaiter(_this, void 0, void 0, function () {
|
|
8109
8020
|
var subscriptionState, err_1;
|
|
8110
8021
|
return __generator(this, function (_a) {
|
|
8111
8022
|
switch (_a.label) {
|
|
8112
8023
|
case 0:
|
|
8113
|
-
|
|
8024
|
+
// Cleanup reconnection subscription
|
|
8025
|
+
reconnectSubscription_1 === null || reconnectSubscription_1 === void 0 ? void 0 : reconnectSubscription_1.unsubscribe();
|
|
8026
|
+
_a.label = 1;
|
|
8027
|
+
|
|
8028
|
+
case 1:
|
|
8029
|
+
_a.trys.push([1, 3, 4, 5]); // Waiting that subscription has been connected before trying to unsubscribe
|
|
8114
8030
|
|
|
8115
8031
|
|
|
8116
8032
|
return [4
|
|
8117
8033
|
/*yield*/
|
|
8118
8034
|
, this._waitForSubscriptionToBeConnected(subscriptionId_1)];
|
|
8119
8035
|
|
|
8120
|
-
case
|
|
8036
|
+
case 2:
|
|
8121
8037
|
// Waiting that subscription has been connected before trying to unsubscribe
|
|
8122
8038
|
_a.sent();
|
|
8123
8039
|
|
|
@@ -8138,23 +8054,23 @@ function (_super) {
|
|
|
8138
8054
|
|
|
8139
8055
|
return [3
|
|
8140
8056
|
/*break*/
|
|
8141
|
-
,
|
|
8057
|
+
, 5];
|
|
8142
8058
|
|
|
8143
|
-
case
|
|
8059
|
+
case 3:
|
|
8144
8060
|
err_1 = _a.sent();
|
|
8145
8061
|
logger.debug("Error while unsubscribing " + err_1);
|
|
8146
8062
|
return [3
|
|
8147
8063
|
/*break*/
|
|
8148
|
-
,
|
|
8064
|
+
, 5];
|
|
8149
8065
|
|
|
8150
|
-
case
|
|
8066
|
+
case 4:
|
|
8151
8067
|
this._removeSubscriptionObserver(subscriptionId_1);
|
|
8152
8068
|
|
|
8153
8069
|
return [7
|
|
8154
8070
|
/*endfinally*/
|
|
8155
8071
|
];
|
|
8156
8072
|
|
|
8157
|
-
case
|
|
8073
|
+
case 5:
|
|
8158
8074
|
return [2
|
|
8159
8075
|
/*return*/
|
|
8160
8076
|
];
|
|
@@ -8179,21 +8095,21 @@ function (_super) {
|
|
|
8179
8095
|
observer = _a.observer,
|
|
8180
8096
|
subscriptionId = _a.subscriptionId;
|
|
8181
8097
|
|
|
8182
|
-
var _b
|
|
8098
|
+
var _b;
|
|
8183
8099
|
|
|
8184
8100
|
return __awaiter(this, void 0, void 0, function () {
|
|
8185
|
-
var appSyncGraphqlEndpoint, authenticationType, query, variables, apiKey, region,
|
|
8101
|
+
var appSyncGraphqlEndpoint, authenticationType, query, variables, apiKey, region, _c, graphql_headers, _d, additionalHeaders, subscriptionState, data, dataString, headerObj, _e, _f, subscriptionMessage, stringToAWSRealTime, err_2, _g, subscriptionFailedCallback, subscriptionReadyCallback;
|
|
8186
8102
|
|
|
8187
|
-
var
|
|
8103
|
+
var _h;
|
|
8188
8104
|
|
|
8189
8105
|
var _this = this;
|
|
8190
8106
|
|
|
8191
|
-
return __generator(this, function (
|
|
8192
|
-
switch (
|
|
8107
|
+
return __generator(this, function (_j) {
|
|
8108
|
+
switch (_j.label) {
|
|
8193
8109
|
case 0:
|
|
8194
|
-
appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint, authenticationType = options.authenticationType, query = options.query, variables = options.variables, apiKey = options.apiKey, region = options.region,
|
|
8110
|
+
appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint, authenticationType = options.authenticationType, query = options.query, variables = options.variables, apiKey = options.apiKey, region = options.region, _c = options.graphql_headers, graphql_headers = _c === void 0 ? function () {
|
|
8195
8111
|
return {};
|
|
8196
|
-
} :
|
|
8112
|
+
} : _c, _d = options.additionalHeaders, additionalHeaders = _d === void 0 ? {} : _d;
|
|
8197
8113
|
subscriptionState = _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].PENDING;
|
|
8198
8114
|
data = {
|
|
8199
8115
|
query: query,
|
|
@@ -8208,7 +8124,7 @@ function (_super) {
|
|
|
8208
8124
|
startAckTimeoutId: undefined
|
|
8209
8125
|
});
|
|
8210
8126
|
dataString = JSON.stringify(data);
|
|
8211
|
-
|
|
8127
|
+
_e = [{}];
|
|
8212
8128
|
return [4
|
|
8213
8129
|
/*yield*/
|
|
8214
8130
|
, this._awsRealTimeHeaderBasedAuth({
|
|
@@ -8222,13 +8138,13 @@ function (_super) {
|
|
|
8222
8138
|
})];
|
|
8223
8139
|
|
|
8224
8140
|
case 1:
|
|
8225
|
-
|
|
8141
|
+
_f = [__assign.apply(void 0, _e.concat([_j.sent()]))];
|
|
8226
8142
|
return [4
|
|
8227
8143
|
/*yield*/
|
|
8228
8144
|
, graphql_headers()];
|
|
8229
8145
|
|
|
8230
8146
|
case 2:
|
|
8231
|
-
headerObj = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0,
|
|
8147
|
+
headerObj = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0, _f.concat([_j.sent()])), additionalHeaders]), (_h = {}, _h[_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["USER_AGENT_HEADER"]] = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Constants"].userAgent, _h)]);
|
|
8232
8148
|
subscriptionMessage = {
|
|
8233
8149
|
id: subscriptionId,
|
|
8234
8150
|
payload: {
|
|
@@ -8240,10 +8156,10 @@ function (_super) {
|
|
|
8240
8156
|
type: _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_START
|
|
8241
8157
|
};
|
|
8242
8158
|
stringToAWSRealTime = JSON.stringify(subscriptionMessage);
|
|
8243
|
-
|
|
8159
|
+
_j.label = 3;
|
|
8244
8160
|
|
|
8245
8161
|
case 3:
|
|
8246
|
-
|
|
8162
|
+
_j.trys.push([3, 5,, 6]);
|
|
8247
8163
|
|
|
8248
8164
|
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].OPENING_CONNECTION);
|
|
8249
8165
|
return [4
|
|
@@ -8257,35 +8173,23 @@ function (_super) {
|
|
|
8257
8173
|
})];
|
|
8258
8174
|
|
|
8259
8175
|
case 4:
|
|
8260
|
-
|
|
8176
|
+
_j.sent();
|
|
8261
8177
|
|
|
8262
8178
|
return [3
|
|
8263
8179
|
/*break*/
|
|
8264
8180
|
, 6];
|
|
8265
8181
|
|
|
8266
8182
|
case 5:
|
|
8267
|
-
err_2 =
|
|
8268
|
-
logger.debug({
|
|
8269
|
-
err: err_2
|
|
8270
|
-
});
|
|
8271
|
-
message = (_b = err_2['message']) !== null && _b !== void 0 ? _b : '';
|
|
8272
|
-
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
8273
|
-
observer.error({
|
|
8274
|
-
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + message))]
|
|
8275
|
-
});
|
|
8276
|
-
observer.complete();
|
|
8277
|
-
subscriptionFailedCallback_1 = (this.subscriptionObserverMap.get(subscriptionId) || {}).subscriptionFailedCallback; // Notify concurrent unsubscription
|
|
8183
|
+
err_2 = _j.sent();
|
|
8278
8184
|
|
|
8279
|
-
|
|
8280
|
-
subscriptionFailedCallback_1();
|
|
8281
|
-
}
|
|
8185
|
+
this._logStartSubscriptionError(subscriptionId, observer, err_2);
|
|
8282
8186
|
|
|
8283
8187
|
return [2
|
|
8284
8188
|
/*return*/
|
|
8285
8189
|
];
|
|
8286
8190
|
|
|
8287
8191
|
case 6:
|
|
8288
|
-
|
|
8192
|
+
_g = (_b = this.subscriptionObserverMap.get(subscriptionId)) !== null && _b !== void 0 ? _b : {}, subscriptionFailedCallback = _g.subscriptionFailedCallback, subscriptionReadyCallback = _g.subscriptionReadyCallback; // This must be done before sending the message in order to be listening immediately
|
|
8289
8193
|
|
|
8290
8194
|
this.subscriptionObserverMap.set(subscriptionId, {
|
|
8291
8195
|
observer: observer,
|
|
@@ -8309,6 +8213,35 @@ function (_super) {
|
|
|
8309
8213
|
}
|
|
8310
8214
|
});
|
|
8311
8215
|
});
|
|
8216
|
+
}; // Log logic for start subscription failures
|
|
8217
|
+
|
|
8218
|
+
|
|
8219
|
+
AWSAppSyncRealTimeProvider.prototype._logStartSubscriptionError = function (subscriptionId, observer, err) {
|
|
8220
|
+
var _a;
|
|
8221
|
+
|
|
8222
|
+
logger.debug({
|
|
8223
|
+
err: err
|
|
8224
|
+
});
|
|
8225
|
+
var message = (_a = err['message']) !== null && _a !== void 0 ? _a : ''; // Resolving to give the state observer time to propogate the update
|
|
8226
|
+
|
|
8227
|
+
Promise.resolve(this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED)); // Capture the error only when the network didn't cause disruption
|
|
8228
|
+
|
|
8229
|
+
if (this.connectionState !== _types_PubSub__WEBPACK_IMPORTED_MODULE_9__["ConnectionState"].ConnectionDisruptedPendingNetwork) {
|
|
8230
|
+
// When the error is non-retriable, error out the observable
|
|
8231
|
+
if (Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["isNonRetryableError"])(err)) {
|
|
8232
|
+
observer.error({
|
|
8233
|
+
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + message))]
|
|
8234
|
+
});
|
|
8235
|
+
} else {
|
|
8236
|
+
logger.debug(_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + message);
|
|
8237
|
+
}
|
|
8238
|
+
|
|
8239
|
+
var subscriptionFailedCallback = (this.subscriptionObserverMap.get(subscriptionId) || {}).subscriptionFailedCallback; // Notify concurrent unsubscription
|
|
8240
|
+
|
|
8241
|
+
if (typeof subscriptionFailedCallback === 'function') {
|
|
8242
|
+
subscriptionFailedCallback();
|
|
8243
|
+
}
|
|
8244
|
+
}
|
|
8312
8245
|
}; // Waiting that subscription has been connected before trying to unsubscribe
|
|
8313
8246
|
|
|
8314
8247
|
|
|
@@ -8465,7 +8398,7 @@ function (_super) {
|
|
|
8465
8398
|
}
|
|
8466
8399
|
|
|
8467
8400
|
if (startAckTimeoutId) clearTimeout(startAckTimeoutId);
|
|
8468
|
-
dispatchApiEvent(
|
|
8401
|
+
dispatchApiEvent(_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].SUBSCRIPTION_ACK, {
|
|
8469
8402
|
query: query,
|
|
8470
8403
|
variables: variables
|
|
8471
8404
|
}, 'Connection established for subscription');
|
|
@@ -8491,7 +8424,7 @@ function (_super) {
|
|
|
8491
8424
|
if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
|
|
8492
8425
|
if (this.keepAliveAlertTimeoutId) clearTimeout(this.keepAliveAlertTimeoutId);
|
|
8493
8426
|
this.keepAliveTimeoutId = setTimeout(function () {
|
|
8494
|
-
return _this._errorDisconnect(
|
|
8427
|
+
return _this._errorDisconnect(_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].TIMEOUT_DISCONNECT);
|
|
8495
8428
|
}, this.keepAliveTimeout);
|
|
8496
8429
|
this.keepAliveAlertTimeoutId = setTimeout(function () {
|
|
8497
8430
|
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].KEEP_ALIVE_MISSED);
|
|
@@ -8513,11 +8446,11 @@ function (_super) {
|
|
|
8513
8446
|
subscriptionFailedCallback: subscriptionFailedCallback,
|
|
8514
8447
|
subscriptionState: subscriptionState
|
|
8515
8448
|
});
|
|
8449
|
+
logger.debug(_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + JSON.stringify(payload));
|
|
8516
8450
|
observer.error({
|
|
8517
|
-
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](
|
|
8451
|
+
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + JSON.stringify(payload)))]
|
|
8518
8452
|
});
|
|
8519
8453
|
if (startAckTimeoutId) clearTimeout(startAckTimeoutId);
|
|
8520
|
-
observer.complete();
|
|
8521
8454
|
|
|
8522
8455
|
if (typeof subscriptionFailedCallback === 'function') {
|
|
8523
8456
|
subscriptionFailedCallback();
|
|
@@ -8528,16 +8461,6 @@ function (_super) {
|
|
|
8528
8461
|
|
|
8529
8462
|
AWSAppSyncRealTimeProvider.prototype._errorDisconnect = function (msg) {
|
|
8530
8463
|
logger.debug("Disconnect error: " + msg);
|
|
8531
|
-
this.subscriptionObserverMap.forEach(function (_a) {
|
|
8532
|
-
var observer = _a.observer;
|
|
8533
|
-
|
|
8534
|
-
if (observer && !observer.closed) {
|
|
8535
|
-
observer.error({
|
|
8536
|
-
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](msg))]
|
|
8537
|
-
});
|
|
8538
|
-
}
|
|
8539
|
-
});
|
|
8540
|
-
this.subscriptionObserverMap.clear();
|
|
8541
8464
|
|
|
8542
8465
|
if (this.awsRealTimeSocket) {
|
|
8543
8466
|
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
@@ -8565,18 +8488,7 @@ function (_super) {
|
|
|
8565
8488
|
variables: variables,
|
|
8566
8489
|
subscriptionState: _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].FAILED
|
|
8567
8490
|
});
|
|
8568
|
-
|
|
8569
|
-
if (observer && !observer.closed) {
|
|
8570
|
-
observer.error({
|
|
8571
|
-
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"]("Subscription timeout " + JSON.stringify({
|
|
8572
|
-
query: query,
|
|
8573
|
-
variables: variables
|
|
8574
|
-
})))]
|
|
8575
|
-
}); // Cleanup will be automatically executed
|
|
8576
|
-
|
|
8577
|
-
observer.complete();
|
|
8578
|
-
}
|
|
8579
|
-
|
|
8491
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
8580
8492
|
logger.debug('timeoutStartSubscription', JSON.stringify({
|
|
8581
8493
|
query: query,
|
|
8582
8494
|
variables: variables
|
|
@@ -8666,6 +8578,7 @@ function (_super) {
|
|
|
8666
8578
|
|
|
8667
8579
|
case 4:
|
|
8668
8580
|
err_3 = _c.sent();
|
|
8581
|
+
logger.debug('Connection exited with', err_3);
|
|
8669
8582
|
this.promiseArray.forEach(function (_a) {
|
|
8670
8583
|
var rej = _a.rej;
|
|
8671
8584
|
return rej(err_3);
|
|
@@ -8739,8 +8652,6 @@ function (_super) {
|
|
|
8739
8652
|
};
|
|
8740
8653
|
|
|
8741
8654
|
newSocket.onclose = function () {
|
|
8742
|
-
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CONNECTION_FAILED);
|
|
8743
|
-
|
|
8744
8655
|
rej(new Error('Connection handshake error'));
|
|
8745
8656
|
};
|
|
8746
8657
|
|
|
@@ -8789,13 +8700,13 @@ function (_super) {
|
|
|
8789
8700
|
_this.awsRealTimeSocket.onerror = function (err) {
|
|
8790
8701
|
logger.debug(err);
|
|
8791
8702
|
|
|
8792
|
-
_this._errorDisconnect(
|
|
8703
|
+
_this._errorDisconnect(_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
|
|
8793
8704
|
};
|
|
8794
8705
|
|
|
8795
8706
|
_this.awsRealTimeSocket.onclose = function (event) {
|
|
8796
8707
|
logger.debug("WebSocket closed " + event.reason);
|
|
8797
8708
|
|
|
8798
|
-
_this._errorDisconnect(
|
|
8709
|
+
_this._errorDisconnect(_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
|
|
8799
8710
|
};
|
|
8800
8711
|
}
|
|
8801
8712
|
|
|
@@ -8827,14 +8738,17 @@ function (_super) {
|
|
|
8827
8738
|
|
|
8828
8739
|
_this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
|
|
8829
8740
|
|
|
8830
|
-
|
|
8831
|
-
|
|
8741
|
+
var checkAckOk_1 = function checkAckOk_1(ackOk) {
|
|
8742
|
+
if (!ackOk) {
|
|
8743
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CONNECTION_FAILED);
|
|
8832
8744
|
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
|
|
8745
|
+
rej(new Error("Connection timeout: ack from AWSAppSyncRealTime was not received after " + _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"] + " ms"));
|
|
8746
|
+
}
|
|
8747
|
+
};
|
|
8748
|
+
|
|
8749
|
+
setTimeout(function () {
|
|
8750
|
+
return checkAckOk_1(ackOk_1);
|
|
8751
|
+
}, _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"]);
|
|
8838
8752
|
}
|
|
8839
8753
|
});
|
|
8840
8754
|
}()];
|
|
@@ -9399,8 +9313,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
9399
9313
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(uuid__WEBPACK_IMPORTED_MODULE_1__);
|
|
9400
9314
|
/* harmony import */ var zen_observable_ts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! zen-observable-ts */ "../../node_modules/zen-observable-ts/lib/bundle.esm.js");
|
|
9401
9315
|
/* harmony import */ var _PubSubProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./PubSubProvider */ "./lib-esm/Providers/PubSubProvider.js");
|
|
9402
|
-
/* harmony import */ var
|
|
9403
|
-
/* harmony import */ var
|
|
9316
|
+
/* harmony import */ var _types_PubSub__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../types/PubSub */ "./lib-esm/types/PubSub.js");
|
|
9317
|
+
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
|
|
9318
|
+
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__);
|
|
9319
|
+
/* harmony import */ var _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/ConnectionStateMonitor */ "./lib-esm/utils/ConnectionStateMonitor.js");
|
|
9320
|
+
/* harmony import */ var _utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/ReconnectionMonitor */ "./lib-esm/utils/ReconnectionMonitor.js");
|
|
9321
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./constants */ "./lib-esm/Providers/constants.js");
|
|
9404
9322
|
function _typeof(obj) {
|
|
9405
9323
|
"@babel/helpers - typeof";
|
|
9406
9324
|
|
|
@@ -9627,7 +9545,11 @@ var __rest = undefined && undefined.__rest || function (s, e) {
|
|
|
9627
9545
|
|
|
9628
9546
|
|
|
9629
9547
|
|
|
9630
|
-
|
|
9548
|
+
|
|
9549
|
+
|
|
9550
|
+
|
|
9551
|
+
|
|
9552
|
+
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["ConsoleLogger"]('MqttOverWSProvider');
|
|
9631
9553
|
function mqttTopicMatch(filter, topic) {
|
|
9632
9554
|
var filterArray = filter.split('/');
|
|
9633
9555
|
var length = filterArray.length;
|
|
@@ -9653,18 +9575,21 @@ function () {
|
|
|
9653
9575
|
ClientsQueue.prototype.get = function (clientId, clientFactory) {
|
|
9654
9576
|
return __awaiter(this, void 0, void 0, function () {
|
|
9655
9577
|
var cachedPromise, newPromise;
|
|
9578
|
+
|
|
9579
|
+
var _this = this;
|
|
9580
|
+
|
|
9656
9581
|
return __generator(this, function (_a) {
|
|
9657
9582
|
cachedPromise = this.promises.get(clientId);
|
|
9658
|
-
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
/*return*/
|
|
9662
|
-
, cachedPromise];
|
|
9663
|
-
}
|
|
9583
|
+
if (cachedPromise) return [2
|
|
9584
|
+
/*return*/
|
|
9585
|
+
, cachedPromise];
|
|
9664
9586
|
|
|
9665
9587
|
if (clientFactory) {
|
|
9666
9588
|
newPromise = clientFactory(clientId);
|
|
9667
9589
|
this.promises.set(clientId, newPromise);
|
|
9590
|
+
newPromise["catch"](function (v) {
|
|
9591
|
+
return _this.promises["delete"](clientId);
|
|
9592
|
+
});
|
|
9668
9593
|
return [2
|
|
9669
9594
|
/*return*/
|
|
9670
9595
|
, newPromise];
|
|
@@ -9692,6 +9617,14 @@ function () {
|
|
|
9692
9617
|
return ClientsQueue;
|
|
9693
9618
|
}();
|
|
9694
9619
|
|
|
9620
|
+
var dispatchPubSubEvent = function dispatchPubSubEvent(event, data, message) {
|
|
9621
|
+
_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Hub"].dispatch('pubsub', {
|
|
9622
|
+
event: event,
|
|
9623
|
+
data: data,
|
|
9624
|
+
message: message
|
|
9625
|
+
}, 'PubSub', _constants__WEBPACK_IMPORTED_MODULE_8__["AMPLIFY_SYMBOL"]);
|
|
9626
|
+
};
|
|
9627
|
+
|
|
9695
9628
|
var topicSymbol = typeof Symbol !== 'undefined' ? Symbol('topic') : '@@topic';
|
|
9696
9629
|
|
|
9697
9630
|
var MqttOverWSProvider =
|
|
@@ -9709,8 +9642,26 @@ function (_super) {
|
|
|
9709
9642
|
})) || this;
|
|
9710
9643
|
|
|
9711
9644
|
_this._clientsQueue = new ClientsQueue();
|
|
9645
|
+
_this.connectionStateMonitor = new _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__["ConnectionStateMonitor"]();
|
|
9646
|
+
_this.reconnectionMonitor = new _utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_7__["ReconnectionMonitor"]();
|
|
9712
9647
|
_this._topicObservers = new Map();
|
|
9713
|
-
_this._clientIdObservers = new Map();
|
|
9648
|
+
_this._clientIdObservers = new Map(); // Monitor the connection health state and pass changes along to Hub
|
|
9649
|
+
|
|
9650
|
+
_this.connectionStateMonitor.connectionStateObservable.subscribe(function (connectionStateChange) {
|
|
9651
|
+
dispatchPubSubEvent(_constants__WEBPACK_IMPORTED_MODULE_8__["CONNECTION_STATE_CHANGE"], {
|
|
9652
|
+
provider: _this,
|
|
9653
|
+
connectionState: connectionStateChange
|
|
9654
|
+
}, "Connection state is " + connectionStateChange);
|
|
9655
|
+
_this.connectionState = connectionStateChange; // Trigger reconnection when the connection is disrupted
|
|
9656
|
+
|
|
9657
|
+
if (connectionStateChange === _types_PubSub__WEBPACK_IMPORTED_MODULE_4__["ConnectionState"].ConnectionDisrupted) {
|
|
9658
|
+
_this.reconnectionMonitor.record(_utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_7__["ReconnectEvent"].START_RECONNECT);
|
|
9659
|
+
} else if (connectionStateChange !== _types_PubSub__WEBPACK_IMPORTED_MODULE_4__["ConnectionState"].Connecting) {
|
|
9660
|
+
// Trigger connected to halt reconnection attempts
|
|
9661
|
+
_this.reconnectionMonitor.record(_utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_7__["ReconnectEvent"].HALT_RECONNECT);
|
|
9662
|
+
}
|
|
9663
|
+
});
|
|
9664
|
+
|
|
9714
9665
|
return _this;
|
|
9715
9666
|
}
|
|
9716
9667
|
|
|
@@ -9752,8 +9703,6 @@ function (_super) {
|
|
|
9752
9703
|
};
|
|
9753
9704
|
|
|
9754
9705
|
MqttOverWSProvider.prototype.onDisconnect = function (_a) {
|
|
9755
|
-
var _this = this;
|
|
9756
|
-
|
|
9757
9706
|
var clientId = _a.clientId,
|
|
9758
9707
|
errorCode = _a.errorCode,
|
|
9759
9708
|
args = __rest(_a, ["clientId", "errorCode"]);
|
|
@@ -9762,7 +9711,6 @@ function (_super) {
|
|
|
9762
9711
|
logger.warn(clientId, JSON.stringify(__assign({
|
|
9763
9712
|
errorCode: errorCode
|
|
9764
9713
|
}, args), null, 2));
|
|
9765
|
-
var topicsToDelete_1 = [];
|
|
9766
9714
|
|
|
9767
9715
|
if (!clientId) {
|
|
9768
9716
|
return;
|
|
@@ -9774,24 +9722,7 @@ function (_super) {
|
|
|
9774
9722
|
return;
|
|
9775
9723
|
}
|
|
9776
9724
|
|
|
9777
|
-
|
|
9778
|
-
observer.error('Disconnected, error code: ' + errorCode); // removing observers for disconnected clientId
|
|
9779
|
-
|
|
9780
|
-
_this._topicObservers.forEach(function (observerForTopic, observerTopic) {
|
|
9781
|
-
observerForTopic["delete"](observer);
|
|
9782
|
-
|
|
9783
|
-
if (observerForTopic.size === 0) {
|
|
9784
|
-
topicsToDelete_1.push(observerTopic);
|
|
9785
|
-
}
|
|
9786
|
-
});
|
|
9787
|
-
}); // forgiving any trace of clientId
|
|
9788
|
-
|
|
9789
|
-
this._clientIdObservers["delete"](clientId); // Removing topics that are not listen by an observer
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
topicsToDelete_1.forEach(function (topic) {
|
|
9793
|
-
_this._topicObservers["delete"](topic);
|
|
9794
|
-
});
|
|
9725
|
+
this.disconnect(clientId);
|
|
9795
9726
|
}
|
|
9796
9727
|
};
|
|
9797
9728
|
|
|
@@ -9799,7 +9730,7 @@ function (_super) {
|
|
|
9799
9730
|
var url = _a.url,
|
|
9800
9731
|
clientId = _a.clientId;
|
|
9801
9732
|
return __awaiter(this, void 0, void 0, function () {
|
|
9802
|
-
var client;
|
|
9733
|
+
var client, connected;
|
|
9803
9734
|
|
|
9804
9735
|
var _this = this;
|
|
9805
9736
|
|
|
@@ -9807,7 +9738,8 @@ function (_super) {
|
|
|
9807
9738
|
switch (_b.label) {
|
|
9808
9739
|
case 0:
|
|
9809
9740
|
logger.debug('Creating new MQTT client', clientId);
|
|
9810
|
-
|
|
9741
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__["CONNECTION_CHANGE"].OPENING_CONNECTION);
|
|
9742
|
+
client = new paho_mqtt__WEBPACK_IMPORTED_MODULE_0__["Client"](url, clientId);
|
|
9811
9743
|
|
|
9812
9744
|
client.onMessageArrived = function (_a) {
|
|
9813
9745
|
var topic = _a.destinationName,
|
|
@@ -9824,6 +9756,8 @@ function (_super) {
|
|
|
9824
9756
|
clientId: clientId,
|
|
9825
9757
|
errorCode: errorCode
|
|
9826
9758
|
}, args));
|
|
9759
|
+
|
|
9760
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__["CONNECTION_CHANGE"].CLOSED);
|
|
9827
9761
|
};
|
|
9828
9762
|
|
|
9829
9763
|
return [4
|
|
@@ -9833,14 +9767,24 @@ function (_super) {
|
|
|
9833
9767
|
useSSL: _this.isSSLEnabled,
|
|
9834
9768
|
mqttVersion: 3,
|
|
9835
9769
|
onSuccess: function onSuccess() {
|
|
9836
|
-
return resolve(
|
|
9770
|
+
return resolve(true);
|
|
9837
9771
|
},
|
|
9838
|
-
onFailure:
|
|
9772
|
+
onFailure: function onFailure(x) {
|
|
9773
|
+
if (clientId) _this._clientsQueue.remove(clientId);
|
|
9774
|
+
|
|
9775
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__["CONNECTION_CHANGE"].CLOSED);
|
|
9776
|
+
|
|
9777
|
+
resolve(false);
|
|
9778
|
+
}
|
|
9839
9779
|
});
|
|
9840
9780
|
})];
|
|
9841
9781
|
|
|
9842
9782
|
case 1:
|
|
9843
|
-
_b.sent();
|
|
9783
|
+
connected = _b.sent();
|
|
9784
|
+
|
|
9785
|
+
if (connected) {
|
|
9786
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__["CONNECTION_CHANGE"].CONNECTION_ESTABLISHED);
|
|
9787
|
+
}
|
|
9844
9788
|
|
|
9845
9789
|
return [2
|
|
9846
9790
|
/*return*/
|
|
@@ -9864,9 +9808,33 @@ function (_super) {
|
|
|
9864
9808
|
return [4
|
|
9865
9809
|
/*yield*/
|
|
9866
9810
|
, this.clientsQueue.get(clientId, function (clientId) {
|
|
9867
|
-
return _this
|
|
9868
|
-
|
|
9869
|
-
|
|
9811
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
9812
|
+
var client;
|
|
9813
|
+
return __generator(this, function (_a) {
|
|
9814
|
+
switch (_a.label) {
|
|
9815
|
+
case 0:
|
|
9816
|
+
return [4
|
|
9817
|
+
/*yield*/
|
|
9818
|
+
, this.newClient(__assign(__assign({}, options), {
|
|
9819
|
+
clientId: clientId
|
|
9820
|
+
}))];
|
|
9821
|
+
|
|
9822
|
+
case 1:
|
|
9823
|
+
client = _a.sent();
|
|
9824
|
+
|
|
9825
|
+
if (client) {
|
|
9826
|
+
// Once connected, subscribe to all topics registered observers
|
|
9827
|
+
this._topicObservers.forEach(function (_value, key) {
|
|
9828
|
+
client.subscribe(key);
|
|
9829
|
+
});
|
|
9830
|
+
}
|
|
9831
|
+
|
|
9832
|
+
return [2
|
|
9833
|
+
/*return*/
|
|
9834
|
+
, client];
|
|
9835
|
+
}
|
|
9836
|
+
});
|
|
9837
|
+
});
|
|
9870
9838
|
})];
|
|
9871
9839
|
|
|
9872
9840
|
case 1:
|
|
@@ -9896,6 +9864,7 @@ function (_super) {
|
|
|
9896
9864
|
}
|
|
9897
9865
|
|
|
9898
9866
|
this.clientsQueue.remove(clientId);
|
|
9867
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__["CONNECTION_CHANGE"].CLOSED);
|
|
9899
9868
|
return [2
|
|
9900
9869
|
/*return*/
|
|
9901
9870
|
];
|
|
@@ -9906,7 +9875,7 @@ function (_super) {
|
|
|
9906
9875
|
|
|
9907
9876
|
MqttOverWSProvider.prototype.publish = function (topics, msg) {
|
|
9908
9877
|
return __awaiter(this, void 0, void 0, function () {
|
|
9909
|
-
var targetTopics, message,
|
|
9878
|
+
var targetTopics, message, client;
|
|
9910
9879
|
return __generator(this, function (_a) {
|
|
9911
9880
|
switch (_a.label) {
|
|
9912
9881
|
case 0:
|
|
@@ -9914,24 +9883,22 @@ function (_super) {
|
|
|
9914
9883
|
message = JSON.stringify(msg);
|
|
9915
9884
|
return [4
|
|
9916
9885
|
/*yield*/
|
|
9917
|
-
, this.
|
|
9886
|
+
, this.clientsQueue.get(this.clientId)];
|
|
9918
9887
|
|
|
9919
9888
|
case 1:
|
|
9920
|
-
url = _a.sent();
|
|
9921
|
-
return [4
|
|
9922
|
-
/*yield*/
|
|
9923
|
-
, this.connect(this.clientId, {
|
|
9924
|
-
url: url
|
|
9925
|
-
})];
|
|
9926
|
-
|
|
9927
|
-
case 2:
|
|
9928
9889
|
client = _a.sent();
|
|
9929
|
-
|
|
9930
|
-
|
|
9931
|
-
|
|
9932
|
-
|
|
9933
|
-
|
|
9934
|
-
|
|
9890
|
+
|
|
9891
|
+
if (client) {
|
|
9892
|
+
logger.debug('Publishing to topic(s)', targetTopics.join(','), message);
|
|
9893
|
+
targetTopics.forEach(function (topic) {
|
|
9894
|
+
return client.send(topic, message);
|
|
9895
|
+
});
|
|
9896
|
+
} else {
|
|
9897
|
+
logger.debug('Publishing to topic(s) failed', targetTopics.join(','), message);
|
|
9898
|
+
}
|
|
9899
|
+
|
|
9900
|
+
return [2
|
|
9901
|
+
/*return*/
|
|
9935
9902
|
];
|
|
9936
9903
|
}
|
|
9937
9904
|
});
|
|
@@ -9973,6 +9940,7 @@ function (_super) {
|
|
|
9973
9940
|
|
|
9974
9941
|
var targetTopics = [].concat(topics);
|
|
9975
9942
|
logger.debug('Subscribing to topic(s)', targetTopics.join(','));
|
|
9943
|
+
var reconnectSubscription;
|
|
9976
9944
|
return new zen_observable_ts__WEBPACK_IMPORTED_MODULE_2__["default"](function (observer) {
|
|
9977
9945
|
targetTopics.forEach(function (topic) {
|
|
9978
9946
|
// this._topicObservers is used to notify the observers according to the topic received on the message
|
|
@@ -9985,9 +9953,7 @@ function (_super) {
|
|
|
9985
9953
|
}
|
|
9986
9954
|
|
|
9987
9955
|
observersForTopic.add(observer);
|
|
9988
|
-
});
|
|
9989
|
-
|
|
9990
|
-
var client;
|
|
9956
|
+
});
|
|
9991
9957
|
var _a = options.clientId,
|
|
9992
9958
|
clientId = _a === void 0 ? _this.clientId : _a; // this._clientIdObservers is used to close observers when client gets disconnected
|
|
9993
9959
|
|
|
@@ -10003,59 +9969,92 @@ function (_super) {
|
|
|
10003
9969
|
|
|
10004
9970
|
(function () {
|
|
10005
9971
|
return __awaiter(_this, void 0, void 0, function () {
|
|
10006
|
-
var
|
|
9972
|
+
var getClient;
|
|
10007
9973
|
|
|
10008
|
-
|
|
10009
|
-
|
|
9974
|
+
var _this = this;
|
|
9975
|
+
|
|
9976
|
+
return __generator(this, function (_a) {
|
|
9977
|
+
switch (_a.label) {
|
|
10010
9978
|
case 0:
|
|
10011
|
-
|
|
10012
|
-
|
|
10013
|
-
|
|
10014
|
-
, 2];
|
|
10015
|
-
return [4
|
|
10016
|
-
/*yield*/
|
|
10017
|
-
, this.endpoint];
|
|
9979
|
+
getClient = function getClient() {
|
|
9980
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
9981
|
+
var _a, url, _b, client_1, e_1;
|
|
10018
9982
|
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10023
|
-
, 3];
|
|
9983
|
+
return __generator(this, function (_c) {
|
|
9984
|
+
switch (_c.label) {
|
|
9985
|
+
case 0:
|
|
9986
|
+
_c.trys.push([0, 5,, 6]);
|
|
10024
9987
|
|
|
10025
|
-
|
|
10026
|
-
|
|
10027
|
-
|
|
9988
|
+
_a = options.url;
|
|
9989
|
+
if (!(_a === void 0)) return [3
|
|
9990
|
+
/*break*/
|
|
9991
|
+
, 2];
|
|
9992
|
+
return [4
|
|
9993
|
+
/*yield*/
|
|
9994
|
+
, this.endpoint];
|
|
9995
|
+
|
|
9996
|
+
case 1:
|
|
9997
|
+
_b = _c.sent();
|
|
9998
|
+
return [3
|
|
9999
|
+
/*break*/
|
|
10000
|
+
, 3];
|
|
10001
|
+
|
|
10002
|
+
case 2:
|
|
10003
|
+
_b = _a;
|
|
10004
|
+
_c.label = 3;
|
|
10005
|
+
|
|
10006
|
+
case 3:
|
|
10007
|
+
url = _b;
|
|
10008
|
+
return [4
|
|
10009
|
+
/*yield*/
|
|
10010
|
+
, this.connect(clientId, {
|
|
10011
|
+
url: url
|
|
10012
|
+
})];
|
|
10013
|
+
|
|
10014
|
+
case 4:
|
|
10015
|
+
client_1 = _c.sent();
|
|
10016
|
+
|
|
10017
|
+
if (client_1 !== undefined) {
|
|
10018
|
+
targetTopics.forEach(function (topic) {
|
|
10019
|
+
client_1.subscribe(topic);
|
|
10020
|
+
});
|
|
10021
|
+
}
|
|
10022
|
+
|
|
10023
|
+
return [3
|
|
10024
|
+
/*break*/
|
|
10025
|
+
, 6];
|
|
10026
|
+
|
|
10027
|
+
case 5:
|
|
10028
|
+
e_1 = _c.sent();
|
|
10029
|
+
logger.debug('Error forming connection', e_1);
|
|
10030
|
+
return [3
|
|
10031
|
+
/*break*/
|
|
10032
|
+
, 6];
|
|
10028
10033
|
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10034
|
+
case 6:
|
|
10035
|
+
return [2
|
|
10036
|
+
/*return*/
|
|
10037
|
+
];
|
|
10038
|
+
}
|
|
10039
|
+
});
|
|
10040
|
+
});
|
|
10041
|
+
}; // Establish the initial connection
|
|
10032
10042
|
|
|
10033
|
-
case 4:
|
|
10034
|
-
_c.trys.push([4, 6,, 7]);
|
|
10035
10043
|
|
|
10036
10044
|
return [4
|
|
10037
10045
|
/*yield*/
|
|
10038
|
-
,
|
|
10039
|
-
url: url
|
|
10040
|
-
})];
|
|
10046
|
+
, getClient()];
|
|
10041
10047
|
|
|
10042
|
-
case
|
|
10043
|
-
|
|
10044
|
-
|
|
10045
|
-
|
|
10048
|
+
case 1:
|
|
10049
|
+
// Establish the initial connection
|
|
10050
|
+
_a.sent(); // Add an observable to the reconnection list to manage reconnection for this subscription
|
|
10051
|
+
|
|
10052
|
+
|
|
10053
|
+
reconnectSubscription = new zen_observable_ts__WEBPACK_IMPORTED_MODULE_2__["default"](function (observer) {
|
|
10054
|
+
_this.reconnectionMonitor.addObserver(observer);
|
|
10055
|
+
}).subscribe(function () {
|
|
10056
|
+
getClient();
|
|
10046
10057
|
});
|
|
10047
|
-
return [3
|
|
10048
|
-
/*break*/
|
|
10049
|
-
, 7];
|
|
10050
|
-
|
|
10051
|
-
case 6:
|
|
10052
|
-
e_1 = _c.sent();
|
|
10053
|
-
observer.error(e_1);
|
|
10054
|
-
return [3
|
|
10055
|
-
/*break*/
|
|
10056
|
-
, 7];
|
|
10057
|
-
|
|
10058
|
-
case 7:
|
|
10059
10058
|
return [2
|
|
10060
10059
|
/*return*/
|
|
10061
10060
|
];
|
|
@@ -10065,34 +10064,54 @@ function (_super) {
|
|
|
10065
10064
|
})();
|
|
10066
10065
|
|
|
10067
10066
|
return function () {
|
|
10068
|
-
|
|
10067
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
10068
|
+
var client;
|
|
10069
10069
|
|
|
10070
|
-
|
|
10070
|
+
var _this = this;
|
|
10071
10071
|
|
|
10072
|
-
|
|
10073
|
-
(_a = _this._clientIdObservers.get(clientId)) === null || _a === void 0 ? void 0 : _a["delete"](observer); // No more observers per client => client not needed anymore
|
|
10072
|
+
var _a, _b;
|
|
10074
10073
|
|
|
10075
|
-
|
|
10076
|
-
|
|
10074
|
+
return __generator(this, function (_c) {
|
|
10075
|
+
switch (_c.label) {
|
|
10076
|
+
case 0:
|
|
10077
|
+
return [4
|
|
10078
|
+
/*yield*/
|
|
10079
|
+
, this.clientsQueue.get(clientId)];
|
|
10077
10080
|
|
|
10078
|
-
|
|
10079
|
-
|
|
10081
|
+
case 1:
|
|
10082
|
+
client = _c.sent();
|
|
10083
|
+
reconnectSubscription === null || reconnectSubscription === void 0 ? void 0 : reconnectSubscription.unsubscribe();
|
|
10080
10084
|
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
observersForTopic["delete"](observer); // if no observers exists for the topic, topic should be removed
|
|
10085
|
+
if (client) {
|
|
10086
|
+
(_a = this._clientIdObservers.get(clientId)) === null || _a === void 0 ? void 0 : _a["delete"](observer); // No more observers per client => client not needed anymore
|
|
10084
10087
|
|
|
10085
|
-
|
|
10086
|
-
|
|
10088
|
+
if (((_b = this._clientIdObservers.get(clientId)) === null || _b === void 0 ? void 0 : _b.size) === 0) {
|
|
10089
|
+
this.disconnect(clientId);
|
|
10090
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__["CONNECTION_CHANGE"].CLOSING_CONNECTION);
|
|
10087
10091
|
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10092
|
+
this._clientIdObservers["delete"](clientId);
|
|
10093
|
+
}
|
|
10094
|
+
|
|
10095
|
+
targetTopics.forEach(function (topic) {
|
|
10096
|
+
var observersForTopic = _this._topicObservers.get(topic) || new Set();
|
|
10097
|
+
observersForTopic["delete"](observer); // if no observers exists for the topic, topic should be removed
|
|
10098
|
+
|
|
10099
|
+
if (observersForTopic.size === 0) {
|
|
10100
|
+
_this._topicObservers["delete"](topic);
|
|
10101
|
+
|
|
10102
|
+
if (client.isConnected()) {
|
|
10103
|
+
client.unsubscribe(topic);
|
|
10104
|
+
}
|
|
10105
|
+
}
|
|
10106
|
+
});
|
|
10107
|
+
}
|
|
10108
|
+
|
|
10109
|
+
return [2
|
|
10110
|
+
/*return*/
|
|
10111
|
+
, null];
|
|
10091
10112
|
}
|
|
10092
10113
|
});
|
|
10093
|
-
}
|
|
10094
|
-
|
|
10095
|
-
return null;
|
|
10114
|
+
});
|
|
10096
10115
|
};
|
|
10097
10116
|
});
|
|
10098
10117
|
};
|
|
@@ -10172,6 +10191,151 @@ function () {
|
|
|
10172
10191
|
|
|
10173
10192
|
|
|
10174
10193
|
|
|
10194
|
+
/***/ }),
|
|
10195
|
+
|
|
10196
|
+
/***/ "./lib-esm/Providers/constants.js":
|
|
10197
|
+
/*!****************************************!*\
|
|
10198
|
+
!*** ./lib-esm/Providers/constants.js ***!
|
|
10199
|
+
\****************************************/
|
|
10200
|
+
/*! exports provided: MAX_DELAY_MS, NON_RETRYABLE_CODES, CONNECTION_STATE_CHANGE, 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, RECONNECT_DELAY, RECONNECT_INTERVAL */
|
|
10201
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
10202
|
+
|
|
10203
|
+
"use strict";
|
|
10204
|
+
__webpack_require__.r(__webpack_exports__);
|
|
10205
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MAX_DELAY_MS", function() { return MAX_DELAY_MS; });
|
|
10206
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NON_RETRYABLE_CODES", function() { return NON_RETRYABLE_CODES; });
|
|
10207
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_STATE_CHANGE", function() { return CONNECTION_STATE_CHANGE; });
|
|
10208
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MESSAGE_TYPES", function() { return MESSAGE_TYPES; });
|
|
10209
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SUBSCRIPTION_STATUS", function() { return SUBSCRIPTION_STATUS; });
|
|
10210
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SOCKET_STATUS", function() { return SOCKET_STATUS; });
|
|
10211
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMPLIFY_SYMBOL", function() { return AMPLIFY_SYMBOL; });
|
|
10212
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AWS_APPSYNC_REALTIME_HEADERS", function() { return AWS_APPSYNC_REALTIME_HEADERS; });
|
|
10213
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_INIT_TIMEOUT", function() { return CONNECTION_INIT_TIMEOUT; });
|
|
10214
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "START_ACK_TIMEOUT", function() { return START_ACK_TIMEOUT; });
|
|
10215
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_TIMEOUT; });
|
|
10216
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT; });
|
|
10217
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RECONNECT_DELAY", function() { return RECONNECT_DELAY; });
|
|
10218
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RECONNECT_INTERVAL", function() { return RECONNECT_INTERVAL; });
|
|
10219
|
+
var MAX_DELAY_MS = 5000;
|
|
10220
|
+
var NON_RETRYABLE_CODES = [400, 401, 403];
|
|
10221
|
+
var CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
|
|
10222
|
+
var MESSAGE_TYPES;
|
|
10223
|
+
|
|
10224
|
+
(function (MESSAGE_TYPES) {
|
|
10225
|
+
/**
|
|
10226
|
+
* Client -> Server message.
|
|
10227
|
+
* This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
|
|
10228
|
+
*/
|
|
10229
|
+
MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
|
|
10230
|
+
/**
|
|
10231
|
+
* Server -> Client message
|
|
10232
|
+
* This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
|
|
10233
|
+
*/
|
|
10234
|
+
|
|
10235
|
+
MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
|
|
10236
|
+
/**
|
|
10237
|
+
* Server -> Client message.
|
|
10238
|
+
* This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
|
|
10239
|
+
*/
|
|
10240
|
+
|
|
10241
|
+
MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
|
|
10242
|
+
/**
|
|
10243
|
+
* Client -> Server message.
|
|
10244
|
+
* This message type is for register subscriptions with AWS AppSync RealTime
|
|
10245
|
+
*/
|
|
10246
|
+
|
|
10247
|
+
MESSAGE_TYPES["GQL_START"] = "start";
|
|
10248
|
+
/**
|
|
10249
|
+
* Server -> Client message.
|
|
10250
|
+
* This message type is for the ack response from AWS AppSync RealTime for GQL_START message
|
|
10251
|
+
*/
|
|
10252
|
+
|
|
10253
|
+
MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
|
|
10254
|
+
/**
|
|
10255
|
+
* Server -> Client message.
|
|
10256
|
+
* This message type is for subscription message from AWS AppSync RealTime
|
|
10257
|
+
*/
|
|
10258
|
+
|
|
10259
|
+
MESSAGE_TYPES["GQL_DATA"] = "data";
|
|
10260
|
+
/**
|
|
10261
|
+
* Server -> Client message.
|
|
10262
|
+
* This message type helps the client to know is still receiving messages from AWS AppSync RealTime
|
|
10263
|
+
*/
|
|
10264
|
+
|
|
10265
|
+
MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
|
|
10266
|
+
/**
|
|
10267
|
+
* Client -> Server message.
|
|
10268
|
+
* This message type is for unregister subscriptions with AWS AppSync RealTime
|
|
10269
|
+
*/
|
|
10270
|
+
|
|
10271
|
+
MESSAGE_TYPES["GQL_STOP"] = "stop";
|
|
10272
|
+
/**
|
|
10273
|
+
* Server -> Client message.
|
|
10274
|
+
* This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
|
|
10275
|
+
*/
|
|
10276
|
+
|
|
10277
|
+
MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
|
|
10278
|
+
/**
|
|
10279
|
+
* Server -> Client message.
|
|
10280
|
+
* This message type is for sending error messages from AWS AppSync RealTime to the client
|
|
10281
|
+
*/
|
|
10282
|
+
|
|
10283
|
+
MESSAGE_TYPES["GQL_ERROR"] = "error";
|
|
10284
|
+
})(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
|
|
10285
|
+
|
|
10286
|
+
var SUBSCRIPTION_STATUS;
|
|
10287
|
+
|
|
10288
|
+
(function (SUBSCRIPTION_STATUS) {
|
|
10289
|
+
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
|
|
10290
|
+
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
|
|
10291
|
+
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
|
|
10292
|
+
})(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
|
|
10293
|
+
|
|
10294
|
+
var SOCKET_STATUS;
|
|
10295
|
+
|
|
10296
|
+
(function (SOCKET_STATUS) {
|
|
10297
|
+
SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
|
|
10298
|
+
SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
|
|
10299
|
+
SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
|
|
10300
|
+
})(SOCKET_STATUS || (SOCKET_STATUS = {}));
|
|
10301
|
+
|
|
10302
|
+
var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
|
|
10303
|
+
var AWS_APPSYNC_REALTIME_HEADERS = {
|
|
10304
|
+
accept: 'application/json, text/javascript',
|
|
10305
|
+
'content-encoding': 'amz-1.0',
|
|
10306
|
+
'content-type': 'application/json; charset=UTF-8'
|
|
10307
|
+
};
|
|
10308
|
+
/**
|
|
10309
|
+
* Time in milleseconds to wait for GQL_CONNECTION_INIT message
|
|
10310
|
+
*/
|
|
10311
|
+
|
|
10312
|
+
var CONNECTION_INIT_TIMEOUT = 15000;
|
|
10313
|
+
/**
|
|
10314
|
+
* Time in milleseconds to wait for GQL_START_ACK message
|
|
10315
|
+
*/
|
|
10316
|
+
|
|
10317
|
+
var START_ACK_TIMEOUT = 15000;
|
|
10318
|
+
/**
|
|
10319
|
+
* Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
|
|
10320
|
+
*/
|
|
10321
|
+
|
|
10322
|
+
var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
|
|
10323
|
+
/**
|
|
10324
|
+
* Default Time in milleseconds to alert for missed GQL_CONNECTION_KEEP_ALIVE message
|
|
10325
|
+
*/
|
|
10326
|
+
|
|
10327
|
+
var DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = 65 * 1000;
|
|
10328
|
+
/**
|
|
10329
|
+
* Default delay time in milleseconds between when reconnect is triggered vs when it is attempted
|
|
10330
|
+
*/
|
|
10331
|
+
|
|
10332
|
+
var RECONNECT_DELAY = 5 * 1000;
|
|
10333
|
+
/**
|
|
10334
|
+
* Default interval time in milleseconds between when reconnect is re-attempted
|
|
10335
|
+
*/
|
|
10336
|
+
|
|
10337
|
+
var RECONNECT_INTERVAL = 60 * 1000;
|
|
10338
|
+
|
|
10175
10339
|
/***/ }),
|
|
10176
10340
|
|
|
10177
10341
|
/***/ "./lib-esm/Providers/index.js":
|
|
@@ -10605,13 +10769,11 @@ _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Amplify"].register(PubSub);
|
|
|
10605
10769
|
/*!**************************!*\
|
|
10606
10770
|
!*** ./lib-esm/index.js ***!
|
|
10607
10771
|
\**************************/
|
|
10608
|
-
/*! exports provided: AbstractPubSubProvider, AWSAppSyncProvider, AWSAppSyncRealTimeProvider, AWSIoTProvider, mqttTopicMatch, MqttOverWSProvider, CONNECTION_STATE_CHANGE, ConnectionState,
|
|
10772
|
+
/*! exports provided: AbstractPubSubProvider, AWSAppSyncProvider, AWSAppSyncRealTimeProvider, AWSIoTProvider, mqttTopicMatch, MqttOverWSProvider, CONNECTION_STATE_CHANGE, ConnectionState, CONTROL_MSG, PubSub, default */
|
|
10609
10773
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
10610
10774
|
|
|
10611
10775
|
"use strict";
|
|
10612
10776
|
__webpack_require__.r(__webpack_exports__);
|
|
10613
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_STATE_CHANGE", function() { return CONNECTION_STATE_CHANGE; });
|
|
10614
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONTROL_MSG", function() { return CONTROL_MSG; });
|
|
10615
10777
|
/* harmony import */ var _PubSub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PubSub */ "./lib-esm/PubSub.js");
|
|
10616
10778
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PubSub", function() { return _PubSub__WEBPACK_IMPORTED_MODULE_0__["PubSub"]; });
|
|
10617
10779
|
|
|
@@ -10628,8 +10790,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
10628
10790
|
|
|
10629
10791
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MqttOverWSProvider", function() { return _Providers__WEBPACK_IMPORTED_MODULE_1__["MqttOverWSProvider"]; });
|
|
10630
10792
|
|
|
10631
|
-
/* harmony import */ var
|
|
10632
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "
|
|
10793
|
+
/* harmony import */ var _Providers_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Providers/constants */ "./lib-esm/Providers/constants.js");
|
|
10794
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_STATE_CHANGE", function() { return _Providers_constants__WEBPACK_IMPORTED_MODULE_2__["CONNECTION_STATE_CHANGE"]; });
|
|
10795
|
+
|
|
10796
|
+
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./types */ "./lib-esm/types/index.js");
|
|
10797
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConnectionState", function() { return _types__WEBPACK_IMPORTED_MODULE_3__["ConnectionState"]; });
|
|
10798
|
+
|
|
10799
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CONTROL_MSG", function() { return _types__WEBPACK_IMPORTED_MODULE_3__["CONTROL_MSG"]; });
|
|
10633
10800
|
|
|
10634
10801
|
/*
|
|
10635
10802
|
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
@@ -10645,17 +10812,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
10645
10812
|
*/
|
|
10646
10813
|
|
|
10647
10814
|
|
|
10648
|
-
var CONTROL_MSG;
|
|
10649
|
-
|
|
10650
|
-
(function (CONTROL_MSG) {
|
|
10651
|
-
CONTROL_MSG["CONNECTION_CLOSED"] = "Connection closed";
|
|
10652
|
-
CONTROL_MSG["CONNECTION_FAILED"] = "Connection failed";
|
|
10653
|
-
CONTROL_MSG["REALTIME_SUBSCRIPTION_INIT_ERROR"] = "AppSync Realtime subscription init error";
|
|
10654
|
-
CONTROL_MSG["SUBSCRIPTION_ACK"] = "Subscription ack";
|
|
10655
|
-
CONTROL_MSG["TIMEOUT_DISCONNECT"] = "Timeout disconnect";
|
|
10656
|
-
})(CONTROL_MSG || (CONTROL_MSG = {}));
|
|
10657
10815
|
|
|
10658
|
-
var CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
|
|
10659
10816
|
|
|
10660
10817
|
|
|
10661
10818
|
/**
|
|
@@ -10666,17 +10823,41 @@ var CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
|
|
|
10666
10823
|
|
|
10667
10824
|
/***/ }),
|
|
10668
10825
|
|
|
10669
|
-
/***/ "./lib-esm/types/
|
|
10670
|
-
|
|
10671
|
-
!*** ./lib-esm/types/
|
|
10672
|
-
|
|
10673
|
-
/*! exports provided: ConnectionState */
|
|
10826
|
+
/***/ "./lib-esm/types/PubSub.js":
|
|
10827
|
+
/*!*********************************!*\
|
|
10828
|
+
!*** ./lib-esm/types/PubSub.js ***!
|
|
10829
|
+
\*********************************/
|
|
10830
|
+
/*! exports provided: CONTROL_MSG, ConnectionState */
|
|
10674
10831
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
10675
10832
|
|
|
10676
10833
|
"use strict";
|
|
10677
10834
|
__webpack_require__.r(__webpack_exports__);
|
|
10835
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONTROL_MSG", function() { return CONTROL_MSG; });
|
|
10678
10836
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConnectionState", function() { return ConnectionState; });
|
|
10837
|
+
/*
|
|
10838
|
+
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
10839
|
+
*
|
|
10840
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
10841
|
+
* the License. A copy of the License is located at
|
|
10842
|
+
*
|
|
10843
|
+
* http://aws.amazon.com/apache2.0/
|
|
10844
|
+
*
|
|
10845
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
10846
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
10847
|
+
* and limitations under the License.
|
|
10848
|
+
*/
|
|
10849
|
+
var CONTROL_MSG;
|
|
10850
|
+
|
|
10851
|
+
(function (CONTROL_MSG) {
|
|
10852
|
+
CONTROL_MSG["CONNECTION_CLOSED"] = "Connection closed";
|
|
10853
|
+
CONTROL_MSG["CONNECTION_FAILED"] = "Connection failed";
|
|
10854
|
+
CONTROL_MSG["REALTIME_SUBSCRIPTION_INIT_ERROR"] = "AppSync Realtime subscription init error";
|
|
10855
|
+
CONTROL_MSG["SUBSCRIPTION_ACK"] = "Subscription ack";
|
|
10856
|
+
CONTROL_MSG["TIMEOUT_DISCONNECT"] = "Timeout disconnect";
|
|
10857
|
+
})(CONTROL_MSG || (CONTROL_MSG = {}));
|
|
10679
10858
|
/** @enum {string} */
|
|
10859
|
+
|
|
10860
|
+
|
|
10680
10861
|
var ConnectionState;
|
|
10681
10862
|
|
|
10682
10863
|
(function (ConnectionState) {
|
|
@@ -10721,6 +10902,24 @@ var ConnectionState;
|
|
|
10721
10902
|
ConnectionState["ConnectedPendingKeepAlive"] = "ConnectedPendingKeepAlive";
|
|
10722
10903
|
})(ConnectionState || (ConnectionState = {}));
|
|
10723
10904
|
|
|
10905
|
+
/***/ }),
|
|
10906
|
+
|
|
10907
|
+
/***/ "./lib-esm/types/index.js":
|
|
10908
|
+
/*!********************************!*\
|
|
10909
|
+
!*** ./lib-esm/types/index.js ***!
|
|
10910
|
+
\********************************/
|
|
10911
|
+
/*! exports provided: CONTROL_MSG, ConnectionState */
|
|
10912
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
10913
|
+
|
|
10914
|
+
"use strict";
|
|
10915
|
+
__webpack_require__.r(__webpack_exports__);
|
|
10916
|
+
/* harmony import */ var _PubSub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PubSub */ "./lib-esm/types/PubSub.js");
|
|
10917
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CONTROL_MSG", function() { return _PubSub__WEBPACK_IMPORTED_MODULE_0__["CONTROL_MSG"]; });
|
|
10918
|
+
|
|
10919
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConnectionState", function() { return _PubSub__WEBPACK_IMPORTED_MODULE_0__["ConnectionState"]; });
|
|
10920
|
+
|
|
10921
|
+
|
|
10922
|
+
|
|
10724
10923
|
/***/ }),
|
|
10725
10924
|
|
|
10726
10925
|
/***/ "./lib-esm/utils/ConnectionStateMonitor.js":
|
|
@@ -10734,10 +10933,9 @@ var ConnectionState;
|
|
|
10734
10933
|
__webpack_require__.r(__webpack_exports__);
|
|
10735
10934
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_CHANGE", function() { return CONNECTION_CHANGE; });
|
|
10736
10935
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConnectionStateMonitor", function() { return ConnectionStateMonitor; });
|
|
10737
|
-
/* harmony import */ var
|
|
10738
|
-
/* harmony import */ var
|
|
10739
|
-
/* harmony import */ var
|
|
10740
|
-
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../index */ "./lib-esm/index.js");
|
|
10936
|
+
/* harmony import */ var zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! zen-observable-ts */ "../../node_modules/zen-observable-ts/lib/bundle.esm.js");
|
|
10937
|
+
/* harmony import */ var _types_PubSub__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../types/PubSub */ "./lib-esm/types/PubSub.js");
|
|
10938
|
+
/* harmony import */ var _ReachabilityMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ReachabilityMonitor */ "./lib-esm/utils/ReachabilityMonitor/index.js");
|
|
10741
10939
|
/*
|
|
10742
10940
|
* Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
10743
10941
|
*
|
|
@@ -10813,8 +11011,18 @@ function () {
|
|
|
10813
11011
|
connectionState: 'disconnected',
|
|
10814
11012
|
intendedConnectionState: 'disconnected',
|
|
10815
11013
|
keepAliveState: 'healthy'
|
|
10816
|
-
};
|
|
10817
|
-
|
|
11014
|
+
}; // Attempt to update the state with the current actual network state
|
|
11015
|
+
|
|
11016
|
+
this._initialNetworkStateSubscription = Object(_ReachabilityMonitor__WEBPACK_IMPORTED_MODULE_2__["ReachabilityMonitor"])().subscribe(function (_a) {
|
|
11017
|
+
var online = _a.online;
|
|
11018
|
+
|
|
11019
|
+
var _b;
|
|
11020
|
+
|
|
11021
|
+
_this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);
|
|
11022
|
+
|
|
11023
|
+
(_b = _this._initialNetworkStateSubscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
|
|
11024
|
+
});
|
|
11025
|
+
this._linkedConnectionStateObservable = new zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__["default"](function (connectionStateObserver) {
|
|
10818
11026
|
connectionStateObserver.next(_this._linkedConnectionState);
|
|
10819
11027
|
_this._linkedConnectionStateObserver = connectionStateObserver;
|
|
10820
11028
|
});
|
|
@@ -10825,11 +11033,15 @@ function () {
|
|
|
10825
11033
|
|
|
10826
11034
|
|
|
10827
11035
|
ConnectionStateMonitor.prototype.enableNetworkMonitoring = function () {
|
|
10828
|
-
var _this = this;
|
|
11036
|
+
var _this = this;
|
|
11037
|
+
|
|
11038
|
+
var _a; // If no initial network state was discovered, stop trying
|
|
10829
11039
|
|
|
10830
11040
|
|
|
11041
|
+
(_a = this._initialNetworkStateSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe(); // Maintain the network state based on the reachability monitor
|
|
11042
|
+
|
|
10831
11043
|
if (this._networkMonitoringSubscription === undefined) {
|
|
10832
|
-
this._networkMonitoringSubscription =
|
|
11044
|
+
this._networkMonitoringSubscription = Object(_ReachabilityMonitor__WEBPACK_IMPORTED_MODULE_2__["ReachabilityMonitor"])().subscribe(function (_a) {
|
|
10833
11045
|
var online = _a.online;
|
|
10834
11046
|
|
|
10835
11047
|
_this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);
|
|
@@ -10902,15 +11114,15 @@ function () {
|
|
|
10902
11114
|
networkState = _a.networkState,
|
|
10903
11115
|
intendedConnectionState = _a.intendedConnectionState,
|
|
10904
11116
|
keepAliveState = _a.keepAliveState;
|
|
10905
|
-
if (connectionState === 'connected' && networkState === 'disconnected') return
|
|
10906
|
-
if (connectionState === 'connected' && intendedConnectionState === 'disconnected') return
|
|
10907
|
-
if (connectionState === 'disconnected' && intendedConnectionState === 'connected' && networkState === 'disconnected') return
|
|
10908
|
-
if (connectionState === 'disconnected' && intendedConnectionState === 'connected') return
|
|
10909
|
-
if (connectionState === 'connected' && keepAliveState === 'unhealthy') return
|
|
10910
|
-
|
|
10911
|
-
if (connectionState === 'connecting') return
|
|
10912
|
-
if (connectionState === 'disconnected') return
|
|
10913
|
-
return
|
|
11117
|
+
if (connectionState === 'connected' && networkState === 'disconnected') return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectedPendingNetwork;
|
|
11118
|
+
if (connectionState === 'connected' && intendedConnectionState === 'disconnected') return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectedPendingDisconnect;
|
|
11119
|
+
if (connectionState === 'disconnected' && intendedConnectionState === 'connected' && networkState === 'disconnected') return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectionDisruptedPendingNetwork;
|
|
11120
|
+
if (connectionState === 'disconnected' && intendedConnectionState === 'connected') return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectionDisrupted;
|
|
11121
|
+
if (connectionState === 'connected' && keepAliveState === 'unhealthy') return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectedPendingKeepAlive; // All remaining states directly correspond to the connection state
|
|
11122
|
+
|
|
11123
|
+
if (connectionState === 'connecting') return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].Connecting;
|
|
11124
|
+
if (connectionState === 'disconnected') return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].Disconnected;
|
|
11125
|
+
return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].Connected;
|
|
10914
11126
|
};
|
|
10915
11127
|
|
|
10916
11128
|
return ConnectionStateMonitor;
|
|
@@ -10918,6 +11130,129 @@ function () {
|
|
|
10918
11130
|
|
|
10919
11131
|
|
|
10920
11132
|
|
|
11133
|
+
/***/ }),
|
|
11134
|
+
|
|
11135
|
+
/***/ "./lib-esm/utils/ReachabilityMonitor/index.js":
|
|
11136
|
+
/*!****************************************************!*\
|
|
11137
|
+
!*** ./lib-esm/utils/ReachabilityMonitor/index.js ***!
|
|
11138
|
+
\****************************************************/
|
|
11139
|
+
/*! exports provided: ReachabilityMonitor */
|
|
11140
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
11141
|
+
|
|
11142
|
+
"use strict";
|
|
11143
|
+
__webpack_require__.r(__webpack_exports__);
|
|
11144
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReachabilityMonitor", function() { return ReachabilityMonitor; });
|
|
11145
|
+
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
|
|
11146
|
+
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__);
|
|
11147
|
+
|
|
11148
|
+
var ReachabilityMonitor = function ReachabilityMonitor() {
|
|
11149
|
+
return new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Reachability"]().networkMonitor();
|
|
11150
|
+
};
|
|
11151
|
+
|
|
11152
|
+
/***/ }),
|
|
11153
|
+
|
|
11154
|
+
/***/ "./lib-esm/utils/ReconnectionMonitor.js":
|
|
11155
|
+
/*!**********************************************!*\
|
|
11156
|
+
!*** ./lib-esm/utils/ReconnectionMonitor.js ***!
|
|
11157
|
+
\**********************************************/
|
|
11158
|
+
/*! exports provided: ReconnectEvent, ReconnectionMonitor */
|
|
11159
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
11160
|
+
|
|
11161
|
+
"use strict";
|
|
11162
|
+
__webpack_require__.r(__webpack_exports__);
|
|
11163
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReconnectEvent", function() { return ReconnectEvent; });
|
|
11164
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReconnectionMonitor", function() { return ReconnectionMonitor; });
|
|
11165
|
+
/* harmony import */ var _Providers_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Providers/constants */ "./lib-esm/Providers/constants.js");
|
|
11166
|
+
|
|
11167
|
+
var ReconnectEvent;
|
|
11168
|
+
|
|
11169
|
+
(function (ReconnectEvent) {
|
|
11170
|
+
ReconnectEvent["START_RECONNECT"] = "START_RECONNECT";
|
|
11171
|
+
ReconnectEvent["HALT_RECONNECT"] = "HALT_RECONNECT";
|
|
11172
|
+
})(ReconnectEvent || (ReconnectEvent = {}));
|
|
11173
|
+
/**
|
|
11174
|
+
* Captures the reconnect event logic used to determine when to reconnect to PubSub providers.
|
|
11175
|
+
* Reconnnect attempts are delayed by 5 seconds to let the interface settle.
|
|
11176
|
+
* Attempting to reconnect only once creates unrecoverable states when the network state isn't
|
|
11177
|
+
* supported by the browser, so this keeps retrying every minute until halted.
|
|
11178
|
+
*/
|
|
11179
|
+
|
|
11180
|
+
|
|
11181
|
+
var ReconnectionMonitor =
|
|
11182
|
+
/** @class */
|
|
11183
|
+
function () {
|
|
11184
|
+
function ReconnectionMonitor() {
|
|
11185
|
+
this.reconnectObservers = [];
|
|
11186
|
+
}
|
|
11187
|
+
/**
|
|
11188
|
+
* Add reconnect observer to the list of observers to alert on reconnect
|
|
11189
|
+
*/
|
|
11190
|
+
|
|
11191
|
+
|
|
11192
|
+
ReconnectionMonitor.prototype.addObserver = function (reconnectObserver) {
|
|
11193
|
+
this.reconnectObservers.push(reconnectObserver);
|
|
11194
|
+
};
|
|
11195
|
+
/**
|
|
11196
|
+
* Given a reconnect event, start the appropriate behavior
|
|
11197
|
+
*/
|
|
11198
|
+
|
|
11199
|
+
|
|
11200
|
+
ReconnectionMonitor.prototype.record = function (event) {
|
|
11201
|
+
var _this = this;
|
|
11202
|
+
|
|
11203
|
+
if (event === ReconnectEvent.START_RECONNECT) {
|
|
11204
|
+
// If the reconnection hasn't been started
|
|
11205
|
+
if (this.reconnectSetTimeoutId === undefined && this.reconnectIntervalId === undefined) {
|
|
11206
|
+
this.reconnectSetTimeoutId = setTimeout(function () {
|
|
11207
|
+
// Reconnect now
|
|
11208
|
+
_this._triggerReconnect(); // Retry reconnect every periodically until it works
|
|
11209
|
+
|
|
11210
|
+
|
|
11211
|
+
_this.reconnectIntervalId = setInterval(function () {
|
|
11212
|
+
_this._triggerReconnect();
|
|
11213
|
+
}, _Providers_constants__WEBPACK_IMPORTED_MODULE_0__["RECONNECT_INTERVAL"]);
|
|
11214
|
+
}, _Providers_constants__WEBPACK_IMPORTED_MODULE_0__["RECONNECT_DELAY"]);
|
|
11215
|
+
}
|
|
11216
|
+
}
|
|
11217
|
+
|
|
11218
|
+
if (event === ReconnectEvent.HALT_RECONNECT) {
|
|
11219
|
+
if (this.reconnectIntervalId) {
|
|
11220
|
+
clearInterval(this.reconnectIntervalId);
|
|
11221
|
+
this.reconnectIntervalId = undefined;
|
|
11222
|
+
}
|
|
11223
|
+
|
|
11224
|
+
if (this.reconnectSetTimeoutId) {
|
|
11225
|
+
clearTimeout(this.reconnectSetTimeoutId);
|
|
11226
|
+
this.reconnectSetTimeoutId = undefined;
|
|
11227
|
+
}
|
|
11228
|
+
}
|
|
11229
|
+
};
|
|
11230
|
+
/**
|
|
11231
|
+
* Complete all reconnect observers
|
|
11232
|
+
*/
|
|
11233
|
+
|
|
11234
|
+
|
|
11235
|
+
ReconnectionMonitor.prototype.close = function () {
|
|
11236
|
+
this.reconnectObservers.forEach(function (reconnectObserver) {
|
|
11237
|
+
var _a;
|
|
11238
|
+
|
|
11239
|
+
(_a = reconnectObserver.complete) === null || _a === void 0 ? void 0 : _a.call(reconnectObserver);
|
|
11240
|
+
});
|
|
11241
|
+
};
|
|
11242
|
+
|
|
11243
|
+
ReconnectionMonitor.prototype._triggerReconnect = function () {
|
|
11244
|
+
this.reconnectObservers.forEach(function (reconnectObserver) {
|
|
11245
|
+
var _a;
|
|
11246
|
+
|
|
11247
|
+
(_a = reconnectObserver.next) === null || _a === void 0 ? void 0 : _a.call(reconnectObserver);
|
|
11248
|
+
});
|
|
11249
|
+
};
|
|
11250
|
+
|
|
11251
|
+
return ReconnectionMonitor;
|
|
11252
|
+
}();
|
|
11253
|
+
|
|
11254
|
+
|
|
11255
|
+
|
|
10921
11256
|
/***/ }),
|
|
10922
11257
|
|
|
10923
11258
|
/***/ "@aws-amplify/auth":
|