@aws-amplify/pubsub 4.2.6-custom-pk.97 → 4.2.6-custom-pk.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +28 -108
  2. package/dist/aws-amplify-pubsub.js +506 -141
  3. package/dist/aws-amplify-pubsub.js.map +1 -1
  4. package/dist/aws-amplify-pubsub.min.js +2 -2
  5. package/dist/aws-amplify-pubsub.min.js.map +1 -1
  6. package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +4 -1
  7. package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +41 -12
  8. package/lib/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
  9. package/lib/Providers/MqttOverWSProvider.d.ts +1 -0
  10. package/lib/Providers/MqttOverWSProvider.js +23 -1
  11. package/lib/Providers/MqttOverWSProvider.js.map +1 -1
  12. package/lib/Providers/{AWSAppSyncRealTimeProvider/constants.d.ts → constants.d.ts} +4 -0
  13. package/lib/Providers/{AWSAppSyncRealTimeProvider/constants.js → constants.js} +4 -0
  14. package/lib/Providers/constants.js.map +1 -0
  15. package/lib/index.d.ts +2 -0
  16. package/lib/index.js +3 -0
  17. package/lib/index.js.map +1 -1
  18. package/lib/types/index.d.ts +11 -0
  19. package/lib/types/index.js +36 -0
  20. package/lib/types/index.js.map +1 -1
  21. package/lib/utils/ConnectionStateMonitor.d.ts +40 -0
  22. package/lib/utils/ConnectionStateMonitor.js +157 -0
  23. package/lib/utils/ConnectionStateMonitor.js.map +1 -0
  24. package/lib/utils/ReachabilityMonitor/index.d.ts +3 -0
  25. package/lib/utils/ReachabilityMonitor/index.js +5 -0
  26. package/lib/utils/ReachabilityMonitor/index.js.map +1 -0
  27. package/lib/utils/ReachabilityMonitor/index.native.d.ts +3 -0
  28. package/lib/utils/ReachabilityMonitor/index.native.js +11 -0
  29. package/lib/utils/ReachabilityMonitor/index.native.js.map +1 -0
  30. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +4 -1
  31. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +42 -13
  32. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
  33. package/lib-esm/Providers/MqttOverWSProvider.d.ts +1 -0
  34. package/lib-esm/Providers/MqttOverWSProvider.js +24 -2
  35. package/lib-esm/Providers/MqttOverWSProvider.js.map +1 -1
  36. package/lib-esm/Providers/{AWSAppSyncRealTimeProvider/constants.d.ts → constants.d.ts} +4 -0
  37. package/lib-esm/Providers/{AWSAppSyncRealTimeProvider/constants.js → constants.js} +4 -0
  38. package/lib-esm/Providers/constants.js.map +1 -0
  39. package/lib-esm/index.d.ts +2 -0
  40. package/lib-esm/index.js +2 -0
  41. package/lib-esm/index.js.map +1 -1
  42. package/lib-esm/types/index.d.ts +11 -0
  43. package/lib-esm/types/index.js +36 -0
  44. package/lib-esm/types/index.js.map +1 -1
  45. package/lib-esm/utils/ConnectionStateMonitor.d.ts +40 -0
  46. package/lib-esm/utils/ConnectionStateMonitor.js +152 -0
  47. package/lib-esm/utils/ConnectionStateMonitor.js.map +1 -0
  48. package/lib-esm/utils/ReachabilityMonitor/index.d.ts +3 -0
  49. package/lib-esm/utils/ReachabilityMonitor/index.js +3 -0
  50. package/lib-esm/utils/ReachabilityMonitor/index.js.map +1 -0
  51. package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +3 -0
  52. package/lib-esm/utils/ReachabilityMonitor/index.native.js +6 -0
  53. package/lib-esm/utils/ReachabilityMonitor/index.native.js.map +1 -0
  54. package/package.json +5 -5
  55. package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +67 -15
  56. package/src/Providers/MqttOverWSProvider.ts +43 -2
  57. package/src/Providers/{AWSAppSyncRealTimeProvider/constants.ts → constants.ts} +5 -0
  58. package/src/index.ts +3 -0
  59. package/src/types/index.ts +36 -0
  60. package/src/utils/ConnectionStateMonitor.ts +192 -0
  61. package/src/utils/ReachabilityMonitor/index.native.ts +5 -0
  62. package/src/utils/ReachabilityMonitor/index.ts +3 -0
  63. package/lib/Providers/AWSAppSyncRealTimeProvider/constants.js.map +0 -1
  64. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/Providers/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,YAAY,GAAG,IAAI,CAAC;AAEjC,MAAM,CAAC,IAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAEnD,MAAM,CAAN,IAAY,aAmDX;AAnDD,WAAY,aAAa;IACxB;;;OAGG;IACH,wDAAuC,CAAA;IACvC;;;OAGG;IACH,0DAAyC,CAAA;IACzC;;;OAGG;IACH,sDAAqC,CAAA;IACrC;;;OAGG;IACH,oCAAmB,CAAA;IACnB;;;OAGG;IACH,4CAA2B,CAAA;IAC3B;;;OAGG;IACH,kCAAiB,CAAA;IACjB;;;OAGG;IACH,iDAAgC,CAAA;IAChC;;;OAGG;IACH,kCAAiB,CAAA;IACjB;;;OAGG;IACH,0CAAyB,CAAA;IACzB;;;OAGG;IACH,oCAAmB,CAAA;AACpB,CAAC,EAnDW,aAAa,KAAb,aAAa,QAmDxB;AAED,MAAM,CAAN,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC9B,mEAAO,CAAA;IACP,uEAAS,CAAA;IACT,iEAAM,CAAA;AACP,CAAC,EAJW,mBAAmB,KAAnB,mBAAmB,QAI9B;AAED,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACxB,qDAAM,CAAA;IACN,mDAAK,CAAA;IACL,6DAAU,CAAA;AACX,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAED,MAAM,CAAC,IAAM,cAAc,GAAG,CAC7B,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,UAAU;IAChE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAC/B,CAAC,CAAC,mBAAmB,CACZ,CAAC;AAEZ,MAAM,CAAC,IAAM,4BAA4B,GAAG;IAC3C,MAAM,EAAE,mCAAmC;IAC3C,kBAAkB,EAAE,SAAS;IAC7B,cAAc,EAAE,iCAAiC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,IAAM,uBAAuB,GAAG,KAAK,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,IAAM,iBAAiB,GAAG,KAAK,CAAC;AAEvC;;GAEG;AACH,MAAM,CAAC,IAAM,0BAA0B,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAExD;;GAEG;AACH,MAAM,CAAC,IAAM,gCAAgC,GAAG,EAAE,GAAG,IAAI,CAAC"}
