@aws-amplify/cache 4.0.51-next.20 → 4.0.51-next.32

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 (52) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/lib/.tsbuildinfo +3 -0
  3. package/lib/BrowserStorageCache.js +0 -4
  4. package/lib/BrowserStorageCache.js.map +1 -1
  5. package/lib/InMemoryCache.js +0 -4
  6. package/lib/InMemoryCache.js.map +1 -1
  7. package/lib/StorageCache.js +0 -4
  8. package/lib/StorageCache.js.map +1 -1
  9. package/lib/index.js +0 -4
  10. package/lib/index.js.map +1 -1
  11. package/lib/reactnative.js +0 -4
  12. package/lib/reactnative.js.map +1 -1
  13. package/lib-esm/.tsbuildinfo +3 -0
  14. package/lib-esm/BrowserStorageCache.d.ts +0 -4
  15. package/lib-esm/BrowserStorageCache.js +0 -4
  16. package/lib-esm/BrowserStorageCache.js.map +1 -1
  17. package/lib-esm/InMemoryCache.d.ts +0 -4
  18. package/lib-esm/InMemoryCache.js +0 -4
  19. package/lib-esm/InMemoryCache.js.map +1 -1
  20. package/lib-esm/StorageCache.d.ts +0 -4
  21. package/lib-esm/StorageCache.js +0 -4
  22. package/lib-esm/StorageCache.js.map +1 -1
  23. package/lib-esm/index.d.ts +0 -4
  24. package/lib-esm/index.js +0 -4
  25. package/lib-esm/index.js.map +1 -1
  26. package/lib-esm/reactnative.d.ts +0 -4
  27. package/lib-esm/reactnative.js +0 -4
  28. package/lib-esm/reactnative.js.map +1 -1
  29. package/package.json +8 -3
  30. package/src/BrowserStorageCache.ts +0 -5
  31. package/src/InMemoryCache.ts +0 -4
  32. package/src/StorageCache.ts +0 -5
  33. package/src/index.ts +0 -4
  34. package/src/reactnative.ts +0 -4
  35. package/build.js +0 -5
  36. package/dist/aws-amplify-cache.js +0 -1699
  37. package/dist/aws-amplify-cache.js.map +0 -1
  38. package/dist/aws-amplify-cache.min.js +0 -2
  39. package/dist/aws-amplify-cache.min.js.map +0 -1
  40. package/index.js +0 -7
  41. package/lib/AsyncStorageCache.d.ts +0 -155
  42. package/lib/BrowserStorageCache.d.ts +0 -169
  43. package/lib/InMemoryCache.d.ts +0 -135
  44. package/lib/StorageCache.d.ts +0 -35
  45. package/lib/Utils/CacheList.d.ts +0 -89
  46. package/lib/Utils/CacheUtils.d.ts +0 -24
  47. package/lib/Utils/index.d.ts +0 -2
  48. package/lib/index.d.ts +0 -8
  49. package/lib/reactnative.d.ts +0 -6
  50. package/lib/types/Cache.d.ts +0 -55
  51. package/lib/types/index.d.ts +0 -1
  52. package/webpack.config.dev.js +0 -6
