@aws-amplify/api 4.0.30-custom-pk.97 → 4.0.30-custom-pk.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -97
- package/dist/aws-amplify-api.js +506 -141
- 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
|
@@ -12135,131 +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 */
|
|
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
|
-
var MAX_DELAY_MS = 5000;
|
|
12160
|
-
var NON_RETRYABLE_CODES = [400, 401, 403];
|
|
12161
|
-
var MESSAGE_TYPES;
|
|
12162
|
-
|
|
12163
|
-
(function (MESSAGE_TYPES) {
|
|
12164
|
-
/**
|
|
12165
|
-
* Client -> Server message.
|
|
12166
|
-
* This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
|
|
12167
|
-
*/
|
|
12168
|
-
MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
|
|
12169
|
-
/**
|
|
12170
|
-
* Server -> Client message
|
|
12171
|
-
* This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
|
|
12172
|
-
*/
|
|
12173
|
-
|
|
12174
|
-
MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
|
|
12175
|
-
/**
|
|
12176
|
-
* Server -> Client message.
|
|
12177
|
-
* This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
|
|
12178
|
-
*/
|
|
12179
|
-
|
|
12180
|
-
MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
|
|
12181
|
-
/**
|
|
12182
|
-
* Client -> Server message.
|
|
12183
|
-
* This message type is for register subscriptions with AWS AppSync RealTime
|
|
12184
|
-
*/
|
|
12185
|
-
|
|
12186
|
-
MESSAGE_TYPES["GQL_START"] = "start";
|
|
12187
|
-
/**
|
|
12188
|
-
* Server -> Client message.
|
|
12189
|
-
* This message type is for the ack response from AWS AppSync RealTime for GQL_START message
|
|
12190
|
-
*/
|
|
12191
|
-
|
|
12192
|
-
MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
|
|
12193
|
-
/**
|
|
12194
|
-
* Server -> Client message.
|
|
12195
|
-
* This message type is for subscription message from AWS AppSync RealTime
|
|
12196
|
-
*/
|
|
12197
|
-
|
|
12198
|
-
MESSAGE_TYPES["GQL_DATA"] = "data";
|
|
12199
|
-
/**
|
|
12200
|
-
* Server -> Client message.
|
|
12201
|
-
* This message type helps the client to know is still receiving messages from AWS AppSync RealTime
|
|
12202
|
-
*/
|
|
12203
|
-
|
|
12204
|
-
MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
|
|
12205
|
-
/**
|
|
12206
|
-
* Client -> Server message.
|
|
12207
|
-
* This message type is for unregister subscriptions with AWS AppSync RealTime
|
|
12208
|
-
*/
|
|
12209
|
-
|
|
12210
|
-
MESSAGE_TYPES["GQL_STOP"] = "stop";
|
|
12211
|
-
/**
|
|
12212
|
-
* Server -> Client message.
|
|
12213
|
-
* This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
|
|
12214
|
-
*/
|
|
12215
|
-
|
|
12216
|
-
MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
|
|
12217
|
-
/**
|
|
12218
|
-
* Server -> Client message.
|
|
12219
|
-
* This message type is for sending error messages from AWS AppSync RealTime to the client
|
|
12220
|
-
*/
|
|
12221
|
-
|
|
12222
|
-
MESSAGE_TYPES["GQL_ERROR"] = "error";
|
|
12223
|
-
})(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
|
|
12224
|
-
|
|
12225
|
-
var SUBSCRIPTION_STATUS;
|
|
12226
|
-
|
|
12227
|
-
(function (SUBSCRIPTION_STATUS) {
|
|
12228
|
-
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
|
|
12229
|
-
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
|
|
12230
|
-
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
|
|
12231
|
-
})(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
|
|
12232
|
-
|
|
12233
|
-
var SOCKET_STATUS;
|
|
12234
|
-
|
|
12235
|
-
(function (SOCKET_STATUS) {
|
|
12236
|
-
SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
|
|
12237
|
-
SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
|
|
12238
|
-
SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
|
|
12239
|
-
})(SOCKET_STATUS || (SOCKET_STATUS = {}));
|
|
12240
|
-
|
|
12241
|
-
var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
|
|
12242
|
-
var AWS_APPSYNC_REALTIME_HEADERS = {
|
|
12243
|
-
accept: 'application/json, text/javascript',
|
|
12244
|
-
'content-encoding': 'amz-1.0',
|
|
12245
|
-
'content-type': 'application/json; charset=UTF-8'
|
|
12246
|
-
};
|
|
12247
|
-
/**
|
|
12248
|
-
* Time in milleseconds to wait for GQL_CONNECTION_INIT message
|
|
12249
|
-
*/
|
|
12250
|
-
|
|
12251
|
-
var CONNECTION_INIT_TIMEOUT = 15000;
|
|
12252
|
-
/**
|
|
12253
|
-
* Time in milleseconds to wait for GQL_START_ACK message
|
|
12254
|
-
*/
|
|
12255
|
-
|
|
12256
|
-
var START_ACK_TIMEOUT = 15000;
|
|
12257
|
-
/**
|
|
12258
|
-
* Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
|
|
12259
|
-
*/
|
|
12260
|
-
|
|
12261
|
-
var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
|
|
12262
|
-
|
|
12263
12138
|
/***/ }),
|
|
12264
12139
|
|
|
12265
12140
|
/***/ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js":
|
|
@@ -12289,7 +12164,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
12289
12164
|
/* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7__);
|
|
12290
12165
|
/* harmony import */ var _PubSubProvider__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PubSubProvider */ "../pubsub/lib-esm/Providers/PubSubProvider.js");
|
|
12291
12166
|
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../index */ "../pubsub/lib-esm/index.js");
|
|
12292
|
-
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*!
|
|
12167
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../constants */ "../pubsub/lib-esm/Providers/constants.js");
|
|
12168
|
+
/* harmony import */ var _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../utils/ConnectionStateMonitor */ "../pubsub/lib-esm/utils/ConnectionStateMonitor.js");
|
|
12293
12169
|
var __extends = undefined && undefined.__extends || function () {
|
|
12294
12170
|
var _extendStatics = function extendStatics(d, b) {
|
|
12295
12171
|
_extendStatics = Object.setPrototypeOf || {
|
|
@@ -12526,6 +12402,7 @@ var __read = undefined && undefined.__read || function (o, n) {
|
|
|
12526
12402
|
|
|
12527
12403
|
|
|
12528
12404
|
|
|
12405
|
+
|
|
12529
12406
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Logger"]('AWSAppSyncRealTimeProvider');
|
|
12530
12407
|
|
|
12531
12408
|
var dispatchApiEvent = function dispatchApiEvent(event, data, message) {
|
|
@@ -12544,13 +12421,26 @@ var AWSAppSyncRealTimeProvider =
|
|
|
12544
12421
|
function (_super) {
|
|
12545
12422
|
__extends(AWSAppSyncRealTimeProvider, _super);
|
|
12546
12423
|
|
|
12547
|
-
function AWSAppSyncRealTimeProvider() {
|
|
12548
|
-
|
|
12424
|
+
function AWSAppSyncRealTimeProvider(options) {
|
|
12425
|
+
if (options === void 0) {
|
|
12426
|
+
options = {};
|
|
12427
|
+
}
|
|
12428
|
+
|
|
12429
|
+
var _this = _super.call(this, options) || this;
|
|
12549
12430
|
|
|
12550
12431
|
_this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
|
|
12551
12432
|
_this.keepAliveTimeout = _constants__WEBPACK_IMPORTED_MODULE_10__["DEFAULT_KEEP_ALIVE_TIMEOUT"];
|
|
12552
12433
|
_this.subscriptionObserverMap = new Map();
|
|
12553
12434
|
_this.promiseArray = [];
|
|
12435
|
+
_this.connectionStateMonitor = new _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["ConnectionStateMonitor"](); // Monitor the connection state and pass changes along to Hub
|
|
12436
|
+
|
|
12437
|
+
_this.connectionStateMonitor.connectionStateObservable.subscribe(function (ConnectionState) {
|
|
12438
|
+
dispatchApiEvent(_index__WEBPACK_IMPORTED_MODULE_9__["CONNECTION_STATE_CHANGE"], {
|
|
12439
|
+
provider: _this,
|
|
12440
|
+
connectionState: ConnectionState
|
|
12441
|
+
}, "Connection state is " + ConnectionState);
|
|
12442
|
+
});
|
|
12443
|
+
|
|
12554
12444
|
return _this;
|
|
12555
12445
|
}
|
|
12556
12446
|
|
|
@@ -12600,6 +12490,9 @@ function (_super) {
|
|
|
12600
12490
|
observer.error({
|
|
12601
12491
|
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].REALTIME_SUBSCRIPTION_INIT_ERROR + ": " + err))]
|
|
12602
12492
|
});
|
|
12493
|
+
|
|
12494
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
12495
|
+
|
|
12603
12496
|
observer.complete();
|
|
12604
12497
|
});
|
|
12605
12498
|
|
|
@@ -12744,6 +12637,7 @@ function (_super) {
|
|
|
12744
12637
|
case 3:
|
|
12745
12638
|
_k.trys.push([3, 5,, 6]);
|
|
12746
12639
|
|
|
12640
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].OPENING_CONNECTION);
|
|
12747
12641
|
return [4
|
|
12748
12642
|
/*yield*/
|
|
12749
12643
|
, this._initializeWebSocketConnection({
|
|
@@ -12767,6 +12661,7 @@ function (_super) {
|
|
|
12767
12661
|
err: err_2
|
|
12768
12662
|
});
|
|
12769
12663
|
message = (_b = err_2['message']) !== null && _b !== void 0 ? _b : '';
|
|
12664
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
12770
12665
|
observer.error({
|
|
12771
12666
|
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + message))]
|
|
12772
12667
|
});
|
|
@@ -12885,12 +12780,22 @@ function (_super) {
|
|
|
12885
12780
|
return;
|
|
12886
12781
|
}
|
|
12887
12782
|
|
|
12783
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSING_CONNECTION);
|
|
12784
|
+
|
|
12888
12785
|
if (this.awsRealTimeSocket.bufferedAmount > 0) {
|
|
12889
12786
|
// Still data on the WebSocket
|
|
12890
12787
|
setTimeout(this._closeSocketIfRequired.bind(this), 1000);
|
|
12891
12788
|
} else {
|
|
12892
12789
|
logger.debug('closing WebSocket...');
|
|
12893
|
-
|
|
12790
|
+
|
|
12791
|
+
if (this.keepAliveTimeoutId) {
|
|
12792
|
+
clearTimeout(this.keepAliveTimeoutId);
|
|
12793
|
+
}
|
|
12794
|
+
|
|
12795
|
+
if (this.keepAliveAlertTimeoutId) {
|
|
12796
|
+
clearTimeout(this.keepAliveAlertTimeoutId);
|
|
12797
|
+
}
|
|
12798
|
+
|
|
12894
12799
|
var tempSocket = this.awsRealTimeSocket; // Cleaning callbacks to avoid race condition, socket still exists
|
|
12895
12800
|
|
|
12896
12801
|
tempSocket.onclose = null;
|
|
@@ -12898,10 +12803,13 @@ function (_super) {
|
|
|
12898
12803
|
tempSocket.close(1000);
|
|
12899
12804
|
this.awsRealTimeSocket = undefined;
|
|
12900
12805
|
this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
|
|
12806
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
12901
12807
|
}
|
|
12902
12808
|
};
|
|
12903
12809
|
|
|
12904
12810
|
AWSAppSyncRealTimeProvider.prototype._handleIncomingSubscriptionMessage = function (message) {
|
|
12811
|
+
var _this = this;
|
|
12812
|
+
|
|
12905
12813
|
logger.debug("subscription message from AWS AppSync RealTime: " + message.data);
|
|
12906
12814
|
|
|
12907
12815
|
var _a = JSON.parse(message.data),
|
|
@@ -12965,15 +12873,22 @@ function (_super) {
|
|
|
12965
12873
|
subscriptionReadyCallback: subscriptionReadyCallback,
|
|
12966
12874
|
subscriptionFailedCallback: subscriptionFailedCallback
|
|
12967
12875
|
});
|
|
12968
|
-
}
|
|
12969
|
-
|
|
12876
|
+
}
|
|
12970
12877
|
|
|
12878
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CONNECTION_ESTABLISHED);
|
|
12971
12879
|
return;
|
|
12972
12880
|
}
|
|
12973
12881
|
|
|
12974
12882
|
if (type === _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_CONNECTION_KEEP_ALIVE) {
|
|
12975
12883
|
if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
|
|
12976
|
-
|
|
12884
|
+
if (this.keepAliveAlertTimeoutId) clearTimeout(this.keepAliveAlertTimeoutId);
|
|
12885
|
+
this.keepAliveTimeoutId = setTimeout(function () {
|
|
12886
|
+
return _this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].TIMEOUT_DISCONNECT);
|
|
12887
|
+
}, this.keepAliveTimeout);
|
|
12888
|
+
this.keepAliveAlertTimeoutId = setTimeout(function () {
|
|
12889
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].KEEP_ALIVE_MISSED);
|
|
12890
|
+
}, _constants__WEBPACK_IMPORTED_MODULE_10__["DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT"]);
|
|
12891
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].KEEP_ALIVE);
|
|
12977
12892
|
return;
|
|
12978
12893
|
}
|
|
12979
12894
|
|
|
@@ -13017,6 +12932,7 @@ function (_super) {
|
|
|
13017
12932
|
this.subscriptionObserverMap.clear();
|
|
13018
12933
|
|
|
13019
12934
|
if (this.awsRealTimeSocket) {
|
|
12935
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
|
|
13020
12936
|
this.awsRealTimeSocket.close();
|
|
13021
12937
|
}
|
|
13022
12938
|
|
|
@@ -13215,6 +13131,8 @@ function (_super) {
|
|
|
13215
13131
|
};
|
|
13216
13132
|
|
|
13217
13133
|
newSocket.onclose = function () {
|
|
13134
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CONNECTION_FAILED);
|
|
13135
|
+
|
|
13218
13136
|
rej(new Error('Connection handshake error'));
|
|
13219
13137
|
};
|
|
13220
13138
|
|
|
@@ -13301,13 +13219,17 @@ function (_super) {
|
|
|
13301
13219
|
|
|
13302
13220
|
_this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
|
|
13303
13221
|
|
|
13304
|
-
|
|
13305
|
-
|
|
13222
|
+
var checkAckOk_1 = function checkAckOk_1(ackOk) {
|
|
13223
|
+
if (!ackOk) {
|
|
13224
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CONNECTION_FAILED);
|
|
13306
13225
|
|
|
13307
|
-
|
|
13308
|
-
|
|
13309
|
-
|
|
13310
|
-
|
|
13226
|
+
rej(new Error("Connection timeout: ack from AWSAppSyncRealTime was not received after " + _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"] + " ms"));
|
|
13227
|
+
}
|
|
13228
|
+
};
|
|
13229
|
+
|
|
13230
|
+
setTimeout(function () {
|
|
13231
|
+
return checkAckOk_1(ackOk_1);
|
|
13232
|
+
}, _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"]);
|
|
13311
13233
|
}
|
|
13312
13234
|
});
|
|
13313
13235
|
}()];
|
|
@@ -13874,6 +13796,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
13874
13796
|
/* harmony import */ var _PubSubProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./PubSubProvider */ "../pubsub/lib-esm/Providers/PubSubProvider.js");
|
|
13875
13797
|
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
|
|
13876
13798
|
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__);
|
|
13799
|
+
/* harmony import */ var _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/ConnectionStateMonitor */ "../pubsub/lib-esm/utils/ConnectionStateMonitor.js");
|
|
13800
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./constants */ "../pubsub/lib-esm/Providers/constants.js");
|
|
13801
|
+
/* harmony import */ var ___WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! .. */ "../pubsub/lib-esm/index.js");
|
|
13877
13802
|
function _typeof(obj) {
|
|
13878
13803
|
"@babel/helpers - typeof";
|
|
13879
13804
|
|
|
@@ -14100,6 +14025,9 @@ var __rest = undefined && undefined.__rest || function (s, e) {
|
|
|
14100
14025
|
|
|
14101
14026
|
|
|
14102
14027
|
|
|
14028
|
+
|
|
14029
|
+
|
|
14030
|
+
|
|
14103
14031
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__["ConsoleLogger"]('MqttOverWSProvider');
|
|
14104
14032
|
function mqttTopicMatch(filter, topic) {
|
|
14105
14033
|
var filterArray = filter.split('/');
|
|
@@ -14165,6 +14093,14 @@ function () {
|
|
|
14165
14093
|
return ClientsQueue;
|
|
14166
14094
|
}();
|
|
14167
14095
|
|
|
14096
|
+
var dispatchPubSubEvent = function dispatchPubSubEvent(event, data, message) {
|
|
14097
|
+
_aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__["Hub"].dispatch('pubsub', {
|
|
14098
|
+
event: event,
|
|
14099
|
+
data: data,
|
|
14100
|
+
message: message
|
|
14101
|
+
}, 'PubSub', _constants__WEBPACK_IMPORTED_MODULE_6__["AMPLIFY_SYMBOL"]);
|
|
14102
|
+
};
|
|
14103
|
+
|
|
14168
14104
|
var topicSymbol = typeof Symbol !== 'undefined' ? Symbol('topic') : '@@topic';
|
|
14169
14105
|
|
|
14170
14106
|
var MqttOverWSProvider =
|
|
@@ -14182,8 +14118,17 @@ function (_super) {
|
|
|
14182
14118
|
})) || this;
|
|
14183
14119
|
|
|
14184
14120
|
_this._clientsQueue = new ClientsQueue();
|
|
14121
|
+
_this.connectionStateMonitor = new _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["ConnectionStateMonitor"]();
|
|
14185
14122
|
_this._topicObservers = new Map();
|
|
14186
|
-
_this._clientIdObservers = new Map();
|
|
14123
|
+
_this._clientIdObservers = new Map(); // Monitor the connection health state and pass changes along to Hub
|
|
14124
|
+
|
|
14125
|
+
_this.connectionStateMonitor.connectionStateObservable.subscribe(function (connectionStateChange) {
|
|
14126
|
+
dispatchPubSubEvent(___WEBPACK_IMPORTED_MODULE_7__["CONNECTION_STATE_CHANGE"], {
|
|
14127
|
+
provider: _this,
|
|
14128
|
+
connectionState: connectionStateChange
|
|
14129
|
+
}, "Connection state is " + connectionStateChange);
|
|
14130
|
+
});
|
|
14131
|
+
|
|
14187
14132
|
return _this;
|
|
14188
14133
|
}
|
|
14189
14134
|
|
|
@@ -14280,6 +14225,7 @@ function (_super) {
|
|
|
14280
14225
|
switch (_b.label) {
|
|
14281
14226
|
case 0:
|
|
14282
14227
|
logger.debug('Creating new MQTT client', clientId);
|
|
14228
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].OPENING_CONNECTION);
|
|
14283
14229
|
client = new paho_mqtt__WEBPACK_IMPORTED_MODULE_0__["Client"](url, clientId); // client.trace = (args) => logger.debug(clientId, JSON.stringify(args, null, 2));
|
|
14284
14230
|
|
|
14285
14231
|
client.onMessageArrived = function (_a) {
|
|
@@ -14297,6 +14243,8 @@ function (_super) {
|
|
|
14297
14243
|
clientId: clientId,
|
|
14298
14244
|
errorCode: errorCode
|
|
14299
14245
|
}, args));
|
|
14246
|
+
|
|
14247
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].CLOSED);
|
|
14300
14248
|
};
|
|
14301
14249
|
|
|
14302
14250
|
return [4
|
|
@@ -14308,13 +14256,18 @@ function (_super) {
|
|
|
14308
14256
|
onSuccess: function onSuccess() {
|
|
14309
14257
|
return resolve(client);
|
|
14310
14258
|
},
|
|
14311
|
-
onFailure:
|
|
14259
|
+
onFailure: function onFailure() {
|
|
14260
|
+
reject();
|
|
14261
|
+
|
|
14262
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].CONNECTION_FAILED);
|
|
14263
|
+
}
|
|
14312
14264
|
});
|
|
14313
14265
|
})];
|
|
14314
14266
|
|
|
14315
14267
|
case 1:
|
|
14316
14268
|
_b.sent();
|
|
14317
14269
|
|
|
14270
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].CONNECTION_ESTABLISHED);
|
|
14318
14271
|
return [2
|
|
14319
14272
|
/*return*/
|
|
14320
14273
|
, client];
|
|
@@ -14366,6 +14319,7 @@ function (_super) {
|
|
|
14366
14319
|
|
|
14367
14320
|
if (client && client.isConnected()) {
|
|
14368
14321
|
client.disconnect();
|
|
14322
|
+
this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].CLOSED);
|
|
14369
14323
|
}
|
|
14370
14324
|
|
|
14371
14325
|
this.clientsQueue.remove(clientId);
|
|
@@ -14546,6 +14500,8 @@ function (_super) {
|
|
|
14546
14500
|
(_a = _this._clientIdObservers.get(clientId)) === null || _a === void 0 ? void 0 : _a["delete"](observer); // No more observers per client => client not needed anymore
|
|
14547
14501
|
|
|
14548
14502
|
if (((_b = _this._clientIdObservers.get(clientId)) === null || _b === void 0 ? void 0 : _b.size) === 0) {
|
|
14503
|
+
_this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].CLOSING_CONNECTION);
|
|
14504
|
+
|
|
14549
14505
|
_this.disconnect(clientId);
|
|
14550
14506
|
|
|
14551
14507
|
_this._clientIdObservers["delete"](clientId);
|
|
@@ -14645,6 +14601,137 @@ function () {
|
|
|
14645
14601
|
|
|
14646
14602
|
|
|
14647
14603
|
|
|
14604
|
+
/***/ }),
|
|
14605
|
+
|
|
14606
|
+
/***/ "../pubsub/lib-esm/Providers/constants.js":
|
|
14607
|
+
/*!************************************************!*\
|
|
14608
|
+
!*** ../pubsub/lib-esm/Providers/constants.js ***!
|
|
14609
|
+
\************************************************/
|
|
14610
|
+
/*! 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 */
|
|
14611
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
14612
|
+
|
|
14613
|
+
"use strict";
|
|
14614
|
+
__webpack_require__.r(__webpack_exports__);
|
|
14615
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MAX_DELAY_MS", function() { return MAX_DELAY_MS; });
|
|
14616
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NON_RETRYABLE_CODES", function() { return NON_RETRYABLE_CODES; });
|
|
14617
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MESSAGE_TYPES", function() { return MESSAGE_TYPES; });
|
|
14618
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SUBSCRIPTION_STATUS", function() { return SUBSCRIPTION_STATUS; });
|
|
14619
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SOCKET_STATUS", function() { return SOCKET_STATUS; });
|
|
14620
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMPLIFY_SYMBOL", function() { return AMPLIFY_SYMBOL; });
|
|
14621
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AWS_APPSYNC_REALTIME_HEADERS", function() { return AWS_APPSYNC_REALTIME_HEADERS; });
|
|
14622
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_INIT_TIMEOUT", function() { return CONNECTION_INIT_TIMEOUT; });
|
|
14623
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "START_ACK_TIMEOUT", function() { return START_ACK_TIMEOUT; });
|
|
14624
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_TIMEOUT; });
|
|
14625
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT; });
|
|
14626
|
+
var MAX_DELAY_MS = 5000;
|
|
14627
|
+
var NON_RETRYABLE_CODES = [400, 401, 403];
|
|
14628
|
+
var MESSAGE_TYPES;
|
|
14629
|
+
|
|
14630
|
+
(function (MESSAGE_TYPES) {
|
|
14631
|
+
/**
|
|
14632
|
+
* Client -> Server message.
|
|
14633
|
+
* This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
|
|
14634
|
+
*/
|
|
14635
|
+
MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
|
|
14636
|
+
/**
|
|
14637
|
+
* Server -> Client message
|
|
14638
|
+
* This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
|
|
14639
|
+
*/
|
|
14640
|
+
|
|
14641
|
+
MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
|
|
14642
|
+
/**
|
|
14643
|
+
* Server -> Client message.
|
|
14644
|
+
* This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
|
|
14645
|
+
*/
|
|
14646
|
+
|
|
14647
|
+
MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
|
|
14648
|
+
/**
|
|
14649
|
+
* Client -> Server message.
|
|
14650
|
+
* This message type is for register subscriptions with AWS AppSync RealTime
|
|
14651
|
+
*/
|
|
14652
|
+
|
|
14653
|
+
MESSAGE_TYPES["GQL_START"] = "start";
|
|
14654
|
+
/**
|
|
14655
|
+
* Server -> Client message.
|
|
14656
|
+
* This message type is for the ack response from AWS AppSync RealTime for GQL_START message
|
|
14657
|
+
*/
|
|
14658
|
+
|
|
14659
|
+
MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
|
|
14660
|
+
/**
|
|
14661
|
+
* Server -> Client message.
|
|
14662
|
+
* This message type is for subscription message from AWS AppSync RealTime
|
|
14663
|
+
*/
|
|
14664
|
+
|
|
14665
|
+
MESSAGE_TYPES["GQL_DATA"] = "data";
|
|
14666
|
+
/**
|
|
14667
|
+
* Server -> Client message.
|
|
14668
|
+
* This message type helps the client to know is still receiving messages from AWS AppSync RealTime
|
|
14669
|
+
*/
|
|
14670
|
+
|
|
14671
|
+
MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
|
|
14672
|
+
/**
|
|
14673
|
+
* Client -> Server message.
|
|
14674
|
+
* This message type is for unregister subscriptions with AWS AppSync RealTime
|
|
14675
|
+
*/
|
|
14676
|
+
|
|
14677
|
+
MESSAGE_TYPES["GQL_STOP"] = "stop";
|
|
14678
|
+
/**
|
|
14679
|
+
* Server -> Client message.
|
|
14680
|
+
* This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
|
|
14681
|
+
*/
|
|
14682
|
+
|
|
14683
|
+
MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
|
|
14684
|
+
/**
|
|
14685
|
+
* Server -> Client message.
|
|
14686
|
+
* This message type is for sending error messages from AWS AppSync RealTime to the client
|
|
14687
|
+
*/
|
|
14688
|
+
|
|
14689
|
+
MESSAGE_TYPES["GQL_ERROR"] = "error";
|
|
14690
|
+
})(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
|
|
14691
|
+
|
|
14692
|
+
var SUBSCRIPTION_STATUS;
|
|
14693
|
+
|
|
14694
|
+
(function (SUBSCRIPTION_STATUS) {
|
|
14695
|
+
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
|
|
14696
|
+
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
|
|
14697
|
+
SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
|
|
14698
|
+
})(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
|
|
14699
|
+
|
|
14700
|
+
var SOCKET_STATUS;
|
|
14701
|
+
|
|
14702
|
+
(function (SOCKET_STATUS) {
|
|
14703
|
+
SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
|
|
14704
|
+
SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
|
|
14705
|
+
SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
|
|
14706
|
+
})(SOCKET_STATUS || (SOCKET_STATUS = {}));
|
|
14707
|
+
|
|
14708
|
+
var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
|
|
14709
|
+
var AWS_APPSYNC_REALTIME_HEADERS = {
|
|
14710
|
+
accept: 'application/json, text/javascript',
|
|
14711
|
+
'content-encoding': 'amz-1.0',
|
|
14712
|
+
'content-type': 'application/json; charset=UTF-8'
|
|
14713
|
+
};
|
|
14714
|
+
/**
|
|
14715
|
+
* Time in milleseconds to wait for GQL_CONNECTION_INIT message
|
|
14716
|
+
*/
|
|
14717
|
+
|
|
14718
|
+
var CONNECTION_INIT_TIMEOUT = 15000;
|
|
14719
|
+
/**
|
|
14720
|
+
* Time in milleseconds to wait for GQL_START_ACK message
|
|
14721
|
+
*/
|
|
14722
|
+
|
|
14723
|
+
var START_ACK_TIMEOUT = 15000;
|
|
14724
|
+
/**
|
|
14725
|
+
* Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
|
|
14726
|
+
*/
|
|
14727
|
+
|
|
14728
|
+
var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
|
|
14729
|
+
/**
|
|
14730
|
+
* Default Time in milleseconds to alert for missed GQL_CONNECTION_KEEP_ALIVE message
|
|
14731
|
+
*/
|
|
14732
|
+
|
|
14733
|
+
var DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = 65 * 1000;
|
|
14734
|
+
|
|
14648
14735
|
/***/ }),
|
|
14649
14736
|
|
|
14650
14737
|
/***/ "../pubsub/lib-esm/Providers/index.js":
|
|
@@ -15078,11 +15165,12 @@ _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Amplify"].register(PubSub);
|
|
|
15078
15165
|
/*!**********************************!*\
|
|
15079
15166
|
!*** ../pubsub/lib-esm/index.js ***!
|
|
15080
15167
|
\**********************************/
|
|
15081
|
-
/*! exports provided: AbstractPubSubProvider, AWSAppSyncProvider, AWSAppSyncRealTimeProvider, AWSIoTProvider, mqttTopicMatch, MqttOverWSProvider, PubSub, CONTROL_MSG, default */
|
|
15168
|
+
/*! exports provided: AbstractPubSubProvider, AWSAppSyncProvider, AWSAppSyncRealTimeProvider, AWSIoTProvider, mqttTopicMatch, MqttOverWSProvider, CONNECTION_STATE_CHANGE, ConnectionState, PubSub, CONTROL_MSG, default */
|
|
15082
15169
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
15083
15170
|
|
|
15084
15171
|
"use strict";
|
|
15085
15172
|
__webpack_require__.r(__webpack_exports__);
|
|
15173
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_STATE_CHANGE", function() { return CONNECTION_STATE_CHANGE; });
|
|
15086
15174
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONTROL_MSG", function() { return CONTROL_MSG; });
|
|
15087
15175
|
/* harmony import */ var _PubSub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PubSub */ "../pubsub/lib-esm/PubSub.js");
|
|
15088
15176
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PubSub", function() { return _PubSub__WEBPACK_IMPORTED_MODULE_0__["PubSub"]; });
|
|
@@ -15100,6 +15188,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
15100
15188
|
|
|
15101
15189
|
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MqttOverWSProvider", function() { return _Providers__WEBPACK_IMPORTED_MODULE_1__["MqttOverWSProvider"]; });
|
|
15102
15190
|
|
|
15191
|
+
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types */ "../pubsub/lib-esm/types/index.js");
|
|
15192
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConnectionState", function() { return _types__WEBPACK_IMPORTED_MODULE_2__["ConnectionState"]; });
|
|
15193
|
+
|
|
15103
15194
|
/*
|
|
15104
15195
|
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
15105
15196
|
*
|
|
@@ -15124,6 +15215,8 @@ var CONTROL_MSG;
|
|
|
15124
15215
|
CONTROL_MSG["TIMEOUT_DISCONNECT"] = "Timeout disconnect";
|
|
15125
15216
|
})(CONTROL_MSG || (CONTROL_MSG = {}));
|
|
15126
15217
|
|
|
15218
|
+
var CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
|
|
15219
|
+
|
|
15127
15220
|
|
|
15128
15221
|
/**
|
|
15129
15222
|
* @deprecated use named import
|
|
@@ -15133,6 +15226,278 @@ var CONTROL_MSG;
|
|
|
15133
15226
|
|
|
15134
15227
|
/***/ }),
|
|
15135
15228
|
|
|
15229
|
+
/***/ "../pubsub/lib-esm/types/index.js":
|
|
15230
|
+
/*!****************************************!*\
|
|
15231
|
+
!*** ../pubsub/lib-esm/types/index.js ***!
|
|
15232
|
+
\****************************************/
|
|
15233
|
+
/*! exports provided: ConnectionState */
|
|
15234
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
15235
|
+
|
|
15236
|
+
"use strict";
|
|
15237
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15238
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConnectionState", function() { return ConnectionState; });
|
|
15239
|
+
/** @enum {string} */
|
|
15240
|
+
var ConnectionState;
|
|
15241
|
+
|
|
15242
|
+
(function (ConnectionState) {
|
|
15243
|
+
/*
|
|
15244
|
+
* The connection is alive and healthy
|
|
15245
|
+
*/
|
|
15246
|
+
ConnectionState["Connected"] = "Connected";
|
|
15247
|
+
/*
|
|
15248
|
+
* The connection is alive, but the connection is offline
|
|
15249
|
+
*/
|
|
15250
|
+
|
|
15251
|
+
ConnectionState["ConnectedPendingNetwork"] = "ConnectedPendingNetwork";
|
|
15252
|
+
/*
|
|
15253
|
+
* The connection has been disconnected while in use
|
|
15254
|
+
*/
|
|
15255
|
+
|
|
15256
|
+
ConnectionState["ConnectionDisrupted"] = "ConnectionDisrupted";
|
|
15257
|
+
/*
|
|
15258
|
+
* The connection has been disconnected and the network is offline
|
|
15259
|
+
*/
|
|
15260
|
+
|
|
15261
|
+
ConnectionState["ConnectionDisruptedPendingNetwork"] = "ConnectionDisruptedPendingNetwork";
|
|
15262
|
+
/*
|
|
15263
|
+
* The connection is in the process of connecting
|
|
15264
|
+
*/
|
|
15265
|
+
|
|
15266
|
+
ConnectionState["Connecting"] = "Connecting";
|
|
15267
|
+
/*
|
|
15268
|
+
* The connection is not in use and is being disconnected
|
|
15269
|
+
*/
|
|
15270
|
+
|
|
15271
|
+
ConnectionState["ConnectedPendingDisconnect"] = "ConnectedPendingDisconnect";
|
|
15272
|
+
/*
|
|
15273
|
+
* The connection is not in use and has been disconnected
|
|
15274
|
+
*/
|
|
15275
|
+
|
|
15276
|
+
ConnectionState["Disconnected"] = "Disconnected";
|
|
15277
|
+
/*
|
|
15278
|
+
* The connection is alive, but a keep alive message has been missed
|
|
15279
|
+
*/
|
|
15280
|
+
|
|
15281
|
+
ConnectionState["ConnectedPendingKeepAlive"] = "ConnectedPendingKeepAlive";
|
|
15282
|
+
})(ConnectionState || (ConnectionState = {}));
|
|
15283
|
+
|
|
15284
|
+
/***/ }),
|
|
15285
|
+
|
|
15286
|
+
/***/ "../pubsub/lib-esm/utils/ConnectionStateMonitor.js":
|
|
15287
|
+
/*!*********************************************************!*\
|
|
15288
|
+
!*** ../pubsub/lib-esm/utils/ConnectionStateMonitor.js ***!
|
|
15289
|
+
\*********************************************************/
|
|
15290
|
+
/*! exports provided: CONNECTION_CHANGE, ConnectionStateMonitor */
|
|
15291
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
15292
|
+
|
|
15293
|
+
"use strict";
|
|
15294
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15295
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_CHANGE", function() { return CONNECTION_CHANGE; });
|
|
15296
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConnectionStateMonitor", function() { return ConnectionStateMonitor; });
|
|
15297
|
+
/* harmony import */ var zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! zen-observable-ts */ "../../node_modules/zen-observable-ts/lib/bundle.esm.js");
|
|
15298
|
+
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index */ "../pubsub/lib-esm/index.js");
|
|
15299
|
+
/* harmony import */ var _ReachabilityMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ReachabilityMonitor */ "../pubsub/lib-esm/utils/ReachabilityMonitor/index.js");
|
|
15300
|
+
/*
|
|
15301
|
+
* Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
15302
|
+
*
|
|
15303
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
15304
|
+
* the License. A copy of the License is located at
|
|
15305
|
+
*
|
|
15306
|
+
* http://aws.amazon.com/apache2.0/
|
|
15307
|
+
*
|
|
15308
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
15309
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
15310
|
+
* and limitations under the License.
|
|
15311
|
+
*/
|
|
15312
|
+
var __assign = undefined && undefined.__assign || function () {
|
|
15313
|
+
__assign = Object.assign || function (t) {
|
|
15314
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
15315
|
+
s = arguments[i];
|
|
15316
|
+
|
|
15317
|
+
for (var p in s) {
|
|
15318
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
15319
|
+
}
|
|
15320
|
+
}
|
|
15321
|
+
|
|
15322
|
+
return t;
|
|
15323
|
+
};
|
|
15324
|
+
|
|
15325
|
+
return __assign.apply(this, arguments);
|
|
15326
|
+
};
|
|
15327
|
+
|
|
15328
|
+
|
|
15329
|
+
|
|
15330
|
+
|
|
15331
|
+
var CONNECTION_CHANGE = {
|
|
15332
|
+
KEEP_ALIVE_MISSED: {
|
|
15333
|
+
keepAliveState: 'unhealthy'
|
|
15334
|
+
},
|
|
15335
|
+
KEEP_ALIVE: {
|
|
15336
|
+
keepAliveState: 'healthy'
|
|
15337
|
+
},
|
|
15338
|
+
CONNECTION_ESTABLISHED: {
|
|
15339
|
+
connectionState: 'connected'
|
|
15340
|
+
},
|
|
15341
|
+
CONNECTION_FAILED: {
|
|
15342
|
+
intendedConnectionState: 'disconnected',
|
|
15343
|
+
connectionState: 'disconnected'
|
|
15344
|
+
},
|
|
15345
|
+
CLOSING_CONNECTION: {
|
|
15346
|
+
intendedConnectionState: 'disconnected'
|
|
15347
|
+
},
|
|
15348
|
+
OPENING_CONNECTION: {
|
|
15349
|
+
intendedConnectionState: 'connected',
|
|
15350
|
+
connectionState: 'connecting'
|
|
15351
|
+
},
|
|
15352
|
+
CLOSED: {
|
|
15353
|
+
connectionState: 'disconnected'
|
|
15354
|
+
},
|
|
15355
|
+
ONLINE: {
|
|
15356
|
+
networkState: 'connected'
|
|
15357
|
+
},
|
|
15358
|
+
OFFLINE: {
|
|
15359
|
+
networkState: 'disconnected'
|
|
15360
|
+
}
|
|
15361
|
+
};
|
|
15362
|
+
|
|
15363
|
+
var ConnectionStateMonitor =
|
|
15364
|
+
/** @class */
|
|
15365
|
+
function () {
|
|
15366
|
+
function ConnectionStateMonitor() {
|
|
15367
|
+
var _this = this;
|
|
15368
|
+
|
|
15369
|
+
this._networkMonitoringSubscription = undefined;
|
|
15370
|
+
this._linkedConnectionState = {
|
|
15371
|
+
networkState: 'connected',
|
|
15372
|
+
connectionState: 'disconnected',
|
|
15373
|
+
intendedConnectionState: 'disconnected',
|
|
15374
|
+
keepAliveState: 'healthy'
|
|
15375
|
+
};
|
|
15376
|
+
this._linkedConnectionStateObservable = new zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__["default"](function (connectionStateObserver) {
|
|
15377
|
+
connectionStateObserver.next(_this._linkedConnectionState);
|
|
15378
|
+
_this._linkedConnectionStateObserver = connectionStateObserver;
|
|
15379
|
+
});
|
|
15380
|
+
}
|
|
15381
|
+
/**
|
|
15382
|
+
* Turn network state monitoring on if it isn't on already
|
|
15383
|
+
*/
|
|
15384
|
+
|
|
15385
|
+
|
|
15386
|
+
ConnectionStateMonitor.prototype.enableNetworkMonitoring = function () {
|
|
15387
|
+
var _this = this; // Maintain the network state based on the reachability monitor
|
|
15388
|
+
|
|
15389
|
+
|
|
15390
|
+
if (this._networkMonitoringSubscription === undefined) {
|
|
15391
|
+
this._networkMonitoringSubscription = Object(_ReachabilityMonitor__WEBPACK_IMPORTED_MODULE_2__["ReachabilityMonitor"])().subscribe(function (_a) {
|
|
15392
|
+
var online = _a.online;
|
|
15393
|
+
|
|
15394
|
+
_this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);
|
|
15395
|
+
});
|
|
15396
|
+
}
|
|
15397
|
+
};
|
|
15398
|
+
/**
|
|
15399
|
+
* Turn network state monitoring off if it isn't off already
|
|
15400
|
+
*/
|
|
15401
|
+
|
|
15402
|
+
|
|
15403
|
+
ConnectionStateMonitor.prototype.disableNetworkMonitoring = function () {
|
|
15404
|
+
var _a;
|
|
15405
|
+
|
|
15406
|
+
(_a = this._networkMonitoringSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
15407
|
+
this._networkMonitoringSubscription = undefined;
|
|
15408
|
+
};
|
|
15409
|
+
|
|
15410
|
+
Object.defineProperty(ConnectionStateMonitor.prototype, "connectionStateObservable", {
|
|
15411
|
+
/**
|
|
15412
|
+
* Get the observable that allows us to monitor the connection state
|
|
15413
|
+
*
|
|
15414
|
+
* @returns {Observable<ConnectionState>} - The observable that emits ConnectionState updates
|
|
15415
|
+
*/
|
|
15416
|
+
get: function get() {
|
|
15417
|
+
var _this = this;
|
|
15418
|
+
|
|
15419
|
+
var previous; // The linked state aggregates state changes to any of the network, connection,
|
|
15420
|
+
// intendedConnection and keepAliveHealth. Some states will change these independent
|
|
15421
|
+
// states without changing the overall connection state.
|
|
15422
|
+
// After translating from linked states to ConnectionState, then remove any duplicates
|
|
15423
|
+
|
|
15424
|
+
return this._linkedConnectionStateObservable.map(function (value) {
|
|
15425
|
+
return _this.connectionStatesTranslator(value);
|
|
15426
|
+
}).filter(function (current) {
|
|
15427
|
+
var toInclude = current !== previous;
|
|
15428
|
+
previous = current;
|
|
15429
|
+
return toInclude;
|
|
15430
|
+
});
|
|
15431
|
+
},
|
|
15432
|
+
enumerable: true,
|
|
15433
|
+
configurable: true
|
|
15434
|
+
});
|
|
15435
|
+
/*
|
|
15436
|
+
* Updates local connection state and emits the full state to the observer.
|
|
15437
|
+
*/
|
|
15438
|
+
|
|
15439
|
+
ConnectionStateMonitor.prototype.record = function (statusUpdates) {
|
|
15440
|
+
// Maintain the network monitor
|
|
15441
|
+
if (statusUpdates.intendedConnectionState === 'connected') {
|
|
15442
|
+
this.enableNetworkMonitoring();
|
|
15443
|
+
} else if (statusUpdates.intendedConnectionState === 'disconnected') {
|
|
15444
|
+
this.disableNetworkMonitoring();
|
|
15445
|
+
} // Maintain the socket state
|
|
15446
|
+
|
|
15447
|
+
|
|
15448
|
+
var newSocketStatus = __assign(__assign({}, this._linkedConnectionState), statusUpdates);
|
|
15449
|
+
|
|
15450
|
+
this._linkedConnectionState = __assign({}, newSocketStatus);
|
|
15451
|
+
|
|
15452
|
+
this._linkedConnectionStateObserver.next(this._linkedConnectionState);
|
|
15453
|
+
};
|
|
15454
|
+
/*
|
|
15455
|
+
* Translate the ConnectionState structure into a specific ConnectionState string literal union
|
|
15456
|
+
*/
|
|
15457
|
+
|
|
15458
|
+
|
|
15459
|
+
ConnectionStateMonitor.prototype.connectionStatesTranslator = function (_a) {
|
|
15460
|
+
var connectionState = _a.connectionState,
|
|
15461
|
+
networkState = _a.networkState,
|
|
15462
|
+
intendedConnectionState = _a.intendedConnectionState,
|
|
15463
|
+
keepAliveState = _a.keepAliveState;
|
|
15464
|
+
if (connectionState === 'connected' && networkState === 'disconnected') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectedPendingNetwork;
|
|
15465
|
+
if (connectionState === 'connected' && intendedConnectionState === 'disconnected') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectedPendingDisconnect;
|
|
15466
|
+
if (connectionState === 'disconnected' && intendedConnectionState === 'connected' && networkState === 'disconnected') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectionDisruptedPendingNetwork;
|
|
15467
|
+
if (connectionState === 'disconnected' && intendedConnectionState === 'connected') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectionDisrupted;
|
|
15468
|
+
if (connectionState === 'connected' && keepAliveState === 'unhealthy') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectedPendingKeepAlive; // All remaining states directly correspond to the connection state
|
|
15469
|
+
|
|
15470
|
+
if (connectionState === 'connecting') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].Connecting;
|
|
15471
|
+
if (connectionState === 'disconnected') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].Disconnected;
|
|
15472
|
+
return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].Connected;
|
|
15473
|
+
};
|
|
15474
|
+
|
|
15475
|
+
return ConnectionStateMonitor;
|
|
15476
|
+
}();
|
|
15477
|
+
|
|
15478
|
+
|
|
15479
|
+
|
|
15480
|
+
/***/ }),
|
|
15481
|
+
|
|
15482
|
+
/***/ "../pubsub/lib-esm/utils/ReachabilityMonitor/index.js":
|
|
15483
|
+
/*!************************************************************!*\
|
|
15484
|
+
!*** ../pubsub/lib-esm/utils/ReachabilityMonitor/index.js ***!
|
|
15485
|
+
\************************************************************/
|
|
15486
|
+
/*! exports provided: ReachabilityMonitor */
|
|
15487
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
15488
|
+
|
|
15489
|
+
"use strict";
|
|
15490
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15491
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReachabilityMonitor", function() { return ReachabilityMonitor; });
|
|
15492
|
+
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
|
|
15493
|
+
/* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__);
|
|
15494
|
+
|
|
15495
|
+
var ReachabilityMonitor = function ReachabilityMonitor() {
|
|
15496
|
+
return new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Reachability"]().networkMonitor();
|
|
15497
|
+
};
|
|
15498
|
+
|
|
15499
|
+
/***/ }),
|
|
15500
|
+
|
|
15136
15501
|
/***/ "./lib-esm/API.js":
|
|
15137
15502
|
/*!************************!*\
|
|
15138
15503
|
!*** ./lib-esm/API.js ***!
|