@@ -7,6 +7,8 @@ declare enum CONTROL_MSG {
7
7
  SUBSCRIPTION_ACK = "Subscription ack",
8
8
  TIMEOUT_DISCONNECT = "Timeout disconnect"
9
9
  }
10
+ export declare const CONNECTION_STATE_CHANGE = "ConnectionStateChange";
11
+ export { ConnectionState } from './types';
10
12
  export { PubSub, CONTROL_MSG };
11
13
  /**
12
14
  * @deprecated use named import
package/lib-esm/index.js CHANGED
@@ -20,6 +20,8 @@ var CONTROL_MSG;
20
20
  CONTROL_MSG["SUBSCRIPTION_ACK"] = "Subscription ack";
21
21
  CONTROL_MSG["TIMEOUT_DISCONNECT"] = "Timeout disconnect";
22
22
  })(CONTROL_MSG || (CONTROL_MSG = {}));
23
+ export var CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
24
+ export { ConnectionState } from './types';
23
25
  export { PubSub, CONTROL_MSG };
24
26
  /**
25
27
  * @deprecated use named import
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,cAAc,aAAa,CAAC;AAE5B,IAAK,WAMJ;AAND,WAAK,WAAW;IACf,sDAAuC,CAAA;IACvC,sDAAuC,CAAA;IACvC,4FAA6E,CAAA;IAC7E,oDAAqC,CAAA;IACrC,wDAAyC,CAAA;AAC1C,CAAC,EANI,WAAW,KAAX,WAAW,QAMf;AAED,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAE/B;;GAEG;AACH,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,cAAc,aAAa,CAAC;AAE5B,IAAK,WAMJ;AAND,WAAK,WAAW;IACf,sDAAuC,CAAA;IACvC,sDAAuC,CAAA;IACvC,4FAA6E,CAAA;IAC7E,oDAAqC,CAAA;IACrC,wDAAyC,CAAA;AAC1C,CAAC,EANI,WAAW,KAAX,WAAW,QAMf;AAED,MAAM,CAAC,IAAM,uBAAuB,GAAG,uBAAuB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAE/B;;GAEG;AACH,eAAe,MAAM,CAAC"}
@@ -6,3 +6,14 @@ export interface SubscriptionObserver<T> {
6
6
  error(errorValue: any): void;
7
7
  complete(): void;
8
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
+ }
@@ -1 +1,37 @@
1
+ /** @enum {string} */
2
+ export var ConnectionState;
3
+ (function (ConnectionState) {
4
+ /*
5
+ * The connection is alive and healthy
6
+ */
7
+ ConnectionState["Connected"] = "Connected";
8
+ /*
9
+ * The connection is alive, but the connection is offline
10
+ */
11
+ ConnectionState["ConnectedPendingNetwork"] = "ConnectedPendingNetwork";
12
+ /*
13
+ * The connection has been disconnected while in use
14
+ */
15
+ ConnectionState["ConnectionDisrupted"] = "ConnectionDisrupted";
16
+ /*
17
+ * The connection has been disconnected and the network is offline
18
+ */
19
+ ConnectionState["ConnectionDisruptedPendingNetwork"] = "ConnectionDisruptedPendingNetwork";
20
+ /*
21
+ * The connection is in the process of connecting
22
+ */
23
+ ConnectionState["Connecting"] = "Connecting";
24
+ /*
25
+ * The connection is not in use and is being disconnected
26
+ */
27
+ ConnectionState["ConnectedPendingDisconnect"] = "ConnectedPendingDisconnect";
28
+ /*
29
+ * The connection is not in use and has been disconnected
30
+ */
31
+ ConnectionState["Disconnected"] = "Disconnected";
32
+ /*
33
+ * The connection is alive, but a keep alive message has been missed
34
+ */
35
+ ConnectionState["ConnectedPendingKeepAlive"] = "ConnectedPendingKeepAlive";
36
+ })(ConnectionState || (ConnectionState = {}));
1
37
  //# sourceMappingURL=index.js.map
