@aws-amplify/core 6.0.1-console-preview.67f944e.0 → 6.0.1-console-preview.0bbe168.0
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/lib/AwsClients/Pinpoint/getInAppMessages.d.ts +1 -1
- package/lib/AwsClients/Pinpoint/putEvents.d.ts +1 -1
- package/lib/AwsClients/Pinpoint/updateEndpoint.d.ts +1 -1
- package/lib/BackgroundProcessManager/BackgroundManagerNotOpenError.d.ts +3 -0
- package/lib/BackgroundProcessManager/BackgroundManagerNotOpenError.js +28 -0
- package/{lib-esm/Util → lib/BackgroundProcessManager}/BackgroundProcessManager.d.ts +1 -23
- package/lib/{Util → BackgroundProcessManager}/BackgroundProcessManager.js +13 -56
- package/lib/BackgroundProcessManager/index.d.ts +1 -0
- package/lib/BackgroundProcessManager/index.js +7 -0
- package/lib/BackgroundProcessManager/types.d.ts +41 -0
- package/lib/BackgroundProcessManager/types.js +23 -0
- package/lib/Hub/index.js +2 -2
- package/lib/Logger/ConsoleLogger.js +2 -2
- package/lib/{Util → Mutex}/Mutex.d.ts +2 -15
- package/lib/{Util → Mutex}/Mutex.js +2 -1
- package/lib/Mutex/index.d.ts +1 -0
- package/lib/Mutex/index.js +7 -0
- package/lib/Mutex/types.d.ts +13 -0
- package/lib/Mutex/types.js +4 -0
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/Reachability/Reachability.d.ts +6 -0
- package/lib/Reachability/Reachability.js +29 -0
- package/lib/Reachability/Reachability.native.d.ts +6 -0
- package/lib/{Util → Reachability}/Reachability.native.js +8 -10
- package/lib/Reachability/index.d.ts +1 -0
- package/lib/Reachability/index.js +7 -0
- package/lib/Reachability/types.d.ts +3 -0
- package/lib/Reachability/types.js +4 -0
- package/lib/ServiceWorker/ServiceWorker.js +2 -2
- package/lib/{Signer.js → Signer/Signer.js} +3 -3
- package/lib/Signer/index.d.ts +1 -0
- package/lib/Signer/index.js +7 -0
- package/lib/clients/middleware/retry/jitteredBackoff.js +2 -2
- package/lib/{Util/Constants.d.ts → constants.d.ts} +0 -2
- package/lib/{Util/Constants.js → constants.js} +1 -6
- package/lib/libraryUtils.d.ts +7 -6
- package/lib/libraryUtils.js +37 -49
- package/lib/providers/pinpoint/apis/updateEndpoint.d.ts +1 -1
- package/lib/providers/pinpoint/apis/updateEndpoint.js +7 -5
- package/lib/providers/pinpoint/types/pinpoint.d.ts +1 -0
- package/lib/singleton/Auth/utils/index.js +2 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/core.d.ts +4 -1
- package/lib/utils/convert/base64/base64Decoder.d.ts +2 -0
- package/lib/utils/convert/base64/base64Decoder.js +11 -0
- package/lib/utils/convert/base64/base64Encoder.d.ts +2 -0
- package/lib/utils/convert/base64/base64Encoder.js +18 -0
- package/lib/utils/convert/base64/bytesToString.d.ts +1 -0
- package/lib/utils/convert/base64/bytesToString.js +9 -0
- package/lib/utils/convert/index.d.ts +2 -0
- package/lib/utils/convert/index.js +9 -0
- package/lib/utils/convert/types.d.ts +9 -0
- package/lib/utils/convert/types.js +4 -0
- package/lib/utils/generateRandomString.d.ts +1 -0
- package/lib/utils/generateRandomString.js +14 -0
- package/lib/utils/globalHelpers/index.d.ts +3 -0
- package/lib/utils/globalHelpers/index.js +50 -0
- package/lib/utils/globalHelpers/index.native.d.ts +5 -0
- package/lib/utils/globalHelpers/index.native.js +27 -0
- package/lib/utils/index.d.ts +6 -0
- package/lib/utils/index.js +21 -0
- package/lib/utils/isBrowser.d.ts +1 -0
- package/lib/utils/isBrowser.js +9 -0
- package/lib/utils/isWebWorker.d.ts +1 -0
- package/lib/utils/isWebWorker.js +14 -0
- package/lib/utils/retry/NonRetryableError.d.ts +4 -0
- package/lib/utils/retry/NonRetryableError.js +30 -0
- package/lib/utils/retry/constants.d.ts +1 -0
- package/lib/utils/retry/constants.js +6 -0
- package/lib/utils/retry/index.d.ts +5 -0
- package/lib/utils/retry/index.js +15 -0
- package/lib/utils/retry/isNonRetryableError.d.ts +2 -0
- package/lib/utils/retry/isNonRetryableError.js +10 -0
- package/lib/utils/retry/jitteredBackoff.d.ts +6 -0
- package/lib/utils/retry/jitteredBackoff.js +20 -0
- package/lib/utils/retry/jitteredExponentialRetry.d.ts +5 -0
- package/lib/utils/retry/jitteredExponentialRetry.js +17 -0
- package/lib/utils/retry/retry.d.ts +6 -0
- package/lib/{Util/Retry.js → utils/retry/retry.js} +6 -57
- package/lib/utils/urlSafeDecode.d.ts +1 -0
- package/lib/{Util/StringUtils.js → utils/urlSafeDecode.js} +2 -9
- package/lib/utils/urlSafeEncode.d.ts +1 -0
- package/lib/utils/urlSafeEncode.js +12 -0
- package/lib-esm/AwsClients/Pinpoint/getInAppMessages.d.ts +1 -1
- package/lib-esm/AwsClients/Pinpoint/putEvents.d.ts +1 -1
- package/lib-esm/AwsClients/Pinpoint/updateEndpoint.d.ts +1 -1
- package/lib-esm/BackgroundProcessManager/BackgroundManagerNotOpenError.d.ts +3 -0
- package/lib-esm/BackgroundProcessManager/BackgroundManagerNotOpenError.js +25 -0
- package/{lib/Util → lib-esm/BackgroundProcessManager}/BackgroundProcessManager.d.ts +1 -23
- package/lib-esm/{Util → BackgroundProcessManager}/BackgroundProcessManager.js +4 -47
- package/lib-esm/BackgroundProcessManager/index.d.ts +1 -0
- package/lib-esm/BackgroundProcessManager/index.js +3 -0
- package/lib-esm/BackgroundProcessManager/types.d.ts +41 -0
- package/lib-esm/BackgroundProcessManager/types.js +20 -0
- package/lib-esm/Hub/index.js +1 -1
- package/lib-esm/Logger/ConsoleLogger.js +1 -1
- package/lib-esm/{Util → Mutex}/Mutex.d.ts +2 -15
- package/lib-esm/{Util → Mutex}/Mutex.js +1 -1
- package/lib-esm/Mutex/index.d.ts +1 -0
- package/lib-esm/Mutex/index.js +3 -0
- package/lib-esm/Mutex/types.d.ts +13 -0
- package/lib-esm/Mutex/types.js +3 -0
- package/lib-esm/Platform/version.d.ts +1 -1
- package/lib-esm/Platform/version.js +1 -1
- package/lib-esm/Reachability/Reachability.d.ts +6 -0
- package/lib-esm/Reachability/Reachability.js +26 -0
- package/lib-esm/Reachability/Reachability.native.d.ts +6 -0
- package/lib-esm/{Util → Reachability}/Reachability.native.js +6 -6
- package/lib-esm/Reachability/index.d.ts +1 -0
- package/lib-esm/Reachability/index.js +3 -0
- package/lib-esm/Reachability/types.d.ts +3 -0
- package/lib-esm/Reachability/types.js +3 -0
- package/lib-esm/ServiceWorker/ServiceWorker.js +1 -1
- package/lib-esm/{Signer.js → Signer/Signer.js} +2 -2
- package/lib-esm/Signer/index.d.ts +1 -0
- package/lib-esm/Signer/index.js +3 -0
- package/lib-esm/clients/middleware/retry/jitteredBackoff.js +1 -1
- package/lib-esm/{Util/Constants.d.ts → constants.d.ts} +0 -2
- package/lib-esm/{Util/Constants.js → constants.js} +0 -5
- package/lib-esm/libraryUtils.d.ts +7 -6
- package/lib-esm/libraryUtils.js +8 -8
- package/lib-esm/providers/pinpoint/apis/updateEndpoint.d.ts +1 -1
- package/lib-esm/providers/pinpoint/apis/updateEndpoint.js +7 -5
- package/lib-esm/providers/pinpoint/types/pinpoint.d.ts +1 -0
- package/lib-esm/singleton/Auth/utils/index.js +2 -1
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types/core.d.ts +4 -1
- package/lib-esm/utils/convert/base64/base64Decoder.d.ts +2 -0
- package/lib-esm/utils/convert/base64/base64Decoder.js +8 -0
- package/lib-esm/utils/convert/base64/base64Encoder.d.ts +2 -0
- package/lib-esm/utils/convert/base64/base64Encoder.js +15 -0
- package/lib-esm/utils/convert/base64/bytesToString.d.ts +1 -0
- package/lib-esm/utils/convert/base64/bytesToString.js +5 -0
- package/lib-esm/utils/convert/index.d.ts +2 -0
- package/lib-esm/utils/convert/index.js +4 -0
- package/lib-esm/utils/convert/types.d.ts +9 -0
- package/lib-esm/utils/convert/types.js +3 -0
- package/lib-esm/utils/generateRandomString.d.ts +1 -0
- package/lib-esm/utils/generateRandomString.js +10 -0
- package/lib-esm/utils/globalHelpers/index.d.ts +3 -0
- package/lib-esm/utils/globalHelpers/index.js +44 -0
- package/lib-esm/utils/globalHelpers/index.native.d.ts +5 -0
- package/lib-esm/utils/globalHelpers/index.native.js +21 -0
- package/lib-esm/utils/index.d.ts +6 -0
- package/lib-esm/utils/index.js +8 -0
- package/lib-esm/utils/isBrowser.d.ts +1 -0
- package/lib-esm/utils/isBrowser.js +5 -0
- package/lib-esm/utils/isWebWorker.d.ts +1 -0
- package/lib-esm/utils/isWebWorker.js +10 -0
- package/lib-esm/utils/retry/NonRetryableError.d.ts +4 -0
- package/lib-esm/utils/retry/NonRetryableError.js +27 -0
- package/lib-esm/utils/retry/constants.d.ts +1 -0
- package/lib-esm/utils/retry/constants.js +3 -0
- package/lib-esm/utils/retry/index.d.ts +5 -0
- package/lib-esm/utils/retry/index.js +7 -0
- package/lib-esm/utils/retry/isNonRetryableError.d.ts +2 -0
- package/lib-esm/utils/retry/isNonRetryableError.js +6 -0
- package/lib-esm/utils/retry/jitteredBackoff.d.ts +6 -0
- package/lib-esm/utils/retry/jitteredBackoff.js +16 -0
- package/lib-esm/utils/retry/jitteredExponentialRetry.d.ts +5 -0
- package/lib-esm/utils/retry/jitteredExponentialRetry.js +13 -0
- package/lib-esm/utils/retry/retry.d.ts +6 -0
- package/lib-esm/{Util/Retry.js → utils/retry/retry.js} +4 -52
- package/lib-esm/{Util/StringUtils.d.ts → utils/urlSafeDecode.d.ts} +0 -1
- package/lib-esm/{Util/StringUtils.js → utils/urlSafeDecode.js} +0 -6
- package/{lib/Util/StringUtils.d.ts → lib-esm/utils/urlSafeEncode.d.ts} +0 -1
- package/lib-esm/utils/urlSafeEncode.js +8 -0
- package/package.json +7 -4
- package/src/BackgroundProcessManager/BackgroundManagerNotOpenError.ts +8 -0
- package/src/{Util → BackgroundProcessManager}/BackgroundProcessManager.ts +4 -58
- package/src/BackgroundProcessManager/index.ts +4 -0
- package/src/BackgroundProcessManager/types.ts +49 -0
- package/src/Hub/index.ts +1 -1
- package/src/Logger/ConsoleLogger.ts +1 -1
- package/src/{Util → Mutex}/Mutex.ts +2 -20
- package/src/Mutex/index.ts +4 -0
- package/src/Mutex/types.ts +20 -0
- package/src/Platform/version.ts +1 -1
- package/src/{Util → Reachability}/Reachability.native.ts +4 -11
- package/src/Reachability/Reachability.ts +35 -0
- package/src/Reachability/index.ts +4 -0
- package/src/Reachability/types.ts +6 -0
- package/src/ServiceWorker/ServiceWorker.ts +1 -1
- package/src/{Signer.ts → Signer/Signer.ts} +2 -2
- package/src/Signer/index.ts +4 -0
- package/src/clients/middleware/retry/jitteredBackoff.ts +1 -1
- package/src/{Util/Constants.ts → constants.ts} +0 -5
- package/src/libraryUtils.ts +16 -35
- package/src/providers/pinpoint/apis/updateEndpoint.ts +19 -3
- package/src/providers/pinpoint/types/pinpoint.ts +1 -0
- package/src/singleton/Auth/utils/index.ts +2 -1
- package/src/types/core.ts +4 -1
- package/src/utils/convert/base64/base64Decoder.ts +11 -0
- package/src/utils/convert/base64/base64Encoder.ts +18 -0
- package/src/utils/convert/base64/bytesToString.ts +6 -0
- package/src/utils/convert/index.ts +5 -0
- package/src/utils/convert/types.ts +17 -0
- package/src/utils/generateRandomString.ts +16 -0
- package/src/utils/globalHelpers/index.native.ts +28 -0
- package/src/utils/globalHelpers/index.ts +54 -0
- package/src/utils/index.ts +15 -0
- package/src/utils/isBrowser.ts +5 -0
- package/src/utils/isWebWorker.ts +13 -0
- package/src/utils/retry/NonRetryableError.ts +9 -0
- package/src/utils/retry/constants.ts +4 -0
- package/src/utils/retry/index.ts +8 -0
- package/src/utils/retry/isNonRetryableError.ts +9 -0
- package/src/utils/retry/jitteredBackoff.ts +21 -0
- package/src/utils/retry/jitteredExponentialRetry.ts +18 -0
- package/src/{Util/Retry.ts → utils/retry/retry.ts} +4 -44
- package/src/{Util/StringUtils.ts → utils/urlSafeDecode.ts} +0 -6
- package/src/utils/urlSafeEncode.ts +9 -0
- package/lib/Util/JS.d.ts +0 -29
- package/lib/Util/JS.js +0 -214
- package/lib/Util/Reachability.d.ts +0 -13
- package/lib/Util/Reachability.js +0 -69
- package/lib/Util/Reachability.native.d.ts +0 -12
- package/lib/Util/Retry.d.ts +0 -21
- package/lib/Util/index.d.ts +0 -7
- package/lib/Util/index.js +0 -31
- package/lib-esm/Util/JS.d.ts +0 -29
- package/lib-esm/Util/JS.js +0 -199
- package/lib-esm/Util/Reachability.d.ts +0 -13
- package/lib-esm/Util/Reachability.js +0 -64
- package/lib-esm/Util/Reachability.native.d.ts +0 -12
- package/lib-esm/Util/Retry.d.ts +0 -21
- package/lib-esm/Util/index.d.ts +0 -7
- package/lib-esm/Util/index.js +0 -9
- package/src/Util/JS.ts +0 -255
- package/src/Util/Reachability.ts +0 -58
- package/src/Util/index.ts +0 -23
- /package/lib/{Util → Signer}/DateUtils.d.ts +0 -0
- /package/lib/{Util → Signer}/DateUtils.js +0 -0
- /package/lib/{Signer.d.ts → Signer/Signer.d.ts} +0 -0
- /package/lib-esm/{Util → Signer}/DateUtils.d.ts +0 -0
- /package/lib-esm/{Util → Signer}/DateUtils.js +0 -0
- /package/lib-esm/{Signer.d.ts → Signer/Signer.d.ts} +0 -0
- /package/src/{Util → Signer}/DateUtils.ts +0 -0
package/lib-esm/Util/JS.js
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
var MIME_MAP = [
|
|
4
|
-
{ type: 'text/plain', ext: 'txt' },
|
|
5
|
-
{ type: 'text/html', ext: 'html' },
|
|
6
|
-
{ type: 'text/javascript', ext: 'js' },
|
|
7
|
-
{ type: 'text/css', ext: 'css' },
|
|
8
|
-
{ type: 'text/csv', ext: 'csv' },
|
|
9
|
-
{ type: 'text/yaml', ext: 'yml' },
|
|
10
|
-
{ type: 'text/yaml', ext: 'yaml' },
|
|
11
|
-
{ type: 'text/calendar', ext: 'ics' },
|
|
12
|
-
{ type: 'text/calendar', ext: 'ical' },
|
|
13
|
-
{ type: 'image/apng', ext: 'apng' },
|
|
14
|
-
{ type: 'image/bmp', ext: 'bmp' },
|
|
15
|
-
{ type: 'image/gif', ext: 'gif' },
|
|
16
|
-
{ type: 'image/x-icon', ext: 'ico' },
|
|
17
|
-
{ type: 'image/x-icon', ext: 'cur' },
|
|
18
|
-
{ type: 'image/jpeg', ext: 'jpg' },
|
|
19
|
-
{ type: 'image/jpeg', ext: 'jpeg' },
|
|
20
|
-
{ type: 'image/jpeg', ext: 'jfif' },
|
|
21
|
-
{ type: 'image/jpeg', ext: 'pjp' },
|
|
22
|
-
{ type: 'image/jpeg', ext: 'pjpeg' },
|
|
23
|
-
{ type: 'image/png', ext: 'png' },
|
|
24
|
-
{ type: 'image/svg+xml', ext: 'svg' },
|
|
25
|
-
{ type: 'image/tiff', ext: 'tif' },
|
|
26
|
-
{ type: 'image/tiff', ext: 'tiff' },
|
|
27
|
-
{ type: 'image/webp', ext: 'webp' },
|
|
28
|
-
{ type: 'application/json', ext: 'json' },
|
|
29
|
-
{ type: 'application/xml', ext: 'xml' },
|
|
30
|
-
{ type: 'application/x-sh', ext: 'sh' },
|
|
31
|
-
{ type: 'application/zip', ext: 'zip' },
|
|
32
|
-
{ type: 'application/x-rar-compressed', ext: 'rar' },
|
|
33
|
-
{ type: 'application/x-tar', ext: 'tar' },
|
|
34
|
-
{ type: 'application/x-bzip', ext: 'bz' },
|
|
35
|
-
{ type: 'application/x-bzip2', ext: 'bz2' },
|
|
36
|
-
{ type: 'application/pdf', ext: 'pdf' },
|
|
37
|
-
{ type: 'application/java-archive', ext: 'jar' },
|
|
38
|
-
{ type: 'application/msword', ext: 'doc' },
|
|
39
|
-
{ type: 'application/vnd.ms-excel', ext: 'xls' },
|
|
40
|
-
{ type: 'application/vnd.ms-excel', ext: 'xlsx' },
|
|
41
|
-
{ type: 'message/rfc822', ext: 'eml' },
|
|
42
|
-
];
|
|
43
|
-
export var isEmpty = function (obj) {
|
|
44
|
-
if (obj === void 0) { obj = {}; }
|
|
45
|
-
return Object.keys(obj).length === 0;
|
|
46
|
-
};
|
|
47
|
-
export var sortByField = function (list, field, dir) {
|
|
48
|
-
if (!list || !list.sort) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
var dirX = dir && dir === 'desc' ? -1 : 1;
|
|
52
|
-
list.sort(function (a, b) {
|
|
53
|
-
var a_val = a[field];
|
|
54
|
-
var b_val = b[field];
|
|
55
|
-
if (typeof b_val === 'undefined') {
|
|
56
|
-
return typeof a_val === 'undefined' ? 0 : 1 * dirX;
|
|
57
|
-
}
|
|
58
|
-
if (typeof a_val === 'undefined') {
|
|
59
|
-
return -1 * dirX;
|
|
60
|
-
}
|
|
61
|
-
if (a_val < b_val) {
|
|
62
|
-
return -1 * dirX;
|
|
63
|
-
}
|
|
64
|
-
if (a_val > b_val) {
|
|
65
|
-
return 1 * dirX;
|
|
66
|
-
}
|
|
67
|
-
return 0;
|
|
68
|
-
});
|
|
69
|
-
return true;
|
|
70
|
-
};
|
|
71
|
-
export var objectLessAttributes = function (obj, less) {
|
|
72
|
-
var ret = Object.assign({}, obj);
|
|
73
|
-
if (less) {
|
|
74
|
-
if (typeof less === 'string') {
|
|
75
|
-
delete ret[less];
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
less.forEach(function (attr) {
|
|
79
|
-
delete ret[attr];
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return ret;
|
|
84
|
-
};
|
|
85
|
-
export var filenameToContentType = function (filename, defVal) {
|
|
86
|
-
if (defVal === void 0) { defVal = 'application/octet-stream'; }
|
|
87
|
-
var name = filename.toLowerCase();
|
|
88
|
-
var filtered = MIME_MAP.filter(function (mime) { return name.endsWith('.' + mime.ext); });
|
|
89
|
-
return filtered.length > 0 ? filtered[0].type : defVal;
|
|
90
|
-
};
|
|
91
|
-
export var isTextFile = function (contentType) {
|
|
92
|
-
var type = contentType.toLowerCase();
|
|
93
|
-
if (type.startsWith('text/')) {
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
return ('application/json' === type ||
|
|
97
|
-
'application/xml' === type ||
|
|
98
|
-
'application/sh' === type);
|
|
99
|
-
};
|
|
100
|
-
export var generateRandomString = function () {
|
|
101
|
-
var result = '';
|
|
102
|
-
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
103
|
-
for (var i = 32; i > 0; i -= 1) {
|
|
104
|
-
result += chars[Math.floor(Math.random() * chars.length)];
|
|
105
|
-
}
|
|
106
|
-
return result;
|
|
107
|
-
};
|
|
108
|
-
export var makeQuerablePromise = function (promise) {
|
|
109
|
-
if (promise.isResolved)
|
|
110
|
-
return promise;
|
|
111
|
-
var isPending = true;
|
|
112
|
-
var isRejected = false;
|
|
113
|
-
var isFullfilled = false;
|
|
114
|
-
var result = promise.then(function (data) {
|
|
115
|
-
isFullfilled = true;
|
|
116
|
-
isPending = false;
|
|
117
|
-
return data;
|
|
118
|
-
}, function (e) {
|
|
119
|
-
isRejected = true;
|
|
120
|
-
isPending = false;
|
|
121
|
-
throw e;
|
|
122
|
-
});
|
|
123
|
-
result.isFullfilled = function () { return isFullfilled; };
|
|
124
|
-
result.isPending = function () { return isPending; };
|
|
125
|
-
result.isRejected = function () { return isRejected; };
|
|
126
|
-
return result;
|
|
127
|
-
};
|
|
128
|
-
export var isWebWorker = function () {
|
|
129
|
-
if (typeof self === 'undefined') {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
var selfContext = self;
|
|
133
|
-
return (typeof selfContext.WorkerGlobalScope !== 'undefined' &&
|
|
134
|
-
self instanceof selfContext.WorkerGlobalScope);
|
|
135
|
-
};
|
|
136
|
-
export var isBrowser = function () {
|
|
137
|
-
return typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* transfer the first letter of the keys to lowercase
|
|
141
|
-
* @param {Object} obj - the object need to be transferred
|
|
142
|
-
* @param {Array} whiteListForItself - whitelist itself from being transferred
|
|
143
|
-
* @param {Array} whiteListForChildren - whitelist its children keys from being transferred
|
|
144
|
-
*/
|
|
145
|
-
export var transferKeyToLowerCase = function (obj, whiteListForItself, whiteListForChildren) {
|
|
146
|
-
if (whiteListForItself === void 0) { whiteListForItself = []; }
|
|
147
|
-
if (whiteListForChildren === void 0) { whiteListForChildren = []; }
|
|
148
|
-
if (!isStrictObject(obj))
|
|
149
|
-
return obj;
|
|
150
|
-
var ret = {};
|
|
151
|
-
for (var key in obj) {
|
|
152
|
-
if (obj.hasOwnProperty(key)) {
|
|
153
|
-
var transferedKey = whiteListForItself.includes(key)
|
|
154
|
-
? key
|
|
155
|
-
: key[0].toLowerCase() + key.slice(1);
|
|
156
|
-
ret[transferedKey] = whiteListForChildren.includes(key)
|
|
157
|
-
? obj[key]
|
|
158
|
-
: transferKeyToLowerCase(obj[key], whiteListForItself, whiteListForChildren);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return ret;
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* transfer the first letter of the keys to lowercase
|
|
165
|
-
* @param {Object} obj - the object need to be transferred
|
|
166
|
-
* @param {Array} whiteListForItself - whitelist itself from being transferred
|
|
167
|
-
* @param {Array} whiteListForChildren - whitelist its children keys from being transferred
|
|
168
|
-
*/
|
|
169
|
-
export var transferKeyToUpperCase = function (obj, whiteListForItself, whiteListForChildren) {
|
|
170
|
-
if (whiteListForItself === void 0) { whiteListForItself = []; }
|
|
171
|
-
if (whiteListForChildren === void 0) { whiteListForChildren = []; }
|
|
172
|
-
if (!isStrictObject(obj))
|
|
173
|
-
return obj;
|
|
174
|
-
var ret = {};
|
|
175
|
-
for (var key in obj) {
|
|
176
|
-
if (obj.hasOwnProperty(key)) {
|
|
177
|
-
var transferredKey = whiteListForItself.includes(key)
|
|
178
|
-
? key
|
|
179
|
-
: key[0].toUpperCase() + key.slice(1);
|
|
180
|
-
ret[transferredKey] = whiteListForChildren.includes(key)
|
|
181
|
-
? obj[key]
|
|
182
|
-
: transferKeyToUpperCase(obj[key], whiteListForItself, whiteListForChildren);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return ret;
|
|
186
|
-
};
|
|
187
|
-
/**
|
|
188
|
-
* Return true if the object is a strict object
|
|
189
|
-
* which means it's not Array, Function, Number, String, Boolean or Null
|
|
190
|
-
* @param obj the Object
|
|
191
|
-
*/
|
|
192
|
-
export var isStrictObject = function (obj) {
|
|
193
|
-
return (obj instanceof Object &&
|
|
194
|
-
!(obj instanceof Array) &&
|
|
195
|
-
!(obj instanceof Function) &&
|
|
196
|
-
!(obj instanceof Number) &&
|
|
197
|
-
!(obj instanceof String) &&
|
|
198
|
-
!(obj instanceof Boolean));
|
|
199
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import Observable from 'zen-observable-ts';
|
|
2
|
-
type NetworkStatus = {
|
|
3
|
-
online: boolean;
|
|
4
|
-
};
|
|
5
|
-
export default class ReachabilityNavigator implements Reachability {
|
|
6
|
-
private static _observers;
|
|
7
|
-
networkMonitor(netInfo?: any): Observable<NetworkStatus>;
|
|
8
|
-
private static _observerOverride;
|
|
9
|
-
}
|
|
10
|
-
interface Reachability {
|
|
11
|
-
networkMonitor(netInfo?: any): Observable<NetworkStatus>;
|
|
12
|
-
}
|
|
13
|
-
export {};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
var __values = (this && this.__values) || function(o) {
|
|
2
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
-
if (m) return m.call(o);
|
|
4
|
-
if (o && typeof o.length === "number") return {
|
|
5
|
-
next: function () {
|
|
6
|
-
if (o && i >= o.length) o = void 0;
|
|
7
|
-
return { value: o && o[i++], done: !o };
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
-
};
|
|
12
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
13
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
14
|
-
import Observable from 'zen-observable-ts';
|
|
15
|
-
import { isWebWorker } from './JS';
|
|
16
|
-
var ReachabilityNavigator = /** @class */ (function () {
|
|
17
|
-
function ReachabilityNavigator() {
|
|
18
|
-
}
|
|
19
|
-
ReachabilityNavigator.prototype.networkMonitor = function (netInfo) {
|
|
20
|
-
var globalObj = isWebWorker() ? self : window;
|
|
21
|
-
return new Observable(function (observer) {
|
|
22
|
-
observer.next({ online: globalObj.navigator.onLine });
|
|
23
|
-
var notifyOnline = function () { return observer.next({ online: true }); };
|
|
24
|
-
var notifyOffline = function () { return observer.next({ online: false }); };
|
|
25
|
-
globalObj.addEventListener('online', notifyOnline);
|
|
26
|
-
globalObj.addEventListener('offline', notifyOffline);
|
|
27
|
-
ReachabilityNavigator._observers.push(observer);
|
|
28
|
-
return function () {
|
|
29
|
-
globalObj.removeEventListener('online', notifyOnline);
|
|
30
|
-
globalObj.removeEventListener('offline', notifyOffline);
|
|
31
|
-
ReachabilityNavigator._observers =
|
|
32
|
-
ReachabilityNavigator._observers.filter(function (_observer) { return _observer !== observer; });
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
// expose observers to simulate offline mode for integration testing
|
|
37
|
-
ReachabilityNavigator._observerOverride = function (status) {
|
|
38
|
-
var e_1, _a;
|
|
39
|
-
var _loop_1 = function (observer) {
|
|
40
|
-
if (observer.closed) {
|
|
41
|
-
ReachabilityNavigator._observers =
|
|
42
|
-
ReachabilityNavigator._observers.filter(function (_observer) { return _observer !== observer; });
|
|
43
|
-
return "continue";
|
|
44
|
-
}
|
|
45
|
-
observer.next(status);
|
|
46
|
-
};
|
|
47
|
-
try {
|
|
48
|
-
for (var _b = __values(ReachabilityNavigator._observers), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
49
|
-
var observer = _c.value;
|
|
50
|
-
_loop_1(observer);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
54
|
-
finally {
|
|
55
|
-
try {
|
|
56
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
57
|
-
}
|
|
58
|
-
finally { if (e_1) throw e_1.error; }
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
ReachabilityNavigator._observers = [];
|
|
62
|
-
return ReachabilityNavigator;
|
|
63
|
-
}());
|
|
64
|
-
export default ReachabilityNavigator;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Observable from 'zen-observable-ts';
|
|
2
|
-
import type NetInfo from '@react-native-community/netinfo';
|
|
3
|
-
type NetworkStatus = {
|
|
4
|
-
online: boolean;
|
|
5
|
-
};
|
|
6
|
-
export default class ReachabilityNavigator implements Reachability {
|
|
7
|
-
networkMonitor(netInfo?: typeof NetInfo): Observable<NetworkStatus>;
|
|
8
|
-
}
|
|
9
|
-
interface Reachability {
|
|
10
|
-
networkMonitor(netInfo?: typeof NetInfo): Observable<NetworkStatus>;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
package/lib-esm/Util/Retry.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { DelayFunction } from '../types';
|
|
2
|
-
export declare class NonRetryableError extends Error {
|
|
3
|
-
readonly nonRetryable = true;
|
|
4
|
-
constructor(message: string);
|
|
5
|
-
}
|
|
6
|
-
export declare const isNonRetryableError: (obj: any) => obj is NonRetryableError;
|
|
7
|
-
/**
|
|
8
|
-
* @private
|
|
9
|
-
* Internal use of Amplify only
|
|
10
|
-
*/
|
|
11
|
-
export declare function retry<T>(functionToRetry: (...args: any[]) => T, args: any[], delayFn: DelayFunction, onTerminate?: Promise<void>): Promise<T>;
|
|
12
|
-
/**
|
|
13
|
-
* @private
|
|
14
|
-
* Internal use of Amplify only
|
|
15
|
-
*/
|
|
16
|
-
export declare function jitteredBackoff(maxDelayMs?: number): DelayFunction;
|
|
17
|
-
/**
|
|
18
|
-
* @private
|
|
19
|
-
* Internal use of Amplify only
|
|
20
|
-
*/
|
|
21
|
-
export declare const jitteredExponentialRetry: <T>(functionToRetry: (...args: any[]) => T, args: any[], maxDelayMs?: number, onTerminate?: Promise<void>) => Promise<T>;
|
package/lib-esm/Util/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { NonRetryableError, isNonRetryableError, jitteredBackoff, jitteredExponentialRetry, retry, } from './Retry';
|
|
2
|
-
export { default as Mutex } from './Mutex';
|
|
3
|
-
export { default as Reachability } from './Reachability';
|
|
4
|
-
export { DateUtils } from './DateUtils';
|
|
5
|
-
export { urlSafeDecode, urlSafeEncode } from './StringUtils';
|
|
6
|
-
export { AWS_CLOUDWATCH_CATEGORY, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, } from './Constants';
|
|
7
|
-
export { BackgroundProcessManager, BackgroundManagerNotOpenError, BackgroundProcessManagerState, } from './BackgroundProcessManager';
|
package/lib-esm/Util/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
export { NonRetryableError, isNonRetryableError, jitteredBackoff, jitteredExponentialRetry, retry, } from './Retry';
|
|
4
|
-
export { default as Mutex } from './Mutex';
|
|
5
|
-
export { default as Reachability } from './Reachability';
|
|
6
|
-
export { DateUtils } from './DateUtils';
|
|
7
|
-
export { urlSafeDecode, urlSafeEncode } from './StringUtils';
|
|
8
|
-
export { AWS_CLOUDWATCH_CATEGORY, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, } from './Constants';
|
|
9
|
-
export { BackgroundProcessManager, BackgroundManagerNotOpenError, BackgroundProcessManagerState, } from './BackgroundProcessManager';
|
package/src/Util/JS.ts
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
const MIME_MAP = [
|
|
5
|
-
{ type: 'text/plain', ext: 'txt' },
|
|
6
|
-
{ type: 'text/html', ext: 'html' },
|
|
7
|
-
{ type: 'text/javascript', ext: 'js' },
|
|
8
|
-
{ type: 'text/css', ext: 'css' },
|
|
9
|
-
{ type: 'text/csv', ext: 'csv' },
|
|
10
|
-
{ type: 'text/yaml', ext: 'yml' },
|
|
11
|
-
{ type: 'text/yaml', ext: 'yaml' },
|
|
12
|
-
{ type: 'text/calendar', ext: 'ics' },
|
|
13
|
-
{ type: 'text/calendar', ext: 'ical' },
|
|
14
|
-
|
|
15
|
-
{ type: 'image/apng', ext: 'apng' },
|
|
16
|
-
{ type: 'image/bmp', ext: 'bmp' },
|
|
17
|
-
{ type: 'image/gif', ext: 'gif' },
|
|
18
|
-
{ type: 'image/x-icon', ext: 'ico' },
|
|
19
|
-
{ type: 'image/x-icon', ext: 'cur' },
|
|
20
|
-
{ type: 'image/jpeg', ext: 'jpg' },
|
|
21
|
-
{ type: 'image/jpeg', ext: 'jpeg' },
|
|
22
|
-
{ type: 'image/jpeg', ext: 'jfif' },
|
|
23
|
-
{ type: 'image/jpeg', ext: 'pjp' },
|
|
24
|
-
{ type: 'image/jpeg', ext: 'pjpeg' },
|
|
25
|
-
{ type: 'image/png', ext: 'png' },
|
|
26
|
-
{ type: 'image/svg+xml', ext: 'svg' },
|
|
27
|
-
{ type: 'image/tiff', ext: 'tif' },
|
|
28
|
-
{ type: 'image/tiff', ext: 'tiff' },
|
|
29
|
-
{ type: 'image/webp', ext: 'webp' },
|
|
30
|
-
|
|
31
|
-
{ type: 'application/json', ext: 'json' },
|
|
32
|
-
{ type: 'application/xml', ext: 'xml' },
|
|
33
|
-
{ type: 'application/x-sh', ext: 'sh' },
|
|
34
|
-
{ type: 'application/zip', ext: 'zip' },
|
|
35
|
-
{ type: 'application/x-rar-compressed', ext: 'rar' },
|
|
36
|
-
{ type: 'application/x-tar', ext: 'tar' },
|
|
37
|
-
{ type: 'application/x-bzip', ext: 'bz' },
|
|
38
|
-
{ type: 'application/x-bzip2', ext: 'bz2' },
|
|
39
|
-
{ type: 'application/pdf', ext: 'pdf' },
|
|
40
|
-
{ type: 'application/java-archive', ext: 'jar' },
|
|
41
|
-
{ type: 'application/msword', ext: 'doc' },
|
|
42
|
-
{ type: 'application/vnd.ms-excel', ext: 'xls' },
|
|
43
|
-
{ type: 'application/vnd.ms-excel', ext: 'xlsx' },
|
|
44
|
-
|
|
45
|
-
{ type: 'message/rfc822', ext: 'eml' },
|
|
46
|
-
];
|
|
47
|
-
|
|
48
|
-
export const isEmpty = (obj = {}) => Object.keys(obj).length === 0;
|
|
49
|
-
|
|
50
|
-
export const sortByField = (
|
|
51
|
-
list: any[],
|
|
52
|
-
field: string | number,
|
|
53
|
-
dir: string
|
|
54
|
-
) => {
|
|
55
|
-
if (!list || !list.sort) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const dirX = dir && dir === 'desc' ? -1 : 1;
|
|
60
|
-
list.sort(function(a, b) {
|
|
61
|
-
const a_val = a[field];
|
|
62
|
-
const b_val = b[field];
|
|
63
|
-
|
|
64
|
-
if (typeof b_val === 'undefined') {
|
|
65
|
-
return typeof a_val === 'undefined' ? 0 : 1 * dirX;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (typeof a_val === 'undefined') {
|
|
69
|
-
return -1 * dirX;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (a_val < b_val) {
|
|
73
|
-
return -1 * dirX;
|
|
74
|
-
}
|
|
75
|
-
if (a_val > b_val) {
|
|
76
|
-
return 1 * dirX;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return 0;
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
return true;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export const objectLessAttributes = (
|
|
86
|
-
obj: Record<string, any>,
|
|
87
|
-
less: string | string[]
|
|
88
|
-
) => {
|
|
89
|
-
const ret = Object.assign({}, obj);
|
|
90
|
-
if (less) {
|
|
91
|
-
if (typeof less === 'string') {
|
|
92
|
-
delete ret[less];
|
|
93
|
-
} else {
|
|
94
|
-
less.forEach(attr => {
|
|
95
|
-
delete ret[attr];
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return ret;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export const filenameToContentType = (
|
|
104
|
-
filename: string,
|
|
105
|
-
defVal = 'application/octet-stream'
|
|
106
|
-
) => {
|
|
107
|
-
const name = filename.toLowerCase();
|
|
108
|
-
|
|
109
|
-
const filtered = MIME_MAP.filter(mime => name.endsWith('.' + mime.ext));
|
|
110
|
-
return filtered.length > 0 ? filtered[0].type : defVal;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export const isTextFile = (contentType: string) => {
|
|
114
|
-
const type = contentType.toLowerCase();
|
|
115
|
-
if (type.startsWith('text/')) {
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
return (
|
|
119
|
-
'application/json' === type ||
|
|
120
|
-
'application/xml' === type ||
|
|
121
|
-
'application/sh' === type
|
|
122
|
-
);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export const generateRandomString = () => {
|
|
126
|
-
let result = '';
|
|
127
|
-
const chars =
|
|
128
|
-
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
129
|
-
for (let i = 32; i > 0; i -= 1) {
|
|
130
|
-
result += chars[Math.floor(Math.random() * chars.length)];
|
|
131
|
-
}
|
|
132
|
-
return result;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export const makeQuerablePromise = (promise: any) => {
|
|
136
|
-
if (promise.isResolved) return promise;
|
|
137
|
-
|
|
138
|
-
let isPending = true;
|
|
139
|
-
let isRejected = false;
|
|
140
|
-
let isFullfilled = false;
|
|
141
|
-
|
|
142
|
-
const result = promise.then(
|
|
143
|
-
(data: unknown) => {
|
|
144
|
-
isFullfilled = true;
|
|
145
|
-
isPending = false;
|
|
146
|
-
return data;
|
|
147
|
-
},
|
|
148
|
-
(e: unknown) => {
|
|
149
|
-
isRejected = true;
|
|
150
|
-
isPending = false;
|
|
151
|
-
throw e;
|
|
152
|
-
}
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
result.isFullfilled = () => isFullfilled;
|
|
156
|
-
result.isPending = () => isPending;
|
|
157
|
-
result.isRejected = () => isRejected;
|
|
158
|
-
|
|
159
|
-
return result;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
export const isWebWorker = () => {
|
|
163
|
-
if (typeof self === 'undefined') {
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
const selfContext = self as { WorkerGlobalScope?: any };
|
|
167
|
-
return (
|
|
168
|
-
typeof selfContext.WorkerGlobalScope !== 'undefined' &&
|
|
169
|
-
self instanceof selfContext.WorkerGlobalScope
|
|
170
|
-
);
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
export const isBrowser = () =>
|
|
174
|
-
typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* transfer the first letter of the keys to lowercase
|
|
178
|
-
* @param {Object} obj - the object need to be transferred
|
|
179
|
-
* @param {Array} whiteListForItself - whitelist itself from being transferred
|
|
180
|
-
* @param {Array} whiteListForChildren - whitelist its children keys from being transferred
|
|
181
|
-
*/
|
|
182
|
-
export const transferKeyToLowerCase = (
|
|
183
|
-
obj: Record<string, any>,
|
|
184
|
-
whiteListForItself: string[] = [],
|
|
185
|
-
whiteListForChildren: string[] = []
|
|
186
|
-
) => {
|
|
187
|
-
if (!isStrictObject(obj)) return obj;
|
|
188
|
-
const ret: Record<string, any> = {};
|
|
189
|
-
|
|
190
|
-
for (const key in obj) {
|
|
191
|
-
if (obj.hasOwnProperty(key)) {
|
|
192
|
-
const transferedKey = whiteListForItself.includes(key)
|
|
193
|
-
? key
|
|
194
|
-
: key[0].toLowerCase() + key.slice(1);
|
|
195
|
-
|
|
196
|
-
ret[transferedKey] = whiteListForChildren.includes(key)
|
|
197
|
-
? obj[key]
|
|
198
|
-
: transferKeyToLowerCase(
|
|
199
|
-
obj[key],
|
|
200
|
-
whiteListForItself,
|
|
201
|
-
whiteListForChildren
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return ret;
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* transfer the first letter of the keys to lowercase
|
|
211
|
-
* @param {Object} obj - the object need to be transferred
|
|
212
|
-
* @param {Array} whiteListForItself - whitelist itself from being transferred
|
|
213
|
-
* @param {Array} whiteListForChildren - whitelist its children keys from being transferred
|
|
214
|
-
*/
|
|
215
|
-
export const transferKeyToUpperCase = (
|
|
216
|
-
obj: Record<string, any>,
|
|
217
|
-
whiteListForItself: string[] = [],
|
|
218
|
-
whiteListForChildren: string[] = []
|
|
219
|
-
) => {
|
|
220
|
-
if (!isStrictObject(obj)) return obj;
|
|
221
|
-
const ret: Record<string, any> = {};
|
|
222
|
-
|
|
223
|
-
for (const key in obj) {
|
|
224
|
-
if (obj.hasOwnProperty(key)) {
|
|
225
|
-
const transferredKey = whiteListForItself.includes(key)
|
|
226
|
-
? key
|
|
227
|
-
: key[0].toUpperCase() + key.slice(1);
|
|
228
|
-
|
|
229
|
-
ret[transferredKey] = whiteListForChildren.includes(key)
|
|
230
|
-
? obj[key]
|
|
231
|
-
: transferKeyToUpperCase(
|
|
232
|
-
obj[key],
|
|
233
|
-
whiteListForItself,
|
|
234
|
-
whiteListForChildren
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
return ret;
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Return true if the object is a strict object
|
|
243
|
-
* which means it's not Array, Function, Number, String, Boolean or Null
|
|
244
|
-
* @param obj the Object
|
|
245
|
-
*/
|
|
246
|
-
export const isStrictObject = (obj: any) => {
|
|
247
|
-
return (
|
|
248
|
-
obj instanceof Object &&
|
|
249
|
-
!(obj instanceof Array) &&
|
|
250
|
-
!(obj instanceof Function) &&
|
|
251
|
-
!(obj instanceof Number) &&
|
|
252
|
-
!(obj instanceof String) &&
|
|
253
|
-
!(obj instanceof Boolean)
|
|
254
|
-
);
|
|
255
|
-
};
|
package/src/Util/Reachability.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import Observable, { ZenObservable } from 'zen-observable-ts';
|
|
4
|
-
import { isWebWorker } from './JS';
|
|
5
|
-
|
|
6
|
-
type NetworkStatus = {
|
|
7
|
-
online: boolean;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export default class ReachabilityNavigator implements Reachability {
|
|
11
|
-
private static _observers: Array<
|
|
12
|
-
ZenObservable.SubscriptionObserver<NetworkStatus>
|
|
13
|
-
> = [];
|
|
14
|
-
|
|
15
|
-
networkMonitor(netInfo?: any): Observable<NetworkStatus> {
|
|
16
|
-
const globalObj = isWebWorker() ? self : window;
|
|
17
|
-
|
|
18
|
-
return new Observable(observer => {
|
|
19
|
-
observer.next({ online: globalObj.navigator.onLine });
|
|
20
|
-
|
|
21
|
-
const notifyOnline = () => observer.next({ online: true });
|
|
22
|
-
const notifyOffline = () => observer.next({ online: false });
|
|
23
|
-
|
|
24
|
-
globalObj.addEventListener('online', notifyOnline);
|
|
25
|
-
globalObj.addEventListener('offline', notifyOffline);
|
|
26
|
-
|
|
27
|
-
ReachabilityNavigator._observers.push(observer);
|
|
28
|
-
|
|
29
|
-
return () => {
|
|
30
|
-
globalObj.removeEventListener('online', notifyOnline);
|
|
31
|
-
globalObj.removeEventListener('offline', notifyOffline);
|
|
32
|
-
|
|
33
|
-
ReachabilityNavigator._observers =
|
|
34
|
-
ReachabilityNavigator._observers.filter(
|
|
35
|
-
_observer => _observer !== observer
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// expose observers to simulate offline mode for integration testing
|
|
42
|
-
private static _observerOverride(status: NetworkStatus): void {
|
|
43
|
-
for (const observer of ReachabilityNavigator._observers) {
|
|
44
|
-
if (observer.closed) {
|
|
45
|
-
ReachabilityNavigator._observers =
|
|
46
|
-
ReachabilityNavigator._observers.filter(
|
|
47
|
-
_observer => _observer !== observer
|
|
48
|
-
);
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
observer.next(status);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
interface Reachability {
|
|
57
|
-
networkMonitor(netInfo?: any): Observable<NetworkStatus>;
|
|
58
|
-
}
|
package/src/Util/index.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
export {
|
|
4
|
-
NonRetryableError,
|
|
5
|
-
isNonRetryableError,
|
|
6
|
-
jitteredBackoff,
|
|
7
|
-
jitteredExponentialRetry,
|
|
8
|
-
retry,
|
|
9
|
-
} from './Retry';
|
|
10
|
-
export { default as Mutex } from './Mutex';
|
|
11
|
-
export { default as Reachability } from './Reachability';
|
|
12
|
-
export { DateUtils } from './DateUtils';
|
|
13
|
-
export { urlSafeDecode, urlSafeEncode } from './StringUtils';
|
|
14
|
-
export {
|
|
15
|
-
AWS_CLOUDWATCH_CATEGORY,
|
|
16
|
-
NO_CREDS_ERROR_STRING,
|
|
17
|
-
RETRY_ERROR_CODES,
|
|
18
|
-
} from './Constants';
|
|
19
|
-
export {
|
|
20
|
-
BackgroundProcessManager,
|
|
21
|
-
BackgroundManagerNotOpenError,
|
|
22
|
-
BackgroundProcessManagerState,
|
|
23
|
-
} from './BackgroundProcessManager';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|