@aws-amplify/api 4.0.48 → 4.0.49-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 +56 -0
- package/dist/aws-amplify-api.js +711 -376
- package/dist/aws-amplify-api.js.map +1 -1
- package/dist/aws-amplify-api.min.js +3 -3
- package/dist/aws-amplify-api.min.js.map +1 -1
- package/package.json +4 -4
package/dist/aws-amplify-api.js
CHANGED
|
@@ -10246,8 +10246,8 @@ function () {
|
|
|
10246
10246
|
} : _c;
|
|
10247
10247
|
var authenticationType = defaultAuthenticationType || aws_appsync_authenticationType || 'AWS_IAM';
|
|
10248
10248
|
|
|
10249
|
-
if (_aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_2__["
|
|
10250
|
-
return _aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_2__["
|
|
10249
|
+
if (_aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_2__["PubSub"] && typeof _aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_2__["PubSub"].subscribe === 'function') {
|
|
10250
|
+
return _aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_2__["PubSub"].subscribe('', {
|
|
10251
10251
|
provider: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER"],
|
|
10252
10252
|
appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
|
|
10253
10253
|
authenticationType: authenticationType,
|
|
@@ -12135,137 +12135,6 @@ function (_super) {
|
|
|
12135
12135
|
|
|
12136
12136
|
|
|
12137
12137
|
|
|
12138
|
-
/***/ }),
|
|
12139
|
-
|
|
12140
|
-
/***/ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js":
|
|
12141
|
-
/*!***************************************************************************!*\
|
|
12142
|
-
!*** ../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js ***!
|
|
12143
|
-
\***************************************************************************/
|
|
12144
|
-
/*! 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 */
|
|
12145
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
12146
|
-
|
|
12147
|
-
"use strict";
|
|
12148
|
-
__webpack_require__.r(__webpack_exports__);
|
|
12149
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MAX_DELAY_MS", function() { return MAX_DELAY_MS; });
|
|
12150
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NON_RETRYABLE_CODES", function() { return NON_RETRYABLE_CODES; });
|
|
12151
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MESSAGE_TYPES", function() { return MESSAGE_TYPES; });
|
|
12152
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SUBSCRIPTION_STATUS", function() { return SUBSCRIPTION_STATUS; });
|
|
12153
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SOCKET_STATUS", function() { return SOCKET_STATUS; });
|
|
12154
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMPLIFY_SYMBOL", function() { return AMPLIFY_SYMBOL; });
|
|
12155
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AWS_APPSYNC_REALTIME_HEADERS", function() { return AWS_APPSYNC_REALTIME_HEADERS; });
|
|
12156
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_INIT_TIMEOUT", function() { return CONNECTION_INIT_TIMEOUT; });
|
|
12157
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "START_ACK_TIMEOUT", function() { return START_ACK_TIMEOUT; });
|
|
12158
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_TIMEOUT; });
|
|
12159
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT; });
|
|
12160
|
-
var MAX_DELAY_MS = 5000;
|
|
12161
|
-
var NON_RETRYABLE_CODES = [400, 401, 403];
|
|
12162
|
-
var MESSAGE_TYPES;
|
|
12163
|
-
|
|
12164
|
-
(function (MESSAGE_TYPES) {
|
|
12165
|
-
/**
|
|
12166
|
-
* Client -> Server message.
|
|
12167
|
-
* This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
|
|
12168
|
-
*/
|
|
12169
|
-
MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
|
|
12170
|
-
/**
|
|
12171
|
-
* Server -> Client message
|
|
12172
|
-
* This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
|
|
12173
|
-
*/
|
|
12174
|
-
|
|
12175
|
-
MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
|
|
12176
|
-
/**
|
|
12177
|
-
* Server -> Client message.
|
|
12178
|
-
* This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
|
|
12179
|
-
*/
|
|
12180
|
-
|
|
12181
|
-
MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
|
|
12182
|
-
/**
|
|
12183
|
-
* Client -> Server message.
|
|
12184
|
-
* This message type is for register subscriptions with AWS AppSync RealTime
|
|
12185
|
-
*/
|
|
12186
|
-
|
|
12187
|
-
MESSAGE_TYPES["GQL_START"] = "start";
|
|
12188
|
-
/**
|
|
12189
|
-
* Server -> Client message.
|
|
12190
|
-
* This message type is for the ack response from AWS AppSync RealTime for GQL_START message
|
|
12191
|
-
*/
|
|
12192
|
-
|
|
12193
|
-
MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
|
|
12194
|
-
/**
|
|
12195
|
-
* Server -> Client message.
|
|
12196
|
-
* This message type is for subscription message from AWS AppSync RealTime
|
|
12197
|
-
*/
|
|
12198
|
-
|
|
12199
|
-
MESSAGE_TYPES["GQL_DATA"] = "data";
|
|
12200
|
-
/**
|
|
12201
|
-
* Server -> Client message.
|
|
12202
|
-
* This message type helps the client to know is still receiving messages from AWS AppSync RealTime
|
|
12203
|
-
*/
|
|
12204
|
-
|
|
12205
|
-
MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
|
|
12206
|
-
/**
|
|
12207
|
-
* Client -> Server message.
|
|
12208
|
-
* This message type is for unregister subscriptions with AWS AppSync RealTime
|
|
12209
|
-
*/
|
|
12210
|
-
|
|
12211
|
-
MESSAGE_TYPES["GQL_STOP"] = "stop";
|
|
12212
|
-
/**
|
|
12213
|
-
* Server -> Client message.
|
|
12214
|
-
* This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
|
|
12215
|
-
*/
|
|
12216
|
-
|
|
12217
|
-
MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
|
|
12218
|
-
/**
|
|
12219
|
-
* Server -> Client message.
|
|
12220
|
-
* This message type is for sending error messages from AWS AppSync RealTime to the client
|
|
12221
|
-
*/
|
|
12222
|
-
|
|
12223
|
-
MESSAGE_TYPES["GQL_ERROR"] = "error";
|
|
12224
|
-
})(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
|
|
12225
|
-
|
|
12226
|
-
var SUBSCRIPTION_STATUS;
|
|
12227
|
-
|
|
12228
|
-
(function (SUBSCRIPTION_STATUS) {
|
|
12229
|
-
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
|
|
12230
|
-
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
|
|
12231
|
-
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
|
|
12232
|
-
})(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
|
|
12233
|
-
|
|
12234
|
-
var SOCKET_STATUS;
|
|
12235
|
-
|
|
12236
|
-
(function (SOCKET_STATUS) {
|
|
12237
|
-
SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
|
|
12238
|
-
SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
|
|
12239
|
-
SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
|
|
12240
|
-
})(SOCKET_STATUS || (SOCKET_STATUS = {}));
|
|
12241
|
-
|
|
12242
|
-
var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
|
|
12243
|
-
var AWS_APPSYNC_REALTIME_HEADERS = {
|
|
12244
|
-
accept: 'application/json, text/javascript',
|
|
12245
|
-
'content-encoding': 'amz-1.0',
|
|
12246
|
-
'content-type': 'application/json; charset=UTF-8'
|
|
12247
|
-
};
|
|
12248
|
-
/**
|
|
12249
|
-
* Time in milleseconds to wait for GQL_CONNECTION_INIT message
|
|
12250
|
-
*/
|
|
12251
|
-
|
|
12252
|
-
var CONNECTION_INIT_TIMEOUT = 15000;
|
|
12253
|
-
/**
|
|
12254
|
-
* Time in milleseconds to wait for GQL_START_ACK message
|
|
12255
|
-
*/
|
|
12256
|
-
|
|
12257
|
-
var START_ACK_TIMEOUT = 15000;
|
|
12258
|
-
/**
|
|
12259
|
-
* Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
|
|
12260
|
-
*/
|
|
12261
|
-
|
|
12262
|
-
var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
|
|
12263
|
-
/**
|
|
12264
|
-
* Default Time in milleseconds to alert for missed GQL_CONNECTION_KEEP_ALIVE message
|
|
12265
|
-
*/
|
|
12266
|
-
|
|
12267
|
-
var DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = 65 * 1000;
|
|
12268
|
-
|
|
12269
12138
|
/***/ }),
|
|
12270
12139
|
|
|
12271
12140
|
/***/ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js":
|
|
@@ -12294,9 +12163,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
12294
12163
|
/* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
|
|
12295
12164
|
/* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7__);
|
|
12296
12165
|
/* harmony import */ var _PubSubProvider__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PubSubProvider */ "../pubsub/lib-esm/Providers/PubSubProvider.js");
|
|
12297
|
-
/* harmony import */ var
|
|
12298
|
-
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*!
|
|
12166
|
+
/* harmony import */ var _types_PubSub__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../types/PubSub */ "../pubsub/lib-esm/types/PubSub.js");
|
|
12167
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../constants */ "../pubsub/lib-esm/Providers/constants.js");
|
|
12299
12168
|
/* harmony import */ var _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../utils/ConnectionStateMonitor */ "../pubsub/lib-esm/utils/ConnectionStateMonitor.js");
|
|
12169
|
+
/* harmony import */ var _utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../utils/ReconnectionMonitor */ "../pubsub/lib-esm/utils/ReconnectionMonitor.js");
|
|
12300
12170
|
var __extends = undefined && undefined.__extends || function () {
|
|
12301
12171
|
var _extendStatics = function extendStatics(d, b) {
|
|
12302
12172
|
_extendStatics = Object.setPrototypeOf || {
|
|
@@ -12534,6 +12404,7 @@ var __read = undefined && undefined.__read || function (o, n) {
|
|
|
12534
12404
|
|
|
12535
12405
|
|
|
12536
12406
|
|
|
12407
|
+
|
|
12537
12408
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Logger"]('AWSAppSyncRealTimeProvider');
|
|
12538
12409
|
|
|
12539
12410
|
var dispatchApiEvent = function dispatchApiEvent(event, data, message) {
|
|
@@ -12563,17 +12434,42 @@ function (_super) {
|
|
|
12563
12434
|
_this.keepAliveTimeout = _constants__WEBPACK_IMPORTED_MODULE_10__["DEFAULT_KEEP_ALIVE_TIMEOUT"];
|
|
12564
12435
|
_this.subscriptionObserverMap = new Map();
|
|
12565
12436
|
_this.promiseArray = [];
|
|
12566
|
-
_this.connectionStateMonitor = new _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["ConnectionStateMonitor"]();
|
|
12437
|
+
_this.connectionStateMonitor = new _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["ConnectionStateMonitor"]();
|
|
12438
|
+
_this.reconnectionMonitor = new _utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_12__["ReconnectionMonitor"](); // Monitor the connection state and pass changes along to Hub
|
|
12567
12439
|
|
|
12568
|
-
_this.connectionStateMonitor.connectionStateObservable.subscribe(function (
|
|
12569
|
-
dispatchApiEvent(
|
|
12440
|
+
_this.connectionStateMonitorSubscription = _this.connectionStateMonitor.connectionStateObservable.subscribe(function (connectionState) {
|
|
12441
|
+
dispatchApiEvent(_constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_STATE_CHANGE"], {
|
|
12570
12442
|
provider: _this,
|
|
12571
|
-
connectionState:
|
|
12572
|
-
}, "Connection state is " +
|
|
12573
|
-
|
|
12443
|
+
connectionState: connectionState
|
|
12444
|
+
}, "Connection state is " + connectionState);
|
|
12445
|
+
_this.connectionState = connectionState; // Trigger START_RECONNECT when the connection is disrupted
|
|
12574
12446
|
|
|
12447
|
+
if (connectionState === _types_PubSub__WEBPACK_IMPORTED_MODULE_9__["ConnectionState"].ConnectionDisrupted) {
|
|
12448
|
+
_this.reconnectionMonitor.record(_utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_12__["ReconnectEvent"].START_RECONNECT);
|
|
12449
|
+
} // Trigger HALT_RECONNECT to halt reconnection attempts when the state is anything other than
|
|
12450
|
+
// ConnectionDisrupted or Connecting
|
|
12451
|
+
|
|
12452
|
+
|
|
12453
|
+
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)) {
|
|
12454
|
+
_this.reconnectionMonitor.record(_utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_12__["ReconnectEvent"].HALT_RECONNECT);
|
|
12455
|
+
}
|
|
12456
|
+
});
|
|
12575
12457
|
return _this;
|
|
12576
12458
|
}
|
|
12459
|
+
/**
|
|
12460
|
+
* Mark the socket closed and release all active listeners
|
|
12461
|
+
*/
|
|
12462
|
+
|
|
12463
|
+
|
|
12464
|
+
AWSAppSyncRealTimeProvider.prototype.close = function () {
|
|
12465
|
+
// Mark the socket closed both in status and the connection monitor
|
|
12466
|
+
this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
|
|
12467
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CONNECTION_FAILED); // Turn off the subscription monitor Hub publishing
|
|
12468
|
+
|
|
12469
|
+
this.connectionStateMonitorSubscription.unsubscribe(); // Complete all reconnect observers
|
|
12470
|
+
|
|
12471
|
+
this.reconnectionMonitor.close();
|
|
12472
|
+
};
|
|
12577
12473
|
|
|
12578
12474
|
AWSAppSyncRealTimeProvider.prototype.getNewWebSocket = function (url, protocol) {
|
|
12579
12475
|
return new WebSocket(url, protocol);
|
|
@@ -12611,36 +12507,56 @@ function (_super) {
|
|
|
12611
12507
|
});
|
|
12612
12508
|
observer.complete();
|
|
12613
12509
|
} else {
|
|
12510
|
+
var subscriptionStartActive_1 = false;
|
|
12614
12511
|
var subscriptionId_1 = Object(uuid__WEBPACK_IMPORTED_MODULE_3__["v4"])();
|
|
12615
12512
|
|
|
12616
|
-
|
|
12617
|
-
|
|
12618
|
-
|
|
12619
|
-
subscriptionId: subscriptionId_1
|
|
12620
|
-
})["catch"](function (err) {
|
|
12621
|
-
observer.error({
|
|
12622
|
-
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].REALTIME_SUBSCRIPTION_INIT_ERROR + ": " + err))]
|
|
12623
|
-
});
|
|
12513
|
+
var startSubscription_1 = function startSubscription_1() {
|
|
12514
|
+
if (!subscriptionStartActive_1) {
|
|
12515
|
+
subscriptionStartActive_1 = true;
|
|
12624
12516
|
|
|
12625
|
-
|
|
12517
|
+
var startSubscriptionPromise = _this._startSubscriptionWithAWSAppSyncRealTime({
|
|
12518
|
+
options: options,
|
|
12519
|
+
observer: observer,
|
|
12520
|
+
subscriptionId: subscriptionId_1
|
|
12521
|
+
})["catch"](function (err) {
|
|
12522
|
+
logger.debug(_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].REALTIME_SUBSCRIPTION_INIT_ERROR + ": " + err);
|
|
12626
12523
|
|
|
12627
|
-
|
|
12628
|
-
|
|
12524
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
12525
|
+
});
|
|
12526
|
+
|
|
12527
|
+
startSubscriptionPromise["finally"](function () {
|
|
12528
|
+
subscriptionStartActive_1 = false;
|
|
12529
|
+
});
|
|
12530
|
+
}
|
|
12531
|
+
};
|
|
12629
12532
|
|
|
12533
|
+
var reconnectSubscription_1; // Add an observable to the reconnection list to manage reconnection for this subscription
|
|
12534
|
+
|
|
12535
|
+
reconnectSubscription_1 = new zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__["default"](function (observer) {
|
|
12536
|
+
_this.reconnectionMonitor.addObserver(observer);
|
|
12537
|
+
}).subscribe(function () {
|
|
12538
|
+
startSubscription_1();
|
|
12539
|
+
});
|
|
12540
|
+
startSubscription_1();
|
|
12630
12541
|
return function () {
|
|
12631
12542
|
return __awaiter(_this, void 0, void 0, function () {
|
|
12632
12543
|
var subscriptionState, err_1;
|
|
12633
12544
|
return __generator(this, function (_a) {
|
|
12634
12545
|
switch (_a.label) {
|
|
12635
12546
|
case 0:
|
|
12636
|
-
|
|
12547
|
+
// Cleanup reconnection subscription
|
|
12548
|
+
reconnectSubscription_1 === null || reconnectSubscription_1 === void 0 ? void 0 : reconnectSubscription_1.unsubscribe();
|
|
12549
|
+
_a.label = 1;
|
|
12550
|
+
|
|
12551
|
+
case 1:
|
|
12552
|
+
_a.trys.push([1, 3, 4, 5]); // Waiting that subscription has been connected before trying to unsubscribe
|
|
12637
12553
|
|
|
12638
12554
|
|
|
12639
12555
|
return [4
|
|
12640
12556
|
/*yield*/
|
|
12641
12557
|
, this._waitForSubscriptionToBeConnected(subscriptionId_1)];
|
|
12642
12558
|
|
|
12643
|
-
case
|
|
12559
|
+
case 2:
|
|
12644
12560
|
// Waiting that subscription has been connected before trying to unsubscribe
|
|
12645
12561
|
_a.sent();
|
|
12646
12562
|
|
|
@@ -12661,23 +12577,23 @@ function (_super) {
|
|
|
12661
12577
|
|
|
12662
12578
|
return [3
|
|
12663
12579
|
/*break*/
|
|
12664
|
-
,
|
|
12580
|
+
, 5];
|
|
12665
12581
|
|
|
12666
|
-
case
|
|
12582
|
+
case 3:
|
|
12667
12583
|
err_1 = _a.sent();
|
|
12668
12584
|
logger.debug("Error while unsubscribing " + err_1);
|
|
12669
12585
|
return [3
|
|
12670
12586
|
/*break*/
|
|
12671
|
-
,
|
|
12587
|
+
, 5];
|
|
12672
12588
|
|
|
12673
|
-
case
|
|
12589
|
+
case 4:
|
|
12674
12590
|
this._removeSubscriptionObserver(subscriptionId_1);
|
|
12675
12591
|
|
|
12676
12592
|
return [7
|
|
12677
12593
|
/*endfinally*/
|
|
12678
12594
|
];
|
|
12679
12595
|
|
|
12680
|
-
case
|
|
12596
|
+
case 5:
|
|
12681
12597
|
return [2
|
|
12682
12598
|
/*return*/
|
|
12683
12599
|
];
|
|
@@ -12702,21 +12618,21 @@ function (_super) {
|
|
|
12702
12618
|
observer = _a.observer,
|
|
12703
12619
|
subscriptionId = _a.subscriptionId;
|
|
12704
12620
|
|
|
12705
|
-
var _b
|
|
12621
|
+
var _b;
|
|
12706
12622
|
|
|
12707
12623
|
return __awaiter(this, void 0, void 0, function () {
|
|
12708
|
-
var appSyncGraphqlEndpoint, authenticationType, query, variables, apiKey, region,
|
|
12624
|
+
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;
|
|
12709
12625
|
|
|
12710
|
-
var
|
|
12626
|
+
var _h;
|
|
12711
12627
|
|
|
12712
12628
|
var _this = this;
|
|
12713
12629
|
|
|
12714
|
-
return __generator(this, function (
|
|
12715
|
-
switch (
|
|
12630
|
+
return __generator(this, function (_j) {
|
|
12631
|
+
switch (_j.label) {
|
|
12716
12632
|
case 0:
|
|
12717
|
-
appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint, authenticationType = options.authenticationType, query = options.query, variables = options.variables, apiKey = options.apiKey, region = options.region,
|
|
12633
|
+
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 () {
|
|
12718
12634
|
return {};
|
|
12719
|
-
} :
|
|
12635
|
+
} : _c, _d = options.additionalHeaders, additionalHeaders = _d === void 0 ? {} : _d;
|
|
12720
12636
|
subscriptionState = _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].PENDING;
|
|
12721
12637
|
data = {
|
|
12722
12638
|
query: query,
|
|
@@ -12731,7 +12647,7 @@ function (_super) {
|
|
|
12731
12647
|
startAckTimeoutId: undefined
|
|
12732
12648
|
});
|
|
12733
12649
|
dataString = JSON.stringify(data);
|
|
12734
|
-
|
|
12650
|
+
_e = [{}];
|
|
12735
12651
|
return [4
|
|
12736
12652
|
/*yield*/
|
|
12737
12653
|
, this._awsRealTimeHeaderBasedAuth({
|
|
@@ -12745,13 +12661,13 @@ function (_super) {
|
|
|
12745
12661
|
})];
|
|
12746
12662
|
|
|
12747
12663
|
case 1:
|
|
12748
|
-
|
|
12664
|
+
_f = [__assign.apply(void 0, _e.concat([_j.sent()]))];
|
|
12749
12665
|
return [4
|
|
12750
12666
|
/*yield*/
|
|
12751
12667
|
, graphql_headers()];
|
|
12752
12668
|
|
|
12753
12669
|
case 2:
|
|
12754
|
-
headerObj = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0,
|
|
12670
|
+
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)]);
|
|
12755
12671
|
subscriptionMessage = {
|
|
12756
12672
|
id: subscriptionId,
|
|
12757
12673
|
payload: {
|
|
@@ -12763,10 +12679,10 @@ function (_super) {
|
|
|
12763
12679
|
type: _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_START
|
|
12764
12680
|
};
|
|
12765
12681
|
stringToAWSRealTime = JSON.stringify(subscriptionMessage);
|
|
12766
|
-
|
|
12682
|
+
_j.label = 3;
|
|
12767
12683
|
|
|
12768
12684
|
case 3:
|
|
12769
|
-
|
|
12685
|
+
_j.trys.push([3, 5,, 6]);
|
|
12770
12686
|
|
|
12771
12687
|
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].OPENING_CONNECTION);
|
|
12772
12688
|
return [4
|
|
@@ -12780,35 +12696,23 @@ function (_super) {
|
|
|
12780
12696
|
})];
|
|
12781
12697
|
|
|
12782
12698
|
case 4:
|
|
12783
|
-
|
|
12699
|
+
_j.sent();
|
|
12784
12700
|
|
|
12785
12701
|
return [3
|
|
12786
12702
|
/*break*/
|
|
12787
12703
|
, 6];
|
|
12788
12704
|
|
|
12789
12705
|
case 5:
|
|
12790
|
-
err_2 =
|
|
12791
|
-
logger.debug({
|
|
12792
|
-
err: err_2
|
|
12793
|
-
});
|
|
12794
|
-
message = (_b = err_2['message']) !== null && _b !== void 0 ? _b : '';
|
|
12795
|
-
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
12796
|
-
observer.error({
|
|
12797
|
-
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + message))]
|
|
12798
|
-
});
|
|
12799
|
-
observer.complete();
|
|
12800
|
-
subscriptionFailedCallback_1 = (this.subscriptionObserverMap.get(subscriptionId) || {}).subscriptionFailedCallback; // Notify concurrent unsubscription
|
|
12706
|
+
err_2 = _j.sent();
|
|
12801
12707
|
|
|
12802
|
-
|
|
12803
|
-
subscriptionFailedCallback_1();
|
|
12804
|
-
}
|
|
12708
|
+
this._logStartSubscriptionError(subscriptionId, observer, err_2);
|
|
12805
12709
|
|
|
12806
12710
|
return [2
|
|
12807
12711
|
/*return*/
|
|
12808
12712
|
];
|
|
12809
12713
|
|
|
12810
12714
|
case 6:
|
|
12811
|
-
|
|
12715
|
+
_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
|
|
12812
12716
|
|
|
12813
12717
|
this.subscriptionObserverMap.set(subscriptionId, {
|
|
12814
12718
|
observer: observer,
|
|
@@ -12832,6 +12736,35 @@ function (_super) {
|
|
|
12832
12736
|
}
|
|
12833
12737
|
});
|
|
12834
12738
|
});
|
|
12739
|
+
}; // Log logic for start subscription failures
|
|
12740
|
+
|
|
12741
|
+
|
|
12742
|
+
AWSAppSyncRealTimeProvider.prototype._logStartSubscriptionError = function (subscriptionId, observer, err) {
|
|
12743
|
+
var _a;
|
|
12744
|
+
|
|
12745
|
+
logger.debug({
|
|
12746
|
+
err: err
|
|
12747
|
+
});
|
|
12748
|
+
var message = (_a = err['message']) !== null && _a !== void 0 ? _a : ''; // Resolving to give the state observer time to propogate the update
|
|
12749
|
+
|
|
12750
|
+
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
|
|
12751
|
+
|
|
12752
|
+
if (this.connectionState !== _types_PubSub__WEBPACK_IMPORTED_MODULE_9__["ConnectionState"].ConnectionDisruptedPendingNetwork) {
|
|
12753
|
+
// When the error is non-retriable, error out the observable
|
|
12754
|
+
if (Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["isNonRetryableError"])(err)) {
|
|
12755
|
+
observer.error({
|
|
12756
|
+
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + message))]
|
|
12757
|
+
});
|
|
12758
|
+
} else {
|
|
12759
|
+
logger.debug(_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + message);
|
|
12760
|
+
}
|
|
12761
|
+
|
|
12762
|
+
var subscriptionFailedCallback = (this.subscriptionObserverMap.get(subscriptionId) || {}).subscriptionFailedCallback; // Notify concurrent unsubscription
|
|
12763
|
+
|
|
12764
|
+
if (typeof subscriptionFailedCallback === 'function') {
|
|
12765
|
+
subscriptionFailedCallback();
|
|
12766
|
+
}
|
|
12767
|
+
}
|
|
12835
12768
|
}; // Waiting that subscription has been connected before trying to unsubscribe
|
|
12836
12769
|
|
|
12837
12770
|
|
|
@@ -12988,7 +12921,7 @@ function (_super) {
|
|
|
12988
12921
|
}
|
|
12989
12922
|
|
|
12990
12923
|
if (startAckTimeoutId) clearTimeout(startAckTimeoutId);
|
|
12991
|
-
dispatchApiEvent(
|
|
12924
|
+
dispatchApiEvent(_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].SUBSCRIPTION_ACK, {
|
|
12992
12925
|
query: query,
|
|
12993
12926
|
variables: variables
|
|
12994
12927
|
}, 'Connection established for subscription');
|
|
@@ -13014,7 +12947,7 @@ function (_super) {
|
|
|
13014
12947
|
if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
|
|
13015
12948
|
if (this.keepAliveAlertTimeoutId) clearTimeout(this.keepAliveAlertTimeoutId);
|
|
13016
12949
|
this.keepAliveTimeoutId = setTimeout(function () {
|
|
13017
|
-
return _this._errorDisconnect(
|
|
12950
|
+
return _this._errorDisconnect(_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].TIMEOUT_DISCONNECT);
|
|
13018
12951
|
}, this.keepAliveTimeout);
|
|
13019
12952
|
this.keepAliveAlertTimeoutId = setTimeout(function () {
|
|
13020
12953
|
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].KEEP_ALIVE_MISSED);
|
|
@@ -13036,11 +12969,11 @@ function (_super) {
|
|
|
13036
12969
|
subscriptionFailedCallback: subscriptionFailedCallback,
|
|
13037
12970
|
subscriptionState: subscriptionState
|
|
13038
12971
|
});
|
|
12972
|
+
logger.debug(_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + JSON.stringify(payload));
|
|
13039
12973
|
observer.error({
|
|
13040
|
-
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](
|
|
12974
|
+
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + JSON.stringify(payload)))]
|
|
13041
12975
|
});
|
|
13042
12976
|
if (startAckTimeoutId) clearTimeout(startAckTimeoutId);
|
|
13043
|
-
observer.complete();
|
|
13044
12977
|
|
|
13045
12978
|
if (typeof subscriptionFailedCallback === 'function') {
|
|
13046
12979
|
subscriptionFailedCallback();
|
|
@@ -13051,16 +12984,6 @@ function (_super) {
|
|
|
13051
12984
|
|
|
13052
12985
|
AWSAppSyncRealTimeProvider.prototype._errorDisconnect = function (msg) {
|
|
13053
12986
|
logger.debug("Disconnect error: " + msg);
|
|
13054
|
-
this.subscriptionObserverMap.forEach(function (_a) {
|
|
13055
|
-
var observer = _a.observer;
|
|
13056
|
-
|
|
13057
|
-
if (observer && !observer.closed) {
|
|
13058
|
-
observer.error({
|
|
13059
|
-
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](msg))]
|
|
13060
|
-
});
|
|
13061
|
-
}
|
|
13062
|
-
});
|
|
13063
|
-
this.subscriptionObserverMap.clear();
|
|
13064
12987
|
|
|
13065
12988
|
if (this.awsRealTimeSocket) {
|
|
13066
12989
|
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
@@ -13088,18 +13011,7 @@ function (_super) {
|
|
|
13088
13011
|
variables: variables,
|
|
13089
13012
|
subscriptionState: _constants__WEBPACK_IMPORTED_MODULE_10__["SUBSCRIPTION_STATUS"].FAILED
|
|
13090
13013
|
});
|
|
13091
|
-
|
|
13092
|
-
if (observer && !observer.closed) {
|
|
13093
|
-
observer.error({
|
|
13094
|
-
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"]("Subscription timeout " + JSON.stringify({
|
|
13095
|
-
query: query,
|
|
13096
|
-
variables: variables
|
|
13097
|
-
})))]
|
|
13098
|
-
}); // Cleanup will be automatically executed
|
|
13099
|
-
|
|
13100
|
-
observer.complete();
|
|
13101
|
-
}
|
|
13102
|
-
|
|
13014
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
13103
13015
|
logger.debug('timeoutStartSubscription', JSON.stringify({
|
|
13104
13016
|
query: query,
|
|
13105
13017
|
variables: variables
|
|
@@ -13189,6 +13101,7 @@ function (_super) {
|
|
|
13189
13101
|
|
|
13190
13102
|
case 4:
|
|
13191
13103
|
err_3 = _c.sent();
|
|
13104
|
+
logger.debug('Connection exited with', err_3);
|
|
13192
13105
|
this.promiseArray.forEach(function (_a) {
|
|
13193
13106
|
var rej = _a.rej;
|
|
13194
13107
|
return rej(err_3);
|
|
@@ -13262,8 +13175,6 @@ function (_super) {
|
|
|
13262
13175
|
};
|
|
13263
13176
|
|
|
13264
13177
|
newSocket.onclose = function () {
|
|
13265
|
-
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CONNECTION_FAILED);
|
|
13266
|
-
|
|
13267
13178
|
rej(new Error('Connection handshake error'));
|
|
13268
13179
|
};
|
|
13269
13180
|
|
|
@@ -13312,13 +13223,13 @@ function (_super) {
|
|
|
13312
13223
|
_this.awsRealTimeSocket.onerror = function (err) {
|
|
13313
13224
|
logger.debug(err);
|
|
13314
13225
|
|
|
13315
|
-
_this._errorDisconnect(
|
|
13226
|
+
_this._errorDisconnect(_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
|
|
13316
13227
|
};
|
|
13317
13228
|
|
|
13318
13229
|
_this.awsRealTimeSocket.onclose = function (event) {
|
|
13319
13230
|
logger.debug("WebSocket closed " + event.reason);
|
|
13320
13231
|
|
|
13321
|
-
_this._errorDisconnect(
|
|
13232
|
+
_this._errorDisconnect(_types_PubSub__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
|
|
13322
13233
|
};
|
|
13323
13234
|
}
|
|
13324
13235
|
|
|
@@ -13350,14 +13261,17 @@ function (_super) {
|
|
|
13350
13261
|
|
|
13351
13262
|
_this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
|
|
13352
13263
|
|
|
13353
|
-
|
|
13354
|
-
|
|
13264
|
+
var checkAckOk_1 = function checkAckOk_1(ackOk) {
|
|
13265
|
+
if (!ackOk) {
|
|
13266
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CONNECTION_FAILED);
|
|
13355
13267
|
|
|
13356
|
-
|
|
13357
|
-
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
|
|
13268
|
+
rej(new Error("Connection timeout: ack from AWSAppSyncRealTime was not received after " + _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"] + " ms"));
|
|
13269
|
+
}
|
|
13270
|
+
};
|
|
13271
|
+
|
|
13272
|
+
setTimeout(function () {
|
|
13273
|
+
return checkAckOk_1(ackOk_1);
|
|
13274
|
+
}, _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"]);
|
|
13361
13275
|
}
|
|
13362
13276
|
});
|
|
13363
13277
|
}()];
|
|
@@ -13922,8 +13836,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
13922
13836
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(uuid__WEBPACK_IMPORTED_MODULE_1__);
|
|
13923
13837
|
/* harmony import */ var zen_observable_ts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! zen-observable-ts */ "../../node_modules/zen-observable-ts/lib/bundle.esm.js");
|
|
13924
13838
|
/* harmony import */ var _PubSubProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./PubSubProvider */ "../pubsub/lib-esm/Providers/PubSubProvider.js");
|
|
13925
|
-
/* harmony import */ var
|
|
13926
|
-
/* harmony import */ var
|
|
13839
|
+
/* harmony import */ var _types_PubSub__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../types/PubSub */ "../pubsub/lib-esm/types/PubSub.js");
|
|
13840
|
+
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
|
|
13841
|
+
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__);
|
|
13842
|
+
/* harmony import */ var _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/ConnectionStateMonitor */ "../pubsub/lib-esm/utils/ConnectionStateMonitor.js");
|
|
13843
|
+
/* harmony import */ var _utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/ReconnectionMonitor */ "../pubsub/lib-esm/utils/ReconnectionMonitor.js");
|
|
13844
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./constants */ "../pubsub/lib-esm/Providers/constants.js");
|
|
13927
13845
|
function _typeof(obj) {
|
|
13928
13846
|
"@babel/helpers - typeof";
|
|
13929
13847
|
|
|
@@ -14150,7 +14068,11 @@ var __rest = undefined && undefined.__rest || function (s, e) {
|
|
|
14150
14068
|
|
|
14151
14069
|
|
|
14152
14070
|
|
|
14153
|
-
|
|
14071
|
+
|
|
14072
|
+
|
|
14073
|
+
|
|
14074
|
+
|
|
14075
|
+
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["ConsoleLogger"]('MqttOverWSProvider');
|
|
14154
14076
|
function mqttTopicMatch(filter, topic) {
|
|
14155
14077
|
var filterArray = filter.split('/');
|
|
14156
14078
|
var length = filterArray.length;
|
|
@@ -14176,18 +14098,21 @@ function () {
|
|
|
14176
14098
|
ClientsQueue.prototype.get = function (clientId, clientFactory) {
|
|
14177
14099
|
return __awaiter(this, void 0, void 0, function () {
|
|
14178
14100
|
var cachedPromise, newPromise;
|
|
14101
|
+
|
|
14102
|
+
var _this = this;
|
|
14103
|
+
|
|
14179
14104
|
return __generator(this, function (_a) {
|
|
14180
14105
|
cachedPromise = this.promises.get(clientId);
|
|
14181
|
-
|
|
14182
|
-
|
|
14183
|
-
|
|
14184
|
-
/*return*/
|
|
14185
|
-
, cachedPromise];
|
|
14186
|
-
}
|
|
14106
|
+
if (cachedPromise) return [2
|
|
14107
|
+
/*return*/
|
|
14108
|
+
, cachedPromise];
|
|
14187
14109
|
|
|
14188
14110
|
if (clientFactory) {
|
|
14189
14111
|
newPromise = clientFactory(clientId);
|
|
14190
14112
|
this.promises.set(clientId, newPromise);
|
|
14113
|
+
newPromise["catch"](function (v) {
|
|
14114
|
+
return _this.promises["delete"](clientId);
|
|
14115
|
+
});
|
|
14191
14116
|
return [2
|
|
14192
14117
|
/*return*/
|
|
14193
14118
|
, newPromise];
|
|
@@ -14215,6 +14140,14 @@ function () {
|
|
|
14215
14140
|
return ClientsQueue;
|
|
14216
14141
|
}();
|
|
14217
14142
|
|
|
14143
|
+
var dispatchPubSubEvent = function dispatchPubSubEvent(event, data, message) {
|
|
14144
|
+
_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Hub"].dispatch('pubsub', {
|
|
14145
|
+
event: event,
|
|
14146
|
+
data: data,
|
|
14147
|
+
message: message
|
|
14148
|
+
}, 'PubSub', _constants__WEBPACK_IMPORTED_MODULE_8__["AMPLIFY_SYMBOL"]);
|
|
14149
|
+
};
|
|
14150
|
+
|
|
14218
14151
|
var topicSymbol = typeof Symbol !== 'undefined' ? Symbol('topic') : '@@topic';
|
|
14219
14152
|
|
|
14220
14153
|
var MqttOverWSProvider =
|
|
@@ -14232,8 +14165,26 @@ function (_super) {
|
|
|
14232
14165
|
})) || this;
|
|
14233
14166
|
|
|
14234
14167
|
_this._clientsQueue = new ClientsQueue();
|
|
14168
|
+
_this.connectionStateMonitor = new _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__["ConnectionStateMonitor"]();
|
|
14169
|
+
_this.reconnectionMonitor = new _utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_7__["ReconnectionMonitor"]();
|
|
14235
14170
|
_this._topicObservers = new Map();
|
|
14236
|
-
_this._clientIdObservers = new Map();
|
|
14171
|
+
_this._clientIdObservers = new Map(); // Monitor the connection health state and pass changes along to Hub
|
|
14172
|
+
|
|
14173
|
+
_this.connectionStateMonitor.connectionStateObservable.subscribe(function (connectionStateChange) {
|
|
14174
|
+
dispatchPubSubEvent(_constants__WEBPACK_IMPORTED_MODULE_8__["CONNECTION_STATE_CHANGE"], {
|
|
14175
|
+
provider: _this,
|
|
14176
|
+
connectionState: connectionStateChange
|
|
14177
|
+
}, "Connection state is " + connectionStateChange);
|
|
14178
|
+
_this.connectionState = connectionStateChange; // Trigger reconnection when the connection is disrupted
|
|
14179
|
+
|
|
14180
|
+
if (connectionStateChange === _types_PubSub__WEBPACK_IMPORTED_MODULE_4__["ConnectionState"].ConnectionDisrupted) {
|
|
14181
|
+
_this.reconnectionMonitor.record(_utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_7__["ReconnectEvent"].START_RECONNECT);
|
|
14182
|
+
} else if (connectionStateChange !== _types_PubSub__WEBPACK_IMPORTED_MODULE_4__["ConnectionState"].Connecting) {
|
|
14183
|
+
// Trigger connected to halt reconnection attempts
|
|
14184
|
+
_this.reconnectionMonitor.record(_utils_ReconnectionMonitor__WEBPACK_IMPORTED_MODULE_7__["ReconnectEvent"].HALT_RECONNECT);
|
|
14185
|
+
}
|
|
14186
|
+
});
|
|
14187
|
+
|
|
14237
14188
|
return _this;
|
|
14238
14189
|
}
|
|
14239
14190
|
|
|
@@ -14275,8 +14226,6 @@ function (_super) {
|
|
|
14275
14226
|
};
|
|
14276
14227
|
|
|
14277
14228
|
MqttOverWSProvider.prototype.onDisconnect = function (_a) {
|
|
14278
|
-
var _this = this;
|
|
14279
|
-
|
|
14280
14229
|
var clientId = _a.clientId,
|
|
14281
14230
|
errorCode = _a.errorCode,
|
|
14282
14231
|
args = __rest(_a, ["clientId", "errorCode"]);
|
|
@@ -14285,7 +14234,6 @@ function (_super) {
|
|
|
14285
14234
|
logger.warn(clientId, JSON.stringify(__assign({
|
|
14286
14235
|
errorCode: errorCode
|
|
14287
14236
|
}, args), null, 2));
|
|
14288
|
-
var topicsToDelete_1 = [];
|
|
14289
14237
|
|
|
14290
14238
|
if (!clientId) {
|
|
14291
14239
|
return;
|
|
@@ -14297,24 +14245,7 @@ function (_super) {
|
|
|
14297
14245
|
return;
|
|
14298
14246
|
}
|
|
14299
14247
|
|
|
14300
|
-
|
|
14301
|
-
observer.error('Disconnected, error code: ' + errorCode); // removing observers for disconnected clientId
|
|
14302
|
-
|
|
14303
|
-
_this._topicObservers.forEach(function (observerForTopic, observerTopic) {
|
|
14304
|
-
observerForTopic["delete"](observer);
|
|
14305
|
-
|
|
14306
|
-
if (observerForTopic.size === 0) {
|
|
14307
|
-
topicsToDelete_1.push(observerTopic);
|
|
14308
|
-
}
|
|
14309
|
-
});
|
|
14310
|
-
}); // forgiving any trace of clientId
|
|
14311
|
-
|
|
14312
|
-
this._clientIdObservers["delete"](clientId); // Removing topics that are not listen by an observer
|
|
14313
|
-
|
|
14314
|
-
|
|
14315
|
-
topicsToDelete_1.forEach(function (topic) {
|
|
14316
|
-
_this._topicObservers["delete"](topic);
|
|
14317
|
-
});
|
|
14248
|
+
this.disconnect(clientId);
|
|
14318
14249
|
}
|
|
14319
14250
|
};
|
|
14320
14251
|
|
|
@@ -14322,7 +14253,7 @@ function (_super) {
|
|
|
14322
14253
|
var url = _a.url,
|
|
14323
14254
|
clientId = _a.clientId;
|
|
14324
14255
|
return __awaiter(this, void 0, void 0, function () {
|
|
14325
|
-
var client;
|
|
14256
|
+
var client, connected;
|
|
14326
14257
|
|
|
14327
14258
|
var _this = this;
|
|
14328
14259
|
|
|
@@ -14330,7 +14261,8 @@ function (_super) {
|
|
|
14330
14261
|
switch (_b.label) {
|
|
14331
14262
|
case 0:
|
|
14332
14263
|
logger.debug('Creating new MQTT client', clientId);
|
|
14333
|
-
|
|
14264
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__["CONNECTION_CHANGE"].OPENING_CONNECTION);
|
|
14265
|
+
client = new paho_mqtt__WEBPACK_IMPORTED_MODULE_0__["Client"](url, clientId);
|
|
14334
14266
|
|
|
14335
14267
|
client.onMessageArrived = function (_a) {
|
|
14336
14268
|
var topic = _a.destinationName,
|
|
@@ -14347,6 +14279,8 @@ function (_super) {
|
|
|
14347
14279
|
clientId: clientId,
|
|
14348
14280
|
errorCode: errorCode
|
|
14349
14281
|
}, args));
|
|
14282
|
+
|
|
14283
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__["CONNECTION_CHANGE"].CLOSED);
|
|
14350
14284
|
};
|
|
14351
14285
|
|
|
14352
14286
|
return [4
|
|
@@ -14356,14 +14290,24 @@ function (_super) {
|
|
|
14356
14290
|
useSSL: _this.isSSLEnabled,
|
|
14357
14291
|
mqttVersion: 3,
|
|
14358
14292
|
onSuccess: function onSuccess() {
|
|
14359
|
-
return resolve(
|
|
14293
|
+
return resolve(true);
|
|
14360
14294
|
},
|
|
14361
|
-
onFailure:
|
|
14295
|
+
onFailure: function onFailure(x) {
|
|
14296
|
+
if (clientId) _this._clientsQueue.remove(clientId);
|
|
14297
|
+
|
|
14298
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__["CONNECTION_CHANGE"].CLOSED);
|
|
14299
|
+
|
|
14300
|
+
resolve(false);
|
|
14301
|
+
}
|
|
14362
14302
|
});
|
|
14363
14303
|
})];
|
|
14364
14304
|
|
|
14365
14305
|
case 1:
|
|
14366
|
-
_b.sent();
|
|
14306
|
+
connected = _b.sent();
|
|
14307
|
+
|
|
14308
|
+
if (connected) {
|
|
14309
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__["CONNECTION_CHANGE"].CONNECTION_ESTABLISHED);
|
|
14310
|
+
}
|
|
14367
14311
|
|
|
14368
14312
|
return [2
|
|
14369
14313
|
/*return*/
|
|
@@ -14387,9 +14331,33 @@ function (_super) {
|
|
|
14387
14331
|
return [4
|
|
14388
14332
|
/*yield*/
|
|
14389
14333
|
, this.clientsQueue.get(clientId, function (clientId) {
|
|
14390
|
-
return _this
|
|
14391
|
-
|
|
14392
|
-
|
|
14334
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
14335
|
+
var client;
|
|
14336
|
+
return __generator(this, function (_a) {
|
|
14337
|
+
switch (_a.label) {
|
|
14338
|
+
case 0:
|
|
14339
|
+
return [4
|
|
14340
|
+
/*yield*/
|
|
14341
|
+
, this.newClient(__assign(__assign({}, options), {
|
|
14342
|
+
clientId: clientId
|
|
14343
|
+
}))];
|
|
14344
|
+
|
|
14345
|
+
case 1:
|
|
14346
|
+
client = _a.sent();
|
|
14347
|
+
|
|
14348
|
+
if (client) {
|
|
14349
|
+
// Once connected, subscribe to all topics registered observers
|
|
14350
|
+
this._topicObservers.forEach(function (_value, key) {
|
|
14351
|
+
client.subscribe(key);
|
|
14352
|
+
});
|
|
14353
|
+
}
|
|
14354
|
+
|
|
14355
|
+
return [2
|
|
14356
|
+
/*return*/
|
|
14357
|
+
, client];
|
|
14358
|
+
}
|
|
14359
|
+
});
|
|
14360
|
+
});
|
|
14393
14361
|
})];
|
|
14394
14362
|
|
|
14395
14363
|
case 1:
|
|
@@ -14419,6 +14387,7 @@ function (_super) {
|
|
|
14419
14387
|
}
|
|
14420
14388
|
|
|
14421
14389
|
this.clientsQueue.remove(clientId);
|
|
14390
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__["CONNECTION_CHANGE"].CLOSED);
|
|
14422
14391
|
return [2
|
|
14423
14392
|
/*return*/
|
|
14424
14393
|
];
|
|
@@ -14429,7 +14398,7 @@ function (_super) {
|
|
|
14429
14398
|
|
|
14430
14399
|
MqttOverWSProvider.prototype.publish = function (topics, msg) {
|
|
14431
14400
|
return __awaiter(this, void 0, void 0, function () {
|
|
14432
|
-
var targetTopics, message,
|
|
14401
|
+
var targetTopics, message, client;
|
|
14433
14402
|
return __generator(this, function (_a) {
|
|
14434
14403
|
switch (_a.label) {
|
|
14435
14404
|
case 0:
|
|
@@ -14437,22 +14406,20 @@ function (_super) {
|
|
|
14437
14406
|
message = JSON.stringify(msg);
|
|
14438
14407
|
return [4
|
|
14439
14408
|
/*yield*/
|
|
14440
|
-
, this.
|
|
14409
|
+
, this.clientsQueue.get(this.clientId)];
|
|
14441
14410
|
|
|
14442
14411
|
case 1:
|
|
14443
|
-
url = _a.sent();
|
|
14444
|
-
return [4
|
|
14445
|
-
/*yield*/
|
|
14446
|
-
, this.connect(this.clientId, {
|
|
14447
|
-
url: url
|
|
14448
|
-
})];
|
|
14449
|
-
|
|
14450
|
-
case 2:
|
|
14451
14412
|
client = _a.sent();
|
|
14452
|
-
|
|
14453
|
-
|
|
14454
|
-
|
|
14455
|
-
|
|
14413
|
+
|
|
14414
|
+
if (client) {
|
|
14415
|
+
logger.debug('Publishing to topic(s)', targetTopics.join(','), message);
|
|
14416
|
+
targetTopics.forEach(function (topic) {
|
|
14417
|
+
return client.send(topic, message);
|
|
14418
|
+
});
|
|
14419
|
+
} else {
|
|
14420
|
+
logger.debug('Publishing to topic(s) failed', targetTopics.join(','), message);
|
|
14421
|
+
}
|
|
14422
|
+
|
|
14456
14423
|
return [2
|
|
14457
14424
|
/*return*/
|
|
14458
14425
|
];
|
|
@@ -14496,6 +14463,7 @@ function (_super) {
|
|
|
14496
14463
|
|
|
14497
14464
|
var targetTopics = [].concat(topics);
|
|
14498
14465
|
logger.debug('Subscribing to topic(s)', targetTopics.join(','));
|
|
14466
|
+
var reconnectSubscription;
|
|
14499
14467
|
return new zen_observable_ts__WEBPACK_IMPORTED_MODULE_2__["default"](function (observer) {
|
|
14500
14468
|
targetTopics.forEach(function (topic) {
|
|
14501
14469
|
// this._topicObservers is used to notify the observers according to the topic received on the message
|
|
@@ -14508,9 +14476,7 @@ function (_super) {
|
|
|
14508
14476
|
}
|
|
14509
14477
|
|
|
14510
14478
|
observersForTopic.add(observer);
|
|
14511
|
-
});
|
|
14512
|
-
|
|
14513
|
-
var client;
|
|
14479
|
+
});
|
|
14514
14480
|
var _a = options.clientId,
|
|
14515
14481
|
clientId = _a === void 0 ? _this.clientId : _a; // this._clientIdObservers is used to close observers when client gets disconnected
|
|
14516
14482
|
|
|
@@ -14526,59 +14492,92 @@ function (_super) {
|
|
|
14526
14492
|
|
|
14527
14493
|
(function () {
|
|
14528
14494
|
return __awaiter(_this, void 0, void 0, function () {
|
|
14529
|
-
var
|
|
14495
|
+
var getClient;
|
|
14530
14496
|
|
|
14531
|
-
|
|
14532
|
-
|
|
14497
|
+
var _this = this;
|
|
14498
|
+
|
|
14499
|
+
return __generator(this, function (_a) {
|
|
14500
|
+
switch (_a.label) {
|
|
14533
14501
|
case 0:
|
|
14534
|
-
|
|
14535
|
-
|
|
14536
|
-
|
|
14537
|
-
, 2];
|
|
14538
|
-
return [4
|
|
14539
|
-
/*yield*/
|
|
14540
|
-
, this.endpoint];
|
|
14502
|
+
getClient = function getClient() {
|
|
14503
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
14504
|
+
var _a, url, _b, client_1, e_1;
|
|
14541
14505
|
|
|
14542
|
-
|
|
14543
|
-
|
|
14544
|
-
|
|
14545
|
-
|
|
14546
|
-
, 3];
|
|
14506
|
+
return __generator(this, function (_c) {
|
|
14507
|
+
switch (_c.label) {
|
|
14508
|
+
case 0:
|
|
14509
|
+
_c.trys.push([0, 5,, 6]);
|
|
14547
14510
|
|
|
14548
|
-
|
|
14549
|
-
|
|
14550
|
-
|
|
14511
|
+
_a = options.url;
|
|
14512
|
+
if (!(_a === void 0)) return [3
|
|
14513
|
+
/*break*/
|
|
14514
|
+
, 2];
|
|
14515
|
+
return [4
|
|
14516
|
+
/*yield*/
|
|
14517
|
+
, this.endpoint];
|
|
14518
|
+
|
|
14519
|
+
case 1:
|
|
14520
|
+
_b = _c.sent();
|
|
14521
|
+
return [3
|
|
14522
|
+
/*break*/
|
|
14523
|
+
, 3];
|
|
14524
|
+
|
|
14525
|
+
case 2:
|
|
14526
|
+
_b = _a;
|
|
14527
|
+
_c.label = 3;
|
|
14528
|
+
|
|
14529
|
+
case 3:
|
|
14530
|
+
url = _b;
|
|
14531
|
+
return [4
|
|
14532
|
+
/*yield*/
|
|
14533
|
+
, this.connect(clientId, {
|
|
14534
|
+
url: url
|
|
14535
|
+
})];
|
|
14551
14536
|
|
|
14552
|
-
|
|
14553
|
-
|
|
14554
|
-
|
|
14537
|
+
case 4:
|
|
14538
|
+
client_1 = _c.sent();
|
|
14539
|
+
|
|
14540
|
+
if (client_1 !== undefined) {
|
|
14541
|
+
targetTopics.forEach(function (topic) {
|
|
14542
|
+
client_1.subscribe(topic);
|
|
14543
|
+
});
|
|
14544
|
+
}
|
|
14545
|
+
|
|
14546
|
+
return [3
|
|
14547
|
+
/*break*/
|
|
14548
|
+
, 6];
|
|
14549
|
+
|
|
14550
|
+
case 5:
|
|
14551
|
+
e_1 = _c.sent();
|
|
14552
|
+
logger.debug('Error forming connection', e_1);
|
|
14553
|
+
return [3
|
|
14554
|
+
/*break*/
|
|
14555
|
+
, 6];
|
|
14556
|
+
|
|
14557
|
+
case 6:
|
|
14558
|
+
return [2
|
|
14559
|
+
/*return*/
|
|
14560
|
+
];
|
|
14561
|
+
}
|
|
14562
|
+
});
|
|
14563
|
+
});
|
|
14564
|
+
}; // Establish the initial connection
|
|
14555
14565
|
|
|
14556
|
-
case 4:
|
|
14557
|
-
_c.trys.push([4, 6,, 7]);
|
|
14558
14566
|
|
|
14559
14567
|
return [4
|
|
14560
14568
|
/*yield*/
|
|
14561
|
-
,
|
|
14562
|
-
url: url
|
|
14563
|
-
})];
|
|
14569
|
+
, getClient()];
|
|
14564
14570
|
|
|
14565
|
-
case
|
|
14566
|
-
|
|
14567
|
-
|
|
14568
|
-
client.subscribe(topic);
|
|
14569
|
-
});
|
|
14570
|
-
return [3
|
|
14571
|
-
/*break*/
|
|
14572
|
-
, 7];
|
|
14571
|
+
case 1:
|
|
14572
|
+
// Establish the initial connection
|
|
14573
|
+
_a.sent(); // Add an observable to the reconnection list to manage reconnection for this subscription
|
|
14573
14574
|
|
|
14574
|
-
case 6:
|
|
14575
|
-
e_1 = _c.sent();
|
|
14576
|
-
observer.error(e_1);
|
|
14577
|
-
return [3
|
|
14578
|
-
/*break*/
|
|
14579
|
-
, 7];
|
|
14580
14575
|
|
|
14581
|
-
|
|
14576
|
+
reconnectSubscription = new zen_observable_ts__WEBPACK_IMPORTED_MODULE_2__["default"](function (observer) {
|
|
14577
|
+
_this.reconnectionMonitor.addObserver(observer);
|
|
14578
|
+
}).subscribe(function () {
|
|
14579
|
+
getClient();
|
|
14580
|
+
});
|
|
14582
14581
|
return [2
|
|
14583
14582
|
/*return*/
|
|
14584
14583
|
];
|
|
@@ -14588,34 +14587,54 @@ function (_super) {
|
|
|
14588
14587
|
})();
|
|
14589
14588
|
|
|
14590
14589
|
return function () {
|
|
14591
|
-
|
|
14590
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
14591
|
+
var client;
|
|
14592
14592
|
|
|
14593
|
-
|
|
14593
|
+
var _this = this;
|
|
14594
|
+
|
|
14595
|
+
var _a, _b;
|
|
14596
|
+
|
|
14597
|
+
return __generator(this, function (_c) {
|
|
14598
|
+
switch (_c.label) {
|
|
14599
|
+
case 0:
|
|
14600
|
+
return [4
|
|
14601
|
+
/*yield*/
|
|
14602
|
+
, this.clientsQueue.get(clientId)];
|
|
14594
14603
|
|
|
14595
|
-
|
|
14596
|
-
|
|
14604
|
+
case 1:
|
|
14605
|
+
client = _c.sent();
|
|
14606
|
+
reconnectSubscription === null || reconnectSubscription === void 0 ? void 0 : reconnectSubscription.unsubscribe();
|
|
14597
14607
|
|
|
14598
|
-
|
|
14599
|
-
|
|
14608
|
+
if (client) {
|
|
14609
|
+
(_a = this._clientIdObservers.get(clientId)) === null || _a === void 0 ? void 0 : _a["delete"](observer); // No more observers per client => client not needed anymore
|
|
14600
14610
|
|
|
14601
|
-
|
|
14602
|
-
|
|
14611
|
+
if (((_b = this._clientIdObservers.get(clientId)) === null || _b === void 0 ? void 0 : _b.size) === 0) {
|
|
14612
|
+
this.disconnect(clientId);
|
|
14613
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_6__["CONNECTION_CHANGE"].CLOSING_CONNECTION);
|
|
14603
14614
|
|
|
14604
|
-
|
|
14605
|
-
|
|
14606
|
-
observersForTopic["delete"](observer); // if no observers exists for the topic, topic should be removed
|
|
14615
|
+
this._clientIdObservers["delete"](clientId);
|
|
14616
|
+
}
|
|
14607
14617
|
|
|
14608
|
-
|
|
14609
|
-
|
|
14618
|
+
targetTopics.forEach(function (topic) {
|
|
14619
|
+
var observersForTopic = _this._topicObservers.get(topic) || new Set();
|
|
14620
|
+
observersForTopic["delete"](observer); // if no observers exists for the topic, topic should be removed
|
|
14610
14621
|
|
|
14611
|
-
|
|
14612
|
-
|
|
14613
|
-
|
|
14622
|
+
if (observersForTopic.size === 0) {
|
|
14623
|
+
_this._topicObservers["delete"](topic);
|
|
14624
|
+
|
|
14625
|
+
if (client.isConnected()) {
|
|
14626
|
+
client.unsubscribe(topic);
|
|
14627
|
+
}
|
|
14628
|
+
}
|
|
14629
|
+
});
|
|
14630
|
+
}
|
|
14631
|
+
|
|
14632
|
+
return [2
|
|
14633
|
+
/*return*/
|
|
14634
|
+
, null];
|
|
14614
14635
|
}
|
|
14615
14636
|
});
|
|
14616
|
-
}
|
|
14617
|
-
|
|
14618
|
-
return null;
|
|
14637
|
+
});
|
|
14619
14638
|
};
|
|
14620
14639
|
});
|
|
14621
14640
|
};
|
|
@@ -14695,6 +14714,151 @@ function () {
|
|
|
14695
14714
|
|
|
14696
14715
|
|
|
14697
14716
|
|
|
14717
|
+
/***/ }),
|
|
14718
|
+
|
|
14719
|
+
/***/ "../pubsub/lib-esm/Providers/constants.js":
|
|
14720
|
+
/*!************************************************!*\
|
|
14721
|
+
!*** ../pubsub/lib-esm/Providers/constants.js ***!
|
|
14722
|
+
\************************************************/
|
|
14723
|
+
/*! 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 */
|
|
14724
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
14725
|
+
|
|
14726
|
+
"use strict";
|
|
14727
|
+
__webpack_require__.r(__webpack_exports__);
|
|
14728
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MAX_DELAY_MS", function() { return MAX_DELAY_MS; });
|
|
14729
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NON_RETRYABLE_CODES", function() { return NON_RETRYABLE_CODES; });
|
|
14730
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_STATE_CHANGE", function() { return CONNECTION_STATE_CHANGE; });
|
|
14731
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MESSAGE_TYPES", function() { return MESSAGE_TYPES; });
|
|
14732
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SUBSCRIPTION_STATUS", function() { return SUBSCRIPTION_STATUS; });
|
|
14733
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SOCKET_STATUS", function() { return SOCKET_STATUS; });
|
|
14734
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMPLIFY_SYMBOL", function() { return AMPLIFY_SYMBOL; });
|
|
14735
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AWS_APPSYNC_REALTIME_HEADERS", function() { return AWS_APPSYNC_REALTIME_HEADERS; });
|
|
14736
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_INIT_TIMEOUT", function() { return CONNECTION_INIT_TIMEOUT; });
|
|
14737
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "START_ACK_TIMEOUT", function() { return START_ACK_TIMEOUT; });
|
|
14738
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_TIMEOUT; });
|
|
14739
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT; });
|
|
14740
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RECONNECT_DELAY", function() { return RECONNECT_DELAY; });
|
|
14741
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RECONNECT_INTERVAL", function() { return RECONNECT_INTERVAL; });
|
|
14742
|
+
var MAX_DELAY_MS = 5000;
|
|
14743
|
+
var NON_RETRYABLE_CODES = [400, 401, 403];
|
|
14744
|
+
var CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
|
|
14745
|
+
var MESSAGE_TYPES;
|
|
14746
|
+
|
|
14747
|
+
(function (MESSAGE_TYPES) {
|
|
14748
|
+
/**
|
|
14749
|
+
* Client -> Server message.
|
|
14750
|
+
* This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
|
|
14751
|
+
*/
|
|
14752
|
+
MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
|
|
14753
|
+
/**
|
|
14754
|
+
* Server -> Client message
|
|
14755
|
+
* This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
|
|
14756
|
+
*/
|
|
14757
|
+
|
|
14758
|
+
MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
|
|
14759
|
+
/**
|
|
14760
|
+
* Server -> Client message.
|
|
14761
|
+
* This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
|
|
14762
|
+
*/
|
|
14763
|
+
|
|
14764
|
+
MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
|
|
14765
|
+
/**
|
|
14766
|
+
* Client -> Server message.
|
|
14767
|
+
* This message type is for register subscriptions with AWS AppSync RealTime
|
|
14768
|
+
*/
|
|
14769
|
+
|
|
14770
|
+
MESSAGE_TYPES["GQL_START"] = "start";
|
|
14771
|
+
/**
|
|
14772
|
+
* Server -> Client message.
|
|
14773
|
+
* This message type is for the ack response from AWS AppSync RealTime for GQL_START message
|
|
14774
|
+
*/
|
|
14775
|
+
|
|
14776
|
+
MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
|
|
14777
|
+
/**
|
|
14778
|
+
* Server -> Client message.
|
|
14779
|
+
* This message type is for subscription message from AWS AppSync RealTime
|
|
14780
|
+
*/
|
|
14781
|
+
|
|
14782
|
+
MESSAGE_TYPES["GQL_DATA"] = "data";
|
|
14783
|
+
/**
|
|
14784
|
+
* Server -> Client message.
|
|
14785
|
+
* This message type helps the client to know is still receiving messages from AWS AppSync RealTime
|
|
14786
|
+
*/
|
|
14787
|
+
|
|
14788
|
+
MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
|
|
14789
|
+
/**
|
|
14790
|
+
* Client -> Server message.
|
|
14791
|
+
* This message type is for unregister subscriptions with AWS AppSync RealTime
|
|
14792
|
+
*/
|
|
14793
|
+
|
|
14794
|
+
MESSAGE_TYPES["GQL_STOP"] = "stop";
|
|
14795
|
+
/**
|
|
14796
|
+
* Server -> Client message.
|
|
14797
|
+
* This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
|
|
14798
|
+
*/
|
|
14799
|
+
|
|
14800
|
+
MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
|
|
14801
|
+
/**
|
|
14802
|
+
* Server -> Client message.
|
|
14803
|
+
* This message type is for sending error messages from AWS AppSync RealTime to the client
|
|
14804
|
+
*/
|
|
14805
|
+
|
|
14806
|
+
MESSAGE_TYPES["GQL_ERROR"] = "error";
|
|
14807
|
+
})(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
|
|
14808
|
+
|
|
14809
|
+
var SUBSCRIPTION_STATUS;
|
|
14810
|
+
|
|
14811
|
+
(function (SUBSCRIPTION_STATUS) {
|
|
14812
|
+
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
|
|
14813
|
+
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
|
|
14814
|
+
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
|
|
14815
|
+
})(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
|
|
14816
|
+
|
|
14817
|
+
var SOCKET_STATUS;
|
|
14818
|
+
|
|
14819
|
+
(function (SOCKET_STATUS) {
|
|
14820
|
+
SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
|
|
14821
|
+
SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
|
|
14822
|
+
SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
|
|
14823
|
+
})(SOCKET_STATUS || (SOCKET_STATUS = {}));
|
|
14824
|
+
|
|
14825
|
+
var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
|
|
14826
|
+
var AWS_APPSYNC_REALTIME_HEADERS = {
|
|
14827
|
+
accept: 'application/json, text/javascript',
|
|
14828
|
+
'content-encoding': 'amz-1.0',
|
|
14829
|
+
'content-type': 'application/json; charset=UTF-8'
|
|
14830
|
+
};
|
|
14831
|
+
/**
|
|
14832
|
+
* Time in milleseconds to wait for GQL_CONNECTION_INIT message
|
|
14833
|
+
*/
|
|
14834
|
+
|
|
14835
|
+
var CONNECTION_INIT_TIMEOUT = 15000;
|
|
14836
|
+
/**
|
|
14837
|
+
* Time in milleseconds to wait for GQL_START_ACK message
|
|
14838
|
+
*/
|
|
14839
|
+
|
|
14840
|
+
var START_ACK_TIMEOUT = 15000;
|
|
14841
|
+
/**
|
|
14842
|
+
* Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
|
|
14843
|
+
*/
|
|
14844
|
+
|
|
14845
|
+
var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
|
|
14846
|
+
/**
|
|
14847
|
+
* Default Time in milleseconds to alert for missed GQL_CONNECTION_KEEP_ALIVE message
|
|
14848
|
+
*/
|
|
14849
|
+
|
|
14850
|
+
var DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = 65 * 1000;
|
|
14851
|
+
/**
|
|
14852
|
+
* Default delay time in milleseconds between when reconnect is triggered vs when it is attempted
|
|
14853
|
+
*/
|
|
14854
|
+
|
|
14855
|
+
var RECONNECT_DELAY = 5 * 1000;
|
|
14856
|
+
/**
|
|
14857
|
+
* Default interval time in milleseconds between when reconnect is re-attempted
|
|
14858
|
+
*/
|
|
14859
|
+
|
|
14860
|
+
var RECONNECT_INTERVAL = 60 * 1000;
|
|
14861
|
+
|
|
14698
14862
|
/***/ }),
|
|
14699
14863
|
|
|
14700
14864
|
/***/ "../pubsub/lib-esm/Providers/index.js":
|
|
@@ -15128,13 +15292,11 @@ _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Amplify"].register(PubSub);
|
|
|
15128
15292
|
/*!**********************************!*\
|
|
15129
15293
|
!*** ../pubsub/lib-esm/index.js ***!
|
|
15130
15294
|
\**********************************/
|
|
15131
|
-
/*! exports provided: AbstractPubSubProvider, AWSAppSyncProvider, AWSAppSyncRealTimeProvider, AWSIoTProvider, mqttTopicMatch, MqttOverWSProvider, CONNECTION_STATE_CHANGE, ConnectionState,
|
|
15295
|
+
/*! exports provided: AbstractPubSubProvider, AWSAppSyncProvider, AWSAppSyncRealTimeProvider, AWSIoTProvider, mqttTopicMatch, MqttOverWSProvider, CONNECTION_STATE_CHANGE, ConnectionState, CONTROL_MSG, PubSub, default */
|
|
15132
15296
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
15133
15297
|
|
|
15134
15298
|
"use strict";
|
|
15135
15299
|
__webpack_require__.r(__webpack_exports__);
|
|
15136
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_STATE_CHANGE", function() { return CONNECTION_STATE_CHANGE; });
|
|
15137
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONTROL_MSG", function() { return CONTROL_MSG; });
|
|
15138
15300
|
/* harmony import */ var _PubSub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PubSub */ "../pubsub/lib-esm/PubSub.js");
|
|
15139
15301
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PubSub", function() { return _PubSub__WEBPACK_IMPORTED_MODULE_0__["PubSub"]; });
|
|
15140
15302
|
|
|
@@ -15151,8 +15313,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
15151
15313
|
|
|
15152
15314
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MqttOverWSProvider", function() { return _Providers__WEBPACK_IMPORTED_MODULE_1__["MqttOverWSProvider"]; });
|
|
15153
15315
|
|
|
15154
|
-
/* harmony import */ var
|
|
15155
|
-
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "
|
|
15316
|
+
/* harmony import */ var _Providers_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Providers/constants */ "../pubsub/lib-esm/Providers/constants.js");
|
|
15317
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_STATE_CHANGE", function() { return _Providers_constants__WEBPACK_IMPORTED_MODULE_2__["CONNECTION_STATE_CHANGE"]; });
|
|
15318
|
+
|
|
15319
|
+
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./types */ "../pubsub/lib-esm/types/index.js");
|
|
15320
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConnectionState", function() { return _types__WEBPACK_IMPORTED_MODULE_3__["ConnectionState"]; });
|
|
15321
|
+
|
|
15322
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CONTROL_MSG", function() { return _types__WEBPACK_IMPORTED_MODULE_3__["CONTROL_MSG"]; });
|
|
15156
15323
|
|
|
15157
15324
|
/*
|
|
15158
15325
|
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
@@ -15168,17 +15335,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
15168
15335
|
*/
|
|
15169
15336
|
|
|
15170
15337
|
|
|
15171
|
-
var CONTROL_MSG;
|
|
15172
|
-
|
|
15173
|
-
(function (CONTROL_MSG) {
|
|
15174
|
-
CONTROL_MSG["CONNECTION_CLOSED"] = "Connection closed";
|
|
15175
|
-
CONTROL_MSG["CONNECTION_FAILED"] = "Connection failed";
|
|
15176
|
-
CONTROL_MSG["REALTIME_SUBSCRIPTION_INIT_ERROR"] = "AppSync Realtime subscription init error";
|
|
15177
|
-
CONTROL_MSG["SUBSCRIPTION_ACK"] = "Subscription ack";
|
|
15178
|
-
CONTROL_MSG["TIMEOUT_DISCONNECT"] = "Timeout disconnect";
|
|
15179
|
-
})(CONTROL_MSG || (CONTROL_MSG = {}));
|
|
15180
15338
|
|
|
15181
|
-
var CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
|
|
15182
15339
|
|
|
15183
15340
|
|
|
15184
15341
|
/**
|
|
@@ -15189,17 +15346,41 @@ var CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
|
|
|
15189
15346
|
|
|
15190
15347
|
/***/ }),
|
|
15191
15348
|
|
|
15192
|
-
/***/ "../pubsub/lib-esm/types/
|
|
15193
|
-
|
|
15194
|
-
!*** ../pubsub/lib-esm/types/
|
|
15195
|
-
|
|
15196
|
-
/*! exports provided: ConnectionState */
|
|
15349
|
+
/***/ "../pubsub/lib-esm/types/PubSub.js":
|
|
15350
|
+
/*!*****************************************!*\
|
|
15351
|
+
!*** ../pubsub/lib-esm/types/PubSub.js ***!
|
|
15352
|
+
\*****************************************/
|
|
15353
|
+
/*! exports provided: CONTROL_MSG, ConnectionState */
|
|
15197
15354
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
15198
15355
|
|
|
15199
15356
|
"use strict";
|
|
15200
15357
|
__webpack_require__.r(__webpack_exports__);
|
|
15358
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONTROL_MSG", function() { return CONTROL_MSG; });
|
|
15201
15359
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConnectionState", function() { return ConnectionState; });
|
|
15360
|
+
/*
|
|
15361
|
+
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
15362
|
+
*
|
|
15363
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
15364
|
+
* the License. A copy of the License is located at
|
|
15365
|
+
*
|
|
15366
|
+
* http://aws.amazon.com/apache2.0/
|
|
15367
|
+
*
|
|
15368
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
15369
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
15370
|
+
* and limitations under the License.
|
|
15371
|
+
*/
|
|
15372
|
+
var CONTROL_MSG;
|
|
15373
|
+
|
|
15374
|
+
(function (CONTROL_MSG) {
|
|
15375
|
+
CONTROL_MSG["CONNECTION_CLOSED"] = "Connection closed";
|
|
15376
|
+
CONTROL_MSG["CONNECTION_FAILED"] = "Connection failed";
|
|
15377
|
+
CONTROL_MSG["REALTIME_SUBSCRIPTION_INIT_ERROR"] = "AppSync Realtime subscription init error";
|
|
15378
|
+
CONTROL_MSG["SUBSCRIPTION_ACK"] = "Subscription ack";
|
|
15379
|
+
CONTROL_MSG["TIMEOUT_DISCONNECT"] = "Timeout disconnect";
|
|
15380
|
+
})(CONTROL_MSG || (CONTROL_MSG = {}));
|
|
15202
15381
|
/** @enum {string} */
|
|
15382
|
+
|
|
15383
|
+
|
|
15203
15384
|
var ConnectionState;
|
|
15204
15385
|
|
|
15205
15386
|
(function (ConnectionState) {
|
|
@@ -15244,6 +15425,24 @@ var ConnectionState;
|
|
|
15244
15425
|
ConnectionState["ConnectedPendingKeepAlive"] = "ConnectedPendingKeepAlive";
|
|
15245
15426
|
})(ConnectionState || (ConnectionState = {}));
|
|
15246
15427
|
|
|
15428
|
+
/***/ }),
|
|
15429
|
+
|
|
15430
|
+
/***/ "../pubsub/lib-esm/types/index.js":
|
|
15431
|
+
/*!****************************************!*\
|
|
15432
|
+
!*** ../pubsub/lib-esm/types/index.js ***!
|
|
15433
|
+
\****************************************/
|
|
15434
|
+
/*! exports provided: CONTROL_MSG, ConnectionState */
|
|
15435
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
15436
|
+
|
|
15437
|
+
"use strict";
|
|
15438
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15439
|
+
/* harmony import */ var _PubSub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PubSub */ "../pubsub/lib-esm/types/PubSub.js");
|
|
15440
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CONTROL_MSG", function() { return _PubSub__WEBPACK_IMPORTED_MODULE_0__["CONTROL_MSG"]; });
|
|
15441
|
+
|
|
15442
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConnectionState", function() { return _PubSub__WEBPACK_IMPORTED_MODULE_0__["ConnectionState"]; });
|
|
15443
|
+
|
|
15444
|
+
|
|
15445
|
+
|
|
15247
15446
|
/***/ }),
|
|
15248
15447
|
|
|
15249
15448
|
/***/ "../pubsub/lib-esm/utils/ConnectionStateMonitor.js":
|
|
@@ -15257,10 +15456,9 @@ var ConnectionState;
|
|
|
15257
15456
|
__webpack_require__.r(__webpack_exports__);
|
|
15258
15457
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_CHANGE", function() { return CONNECTION_CHANGE; });
|
|
15259
15458
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConnectionStateMonitor", function() { return ConnectionStateMonitor; });
|
|
15260
|
-
/* harmony import */ var
|
|
15261
|
-
/* harmony import */ var
|
|
15262
|
-
/* harmony import */ var
|
|
15263
|
-
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../index */ "../pubsub/lib-esm/index.js");
|
|
15459
|
+
/* harmony import */ var zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! zen-observable-ts */ "../../node_modules/zen-observable-ts/lib/bundle.esm.js");
|
|
15460
|
+
/* harmony import */ var _types_PubSub__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../types/PubSub */ "../pubsub/lib-esm/types/PubSub.js");
|
|
15461
|
+
/* harmony import */ var _ReachabilityMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ReachabilityMonitor */ "../pubsub/lib-esm/utils/ReachabilityMonitor/index.js");
|
|
15264
15462
|
/*
|
|
15265
15463
|
* Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
15266
15464
|
*
|
|
@@ -15336,8 +15534,18 @@ function () {
|
|
|
15336
15534
|
connectionState: 'disconnected',
|
|
15337
15535
|
intendedConnectionState: 'disconnected',
|
|
15338
15536
|
keepAliveState: 'healthy'
|
|
15339
|
-
};
|
|
15340
|
-
|
|
15537
|
+
}; // Attempt to update the state with the current actual network state
|
|
15538
|
+
|
|
15539
|
+
this._initialNetworkStateSubscription = Object(_ReachabilityMonitor__WEBPACK_IMPORTED_MODULE_2__["ReachabilityMonitor"])().subscribe(function (_a) {
|
|
15540
|
+
var online = _a.online;
|
|
15541
|
+
|
|
15542
|
+
var _b;
|
|
15543
|
+
|
|
15544
|
+
_this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);
|
|
15545
|
+
|
|
15546
|
+
(_b = _this._initialNetworkStateSubscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
|
|
15547
|
+
});
|
|
15548
|
+
this._linkedConnectionStateObservable = new zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__["default"](function (connectionStateObserver) {
|
|
15341
15549
|
connectionStateObserver.next(_this._linkedConnectionState);
|
|
15342
15550
|
_this._linkedConnectionStateObserver = connectionStateObserver;
|
|
15343
15551
|
});
|
|
@@ -15348,11 +15556,15 @@ function () {
|
|
|
15348
15556
|
|
|
15349
15557
|
|
|
15350
15558
|
ConnectionStateMonitor.prototype.enableNetworkMonitoring = function () {
|
|
15351
|
-
var _this = this;
|
|
15559
|
+
var _this = this;
|
|
15560
|
+
|
|
15561
|
+
var _a; // If no initial network state was discovered, stop trying
|
|
15352
15562
|
|
|
15353
15563
|
|
|
15564
|
+
(_a = this._initialNetworkStateSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe(); // Maintain the network state based on the reachability monitor
|
|
15565
|
+
|
|
15354
15566
|
if (this._networkMonitoringSubscription === undefined) {
|
|
15355
|
-
this._networkMonitoringSubscription =
|
|
15567
|
+
this._networkMonitoringSubscription = Object(_ReachabilityMonitor__WEBPACK_IMPORTED_MODULE_2__["ReachabilityMonitor"])().subscribe(function (_a) {
|
|
15356
15568
|
var online = _a.online;
|
|
15357
15569
|
|
|
15358
15570
|
_this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);
|
|
@@ -15425,15 +15637,15 @@ function () {
|
|
|
15425
15637
|
networkState = _a.networkState,
|
|
15426
15638
|
intendedConnectionState = _a.intendedConnectionState,
|
|
15427
15639
|
keepAliveState = _a.keepAliveState;
|
|
15428
|
-
if (connectionState === 'connected' && networkState === 'disconnected') return
|
|
15429
|
-
if (connectionState === 'connected' && intendedConnectionState === 'disconnected') return
|
|
15430
|
-
if (connectionState === 'disconnected' && intendedConnectionState === 'connected' && networkState === 'disconnected') return
|
|
15431
|
-
if (connectionState === 'disconnected' && intendedConnectionState === 'connected') return
|
|
15432
|
-
if (connectionState === 'connected' && keepAliveState === 'unhealthy') return
|
|
15640
|
+
if (connectionState === 'connected' && networkState === 'disconnected') return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectedPendingNetwork;
|
|
15641
|
+
if (connectionState === 'connected' && intendedConnectionState === 'disconnected') return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectedPendingDisconnect;
|
|
15642
|
+
if (connectionState === 'disconnected' && intendedConnectionState === 'connected' && networkState === 'disconnected') return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectionDisruptedPendingNetwork;
|
|
15643
|
+
if (connectionState === 'disconnected' && intendedConnectionState === 'connected') return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectionDisrupted;
|
|
15644
|
+
if (connectionState === 'connected' && keepAliveState === 'unhealthy') return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectedPendingKeepAlive; // All remaining states directly correspond to the connection state
|
|
15433
15645
|
|
|
15434
|
-
if (connectionState === 'connecting') return
|
|
15435
|
-
if (connectionState === 'disconnected') return
|
|
15436
|
-
return
|
|
15646
|
+
if (connectionState === 'connecting') return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].Connecting;
|
|
15647
|
+
if (connectionState === 'disconnected') return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].Disconnected;
|
|
15648
|
+
return _types_PubSub__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].Connected;
|
|
15437
15649
|
};
|
|
15438
15650
|
|
|
15439
15651
|
return ConnectionStateMonitor;
|
|
@@ -15441,6 +15653,129 @@ function () {
|
|
|
15441
15653
|
|
|
15442
15654
|
|
|
15443
15655
|
|
|
15656
|
+
/***/ }),
|
|
15657
|
+
|
|
15658
|
+
/***/ "../pubsub/lib-esm/utils/ReachabilityMonitor/index.js":
|
|
15659
|
+
/*!************************************************************!*\
|
|
15660
|
+
!*** ../pubsub/lib-esm/utils/ReachabilityMonitor/index.js ***!
|
|
15661
|
+
\************************************************************/
|
|
15662
|
+
/*! exports provided: ReachabilityMonitor */
|
|
15663
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
15664
|
+
|
|
15665
|
+
"use strict";
|
|
15666
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15667
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReachabilityMonitor", function() { return ReachabilityMonitor; });
|
|
15668
|
+
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
|
|
15669
|
+
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__);
|
|
15670
|
+
|
|
15671
|
+
var ReachabilityMonitor = function ReachabilityMonitor() {
|
|
15672
|
+
return new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Reachability"]().networkMonitor();
|
|
15673
|
+
};
|
|
15674
|
+
|
|
15675
|
+
/***/ }),
|
|
15676
|
+
|
|
15677
|
+
/***/ "../pubsub/lib-esm/utils/ReconnectionMonitor.js":
|
|
15678
|
+
/*!******************************************************!*\
|
|
15679
|
+
!*** ../pubsub/lib-esm/utils/ReconnectionMonitor.js ***!
|
|
15680
|
+
\******************************************************/
|
|
15681
|
+
/*! exports provided: ReconnectEvent, ReconnectionMonitor */
|
|
15682
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
15683
|
+
|
|
15684
|
+
"use strict";
|
|
15685
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15686
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReconnectEvent", function() { return ReconnectEvent; });
|
|
15687
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReconnectionMonitor", function() { return ReconnectionMonitor; });
|
|
15688
|
+
/* harmony import */ var _Providers_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Providers/constants */ "../pubsub/lib-esm/Providers/constants.js");
|
|
15689
|
+
|
|
15690
|
+
var ReconnectEvent;
|
|
15691
|
+
|
|
15692
|
+
(function (ReconnectEvent) {
|
|
15693
|
+
ReconnectEvent["START_RECONNECT"] = "START_RECONNECT";
|
|
15694
|
+
ReconnectEvent["HALT_RECONNECT"] = "HALT_RECONNECT";
|
|
15695
|
+
})(ReconnectEvent || (ReconnectEvent = {}));
|
|
15696
|
+
/**
|
|
15697
|
+
* Captures the reconnect event logic used to determine when to reconnect to PubSub providers.
|
|
15698
|
+
* Reconnnect attempts are delayed by 5 seconds to let the interface settle.
|
|
15699
|
+
* Attempting to reconnect only once creates unrecoverable states when the network state isn't
|
|
15700
|
+
* supported by the browser, so this keeps retrying every minute until halted.
|
|
15701
|
+
*/
|
|
15702
|
+
|
|
15703
|
+
|
|
15704
|
+
var ReconnectionMonitor =
|
|
15705
|
+
/** @class */
|
|
15706
|
+
function () {
|
|
15707
|
+
function ReconnectionMonitor() {
|
|
15708
|
+
this.reconnectObservers = [];
|
|
15709
|
+
}
|
|
15710
|
+
/**
|
|
15711
|
+
* Add reconnect observer to the list of observers to alert on reconnect
|
|
15712
|
+
*/
|
|
15713
|
+
|
|
15714
|
+
|
|
15715
|
+
ReconnectionMonitor.prototype.addObserver = function (reconnectObserver) {
|
|
15716
|
+
this.reconnectObservers.push(reconnectObserver);
|
|
15717
|
+
};
|
|
15718
|
+
/**
|
|
15719
|
+
* Given a reconnect event, start the appropriate behavior
|
|
15720
|
+
*/
|
|
15721
|
+
|
|
15722
|
+
|
|
15723
|
+
ReconnectionMonitor.prototype.record = function (event) {
|
|
15724
|
+
var _this = this;
|
|
15725
|
+
|
|
15726
|
+
if (event === ReconnectEvent.START_RECONNECT) {
|
|
15727
|
+
// If the reconnection hasn't been started
|
|
15728
|
+
if (this.reconnectSetTimeoutId === undefined && this.reconnectIntervalId === undefined) {
|
|
15729
|
+
this.reconnectSetTimeoutId = setTimeout(function () {
|
|
15730
|
+
// Reconnect now
|
|
15731
|
+
_this._triggerReconnect(); // Retry reconnect every periodically until it works
|
|
15732
|
+
|
|
15733
|
+
|
|
15734
|
+
_this.reconnectIntervalId = setInterval(function () {
|
|
15735
|
+
_this._triggerReconnect();
|
|
15736
|
+
}, _Providers_constants__WEBPACK_IMPORTED_MODULE_0__["RECONNECT_INTERVAL"]);
|
|
15737
|
+
}, _Providers_constants__WEBPACK_IMPORTED_MODULE_0__["RECONNECT_DELAY"]);
|
|
15738
|
+
}
|
|
15739
|
+
}
|
|
15740
|
+
|
|
15741
|
+
if (event === ReconnectEvent.HALT_RECONNECT) {
|
|
15742
|
+
if (this.reconnectIntervalId) {
|
|
15743
|
+
clearInterval(this.reconnectIntervalId);
|
|
15744
|
+
this.reconnectIntervalId = undefined;
|
|
15745
|
+
}
|
|
15746
|
+
|
|
15747
|
+
if (this.reconnectSetTimeoutId) {
|
|
15748
|
+
clearTimeout(this.reconnectSetTimeoutId);
|
|
15749
|
+
this.reconnectSetTimeoutId = undefined;
|
|
15750
|
+
}
|
|
15751
|
+
}
|
|
15752
|
+
};
|
|
15753
|
+
/**
|
|
15754
|
+
* Complete all reconnect observers
|
|
15755
|
+
*/
|
|
15756
|
+
|
|
15757
|
+
|
|
15758
|
+
ReconnectionMonitor.prototype.close = function () {
|
|
15759
|
+
this.reconnectObservers.forEach(function (reconnectObserver) {
|
|
15760
|
+
var _a;
|
|
15761
|
+
|
|
15762
|
+
(_a = reconnectObserver.complete) === null || _a === void 0 ? void 0 : _a.call(reconnectObserver);
|
|
15763
|
+
});
|
|
15764
|
+
};
|
|
15765
|
+
|
|
15766
|
+
ReconnectionMonitor.prototype._triggerReconnect = function () {
|
|
15767
|
+
this.reconnectObservers.forEach(function (reconnectObserver) {
|
|
15768
|
+
var _a;
|
|
15769
|
+
|
|
15770
|
+
(_a = reconnectObserver.next) === null || _a === void 0 ? void 0 : _a.call(reconnectObserver);
|
|
15771
|
+
});
|
|
15772
|
+
};
|
|
15773
|
+
|
|
15774
|
+
return ReconnectionMonitor;
|
|
15775
|
+
}();
|
|
15776
|
+
|
|
15777
|
+
|
|
15778
|
+
|
|
15444
15779
|
/***/ }),
|
|
15445
15780
|
|
|
15446
15781
|
/***/ "./lib-esm/API.js":
|