@aws-amplify/pubsub 4.4.9 → 4.4.10-next.20
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 +1260 -2214
- 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/AWSAppSyncProvider.js +20 -102
- package/lib/Providers/AWSAppSyncProvider.js.map +1 -1
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +10 -2
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +166 -208
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/lib/Providers/AWSIotProvider.js +4 -52
- package/lib/Providers/AWSIotProvider.js.map +1 -1
- package/lib/Providers/MqttOverWSProvider.d.ts +5 -1
- package/lib/Providers/MqttOverWSProvider.js +172 -187
- package/lib/Providers/MqttOverWSProvider.js.map +1 -1
- package/lib/Providers/PubSubProvider.d.ts +1 -1
- package/lib/Providers/PubSubProvider.js +3 -13
- package/lib/Providers/PubSubProvider.js.map +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/Providers/index.js +6 -8
- package/lib/Providers/index.js.map +1 -1
- package/lib/PubSub.js +6 -44
- package/lib/PubSub.js.map +1 -1
- package/lib/index.d.ts +3 -10
- package/lib/index.js +5 -14
- 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 +2 -36
- package/lib/types/index.js.map +1 -1
- package/lib/utils/ConnectionStateMonitor.d.ts +2 -1
- package/lib/utils/ConnectionStateMonitor.js +25 -30
- 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 +9 -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/AWSAppSyncProvider.js +1 -80
- package/lib-esm/Providers/AWSAppSyncProvider.js.map +1 -1
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +10 -2
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +130 -162
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/lib-esm/Providers/AWSIotProvider.js +1 -49
- package/lib-esm/Providers/AWSIotProvider.js.map +1 -1
- package/lib-esm/Providers/MqttOverWSProvider.d.ts +5 -1
- package/lib-esm/Providers/MqttOverWSProvider.js +154 -159
- package/lib-esm/Providers/MqttOverWSProvider.js.map +1 -1
- package/lib-esm/Providers/PubSubProvider.d.ts +1 -1
- package/lib-esm/Providers/PubSubProvider.js +1 -11
- package/lib-esm/Providers/PubSubProvider.js.map +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/PubSub.js +1 -36
- package/lib-esm/PubSub.js.map +1 -1
- 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 +14 -16
- 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 +6 -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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":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C;CACjD,CAAC;AAEF;;GAEG;AACU,QAAA,uBAAuB,GAAG,KAAK,CAAC;AAE7C;;GAEG;AACU,QAAA,iBAAiB,GAAG,KAAK,CAAC;AAEvC;;GAEG;AACU,QAAA,0BAA0B,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAExD;;GAEG;AACU,QAAA,gCAAgC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE1D;;GAEG;AACU,QAAA,eAAe,GAAG,CAAC,GAAG,IAAI,CAAC;AAExC;;GAEG;AACU,QAAA,kBAAkB,GAAG,EAAE,GAAG,IAAI,CAAC"}
|
package/lib/Providers/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function __export(m) {
|
|
3
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
-
}
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
6
4
|
/*
|
|
7
5
|
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
8
6
|
*
|
|
@@ -15,9 +13,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
13
|
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
16
14
|
* and limitations under the License.
|
|
17
15
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
tslib_1.__exportStar(require("./PubSubProvider"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./AWSAppSyncProvider"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./AWSAppSyncRealTimeProvider"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./AWSIotProvider"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./MqttOverWSProvider"), exports);
|
|
23
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Providers/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Providers/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACH,2DAAiC;AACjC,+DAAqC;AACrC,uEAA6C;AAC7C,2DAAiC;AACjC,+DAAqC"}
|
package/lib/PubSub.js
CHANGED
|
@@ -1,44 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
42
4
|
/*
|
|
43
5
|
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
44
6
|
*
|
|
@@ -52,7 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
52
14
|
* and limitations under the License.
|
|
53
15
|
*/
|
|
54
16
|
// import '../Common/Polyfills';
|
|
55
|
-
var zen_observable_ts_1 = __importDefault(require("zen-observable-ts"));
|
|
17
|
+
var zen_observable_ts_1 = tslib_1.__importDefault(require("zen-observable-ts"));
|
|
56
18
|
var core_1 = require("@aws-amplify/core");
|
|
57
19
|
var Providers_1 = require("./Providers");
|
|
58
20
|
var isNode = core_1.browserOrNode().isNode;
|
|
@@ -117,9 +79,9 @@ var PubSubClass = /** @class */ (function () {
|
|
|
117
79
|
* @param {Object} pluggable - an instance of the plugin
|
|
118
80
|
*/
|
|
119
81
|
PubSubClass.prototype.addPluggable = function (pluggable) {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
121
83
|
var config;
|
|
122
|
-
return __generator(this, function (_a) {
|
|
84
|
+
return tslib_1.__generator(this, function (_a) {
|
|
123
85
|
if (pluggable && pluggable.getCategory() === 'PubSub') {
|
|
124
86
|
this._pluggables.push(pluggable);
|
|
125
87
|
config = pluggable.configure(this._options);
|
|
@@ -158,8 +120,8 @@ var PubSubClass = /** @class */ (function () {
|
|
|
158
120
|
return [provider];
|
|
159
121
|
};
|
|
160
122
|
PubSubClass.prototype.publish = function (topics, msg, options) {
|
|
161
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
162
|
-
return __generator(this, function (_a) {
|
|
123
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
124
|
+
return tslib_1.__generator(this, function (_a) {
|
|
163
125
|
return [2 /*return*/, Promise.all(this.getProviders(options).map(function (provider) {
|
|
164
126
|
return provider.publish(topics, msg, options);
|
|
165
127
|
}))];
|
package/lib/PubSub.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PubSub.js","sourceRoot":"","sources":["../src/PubSub.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PubSub.js","sourceRoot":"","sources":["../src/PubSub.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACH,gCAAgC;AAChC,gFAA2C;AAE3C,0CAM2B;AAE3B,yCAA6E;AAErE,IAAA,sCAAM,CAAqB;AACnC,IAAM,MAAM,GAAG,IAAI,oBAAM,CAAC,QAAQ,CAAC,CAAC;AAEpC;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QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,UAAA,EAAE,KAAK,OAAA,EAAE,CAAC,EAAlC,CAAkC;oBACjD,KAAK,EAAE,UAAA,KAAK,IAAI,OAAA,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,UAAA,EAAE,KAAK,OAAA,EAAE,CAAC,EAAnC,CAAmC;iBAEnD,CAAC;YALF,CAKE,CACF,CAAC;YAEF,OAAO;gBACN,OAAA,aAAa,CAAC,OAAO,CAAC,UAAA,YAAY,IAAI,OAAA,YAAY,CAAC,WAAW,EAAE,EAA1B,CAA0B,CAAC;YAAjE,CAAiE,CAAC;QACpE,CAAC,CAAC,CAAC;IACJ,CAAC;IACF,kBAAC;AAAD,CAAC,AAtKD,IAsKC;AAtKY,kCAAW;AAwKX,QAAA,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;AACxC,cAAO,CAAC,QAAQ,CAAC,cAAM,CAAC,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import { PubSub } from './PubSub';
|
|
2
2
|
export * from './Providers';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
REALTIME_SUBSCRIPTION_INIT_ERROR = "AppSync Realtime subscription init error",
|
|
7
|
-
SUBSCRIPTION_ACK = "Subscription ack",
|
|
8
|
-
TIMEOUT_DISCONNECT = "Timeout disconnect"
|
|
9
|
-
}
|
|
10
|
-
export declare const CONNECTION_STATE_CHANGE = "ConnectionStateChange";
|
|
11
|
-
export { ConnectionState } from './types';
|
|
12
|
-
export { PubSub, CONTROL_MSG };
|
|
3
|
+
export { CONNECTION_STATE_CHANGE } from './Providers/constants';
|
|
4
|
+
export { ConnectionState, CONTROL_MSG } from './types';
|
|
5
|
+
export { PubSub };
|
|
13
6
|
/**
|
|
14
7
|
* @deprecated use named import
|
|
15
8
|
*/
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function __export(m) {
|
|
3
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
-
}
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
6
4
|
/*
|
|
7
5
|
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
8
6
|
*
|
|
@@ -17,19 +15,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
15
|
*/
|
|
18
16
|
var PubSub_1 = require("./PubSub");
|
|
19
17
|
exports.PubSub = PubSub_1.PubSub;
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
CONTROL_MSG["CONNECTION_CLOSED"] = "Connection closed";
|
|
24
|
-
CONTROL_MSG["CONNECTION_FAILED"] = "Connection failed";
|
|
25
|
-
CONTROL_MSG["REALTIME_SUBSCRIPTION_INIT_ERROR"] = "AppSync Realtime subscription init error";
|
|
26
|
-
CONTROL_MSG["SUBSCRIPTION_ACK"] = "Subscription ack";
|
|
27
|
-
CONTROL_MSG["TIMEOUT_DISCONNECT"] = "Timeout disconnect";
|
|
28
|
-
})(CONTROL_MSG || (CONTROL_MSG = {}));
|
|
29
|
-
exports.CONTROL_MSG = CONTROL_MSG;
|
|
30
|
-
exports.CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
|
|
18
|
+
tslib_1.__exportStar(require("./Providers"), exports);
|
|
19
|
+
var constants_1 = require("./Providers/constants");
|
|
20
|
+
exports.CONNECTION_STATE_CHANGE = constants_1.CONNECTION_STATE_CHANGE;
|
|
31
21
|
var types_1 = require("./types");
|
|
32
22
|
exports.ConnectionState = types_1.ConnectionState;
|
|
23
|
+
exports.CONTROL_MSG = types_1.CONTROL_MSG;
|
|
33
24
|
/**
|
|
34
25
|
* @deprecated use named import
|
|
35
26
|
*/
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACH,mCAAkC;AAQzB,iBARA,eAAM,CAQA;AANf,sDAA4B;AAE5B,mDAAgE;AAAvD,8CAAA,uBAAuB,CAAA;AAEhC,iCAAuD;AAA9C,kCAAA,eAAe,CAAA;AAAE,8BAAA,WAAW,CAAA;AAIrC;;GAEG;AACH,kBAAe,eAAM,CAAC"}
|
package/lib/types/Provider.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import Observable from 'zen-observable-ts';
|
|
2
|
-
|
|
2
|
+
export interface PubSubOptions {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
export interface ProviderOptions {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Migrated to ProviderOptions
|
|
10
|
+
*/
|
|
11
|
+
export declare type ProvidertOptions = ProviderOptions;
|
|
3
12
|
export interface PubSubProvider {
|
|
4
13
|
configure(config: object): object;
|
|
5
14
|
getCategory(): string;
|
package/lib/types/PubSub.d.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
|
|
1
|
+
export interface SubscriptionObserver<T> {
|
|
2
|
+
closed: boolean;
|
|
3
|
+
next(value: T): void;
|
|
4
|
+
error(errorValue: any): void;
|
|
5
|
+
complete(): void;
|
|
3
6
|
}
|
|
4
|
-
export
|
|
5
|
-
|
|
7
|
+
export declare enum CONTROL_MSG {
|
|
8
|
+
CONNECTION_CLOSED = "Connection closed",
|
|
9
|
+
CONNECTION_FAILED = "Connection failed",
|
|
10
|
+
REALTIME_SUBSCRIPTION_INIT_ERROR = "AppSync Realtime subscription init error",
|
|
11
|
+
SUBSCRIPTION_ACK = "Subscription ack",
|
|
12
|
+
TIMEOUT_DISCONNECT = "Timeout disconnect"
|
|
13
|
+
}
|
|
14
|
+
/** @enum {string} */
|
|
15
|
+
export declare enum ConnectionState {
|
|
16
|
+
Connected = "Connected",
|
|
17
|
+
ConnectedPendingNetwork = "ConnectedPendingNetwork",
|
|
18
|
+
ConnectionDisrupted = "ConnectionDisrupted",
|
|
19
|
+
ConnectionDisruptedPendingNetwork = "ConnectionDisruptedPendingNetwork",
|
|
20
|
+
Connecting = "Connecting",
|
|
21
|
+
ConnectedPendingDisconnect = "ConnectedPendingDisconnect",
|
|
22
|
+
Disconnected = "Disconnected",
|
|
23
|
+
ConnectedPendingKeepAlive = "ConnectedPendingKeepAlive"
|
|
6
24
|
}
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated Migrated to ProviderOptions
|
|
9
|
-
*/
|
|
10
|
-
export declare type ProvidertOptions = ProviderOptions;
|
package/lib/types/PubSub.js
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
6
|
+
* the License. A copy of the License is located at
|
|
7
|
+
*
|
|
8
|
+
* http://aws.amazon.com/apache2.0/
|
|
9
|
+
*
|
|
10
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
11
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
12
|
+
* and limitations under the License.
|
|
13
|
+
*/
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
var CONTROL_MSG;
|
|
16
|
+
(function (CONTROL_MSG) {
|
|
17
|
+
CONTROL_MSG["CONNECTION_CLOSED"] = "Connection closed";
|
|
18
|
+
CONTROL_MSG["CONNECTION_FAILED"] = "Connection failed";
|
|
19
|
+
CONTROL_MSG["REALTIME_SUBSCRIPTION_INIT_ERROR"] = "AppSync Realtime subscription init error";
|
|
20
|
+
CONTROL_MSG["SUBSCRIPTION_ACK"] = "Subscription ack";
|
|
21
|
+
CONTROL_MSG["TIMEOUT_DISCONNECT"] = "Timeout disconnect";
|
|
22
|
+
})(CONTROL_MSG = exports.CONTROL_MSG || (exports.CONTROL_MSG = {}));
|
|
23
|
+
/** @enum {string} */
|
|
24
|
+
var ConnectionState;
|
|
25
|
+
(function (ConnectionState) {
|
|
26
|
+
/*
|
|
27
|
+
* The connection is alive and healthy
|
|
28
|
+
*/
|
|
29
|
+
ConnectionState["Connected"] = "Connected";
|
|
30
|
+
/*
|
|
31
|
+
* The connection is alive, but the connection is offline
|
|
32
|
+
*/
|
|
33
|
+
ConnectionState["ConnectedPendingNetwork"] = "ConnectedPendingNetwork";
|
|
34
|
+
/*
|
|
35
|
+
* The connection has been disconnected while in use
|
|
36
|
+
*/
|
|
37
|
+
ConnectionState["ConnectionDisrupted"] = "ConnectionDisrupted";
|
|
38
|
+
/*
|
|
39
|
+
* The connection has been disconnected and the network is offline
|
|
40
|
+
*/
|
|
41
|
+
ConnectionState["ConnectionDisruptedPendingNetwork"] = "ConnectionDisruptedPendingNetwork";
|
|
42
|
+
/*
|
|
43
|
+
* The connection is in the process of connecting
|
|
44
|
+
*/
|
|
45
|
+
ConnectionState["Connecting"] = "Connecting";
|
|
46
|
+
/*
|
|
47
|
+
* The connection is not in use and is being disconnected
|
|
48
|
+
*/
|
|
49
|
+
ConnectionState["ConnectedPendingDisconnect"] = "ConnectedPendingDisconnect";
|
|
50
|
+
/*
|
|
51
|
+
* The connection is not in use and has been disconnected
|
|
52
|
+
*/
|
|
53
|
+
ConnectionState["Disconnected"] = "Disconnected";
|
|
54
|
+
/*
|
|
55
|
+
* The connection is alive, but a keep alive message has been missed
|
|
56
|
+
*/
|
|
57
|
+
ConnectionState["ConnectedPendingKeepAlive"] = "ConnectedPendingKeepAlive";
|
|
58
|
+
})(ConnectionState = exports.ConnectionState || (exports.ConnectionState = {}));
|
|
3
59
|
//# sourceMappingURL=PubSub.js.map
|
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,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
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 = {}));
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./PubSub"), exports);
|
|
39
5
|
//# 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,mDAAyB"}
|
|
@@ -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
|
|
@@ -11,24 +11,11 @@
|
|
|
11
11
|
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
12
12
|
* and limitations under the License.
|
|
13
13
|
*/
|
|
14
|
-
var __assign = (this && this.__assign) || function () {
|
|
15
|
-
__assign = Object.assign || function(t) {
|
|
16
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
17
|
-
s = arguments[i];
|
|
18
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
19
|
-
t[p] = s[p];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
|
-
return __assign.apply(this, arguments);
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
var
|
|
30
|
-
var zen_observable_ts_1 = __importDefault(require("zen-observable-ts"));
|
|
31
|
-
var
|
|
15
|
+
var tslib_1 = require("tslib");
|
|
16
|
+
var zen_observable_ts_1 = tslib_1.__importDefault(require("zen-observable-ts"));
|
|
17
|
+
var PubSub_1 = require("../types/PubSub");
|
|
18
|
+
var ReachabilityMonitor_1 = require("./ReachabilityMonitor");
|
|
32
19
|
exports.CONNECTION_CHANGE = {
|
|
33
20
|
KEEP_ALIVE_MISSED: { keepAliveState: 'unhealthy' },
|
|
34
21
|
KEEP_ALIVE: { keepAliveState: 'healthy' },
|
|
@@ -56,6 +43,13 @@ var ConnectionStateMonitor = /** @class */ (function () {
|
|
|
56
43
|
intendedConnectionState: 'disconnected',
|
|
57
44
|
keepAliveState: 'healthy',
|
|
58
45
|
};
|
|
46
|
+
// Attempt to update the state with the current actual network state
|
|
47
|
+
this._initialNetworkStateSubscription = ReachabilityMonitor_1.ReachabilityMonitor().subscribe(function (_a) {
|
|
48
|
+
var online = _a.online;
|
|
49
|
+
var _b;
|
|
50
|
+
_this.record(online ? exports.CONNECTION_CHANGE.ONLINE : exports.CONNECTION_CHANGE.OFFLINE);
|
|
51
|
+
(_b = _this._initialNetworkStateSubscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
|
|
52
|
+
});
|
|
59
53
|
this._linkedConnectionStateObservable =
|
|
60
54
|
new zen_observable_ts_1.default(function (connectionStateObserver) {
|
|
61
55
|
connectionStateObserver.next(_this._linkedConnectionState);
|
|
@@ -67,11 +61,12 @@ var ConnectionStateMonitor = /** @class */ (function () {
|
|
|
67
61
|
*/
|
|
68
62
|
ConnectionStateMonitor.prototype.enableNetworkMonitoring = function () {
|
|
69
63
|
var _this = this;
|
|
64
|
+
var _a;
|
|
65
|
+
// If no initial network state was discovered, stop trying
|
|
66
|
+
(_a = this._initialNetworkStateSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
70
67
|
// Maintain the network state based on the reachability monitor
|
|
71
68
|
if (this._networkMonitoringSubscription === undefined) {
|
|
72
|
-
this._networkMonitoringSubscription =
|
|
73
|
-
.networkMonitor()
|
|
74
|
-
.subscribe(function (_a) {
|
|
69
|
+
this._networkMonitoringSubscription = ReachabilityMonitor_1.ReachabilityMonitor().subscribe(function (_a) {
|
|
75
70
|
var online = _a.online;
|
|
76
71
|
_this.record(online ? exports.CONNECTION_CHANGE.ONLINE : exports.CONNECTION_CHANGE.OFFLINE);
|
|
77
72
|
});
|
|
@@ -123,8 +118,8 @@ var ConnectionStateMonitor = /** @class */ (function () {
|
|
|
123
118
|
this.disableNetworkMonitoring();
|
|
124
119
|
}
|
|
125
120
|
// Maintain the socket state
|
|
126
|
-
var newSocketStatus = __assign(__assign({}, this._linkedConnectionState), statusUpdates);
|
|
127
|
-
this._linkedConnectionState = __assign({}, newSocketStatus);
|
|
121
|
+
var newSocketStatus = tslib_1.__assign(tslib_1.__assign({}, this._linkedConnectionState), statusUpdates);
|
|
122
|
+
this._linkedConnectionState = tslib_1.__assign({}, newSocketStatus);
|
|
128
123
|
this._linkedConnectionStateObserver.next(this._linkedConnectionState);
|
|
129
124
|
};
|
|
130
125
|
/*
|
|
@@ -133,25 +128,25 @@ var ConnectionStateMonitor = /** @class */ (function () {
|
|
|
133
128
|
ConnectionStateMonitor.prototype.connectionStatesTranslator = function (_a) {
|
|
134
129
|
var connectionState = _a.connectionState, networkState = _a.networkState, intendedConnectionState = _a.intendedConnectionState, keepAliveState = _a.keepAliveState;
|
|
135
130
|
if (connectionState === 'connected' && networkState === 'disconnected')
|
|
136
|
-
return
|
|
131
|
+
return PubSub_1.ConnectionState.ConnectedPendingNetwork;
|
|
137
132
|
if (connectionState === 'connected' &&
|
|
138
133
|
intendedConnectionState === 'disconnected')
|
|
139
|
-
return
|
|
134
|
+
return PubSub_1.ConnectionState.ConnectedPendingDisconnect;
|
|
140
135
|
if (connectionState === 'disconnected' &&
|
|
141
136
|
intendedConnectionState === 'connected' &&
|
|
142
137
|
networkState === 'disconnected')
|
|
143
|
-
return
|
|
138
|
+
return PubSub_1.ConnectionState.ConnectionDisruptedPendingNetwork;
|
|
144
139
|
if (connectionState === 'disconnected' &&
|
|
145
140
|
intendedConnectionState === 'connected')
|
|
146
|
-
return
|
|
141
|
+
return PubSub_1.ConnectionState.ConnectionDisrupted;
|
|
147
142
|
if (connectionState === 'connected' && keepAliveState === 'unhealthy')
|
|
148
|
-
return
|
|
143
|
+
return PubSub_1.ConnectionState.ConnectedPendingKeepAlive;
|
|
149
144
|
// All remaining states directly correspond to the connection state
|
|
150
145
|
if (connectionState === 'connecting')
|
|
151
|
-
return
|
|
146
|
+
return PubSub_1.ConnectionState.Connecting;
|
|
152
147
|
if (connectionState === 'disconnected')
|
|
153
|
-
return
|
|
154
|
-
return
|
|
148
|
+
return PubSub_1.ConnectionState.Disconnected;
|
|
149
|
+
return PubSub_1.ConnectionState.Connected;
|
|
155
150
|
};
|
|
156
151
|
return ConnectionStateMonitor;
|
|
157
152
|
}());
|
|
@@ -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,gFAA8D;AAC9D,0CAAkD;AAClD,6DAA4D;AAY/C,QAAA,iBAAiB,GAW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oot":"","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,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var core_1 = require("@aws-amplify/core");
|
|
5
|
+
var netinfo_1 = tslib_1.__importDefault(require("@react-native-community/netinfo"));
|
|
6
|
+
exports.ReachabilityMonitor = function () {
|
|
7
|
+
return new core_1.Reachability().networkMonitor(netinfo_1.default);
|
|
8
|
+
};
|
|
9
|
+
//# 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,oFAAqE;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
|
+
}
|