@@ -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":"AAsBA,qBAAqB;AACrB,MAAM,CAAN,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,KAAf,eAAe,QAiC1B"}
@@ -0,0 +1,40 @@
1
+ import Observable from 'zen-observable-ts';
2
+ import { ConnectionState } from '../index';
3
+ declare type LinkedConnectionState = 'connected' | 'disconnected';
4
+ declare type LinkedHealthState = 'healthy' | 'unhealthy';
5
+ declare type LinkedConnectionStates = {
6
+ networkState: LinkedConnectionState;
7
+ connectionState: LinkedConnectionState | 'connecting';
8
+ intendedConnectionState: LinkedConnectionState;
9
+ keepAliveState: LinkedHealthState;
10
+ };
11
+ export declare const CONNECTION_CHANGE: {
12
+ [key in 'KEEP_ALIVE_MISSED' | 'KEEP_ALIVE' | 'CONNECTION_ESTABLISHED' | 'CONNECTION_FAILED' | 'CLOSING_CONNECTION' | 'OPENING_CONNECTION' | 'CLOSED' | 'ONLINE' | 'OFFLINE']: Partial<LinkedConnectionStates>;
13
+ };
14
+ export declare class ConnectionStateMonitor {
15
+ /**
16
+ * @private
17
+ */
18
+ private _linkedConnectionState;
19
+ private _linkedConnectionStateObservable;
20
+ private _linkedConnectionStateObserver;
21
+ private _networkMonitoringSubscription?;
22
+ constructor();
23
+ /**
24
+ * Turn network state monitoring on if it isn't on already
25
+ */
26
+ private enableNetworkMonitoring;
27
+ /**
28
+ * Turn network state monitoring off if it isn't off already
29
+ */
30
+ private disableNetworkMonitoring;
31
+ /**
32
+ * Get the observable that allows us to monitor the connection state
33
+ *
34
+ * @returns {Observable<ConnectionState>} - The observable that emits ConnectionState updates
35
+ */
36
+ get connectionStateObservable(): Observable<ConnectionState>;
37
+ record(statusUpdates: Partial<LinkedConnectionStates>): void;
38
+ private connectionStatesTranslator;
39
+ }
40
+ export {};
@@ -0,0 +1,152 @@
1
+ /*
2
+ * Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
5
+ * the License. A copy of the License is located at
6
+ *
7
+ * http://aws.amazon.com/apache2.0/
8
+ *
9
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
11
+ * and limitations under the License.
12
+ */
13
+ var __assign = (this && this.__assign) || function () {
14
+ __assign = Object.assign || function(t) {
15
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
16
+ s = arguments[i];
17
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
18
+ t[p] = s[p];
19
+ }
20
+ return t;
21
+ };
22
+ return __assign.apply(this, arguments);
23
+ };
24
+ import Observable from 'zen-observable-ts';
25
+ import { ConnectionState } from '../index';
26
+ import { ReachabilityMonitor } from './ReachabilityMonitor';
27
+ export var CONNECTION_CHANGE = {
28
+ KEEP_ALIVE_MISSED: { keepAliveState: 'unhealthy' },
29
+ KEEP_ALIVE: { keepAliveState: 'healthy' },
30
+ CONNECTION_ESTABLISHED: { connectionState: 'connected' },
31
+ CONNECTION_FAILED: {
32
+ intendedConnectionState: 'disconnected',
33
+ connectionState: 'disconnected',
34
+ },
35
+ CLOSING_CONNECTION: { intendedConnectionState: 'disconnected' },
36
+ OPENING_CONNECTION: {
37
+ intendedConnectionState: 'connected',
38
+ connectionState: 'connecting',
39
+ },
40
+ CLOSED: { connectionState: 'disconnected' },
41
+ ONLINE: { networkState: 'connected' },
42
+ OFFLINE: { networkState: 'disconnected' },
43
+ };
44
+ var ConnectionStateMonitor = /** @class */ (function () {
45
+ function ConnectionStateMonitor() {
46
+ var _this = this;
47
+ this._networkMonitoringSubscription = undefined;
48
+ this._linkedConnectionState = {
49
+ networkState: 'connected',
50
+ connectionState: 'disconnected',
51
+ intendedConnectionState: 'disconnected',
52
+ keepAliveState: 'healthy',
53
+ };
54
+ this._linkedConnectionStateObservable =
55
+ new Observable(function (connectionStateObserver) {
56
+ connectionStateObserver.next(_this._linkedConnectionState);
57
+ _this._linkedConnectionStateObserver = connectionStateObserver;
58
+ });
59
+ }
60
+ /**
61
+ * Turn network state monitoring on if it isn't on already
62
+ */
63
+ ConnectionStateMonitor.prototype.enableNetworkMonitoring = function () {
64
+ var _this = this;
65
+ // Maintain the network state based on the reachability monitor
66
+ if (this._networkMonitoringSubscription === undefined) {
67
+ this._networkMonitoringSubscription = ReachabilityMonitor().subscribe(function (_a) {
68
+ var online = _a.online;
69
+ _this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);
70
+ });
71
+ }
72
+ };
73
+ /**
74
+ * Turn network state monitoring off if it isn't off already
75
+ */
76
+ ConnectionStateMonitor.prototype.disableNetworkMonitoring = function () {
77
+ var _a;
78
+ (_a = this._networkMonitoringSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
79
+ this._networkMonitoringSubscription = undefined;
80
+ };
81
+ Object.defineProperty(ConnectionStateMonitor.prototype, "connectionStateObservable", {
82
+ /**
83
+ * Get the observable that allows us to monitor the connection state
84
+ *
85
+ * @returns {Observable<ConnectionState>} - The observable that emits ConnectionState updates
86
+ */
87
+ get: function () {
88
+ var _this = this;
89
+ var previous;
90
+ // The linked state aggregates state changes to any of the network, connection,
91
+ // intendedConnection and keepAliveHealth. Some states will change these independent
92
+ // states without changing the overall connection state.
93
+ // After translating from linked states to ConnectionState, then remove any duplicates
94
+ return this._linkedConnectionStateObservable
95
+ .map(function (value) {
96
+ return _this.connectionStatesTranslator(value);
97
+ })
98
+ .filter(function (current) {
99
+ var toInclude = current !== previous;
100
+ previous = current;
101
+ return toInclude;
102
+ });
103
+ },
104
+ enumerable: true,
105
+ configurable: true
106
+ });
107
+ /*
108
+ * Updates local connection state and emits the full state to the observer.
109
+ */
110
+ ConnectionStateMonitor.prototype.record = function (statusUpdates) {
111
+ // Maintain the network monitor
112
+ if (statusUpdates.intendedConnectionState === 'connected') {
113
+ this.enableNetworkMonitoring();
114
+ }
115
+ else if (statusUpdates.intendedConnectionState === 'disconnected') {
116
+ this.disableNetworkMonitoring();
117
+ }
118
+ // Maintain the socket state
119
+ var newSocketStatus = __assign(__assign({}, this._linkedConnectionState), statusUpdates);
120
+ this._linkedConnectionState = __assign({}, newSocketStatus);
121
+ this._linkedConnectionStateObserver.next(this._linkedConnectionState);
122
+ };
123
+ /*
124
+ * Translate the ConnectionState structure into a specific ConnectionState string literal union
125
+ */
126
+ ConnectionStateMonitor.prototype.connectionStatesTranslator = function (_a) {
127
+ var connectionState = _a.connectionState, networkState = _a.networkState, intendedConnectionState = _a.intendedConnectionState, keepAliveState = _a.keepAliveState;
128
+ if (connectionState === 'connected' && networkState === 'disconnected')
129
+ return ConnectionState.ConnectedPendingNetwork;
130
+ if (connectionState === 'connected' &&
131
+ intendedConnectionState === 'disconnected')
132
+ return ConnectionState.ConnectedPendingDisconnect;
133
+ if (connectionState === 'disconnected' &&
134
+ intendedConnectionState === 'connected' &&
135
+ networkState === 'disconnected')
136
+ return ConnectionState.ConnectionDisruptedPendingNetwork;
137
+ if (connectionState === 'disconnected' &&
138
+ intendedConnectionState === 'connected')
139
+ return ConnectionState.ConnectionDisrupted;
140
+ if (connectionState === 'connected' && keepAliveState === 'unhealthy')
141
+ return ConnectionState.ConnectedPendingKeepAlive;
142
+ // All remaining states directly correspond to the connection state
143
+ if (connectionState === 'connecting')
144
+ return ConnectionState.Connecting;
145
+ if (connectionState === 'disconnected')
146
+ return ConnectionState.Disconnected;
147
+ return ConnectionState.Connected;
148
+ };
149
+ return ConnectionStateMonitor;
150
+ }());
151
+ export { ConnectionStateMonitor };
152
+ //# sourceMappingURL=ConnectionStateMonitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionStateMonitor.js","sourceRoot":"","sources":["../../src/utils/ConnectionStateMonitor.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,3 @@
1
+ export declare const ReachabilityMonitor: () => import("zen-observable-ts").default<{
2
+ online: boolean;
3
+ }>;
@@ -0,0 +1,3 @@
1
+ import { Reachability } from '@aws-amplify/core';
2
+ export var ReachabilityMonitor = function () { return new Reachability().networkMonitor(); };
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/ReachabilityMonitor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,IAAM,mBAAmB,GAAG,cAAM,OAAA,IAAI,YAAY,EAAE,CAAC,cAAc,EAAE,EAAnC,CAAmC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const ReachabilityMonitor: () => import("zen-observable-ts").default<{
2
+ online: boolean;
3
+ }>;
@@ -0,0 +1,6 @@
1
+ import { Reachability } from '@aws-amplify/core';
2
+ import { default as NetInfo } from '@react-native-community/netinfo';
3
+ export var ReachabilityMonitor = function () {
4
+ return new Reachability().networkMonitor(NetInfo);
5
+ };
6
+ //# 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,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAErE,MAAM,CAAC,IAAM,mBAAmB,GAAG;IAClC,OAAA,IAAI,YAAY,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC;AAA1C,CAA0C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/pubsub",
3
- "version": "4.2.6-custom-pk.97+f42d7ac04",
3
+ "version": "4.2.6-custom-pk.98+b9656543b",
4
4
  "description": "Pubsub category of aws-amplify",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
