@aws-amplify/core 6.0.1-console-preview.5f040a2.0 → 6.0.1-console-preview.23dc225.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/Cache/StorageCache.d.ts +14 -31
- package/lib/Cache/StorageCache.js +97 -102
- package/lib/Cache/StorageCache.native.d.ts +19 -0
- package/lib/Cache/StorageCache.native.js +164 -0
- package/lib/Cache/{AsyncStorageCache.d.ts → StorageCacheCommon.d.ts} +124 -99
- package/lib/Cache/{AsyncStorageCache.js → StorageCacheCommon.js} +497 -432
- package/lib/Cache/constants.d.ts +6 -0
- package/lib/Cache/constants.js +17 -0
- package/lib/Cache/index.d.ts +2 -0
- package/lib/Cache/index.js +7 -0
- package/lib/Cache/types/cache.d.ts +38 -0
- package/lib/Cache/types/index.d.ts +1 -1
- package/lib/Cache/types/index.js +1 -1
- package/lib/Cache/{Utils → utils}/CacheList.d.ts +1 -1
- package/lib/Cache/{Utils → utils}/CacheList.js +2 -1
- package/lib/Cache/utils/cacheHelpers.d.ts +14 -0
- package/lib/Cache/utils/cacheHelpers.js +51 -0
- package/lib/Cache/{Utils → utils}/errorHelpers.d.ts +0 -1
- package/lib/Cache/{Utils → utils}/errorHelpers.js +0 -4
- package/lib/Cache/utils/index.d.ts +2 -0
- package/lib/Cache/utils/index.js +12 -0
- package/lib/Hub/index.d.ts +7 -0
- package/lib/Hub/index.js +8 -1
- package/lib/Platform/customUserAgent.d.ts +16 -0
- package/lib/Platform/customUserAgent.js +70 -0
- package/lib/Platform/index.js +10 -1
- package/lib/Platform/types.d.ts +33 -1
- package/lib/Platform/types.js +1 -0
- package/lib/Platform/version.d.ts +1 -1
- package/lib/Platform/version.js +1 -1
- package/lib/Reachability/Reachability.d.ts +1 -0
- package/lib/Reachability/Reachability.js +36 -0
- package/lib/Signer/Signer.js +3 -2
- package/lib/awsClients/cognitoIdentity/base.js +2 -1
- package/lib/awsClients/pinpoint/base.js +2 -1
- package/lib/awsClients/pinpoint/getInAppMessages.js +2 -1
- package/lib/awsClients/pinpoint/putEvents.js +2 -1
- package/lib/awsClients/pinpoint/updateEndpoint.js +2 -1
- package/lib/clients/middleware/signing/signer/signatureV4/index.d.ts +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/index.js +0 -1
- package/lib/clients/middleware/signing/signer/signatureV4/presignUrl.js +2 -1
- package/lib/index.d.ts +2 -5
- package/lib/index.js +3 -6
- package/lib/libraryUtils.d.ts +7 -5
- package/lib/libraryUtils.js +11 -6
- package/lib/parseAWSExports.js +75 -14
- package/lib/providers/pinpoint/apis/flushEvents.d.ts +2 -2
- package/lib/providers/pinpoint/apis/record.js +3 -3
- package/lib/providers/pinpoint/apis/updateEndpoint.js +6 -6
- package/lib/singleton/API/types.d.ts +4 -3
- package/lib/singleton/Amplify.d.ts +2 -2
- package/lib/singleton/Amplify.js +6 -5
- package/lib/singleton/Auth/types.d.ts +28 -1
- package/lib/singleton/Cache/types.d.ts +18 -0
- package/lib/singleton/Cache/types.js +4 -0
- package/lib/singleton/types.d.ts +3 -1
- package/lib/storage/DefaultStorage.js +1 -1
- package/lib/storage/utils.d.ts +1 -1
- package/lib/storage/utils.js +3 -3
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/amplifyUrl/index.d.ts +13 -0
- package/lib/utils/amplifyUrl/index.js +10 -0
- package/lib/utils/amplifyUrl/polyfill.d.ts +0 -0
- package/lib/utils/amplifyUrl/polyfill.js +4 -0
- package/lib/utils/amplifyUrl/polyfill.native.d.ts +1 -0
- package/lib/utils/amplifyUuid/index.d.ts +3 -0
- package/lib/utils/amplifyUuid/index.js +9 -0
- package/lib/utils/amplifyUuid/polyfill.d.ts +0 -0
- package/lib/utils/amplifyUuid/polyfill.js +4 -0
- package/lib/utils/amplifyUuid/polyfill.native.d.ts +1 -0
- package/lib/utils/amplifyUuid/polyfill.native.js +6 -0
- package/lib/utils/deepFreeze.d.ts +1 -0
- package/lib/utils/deepFreeze.js +38 -0
- package/lib/{ClientDevice/android.d.ts → utils/getClientInfo/getClientInfo.android.d.ts} +1 -1
- package/lib/{ClientDevice/android.js → utils/getClientInfo/getClientInfo.android.js} +4 -4
- package/lib/{ClientDevice/browser.d.ts → utils/getClientInfo/getClientInfo.d.ts} +1 -9
- package/lib/{ClientDevice/ios.d.ts → utils/getClientInfo/getClientInfo.ios.d.ts} +1 -1
- package/lib/{ClientDevice/ios.js → utils/getClientInfo/getClientInfo.ios.js} +4 -4
- package/lib/{ClientDevice/browser.js → utils/getClientInfo/getClientInfo.js} +6 -18
- package/lib/utils/getClientInfo/index.d.ts +1 -0
- package/lib/utils/getClientInfo/index.js +7 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +5 -1
- package/lib-esm/Cache/StorageCache.d.ts +14 -31
- package/lib-esm/Cache/StorageCache.js +97 -102
- package/lib-esm/Cache/StorageCache.native.d.ts +19 -0
- package/lib-esm/Cache/StorageCache.native.js +161 -0
- package/lib-esm/Cache/{AsyncStorageCache.d.ts → StorageCacheCommon.d.ts} +124 -99
- package/lib-esm/Cache/{AsyncStorageCache.js → StorageCacheCommon.js} +496 -430
- package/lib-esm/Cache/constants.d.ts +6 -0
- package/lib-esm/Cache/constants.js +14 -0
- package/lib-esm/Cache/index.d.ts +2 -0
- package/lib-esm/Cache/index.js +4 -0
- package/lib-esm/Cache/types/cache.d.ts +38 -0
- package/lib-esm/Cache/types/index.d.ts +1 -1
- package/lib-esm/Cache/types/index.js +1 -1
- package/lib-esm/Cache/{Utils → utils}/CacheList.d.ts +1 -1
- package/lib-esm/Cache/{Utils → utils}/CacheList.js +1 -1
- package/lib-esm/Cache/utils/cacheHelpers.d.ts +14 -0
- package/lib-esm/Cache/utils/cacheHelpers.js +44 -0
- package/lib-esm/Cache/{Utils → utils}/errorHelpers.d.ts +0 -1
- package/lib-esm/Cache/{Utils → utils}/errorHelpers.js +0 -4
- package/lib-esm/Cache/utils/index.d.ts +2 -0
- package/lib-esm/Cache/utils/index.js +4 -0
- package/lib-esm/Hub/index.d.ts +7 -0
- package/lib-esm/Hub/index.js +7 -0
- package/lib-esm/Platform/customUserAgent.d.ts +16 -0
- package/lib-esm/Platform/customUserAgent.js +65 -0
- package/lib-esm/Platform/index.js +10 -1
- package/lib-esm/Platform/types.d.ts +33 -1
- package/lib-esm/Platform/types.js +1 -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 +1 -0
- package/lib-esm/Reachability/Reachability.js +36 -0
- package/lib-esm/Signer/Signer.js +3 -2
- package/lib-esm/awsClients/cognitoIdentity/base.js +2 -1
- package/lib-esm/awsClients/pinpoint/base.js +2 -1
- package/lib-esm/awsClients/pinpoint/getInAppMessages.js +2 -1
- package/lib-esm/awsClients/pinpoint/putEvents.js +2 -1
- package/lib-esm/awsClients/pinpoint/updateEndpoint.js +2 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.d.ts +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/index.js +0 -1
- package/lib-esm/clients/middleware/signing/signer/signatureV4/presignUrl.js +2 -1
- package/lib-esm/index.d.ts +2 -5
- package/lib-esm/index.js +1 -4
- package/lib-esm/libraryUtils.d.ts +7 -5
- package/lib-esm/libraryUtils.js +5 -3
- package/lib-esm/parseAWSExports.js +75 -14
- package/lib-esm/providers/pinpoint/apis/flushEvents.d.ts +2 -2
- package/lib-esm/providers/pinpoint/apis/record.js +3 -3
- package/lib-esm/providers/pinpoint/apis/updateEndpoint.js +6 -6
- package/lib-esm/singleton/API/types.d.ts +4 -3
- package/lib-esm/singleton/Amplify.d.ts +2 -2
- package/lib-esm/singleton/Amplify.js +6 -5
- package/lib-esm/singleton/Auth/types.d.ts +28 -1
- package/lib-esm/singleton/Cache/types.d.ts +18 -0
- package/lib-esm/singleton/Cache/types.js +3 -0
- package/lib-esm/singleton/types.d.ts +3 -1
- package/lib-esm/storage/DefaultStorage.js +2 -2
- package/lib-esm/storage/utils.d.ts +1 -1
- package/lib-esm/storage/utils.js +1 -1
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/utils/amplifyUrl/index.d.ts +13 -0
- package/lib-esm/utils/amplifyUrl/index.js +6 -0
- package/lib-esm/utils/amplifyUuid/index.d.ts +3 -0
- package/lib-esm/utils/amplifyUuid/index.js +6 -0
- package/lib-esm/utils/amplifyUuid/polyfill.native.js +4 -0
- package/lib-esm/utils/deepFreeze.d.ts +1 -0
- package/lib-esm/utils/deepFreeze.js +34 -0
- package/lib-esm/{ClientDevice/android.d.ts → utils/getClientInfo/getClientInfo.android.d.ts} +1 -1
- package/lib-esm/{ClientDevice/android.js → utils/getClientInfo/getClientInfo.android.js} +2 -2
- package/lib-esm/{ClientDevice/browser.d.ts → utils/getClientInfo/getClientInfo.d.ts} +1 -9
- package/lib-esm/{ClientDevice/ios.d.ts → utils/getClientInfo/getClientInfo.ios.d.ts} +1 -1
- package/lib-esm/{ClientDevice/ios.js → utils/getClientInfo/getClientInfo.ios.js} +2 -2
- package/lib-esm/{ClientDevice/browser.js → utils/getClientInfo/getClientInfo.js} +4 -14
- package/lib-esm/utils/getClientInfo/index.d.ts +1 -0
- package/lib-esm/utils/getClientInfo/index.js +3 -0
- package/lib-esm/utils/index.d.ts +2 -0
- package/lib-esm/utils/index.js +2 -0
- package/package.json +7 -17
- package/src/Cache/StorageCache.native.ts +65 -0
- package/src/Cache/StorageCache.ts +61 -158
- package/src/Cache/StorageCacheCommon.ts +581 -0
- package/src/Cache/constants.ts +18 -0
- package/src/Cache/index.ts +6 -0
- package/src/Cache/types/cache.ts +51 -0
- package/src/Cache/types/index.ts +1 -1
- package/src/Cache/{Utils → utils}/CacheList.ts +185 -185
- package/src/Cache/utils/cacheHelpers.ts +52 -0
- package/src/Cache/{Utils → utils}/errorHelpers.ts +0 -4
- package/src/Cache/{Utils → utils}/index.ts +4 -5
- package/src/Hub/index.ts +8 -0
- package/src/Platform/customUserAgent.ts +75 -0
- package/src/Platform/index.ts +14 -1
- package/src/Platform/types.ts +45 -1
- package/src/Platform/version.ts +1 -1
- package/src/Reachability/Reachability.ts +14 -0
- package/src/Signer/Signer.ts +3 -2
- package/src/awsClients/cognitoIdentity/base.ts +4 -1
- package/src/awsClients/pinpoint/base.ts +2 -1
- package/src/awsClients/pinpoint/getInAppMessages.ts +2 -1
- package/src/awsClients/pinpoint/putEvents.ts +2 -1
- package/src/awsClients/pinpoint/updateEndpoint.ts +2 -1
- package/src/clients/middleware/signing/signer/signatureV4/index.ts +0 -2
- package/src/clients/middleware/signing/signer/signatureV4/presignUrl.ts +2 -1
- package/src/index.ts +3 -4
- package/src/libraryUtils.ts +17 -10
- package/src/parseAWSExports.ts +76 -13
- package/src/providers/pinpoint/apis/flushEvents.ts +2 -2
- package/src/providers/pinpoint/apis/record.ts +3 -3
- package/src/providers/pinpoint/apis/updateEndpoint.ts +6 -6
- package/src/singleton/API/types.ts +4 -3
- package/src/singleton/Amplify.ts +10 -8
- package/src/singleton/Auth/types.ts +50 -1
- package/src/singleton/Cache/types.ts +27 -0
- package/src/singleton/types.ts +3 -1
- package/src/storage/DefaultStorage.ts +2 -2
- package/src/storage/utils.ts +1 -1
- package/src/utils/amplifyUrl/index.ts +9 -0
- package/src/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.ts → utils/amplifyUrl/polyfill.native.ts} +1 -0
- package/src/utils/amplifyUuid/index.ts +9 -0
- package/src/utils/amplifyUuid/polyfill.native.ts +6 -0
- package/src/utils/amplifyUuid/polyfill.ts +4 -0
- package/src/utils/deepFreeze.ts +16 -0
- package/src/{ClientDevice/android.ts → utils/getClientInfo/getClientInfo.android.ts} +2 -2
- package/src/{ClientDevice/ios.ts → utils/getClientInfo/getClientInfo.ios.ts} +3 -3
- package/src/{ClientDevice/browser.ts → utils/getClientInfo/getClientInfo.ts} +4 -16
- package/src/utils/getClientInfo/index.ts +4 -0
- package/src/utils/index.ts +2 -0
- package/lib/Cache/BrowserStorageCache.d.ts +0 -166
- package/lib/Cache/BrowserStorageCache.js +0 -456
- package/lib/Cache/InMemoryCache.d.ts +0 -129
- package/lib/Cache/InMemoryCache.js +0 -342
- package/lib/Cache/Utils/CacheUtils.d.ts +0 -25
- package/lib/Cache/Utils/CacheUtils.js +0 -86
- package/lib/Cache/Utils/index.d.ts +0 -2
- package/lib/Cache/Utils/index.js +0 -16
- package/lib/Cache/reactnative.d.ts +0 -3
- package/lib/Cache/reactnative.js +0 -8
- package/lib/Cache/types/Cache.d.ts +0 -55
- package/lib/ClientDevice/index.d.ts +0 -23
- package/lib/ClientDevice/index.js +0 -18
- package/lib/ClientDevice/reactnative.d.ts +0 -7
- package/lib/ClientDevice/reactnative.js +0 -24
- package/lib-esm/Cache/BrowserStorageCache.d.ts +0 -166
- package/lib-esm/Cache/BrowserStorageCache.js +0 -453
- package/lib-esm/Cache/InMemoryCache.d.ts +0 -129
- package/lib-esm/Cache/InMemoryCache.js +0 -339
- package/lib-esm/Cache/Utils/CacheUtils.d.ts +0 -25
- package/lib-esm/Cache/Utils/CacheUtils.js +0 -79
- package/lib-esm/Cache/Utils/index.d.ts +0 -2
- package/lib-esm/Cache/Utils/index.js +0 -4
- package/lib-esm/Cache/reactnative.d.ts +0 -3
- package/lib-esm/Cache/reactnative.js +0 -6
- package/lib-esm/Cache/types/Cache.d.ts +0 -55
- package/lib-esm/ClientDevice/index.d.ts +0 -23
- package/lib-esm/ClientDevice/index.js +0 -15
- package/lib-esm/ClientDevice/reactnative.d.ts +0 -7
- package/lib-esm/ClientDevice/reactnative.js +0 -21
- package/src/Cache/AsyncStorageCache.ts +0 -495
- package/src/Cache/BrowserStorageCache.ts +0 -504
- package/src/Cache/CHANGELOG.md +0 -1239
- package/src/Cache/InMemoryCache.ts +0 -347
- package/src/Cache/Utils/CacheUtils.ts +0 -90
- package/src/Cache/reactnative.ts +0 -9
- package/src/Cache/types/Cache.ts +0 -75
- package/src/ClientDevice/index.ts +0 -14
- package/src/ClientDevice/reactnative.ts +0 -18
- package/lib/Cache/types/{Cache.js → cache.js} +0 -0
- package/lib/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.js → utils/amplifyUrl/polyfill.native.js} +1 -1
- /package/lib-esm/Cache/types/{Cache.js → cache.js} +0 -0
- /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.d.ts → utils/amplifyUrl/polyfill.d.ts} +0 -0
- /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.js → utils/amplifyUrl/polyfill.js} +0 -0
- /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.d.ts → utils/amplifyUrl/polyfill.native.d.ts} +0 -0
- /package/lib-esm/{clients/middleware/signing/signer/signatureV4/polyfills/index.native.js → utils/amplifyUrl/polyfill.native.js} +0 -0
- /package/{lib/clients/middleware/signing/signer/signatureV4/polyfills/index.d.ts → lib-esm/utils/amplifyUuid/polyfill.d.ts} +0 -0
- /package/{lib/clients/middleware/signing/signer/signatureV4/polyfills/index.js → lib-esm/utils/amplifyUuid/polyfill.js} +0 -0
- /package/{lib/clients/middleware/signing/signer/signatureV4/polyfills/index.native.d.ts → lib-esm/utils/amplifyUuid/polyfill.native.d.ts} +0 -0
- /package/src/{clients/middleware/signing/signer/signatureV4/polyfills/index.ts → utils/amplifyUrl/polyfill.ts} +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import './polyfill';
|
|
5
|
+
|
|
6
|
+
const AmplifyUrl = URL;
|
|
7
|
+
const AmplifyUrlSearchParams = URLSearchParams;
|
|
8
|
+
|
|
9
|
+
export { AmplifyUrl, AmplifyUrlSearchParams };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export const deepFreeze = (object: any) => {
|
|
5
|
+
const propNames = Reflect.ownKeys(object);
|
|
6
|
+
|
|
7
|
+
for (const name of propNames) {
|
|
8
|
+
const value = object[name];
|
|
9
|
+
|
|
10
|
+
if ((value && typeof value === "object") || typeof value === "function") {
|
|
11
|
+
deepFreeze(value);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return Object.freeze(object);
|
|
16
|
+
};
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
// @ts-ignore: missing type definition
|
|
4
4
|
import { Platform, Dimensions } from 'react-native';
|
|
5
|
-
import { ConsoleLogger as Logger } from '
|
|
5
|
+
import { ConsoleLogger as Logger } from '../../Logger';
|
|
6
6
|
|
|
7
7
|
const logger = new Logger('DeviceInfo');
|
|
8
8
|
|
|
9
|
-
export const
|
|
9
|
+
export const getClientInfo = () => {
|
|
10
10
|
const dim = Dimensions.get('screen');
|
|
11
11
|
logger.debug(Platform, dim);
|
|
12
12
|
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
// @ts-ignore: missing type definition
|
|
4
4
|
import { Platform, Dimensions } from 'react-native';
|
|
5
|
-
import { ConsoleLogger as Logger } from '
|
|
5
|
+
import { ConsoleLogger as Logger } from '../../Logger';
|
|
6
6
|
|
|
7
7
|
const logger = new Logger('DeviceInfo');
|
|
8
8
|
|
|
9
|
-
export const
|
|
9
|
+
export const getClientInfo = () => {
|
|
10
10
|
const dim = Dimensions.get('screen');
|
|
11
11
|
logger.debug(Platform, dim);
|
|
12
12
|
const OS = 'ios';
|
|
@@ -21,7 +21,7 @@ export const clientInfo = () => {
|
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
function dimToMake(dim:{height:number
|
|
24
|
+
function dimToMake(dim: { height: number; width: number }) {
|
|
25
25
|
let { height, width } = dim;
|
|
26
26
|
if (height < width) {
|
|
27
27
|
const tmp = height;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { ConsoleLogger as Logger } from '
|
|
3
|
+
import { ConsoleLogger as Logger } from '../../Logger';
|
|
4
4
|
|
|
5
5
|
const logger = new Logger('ClientDevice_Browser');
|
|
6
6
|
|
|
7
|
-
export function
|
|
7
|
+
export function getClientInfo() {
|
|
8
8
|
if (typeof window === 'undefined') {
|
|
9
9
|
return {};
|
|
10
10
|
}
|
|
@@ -25,7 +25,7 @@ function browserClientInfo() {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const { platform, product, vendor, userAgent, language } = nav;
|
|
28
|
-
const type =
|
|
28
|
+
const type = getBrowserType(userAgent);
|
|
29
29
|
const timezone = browserTimezone();
|
|
30
30
|
|
|
31
31
|
return {
|
|
@@ -39,24 +39,12 @@ function browserClientInfo() {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
export function dimension() {
|
|
43
|
-
if (typeof window === 'undefined') {
|
|
44
|
-
logger.warn('No window object available to get browser client info');
|
|
45
|
-
return { width: 320, height: 320 };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
width: window.innerWidth,
|
|
50
|
-
height: window.innerHeight,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
42
|
function browserTimezone() {
|
|
55
43
|
const tzMatch = /\(([A-Za-z\s].*)\)/.exec(new Date().toString());
|
|
56
44
|
return tzMatch ? tzMatch[1] || '' : '';
|
|
57
45
|
}
|
|
58
46
|
|
|
59
|
-
|
|
47
|
+
function getBrowserType(userAgent: string) {
|
|
60
48
|
const operaMatch = /.+(Opera[\s[A-Z]*|OPR[\sA-Z]*)\/([0-9\.]+).*/i.exec(
|
|
61
49
|
userAgent
|
|
62
50
|
);
|
package/src/utils/index.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export { generateRandomString } from './generateRandomString';
|
|
5
|
+
export { getClientInfo } from './getClientInfo';
|
|
5
6
|
export { isBrowser } from './isBrowser';
|
|
6
7
|
export { isWebWorker } from './isWebWorker';
|
|
7
8
|
export {
|
|
@@ -13,3 +14,4 @@ export {
|
|
|
13
14
|
} from './retry';
|
|
14
15
|
export { urlSafeDecode } from './urlSafeDecode';
|
|
15
16
|
export { urlSafeEncode } from './urlSafeEncode';
|
|
17
|
+
export { deepFreeze } from './deepFreeze';
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { StorageCache } from './StorageCache';
|
|
2
|
-
import { ICache, CacheConfig, CacheItemOptions } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Customized storage based on the SessionStorage or LocalStorage with LRU implemented
|
|
5
|
-
*/
|
|
6
|
-
export declare class BrowserStorageCacheClass extends StorageCache implements ICache {
|
|
7
|
-
/**
|
|
8
|
-
* initialize the cache
|
|
9
|
-
* @param config - the configuration of the cache
|
|
10
|
-
*/
|
|
11
|
-
constructor(config?: CacheConfig);
|
|
12
|
-
private getStorage;
|
|
13
|
-
/**
|
|
14
|
-
* decrease current size of the cache
|
|
15
|
-
*
|
|
16
|
-
* @private
|
|
17
|
-
* @param amount - the amount of the cache size which needs to be decreased
|
|
18
|
-
*/
|
|
19
|
-
private _decreaseCurSizeInBytes;
|
|
20
|
-
/**
|
|
21
|
-
* increase current size of the cache
|
|
22
|
-
*
|
|
23
|
-
* @private
|
|
24
|
-
* @param amount - the amount of the cache szie which need to be increased
|
|
25
|
-
*/
|
|
26
|
-
private _increaseCurSizeInBytes;
|
|
27
|
-
/**
|
|
28
|
-
* update the visited time if item has been visited
|
|
29
|
-
*
|
|
30
|
-
* @private
|
|
31
|
-
* @param item - the item which need to be refreshed
|
|
32
|
-
* @param prefixedKey - the key of the item
|
|
33
|
-
*
|
|
34
|
-
* @return the refreshed item
|
|
35
|
-
*/
|
|
36
|
-
private _refreshItem;
|
|
37
|
-
/**
|
|
38
|
-
* check wether item is expired
|
|
39
|
-
*
|
|
40
|
-
* @private
|
|
41
|
-
* @param key - the key of the item
|
|
42
|
-
*
|
|
43
|
-
* @return true if the item is expired.
|
|
44
|
-
*/
|
|
45
|
-
private _isExpired;
|
|
46
|
-
/**
|
|
47
|
-
* delete item from cache
|
|
48
|
-
*
|
|
49
|
-
* @private
|
|
50
|
-
* @param prefixedKey - the key of the item
|
|
51
|
-
* @param size - optional, the byte size of the item
|
|
52
|
-
*/
|
|
53
|
-
private _removeItem;
|
|
54
|
-
/**
|
|
55
|
-
* put item into cache
|
|
56
|
-
*
|
|
57
|
-
* @private
|
|
58
|
-
* @param prefixedKey - the key of the item
|
|
59
|
-
* @param itemData - the value of the item
|
|
60
|
-
* @param itemSizeInBytes - the byte size of the item
|
|
61
|
-
*/
|
|
62
|
-
private _setItem;
|
|
63
|
-
/**
|
|
64
|
-
* total space needed when poping out items
|
|
65
|
-
*
|
|
66
|
-
* @private
|
|
67
|
-
* @param itemSize
|
|
68
|
-
*
|
|
69
|
-
* @return total space needed
|
|
70
|
-
*/
|
|
71
|
-
private _sizeToPop;
|
|
72
|
-
/**
|
|
73
|
-
* see whether cache is full
|
|
74
|
-
*
|
|
75
|
-
* @private
|
|
76
|
-
* @param itemSize
|
|
77
|
-
*
|
|
78
|
-
* @return true if cache is full
|
|
79
|
-
*/
|
|
80
|
-
private _isCacheFull;
|
|
81
|
-
/**
|
|
82
|
-
* scan the storage and find out all the keys owned by this cache
|
|
83
|
-
* also clean the expired keys while scanning
|
|
84
|
-
*
|
|
85
|
-
* @private
|
|
86
|
-
*
|
|
87
|
-
* @return array of keys
|
|
88
|
-
*/
|
|
89
|
-
private _findValidKeys;
|
|
90
|
-
/**
|
|
91
|
-
* get all the items we have, sort them by their priority,
|
|
92
|
-
* if priority is same, sort them by their last visited time
|
|
93
|
-
* pop out items from the low priority (5 is the lowest)
|
|
94
|
-
*
|
|
95
|
-
* @private
|
|
96
|
-
* @param keys - all the keys in this cache
|
|
97
|
-
* @param sizeToPop - the total size of the items which needed to be poped out
|
|
98
|
-
*/
|
|
99
|
-
private _popOutItems;
|
|
100
|
-
/**
|
|
101
|
-
* Set item into cache. You can put number, string, boolean or object.
|
|
102
|
-
* The cache will first check whether has the same key.
|
|
103
|
-
* If it has, it will delete the old item and then put the new item in
|
|
104
|
-
* The cache will pop out items if it is full
|
|
105
|
-
* You can specify the cache item options. The cache will abort and output a warning:
|
|
106
|
-
* If the key is invalid
|
|
107
|
-
* If the size of the item exceeds itemMaxSize.
|
|
108
|
-
* If the value is undefined
|
|
109
|
-
* If incorrect cache item configuration
|
|
110
|
-
* If error happened with browser storage
|
|
111
|
-
*
|
|
112
|
-
* @param key - the key of the item
|
|
113
|
-
* @param value - the value of the item
|
|
114
|
-
* @param {Object} [options] - optional, the specified meta-data
|
|
115
|
-
*/
|
|
116
|
-
setItem(key: string, value: object | number | string | boolean, options?: CacheItemOptions): void;
|
|
117
|
-
/**
|
|
118
|
-
* Get item from cache. It will return null if item doesn’t exist or it has been expired.
|
|
119
|
-
* If you specified callback function in the options,
|
|
120
|
-
* then the function will be executed if no such item in the cache
|
|
121
|
-
* and finally put the return value into cache.
|
|
122
|
-
* Please make sure the callback function will return the value you want to put into the cache.
|
|
123
|
-
* The cache will abort output a warning:
|
|
124
|
-
* If the key is invalid
|
|
125
|
-
* If error happened with browser storage
|
|
126
|
-
*
|
|
127
|
-
* @param key - the key of the item
|
|
128
|
-
* @param {Object} [options] - the options of callback function
|
|
129
|
-
*
|
|
130
|
-
* @return - return the value of the item
|
|
131
|
-
*/
|
|
132
|
-
getItem(key: string, options?: CacheItemOptions): any;
|
|
133
|
-
/**
|
|
134
|
-
* remove item from the cache
|
|
135
|
-
* The cache will abort output a warning:
|
|
136
|
-
* If error happened with browser storage
|
|
137
|
-
* @param key - the key of the item
|
|
138
|
-
*/
|
|
139
|
-
removeItem(key: string): void;
|
|
140
|
-
/**
|
|
141
|
-
* clear the entire cache
|
|
142
|
-
* The cache will abort output a warning:
|
|
143
|
-
* If error happened with browser storage
|
|
144
|
-
*/
|
|
145
|
-
clear(): void;
|
|
146
|
-
/**
|
|
147
|
-
* Return all the keys in the cache.
|
|
148
|
-
*
|
|
149
|
-
* @return - all keys in the cache
|
|
150
|
-
*/
|
|
151
|
-
getAllKeys(): string[];
|
|
152
|
-
/**
|
|
153
|
-
* return the current size of the cache
|
|
154
|
-
*
|
|
155
|
-
* @return - current size of the cache
|
|
156
|
-
*/
|
|
157
|
-
getCacheCurSize(): number;
|
|
158
|
-
/**
|
|
159
|
-
* Return a new instance of cache with customized configuration.
|
|
160
|
-
* @param config - the customized configuration
|
|
161
|
-
*
|
|
162
|
-
* @return - new instance of Cache
|
|
163
|
-
*/
|
|
164
|
-
createInstance(config: CacheConfig): ICache;
|
|
165
|
-
}
|
|
166
|
-
export declare const BrowserStorageCache: ICache;
|