@aws-amplify/cache 4.0.64-unstable.4 → 4.0.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/build.js +5 -0
  3. package/dist/aws-amplify-cache.js +1480 -0
  4. package/dist/aws-amplify-cache.js.map +1 -0
  5. package/dist/aws-amplify-cache.min.js +2 -0
  6. package/dist/aws-amplify-cache.min.js.map +1 -0
  7. package/index.js +7 -0
  8. package/lib/AsyncStorageCache.js +101 -40
  9. package/lib/AsyncStorageCache.js.map +1 -1
  10. package/lib/BrowserStorageCache.js +31 -6
  11. package/lib/BrowserStorageCache.js.map +1 -1
  12. package/lib/InMemoryCache.js +43 -6
  13. package/lib/InMemoryCache.js.map +1 -1
  14. package/lib/StorageCache.js +16 -2
  15. package/lib/StorageCache.js.map +1 -1
  16. package/lib/Utils/CacheList.js +24 -4
  17. package/lib/Utils/CacheList.js.map +1 -1
  18. package/lib/Utils/CacheUtils.js +12 -2
  19. package/lib/Utils/CacheUtils.js.map +1 -1
  20. package/lib/Utils/index.js +16 -8
  21. package/lib/Utils/index.js.map +1 -1
  22. package/lib/index.js +18 -2
  23. package/lib/index.js.map +1 -1
  24. package/lib/reactnative.js +18 -2
  25. package/lib/reactnative.js.map +1 -1
  26. package/lib/types/Cache.js +12 -2
  27. package/lib/types/Cache.js.map +1 -1
  28. package/lib/types/index.js +12 -2
  29. package/lib/types/index.js.map +1 -1
  30. package/lib-esm/AsyncStorageCache.d.ts +2 -1
  31. package/lib-esm/AsyncStorageCache.js +64 -6
  32. package/lib-esm/AsyncStorageCache.js.map +1 -1
  33. package/lib-esm/BrowserStorageCache.d.ts +4 -0
  34. package/lib-esm/BrowserStorageCache.js +30 -5
  35. package/lib-esm/BrowserStorageCache.js.map +1 -1
  36. package/lib-esm/InMemoryCache.d.ts +4 -0
  37. package/lib-esm/InMemoryCache.js +40 -3
  38. package/lib-esm/InMemoryCache.js.map +1 -1
  39. package/lib-esm/StorageCache.d.ts +4 -0
  40. package/lib-esm/StorageCache.js +16 -2
  41. package/lib-esm/StorageCache.js.map +1 -1
  42. package/lib-esm/Utils/CacheList.js +23 -3
  43. package/lib-esm/Utils/CacheList.js.map +1 -1
  44. package/lib-esm/Utils/CacheUtils.js +12 -2
  45. package/lib-esm/Utils/CacheUtils.js.map +1 -1
  46. package/lib-esm/Utils/index.d.ts +1 -1
  47. package/lib-esm/Utils/index.js +13 -3
  48. package/lib-esm/Utils/index.js.map +1 -1
  49. package/lib-esm/index.d.ts +4 -0
  50. package/lib-esm/index.js +18 -3
  51. package/lib-esm/index.js.map +1 -1
  52. package/lib-esm/reactnative.d.ts +5 -2
  53. package/lib-esm/reactnative.js +19 -5
  54. package/lib-esm/reactnative.js.map +1 -1
  55. package/lib-esm/types/Cache.js +12 -2
  56. package/lib-esm/types/Cache.js.map +1 -1
  57. package/lib-esm/types/index.js +12 -2
  58. package/lib-esm/types/index.js.map +1 -1
  59. package/package.json +12 -15
  60. package/src/AsyncStorageCache.ts +15 -6
  61. package/src/BrowserStorageCache.ts +18 -4
  62. package/src/InMemoryCache.ts +16 -2
  63. package/src/StorageCache.ts +17 -2
  64. package/src/Utils/CacheList.ts +12 -2
  65. package/src/Utils/CacheUtils.ts +12 -2
  66. package/src/Utils/index.ts +15 -11
  67. package/src/index.ts +20 -4
  68. package/src/reactnative.ts +19 -5
  69. package/src/types/Cache.ts +12 -2
  70. package/src/types/index.ts +12 -2
  71. package/webpack.config.dev.js +6 -0
  72. package/lib/.tsbuildinfo +0 -3
  73. package/lib/AsyncStorageCache.d.ts +0 -154
  74. package/lib/BrowserStorageCache.d.ts +0 -165
  75. package/lib/InMemoryCache.d.ts +0 -131
  76. package/lib/StorageCache.d.ts +0 -31
  77. package/lib/Utils/CacheList.d.ts +0 -89
  78. package/lib/Utils/CacheUtils.d.ts +0 -24
  79. package/lib/Utils/index.d.ts +0 -2
  80. package/lib/index.d.ts +0 -5
  81. package/lib/reactnative.d.ts +0 -3
  82. package/lib/types/Cache.d.ts +0 -55
  83. package/lib/types/index.d.ts +0 -1
  84. package/lib-esm/.tsbuildinfo +0 -3