@@ -45,9 +45,9 @@
45
45
  "cpx": "^1.5.0"
46
46
  },
47
47
  "dependencies": {
48
- "@aws-amplify/auth": "4.3.20-custom-pk.97+f42d7ac04",
49
- "@aws-amplify/cache": "4.0.32-custom-pk.97+f42d7ac04",
50
- "@aws-amplify/core": "4.3.12-custom-pk.97+f42d7ac04",
48
+ "@aws-amplify/auth": "4.3.20-custom-pk.98+b9656543b",
49
+ "@aws-amplify/cache": "4.0.32-custom-pk.98+b9656543b",
50
+ "@aws-amplify/core": "4.3.12-custom-pk.98+b9656543b",
51
51
  "graphql": "15.8.0",
52
52
  "paho-mqtt": "^1.1.0",
53
53
  "uuid": "^3.2.1",
@@ -103,5 +103,5 @@
103
103
  "lib-esm"
104
104
  ]
105
105
  },
106
- "gitHead": "f42d7ac045b4421c1da433e051f91c41b568c03c"
106
+ "gitHead": "b9656543bd5572aa18162805a2370d676961563e"
107
107
  }
@@ -30,19 +30,25 @@ import {
30
30
  import Cache from '@aws-amplify/cache';
31
31
  import Auth, { GRAPHQL_AUTH_MODE } from '@aws-amplify/auth';
32
32
  import { AbstractPubSubProvider } from '../PubSubProvider';
33
- import { CONTROL_MSG } from '../../index';
33
+ import { CONNECTION_STATE_CHANGE, CONTROL_MSG } from '../../index';
34
+
34
35
  import {
35
36
  AMPLIFY_SYMBOL,
36
37
  AWS_APPSYNC_REALTIME_HEADERS,
37
38
  CONNECTION_INIT_TIMEOUT,
38
39
  DEFAULT_KEEP_ALIVE_TIMEOUT,
40
+ DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT,
39
41
  MAX_DELAY_MS,
40
42
  MESSAGE_TYPES,
41
43
  NON_RETRYABLE_CODES,
42
44
  SOCKET_STATUS,
43
45
  START_ACK_TIMEOUT,
44
46
  SUBSCRIPTION_STATUS,
45
- } from './constants';
47
+ } from '../constants';
48
+ import {
49
+ ConnectionStateMonitor,
50
+ CONNECTION_CHANGE,
51
+ } from '../../utils/ConnectionStateMonitor';
46
52
 