@@ -1,1699 +0,0 @@
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
- /***/ "../../node_modules/tslib/tslib.es6.js":
100
- /*!********************************************************!*\
101
- !*** /root/amplify-js/node_modules/tslib/tslib.es6.js ***!
102
- \********************************************************/
103
- /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __createBinding, __exportStar, __values, __read, __spread, __spreadArrays, __spreadArray, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet, __classPrivateFieldIn */
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__, "__extends", function() { return __extends; });
109
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
110
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
111
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
112
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
113
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
114
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
115
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
116
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__createBinding", function() { return __createBinding; });
117
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
118
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
119
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
120
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
121
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
122
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArray", function() { return __spreadArray; });
123
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
124
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
125
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
126
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
127
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
128
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
129
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
130
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldGet", function() { return __classPrivateFieldGet; });
131
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldSet", function() { return __classPrivateFieldSet; });
132
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldIn", function() { return __classPrivateFieldIn; });
133
- /******************************************************************************
134
- Copyright (c) Microsoft Corporation.
135
-
136
- Permission to use, copy, modify, and/or distribute this software for any
137
- purpose with or without fee is hereby granted.
138
-
139
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
140
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
141
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
142
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
143
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
144
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
145
- PERFORMANCE OF THIS SOFTWARE.
146
- ***************************************************************************** */
147
- /* global Reflect, Promise */
148
-
149
- var extendStatics = function(d, b) {
150
- extendStatics = Object.setPrototypeOf ||
151
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
152
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
153
- return extendStatics(d, b);
154
- };
155
-
156
- function __extends(d, b) {
157
- if (typeof b !== "function" && b !== null)
158
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
159
- extendStatics(d, b);
160
- function __() { this.constructor = d; }
161
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
162
- }
163
-
164
- var __assign = function() {
165
- __assign = Object.assign || function __assign(t) {
166
- for (var s, i = 1, n = arguments.length; i < n; i++) {
167
- s = arguments[i];
168
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
169
- }
170
- return t;
171
- }
172
- return __assign.apply(this, arguments);
173
- }
174
-
175
- function __rest(s, e) {
176
- var t = {};
177
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
178
- t[p] = s[p];
179
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
180
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
181
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
182
- t[p[i]] = s[p[i]];
183
- }
184
- return t;
185
- }
186
-
187
- function __decorate(decorators, target, key, desc) {
188
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
189
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
190
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
191
- return c > 3 && r && Object.defineProperty(target, key, r), r;
192
- }
193
-
194
- function __param(paramIndex, decorator) {
195
- return function (target, key) { decorator(target, key, paramIndex); }
196
- }
197
-
198
- function __metadata(metadataKey, metadataValue) {
199
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
200
- }
201
-
202
- function __awaiter(thisArg, _arguments, P, generator) {
203
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
204
- return new (P || (P = Promise))(function (resolve, reject) {
205
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
206
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
207
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
208
- step((generator = generator.apply(thisArg, _arguments || [])).next());
209
- });
210
- }
211
-
212
- function __generator(thisArg, body) {
213
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
214
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
215
- function verb(n) { return function (v) { return step([n, v]); }; }
216
- function step(op) {
217
- if (f) throw new TypeError("Generator is already executing.");
218
- while (_) try {
219
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
220
- if (y = 0, t) op = [op[0] & 2, t.value];
221
- switch (op[0]) {
222
- case 0: case 1: t = op; break;
223
- case 4: _.label++; return { value: op[1], done: false };
224
- case 5: _.label++; y = op[1]; op = [0]; continue;
225
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
226
- default:
227
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
228
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
229
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
230
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
231
- if (t[2]) _.ops.pop();
232
- _.trys.pop(); continue;
233
- }
234
- op = body.call(thisArg, _);
235
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
236
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
237
- }
238
- }
239
-
240
- var __createBinding = Object.create ? (function(o, m, k, k2) {
241
- if (k2 === undefined) k2 = k;
242
- var desc = Object.getOwnPropertyDescriptor(m, k);
243
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
244
- desc = { enumerable: true, get: function() { return m[k]; } };
245
- }
246
- Object.defineProperty(o, k2, desc);
247
- }) : (function(o, m, k, k2) {
248
- if (k2 === undefined) k2 = k;
249
- o[k2] = m[k];
250
- });
251
-
252
- function __exportStar(m, o) {
253
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
254
- }
255
-
256
- function __values(o) {
257
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
258
- if (m) return m.call(o);
259
- if (o && typeof o.length === "number") return {
260
- next: function () {
261
- if (o && i >= o.length) o = void 0;
262
- return { value: o && o[i++], done: !o };
263
- }
264
- };
265
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
266
- }
267
-
268
- function __read(o, n) {
269
- var m = typeof Symbol === "function" && o[Symbol.iterator];
270
- if (!m) return o;
271
- var i = m.call(o), r, ar = [], e;
272
- try {
273
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
274
- }
275
- catch (error) { e = { error: error }; }
276
- finally {
277
- try {
278
- if (r && !r.done && (m = i["return"])) m.call(i);
279
- }
280
- finally { if (e) throw e.error; }
281
- }
282
- return ar;
283
- }
284
-
285
- /** @deprecated */
286
- function __spread() {
287
- for (var ar = [], i = 0; i < arguments.length; i++)
288
- ar = ar.concat(__read(arguments[i]));
289
- return ar;
290
- }
291
-
292
- /** @deprecated */
293
- function __spreadArrays() {
294
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
295
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
296
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
297
- r[k] = a[j];
298
- return r;
299
- }
300
-
301
- function __spreadArray(to, from, pack) {
302
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
303
- if (ar || !(i in from)) {
304
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
305
- ar[i] = from[i];
306
- }
307
- }
308
- return to.concat(ar || Array.prototype.slice.call(from));
309
- }
310
-
311
- function __await(v) {
312
- return this instanceof __await ? (this.v = v, this) : new __await(v);
313
- }
314
-
315
- function __asyncGenerator(thisArg, _arguments, generator) {
316
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
317
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
318
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
319
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
320
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
321
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
322
- function fulfill(value) { resume("next", value); }
323
- function reject(value) { resume("throw", value); }
324
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
325
- }
326
-
327
- function __asyncDelegator(o) {
328
- var i, p;
329
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
330
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
331
- }
332
-
333
- function __asyncValues(o) {
334
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
335
- var m = o[Symbol.asyncIterator], i;
336
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
337
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
338
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
339
- }
340
-
341
- function __makeTemplateObject(cooked, raw) {
342
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
343
- return cooked;
344
- };
345
-
346
- var __setModuleDefault = Object.create ? (function(o, v) {
347
- Object.defineProperty(o, "default", { enumerable: true, value: v });
348
- }) : function(o, v) {
349
- o["default"] = v;
350
- };
351
-
352
- function __importStar(mod) {
353
- if (mod && mod.__esModule) return mod;
354
- var result = {};
355
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
356
- __setModuleDefault(result, mod);
357
- return result;
358
- }
359
-
360
- function __importDefault(mod) {
361
- return (mod && mod.__esModule) ? mod : { default: mod };
362
- }
363
-
364
- function __classPrivateFieldGet(receiver, state, kind, f) {
365
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
366
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
367
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
368
- }
369
-
370
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
371
- if (kind === "m") throw new TypeError("Private method is not writable");
372
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
373
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
374
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
375
- }
376
-
377
- function __classPrivateFieldIn(state, receiver) {
378
- if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
379
- return typeof state === "function" ? receiver === state : state.has(receiver);
380
- }
381
-
382
-
383
- /***/ }),
384
-
385
- /***/ "./lib-esm/BrowserStorageCache.js":
386
- /*!****************************************!*\
387
- !*** ./lib-esm/BrowserStorageCache.js ***!
388
- \****************************************/
389
- /*! exports provided: BrowserStorageCacheClass, BrowserStorageCache, default */
390
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
391
-
392
- "use strict";
393
- __webpack_require__.r(__webpack_exports__);
394
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BrowserStorageCacheClass", function() { return BrowserStorageCacheClass; });
395
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BrowserStorageCache", function() { return BrowserStorageCache; });
396
- /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
397
- /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils */ "./lib-esm/Utils/index.js");
398
- /* harmony import */ var _StorageCache__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./StorageCache */ "./lib-esm/StorageCache.js");
399
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
400
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__);
401
- /*
402
- * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
403
- *
404
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
405
- * the License. A copy of the License is located at
406
- *
407
- * http://aws.amazon.com/apache2.0/
408
- *
409
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
410
- * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
411
- * and limitations under the License.
412
- */
413
-
414
-
415
-
416
-
417
- var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__["ConsoleLogger"]('Cache');
418
- /**
419
- * Customized storage based on the SessionStorage or LocalStorage with LRU implemented
420
- */
421
- var BrowserStorageCacheClass = /** @class */function (_super) {
422
- Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BrowserStorageCacheClass, _super);
423
- /**
424
- * initialize the cache
425
- * @param config - the configuration of the cache
426
- */
427
- function BrowserStorageCacheClass(config) {
428
- var _this = this;
429
- var cacheConfig = config ? Object.assign({}, _Utils__WEBPACK_IMPORTED_MODULE_1__["defaultConfig"], config) : _Utils__WEBPACK_IMPORTED_MODULE_1__["defaultConfig"];
430
- _this = _super.call(this, cacheConfig) || this;
431
- _this.config.storage = cacheConfig.storage;
432
- _this.getItem = _this.getItem.bind(_this);
433
- _this.setItem = _this.setItem.bind(_this);
434
- _this.removeItem = _this.removeItem.bind(_this);
435
- return _this;
436
- }
437
- /**
438
- * decrease current size of the cache
439
- *
440
- * @private
441
- * @param amount - the amount of the cache size which needs to be decreased
442
- */
443
- BrowserStorageCacheClass.prototype._decreaseCurSizeInBytes = function (amount) {
444
- var curSize = this.getCacheCurSize();
445
- this.config.storage.setItem(this.cacheCurSizeKey, (curSize - amount).toString());
446
- };
447
- /**
448
- * increase current size of the cache
449
- *
450
- * @private
451
- * @param amount - the amount of the cache szie which need to be increased
452
- */
453
- BrowserStorageCacheClass.prototype._increaseCurSizeInBytes = function (amount) {
454
- var curSize = this.getCacheCurSize();
455
- this.config.storage.setItem(this.cacheCurSizeKey, (curSize + amount).toString());
456
- };
457
- /**
458
- * update the visited time if item has been visited
459
- *
460
- * @private
461
- * @param item - the item which need to be refreshed
462
- * @param prefixedKey - the key of the item
463
- *
464
- * @return the refreshed item
465
- */
466
- BrowserStorageCacheClass.prototype._refreshItem = function (item, prefixedKey) {
467
- item.visitedTime = Object(_Utils__WEBPACK_IMPORTED_MODULE_1__["getCurrTime"])();
468
- this.config.storage.setItem(prefixedKey, JSON.stringify(item));
469
- return item;
470
- };
471
- /**
472
- * check wether item is expired
473
- *
474
- * @private
475
- * @param key - the key of the item
476
- *
477
- * @return true if the item is expired.
478
- */
479
- BrowserStorageCacheClass.prototype._isExpired = function (key) {
480
- var text = this.config.storage.getItem(key);
481
- var item = JSON.parse(text);
482
- if (Object(_Utils__WEBPACK_IMPORTED_MODULE_1__["getCurrTime"])() >= item.expires) {
483
- return true;
484
- }
485
- return false;
486
- };
487
- /**
488
- * delete item from cache
489
- *
490
- * @private
491
- * @param prefixedKey - the key of the item
492
- * @param size - optional, the byte size of the item
493
- */
494
- BrowserStorageCacheClass.prototype._removeItem = function (prefixedKey, size) {
495
- var itemSize = size ? size : JSON.parse(this.config.storage.getItem(prefixedKey)).byteSize;
496
- this._decreaseCurSizeInBytes(itemSize);
497
- // remove the cache item
498
- this.config.storage.removeItem(prefixedKey);
499
- };
500
- /**
501
- * put item into cache
502
- *
503
- * @private
504
- * @param prefixedKey - the key of the item
505
- * @param itemData - the value of the item
506
- * @param itemSizeInBytes - the byte size of the item
507
- */
508
- BrowserStorageCacheClass.prototype._setItem = function (prefixedKey, item) {
509
- // update the cache size
510
- this._increaseCurSizeInBytes(item.byteSize);
511
- try {
512
- this.config.storage.setItem(prefixedKey, JSON.stringify(item));
513
- } catch (setItemErr) {
514
- // if failed, we need to rollback the cache size
515
- this._decreaseCurSizeInBytes(item.byteSize);
516
- logger.error("Failed to set item " + setItemErr);
517
- }
518
- };
519
- /**
520
- * total space needed when poping out items
521
- *
522
- * @private
523
- * @param itemSize
524
- *
525
- * @return total space needed
526
- */
527
- BrowserStorageCacheClass.prototype._sizeToPop = function (itemSize) {
528
- var spaceItemNeed = this.getCacheCurSize() + itemSize - this.config.capacityInBytes;
529
- var cacheThresholdSpace = (1 - this.config.warningThreshold) * this.config.capacityInBytes;
530
- return spaceItemNeed > cacheThresholdSpace ? spaceItemNeed : cacheThresholdSpace;
531
- };
532
- /**
533
- * see whether cache is full
534
- *
535
- * @private
536
- * @param itemSize
537
- *
538
- * @return true if cache is full
539
- */
540
- BrowserStorageCacheClass.prototype._isCacheFull = function (itemSize) {
541
- return itemSize + this.getCacheCurSize() > this.config.capacityInBytes;
542
- };
543
- /**
544
- * scan the storage and find out all the keys owned by this cache
545
- * also clean the expired keys while scanning
546
- *
547
- * @private
548
- *
549
- * @return array of keys
550
- */
551
- BrowserStorageCacheClass.prototype._findValidKeys = function () {
552
- var keys = [];
553
- var keyInCache = [];
554
- // get all keys in Storage
555
- for (var i = 0; i < this.config.storage.length; i += 1) {
556
- keyInCache.push(this.config.storage.key(i));
557
- }
558
- // find those items which belong to our cache and also clean those expired items
559
- for (var i = 0; i < keyInCache.length; i += 1) {
560
- var key = keyInCache[i];
561
- if (key.indexOf(this.config.keyPrefix) === 0 && key !== this.cacheCurSizeKey) {
562
- if (this._isExpired(key)) {
563
- this._removeItem(key);
564
- } else {
565
- keys.push(key);
566
- }
567
- }
568
- }
569
- return keys;
570
- };
571
- /**
572
- * get all the items we have, sort them by their priority,
573
- * if priority is same, sort them by their last visited time
574
- * pop out items from the low priority (5 is the lowest)
575
- *
576
- * @private
577
- * @param keys - all the keys in this cache
578
- * @param sizeToPop - the total size of the items which needed to be poped out
579
- */
580
- BrowserStorageCacheClass.prototype._popOutItems = function (keys, sizeToPop) {
581
- var items = [];
582
- var remainedSize = sizeToPop;
583
- // get the items from Storage
584
- for (var i = 0; i < keys.length; i += 1) {
585
- var val = this.config.storage.getItem(keys[i]);
586
- if (val != null) {
587
- var item = JSON.parse(val);
588
- items.push(item);
589
- }
590
- }
591
- // first compare priority
592
- // then compare visited time
593
- items.sort(function (a, b) {
594
- if (a.priority > b.priority) {
595
- return -1;
596
- } else if (a.priority < b.priority) {
597
- return 1;
598
- } else {
599
- if (a.visitedTime < b.visitedTime) {
600
- return -1;
601
- } else return 1;
602
- }
603
- });
604
- for (var i = 0; i < items.length; i += 1) {
605
- // pop out items until we have enough room for new item
606
- this._removeItem(items[i].key, items[i].byteSize);
607
- remainedSize -= items[i].byteSize;
608
- if (remainedSize <= 0) {
609
- return;
610
- }
611
- }
612
- };
613
- /**
614
- * Set item into cache. You can put number, string, boolean or object.
615
- * The cache will first check whether has the same key.
616
- * If it has, it will delete the old item and then put the new item in
617
- * The cache will pop out items if it is full
618
- * You can specify the cache item options. The cache will abort and output a warning:
619
- * If the key is invalid
620
- * If the size of the item exceeds itemMaxSize.
621
- * If the value is undefined
622
- * If incorrect cache item configuration
623
- * If error happened with browser storage
624
- *
625
- * @param key - the key of the item
626
- * @param value - the value of the item
627
- * @param {Object} [options] - optional, the specified meta-data
628
- */
629
- BrowserStorageCacheClass.prototype.setItem = function (key, value, options) {
630
- logger.log("Set item: key is " + key + ", value is " + value + " with options: " + options);
631
- var prefixedKey = this.config.keyPrefix + key;
632
- // invalid keys
633
- if (prefixedKey === this.config.keyPrefix || prefixedKey === this.cacheCurSizeKey) {
634
- logger.warn("Invalid key: should not be empty or 'CurSize'");
635
- return;
636
- }
637
- if (typeof value === 'undefined') {
638
- logger.warn("The value of item should not be undefined!");
639
- return;
640
- }
641
- var cacheItemOptions = {
642
- priority: options && options.priority !== undefined ? options.priority : this.config.defaultPriority,
643
- expires: options && options.expires !== undefined ? options.expires : this.config.defaultTTL + Object(_Utils__WEBPACK_IMPORTED_MODULE_1__["getCurrTime"])()
644
- };
645
- if (cacheItemOptions.priority < 1 || cacheItemOptions.priority > 5) {
646
- logger.warn("Invalid parameter: priority due to out or range. It should be within 1 and 5.");
647
- return;
648
- }
649
- var item = this.fillCacheItem(prefixedKey, value, cacheItemOptions);
650
- // check wether this item is too big;
651
- if (item.byteSize > this.config.itemMaxSize) {
652
- logger.warn("Item with key: " + key + " you are trying to put into is too big!");
653
- return;
654
- }
655
- try {
656
- // first look into the storage, if it exists, delete it.
657
- var val = this.config.storage.getItem(prefixedKey);
658
- if (val) {
659
- this._removeItem(prefixedKey, JSON.parse(val).byteSize);
660
- }
661
- // check whether the cache is full
662
- if (this._isCacheFull(item.byteSize)) {
663
- var validKeys = this._findValidKeys();
664
- // check again and then pop out items
665
- if (this._isCacheFull(item.byteSize)) {
666
- var sizeToPop = this._sizeToPop(item.byteSize);
667
- this._popOutItems(validKeys, sizeToPop);
668
- }
669
- }
670
- // put item in the cache
671
- // may failed due to storage full
672
- this._setItem(prefixedKey, item);
673
- } catch (e) {
674
- logger.warn("setItem failed! " + e);
675
- }
676
- };
677
- /**
678
- * Get item from cache. It will return null if item doesn’t exist or it has been expired.
679
- * If you specified callback function in the options,
680
- * then the function will be executed if no such item in the cache
681
- * and finally put the return value into cache.
682
- * Please make sure the callback function will return the value you want to put into the cache.
683
- * The cache will abort output a warning:
684
- * If the key is invalid
685
- * If error happened with browser storage
686
- *
687
- * @param key - the key of the item
688
- * @param {Object} [options] - the options of callback function
689
- *
690
- * @return - return the value of the item
691
- */
692
- BrowserStorageCacheClass.prototype.getItem = function (key, options) {
693
- logger.log("Get item: key is " + key + " with options " + options);
694
- var ret = null;
695
- var prefixedKey = this.config.keyPrefix + key;
696
- if (prefixedKey === this.config.keyPrefix || prefixedKey === this.cacheCurSizeKey) {
697
- logger.warn("Invalid key: should not be empty or 'CurSize'");
698
- return null;
699
- }
700
- try {
701
- ret = this.config.storage.getItem(prefixedKey);
702
- if (ret != null) {
703
- if (this._isExpired(prefixedKey)) {
704
- // if expired, remove that item and return null
705
- this._removeItem(prefixedKey, JSON.parse(ret).byteSize);
706
- ret = null;
707
- } else {
708
- // if not expired, great, return the value and refresh it
709
- var item = JSON.parse(ret);
710
- item = this._refreshItem(item, prefixedKey);
711
- return item.data;
712
- }
713
- }
714
- if (options && options.callback !== undefined) {
715
- var val = options.callback();
716
- if (val !== null) {
717
- this.setItem(key, val, options);
718
- }
719
- return val;
720
- }
721
- return null;
722
- } catch (e) {
723
- logger.warn("getItem failed! " + e);
724
- return null;
725
- }
726
- };
727
- /**
728
- * remove item from the cache
729
- * The cache will abort output a warning:
730
- * If error happened with browser storage
731
- * @param key - the key of the item
732
- */
733
- BrowserStorageCacheClass.prototype.removeItem = function (key) {
734
- logger.log("Remove item: key is " + key);
735
- var prefixedKey = this.config.keyPrefix + key;
736
- if (prefixedKey === this.config.keyPrefix || prefixedKey === this.cacheCurSizeKey) {
737
- return;
738
- }
739
- try {
740
- var val = this.config.storage.getItem(prefixedKey);
741
- if (val) {
742
- this._removeItem(prefixedKey, JSON.parse(val).byteSize);
743
- }
744
- } catch (e) {
745
- logger.warn("removeItem failed! " + e);
746
- }
747
- };
748
- /**
749
- * clear the entire cache
750
- * The cache will abort output a warning:
751
- * If error happened with browser storage
752
- */
753
- BrowserStorageCacheClass.prototype.clear = function () {
754
- logger.log("Clear Cache");
755
- var keysToRemove = [];
756
- for (var i = 0; i < this.config.storage.length; i += 1) {
757
- var key = this.config.storage.key(i);
758
- if (key.indexOf(this.config.keyPrefix) === 0) {
759
- keysToRemove.push(key);
760
- }
761
- }
762
- try {
763
- for (var i = 0; i < keysToRemove.length; i += 1) {
764
- this.config.storage.removeItem(keysToRemove[i]);
765
- }
766
- } catch (e) {
767
- logger.warn("clear failed! " + e);
768
- }
769
- };
770
- /**
771
- * Return all the keys in the cache.
772
- *
773
- * @return - all keys in the cache
774
- */
775
- BrowserStorageCacheClass.prototype.getAllKeys = function () {
776
- var keys = [];
777
- for (var i = 0; i < this.config.storage.length; i += 1) {
778
- var key = this.config.storage.key(i);
779
- if (key.indexOf(this.config.keyPrefix) === 0 && key !== this.cacheCurSizeKey) {
780
- keys.push(key.substring(this.config.keyPrefix.length));
781
- }
782
- }
783
- return keys;
784
- };
785
- /**
786
- * return the current size of the cache
787
- *
788
- * @return - current size of the cache
789
- */
790
- BrowserStorageCacheClass.prototype.getCacheCurSize = function () {
791
- var ret = this.config.storage.getItem(this.cacheCurSizeKey);
792
- if (!ret) {
793
- this.config.storage.setItem(this.cacheCurSizeKey, '0');
794
- ret = '0';
795
- }
796
- return Number(ret);
797
- };
798
- /**
799
- * Return a new instance of cache with customized configuration.
800
- * @param config - the customized configuration
801
- *
802
- * @return - new instance of Cache
803
- */
804
- BrowserStorageCacheClass.prototype.createInstance = function (config) {
805
- if (!config.keyPrefix || config.keyPrefix === _Utils__WEBPACK_IMPORTED_MODULE_1__["defaultConfig"].keyPrefix) {
806
- logger.error('invalid keyPrefix, setting keyPrefix with timeStamp');
807
- config.keyPrefix = _Utils__WEBPACK_IMPORTED_MODULE_1__["getCurrTime"].toString();
808
- }
809
- return new BrowserStorageCacheClass(config);
810
- };
811
- return BrowserStorageCacheClass;
812
- }(_StorageCache__WEBPACK_IMPORTED_MODULE_2__["StorageCache"]);
813
-
814
- var BrowserStorageCache = new BrowserStorageCacheClass();
815
- /**
816
- * @deprecated use named import
817
- */
818
- /* harmony default export */ __webpack_exports__["default"] = (BrowserStorageCache);
819
-
820
- /***/ }),
821
-
822
- /***/ "./lib-esm/InMemoryCache.js":
823
- /*!**********************************!*\
824
- !*** ./lib-esm/InMemoryCache.js ***!
825
- \**********************************/
826
- /*! exports provided: InMemoryCacheClass, InMemoryCache, default */
827
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
828
-
829
- "use strict";
830
- __webpack_require__.r(__webpack_exports__);
831
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InMemoryCacheClass", function() { return InMemoryCacheClass; });
832
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InMemoryCache", function() { return InMemoryCache; });
833
- /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
834
- /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils */ "./lib-esm/Utils/index.js");
835
- /* harmony import */ var _StorageCache__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./StorageCache */ "./lib-esm/StorageCache.js");
836
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
837
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__);
838
- /*
839
- * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
840
- *
841
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
842
- * the License. A copy of the License is located at
843
- *
844
- * http://aws.amazon.com/apache2.0/
845
- *
846
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
847
- * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
848
- * and limitations under the License.
849
- */
850
-
851
-
852
-
853
-
854
- var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__["ConsoleLogger"]('InMemoryCache');
855
- /**
856
- * Customized in-memory cache with LRU implemented
857
- * @member cacheObj - object which store items
858
- * @member cacheList - list of keys in the cache with LRU
859
- * @member curSizeInBytes - current size of the cache
860
- * @member maxPriority - max of the priority
861
- * @member cacheSizeLimit - the limit of cache size
862
- */
863
- var InMemoryCacheClass = /** @class */function (_super) {
864
- Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InMemoryCacheClass, _super);
865
- /**
866
- * initialize the cache
867
- *
868
- * @param config - the configuration of the cache
869
- */
870
- function InMemoryCacheClass(config) {
871
- var _this = this;
872
- var cacheConfig = config ? Object.assign({}, _Utils__WEBPACK_IMPORTED_MODULE_1__["defaultConfig"], config) : _Utils__WEBPACK_IMPORTED_MODULE_1__["defaultConfig"];
873
- _this = _super.call(this, cacheConfig) || this;
874
- logger.debug('now we start!');
875
- _this.cacheList = [];
876
- _this.curSizeInBytes = 0;
877
- _this.maxPriority = 5;
878
- _this.getItem = _this.getItem.bind(_this);
879
- _this.setItem = _this.setItem.bind(_this);
880
- _this.removeItem = _this.removeItem.bind(_this);
881
- // initialize list for every priority
882
- for (var i = 0; i < _this.maxPriority; i += 1) {
883
- _this.cacheList[i] = new _Utils__WEBPACK_IMPORTED_MODULE_1__["CacheList"]();
884
- }
885
- return _this;
886
- }
887
- /**
888
- * decrease current size of the cache
889
- *
890
- * @param amount - the amount of the cache size which needs to be decreased
891
- */
892
- InMemoryCacheClass.prototype._decreaseCurSizeInBytes = function (amount) {
893
- this.curSizeInBytes -= amount;
894
- };
895
- /**
896
- * increase current size of the cache
897
- *
898
- * @param amount - the amount of the cache szie which need to be increased
899
- */
900
- InMemoryCacheClass.prototype._increaseCurSizeInBytes = function (amount) {
901
- this.curSizeInBytes += amount;
902
- };
903
- /**
904
- * check whether item is expired
905
- *
906
- * @param key - the key of the item
907
- *
908
- * @return true if the item is expired.
909
- */
910
- InMemoryCacheClass.prototype._isExpired = function (key) {
911
- var text = _Utils__WEBPACK_IMPORTED_MODULE_1__["CacheObject"].getItem(key);
912
- var item = JSON.parse(text);
913
- if (Object(_Utils__WEBPACK_IMPORTED_MODULE_1__["getCurrTime"])() >= item.expires) {
914
- return true;
915
- }
916
- return false;
917
- };
918
- /**
919
- * delete item from cache
920
- *
921
- * @param prefixedKey - the key of the item
922
- * @param listIdx - indicates which cache list the key belongs to
923
- */
924
- InMemoryCacheClass.prototype._removeItem = function (prefixedKey, listIdx) {
925
- // delete the key from the list
926
- this.cacheList[listIdx].removeItem(prefixedKey);
927
- // decrease the current size of the cache
928
- this._decreaseCurSizeInBytes(JSON.parse(_Utils__WEBPACK_IMPORTED_MODULE_1__["CacheObject"].getItem(prefixedKey)).byteSize);
929
- // finally remove the item from memory
930
- _Utils__WEBPACK_IMPORTED_MODULE_1__["CacheObject"].removeItem(prefixedKey);
931
- };
932
- /**
933
- * put item into cache
934
- *
935
- * @param prefixedKey - the key of the item
936
- * @param itemData - the value of the item
937
- * @param itemSizeInBytes - the byte size of the item
938
- * @param listIdx - indicates which cache list the key belongs to
939
- */
940
- InMemoryCacheClass.prototype._setItem = function (prefixedKey, item, listIdx) {
941
- // insert the key into the list
942
- this.cacheList[listIdx].insertItem(prefixedKey);
943
- // increase the current size of the cache
944
- this._increaseCurSizeInBytes(item.byteSize);
945
- // finally add the item into memory
946
- _Utils__WEBPACK_IMPORTED_MODULE_1__["CacheObject"].setItem(prefixedKey, JSON.stringify(item));
947
- };
948
- /**
949
- * see whether cache is full
950
- *
951
- * @param itemSize
952
- *
953
- * @return true if cache is full
954
- */
955
- InMemoryCacheClass.prototype._isCacheFull = function (itemSize) {
956
- return this.curSizeInBytes + itemSize > this.config.capacityInBytes;
957
- };
958
- /**
959
- * check whether the cache contains the key
960
- *
961
- * @param key
962
- */
963
- InMemoryCacheClass.prototype.containsKey = function (key) {
964
- var prefixedKey = this.config.keyPrefix + key;
965
- for (var i = 0; i < this.maxPriority; i += 1) {
966
- if (this.cacheList[i].containsKey(prefixedKey)) {
967
- return i + 1;
968
- }
969
- }
970
- return -1;
971
- };
972
- /**
973
- * * Set item into cache. You can put number, string, boolean or object.
974
- * The cache will first check whether has the same key.
975
- * If it has, it will delete the old item and then put the new item in
976
- * The cache will pop out items if it is full
977
- * You can specify the cache item options. The cache will abort and output a warning:
978
- * If the key is invalid
979
- * If the size of the item exceeds itemMaxSize.
980
- * If the value is undefined
981
- * If incorrect cache item configuration
982
- * If error happened with browser storage
983
- *
984
- * @param key - the key of the item
985
- * @param value - the value of the item
986
- * @param options - optional, the specified meta-data
987
- *
988
- * @throws if the item is too big which exceeds the limit of single item size
989
- * @throws if the key is invalid
990
- */
991
- InMemoryCacheClass.prototype.setItem = function (key, value, options) {
992
- var prefixedKey = this.config.keyPrefix + key;
993
- // invalid keys
994
- if (prefixedKey === this.config.keyPrefix || prefixedKey === this.cacheCurSizeKey) {
995
- logger.warn("Invalid key: should not be empty or 'CurSize'");
996
- return;
997
- }
998
- if (typeof value === 'undefined') {
999
- logger.warn("The value of item should not be undefined!");
1000
- return;
1001
- }
1002
- var cacheItemOptions = {
1003
- priority: options && options.priority !== undefined ? options.priority : this.config.defaultPriority,
1004
- expires: options && options.expires !== undefined ? options.expires : this.config.defaultTTL + Object(_Utils__WEBPACK_IMPORTED_MODULE_1__["getCurrTime"])()
1005
- };
1006
- if (cacheItemOptions.priority < 1 || cacheItemOptions.priority > 5) {
1007
- logger.warn("Invalid parameter: priority due to out or range. It should be within 1 and 5.");
1008
- return;
1009
- }
1010
- var item = this.fillCacheItem(prefixedKey, value, cacheItemOptions);
1011
- // check wether this item is too big;
1012
- if (item.byteSize > this.config.itemMaxSize) {
1013
- logger.warn("Item with key: " + key + " you are trying to put into is too big!");
1014
- return;
1015
- }
1016
- // if key already in the cache, then delete it.
1017
- var presentKeyPrio = this.containsKey(key);
1018
- if (presentKeyPrio !== -1) {
1019
- this._removeItem(prefixedKey, presentKeyPrio - 1);
1020
- }
1021
- // pop out items in the cache when cache is full based on LRU
1022
- // first start from lowest priority cache list
1023
- var cacheListIdx = this.maxPriority - 1;
1024
- while (this._isCacheFull(item.byteSize) && cacheListIdx >= 0) {
1025
- if (!this.cacheList[cacheListIdx].isEmpty()) {
1026
- var popedItemKey = this.cacheList[cacheListIdx].getLastItem();
1027
- this._removeItem(popedItemKey, cacheListIdx);
1028
- } else {
1029
- cacheListIdx -= 1;
1030
- }
1031
- }
1032
- this._setItem(prefixedKey, item, Number(item.priority) - 1);
1033
- };
1034
- /**
1035
- * Get item from cache. It will return null if item doesn’t exist or it has been expired.
1036
- * If you specified callback function in the options,
1037
- * then the function will be executed if no such item in the cache
1038
- * and finally put the return value into cache.
1039
- * Please make sure the callback function will return the value you want to put into the cache.
1040
- * The cache will abort output a warning:
1041
- * If the key is invalid
1042
- *
1043
- * @param key - the key of the item
1044
- * @param options - the options of callback function
1045
- */
1046
- InMemoryCacheClass.prototype.getItem = function (key, options) {
1047
- var ret = null;
1048
- var prefixedKey = this.config.keyPrefix + key;
1049
- if (prefixedKey === this.config.keyPrefix || prefixedKey === this.cacheCurSizeKey) {
1050
- logger.warn("Invalid key: should not be empty or 'CurSize'");
1051
- return null;
1052
- }
1053
- // check whether it's in the cachelist
1054
- var presentKeyPrio = this.containsKey(key);
1055
- if (presentKeyPrio !== -1) {
1056
- if (this._isExpired(prefixedKey)) {
1057
- // if expired, remove that item and return null
1058
- this._removeItem(prefixedKey, presentKeyPrio - 1);
1059
- } else {
1060
- // if not expired, great, return the value and refresh it
1061
- ret = _Utils__WEBPACK_IMPORTED_MODULE_1__["CacheObject"].getItem(prefixedKey);
1062
- var item = JSON.parse(ret);
1063
- this.cacheList[item.priority - 1].refresh(prefixedKey);
1064
- return item.data;
1065
- }
1066
- }
1067
- if (options && options.callback !== undefined) {
1068
- var val = options.callback();
1069
- if (val !== null) {
1070
- this.setItem(key, val, options);
1071
- }
1072
- return val;
1073
- }
1074
- return null;
1075
- };
1076
- /**
1077
- * remove item from the cache
1078
- *
1079
- * @param key - the key of the item
1080
- */
1081
- InMemoryCacheClass.prototype.removeItem = function (key) {
1082
- var prefixedKey = this.config.keyPrefix + key;
1083
- // check if the key is in the cache
1084
- var presentKeyPrio = this.containsKey(key);
1085
- if (presentKeyPrio !== -1) {
1086
- this._removeItem(prefixedKey, presentKeyPrio - 1);
1087
- }
1088
- };
1089
- /**
1090
- * clear the entire cache
1091
- */
1092
- InMemoryCacheClass.prototype.clear = function () {
1093
- var e_1, _a;
1094
- for (var i = 0; i < this.maxPriority; i += 1) {
1095
- try {
1096
- for (var _b = (e_1 = void 0, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__values"])(this.cacheList[i].getKeys())), _c = _b.next(); !_c.done; _c = _b.next()) {
1097
- var key = _c.value;
1098
- this._removeItem(key, i);
1099
- }
1100
- } catch (e_1_1) {
1101
- e_1 = {
1102
- error: e_1_1
1103
- };
1104
- } finally {
1105
- try {
1106
- if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
1107
- } finally {
1108
- if (e_1) throw e_1.error;
1109
- }
1110
- }
1111
- }
1112
- };
1113
- /**
1114
- * Return all the keys in the cache.
1115
- */
1116
- InMemoryCacheClass.prototype.getAllKeys = function () {
1117
- var e_2, _a;
1118
- var keys = [];
1119
- for (var i = 0; i < this.maxPriority; i += 1) {
1120
- try {
1121
- for (var _b = (e_2 = void 0, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__values"])(this.cacheList[i].getKeys())), _c = _b.next(); !_c.done; _c = _b.next()) {
1122
- var key = _c.value;
1123
- keys.push(key.substring(this.config.keyPrefix.length));
1124
- }
1125
- } catch (e_2_1) {
1126
- e_2 = {
1127
- error: e_2_1
1128
- };
1129
- } finally {
1130
- try {
1131
- if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
1132
- } finally {
1133
- if (e_2) throw e_2.error;
1134
- }
1135
- }
1136
- }
1137
- return keys;
1138
- };
1139
- /**
1140
- * return the current size of the cache
1141
- *
1142
- * @return the current size of the cache
1143
- */
1144
- InMemoryCacheClass.prototype.getCacheCurSize = function () {
1145
- return this.curSizeInBytes;
1146
- };
1147
- /**
1148
- * Return a new instance of cache with customized configuration.
1149
- * @param config - the customized configuration
1150
- */
1151
- InMemoryCacheClass.prototype.createInstance = function (config) {
1152
- return new InMemoryCacheClass(config);
1153
- };
1154
- return InMemoryCacheClass;
1155
- }(_StorageCache__WEBPACK_IMPORTED_MODULE_2__["StorageCache"]);
1156
-
1157
- var InMemoryCache = new InMemoryCacheClass();
1158
- /**
1159
- * @deprecated use named import
1160
- */
1161
- /* harmony default export */ __webpack_exports__["default"] = (InMemoryCache);
1162
-
1163
- /***/ }),
1164
-
1165
- /***/ "./lib-esm/StorageCache.js":
1166
- /*!*********************************!*\
1167
- !*** ./lib-esm/StorageCache.js ***!
1168
- \*********************************/
1169
- /*! exports provided: StorageCache, default */
1170
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
1171
-
1172
- "use strict";
1173
- __webpack_require__.r(__webpack_exports__);
1174
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StorageCache", function() { return StorageCache; });
1175
- /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Utils */ "./lib-esm/Utils/index.js");
1176
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
1177
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__);
1178
- function _typeof(obj) {
1179
- "@babel/helpers - typeof";
1180
-
1181
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
1182
- return typeof obj;
1183
- } : function (obj) {
1184
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1185
- }, _typeof(obj);
1186
- }
1187
- /*
1188
- * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1189
- *
1190
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
1191
- * the License. A copy of the License is located at
1192
- *
1193
- * http://aws.amazon.com/apache2.0/
1194
- *
1195
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
1196
- * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1197
- * and limitations under the License.
1198
- */
1199
-
1200
-
1201
- var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('StorageCache');
1202
- /**
1203
- * Initialization of the cache
1204
- *
1205
- */
1206
- var StorageCache = /** @class */function () {
1207
- /**
1208
- * Initialize the cache
1209
- * @param config - the configuration of the cache
1210
- */
1211
- function StorageCache(config) {
1212
- this.config = Object.assign({}, config);
1213
- this.cacheCurSizeKey = this.config.keyPrefix + 'CurSize';
1214
- this.checkConfig();
1215
- }
1216
- StorageCache.prototype.getModuleName = function () {
1217
- return 'Cache';
1218
- };
1219
- StorageCache.prototype.checkConfig = function () {
1220
- // check configuration
1221
- if (!Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["isInteger"])(this.config.capacityInBytes)) {
1222
- logger.error('Invalid parameter: capacityInBytes. It should be an Integer. Setting back to default.');
1223
- this.config.capacityInBytes = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].capacityInBytes;
1224
- }
1225
- if (!Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["isInteger"])(this.config.itemMaxSize)) {
1226
- logger.error('Invalid parameter: itemMaxSize. It should be an Integer. Setting back to default.');
1227
- this.config.itemMaxSize = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].itemMaxSize;
1228
- }
1229
- if (!Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["isInteger"])(this.config.defaultTTL)) {
1230
- logger.error('Invalid parameter: defaultTTL. It should be an Integer. Setting back to default.');
1231
- this.config.defaultTTL = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].defaultTTL;
1232
- }
1233
- if (!Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["isInteger"])(this.config.defaultPriority)) {
1234
- logger.error('Invalid parameter: defaultPriority. It should be an Integer. Setting back to default.');
1235
- this.config.defaultPriority = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].defaultPriority;
1236
- }
1237
- if (this.config.itemMaxSize > this.config.capacityInBytes) {
1238
- logger.error('Invalid parameter: itemMaxSize. It should be smaller than capacityInBytes. Setting back to default.');
1239
- this.config.itemMaxSize = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].itemMaxSize;
1240
- }
1241
- if (this.config.defaultPriority > 5 || this.config.defaultPriority < 1) {
1242
- logger.error('Invalid parameter: defaultPriority. It should be between 1 and 5. Setting back to default.');
1243
- this.config.defaultPriority = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].defaultPriority;
1244
- }
1245
- if (Number(this.config.warningThreshold) > 1 || Number(this.config.warningThreshold) < 0) {
1246
- logger.error('Invalid parameter: warningThreshold. It should be between 0 and 1. Setting back to default.');
1247
- this.config.warningThreshold = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].warningThreshold;
1248
- }
1249
- // set 5MB limit
1250
- var cacheLimit = 5 * 1024 * 1024;
1251
- if (this.config.capacityInBytes > cacheLimit) {
1252
- logger.error('Cache Capacity should be less than 5MB. Setting back to default. Setting back to default.');
1253
- this.config.capacityInBytes = _Utils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"].capacityInBytes;
1254
- }
1255
- };
1256
- /**
1257
- * produce a JSON object with meta-data and data value
1258
- * @param value - the value of the item
1259
- * @param options - optional, the specified meta-data
1260
- *
1261
- * @return - the item which has the meta-data and the value
1262
- */
1263
- StorageCache.prototype.fillCacheItem = function (key, value, options) {
1264
- var ret = {
1265
- key: key,
1266
- data: value,
1267
- timestamp: Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"])(),
1268
- visitedTime: Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"])(),
1269
- priority: options.priority,
1270
- expires: options.expires,
1271
- type: _typeof(value),
1272
- byteSize: 0
1273
- };
1274
- ret.byteSize = Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getByteLength"])(JSON.stringify(ret));
1275
- // for accurate size
1276
- ret.byteSize = Object(_Utils__WEBPACK_IMPORTED_MODULE_0__["getByteLength"])(JSON.stringify(ret));
1277
- return ret;
1278
- };
1279
- /**
1280
- * set cache with customized configuration
1281
- * @param config - customized configuration
1282
- *
1283
- * @return - the current configuration
1284
- */
1285
- StorageCache.prototype.configure = function (config) {
1286
- if (!config) {
1287
- return this.config;
1288
- }
1289
- if (config.keyPrefix) {
1290
- logger.warn("Don't try to configure keyPrefix!");
1291
- }
1292
- this.config = Object.assign({}, this.config, config, config.Cache);
1293
- this.checkConfig();
1294
- return this.config;
1295
- };
1296
- return StorageCache;
1297
- }();
1298
-
1299
- /**
1300
- * @deprecated use named import
1301
- */
1302
- /* harmony default export */ __webpack_exports__["default"] = (StorageCache);
1303
-
1304
- /***/ }),
1305
-
1306
- /***/ "./lib-esm/Utils/CacheList.js":
1307
- /*!************************************!*\
1308
- !*** ./lib-esm/Utils/CacheList.js ***!
1309
- \************************************/
1310
- /*! exports provided: default */
1311
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
1312
-
1313
- "use strict";
1314
- __webpack_require__.r(__webpack_exports__);
1315
- /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
1316
- /*
1317
- * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1318
- *
1319
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
1320
- * the License. A copy of the License is located at
1321
- *
1322
- * http://aws.amazon.com/apache2.0/
1323
- *
1324
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
1325
- * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1326
- * and limitations under the License.
1327
- */
1328
-
1329
- var DoubleLinkedNode = /** @class */function () {
1330
- function DoubleLinkedNode(keyVal) {
1331
- this.key = keyVal ? keyVal : '';
1332
- this.prevNode = null;
1333
- this.nextNode = null;
1334
- }
1335
- return DoubleLinkedNode;
1336
- }();
1337
- /**
1338
- * double linked list plus a hash table inside
1339
- * each key in the cache stored as a node in the list
1340
- * recently visited node will be rotated to the head
1341
- * so the Last Recently Visited node will be at the tail
1342
- *
1343
- * @member head - dummy head of the linked list
1344
- * @member tail - dummy tail of the linked list
1345
- * @member hashtable - the hashtable which maps cache key to list node
1346
- * @member length - length of the list
1347
- */
1348
- var CacheList = /** @class */function () {
1349
- /**
1350
- * initialization
1351
- */
1352
- function CacheList() {
1353
- this.head = new DoubleLinkedNode();
1354
- this.tail = new DoubleLinkedNode();
1355
- this.hashtable = {};
1356
- this.length = 0;
1357
- this.head.nextNode = this.tail;
1358
- this.tail.prevNode = this.head;
1359
- }
1360
- /**
1361
- * insert node to the head of the list
1362
- *
1363
- * @param node
1364
- */
1365
- CacheList.prototype.insertNodeToHead = function (node) {
1366
- var tmp = this.head.nextNode;
1367
- this.head.nextNode = node;
1368
- node.nextNode = tmp;
1369
- node.prevNode = this.head;
1370
- tmp.prevNode = node;
1371
- this.length = this.length + 1;
1372
- };
1373
- /**
1374
- * remove node
1375
- *
1376
- * @param node
1377
- */
1378
- CacheList.prototype.removeNode = function (node) {
1379
- node.prevNode.nextNode = node.nextNode;
1380
- node.nextNode.prevNode = node.prevNode;
1381
- node.prevNode = null;
1382
- node.nextNode = null;
1383
- this.length = this.length - 1;
1384
- };
1385
- /**
1386
- * @return true if list is empty
1387
- */
1388
- CacheList.prototype.isEmpty = function () {
1389
- return this.length === 0;
1390
- };
1391
- /**
1392
- * refresh node so it is rotated to the head
1393
- *
1394
- * @param key - key of the node
1395
- */
1396
- CacheList.prototype.refresh = function (key) {
1397
- var node = this.hashtable[key];
1398
- this.removeNode(node);
1399
- this.insertNodeToHead(node);
1400
- };
1401
- /**
1402
- * insert new node to the head and add it in the hashtable
1403
- *
1404
- * @param key - the key of the node
1405
- */
1406
- CacheList.prototype.insertItem = function (key) {
1407
- var node = new DoubleLinkedNode(key);
1408
- this.hashtable[key] = node;
1409
- this.insertNodeToHead(node);
1410
- };
1411
- /**
1412
- * @return the LAST Recently Visited key
1413
- */
1414
- CacheList.prototype.getLastItem = function () {
1415
- return this.tail.prevNode.key;
1416
- };
1417
- /**
1418
- * remove the cache key from the list and hashtable
1419
- * @param key - the key of the node
1420
- */
1421
- CacheList.prototype.removeItem = function (key) {
1422
- var removedItem = this.hashtable[key];
1423
- this.removeNode(removedItem);
1424
- delete this.hashtable[key];
1425
- };
1426
- /**
1427
- * @return length of the list
1428
- */
1429
- CacheList.prototype.getSize = function () {
1430
- return this.length;
1431
- };
1432
- /**
1433
- * @return true if the key is in the hashtable
1434
- * @param key
1435
- */
1436
- CacheList.prototype.containsKey = function (key) {
1437
- return key in this.hashtable;
1438
- };
1439
- /**
1440
- * clean up the list and hashtable
1441
- */
1442
- CacheList.prototype.clearList = function () {
1443
- var e_1, _a;
1444
- try {
1445
- for (var _b = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__values"])(Object.keys(this.hashtable)), _c = _b.next(); !_c.done; _c = _b.next()) {
1446
- var key = _c.value;
1447
- if (this.hashtable.hasOwnProperty(key)) {
1448
- delete this.hashtable[key];
1449
- }
1450
- }
1451
- } catch (e_1_1) {
1452
- e_1 = {
1453
- error: e_1_1
1454
- };
1455
- } finally {
1456
- try {
1457
- if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
1458
- } finally {
1459
- if (e_1) throw e_1.error;
1460
- }
1461
- }
1462
- this.head.nextNode = this.tail;
1463
- this.tail.prevNode = this.head;
1464
- this.length = 0;
1465
- };
1466
- /**
1467
- * @return all keys in the hashtable
1468
- */
1469
- CacheList.prototype.getKeys = function () {
1470
- return Object.keys(this.hashtable);
1471
- };
1472
- /**
1473
- * mainly for test
1474
- *
1475
- * @param key
1476
- * @return true if key is the head node
1477
- */
1478
- CacheList.prototype.isHeadNode = function (key) {
1479
- var node = this.hashtable[key];
1480
- return node.prevNode === this.head;
1481
- };
1482
- /**
1483
- * mainly for test
1484
- *
1485
- * @param key
1486
- * @return true if key is the tail node
1487
- */
1488
- CacheList.prototype.isTailNode = function (key) {
1489
- var node = this.hashtable[key];
1490
- return node.nextNode === this.tail;
1491
- };
1492
- return CacheList;
1493
- }();
1494
- /* harmony default export */ __webpack_exports__["default"] = (CacheList);
1495
-
1496
- /***/ }),
1497
-
1498
- /***/ "./lib-esm/Utils/CacheUtils.js":
1499
- /*!*************************************!*\
1500
- !*** ./lib-esm/Utils/CacheUtils.js ***!
1501
- \*************************************/
1502
- /*! exports provided: defaultConfig, getByteLength, getCurrTime, isInteger, CacheObject */
1503
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
1504
-
1505
- "use strict";
1506
- __webpack_require__.r(__webpack_exports__);
1507
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultConfig", function() { return defaultConfig; });
1508
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getByteLength", function() { return getByteLength; });
1509
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getCurrTime", function() { return getCurrTime; });
1510
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isInteger", function() { return isInteger; });
1511
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CacheObject", function() { return CacheObject; });
1512
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
1513
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__);
1514
- /*
1515
- * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1516
- *
1517
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
1518
- * the License. A copy of the License is located at
1519
- *
1520
- * http://aws.amazon.com/apache2.0/
1521
- *
1522
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
1523
- * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1524
- * and limitations under the License.
1525
- */
1526
-
1527
- /**
1528
- * Default cache config
1529
- */
1530
- var defaultConfig = {
1531
- keyPrefix: 'aws-amplify-cache',
1532
- capacityInBytes: 1048576,
1533
- itemMaxSize: 210000,
1534
- defaultTTL: 259200000,
1535
- defaultPriority: 5,
1536
- warningThreshold: 0.8,
1537
- // the storage helper will check if localStorage exists,
1538
- // if not, will use a in-memory object instead
1539
- storage: new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["StorageHelper"]().getStorage()
1540
- };
1541
- /**
1542
- * return the byte size of the string
1543
- * @param str
1544
- */
1545
- function getByteLength(str) {
1546
- var ret = 0;
1547
- ret = str.length;
1548
- for (var i = str.length; i >= 0; i -= 1) {
1549
- var charCode = str.charCodeAt(i);
1550
- if (charCode > 0x7f && charCode <= 0x7ff) {
1551
- ret += 1;
1552
- } else if (charCode > 0x7ff && charCode <= 0xffff) {
1553
- ret += 2;
1554
- }
1555
- // trail surrogate
1556
- if (charCode >= 0xdc00 && charCode <= 0xdfff) {
1557
- i -= 1;
1558
- }
1559
- }
1560
- return ret;
1561
- }
1562
- /**
1563
- * get current time
1564
- */
1565
- function getCurrTime() {
1566
- var currTime = new Date();
1567
- return currTime.getTime();
1568
- }
1569
- /**
1570
- * check if passed value is an integer
1571
- */
1572
- function isInteger(value) {
1573
- if (Number.isInteger) {
1574
- return Number.isInteger(value);
1575
- }
1576
- return _isInteger(value);
1577
- }
1578
- function _isInteger(value) {
1579
- return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
1580
- }
1581
- /**
1582
- * provide an object as the in-memory cache
1583
- */
1584
- var store = {};
1585
- var CacheObject = /** @class */function () {
1586
- function CacheObject() {}
1587
- CacheObject.clear = function () {
1588
- store = {};
1589
- };
1590
- CacheObject.getItem = function (key) {
1591
- return store[key] || null;
1592
- };
1593
- CacheObject.setItem = function (key, value) {
1594
- store[key] = value;
1595
- };
1596
- CacheObject.removeItem = function (key) {
1597
- delete store[key];
1598
- };
1599
- return CacheObject;
1600
- }();
1601
-
1602
-
1603
- /***/ }),
1604
-
1605
- /***/ "./lib-esm/Utils/index.js":
1606
- /*!********************************!*\
1607
- !*** ./lib-esm/Utils/index.js ***!
1608
- \********************************/
1609
- /*! exports provided: defaultConfig, getByteLength, getCurrTime, isInteger, CacheObject, CacheList */
1610
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
1611
-
1612
- "use strict";
1613
- __webpack_require__.r(__webpack_exports__);
1614
- /* harmony import */ var _CacheUtils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./CacheUtils */ "./lib-esm/Utils/CacheUtils.js");
1615
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "defaultConfig", function() { return _CacheUtils__WEBPACK_IMPORTED_MODULE_0__["defaultConfig"]; });
1616
-
1617
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getByteLength", function() { return _CacheUtils__WEBPACK_IMPORTED_MODULE_0__["getByteLength"]; });
1618
-
1619
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getCurrTime", function() { return _CacheUtils__WEBPACK_IMPORTED_MODULE_0__["getCurrTime"]; });
1620
-
1621
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "isInteger", function() { return _CacheUtils__WEBPACK_IMPORTED_MODULE_0__["isInteger"]; });
1622
-
1623
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CacheObject", function() { return _CacheUtils__WEBPACK_IMPORTED_MODULE_0__["CacheObject"]; });
1624
-
1625
- /* harmony import */ var _CacheList__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CacheList */ "./lib-esm/Utils/CacheList.js");
1626
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CacheList", function() { return _CacheList__WEBPACK_IMPORTED_MODULE_1__["default"]; });
1627
-
1628
- /*
1629
- * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1630
- *
1631
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
1632
- * the License. A copy of the License is located at
1633
- *
1634
- * http://aws.amazon.com/apache2.0/
1635
- *
1636
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
1637
- * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1638
- * and limitations under the License.
1639
- */
1640
-
1641
-
1642
-
1643
- /***/ }),
1644
-
1645
- /***/ "./lib-esm/index.js":
1646
- /*!**************************!*\
1647
- !*** ./lib-esm/index.js ***!
1648
- \**************************/
1649
- /*! exports provided: BrowserStorageCache, InMemoryCache, default */
1650
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
1651
-
1652
- "use strict";
1653
- __webpack_require__.r(__webpack_exports__);
1654
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
1655
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__);
1656
- /* harmony import */ var _BrowserStorageCache__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BrowserStorageCache */ "./lib-esm/BrowserStorageCache.js");
1657
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BrowserStorageCache", function() { return _BrowserStorageCache__WEBPACK_IMPORTED_MODULE_1__["BrowserStorageCache"]; });
1658
-
1659
- /* harmony import */ var _InMemoryCache__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./InMemoryCache */ "./lib-esm/InMemoryCache.js");
1660
- /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InMemoryCache", function() { return _InMemoryCache__WEBPACK_IMPORTED_MODULE_2__["InMemoryCache"]; });
1661
-
1662
- /*
1663
- * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1664
- *
1665
- * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
1666
- * the License. A copy of the License is located at
1667
- *
1668
- * http://aws.amazon.com/apache2.0/
1669
- *
1670
- * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
1671
- * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1672
- * and limitations under the License.
1673
- */
1674
-
1675
-
1676
-
1677
-
1678
- /**
1679
- * @deprecated use named import
1680
- */
1681
- /* harmony default export */ __webpack_exports__["default"] = (_BrowserStorageCache__WEBPACK_IMPORTED_MODULE_1__["BrowserStorageCache"]);
1682
- _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Amplify"].register(_BrowserStorageCache__WEBPACK_IMPORTED_MODULE_1__["BrowserStorageCache"]);
1683
-
1684
- /***/ }),
1685
-
1686
- /***/ "@aws-amplify/core":
1687
- /*!***********************************!*\
1688
- !*** external "aws_amplify_core" ***!
1689
- \***********************************/
1690
- /*! no static exports found */
1691
- /***/ (function(module, exports) {
1692
-
1693
- module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_core__;
1694
-
1695
- /***/ })
1696
-
1697
- /******/ });
1698
- });
1699
- //# sourceMappingURL=aws-amplify-cache.js.map