@aws-amplify/pubsub 4.5.12-unstable.4 → 4.5.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 +24 -0
- package/build.js +5 -0
- package/dist/aws-amplify-pubsub.js +10278 -0
- package/dist/aws-amplify-pubsub.js.map +1 -0
- package/dist/aws-amplify-pubsub.min.js +11 -0
- package/dist/aws-amplify-pubsub.min.js.map +1 -0
- package/index.js +7 -0
- package/lib/Providers/AWSAppSyncProvider.js +102 -20
- package/lib/Providers/AWSAppSyncProvider.js.map +1 -1
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +210 -158
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/lib/Providers/AWSIotProvider.js +64 -6
- package/lib/Providers/AWSIotProvider.js.map +1 -1
- package/lib/Providers/MqttOverWSProvider.js +204 -158
- package/lib/Providers/MqttOverWSProvider.js.map +1 -1
- package/lib/Providers/PubSubProvider.js +13 -3
- package/lib/Providers/PubSubProvider.js.map +1 -1
- package/lib/Providers/constants.js +0 -8
- package/lib/Providers/constants.js.map +1 -1
- package/lib/Providers/index.js +20 -13
- package/lib/Providers/index.js.map +1 -1
- package/lib/PubSub.js +56 -8
- package/lib/PubSub.js.map +1 -1
- package/lib/index.js +20 -9
- package/lib/index.js.map +1 -1
- package/lib/types/PubSub.js +12 -2
- package/lib/types/PubSub.js.map +1 -1
- package/lib/types/index.js +4 -2
- package/lib/types/index.js.map +1 -1
- package/lib/utils/ConnectionStateMonitor.js +29 -16
- package/lib/utils/ConnectionStateMonitor.js.map +1 -1
- package/lib/utils/ReachabilityMonitor/index.native.js +4 -2
- package/lib/utils/ReachabilityMonitor/index.native.js.map +1 -1
- package/lib-esm/Providers/AWSAppSyncProvider.js +80 -1
- package/lib-esm/Providers/AWSAppSyncProvider.js.map +1 -1
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +0 -8
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +168 -126
- package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -1
- package/lib-esm/Providers/AWSIotProvider.js +61 -3
- package/lib-esm/Providers/AWSIotProvider.js.map +1 -1
- package/lib-esm/Providers/MqttOverWSProvider.d.ts +4 -2
- package/lib-esm/Providers/MqttOverWSProvider.js +175 -139
- package/lib-esm/Providers/MqttOverWSProvider.js.map +1 -1
- package/lib-esm/Providers/PubSubProvider.js +11 -1
- package/lib-esm/Providers/PubSubProvider.js.map +1 -1
- package/lib-esm/Providers/constants.d.ts +0 -8
- package/lib-esm/Providers/constants.js +0 -8
- package/lib-esm/Providers/constants.js.map +1 -1
- package/lib-esm/Providers/index.d.ts +5 -5
- package/lib-esm/Providers/index.js +17 -7
- package/lib-esm/Providers/index.js.map +1 -1
- package/lib-esm/PubSub.js +48 -3
- package/lib-esm/PubSub.js.map +1 -1
- package/lib-esm/index.d.ts +7 -2
- package/lib-esm/index.js +19 -4
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/types/Provider.d.ts +4 -0
- package/lib-esm/types/PubSub.js +12 -2
- package/lib-esm/types/PubSub.js.map +1 -1
- package/lib-esm/types/index.js.map +1 -1
- package/lib-esm/utils/ConnectionStateMonitor.d.ts +0 -1
- package/lib-esm/utils/ConnectionStateMonitor.js +23 -13
- package/lib-esm/utils/ConnectionStateMonitor.js.map +1 -1
- package/package.json +10 -14
- package/src/Providers/AWSAppSyncProvider.ts +12 -2
- package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +89 -142
- package/src/Providers/AWSIotProvider.ts +12 -2
- package/src/Providers/MqttOverWSProvider.ts +79 -90
- package/src/Providers/PubSubProvider.ts +12 -2
- package/src/Providers/constants.ts +0 -10
- package/src/Providers/index.ts +17 -15
- package/src/PubSub.ts +12 -2
- package/src/index.ts +23 -15
- package/src/types/Provider.ts +17 -2
- package/src/types/PubSub.ts +12 -2
- package/src/types/index.ts +12 -2
- package/src/utils/ConnectionStateMonitor.ts +12 -16
- package/webpack.config.dev.js +6 -0
- package/lib/.tsbuildinfo +0 -3
- package/lib/Providers/AWSAppSyncProvider.d.ts +0 -21
- package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +0 -75
- package/lib/Providers/AWSIotProvider.d.ts +0 -11
- package/lib/Providers/MqttOverWSProvider.d.ts +0 -41
- package/lib/Providers/PubSubProvider.d.ts +0 -13
- package/lib/Providers/constants.d.ts +0 -95
- package/lib/Providers/index.d.ts +0 -5
- package/lib/PubSub.d.ts +0 -51
- package/lib/index.d.ts +0 -4
- package/lib/types/Provider.d.ts +0 -14
- package/lib/types/PubSub.d.ts +0 -24
- package/lib/types/index.d.ts +0 -2
- package/lib/utils/ConnectionStateMonitor.d.ts +0 -41
- package/lib/utils/ReachabilityMonitor/index.d.ts +0 -3
- package/lib/utils/ReachabilityMonitor/index.native.d.ts +0 -3
- package/lib/utils/ReconnectionMonitor.d.ts +0 -29
- package/lib/utils/ReconnectionMonitor.js +0 -73
- package/lib/utils/ReconnectionMonitor.js.map +0 -1
- package/lib-esm/.tsbuildinfo +0 -3
- package/lib-esm/utils/ReconnectionMonitor.d.ts +0 -29
- package/lib-esm/utils/ReconnectionMonitor.js +0 -71
- package/lib-esm/utils/ReconnectionMonitor.js.map +0 -1
- package/src/utils/ReconnectionMonitor.ts +0 -74
package/lib-esm/PubSub.js
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
/*
|
|
38
|
+
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
39
|
+
*
|
|
40
|
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
|
|
41
|
+
* the License. A copy of the License is located at
|
|
42
|
+
*
|
|
43
|
+
* http://aws.amazon.com/apache2.0/
|
|
44
|
+
*
|
|
45
|
+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
46
|
+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
47
|
+
* and limitations under the License.
|
|
48
|
+
*/
|
|
4
49
|
// import '../Common/Polyfills';
|
|
5
50
|
import Observable from 'zen-observable-ts';
|
|
6
51
|
import { Amplify, browserOrNode, ConsoleLogger as Logger, INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER, INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, } from '@aws-amplify/core';
|
package/lib-esm/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,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EACN,OAAO,EACP,aAAa,EACb,aAAa,IAAI,MAAM,EACvB,oCAAoC,EACpC,6CAA6C,GAC7C,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAErE,IAAA,+BAAM,CAAqB;AACnC,IAAM,M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AAC,KAAK;oBACpB,IAAI,EAAE,UAAA,KAAK,IAAI,OAAA,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;;AAED,MAAM,CAAC,IAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;AACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC"}
|
package/lib-esm/index.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { PubSub } from './PubSub';
|
|
2
|
+
export * from './Providers';
|
|
2
3
|
export { CONNECTION_STATE_CHANGE } from './Providers/constants';
|
|
3
4
|
export { ConnectionState, CONTROL_MSG } from './types';
|
|
4
|
-
export {
|
|
5
|
+
export { PubSub };
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use named import
|
|
8
|
+
*/
|
|
9
|
+
export default PubSub;
|
package/lib-esm/index.js
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2017-2018 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
|
+
import { PubSub } from './PubSub';
|
|
14
|
+
export * from './Providers';
|
|
4
15
|
export { CONNECTION_STATE_CHANGE } from './Providers/constants';
|
|
5
16
|
export { ConnectionState, CONTROL_MSG } from './types';
|
|
6
|
-
export {
|
|
17
|
+
export { PubSub };
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated use named import
|
|
20
|
+
*/
|
|
21
|
+
export default PubSub;
|
|
7
22
|
//# sourceMappingURL=index.js.map
|
package/lib-esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
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,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB;;GAEG;AACH,eAAe,MAAM,CAAC"}
|
|
@@ -5,6 +5,10 @@ export interface PubSubOptions {
|
|
|
5
5
|
export interface ProviderOptions {
|
|
6
6
|
[key: string]: any;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Migrated to ProviderOptions
|
|
10
|
+
*/
|
|
11
|
+
export declare type ProvidertOptions = ProviderOptions;
|
|
8
12
|
export interface PubSubProvider {
|
|
9
13
|
configure(config: object): object;
|
|
10
14
|
getCategory(): string;
|
package/lib-esm/types/PubSub.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2017-2018 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
|
+
*/
|
|
3
13
|
export var CONTROL_MSG;
|
|
4
14
|
(function (CONTROL_MSG) {
|
|
5
15
|
CONTROL_MSG["CONNECTION_CLOSED"] = "Connection closed";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PubSub.js","sourceRoot":"","sources":["../../src/types/PubSub.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"PubSub.js","sourceRoot":"","sources":["../../src/types/PubSub.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AASH,MAAM,CAAN,IAAY,WAMX;AAND,WAAY,WAAW;IACtB,sDAAuC,CAAA;IACvC,sDAAuC,CAAA;IACvC,4FAA6E,CAAA;IAC7E,oDAAqC,CAAA;IACrC,wDAAyC,CAAA;AAC1C,CAAC,EANW,WAAW,KAAX,WAAW,QAMtB;AAED,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"}
|
|
@@ -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,cAAc,UAAU,CAAC"}
|
|
@@ -19,7 +19,6 @@ export declare class ConnectionStateMonitor {
|
|
|
19
19
|
private _linkedConnectionStateObservable;
|
|
20
20
|
private _linkedConnectionStateObserver;
|
|
21
21
|
private _networkMonitoringSubscription?;
|
|
22
|
-
private _initialNetworkStateSubscription?;
|
|
23
22
|
constructor();
|
|
24
23
|
/**
|
|
25
24
|
* Turn network state monitoring on if it isn't on already
|
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
};
|
|
4
24
|
import Observable from 'zen-observable-ts';
|
|
5
25
|
import { ConnectionState } from '../types/PubSub';
|
|
6
26
|
import { ReachabilityMonitor } from './ReachabilityMonitor';
|
|
@@ -31,13 +51,6 @@ var ConnectionStateMonitor = /** @class */ (function () {
|
|
|
31
51
|
intendedConnectionState: 'disconnected',
|
|
32
52
|
keepAliveState: 'healthy',
|
|
33
53
|
};
|
|
34
|
-
// Attempt to update the state with the current actual network state
|
|
35
|
-
this._initialNetworkStateSubscription = ReachabilityMonitor().subscribe(function (_a) {
|
|
36
|
-
var online = _a.online;
|
|
37
|
-
var _b;
|
|
38
|
-
_this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);
|
|
39
|
-
(_b = _this._initialNetworkStateSubscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
|
|
40
|
-
});
|
|
41
54
|
this._linkedConnectionStateObservable =
|
|
42
55
|
new Observable(function (connectionStateObserver) {
|
|
43
56
|
connectionStateObserver.next(_this._linkedConnectionState);
|
|
@@ -49,9 +62,6 @@ var ConnectionStateMonitor = /** @class */ (function () {
|
|
|
49
62
|
*/
|
|
50
63
|
ConnectionStateMonitor.prototype.enableNetworkMonitoring = function () {
|
|
51
64
|
var _this = this;
|
|
52
|
-
var _a;
|
|
53
|
-
// If no initial network state was discovered, stop trying
|
|
54
|
-
(_a = this._initialNetworkStateSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
55
65
|
// Maintain the network state based on the reachability monitor
|
|
56
66
|
if (this._networkMonitoringSubscription === undefined) {
|
|
57
67
|
this._networkMonitoringSubscription = ReachabilityMonitor().subscribe(function (_a) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionStateMonitor.js","sourceRoot":"","sources":["../../src/utils/ConnectionStateMonitor.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"ConnectionStateMonitor.js","sourceRoot":"","sources":["../../src/utils/ConnectionStateMonitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;AAGH,OAAO,UAA6B,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAY5D,MAAM,CAAC,IAAM,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,cAAc,EAAE;IAC/D,kBAAkB,EAAE;QACnB,uBAAuB,EAAE,WAAW;QACpC,eAAe,EAAE,YAAY;KAC7B;IACD,MAAM,EAAE,EAAE,eAAe,EAAE,cAAc,EAAE;IAC3C,MAAM,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE;IACrC,OAAO,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE;CACzC,CAAC;AAEF;IASC;QAAA,iBAcC;QAbA,IAAI,CAAC,8BAA8B,GAAG,SAAS,CAAC;QAChD,IAAI,CAAC,sBAAsB,GAAG;YAC7B,YAAY,EAAE,WAAW;YACzB,eAAe,EAAE,cAAc;YAC/B,uBAAuB,EAAE,cAAc;YACvC,cAAc,EAAE,SAAS;SACzB,CAAC;QAEF,IAAI,CAAC,gCAAgC;YACpC,IAAI,UAAU,CAAyB,UAAA,uBAAuB;gBAC7D,uBAAuB,CAAC,IAAI,CAAC,KAAI,CAAC,sBAAs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plify/pubsub",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.13",
|
|
4
4
|
"description": "Pubsub category of aws-amplify",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib-esm/index.js",
|
|
@@ -9,8 +9,11 @@
|
|
|
9
9
|
"./lib/index": "./lib-esm/index.js"
|
|
10
10
|
},
|
|
11
11
|
"sideEffects": [
|
|
12
|
+
"./src/PubSub.ts",
|
|
12
13
|
"./lib/PubSub.js",
|
|
13
|
-
"./lib-esm/PubSub.js"
|
|
14
|
+
"./lib-esm/PubSub.js",
|
|
15
|
+
"./dist/aws-amplify-pubsub.min.js",
|
|
16
|
+
"./dist/aws-amplify-pubsub.js"
|
|
14
17
|
],
|
|
15
18
|
"publishConfig": {
|
|
16
19
|
"access": "public"
|
|
@@ -25,8 +28,7 @@
|
|
|
25
28
|
"build": "npm run clean && npm run build:esm && npm run build:cjs",
|
|
26
29
|
"clean": "rimraf lib-esm lib dist",
|
|
27
30
|
"format": "echo \"Not implemented\"",
|
|
28
|
-
"lint": "tslint 'src/**/*.ts'
|
|
29
|
-
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 87.63"
|
|
31
|
+
"lint": "tslint 'src/**/*.ts'"
|
|
30
32
|
},
|
|
31
33
|
"repository": {
|
|
32
34
|
"type": "git",
|
|
@@ -42,18 +44,12 @@
|
|
|
42
44
|
"@types/zen-observable": "^0.8.0",
|
|
43
45
|
"cpx": "^1.5.0"
|
|
44
46
|
},
|
|
45
|
-
"files": [
|
|
46
|
-
"lib",
|
|
47
|
-
"lib-esm",
|
|
48
|
-
"src"
|
|
49
|
-
],
|
|
50
47
|
"dependencies": {
|
|
51
|
-
"@aws-amplify/auth": "4.6.
|
|
52
|
-
"@aws-amplify/cache": "4.0.
|
|
53
|
-
"@aws-amplify/core": "4.7.
|
|
48
|
+
"@aws-amplify/auth": "4.6.16",
|
|
49
|
+
"@aws-amplify/cache": "4.0.65",
|
|
50
|
+
"@aws-amplify/core": "4.7.14",
|
|
54
51
|
"graphql": "15.8.0",
|
|
55
52
|
"paho-mqtt": "^1.1.0",
|
|
56
|
-
"tslib": "^1.8.0",
|
|
57
53
|
"uuid": "^3.2.1",
|
|
58
54
|
"zen-observable-ts": "0.8.19"
|
|
59
55
|
},
|
|
@@ -107,5 +103,5 @@
|
|
|
107
103
|
"lib-esm"
|
|
108
104
|
]
|
|
109
105
|
},
|
|
110
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "66b579d31fceaaba7f128b6cd9950dac3d4ef3cb"
|
|
111
107
|
}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2017-2018 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
|
+
*/
|
|
3
13
|
import { Client } from 'paho-mqtt';
|
|
4
14
|
import Observable from 'zen-observable-ts';
|
|
5
15
|
import { ConsoleLogger as Logger } from '@aws-amplify/core';
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
*/
|
|
3
13
|
import Observable, { ZenObservable } from 'zen-observable-ts';
|
|
4
14
|
import { GraphQLError } from 'graphql';
|
|
5
15
|
import * as url from 'url';
|
|
@@ -16,12 +26,11 @@ import {
|
|
|
16
26
|
jitteredExponentialRetry,
|
|
17
27
|
NonRetryableError,
|
|
18
28
|
ICredentials,
|
|
19
|
-
isNonRetryableError,
|
|
20
29
|
} from '@aws-amplify/core';
|
|
21
|
-
import
|
|
22
|
-
import
|
|
30
|
+
import Cache from '@aws-amplify/cache';
|
|
31
|
+
import Auth, { GRAPHQL_AUTH_MODE } from '@aws-amplify/auth';
|
|
23
32
|
import { AbstractPubSubProvider } from '../PubSubProvider';
|
|
24
|
-
import { CONTROL_MSG
|
|
33
|
+
import { CONTROL_MSG } from '../../types/PubSub';
|
|
25
34
|
|
|
26
35
|
import {
|
|
27
36
|
AMPLIFY_SYMBOL,
|
|
@@ -41,10 +50,6 @@ import {
|
|
|
41
50
|
ConnectionStateMonitor,
|
|
42
51
|
CONNECTION_CHANGE,
|
|
43
52
|
} from '../../utils/ConnectionStateMonitor';
|
|
44
|
-
import {
|
|
45
|
-
ReconnectEvent,
|
|
46
|
-
ReconnectionMonitor,
|
|
47
|
-
} from '../../utils/ReconnectionMonitor';
|
|
48
53
|
|
|
49
54
|
const logger = new Logger('AWSAppSyncRealTimeProvider');
|
|
50
55
|
|
|
@@ -94,63 +99,23 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
|
94
99
|
private keepAliveAlertTimeoutId?: ReturnType<typeof setTimeout>;
|
|
95
100
|
private subscriptionObserverMap: Map<string, ObserverQuery> = new Map();
|
|
96
101
|
private promiseArray: Array<{ res: Function; rej: Function }> = [];
|
|
97
|
-
private connectionState: ConnectionState;
|
|
98
102
|
private readonly connectionStateMonitor = new ConnectionStateMonitor();
|
|
99
|
-
private readonly reconnectionMonitor = new ReconnectionMonitor();
|
|
100
|
-
private connectionStateMonitorSubscription: ZenObservable.Subscription;
|
|
101
103
|
|
|
102
104
|
constructor(options: ProviderOptions = {}) {
|
|
103
105
|
super(options);
|
|
104
106
|
// Monitor the connection state and pass changes along to Hub
|
|
105
|
-
this.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
// Trigger START_RECONNECT when the connection is disrupted
|
|
119
|
-
if (connectionState === ConnectionState.ConnectionDisrupted) {
|
|
120
|
-
this.reconnectionMonitor.record(ReconnectEvent.START_RECONNECT);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Trigger HALT_RECONNECT to halt reconnection attempts when the state is anything other than
|
|
124
|
-
// ConnectionDisrupted or Connecting
|
|
125
|
-
if (
|
|
126
|
-
[
|
|
127
|
-
ConnectionState.Connected,
|
|
128
|
-
ConnectionState.ConnectedPendingDisconnect,
|
|
129
|
-
ConnectionState.ConnectedPendingKeepAlive,
|
|
130
|
-
ConnectionState.ConnectedPendingNetwork,
|
|
131
|
-
ConnectionState.ConnectedPendingNetwork,
|
|
132
|
-
ConnectionState.ConnectionDisruptedPendingNetwork,
|
|
133
|
-
ConnectionState.Disconnected,
|
|
134
|
-
].includes(connectionState)
|
|
135
|
-
) {
|
|
136
|
-
this.reconnectionMonitor.record(ReconnectEvent.HALT_RECONNECT);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Mark the socket closed and release all active listeners
|
|
144
|
-
*/
|
|
145
|
-
close() {
|
|
146
|
-
// Mark the socket closed both in status and the connection monitor
|
|
147
|
-
this.socketStatus = SOCKET_STATUS.CLOSED;
|
|
148
|
-
this.connectionStateMonitor.record(CONNECTION_CHANGE.CONNECTION_FAILED);
|
|
149
|
-
|
|
150
|
-
// Turn off the subscription monitor Hub publishing
|
|
151
|
-
this.connectionStateMonitorSubscription.unsubscribe();
|
|
152
|
-
// Complete all reconnect observers
|
|
153
|
-
this.reconnectionMonitor.close();
|
|
107
|
+
this.connectionStateMonitor.connectionStateObservable.subscribe(
|
|
108
|
+
ConnectionState => {
|
|
109
|
+
dispatchApiEvent(
|
|
110
|
+
CONNECTION_STATE_CHANGE,
|
|
111
|
+
{
|
|
112
|
+
provider: this,
|
|
113
|
+
connectionState: ConnectionState,
|
|
114
|
+
},
|
|
115
|
+
`Connection state is ${ConnectionState}`
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
);
|
|
154
119
|
}
|
|
155
120
|
|
|
156
121
|
getNewWebSocket(url, protocol) {
|
|
@@ -193,44 +158,26 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
|
193
158
|
});
|
|
194
159
|
observer.complete();
|
|
195
160
|
} else {
|
|
196
|
-
let subscriptionStartActive = false;
|
|
197
161
|
const subscriptionId = uuid();
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
logger.debug(
|
|
162
|
+
this._startSubscriptionWithAWSAppSyncRealTime({
|
|
163
|
+
options,
|
|
164
|
+
observer,
|
|
165
|
+
subscriptionId,
|
|
166
|
+
}).catch<any>(err => {
|
|
167
|
+
observer.error({
|
|
168
|
+
errors: [
|
|
169
|
+
{
|
|
170
|
+
...new GraphQLError(
|
|
208
171
|
`${CONTROL_MSG.REALTIME_SUBSCRIPTION_INIT_ERROR}: ${err}`
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
let reconnectSubscription: ZenObservable.Subscription;
|
|
220
|
-
|
|
221
|
-
// Add an observable to the reconnection list to manage reconnection for this subscription
|
|
222
|
-
reconnectSubscription = new Observable(observer => {
|
|
223
|
-
this.reconnectionMonitor.addObserver(observer);
|
|
224
|
-
}).subscribe(() => {
|
|
225
|
-
startSubscription();
|
|
172
|
+
),
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
});
|
|
176
|
+
this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
|
|
177
|
+
observer.complete();
|
|
226
178
|
});
|
|
227
179
|
|
|
228
|
-
startSubscription();
|
|
229
|
-
|
|
230
180
|
return async () => {
|
|
231
|
-
// Cleanup reconnection subscription
|
|
232
|
-
reconnectSubscription?.unsubscribe();
|
|
233
|
-
|
|
234
181
|
// Cleanup after unsubscribing or observer.complete was called after _startSubscriptionWithAWSAppSyncRealTime
|
|
235
182
|
try {
|
|
236
183
|
// Waiting that subscription has been connected before trying to unsubscribe
|
|
@@ -341,7 +288,24 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
|
341
288
|
additionalHeaders,
|
|
342
289
|
});
|
|
343
290
|
} catch (err) {
|
|
344
|
-
|
|
291
|
+
logger.debug({ err });
|
|
292
|
+
const message = err['message'] ?? '';
|
|
293
|
+
this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
|
|
294
|
+
observer.error({
|
|
295
|
+
errors: [
|
|
296
|
+
{
|
|
297
|
+
...new GraphQLError(`${CONTROL_MSG.CONNECTION_FAILED}: ${message}`),
|
|
298
|
+
},
|
|
299
|
+
],
|
|
300
|
+
});
|
|
301
|
+
observer.complete();
|
|
302
|
+
const { subscriptionFailedCallback } =
|
|
303
|
+
this.subscriptionObserverMap.get(subscriptionId) || {};
|
|
304
|
+
|
|
305
|
+
// Notify concurrent unsubscription
|
|
306
|
+
if (typeof subscriptionFailedCallback === 'function') {
|
|
307
|
+
subscriptionFailedCallback();
|
|
308
|
+
}
|
|
345
309
|
return;
|
|
346
310
|
}
|
|
347
311
|
|
|
@@ -369,44 +333,6 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
|
369
333
|
}
|
|
370
334
|
}
|
|
371
335
|
|
|
372
|
-
// Log logic for start subscription failures
|
|
373
|
-
private _logStartSubscriptionError(subscriptionId, observer, err) {
|
|
374
|
-
logger.debug({ err });
|
|
375
|
-
const message = err['message'] ?? '';
|
|
376
|
-
// Resolving to give the state observer time to propogate the update
|
|
377
|
-
Promise.resolve(
|
|
378
|
-
this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED)
|
|
379
|
-
);
|
|
380
|
-
|
|
381
|
-
// Capture the error only when the network didn't cause disruption
|
|
382
|
-
if (
|
|
383
|
-
this.connectionState !== ConnectionState.ConnectionDisruptedPendingNetwork
|
|
384
|
-
) {
|
|
385
|
-
// When the error is non-retriable, error out the observable
|
|
386
|
-
if (isNonRetryableError(err)) {
|
|
387
|
-
observer.error({
|
|
388
|
-
errors: [
|
|
389
|
-
{
|
|
390
|
-
...new GraphQLError(
|
|
391
|
-
`${CONTROL_MSG.CONNECTION_FAILED}: ${message}`
|
|
392
|
-
),
|
|
393
|
-
},
|
|
394
|
-
],
|
|
395
|
-
});
|
|
396
|
-
} else {
|
|
397
|
-
logger.debug(`${CONTROL_MSG.CONNECTION_FAILED}: ${message}`);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
const { subscriptionFailedCallback } =
|
|
401
|
-
this.subscriptionObserverMap.get(subscriptionId) || {};
|
|
402
|
-
|
|
403
|
-
// Notify concurrent unsubscription
|
|
404
|
-
if (typeof subscriptionFailedCallback === 'function') {
|
|
405
|
-
subscriptionFailedCallback();
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
|
|
410
336
|
// Waiting that subscription has been connected before trying to unsubscribe
|
|
411
337
|
private async _waitForSubscriptionToBeConnected(subscriptionId: string) {
|
|
412
338
|
const subscriptionObserver =
|
|
@@ -579,10 +505,6 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
|
579
505
|
subscriptionState,
|
|
580
506
|
});
|
|
581
507
|
|
|
582
|
-
logger.debug(
|
|
583
|
-
`${CONTROL_MSG.CONNECTION_FAILED}: ${JSON.stringify(payload)}`
|
|
584
|
-
);
|
|
585
|
-
|
|
586
508
|
observer.error({
|
|
587
509
|
errors: [
|
|
588
510
|
{
|
|
@@ -592,9 +514,9 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
|
592
514
|
},
|
|
593
515
|
],
|
|
594
516
|
});
|
|
595
|
-
|
|
596
517
|
if (startAckTimeoutId) clearTimeout(startAckTimeoutId);
|
|
597
518
|
|
|
519
|
+
observer.complete();
|
|
598
520
|
if (typeof subscriptionFailedCallback === 'function') {
|
|
599
521
|
subscriptionFailedCallback();
|
|
600
522
|
}
|
|
@@ -604,7 +526,14 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
|
604
526
|
|
|
605
527
|
private _errorDisconnect(msg: string) {
|
|
606
528
|
logger.debug(`Disconnect error: ${msg}`);
|
|
607
|
-
|
|
529
|
+
this.subscriptionObserverMap.forEach(({ observer }) => {
|
|
530
|
+
if (observer && !observer.closed) {
|
|
531
|
+
observer.error({
|
|
532
|
+
errors: [{ ...new GraphQLError(msg) }],
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
this.subscriptionObserverMap.clear();
|
|
608
537
|
if (this.awsRealTimeSocket) {
|
|
609
538
|
this.connectionStateMonitor.record(CONNECTION_CHANGE.CLOSED);
|
|
610
539
|
this.awsRealTimeSocket.close();
|
|
@@ -628,7 +557,22 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
|
628
557
|
subscriptionState: SUBSCRIPTION_STATUS.FAILED,
|
|
629
558
|
});
|
|
630
559
|
|
|
631
|
-
|
|
560
|
+
if (observer && !observer.closed) {
|
|
561
|
+
observer.error({
|
|
562
|
+
errors: [
|
|
563
|
+
{
|
|
564
|
+
...new GraphQLError(
|
|
565
|
+
`Subscription timeout ${JSON.stringify({
|
|
566
|
+
query,
|
|
567
|
+
variables,
|
|
568
|
+
})}`
|
|
569
|
+
),
|
|
570
|
+
},
|
|
571
|
+
],
|
|
572
|
+
});
|
|
573
|
+
// Cleanup will be automatically executed
|
|
574
|
+
observer.complete();
|
|
575
|
+
}
|
|
632
576
|
logger.debug(
|
|
633
577
|
'timeoutStartSubscription',
|
|
634
578
|
JSON.stringify({ query, variables })
|
|
@@ -697,7 +641,6 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
|
697
641
|
this.socketStatus = SOCKET_STATUS.READY;
|
|
698
642
|
this.promiseArray = [];
|
|
699
643
|
} catch (err) {
|
|
700
|
-
logger.debug('Connection exited with', err);
|
|
701
644
|
this.promiseArray.forEach(({ rej }) => rej(err));
|
|
702
645
|
this.promiseArray = [];
|
|
703
646
|
if (
|
|
@@ -734,6 +677,9 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
|
734
677
|
logger.debug(`WebSocket connection error`);
|
|
735
678
|
};
|
|
736
679
|
newSocket.onclose = () => {
|
|
680
|
+
this.connectionStateMonitor.record(
|
|
681
|
+
CONNECTION_CHANGE.CONNECTION_FAILED
|
|
682
|
+
);
|
|
737
683
|
rej(new Error('Connection handshake error'));
|
|
738
684
|
};
|
|
739
685
|
newSocket.onopen = () => {
|
|
@@ -742,6 +688,7 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider {
|
|
|
742
688
|
};
|
|
743
689
|
});
|
|
744
690
|
})();
|
|
691
|
+
|
|
745
692
|
// Step 2: wait for ack from AWS AppSyncReaTime after sending init
|
|
746
693
|
await (() => {
|
|
747
694
|
return new Promise((res, rej) => {
|