47
53
  const logger = new Logger('AWSAppSyncRealTimeProvider');
48
54
 
@@ -89,8 +95,27 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
89
95
  private socketStatus: SOCKET_STATUS = SOCKET_STATUS.CLOSED;
90
96
  private keepAliveTimeoutId?: ReturnType<typeof setTimeout>;
91
97
  private keepAliveTimeout = DEFAULT_KEEP_ALIVE_TIMEOUT;
98
+ private keepAliveAlertTimeoutId?: ReturnType<typeof setTimeout>;
92
99
  private subscriptionObserverMap: Map<string, ObserverQuery> = new Map();
93
100
  private promiseArray: Array<{ res: Function; rej: Function }> = [];
101
+ private readonly connectionStateMonitor = new ConnectionStateMonitor();
102
+
103
+ constructor(options: ProviderOptions = {}) {
104
+ super(options);
105
+ // Monitor the connection state and pass changes along to Hub
106
+ this.connectionStateMonitor.connectionStateObservable.subscribe(
107
+ ConnectionState => {
108
+ dispatchApiEvent(
109
+ CONNECTION_STATE_CHANGE,
110
+ {
111
+ provider: this,
112
+ connectionState: ConnectionState,
113
+ },
114
+ `Connection state is ${ConnectionState}`
115
+ );
116
+ }
117
+ );
118
+ }
94
119
 