@@ -0,0 +1,1480 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory(require("aws_amplify_core"));
4
+ else if(typeof define === 'function' && define.amd)
5
+ define("aws_amplify_cache", ["aws_amplify_core"], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["aws_amplify_cache"] = factory(require("aws_amplify_core"));
8
+ else
9
+ root["aws_amplify_cache"] = factory(root["aws_amplify_core"]);
10
+ })(this, function(__WEBPACK_EXTERNAL_MODULE__aws_amplify_core__) {
11
+ return /******/ (function(modules) { // webpackBootstrap
12
+ /******/ // The module cache
13
+ /******/ var installedModules = {};
14
+ /******/
15
+ /******/ // The require function
16
+ /******/ function __webpack_require__(moduleId) {
17
+ /******/
18
+ /******/ // Check if module is in cache
19
+ /******/ if(installedModules[moduleId]) {
20
+ /******/ return installedModules[moduleId].exports;
21
+ /******/ }
22
+ /******/ // Create a new module (and put it into the cache)
23
+ /******/ var module = installedModules[moduleId] = {
24
+ /******/ i: moduleId,
25
+ /******/ l: false,
26
+ /******/ exports: {}
27
+ /******/ };
28
+ /******/
29
+ /******/ // Execute the module function
30
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
+ /******/
32
+ /******/ // Flag the module as loaded
33
+ /******/ module.l = true;
34
+ /******/
35
+ /******/ // Return the exports of the module
36
+ /******/ return module.exports;
37
+ /******/ }
38
+ /******/
39
+ /******/
40
+ /******/ // expose the modules object (__webpack_modules__)
41
+ /******/ __webpack_require__.m = modules;
42
+ /******/
43
+ /******/ // expose the module cache
44
+ /******/ __webpack_require__.c = installedModules;
45
+ /******/
46
+ /******/ // define getter function for harmony exports
47
+ /******/ __webpack_require__.d = function(exports, name, getter) {
48
+ /******/ if(!__webpack_require__.o(exports, name)) {
49
+ /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
50
+ /******/ }
51
+ /******/ };
52
+ /******/
53
+ /******/ // define __esModule on exports
54
+ /******/ __webpack_require__.r = function(exports) {
55
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
56
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
57
+ /******/ }
58
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
59
+ /******/ };
60
+ /******/
61
+ /******/ // create a fake namespace object
62
+ /******/ // mode & 1: value is a module id, require it
63
+ /******/ // mode & 2: merge all properties of value into the ns
64
+ /******/ // mode & 4: return value when already ns object
65
+ /******/ // mode & 8|1: behave like require
66
+ /******/ __webpack_require__.t = function(value, mode) {
67
+ /******/ if(mode & 1) value = __webpack_require__(value);
68
+ /******/ if(mode & 8) return value;
69
+ /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
70
+ /******/ var ns = Object.create(null);
71
+ /******/ __webpack_require__.r(ns);
72
+ /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
73
+ /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
74
+ /******/ return ns;
75
+ /******/ };
76
+ /******/
77
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
78
+ /******/ __webpack_require__.n = function(module) {
79
+ /******/ var getter = module && module.__esModule ?
80
+ /******/ function getDefault() { return module['default']; } :
81
+ /******/ function getModuleExports() { return module; };
82
+ /******/ __webpack_require__.d(getter, 'a', getter);
83
+ /******/ return getter;
84
+ /******/ };
85
+ /******/
86
+ /******/ // Object.prototype.hasOwnProperty.call
87
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
88
+ /******/
89
+ /******/ // __webpack_public_path__
90
+ /******/ __webpack_require__.p = "";
91
+ /******/
92
+ /******/
93
+ /******/ // Load entry module and return exports
94
+ /******/ return __webpack_require__(__webpack_require__.s = "./lib-esm/index.js");
95
+ /******/ })
96
+ /************************************************************************/
97
+ /******/ ({
98
+
99
+ /***/ "./lib-esm/BrowserStorageCache.js":
100
+ /*!****************************************!*\
101
+ !*** ./lib-esm/BrowserStorageCache.js ***!
102
+ \****************************************/
103
+ /*! exports provided: BrowserStorageCacheClass, BrowserStorageCache, default */
104
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
105
+
106
+ "use strict";
107
+ __webpack_require__.r(__webpack_exports__);
108
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BrowserStorageCacheClass", function() { return BrowserStorageCacheClass; });
109
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BrowserStorageCache", function() { return BrowserStorageCache; });
110
+ /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Utils */ "./lib-esm/Utils/index.js");
111
+ /* harmony import */ var _StorageCache__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./StorageCache */ "./lib-esm/StorageCache.js");
112
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
113
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_2__);
114
+ /*
115
+ * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
116
+ *
117
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
118
+ * the License. A copy of the License is located at
119
+ *
120
+ * http://aws.amazon.com/apache2.0/
121
+ *
122
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
123
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
124
+ * and limitations under the License.
125
+ */
126
+ var __extends = undefined && undefined.__extends || function () {
127
+ var _extendStatics = function extendStatics(d, b) {
128
+ _extendStatics = Object.setPrototypeOf || {
129
+ __proto__: []
130
+ } instanceof Array && function (d, b) {
131
+ d.__proto__ = b;
132
+ } || function (d, b) {
133
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
134
+ };
135
+ return _extendStatics(d, b);
136
+ };
137
+ return function (d, b) {
138
+ _extendStatics(d, b);
139
+ function __() {
140
+ this.constructor = d;
141
+ }
142
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
143
+ };
144
+ }();
145
+
146
+
147
+
148
+ var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_2__["ConsoleLogger"]('Cache');
149
+ /**
150
+ * Customized storage based on the SessionStorage or LocalStorage with LRU implemented
151
+ */
152
+ var BrowserStorageCacheClass = /** @class */function (_super) {
153
+ __extends(BrowserStorageCacheClass, _super);
154
+ /**
155
+ * initialize the cache
156
+ * @param config - the configuration of the cache
157
+ */
158
+ function BrowserStorageCacheClass(config) {
159
+ var _this = this;
160
+ var cacheConfig = config ? Object.assign({}, _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"], config) : _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"];
161
+ _this = _super.call(this, cacheConfig) || this;
162
+ _this.config.storage = cacheConfig.storage;
163
+ _this.getItem = _this.getItem.bind(_this);
164
+ _this.setItem = _this.setItem.bind(_this);
165
+ _this.removeItem = _this.removeItem.bind(_this);
166
+ return _this;
167
+ }
168
+ /**
169
+ * decrease current size of the cache
170
+ *
171
+ * @private
172
+ * @param amount - the amount of the cache size which needs to be decreased
173
+ */
174
+ BrowserStorageCacheClass.prototype._decreaseCurSizeInBytes = function (amount) {
175
+ var curSize = this.getCacheCurSize();
176
+ this.config.storage.setItem(this.cacheCurSizeKey, (curSize - amount).toString());
177
+ };
178
+ /**
179
+ * increase current size of the cache
180
+ *
181
+ * @private
182
+ * @param amount - the amount of the cache szie which need to be increased
183
+ */
184
+ BrowserStorageCacheClass.prototype._increaseCurSizeInBytes = function (amount) {
185
+ var curSize = this.getCacheCurSize();
186
+ this.config.storage.setItem(this.cacheCurSizeKey, (curSize + amount).toString());
187
+ };
188
+ /**
189
+ * update the visited time if item has been visited
190
+ *
191
+ * @private
192
+ * @param item - the item which need to be refreshed
193
+ * @param prefixedKey - the key of the item
194
+ *
195
+ * @return the refreshed item
196
+ */
197
+ BrowserStorageCacheClass.prototype._refreshItem = function (item, prefixedKey) {
198
+ item.visitedTime = Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"])();
199
+ this.config.storage.setItem(prefixedKey, JSON.stringify(item));
200
+ return item;
201
+ };
202
+ /**
203
+ * check wether item is expired
204
+ *
205
+ * @private
206
+ * @param key - the key of the item
207
+ *
208
+ * @return true if the item is expired.
209
+ */
210
+ BrowserStorageCacheClass.prototype._isExpired = function (key) {
211
+ var text = this.config.storage.getItem(key);
212
+ var item = JSON.parse(text);
213
+ if (Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"])() >= item.expires) {
214
+ return true;
215
+ }
216
+ return false;
217
+ };
218
+ /**
219
+ * delete item from cache
220
+ *
221
+ * @private
222
+ * @param prefixedKey - the key of the item
223
+ * @param size - optional, the byte size of the item
224
+ */
225
+ BrowserStorageCacheClass.prototype._removeItem = function (prefixedKey, size) {
226
+ var itemSize = size ? size : JSON.parse(this.config.storage.getItem(prefixedKey)).byteSize;
227
+ this._decreaseCurSizeInBytes(itemSize);
228
+ // remove the cache item
229
+ this.config.storage.removeItem(prefixedKey);
230
+ };
231
+ /**
232
+ * put item into cache
233
+ *
234
+ * @private
235
+ * @param prefixedKey - the key of the item
236
+ * @param itemData - the value of the item
237
+ * @param itemSizeInBytes - the byte size of the item
238
+ */
239
+ BrowserStorageCacheClass.prototype._setItem = function (prefixedKey, item) {
240
+ // update the cache size
241
+ this._increaseCurSizeInBytes(item.byteSize);
242
+ try {
243
+ this.config.storage.setItem(prefixedKey, JSON.stringify(item));
244
+ } catch (setItemErr) {
245
+ // if failed, we need to rollback the cache size
246
+ this._decreaseCurSizeInBytes(item.byteSize);
247
+ logger.error("Failed to set item " + setItemErr);
248
+ }
249
+ };
250
+ /**
251
+ * total space needed when poping out items
252
+ *
253
+ * @private
254
+ * @param itemSize
255
+ *
256
+ * @return total space needed
257
+ */
258
+ BrowserStorageCacheClass.prototype._sizeToPop = function (itemSize) {
259
+ var spaceItemNeed = this.getCacheCurSize() + itemSize - this.config.capacityInBytes;
260
+ var cacheThresholdSpace = (1 - this.config.warningThreshold) * this.config.capacityInBytes;
261
+ return spaceItemNeed > cacheThresholdSpace ? spaceItemNeed : cacheThresholdSpace;
262
+ };
263
+ /**
264
+ * see whether cache is full
265
+ *
266
+ * @private
267
+ * @param itemSize
268
+ *
269
+ * @return true if cache is full
270
+ */
271
+ BrowserStorageCacheClass.prototype._isCacheFull = function (itemSize) {
272
+ return itemSize + this.getCacheCurSize() > this.config.capacityInBytes;
273
+ };
274
+ /**
275
+ * scan the storage and find out all the keys owned by this cache
276
+ * also clean the expired keys while scanning
277
+ *
278
+ * @private
279
+ *
280
+ * @return array of keys
281
+ */
282
+ BrowserStorageCacheClass.prototype._findValidKeys = function () {
283
+ var keys = [];
284
+ var keyInCache = [];
285
+ // get all keys in Storage
286
+ for (var i = 0; i < this.config.storage.length; i += 1) {
287
+ keyInCache.push(this.config.storage.key(i));
288
+ }
289
+ // find those items which belong to our cache and also clean those expired items
290
+ for (var i = 0; i < keyInCache.length; i += 1) {
291
+ var key = keyInCache[i];
292
+ if (key.indexOf(this.config.keyPrefix) === 0 && key !== this.cacheCurSizeKey) {
293
+ if (this._isExpired(key)) {
294
+ this._removeItem(key);
295
+ } else {
296
+ keys.push(key);
297
+ }
298
+ }
299
+ }
300
+ return keys;
301
+ };
302
+ /**
303
+ * get all the items we have, sort them by their priority,
304
+ * if priority is same, sort them by their last visited time
305
+ * pop out items from the low priority (5 is the lowest)
306
+ *
307
+ * @private
308
+ * @param keys - all the keys in this cache
309
+ * @param sizeToPop - the total size of the items which needed to be poped out
310
+ */
311
+ BrowserStorageCacheClass.prototype._popOutItems = function (keys, sizeToPop) {
312
+ var items = [];
313
+ var remainedSize = sizeToPop;
314
+ // get the items from Storage
315
+ for (var i = 0; i < keys.length; i += 1) {
316
+ var val = this.config.storage.getItem(keys[i]);
317
+ if (val != null) {
318
+ var item = JSON.parse(val);
319
+ items.push(item);
320
+ }
321
+ }
322
+ // first compare priority
323
+ // then compare visited time
324
+ items.sort(function (a, b) {
325
+ if (a.priority > b.priority) {
326
+ return -1;
327
+ } else if (a.priority < b.priority) {
328
+ return 1;
329
+ } else {
330
+ if (a.visitedTime < b.visitedTime) {
331
+ return -1;
332
+ } else return 1;
333
+ }
334
+ });
335
+ for (var i = 0; i < items.length; i += 1) {
336
+ // pop out items until we have enough room for new item
337
+ this._removeItem(items[i].key, items[i].byteSize);
338
+ remainedSize -= items[i].byteSize;
339
+ if (remainedSize <= 0) {
340
+ return;
341
+ }
342
+ }
343
+ };
344
+ /**
345
+ * Set item into cache. You can put number, string, boolean or object.
346
+ * The cache will first check whether has the same key.
347
+ * If it has, it will delete the old item and then put the new item in
348
+ * The cache will pop out items if it is full
349
+ * You can specify the cache item options. The cache will abort and output a warning:
350
+ * If the key is invalid
351
+ * If the size of the item exceeds itemMaxSize.
352
+ * If the value is undefined
353
+ * If incorrect cache item configuration
354
+ * If error happened with browser storage
355
+ *
356
+ * @param key - the key of the item
357
+ * @param value - the value of the item
358
+ * @param {Object} [options] - optional, the specified meta-data
359
+ */
360
+ BrowserStorageCacheClass.prototype.setItem = function (key, value, options) {
361
+ logger.log("Set item: key is " + key + ", value is " + value + " with options: " + options);
362
+ var prefixedKey = this.config.keyPrefix + key;
363
+ // invalid keys
364
+ if (prefixedKey === this.config.keyPrefix || prefixedKey === this.cacheCurSizeKey) {
365
+ logger.warn("Invalid key: should not be empty or 'CurSize'");
366
+ return;
367
+ }
368
+ if (typeof value === 'undefined') {
369
+ logger.warn("The value of item should not be undefined!");
370
+ return;
371
+ }
372
+ var cacheItemOptions = {
373
+ priority: options && options.priority !== undefined ? options.priority : this.config.defaultPriority,
374
+ expires: options && options.expires !== undefined ? options.expires : this.config.defaultTTL + Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"])()
375
+ };
376
+ if (cacheItemOptions.priority < 1 || cacheItemOptions.priority > 5) {
377
+ logger.warn("Invalid parameter: priority due to out or range. It should be within 1 and 5.");
378
+ return;
379
+ }
380
+ var item = this.fillCacheItem(prefixedKey, value, cacheItemOptions);
381
+ // check wether this item is too big;
382
+ if (item.byteSize > this.config.itemMaxSize) {
383
+ logger.warn("Item with key: " + key + " you are trying to put into is too big!");
384
+ return;
385
+ }
386
+ try {
387
+ // first look into the storage, if it exists, delete it.
388
+ var val = this.config.storage.getItem(prefixedKey);
389
+ if (val) {
390
+ this._removeItem(prefixedKey, JSON.parse(val).byteSize);
391
+ }
392
+ // check whether the cache is full
393
+ if (this._isCacheFull(item.byteSize)) {
394
+ var validKeys = this._findValidKeys();
395
+ // check again and then pop out items
396
+ if (this._isCacheFull(item.byteSize)) {
397
+ var sizeToPop = this._sizeToPop(item.byteSize);
398
+ this._popOutItems(validKeys, sizeToPop);
399
+ }
400
+ }
401
+ // put item in the cache
402
+ // may failed due to storage full
403
+ this._setItem(prefixedKey, item);
404
+ } catch (e) {
405
+ logger.warn("setItem failed! " + e);
406
+ }
407
+ };
408
+ /**
409
+ * Get item from cache. It will return null if item doesn’t exist or it has been expired.
410
+ * If you specified callback function in the options,
411
+ * then the function will be executed if no such item in the cache
412
+ * and finally put the return value into cache.
413
+ * Please make sure the callback function will return the value you want to put into the cache.
414
+ * The cache will abort output a warning:
415
+ * If the key is invalid
416
+ * If error happened with browser storage
417
+ *
418
+ * @param key - the key of the item
419
+ * @param {Object} [options] - the options of callback function
420
+ *
421
+ * @return - return the value of the item
422
+ */
423
+ BrowserStorageCacheClass.prototype.getItem = function (key, options) {
424
+ logger.log("Get item: key is " + key + " with options " + options);
425
+ var ret = null;
426
+ var prefixedKey = this.config.keyPrefix + key;
427
+ if (prefixedKey === this.config.keyPrefix || prefixedKey === this.cacheCurSizeKey) {
428
+ logger.warn("Invalid key: should not be empty or 'CurSize'");
429
+ return null;
430
+ }
431
+ try {
432
+ ret = this.config.storage.getItem(prefixedKey);
433
+ if (ret != null) {
434
+ if (this._isExpired(prefixedKey)) {
435
+ // if expired, remove that item and return null
436
+ this._removeItem(prefixedKey, JSON.parse(ret).byteSize);
437
+ ret = null;
438
+ } else {
439
+ // if not expired, great, return the value and refresh it
440
+ var item = JSON.parse(ret);
441
+ item = this._refreshItem(item, prefixedKey);
442
+ return item.data;
443
+ }
444
+ }
445
+ if (options && options.callback !== undefined) {
446
+ var val = options.callback();
447
+ if (val !== null) {
448
+ this.setItem(key, val, options);
449
+ }
450
+ return val;
451
+ }
452
+ return null;
453
+ } catch (e) {
454
+ logger.warn("getItem failed! " + e);
455
+ return null;
456
+ }
457
+ };
458
+ /**
459
+ * remove item from the cache
460
+ * The cache will abort output a warning:
461
+ * If error happened with browser storage
462
+ * @param key - the key of the item
463
+ */
464
+ BrowserStorageCacheClass.prototype.removeItem = function (key) {
465
+ logger.log("Remove item: key is " + key);
466
+ var prefixedKey = this.config.keyPrefix + key;
467
+ if (prefixedKey === this.config.keyPrefix || prefixedKey === this.cacheCurSizeKey) {
468
+ return;
469
+ }
470
+ try {
471
+ var val = this.config.storage.getItem(prefixedKey);
472
+ if (val) {
473
+ this._removeItem(prefixedKey, JSON.parse(val).byteSize);
474
+ }
475
+ } catch (e) {
476
+ logger.warn("removeItem failed! " + e);
477
+ }
478
+ };
479
+ /**
480
+ * clear the entire cache
481
+ * The cache will abort output a warning:
482
+ * If error happened with browser storage
483
+ */
484
+ BrowserStorageCacheClass.prototype.clear = function () {
485
+ logger.log("Clear Cache");
486
+ var keysToRemove = [];
487
+ for (var i = 0; i < this.config.storage.length; i += 1) {
488
+ var key = this.config.storage.key(i);
489
+ if (key.indexOf(this.config.keyPrefix) === 0) {
490
+ keysToRemove.push(key);
491
+ }
492
+ }
493
+ try {
494
+ for (var i = 0; i < keysToRemove.length; i += 1) {
495
+ this.config.storage.removeItem(keysToRemove[i]);
496
+ }
497
+ } catch (e) {
498
+ logger.warn("clear failed! " + e);
499
+ }
500
+ };
501
+ /**
502
+ * Return all the keys in the cache.
503
+ *
504
+ * @return - all keys in the cache
505
+ */
506
+ BrowserStorageCacheClass.prototype.getAllKeys = function () {
507
+ var keys = [];
508
+ for (var i = 0; i < this.config.storage.length; i += 1) {
509
+ var key = this.config.storage.key(i);
510
+ if (key.indexOf(this.config.keyPrefix) === 0 && key !== this.cacheCurSizeKey) {
511
+ keys.push(key.substring(this.config.keyPrefix.length));
512
+ }
513
+ }
514
+ return keys;
515
+ };
516
+ /**
517
+ * return the current size of the cache
518
+ *
519
+ * @return - current size of the cache
520
+ */
521
+ BrowserStorageCacheClass.prototype.getCacheCurSize = function () {
522
+ var ret = this.config.storage.getItem(this.cacheCurSizeKey);
523
+ if (!ret) {
524
+ this.config.storage.setItem(this.cacheCurSizeKey, '0');
525
+ ret = '0';
526
+ }
527
+ return Number(ret);
528
+ };
529
+ /**
530
+ * Return a new instance of cache with customized configuration.
531
+ * @param config - the customized configuration
532
+ *
533
+ * @return - new instance of Cache
534
+ */
535
+ BrowserStorageCacheClass.prototype.createInstance = function (config) {
536
+ if (!config.keyPrefix || config.keyPrefix === _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].keyPrefix) {
537
+ logger.error('invalid keyPrefix, setting keyPrefix with timeStamp');
538
+ config.keyPrefix = _Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"].toString();
539
+ }
540
+ return new BrowserStorageCacheClass(config);
541
+ };
542
+ return BrowserStorageCacheClass;
543
+ }(_StorageCache__WEBPACK_IMPORTED_MODULE_1__["StorageCache"]);
544
+
545
+ var BrowserStorageCache = new BrowserStorageCacheClass();
546
+ /**
547
+ * @deprecated use named import
548
+ */
549
+ /* harmony default export */ __webpack_exports__["default"] = (BrowserStorageCache);
550
+
551
+ /***/ }),
552
+
553
+ /***/ "./lib-esm/InMemoryCache.js":
554
+ /*!**********************************!*\
555
+ !*** ./lib-esm/InMemoryCache.js ***!
556
+ \**********************************/
557
+ /*! exports provided: InMemoryCacheClass, InMemoryCache, default */
558
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
559
+
560
+ "use strict";
561
+ __webpack_require__.r(__webpack_exports__);
562
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InMemoryCacheClass", function() { return InMemoryCacheClass; });
563
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InMemoryCache", function() { return InMemoryCache; });
564
+ /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Utils */ "./lib-esm/Utils/index.js");
565
+ /* harmony import */ var _StorageCache__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./StorageCache */ "./lib-esm/StorageCache.js");
566
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
567
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_2__);
568
+ /*
569
+ * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
570
+ *
571
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
572
+ * the License. A copy of the License is located at
573
+ *
574
+ * http://aws.amazon.com/apache2.0/
575
+ *
576
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
577
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
578
+ * and limitations under the License.
579
+ */
580
+ var __extends = undefined && undefined.__extends || function () {
581
+ var _extendStatics = function extendStatics(d, b) {
582
+ _extendStatics = Object.setPrototypeOf || {
583
+ __proto__: []
584
+ } instanceof Array && function (d, b) {
585
+ d.__proto__ = b;
586
+ } || function (d, b) {
587
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
588
+ };
589
+ return _extendStatics(d, b);
590
+ };
591
+ return function (d, b) {
592
+ _extendStatics(d, b);
593
+ function __() {
594
+ this.constructor = d;
595
+ }
596
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
597
+ };
598
+ }();
599
+ var __values = undefined && undefined.__values || function (o) {
600
+ var s = typeof Symbol === "function" && Symbol.iterator,
601
+ m = s && o[s],
602
+ i = 0;
603
+ if (m) return m.call(o);
604
+ if (o && typeof o.length === "number") return {
605
+ next: function next() {
606
+ if (o && i >= o.length) o = void 0;
607
+ return {
608
+ value: o && o[i++],
609
+ done: !o
610
+ };
611
+ }
612
+ };
613
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
614
+ };
615
+
616
+
617
+
618
+ var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_2__["ConsoleLogger"]('InMemoryCache');
619
+ /**
620
+ * Customized in-memory cache with LRU implemented
621
+ * @member cacheObj - object which store items
622
+ * @member cacheList - list of keys in the cache with LRU
623
+ * @member curSizeInBytes - current size of the cache
624
+ * @member maxPriority - max of the priority
625
+ * @member cacheSizeLimit - the limit of cache size
626
+ */
627
+ var InMemoryCacheClass = /** @class */function (_super) {
628
+ __extends(InMemoryCacheClass, _super);
629
+ /**
630
+ * initialize the cache
631
+ *
632
+ * @param config - the configuration of the cache
633
+ */
634
+ function InMemoryCacheClass(config) {
635
+ var _this = this;
636
+ var cacheConfig = config ? Object.assign({}, _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"], config) : _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"];
637
+ _this = _super.call(this, cacheConfig) || this;
638
+ logger.debug('now we start!');
639
+ _this.cacheList = [];
640
+ _this.curSizeInBytes = 0;
641
+ _this.maxPriority = 5;
642
+ _this.getItem = _this.getItem.bind(_this);
643
+ _this.setItem = _this.setItem.bind(_this);
644
+ _this.removeItem = _this.removeItem.bind(_this);
645
+ // initialize list for every priority
646
+ for (var i = 0; i < _this.maxPriority; i += 1) {
647
+ _this.cacheList[i] = new _Utils__WEBPACK_IMPORTED_MODULE_0__["CacheList"]();
648
+ }
649
+ return _this;
650
+ }
651
+ /**
652
+ * decrease current size of the cache
653
+ *
654
+ * @param amount - the amount of the cache size which needs to be decreased
655
+ */
656
+ InMemoryCacheClass.prototype._decreaseCurSizeInBytes = function (amount) {
657
+ this.curSizeInBytes -= amount;
658
+ };
659
+ /**
660
+ * increase current size of the cache
661
+ *
662
+ * @param amount - the amount of the cache szie which need to be increased
663
+ */
664
+ InMemoryCacheClass.prototype._increaseCurSizeInBytes = function (amount) {
665
+ this.curSizeInBytes += amount;
666
+ };
667
+ /**
668
+ * check whether item is expired
669
+ *
670
+ * @param key - the key of the item
671
+ *
672
+ * @return true if the item is expired.
673
+ */
674
+ InMemoryCacheClass.prototype._isExpired = function (key) {
675
+ var text = _Utils__WEBPACK_IMPORTED_MODULE_0__["CacheObject"].getItem(key);
676
+ var item = JSON.parse(text);
677
+ if (Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"])() >= item.expires) {
678
+ return true;
679
+ }
680
+ return false;
681
+ };
682
+ /**
683
+ * delete item from cache
684
+ *
685
+ * @param prefixedKey - the key of the item
686
+ * @param listIdx - indicates which cache list the key belongs to
687
+ */
688
+ InMemoryCacheClass.prototype._removeItem = function (prefixedKey, listIdx) {
689
+ // delete the key from the list
690
+ this.cacheList[listIdx].removeItem(prefixedKey);
691
+ // decrease the current size of the cache
692
+ this._decreaseCurSizeInBytes(JSON.parse(_Utils__WEBPACK_IMPORTED_MODULE_0__["CacheObject"].getItem(prefixedKey)).byteSize);
693
+ // finally remove the item from memory
694
+ _Utils__WEBPACK_IMPORTED_MODULE_0__["CacheObject"].removeItem(prefixedKey);
695
+ };
696
+ /**
697
+ * put item into cache
698
+ *
699
+ * @param prefixedKey - the key of the item
700
+ * @param itemData - the value of the item
701
+ * @param itemSizeInBytes - the byte size of the item
702
+ * @param listIdx - indicates which cache list the key belongs to
703
+ */
704
+ InMemoryCacheClass.prototype._setItem = function (prefixedKey, item, listIdx) {
705
+ // insert the key into the list
706
+ this.cacheList[listIdx].insertItem(prefixedKey);
707
+ // increase the current size of the cache
708
+ this._increaseCurSizeInBytes(item.byteSize);
709
+ // finally add the item into memory
710
+ _Utils__WEBPACK_IMPORTED_MODULE_0__["CacheObject"].setItem(prefixedKey, JSON.stringify(item));
711
+ };
712
+ /**
713
+ * see whether cache is full
714
+ *
715
+ * @param itemSize
716
+ *
717
+ * @return true if cache is full
718
+ */
719
+ InMemoryCacheClass.prototype._isCacheFull = function (itemSize) {
720
+ return this.curSizeInBytes + itemSize > this.config.capacityInBytes;
721
+ };
722
+ /**
723
+ * check whether the cache contains the key
724
+ *
725
+ * @param key
726
+ */
727
+ InMemoryCacheClass.prototype.containsKey = function (key) {
728
+ var prefixedKey = this.config.keyPrefix + key;
729
+ for (var i = 0; i < this.maxPriority; i += 1) {
730
+ if (this.cacheList[i].containsKey(prefixedKey)) {
731
+ return i + 1;
732
+ }
733
+ }
734
+ return -1;
735
+ };
736
+ /**
737
+ * * Set item into cache. You can put number, string, boolean or object.
738
+ * The cache will first check whether has the same key.
739
+ * If it has, it will delete the old item and then put the new item in
740
+ * The cache will pop out items if it is full
741
+ * You can specify the cache item options. The cache will abort and output a warning:
742
+ * If the key is invalid
743
+ * If the size of the item exceeds itemMaxSize.
744
+ * If the value is undefined
745
+ * If incorrect cache item configuration
746
+ * If error happened with browser storage
747
+ *
748
+ * @param key - the key of the item
749
+ * @param value - the value of the item
750
+ * @param options - optional, the specified meta-data
751
+ *
752
+ * @throws if the item is too big which exceeds the limit of single item size
753
+ * @throws if the key is invalid
754
+ */
755
+ InMemoryCacheClass.prototype.setItem = function (key, value, options) {
756
+ var prefixedKey = this.config.keyPrefix + key;
757
+ // invalid keys
758
+ if (prefixedKey === this.config.keyPrefix || prefixedKey === this.cacheCurSizeKey) {
759
+ logger.warn("Invalid key: should not be empty or 'CurSize'");
760
+ return;
761
+ }
762
+ if (typeof value === 'undefined') {
763
+ logger.warn("The value of item should not be undefined!");
764
+ return;
765
+ }
766
+ var cacheItemOptions = {
767
+ priority: options && options.priority !== undefined ? options.priority : this.config.defaultPriority,
768
+ expires: options && options.expires !== undefined ? options.expires : this.config.defaultTTL + Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"])()
769
+ };
770
+ if (cacheItemOptions.priority < 1 || cacheItemOptions.priority > 5) {
771
+ logger.warn("Invalid parameter: priority due to out or range. It should be within 1 and 5.");
772
+ return;
773
+ }
774
+ var item = this.fillCacheItem(prefixedKey, value, cacheItemOptions);
775
+ // check wether this item is too big;
776
+ if (item.byteSize > this.config.itemMaxSize) {
777
+ logger.warn("Item with key: " + key + " you are trying to put into is too big!");
778
+ return;
779
+ }
780
+ // if key already in the cache, then delete it.
781
+ var presentKeyPrio = this.containsKey(key);
782
+ if (presentKeyPrio !== -1) {
783
+ this._removeItem(prefixedKey, presentKeyPrio - 1);
784
+ }
785
+ // pop out items in the cache when cache is full based on LRU
786
+ // first start from lowest priority cache list
787
+ var cacheListIdx = this.maxPriority - 1;
788
+ while (this._isCacheFull(item.byteSize) && cacheListIdx >= 0) {
789
+ if (!this.cacheList[cacheListIdx].isEmpty()) {
790
+ var popedItemKey = this.cacheList[cacheListIdx].getLastItem();
791
+ this._removeItem(popedItemKey, cacheListIdx);
792
+ } else {
793
+ cacheListIdx -= 1;
794
+ }
795
+ }
796
+ this._setItem(prefixedKey, item, Number(item.priority) - 1);
797
+ };
798
+ /**
799
+ * Get item from cache. It will return null if item doesn’t exist or it has been expired.
800
+ * If you specified callback function in the options,
801
+ * then the function will be executed if no such item in the cache
802
+ * and finally put the return value into cache.
803
+ * Please make sure the callback function will return the value you want to put into the cache.
804
+ * The cache will abort output a warning:
805
+ * If the key is invalid
806
+ *
807
+ * @param key - the key of the item
808
+ * @param options - the options of callback function
809
+ */
810
+ InMemoryCacheClass.prototype.getItem = function (key, options) {
811
+ var ret = null;
812
+ var prefixedKey = this.config.keyPrefix + key;
813
+ if (prefixedKey === this.config.keyPrefix || prefixedKey === this.cacheCurSizeKey) {
814
+ logger.warn("Invalid key: should not be empty or 'CurSize'");
815
+ return null;
816
+ }
817
+ // check whether it's in the cachelist
818
+ var presentKeyPrio = this.containsKey(key);
819
+ if (presentKeyPrio !== -1) {
820
+ if (this._isExpired(prefixedKey)) {
821
+ // if expired, remove that item and return null
822
+ this._removeItem(prefixedKey, presentKeyPrio - 1);
823
+ } else {
824
+ // if not expired, great, return the value and refresh it
825
+ ret = _Utils__WEBPACK_IMPORTED_MODULE_0__["CacheObject"].getItem(prefixedKey);
826
+ var item = JSON.parse(ret);
827
+ this.cacheList[item.priority - 1].refresh(prefixedKey);
828
+ return item.data;
829
+ }
830
+ }
831
+ if (options && options.callback !== undefined) {
832
+ var val = options.callback();
833
+ if (val !== null) {
834
+ this.setItem(key, val, options);
835
+ }
836
+ return val;
837
+ }
838
+ return null;
839
+ };
840
+ /**
841
+ * remove item from the cache
842
+ *
843
+ * @param key - the key of the item
844
+ */
845
+ InMemoryCacheClass.prototype.removeItem = function (key) {
846
+ var prefixedKey = this.config.keyPrefix + key;
847
+ // check if the key is in the cache
848
+ var presentKeyPrio = this.containsKey(key);
849
+ if (presentKeyPrio !== -1) {
850
+ this._removeItem(prefixedKey, presentKeyPrio - 1);
851
+ }
852
+ };
853
+ /**
854
+ * clear the entire cache
855
+ */
856
+ InMemoryCacheClass.prototype.clear = function () {
857
+ var e_1, _a;
858
+ for (var i = 0; i < this.maxPriority; i += 1) {
859
+ try {
860
+ for (var _b = (e_1 = void 0, __values(this.cacheList[i].getKeys())), _c = _b.next(); !_c.done; _c = _b.next()) {
861
+ var key = _c.value;
862
+ this._removeItem(key, i);
863
+ }
864
+ } catch (e_1_1) {
865
+ e_1 = {
866
+ error: e_1_1
867
+ };
868
+ } finally {
869
+ try {
870
+ if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
871
+ } finally {
872
+ if (e_1) throw e_1.error;
873
+ }
874
+ }
875
+ }
876
+ };
877
+ /**
878
+ * Return all the keys in the cache.
879
+ */
880
+ InMemoryCacheClass.prototype.getAllKeys = function () {
881
+ var e_2, _a;
882
+ var keys = [];
883
+ for (var i = 0; i < this.maxPriority; i += 1) {
884
+ try {
885
+ for (var _b = (e_2 = void 0, __values(this.cacheList[i].getKeys())), _c = _b.next(); !_c.done; _c = _b.next()) {
886
+ var key = _c.value;
887
+ keys.push(key.substring(this.config.keyPrefix.length));
888
+ }
889
+ } catch (e_2_1) {
890
+ e_2 = {
891
+ error: e_2_1
892
+ };
893
+ } finally {
894
+ try {
895
+ if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
896
+ } finally {
897
+ if (e_2) throw e_2.error;
898
+ }
899
+ }
900
+ }
901
+ return keys;
902
+ };
903
+ /**
904
+ * return the current size of the cache
905
+ *
906
+ * @return the current size of the cache
907
+ */
908
+ InMemoryCacheClass.prototype.getCacheCurSize = function () {
909
+ return this.curSizeInBytes;
910
+ };
911
+ /**
912
+ * Return a new instance of cache with customized configuration.
913
+ * @param config - the customized configuration
914
+ */
915
+ InMemoryCacheClass.prototype.createInstance = function (config) {
916
+ return new InMemoryCacheClass(config);
917
+ };
918
+ return InMemoryCacheClass;
919
+ }(_StorageCache__WEBPACK_IMPORTED_MODULE_1__["StorageCache"]);
920
+
921
+ var InMemoryCache = new InMemoryCacheClass();
922
+ /**
923
+ * @deprecated use named import
924
+ */
925
+ /* harmony default export */ __webpack_exports__["default"] = (InMemoryCache);
926
+
927
+ /***/ }),
928
+
929
+ /***/ "./lib-esm/StorageCache.js":
930
+ /*!*********************************!*\
931
+ !*** ./lib-esm/StorageCache.js ***!
932
+ \*********************************/
933
+ /*! exports provided: StorageCache, default */
934
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
935
+
936
+ "use strict";
937
+ __webpack_require__.r(__webpack_exports__);
938
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StorageCache", function() { return StorageCache; });
939
+ /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Utils */ "./lib-esm/Utils/index.js");
940
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
941
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__);
942
+ function _typeof(obj) {
943
+ "@babel/helpers - typeof";
944
+
945
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
946
+ return typeof obj;
947
+ } : function (obj) {
948
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
949
+ }, _typeof(obj);
950
+ }
951
+ /*
952
+ * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
953
+ *
954
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
955
+ * the License. A copy of the License is located at
956
+ *
957
+ * http://aws.amazon.com/apache2.0/
958
+ *
959
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
960
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
961
+ * and limitations under the License.
962
+ */
963
+
964
+
965
+ var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('StorageCache');
966
+ /**
967
+ * Initialization of the cache
968
+ *
969
+ */
970
+ var StorageCache = /** @class */function () {
971
+ /**
972
+ * Initialize the cache
973
+ * @param config - the configuration of the cache
974
+ */
975
+ function StorageCache(config) {
976
+ this.config = Object.assign({}, config);
977
+ this.cacheCurSizeKey = this.config.keyPrefix + 'CurSize';
978
+ this.checkConfig();
979
+ }
980
+ StorageCache.prototype.getModuleName = function () {
981
+ return 'Cache';
982
+ };
983
+ StorageCache.prototype.checkConfig = function () {
984
+ // check configuration
985
+ if (!Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["isInteger"])(this.config.capacityInBytes)) {
986
+ logger.error('Invalid parameter: capacityInBytes. It should be an Integer. Setting back to default.');
987
+ this.config.capacityInBytes = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].capacityInBytes;
988
+ }
989
+ if (!Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["isInteger"])(this.config.itemMaxSize)) {
990
+ logger.error('Invalid parameter: itemMaxSize. It should be an Integer. Setting back to default.');
991
+ this.config.itemMaxSize = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].itemMaxSize;
992
+ }
993
+ if (!Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["isInteger"])(this.config.defaultTTL)) {
994
+ logger.error('Invalid parameter: defaultTTL. It should be an Integer. Setting back to default.');
995
+ this.config.defaultTTL = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].defaultTTL;
996
+ }
997
+ if (!Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["isInteger"])(this.config.defaultPriority)) {
998
+ logger.error('Invalid parameter: defaultPriority. It should be an Integer. Setting back to default.');
999
+ this.config.defaultPriority = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].defaultPriority;
1000
+ }
1001
+ if (this.config.itemMaxSize > this.config.capacityInBytes) {
1002
+ logger.error('Invalid parameter: itemMaxSize. It should be smaller than capacityInBytes. Setting back to default.');
1003
+ this.config.itemMaxSize = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].itemMaxSize;
1004
+ }
1005
+ if (this.config.defaultPriority > 5 || this.config.defaultPriority < 1) {
1006
+ logger.error('Invalid parameter: defaultPriority. It should be between 1 and 5. Setting back to default.');
1007
+ this.config.defaultPriority = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].defaultPriority;
1008
+ }
1009
+ if (Number(this.config.warningThreshold) > 1 || Number(this.config.warningThreshold) < 0) {
1010
+ logger.error('Invalid parameter: warningThreshold. It should be between 0 and 1. Setting back to default.');
1011
+ this.config.warningThreshold = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].warningThreshold;
1012
+ }
1013
+ // set 5MB limit
1014
+ var cacheLimit = 5 * 1024 * 1024;
1015
+ if (this.config.capacityInBytes > cacheLimit) {
1016
+ logger.error('Cache Capacity should be less than 5MB. Setting back to default. Setting back to default.');
1017
+ this.config.capacityInBytes = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].capacityInBytes;
1018
+ }
1019
+ };
1020
+ /**
1021
+ * produce a JSON object with meta-data and data value
1022
+ * @param value - the value of the item
1023
+ * @param options - optional, the specified meta-data
1024
+ *
1025
+ * @return - the item which has the meta-data and the value
1026
+ */
1027
+ StorageCache.prototype.fillCacheItem = function (key, value, options) {
1028
+ var ret = {
1029
+ key: key,
1030
+ data: value,
1031
+ timestamp: Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"])(),
1032
+ visitedTime: Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"])(),
1033
+ priority: options.priority,
1034
+ expires: options.expires,
1035
+ type: _typeof(value),
1036
+ byteSize: 0
1037
+ };
1038
+ ret.byteSize = Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getByteLength"])(JSON.stringify(ret));
1039
+ // for accurate size
1040
+ ret.byteSize = Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getByteLength"])(JSON.stringify(ret));
1041
+ return ret;
1042
+ };
1043
+ /**
1044
+ * set cache with customized configuration
1045
+ * @param config - customized configuration
1046
+ *
1047
+ * @return - the current configuration
1048
+ */
1049
+ StorageCache.prototype.configure = function (config) {
1050
+ if (!config) {
1051
+ return this.config;
1052
+ }
1053
+ if (config.keyPrefix) {
1054
+ logger.warn("Don't try to configure keyPrefix!");
1055
+ }
1056
+ this.config = Object.assign({}, this.config, config, config.Cache);
1057
+ this.checkConfig();
1058
+ return this.config;
1059
+ };
1060
+ return StorageCache;
1061
+ }();
1062
+
1063
+ /**
1064
+ * @deprecated use named import
1065
+ */
1066
+ /* harmony default export */ __webpack_exports__["default"] = (StorageCache);
1067
+
1068
+ /***/ }),
1069
+
1070
+ /***/ "./lib-esm/Utils/CacheList.js":
1071
+ /*!************************************!*\
1072
+ !*** ./lib-esm/Utils/CacheList.js ***!
1073
+ \************************************/
1074
+ /*! exports provided: default */
1075
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1076
+
1077
+ "use strict";
1078
+ __webpack_require__.r(__webpack_exports__);
1079
+ /*
1080
+ * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1081
+ *
1082
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
1083
+ * the License. A copy of the License is located at
1084
+ *
1085
+ * http://aws.amazon.com/apache2.0/
1086
+ *
1087
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
1088
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1089
+ * and limitations under the License.
1090
+ */
1091
+ var __values = undefined && undefined.__values || function (o) {
1092
+ var s = typeof Symbol === "function" && Symbol.iterator,
1093
+ m = s && o[s],
1094
+ i = 0;
1095
+ if (m) return m.call(o);
1096
+ if (o && typeof o.length === "number") return {
1097
+ next: function next() {
1098
+ if (o && i >= o.length) o = void 0;
1099
+ return {
1100
+ value: o && o[i++],
1101
+ done: !o
1102
+ };
1103
+ }
1104
+ };
1105
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
1106
+ };
1107
+ var DoubleLinkedNode = /** @class */function () {
1108
+ function DoubleLinkedNode(keyVal) {
1109
+ this.key = keyVal ? keyVal : '';
1110
+ this.prevNode = null;
1111
+ this.nextNode = null;
1112
+ }
1113
+ return DoubleLinkedNode;
1114
+ }();
1115
+ /**
1116
+ * double linked list plus a hash table inside
1117
+ * each key in the cache stored as a node in the list
1118
+ * recently visited node will be rotated to the head
1119
+ * so the Last Recently Visited node will be at the tail
1120
+ *
1121
+ * @member head - dummy head of the linked list
1122
+ * @member tail - dummy tail of the linked list
1123
+ * @member hashtable - the hashtable which maps cache key to list node
1124
+ * @member length - length of the list
1125
+ */
1126
+ var CacheList = /** @class */function () {
1127
+ /**
1128
+ * initialization
1129
+ */
1130
+ function CacheList() {
1131
+ this.head = new DoubleLinkedNode();
1132
+ this.tail = new DoubleLinkedNode();
1133
+ this.hashtable = {};
1134
+ this.length = 0;
1135
+ this.head.nextNode = this.tail;
1136
+ this.tail.prevNode = this.head;
1137
+ }
1138
+ /**
1139
+ * insert node to the head of the list
1140
+ *
1141
+ * @param node
1142
+ */
1143
+ CacheList.prototype.insertNodeToHead = function (node) {
1144
+ var tmp = this.head.nextNode;
1145
+ this.head.nextNode = node;
1146
+ node.nextNode = tmp;
1147
+ node.prevNode = this.head;
1148
+ tmp.prevNode = node;
1149
+ this.length = this.length + 1;
1150
+ };
1151
+ /**
1152
+ * remove node
1153
+ *
1154
+ * @param node
1155
+ */
1156
+ CacheList.prototype.removeNode = function (node) {
1157
+ node.prevNode.nextNode = node.nextNode;
1158
+ node.nextNode.prevNode = node.prevNode;
1159
+ node.prevNode = null;
1160
+ node.nextNode = null;
1161
+ this.length = this.length - 1;
1162
+ };
1163
+ /**
1164
+ * @return true if list is empty
1165
+ */
1166
+ CacheList.prototype.isEmpty = function () {
1167
+ return this.length === 0;
1168
+ };
1169
+ /**
1170
+ * refresh node so it is rotated to the head
1171
+ *
1172
+ * @param key - key of the node
1173
+ */
1174
+ CacheList.prototype.refresh = function (key) {
1175
+ var node = this.hashtable[key];
1176
+ this.removeNode(node);
1177
+ this.insertNodeToHead(node);
1178
+ };
1179
+ /**
1180
+ * insert new node to the head and add it in the hashtable
1181
+ *
1182
+ * @param key - the key of the node
1183
+ */
1184
+ CacheList.prototype.insertItem = function (key) {
1185
+ var node = new DoubleLinkedNode(key);
1186
+ this.hashtable[key] = node;
1187
+ this.insertNodeToHead(node);
1188
+ };
1189
+ /**
1190
+ * @return the LAST Recently Visited key
1191
+ */
1192
+ CacheList.prototype.getLastItem = function () {
1193
+ return this.tail.prevNode.key;
1194
+ };
1195
+ /**
1196
+ * remove the cache key from the list and hashtable
1197
+ * @param key - the key of the node
1198
+ */
1199
+ CacheList.prototype.removeItem = function (key) {
1200
+ var removedItem = this.hashtable[key];
1201
+ this.removeNode(removedItem);
1202
+ delete this.hashtable[key];
1203
+ };
1204
+ /**
1205
+ * @return length of the list
1206
+ */
1207
+ CacheList.prototype.getSize = function () {
1208
+ return this.length;
1209
+ };
1210
+ /**
1211
+ * @return true if the key is in the hashtable
1212
+ * @param key
1213
+ */
1214
+ CacheList.prototype.containsKey = function (key) {
1215
+ return key in this.hashtable;
1216
+ };
1217
+ /**
1218
+ * clean up the list and hashtable
1219
+ */
1220
+ CacheList.prototype.clearList = function () {
1221
+ var e_1, _a;
1222
+ try {
1223
+ for (var _b = __values(Object.keys(this.hashtable)), _c = _b.next(); !_c.done; _c = _b.next()) {
1224
+ var key = _c.value;
1225
+ if (this.hashtable.hasOwnProperty(key)) {
1226
+ delete this.hashtable[key];
1227
+ }
1228
+ }
1229
+ } catch (e_1_1) {
1230
+ e_1 = {
1231
+ error: e_1_1
1232
+ };
1233
+ } finally {
1234
+ try {
1235
+ if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
1236
+ } finally {
1237
+ if (e_1) throw e_1.error;
1238
+ }
1239
+ }
1240
+ this.head.nextNode = this.tail;
1241
+ this.tail.prevNode = this.head;
1242
+ this.length = 0;
1243
+ };
1244
+ /**
1245
+ * @return all keys in the hashtable
1246
+ */
1247
+ CacheList.prototype.getKeys = function () {
1248
+ return Object.keys(this.hashtable);
1249
+ };
1250
+ /**
1251
+ * mainly for test
1252
+ *
1253
+ * @param key
1254
+ * @return true if key is the head node
1255
+ */
1256
+ CacheList.prototype.isHeadNode = function (key) {
1257
+ var node = this.hashtable[key];
1258
+ return node.prevNode === this.head;
1259
+ };
1260
+ /**
1261
+ * mainly for test
1262
+ *
1263
+ * @param key
1264
+ * @return true if key is the tail node
1265
+ */
1266
+ CacheList.prototype.isTailNode = function (key) {
1267
+ var node = this.hashtable[key];
1268
+ return node.nextNode === this.tail;
1269
+ };
1270
+ return CacheList;
1271
+ }();
1272
+ /* harmony default export */ __webpack_exports__["default"] = (CacheList);
1273
+
1274
+ /***/ }),
1275
+
1276
+ /***/ "./lib-esm/Utils/CacheUtils.js":
1277
+ /*!*************************************!*\
1278
+ !*** ./lib-esm/Utils/CacheUtils.js ***!
1279
+ \*************************************/
1280
+ /*! exports provided: defaultConfig, getByteLength, getCurrTime, isInteger, CacheObject */
1281
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1282
+
1283
+ "use strict";
1284
+ __webpack_require__.r(__webpack_exports__);
1285
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultConfig", function() { return defaultConfig; });
1286
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getByteLength", function() { return getByteLength; });
1287
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getCurrTime", function() { return getCurrTime; });
1288
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isInteger", function() { return isInteger; });
1289
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CacheObject", function() { return CacheObject; });
1290
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
1291
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__);
1292
+ /*
1293
+ * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1294
+ *
1295
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
1296
+ * the License. A copy of the License is located at
1297
+ *
1298
+ * http://aws.amazon.com/apache2.0/
1299
+ *
1300
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
1301
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1302
+ * and limitations under the License.
1303
+ */
1304
+
1305
+ /**
1306
+ * Default cache config
1307
+ */
1308
+ var defaultConfig = {
1309
+ keyPrefix: 'aws-amplify-cache',
1310
+ capacityInBytes: 1048576,
1311
+ itemMaxSize: 210000,
1312
+ defaultTTL: 259200000,
1313
+ defaultPriority: 5,
1314
+ warningThreshold: 0.8,
1315
+ // the storage helper will check if localStorage exists,
1316
+ // if not, will use a in-memory object instead
1317
+ storage: new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["StorageHelper"]().getStorage()
1318
+ };
1319
+ /**
1320
+ * return the byte size of the string
1321
+ * @param str
1322
+ */
1323
+ function getByteLength(str) {
1324
+ var ret = 0;
1325
+ ret = str.length;
1326
+ for (var i = str.length; i >= 0; i -= 1) {
1327
+ var charCode = str.charCodeAt(i);
1328
+ if (charCode > 0x7f && charCode <= 0x7ff) {
1329
+ ret += 1;
1330
+ } else if (charCode > 0x7ff && charCode <= 0xffff) {
1331
+ ret += 2;
1332
+ }
1333
+ // trail surrogate
1334
+ if (charCode >= 0xdc00 && charCode <= 0xdfff) {
1335
+ i -= 1;
1336
+ }
1337
+ }
1338
+ return ret;
1339
+ }
1340
+ /**
1341
+ * get current time
1342
+ */
1343
+ function getCurrTime() {
1344
+ var currTime = new Date();
1345
+ return currTime.getTime();
1346
+ }
1347
+ /**
1348
+ * check if passed value is an integer
1349
+ */
1350
+ function isInteger(value) {
1351
+ if (Number.isInteger) {
1352
+ return Number.isInteger(value);
1353
+ }
1354
+ return _isInteger(value);
1355
+ }
1356
+ function _isInteger(value) {
1357
+ return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
1358
+ }
1359
+ /**
1360
+ * provide an object as the in-memory cache
1361
+ */
1362
+ var store = {};
1363
+ var CacheObject = /** @class */function () {
1364
+ function CacheObject() {}
1365
+ CacheObject.clear = function () {
1366
+ store = {};
1367
+ };
1368
+ CacheObject.getItem = function (key) {
1369
+ return store[key] || null;
1370
+ };
1371
+ CacheObject.setItem = function (key, value) {
1372
+ store[key] = value;
1373
+ };
1374
+ CacheObject.removeItem = function (key) {
1375
+ delete store[key];
1376
+ };
1377
+ return CacheObject;
1378
+ }();
1379
+
1380
+
1381
+ /***/ }),
1382
+
1383
+ /***/ "./lib-esm/Utils/index.js":
1384
+ /*!********************************!*\
1385
+ !*** ./lib-esm/Utils/index.js ***!
1386
+ \********************************/
1387
+ /*! exports provided: defaultConfig, getByteLength, getCurrTime, isInteger, CacheObject, CacheList */
1388
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1389
+
1390
+ "use strict";
1391
+ __webpack_require__.r(__webpack_exports__);
1392
+ /* harmony import */ var _CacheUtils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./CacheUtils */ "./lib-esm/Utils/CacheUtils.js");
1393
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "defaultConfig", function() { return _CacheUtils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"]; });
1394
+
1395
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getByteLength", function() { return _CacheUtils__WEBPACK_IMPORTED_MODULE_0__["getByteLength"]; });
1396
+
1397
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getCurrTime", function() { return _CacheUtils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"]; });
1398
+
1399
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "isInteger", function() { return _CacheUtils__WEBPACK_IMPORTED_MODULE_0__["isInteger"]; });
1400
+
1401
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CacheObject", function() { return _CacheUtils__WEBPACK_IMPORTED_MODULE_0__["CacheObject"]; });
1402
+
1403
+ /* harmony import */ var _CacheList__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CacheList */ "./lib-esm/Utils/CacheList.js");
1404
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CacheList", function() { return _CacheList__WEBPACK_IMPORTED_MODULE_1__["default"]; });
1405
+
1406
+ /*
1407
+ * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1408
+ *
1409
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
1410
+ * the License. A copy of the License is located at
1411
+ *
1412
+ * http://aws.amazon.com/apache2.0/
1413
+ *
1414
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
1415
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1416
+ * and limitations under the License.
1417
+ */
1418
+
1419
+
1420
+
1421
+ /***/ }),
1422
+
1423
+ /***/ "./lib-esm/index.js":
1424
+ /*!**************************!*\
1425
+ !*** ./lib-esm/index.js ***!
1426
+ \**************************/
1427
+ /*! exports provided: BrowserStorageCache, InMemoryCache, Cache, default */
1428
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
1429
+
1430
+ "use strict";
1431
+ __webpack_require__.r(__webpack_exports__);
1432
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
1433
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__);
1434
+ /* harmony import */ var _BrowserStorageCache__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BrowserStorageCache */ "./lib-esm/BrowserStorageCache.js");
1435
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BrowserStorageCache", function() { return _BrowserStorageCache__WEBPACK_IMPORTED_MODULE_1__["BrowserStorageCache"]; });
1436
+
1437
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Cache", function() { return _BrowserStorageCache__WEBPACK_IMPORTED_MODULE_1__["BrowserStorageCache"]; });
1438
+
1439
+ /* harmony import */ var _InMemoryCache__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./InMemoryCache */ "./lib-esm/InMemoryCache.js");
1440
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InMemoryCache", function() { return _InMemoryCache__WEBPACK_IMPORTED_MODULE_2__["InMemoryCache"]; });
1441
+
1442
+ /*
1443
+ * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1444
+ *
1445
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
1446
+ * the License. A copy of the License is located at
1447
+ *
1448
+ * http://aws.amazon.com/apache2.0/
1449
+ *
1450
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
1451
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1452
+ * and limitations under the License.
1453
+ */
1454
+
1455
+
1456
+
1457
+
1458
+
1459
+ /**
1460
+ * @deprecated use named import
1461
+ */
1462
+ /* harmony default export */ __webpack_exports__["default"] = (_BrowserStorageCache__WEBPACK_IMPORTED_MODULE_1__["BrowserStorageCache"]);
1463
+ _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Amplify"].register(_BrowserStorageCache__WEBPACK_IMPORTED_MODULE_1__["BrowserStorageCache"]);
1464
+
1465
+ /***/ }),
1466
+
1467
+ /***/ "@aws-amplify/core":
1468
+ /*!***********************************!*\
1469
+ !*** external "aws_amplify_core" ***!
1470
+ \***********************************/
1471
+ /*! no static exports found */
1472
+ /***/ (function(module, exports) {
1473
+
1474
+ module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_core__;
1475
+
1476
+ /***/ })
1477
+
1478
+ /******/ });
1479
+ });
1480
+ //# sourceMappingURL=aws-amplify-cache.js.map