@aws-amplify/pubsub 4.4.9 → 4.4.10-next.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +73 -0
- package/dist/aws-amplify-pubsub.js +713 -378
- package/dist/aws-amplify-pubsub.js.map +1 -1
- package/dist/aws-amplify-pubsub.min.js +3 -3
- package/dist/aws-amplify-pubsub.min.js.map +1 -1
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +10 -2
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +133 -90
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/lib/Providers/MqttOverWSProvider.d.ts +5 -1
- package/lib/Providers/MqttOverWSProvider.js +152 -87
- package/lib/Providers/MqttOverWSProvider.js.map +1 -1
- package/lib/Providers/PubSubProvider.d.ts +1 -1
- package/lib/Providers/{AWSAppSyncRealTimeProvider/constants.d.ts → constants.d.ts} +9 -0
- package/lib/Providers/{AWSAppSyncRealTimeProvider/constants.js → constants.js} +9 -0
- package/lib/Providers/constants.js.map +1 -0
- package/lib/index.d.ts +3 -10
- package/lib/index.js +3 -10
- package/lib/index.js.map +1 -1
- package/lib/types/Provider.d.ts +10 -1
- package/lib/types/PubSub.d.ts +22 -8
- package/lib/types/PubSub.js +56 -0
- package/lib/types/PubSub.js.map +1 -1
- package/lib/types/index.d.ts +0 -17
- package/lib/types/index.js +4 -36
- package/lib/types/index.js.map +1 -1
- package/lib/utils/ConnectionStateMonitor.d.ts +2 -1
- package/lib/utils/ConnectionStateMonitor.js +21 -13
- package/lib/utils/ConnectionStateMonitor.js.map +1 -1
- package/lib/utils/ReachabilityMonitor/index.d.ts +3 -0
- package/lib/utils/ReachabilityMonitor/index.js +5 -0
- package/lib/utils/ReachabilityMonitor/index.js.map +1 -0
- package/lib/utils/ReachabilityMonitor/index.native.d.ts +3 -0
- package/lib/utils/ReachabilityMonitor/index.native.js +11 -0
- package/lib/utils/ReachabilityMonitor/index.native.js.map +1 -0
- package/lib/utils/ReconnectionMonitor.d.ts +29 -0
- package/lib/utils/ReconnectionMonitor.js +73 -0
- package/lib/utils/ReconnectionMonitor.js.map +1 -0
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +10 -2
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +129 -86
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/lib-esm/Providers/MqttOverWSProvider.d.ts +5 -1
- package/lib-esm/Providers/MqttOverWSProvider.js +153 -88
- package/lib-esm/Providers/MqttOverWSProvider.js.map +1 -1
- package/lib-esm/Providers/PubSubProvider.d.ts +1 -1
- package/lib-esm/Providers/{AWSAppSyncRealTimeProvider/constants.d.ts → constants.d.ts} +9 -0
- package/lib-esm/Providers/{AWSAppSyncRealTimeProvider/constants.js → constants.js} +9 -0
- package/lib-esm/Providers/constants.js.map +1 -0
- package/lib-esm/index.d.ts +3 -10
- package/lib-esm/index.js +3 -11
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/types/Provider.d.ts +10 -1
- package/lib-esm/types/PubSub.d.ts +22 -8
- package/lib-esm/types/PubSub.js +56 -0
- package/lib-esm/types/PubSub.js.map +1 -1
- package/lib-esm/types/index.d.ts +0 -17
- package/lib-esm/types/index.js +1 -36
- package/lib-esm/types/index.js.map +1 -1
- package/lib-esm/utils/ConnectionStateMonitor.d.ts +2 -1
- package/lib-esm/utils/ConnectionStateMonitor.js +13 -5
- package/lib-esm/utils/ConnectionStateMonitor.js.map +1 -1
- package/lib-esm/utils/ReachabilityMonitor/index.d.ts +3 -0
- package/lib-esm/utils/ReachabilityMonitor/index.js +3 -0
- package/lib-esm/utils/ReachabilityMonitor/index.js.map +1 -0
- package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +3 -0
- package/lib-esm/utils/ReachabilityMonitor/index.native.js +6 -0
- package/lib-esm/utils/ReachabilityMonitor/index.native.js.map +1 -0
- package/lib-esm/utils/ReconnectionMonitor.d.ts +29 -0
- package/lib-esm/utils/ReconnectionMonitor.js +71 -0
- package/lib-esm/utils/ReconnectionMonitor.js.map +1 -0
- package/package.json +5 -5
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +154 -90
- package/src/Providers/MqttOverWSProvider.ts +120 -53
- package/src/Providers/PubSubProvider.ts +1 -1
- package/src/Providers/{AWSAppSyncRealTimeProvider/constants.ts → constants.ts} +12 -0
- package/src/index.ts +3 -10
- package/src/types/Provider.ts +13 -1
- package/src/types/PubSub.ts +47 -8
- package/src/types/index.ts +0 -43
- package/src/utils/ConnectionStateMonitor.ts +20 -5
- package/src/utils/ReachabilityMonitor/index.native.ts +5 -0
- package/src/utils/ReachabilityMonitor/index.ts +3 -0
- package/src/utils/ReconnectionMonitor.ts +74 -0
- package/lib/Providers/AWSAppSyncRealTimeProvider/constants.js.map +0 -1
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js.map +0 -1
package/lib/types/PubSub.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PubSub.js","sourceRoot":"","sources":["../../src/types/PubSub.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"PubSub.js","sourceRoot":"","sources":["../../src/types/PubSub.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AASH,IAAY,WAMX;AAND,WAAY,WAAW;IACtB,sDAAuC,CAAA;IACvC,sDAAuC,CAAA;IACvC,4FAA6E,CAAA;IAC7E,oDAAqC,CAAA;IACrC,wDAAyC,CAAA;AAC1C,CAAC,EANW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAMtB;AAED,qBAAqB;AACrB,IAAY,eAiCX;AAjCD,WAAY,eAAe;IAC1B;;OAEG;IACH,0CAAuB,CAAA;IACvB;;OAEG;IACH,sEAAmD,CAAA;IACnD;;OAEG;IACH,8DAA2C,CAAA;IAC3C;;OAEG;IACH,0FAAuE,CAAA;IACvE;;OAEG;IACH,4CAAyB,CAAA;IACzB;;OAEG;IACH,4EAAyD,CAAA;IACzD;;OAEG;IACH,gDAA6B,CAAA;IAC7B;;OAEG;IACH,0EAAuD,CAAA;AACxD,CAAC,EAjCW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAiC1B"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
1
|
export * from './Provider';
|
|
2
2
|
export * from './PubSub';
|
|
3
|
-
export interface SubscriptionObserver<T> {
|
|
4
|
-
closed: boolean;
|
|
5
|
-
next(value: T): void;
|
|
6
|
-
error(errorValue: any): void;
|
|
7
|
-
complete(): void;
|
|
8
|
-
}
|
|
9
|
-
/** @enum {string} */
|
|
10
|
-
export declare enum ConnectionState {
|
|
11
|
-
Connected = "Connected",
|
|
12
|
-
ConnectedPendingNetwork = "ConnectedPendingNetwork",
|
|
13
|
-
ConnectionDisrupted = "ConnectionDisrupted",
|
|
14
|
-
ConnectionDisruptedPendingNetwork = "ConnectionDisruptedPendingNetwork",
|
|
15
|
-
Connecting = "Connecting",
|
|
16
|
-
ConnectedPendingDisconnect = "ConnectedPendingDisconnect",
|
|
17
|
-
Disconnected = "Disconnected",
|
|
18
|
-
ConnectedPendingKeepAlive = "ConnectedPendingKeepAlive"
|
|
19
|
-
}
|
package/lib/types/index.js
CHANGED
|
@@ -1,39 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
function __export(m) {
|
|
3
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
+
}
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
var ConnectionState;
|
|
5
|
-
(function (ConnectionState) {
|
|
6
|
-
/*
|
|
7
|
-
* The connection is alive and healthy
|
|
8
|
-
*/
|
|
9
|
-
ConnectionState["Connected"] = "Connected";
|
|
10
|
-
/*
|
|
11
|
-
* The connection is alive, but the connection is offline
|
|
12
|
-
*/
|
|
13
|
-
ConnectionState["ConnectedPendingNetwork"] = "ConnectedPendingNetwork";
|
|
14
|
-
/*
|
|
15
|
-
* The connection has been disconnected while in use
|
|
16
|
-
*/
|
|
17
|
-
ConnectionState["ConnectionDisrupted"] = "ConnectionDisrupted";
|
|
18
|
-
/*
|
|
19
|
-
* The connection has been disconnected and the network is offline
|
|
20
|
-
*/
|
|
21
|
-
ConnectionState["ConnectionDisruptedPendingNetwork"] = "ConnectionDisruptedPendingNetwork";
|
|
22
|
-
/*
|
|
23
|
-
* The connection is in the process of connecting
|
|
24
|
-
*/
|
|
25
|
-
ConnectionState["Connecting"] = "Connecting";
|
|
26
|
-
/*
|
|
27
|
-
* The connection is not in use and is being disconnected
|
|
28
|
-
*/
|
|
29
|
-
ConnectionState["ConnectedPendingDisconnect"] = "ConnectedPendingDisconnect";
|
|
30
|
-
/*
|
|
31
|
-
* The connection is not in use and has been disconnected
|
|
32
|
-
*/
|
|
33
|
-
ConnectionState["Disconnected"] = "Disconnected";
|
|
34
|
-
/*
|
|
35
|
-
* The connection is alive, but a keep alive message has been missed
|
|
36
|
-
*/
|
|
37
|
-
ConnectionState["ConnectedPendingKeepAlive"] = "ConnectedPendingKeepAlive";
|
|
38
|
-
})(ConnectionState = exports.ConnectionState || (exports.ConnectionState = {}));
|
|
6
|
+
__export(require("./PubSub"));
|
|
39
7
|
//# sourceMappingURL=index.js.map
|
package/lib/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;AAaA,8BAAyB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Observable from 'zen-observable-ts';
|
|
2
|
-
import { ConnectionState } from '../
|
|
2
|
+
import { ConnectionState } from '../types/PubSub';
|
|
3
3
|
declare type LinkedConnectionState = 'connected' | 'disconnected';
|
|
4
4
|
declare type LinkedHealthState = 'healthy' | 'unhealthy';
|
|
5
5
|
declare type LinkedConnectionStates = {
|
|
@@ -19,6 +19,7 @@ export declare class ConnectionStateMonitor {
|
|
|
19
19
|
private _linkedConnectionStateObservable;
|
|
20
20
|
private _linkedConnectionStateObserver;
|
|
21
21
|
private _networkMonitoringSubscription?;
|
|
22
|
+
private _initialNetworkStateSubscription?;
|
|
22
23
|
constructor();
|
|
23
24
|
/**
|
|
24
25
|
* Turn network state monitoring on if it isn't on already
|
|
@@ -26,9 +26,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
var core_1 = require("@aws-amplify/core");
|
|
30
29
|
var zen_observable_ts_1 = __importDefault(require("zen-observable-ts"));
|
|
31
|
-
var
|
|
30
|
+
var PubSub_1 = require("../types/PubSub");
|
|
31
|
+
var ReachabilityMonitor_1 = require("./ReachabilityMonitor");
|
|
32
32
|
exports.CONNECTION_CHANGE = {
|
|
33
33
|
KEEP_ALIVE_MISSED: { keepAliveState: 'unhealthy' },
|
|
34
34
|
KEEP_ALIVE: { keepAliveState: 'healthy' },
|
|
@@ -56,6 +56,13 @@ var ConnectionStateMonitor = /** @class */ (function () {
|
|
|
56
56
|
intendedConnectionState: 'disconnected',
|
|
57
57
|
keepAliveState: 'healthy',
|
|
58
58
|
};
|
|
59
|
+
// Attempt to update the state with the current actual network state
|
|
60
|
+
this._initialNetworkStateSubscription = ReachabilityMonitor_1.ReachabilityMonitor().subscribe(function (_a) {
|
|
61
|
+
var online = _a.online;
|
|
62
|
+
var _b;
|
|
63
|
+
_this.record(online ? exports.CONNECTION_CHANGE.ONLINE : exports.CONNECTION_CHANGE.OFFLINE);
|
|
64
|
+
(_b = _this._initialNetworkStateSubscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
|
|
65
|
+
});
|
|
59
66
|
this._linkedConnectionStateObservable =
|
|
60
67
|
new zen_observable_ts_1.default(function (connectionStateObserver) {
|
|
61
68
|
connectionStateObserver.next(_this._linkedConnectionState);
|
|
@@ -67,11 +74,12 @@ var ConnectionStateMonitor = /** @class */ (function () {
|
|
|
67
74
|
*/
|
|
68
75
|
ConnectionStateMonitor.prototype.enableNetworkMonitoring = function () {
|
|
69
76
|
var _this = this;
|
|
77
|
+
var _a;
|
|
78
|
+
// If no initial network state was discovered, stop trying
|
|
79
|
+
(_a = this._initialNetworkStateSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
70
80
|
// Maintain the network state based on the reachability monitor
|
|
71
81
|
if (this._networkMonitoringSubscription === undefined) {
|
|
72
|
-
this._networkMonitoringSubscription =
|
|
73
|
-
.networkMonitor()
|
|
74
|
-
.subscribe(function (_a) {
|
|
82
|
+
this._networkMonitoringSubscription = ReachabilityMonitor_1.ReachabilityMonitor().subscribe(function (_a) {
|
|
75
83
|
var online = _a.online;
|
|
76
84
|
_this.record(online ? exports.CONNECTION_CHANGE.ONLINE : exports.CONNECTION_CHANGE.OFFLINE);
|
|
77
85
|
});
|
|
@@ -133,25 +141,25 @@ var ConnectionStateMonitor = /** @class */ (function () {
|
|
|
133
141
|
ConnectionStateMonitor.prototype.connectionStatesTranslator = function (_a) {
|
|
134
142
|
var connectionState = _a.connectionState, networkState = _a.networkState, intendedConnectionState = _a.intendedConnectionState, keepAliveState = _a.keepAliveState;
|
|
135
143
|
if (connectionState === 'connected' && networkState === 'disconnected')
|
|
136
|
-
return
|
|
144
|
+
return PubSub_1.ConnectionState.ConnectedPendingNetwork;
|
|
137
145
|
if (connectionState === 'connected' &&
|
|
138
146
|
intendedConnectionState === 'disconnected')
|
|
139
|
-
return
|
|
147
|
+
return PubSub_1.ConnectionState.ConnectedPendingDisconnect;
|
|
140
148
|
if (connectionState === 'disconnected' &&
|
|
141
149
|
intendedConnectionState === 'connected' &&
|
|
142
150
|
networkState === 'disconnected')
|
|
143
|
-
return
|
|
151
|
+
return PubSub_1.ConnectionState.ConnectionDisruptedPendingNetwork;
|
|
144
152
|
if (connectionState === 'disconnected' &&
|
|
145
153
|
intendedConnectionState === 'connected')
|
|
146
|
-
return
|
|
154
|
+
return PubSub_1.ConnectionState.ConnectionDisrupted;
|
|
147
155
|
if (connectionState === 'connected' && keepAliveState === 'unhealthy')
|
|
148
|
-
return
|
|
156
|
+
return PubSub_1.ConnectionState.ConnectedPendingKeepAlive;
|
|
149
157
|
// All remaining states directly correspond to the connection state
|
|
150
158
|
if (connectionState === 'connecting')
|
|
151
|
-
return
|
|
159
|
+
return PubSub_1.ConnectionState.Connecting;
|
|
152
160
|
if (connectionState === 'disconnected')
|
|
153
|
-
return
|
|
154
|
-
return
|
|
161
|
+
return PubSub_1.ConnectionState.Disconnected;
|
|
162
|
+
return PubSub_1.ConnectionState.Connected;
|
|
155
163
|
};
|
|
156
164
|
return ConnectionStateMonitor;
|
|
157
165
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionStateMonitor.js","sourceRoot":"","sources":["../../src/utils/ConnectionStateMonitor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ConnectionStateMonitor.js","sourceRoot":"","sources":["../../src/utils/ConnectionStateMonitor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;AAGH,wEAA8D;AAC9D,0CAAkD;AAClD,6DAA4D;AAY/C,QAAA,iBAAiB,GAW1B;IACH,iBAAiB,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE;IAClD,UAAU,EAAE,EAAE,cAAc,EAAE,SAAS,EAAE;IACzC,sBAAsB,EAAE,EAAE,eAAe,EAAE,WAAW,EAAE;IACxD,iBAAiB,EAAE;QAClB,uBAAuB,EAAE,cAAc;QACvC,eAAe,EAAE,cAAc;KAC/B;IACD,kBAAkB,EAAE,EAAE,uBAAuB,EAAE,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IAAI,CAAC,sBAAsB,CAAC,CAAC;IACvE,CAAC;IAED;;OAEG;IACK,2DAA0B,GAAlC,UAAmC,EAKV;YAJxB,oCAAe,EACf,8BAAY,EACZ,oDAAuB,EACvB,kCAAc;QAEd,IAAI,eAAe,KAAK,WAAW,IAAI,YAAY,KAAK,cAAc;YACrE,OAAO,wBAAe,CAAC,uBAAuB,CAAC;QAEhD,IACC,eAAe,KAAK,WAAW;YAC/B,uBAAuB,KAAK,cAAc;YAE1C,OAAO,wBAAe,CAAC,0BAA0B,CAAC;QAEnD,IACC,eAAe,KAAK,cAAc;YAClC,uBAAuB,KAAK,WAAW;YACvC,YAAY,KAAK,cAAc;YAE/B,OAAO,wBAAe,CAAC,iCAAiC,CAAC;QAE1D,IACC,eAAe,KAAK,cAAc;YAClC,uBAAuB,KAAK,WAAW;YAEvC,OAAO,wBAAe,CAAC,mBAAmB,CAAC;QAE5C,IAAI,eAAe,KAAK,WAAW,IAAI,cAAc,KAAK,WAAW;YACpE,OAAO,wBAAe,CAAC,yBAAyB,CAAC;QAElD,mEAAmE;QACnE,IAAI,eAAe,KAAK,YAAY;YAAE,OAAO,wBAAe,CAAC,UAAU,CAAC;QACxE,IAAI,eAAe,KAAK,cAAc;YAAE,OAAO,wBAAe,CAAC,YAAY,CAAC;QAC5E,OAAO,wBAAe,CAAC,SAAS,CAAC;IAClC,CAAC;IACF,6BAAC;AAAD,CAAC,AApJD,IAoJC;AApJY,wDAAsB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/ReachabilityMonitor/index.ts"],"names":[],"mappings":";;AAAA,0CAAiD;AAEpC,QAAA,mBAAmB,GAAG,cAAM,OAAA,IAAI,mBAAY,EAAE,CAAC,cAAc,EAAE,EAAnC,CAAmC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var core_1 = require("@aws-amplify/core");
|
|
7
|
+
var netinfo_1 = __importDefault(require("@react-native-community/netinfo"));
|
|
8
|
+
exports.ReachabilityMonitor = function () {
|
|
9
|
+
return new core_1.Reachability().networkMonitor(netinfo_1.default);
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.native.js","sourceRoot":"","sources":["../../../src/utils/ReachabilityMonitor/index.native.ts"],"names":[],"mappings":";;;;;AAAA,0CAAiD;AACjD,4EAAqE;AAExD,QAAA,mBAAmB,GAAG;IAClC,OAAA,IAAI,mBAAY,EAAE,CAAC,cAAc,CAAC,iBAAO,CAAC;AAA1C,CAA0C,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Observer } from 'zen-observable-ts';
|
|
2
|
+
export declare enum ReconnectEvent {
|
|
3
|
+
START_RECONNECT = "START_RECONNECT",
|
|
4
|
+
HALT_RECONNECT = "HALT_RECONNECT"
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Captures the reconnect event logic used to determine when to reconnect to PubSub providers.
|
|
8
|
+
* Reconnnect attempts are delayed by 5 seconds to let the interface settle.
|
|
9
|
+
* Attempting to reconnect only once creates unrecoverable states when the network state isn't
|
|
10
|
+
* supported by the browser, so this keeps retrying every minute until halted.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ReconnectionMonitor {
|
|
13
|
+
private reconnectObservers;
|
|
14
|
+
private reconnectIntervalId?;
|
|
15
|
+
private reconnectSetTimeoutId?;
|
|
16
|
+
/**
|
|
17
|
+
* Add reconnect observer to the list of observers to alert on reconnect
|
|
18
|
+
*/
|
|
19
|
+
addObserver(reconnectObserver: Observer<void>): void;
|
|
20
|
+
/**
|
|
21
|
+
* Given a reconnect event, start the appropriate behavior
|
|
22
|
+
*/
|
|
23
|
+
record(event: ReconnectEvent): void;
|
|
24
|
+
/**
|
|
25
|
+
* Complete all reconnect observers
|
|
26
|
+
*/
|
|
27
|
+
close(): void;
|
|
28
|
+
private _triggerReconnect;
|
|
29
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var constants_1 = require("../Providers/constants");
|
|
4
|
+
var ReconnectEvent;
|
|
5
|
+
(function (ReconnectEvent) {
|
|
6
|
+
ReconnectEvent["START_RECONNECT"] = "START_RECONNECT";
|
|
7
|
+
ReconnectEvent["HALT_RECONNECT"] = "HALT_RECONNECT";
|
|
8
|
+
})(ReconnectEvent = exports.ReconnectEvent || (exports.ReconnectEvent = {}));
|
|
9
|
+
/**
|
|
10
|
+
* Captures the reconnect event logic used to determine when to reconnect to PubSub providers.
|
|
11
|
+
* Reconnnect attempts are delayed by 5 seconds to let the interface settle.
|
|
12
|
+
* Attempting to reconnect only once creates unrecoverable states when the network state isn't
|
|
13
|
+
* supported by the browser, so this keeps retrying every minute until halted.
|
|
14
|
+
*/
|
|
15
|
+
var ReconnectionMonitor = /** @class */ (function () {
|
|
16
|
+
function ReconnectionMonitor() {
|
|
17
|
+
this.reconnectObservers = [];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Add reconnect observer to the list of observers to alert on reconnect
|
|
21
|
+
*/
|
|
22
|
+
ReconnectionMonitor.prototype.addObserver = function (reconnectObserver) {
|
|
23
|
+
this.reconnectObservers.push(reconnectObserver);
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Given a reconnect event, start the appropriate behavior
|
|
27
|
+
*/
|
|
28
|
+
ReconnectionMonitor.prototype.record = function (event) {
|
|
29
|
+
var _this = this;
|
|
30
|
+
if (event === ReconnectEvent.START_RECONNECT) {
|
|
31
|
+
// If the reconnection hasn't been started
|
|
32
|
+
if (this.reconnectSetTimeoutId === undefined &&
|
|
33
|
+
this.reconnectIntervalId === undefined) {
|
|
34
|
+
this.reconnectSetTimeoutId = setTimeout(function () {
|
|
35
|
+
// Reconnect now
|
|
36
|
+
_this._triggerReconnect();
|
|
37
|
+
// Retry reconnect every periodically until it works
|
|
38
|
+
_this.reconnectIntervalId = setInterval(function () {
|
|
39
|
+
_this._triggerReconnect();
|
|
40
|
+
}, constants_1.RECONNECT_INTERVAL);
|
|
41
|
+
}, constants_1.RECONNECT_DELAY);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (event === ReconnectEvent.HALT_RECONNECT) {
|
|
45
|
+
if (this.reconnectIntervalId) {
|
|
46
|
+
clearInterval(this.reconnectIntervalId);
|
|
47
|
+
this.reconnectIntervalId = undefined;
|
|
48
|
+
}
|
|
49
|
+
if (this.reconnectSetTimeoutId) {
|
|
50
|
+
clearTimeout(this.reconnectSetTimeoutId);
|
|
51
|
+
this.reconnectSetTimeoutId = undefined;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Complete all reconnect observers
|
|
57
|
+
*/
|
|
58
|
+
ReconnectionMonitor.prototype.close = function () {
|
|
59
|
+
this.reconnectObservers.forEach(function (reconnectObserver) {
|
|
60
|
+
var _a;
|
|
61
|
+
(_a = reconnectObserver.complete) === null || _a === void 0 ? void 0 : _a.call(reconnectObserver);
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
ReconnectionMonitor.prototype._triggerReconnect = function () {
|
|
65
|
+
this.reconnectObservers.forEach(function (reconnectObserver) {
|
|
66
|
+
var _a;
|
|
67
|
+
(_a = reconnectObserver.next) === null || _a === void 0 ? void 0 : _a.call(reconnectObserver);
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
return ReconnectionMonitor;
|
|
71
|
+
}());
|
|
72
|
+
exports.ReconnectionMonitor = ReconnectionMonitor;
|
|
73
|
+
//# sourceMappingURL=ReconnectionMonitor.js.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AAC,qBAAqB,CAAC,CAAC;gBACzC,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC;aACvC;SACD;IACF,CAAC;IAED;;OAEG;IACH,mCAAK,GAAL;QACC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,UAAA,iBAAiB;;YAChD,MAAA,iBAAiB,CAAC,QAAQ,+CAA1B,iBAAiB,EAAc;QAChC,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,+CAAiB,GAAzB;QACC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,UAAA,iBAAiB;;YAChD,MAAA,iBAAiB,CAAC,IAAI,+CAAtB,iBAAiB,EAAU;QAC5B,CAAC,CAAC,CAAC;IACJ,CAAC;IACF,0BAAC;AAAD,CAAC,AA3DD,IA2DC;AA3DY,kDAAmB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Observable, { ZenObservable } from 'zen-observable-ts';
|
|
2
|
-
import { ProviderOptions } from '../../types';
|
|
2
|
+
import { ProviderOptions } from '../../types/Provider';
|
|
3
3
|
import { GRAPHQL_AUTH_MODE } from '@aws-amplify/auth';
|
|
4
4
|
import { AbstractPubSubProvider } from '../PubSubProvider';
|
|
5
|
-
import { SUBSCRIPTION_STATUS } from '
|
|
5
|
+
import { SUBSCRIPTION_STATUS } from '../constants';
|
|
6
6
|
export declare type ObserverQuery = {
|
|
7
7
|
observer: ZenObservable.SubscriptionObserver<any>;
|
|
8
8
|
query: string;
|
|
@@ -33,8 +33,15 @@ export declare class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
|
33
33
|
private keepAliveAlertTimeoutId?;
|
|
34
34
|
private subscriptionObserverMap;
|
|
35
35
|
private promiseArray;
|
|
36
|
+
private connectionState;
|
|
36
37
|
private readonly connectionStateMonitor;
|
|
38
|
+
private readonly reconnectionMonitor;
|
|
39
|
+
private connectionStateMonitorSubscription;
|
|
37
40
|
constructor(options?: ProviderOptions);
|
|
41
|
+
/**
|
|
42
|
+
* Mark the socket closed and release all active listeners
|
|
43
|
+
*/
|
|
44
|
+
close(): void;
|
|
38
45
|
getNewWebSocket(url: any, protocol: any): WebSocket;
|
|
39
46
|
getProviderName(): string;
|
|
40
47
|
newClient(): Promise<any>;
|
|
@@ -43,6 +50,7 @@ export declare class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
|
43
50
|
subscribe(_topics: string[] | string, options?: AWSAppSyncRealTimeProviderOptions): Observable<any>;
|
|
44
51
|
protected get isSSLEnabled(): boolean;
|
|
45
52
|
private _startSubscriptionWithAWSAppSyncRealTime;
|
|
53
|
+
private _logStartSubscriptionError;
|
|
46
54
|
private _waitForSubscriptionToBeConnected;
|
|
47
55
|
private _sendUnsubscriptionMessage;
|
|
48
56
|
private _removeSubscriptionObserver;
|