95
120
  getNewWebSocket(url, protocol) {
96
121
  return new WebSocket(url, protocol);
@@ -147,6 +172,7 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
147
172
  },
148
173
  ],
149
174
  });
175
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
150
176
  observer.complete();
151
177
  });
152
178
 
@@ -252,6 +278,7 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
252
278
  const stringToAWSRealTime = JSON.stringify(subscriptionMessage);
253
279
 
254
280
  try {
281
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.OPENING_CONNECTION);
255
282
  await this._initializeWebSocketConnection({
256
283
  apiKey,
257
284
  appSyncGraphqlEndpoint,
@@ -262,6 +289,7 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
262
289
  } catch (err) {
263
290
  logger.debug({ err });
264
291
  const message = err['message'] ?? '';
292
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
265
293
  observer.error({
266
294
  errors: [
267
295
  {
@@ -366,12 +394,20 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
366
394
  this.socketStatus = SOCKET_STATUS.CLOSED;
367
395
  return;
368
396
  }
397
+
398
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSING_CONNECTION);
399
+
369
400
  if (this.awsRealTimeSocket.bufferedAmount > 0) {
370
401
  // Still data on the WebSocket
371
402
  setTimeout(this._closeSocketIfRequired.bind(this), 1000);
372
403
  } else {
373
404
  logger.debug('closing WebSocket...');
374
- if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
405
+ if (this.keepAliveTimeoutId) {
406
+ clearTimeout(this.keepAliveTimeoutId);
407
+ }
408
+ if (this.keepAliveAlertTimeoutId) {
409
+ clearTimeout(this.keepAliveAlertTimeoutId);
410
+ }
375
411
  const tempSocket = this.awsRealTimeSocket;
376
412
  // Cleaning callbacks to avoid race condition, socket still exists
377
413
  tempSocket.onclose = null;
@@ -379,6 +415,7 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
379
415
  tempSocket.close(1000);
380
416
  this.awsRealTimeSocket = undefined;
381
417
  this.socketStatus = SOCKET_STATUS.CLOSED;
418
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
382
419
  }
383
420
  }
384
421
 
@@ -432,17 +469,25 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
432
469
  subscriptionFailedCallback,
433
470
  });
434
471
  }
472
+ this.connectionStateMonitor.record(
473
+ CONNECTION_CHANGE.CONNECTION_ESTABLISHED
474
+ );
435
475
 
436
- // TODO: emit event on hub but it requires to store the id first
437
476
  return;
438
477
  }
439
478
 
440
479
  if (type === MESSAGE_TYPES.GQL_CONNECTION_KEEP_ALIVE) {
441
480
  if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
481
+ if (this.keepAliveAlertTimeoutId)
482
+ clearTimeout(this.keepAliveAlertTimeoutId);
442
483
  this.keepAliveTimeoutId = setTimeout(
443
- this._errorDisconnect.bind(this, CONTROL_MSG.TIMEOUT_DISCONNECT),
484
+ () => this._errorDisconnect(CONTROL_MSG.TIMEOUT_DISCONNECT),
444
485
  this.keepAliveTimeout
445
486
  );
487
+ this.keepAliveAlertTimeoutId = setTimeout(() => {
488
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.KEEP_ALIVE_MISSED);
489
+ }, DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT);
490
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.KEEP_ALIVE);
446
491
  return;
447
492
  }
448
493
 
@@ -489,6 +534,7 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
489
534
  });
490
535
  this.subscriptionObserverMap.clear();
491
536
  if (this.awsRealTimeSocket) {
537
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
492
538
  this.awsRealTimeSocket.close();
493
539
  }
494
540
 
@@ -630,6 +676,9 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
630
676
  logger.debug(`WebSocket connection error`);
631
677
  };
632
678
  newSocket.onclose = () => {
679
+ this.connectionStateMonitor.record(
680
+ CONNECTION_CHANGE.CONNECTION_FAILED
681
+ );
633
682
  rej(new Error('Connection handshake error'));
634
683
  };
635
684
  newSocket.onopen = () => {
@@ -698,17 +747,20 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
698
747
  };
699
748
  this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
700
749
 
701
- setTimeout(checkAckOk.bind(this, ackOk), CONNECTION_INIT_TIMEOUT);
702
- }
750
+ const checkAckOk = (ackOk: boolean) => {
751
+ if (!ackOk) {
752
+ this.connectionStateMonitor.record(
753
+ CONNECTION_CHANGE.CONNECTION_FAILED
754
+ );
755
+ rej(
756
+ new Error(
757
+ `Connection timeout: ack from AWSAppSyncRealTime was not received after ${CONNECTION_INIT_TIMEOUT} ms`
758
+ )
759
+ );
760
+ }
761
+ };
703
762
 
704
- function checkAckOk(ackOk: boolean) {
705
- if (!ackOk) {
706
- rej(
707
- new Error(
708
- `Connection timeout: ack from AWSRealTime was not received on ${CONNECTION_INIT_TIMEOUT} ms`
709
- )
710
- );
711
- }
763
+ setTimeout(() => checkAckOk(ackOk), CONNECTION_INIT_TIMEOUT);
712
764
  }
713
765
  });
714
766
  })();
@@ -16,7 +16,13 @@ import Observable from 'zen-observable-ts';
16
16
 
17
17
  import { AbstractPubSubProvider } from './PubSubProvider';
18
18
  import { ProviderOptions, SubscriptionObserver } from '../types';
19
- import { ConsoleLogger as Logger } from '@aws-amplify/core';
19
+ import { ConsoleLogger as Logger, Hub } from '@aws-amplify/core';
20
+ import {
21
+ ConnectionStateMonitor,
22
+ CONNECTION_CHANGE,
23
+ } from '../utils/ConnectionStateMonitor';
24
+ import { AMPLIFY_SYMBOL } from './constants';
25
+ import { CONNECTION_STATE_CHANGE } from '..';
20
26
 
21
27
  const logger = new Logger('MqttOverWSProvider');
22
28
 
@@ -72,13 +78,32 @@ class ClientsQueue {
72
78
  }
73
79
  }
74
80
 
81
+ const dispatchPubSubEvent = (event: string, data: any, message: string) => {
82
+ Hub.dispatch('pubsub', { event, data, message }, 'PubSub', AMPLIFY_SYMBOL);
83
+ };
84
+
75
85
  const topicSymbol = typeof Symbol !== 'undefined' ? Symbol('topic') : '@@topic';
76
86
 
77
87
  export class MqttOverWSProvider extends AbstractPubSubProvider {
78
88
  private _clientsQueue = new ClientsQueue();
89
+ private readonly connectionStateMonitor = new ConnectionStateMonitor();
79
90
 
80
91
  constructor(options: MqttProviderOptions = {}) {
81
92
  super({ ...options, clientId: options.clientId || uuid() });
93
+
94
+ // Monitor the connection health state and pass changes along to Hub
95
+ this.connectionStateMonitor.connectionStateObservable.subscribe(
96
+ connectionStateChange => {
97
+ dispatchPubSubEvent(
98
+ CONNECTION_STATE_CHANGE,
99
+ {
100
+ provider: this,
101
+ connectionState: connectionStateChange,
102
+ },
103
+ `Connection state is ${connectionStateChange}`
104
+ );
105
+ }
106
+ );
82
107
  }
83
108
 
84
109
  protected get clientId() {
@@ -149,6 +174,7 @@ export class MqttOverWSProvider extends AbstractPubSubProvider {
149
174
  public async newClient({ url, clientId }: MqttProviderOptions): Promise<any> {
150
175
  logger.debug('Creating new MQTT client', clientId);
151
176
 
177
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.OPENING_CONNECTION);
152
178
  // @ts-ignore
153
179
  const client = new Paho.Client(url, clientId);
154
180
  // client.trace = (args) => logger.debug(clientId, JSON.stringify(args, null, 2));
@@ -168,6 +194,7 @@ export class MqttOverWSProvider extends AbstractPubSubProvider {
168
194
  errorCode: number;
169
195
  }) => {
170
196
  this.onDisconnect({ clientId, errorCode, ...args });
197
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
171
198
  };
172
199
 
173
200
  await new Promise((resolve, reject) => {
@@ -175,10 +202,19 @@ export class MqttOverWSProvider extends AbstractPubSubProvider {
175
202
  useSSL: this.isSSLEnabled,
176
203
  mqttVersion: 3,
177
204
  onSuccess: () => resolve(client),
178
- onFailure: reject,
205
+ onFailure: () => {
206
+ reject();
207
+ this.connectionStateMonitor.record(
208
+ CONNECTION_CHANGE.CONNECTION_FAILED
209
+ );
210
+ },
179
211
  });
180
212
  });
181
213
 
214
+ this.connectionStateMonitor.record(
215
+ CONNECTION_CHANGE.CONNECTION_ESTABLISHED
216
+ );
217
+
182
218
  return client;
183
219
  }
184
220
 
@@ -196,6 +232,7 @@ export class MqttOverWSProvider extends AbstractPubSubProvider {
196
232
 
197
233
  if (client && client.isConnected()) {
198
234
  client.disconnect();
235
+ this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
199
236
  }
200
237
  this.clientsQueue.remove(clientId);
201
238
  }
@@ -293,6 +330,10 @@ export class MqttOverWSProvider extends AbstractPubSubProvider {
293
330
  this._clientIdObservers.get(clientId)?.delete(observer);
294
331
  // No more observers per client => client not needed anymore
295
332
  if (this._clientIdObservers.get(clientId)?.size === 0) {
333
+ this.connectionStateMonitor.record(
334
+ CONNECTION_CHANGE.CLOSING_CONNECTION
335
+ );
336
+
296
337
  this.disconnect(clientId);
297
338
  this._clientIdObservers.delete(clientId);
298
339
  }
@@ -93,3 +93,8 @@ export const START_ACK_TIMEOUT = 15000;
93
93
  * Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
94
94
  */
95
95
  export const DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
96
+
97
+ /**
98
+ * Default Time in milleseconds to alert for missed GQL_CONNECTION_KEEP_ALIVE message
99
+ */
100
+ export const DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = 65 * 1000;
package/src/index.ts CHANGED
@@ -22,6 +22,9 @@ enum CONTROL_MSG {
22
22
  TIMEOUT_DISCONNECT = 'Timeout disconnect',
23
23
  }
24
24
 
25
+ export const CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
26
+ export { ConnectionState } from './types';
27
+
25
28
  export { PubSub, CONTROL_MSG };
26
29
 
27
30
  /**