@ngxs/storage-plugin 3.7.6-dev.master-1bdb8c0 → 3.7.6-dev.master-dcdd391
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/ngxs-storage-plugin.umd.js +411 -539
- package/bundles/ngxs-storage-plugin.umd.js.map +1 -1
- package/esm2015/index.js +2 -6
- package/esm2015/ngxs-storage-plugin.js +2 -9
- package/esm2015/src/engines.js +3 -15
- package/esm2015/src/internals/final-options.js +5 -31
- package/esm2015/src/internals/storage-key.js +5 -31
- package/esm2015/src/internals.js +2 -29
- package/esm2015/src/public_api.js +3 -7
- package/esm2015/src/storage.module.js +8 -13
- package/esm2015/src/storage.plugin.js +24 -86
- package/esm2015/src/symbols.js +1 -97
- package/fesm2015/ngxs-storage-plugin.js +44 -305
- package/fesm2015/ngxs-storage-plugin.js.map +1 -1
- package/ngxs-storage-plugin.d.ts +1 -3
- package/package.json +3 -6
- package/src/storage.module.d.ts +5 -1
- package/src/storage.plugin.d.ts +3 -0
- package/src/symbols.d.ts +1 -1
- package/bundles/ngxs-storage-plugin.umd.min.js +0 -16
- package/bundles/ngxs-storage-plugin.umd.min.js.map +0 -1
- package/esm5/index.js +0 -9
- package/esm5/ngxs-storage-plugin.js +0 -12
- package/esm5/src/engines.js +0 -22
- package/esm5/src/internals/final-options.js +0 -43
- package/esm5/src/internals/storage-key.js +0 -47
- package/esm5/src/internals.js +0 -55
- package/esm5/src/public_api.js +0 -9
- package/esm5/src/storage.module.js +0 -61
- package/esm5/src/storage.plugin.js +0 -239
- package/esm5/src/symbols.js +0 -100
- package/fesm5/ngxs-storage-plugin.js +0 -565
- package/fesm5/ngxs-storage-plugin.js.map +0 -1
- package/ngxs-storage-plugin.metadata.json +0 -1
|
@@ -1,356 +1,367 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@ngxs/store'), require('@angular/common'), require('rxjs/operators')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define('@ngxs/storage-plugin', ['exports', '@angular/core', '@ngxs/store', '@angular/common', 'rxjs/operators'], factory) :
|
|
4
|
-
(global = global || self, factory((global.ngxs = global.ngxs || {}, global.ngxs[
|
|
5
|
-
}(this, function (exports,
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ngxs = global.ngxs || {}, global.ngxs["storage-plugin"] = {}), global.ng.core, global["ngxs-store"], global.ng.common, global.rxjs.operators));
|
|
5
|
+
})(this, (function (exports, i0, store, common, operators) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var extendStatics = function(d, b) {
|
|
24
|
-
extendStatics = Object.setPrototypeOf ||
|
|
25
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
26
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
27
|
-
return extendStatics(d, b);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
function __extends(d, b) {
|
|
31
|
-
extendStatics(d, b);
|
|
32
|
-
function __() { this.constructor = d; }
|
|
33
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var __assign = function() {
|
|
37
|
-
__assign = Object.assign || function __assign(t) {
|
|
38
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
39
|
-
s = arguments[i];
|
|
40
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
41
|
-
}
|
|
42
|
-
return t;
|
|
43
|
-
};
|
|
44
|
-
return __assign.apply(this, arguments);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
function __rest(s, e) {
|
|
48
|
-
var t = {};
|
|
49
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
50
|
-
t[p] = s[p];
|
|
51
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
52
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
53
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
54
|
-
t[p[i]] = s[p[i]];
|
|
55
|
-
}
|
|
56
|
-
return t;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function __decorate(decorators, target, key, desc) {
|
|
60
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
61
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
62
|
-
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;
|
|
63
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function __param(paramIndex, decorator) {
|
|
67
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function __metadata(metadataKey, metadataValue) {
|
|
71
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
75
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
76
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
77
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
78
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
79
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
80
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function __generator(thisArg, body) {
|
|
85
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
86
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
87
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
88
|
-
function step(op) {
|
|
89
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
90
|
-
while (_) try {
|
|
91
|
-
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;
|
|
92
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
93
|
-
switch (op[0]) {
|
|
94
|
-
case 0: case 1: t = op; break;
|
|
95
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
96
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
97
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
98
|
-
default:
|
|
99
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
100
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
101
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
102
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
103
|
-
if (t[2]) _.ops.pop();
|
|
104
|
-
_.trys.pop(); continue;
|
|
105
|
-
}
|
|
106
|
-
op = body.call(thisArg, _);
|
|
107
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
108
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function __createBinding(o, m, k, k2) {
|
|
113
|
-
if (k2 === undefined) k2 = k;
|
|
114
|
-
o[k2] = m[k];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function __exportStar(m, exports) {
|
|
118
|
-
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function __values(o) {
|
|
122
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
123
|
-
if (m) return m.call(o);
|
|
124
|
-
if (o && typeof o.length === "number") return {
|
|
125
|
-
next: function () {
|
|
126
|
-
if (o && i >= o.length) o = void 0;
|
|
127
|
-
return { value: o && o[i++], done: !o };
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function __read(o, n) {
|
|
134
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
135
|
-
if (!m) return o;
|
|
136
|
-
var i = m.call(o), r, ar = [], e;
|
|
137
|
-
try {
|
|
138
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
139
|
-
}
|
|
140
|
-
catch (error) { e = { error: error }; }
|
|
141
|
-
finally {
|
|
142
|
-
try {
|
|
143
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
144
|
-
}
|
|
145
|
-
finally { if (e) throw e.error; }
|
|
146
|
-
}
|
|
147
|
-
return ar;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function __spread() {
|
|
151
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
152
|
-
ar = ar.concat(__read(arguments[i]));
|
|
153
|
-
return ar;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function __spreadArrays() {
|
|
157
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
158
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
159
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
160
|
-
r[k] = a[j];
|
|
161
|
-
return r;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
function __await(v) {
|
|
165
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
169
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
170
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
171
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
172
|
-
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); }); }; }
|
|
173
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
174
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
175
|
-
function fulfill(value) { resume("next", value); }
|
|
176
|
-
function reject(value) { resume("throw", value); }
|
|
177
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function __asyncDelegator(o) {
|
|
181
|
-
var i, p;
|
|
182
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
183
|
-
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; }
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function __asyncValues(o) {
|
|
187
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
188
|
-
var m = o[Symbol.asyncIterator], i;
|
|
189
|
-
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);
|
|
190
|
-
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); }); }; }
|
|
191
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function __makeTemplateObject(cooked, raw) {
|
|
195
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
196
|
-
return cooked;
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
function __importStar(mod) {
|
|
200
|
-
if (mod && mod.__esModule) return mod;
|
|
201
|
-
var result = {};
|
|
202
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
203
|
-
result.default = mod;
|
|
204
|
-
return result;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function __importDefault(mod) {
|
|
208
|
-
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
function __classPrivateFieldGet(receiver, privateMap) {
|
|
212
|
-
if (!privateMap.has(receiver)) {
|
|
213
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
214
|
-
}
|
|
215
|
-
return privateMap.get(receiver);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function __classPrivateFieldSet(receiver, privateMap, value) {
|
|
219
|
-
if (!privateMap.has(receiver)) {
|
|
220
|
-
throw new TypeError("attempted to set private field on non-instance");
|
|
221
|
-
}
|
|
222
|
-
privateMap.set(receiver, value);
|
|
223
|
-
return value;
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
224
23
|
}
|
|
225
24
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
25
|
+
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
26
|
+
|
|
27
|
+
var NGXS_STORAGE_PLUGIN_OPTIONS = new i0.InjectionToken('NGXS_STORAGE_PLUGIN_OPTIONS');
|
|
28
|
+
var STORAGE_ENGINE = new i0.InjectionToken('STORAGE_ENGINE');
|
|
29
|
+
|
|
30
|
+
/******************************************************************************
|
|
31
|
+
Copyright (c) Microsoft Corporation.
|
|
32
|
+
|
|
33
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
34
|
+
purpose with or without fee is hereby granted.
|
|
35
|
+
|
|
36
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
37
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
38
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
39
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
40
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
41
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
42
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
43
|
+
***************************************************************************** */
|
|
44
|
+
/* global Reflect, Promise */
|
|
45
|
+
var extendStatics = function (d, b) {
|
|
46
|
+
extendStatics = Object.setPrototypeOf ||
|
|
47
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
48
|
+
function (d, b) { for (var p in b)
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
50
|
+
d[p] = b[p]; };
|
|
51
|
+
return extendStatics(d, b);
|
|
234
52
|
};
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
* Key for the state slice to store in the storage engine.
|
|
242
|
-
* @type {?|undefined}
|
|
243
|
-
*/
|
|
244
|
-
NgxsStoragePluginOptions.prototype.key;
|
|
245
|
-
/**
|
|
246
|
-
* The namespace is used to prefix the key for the state slice. This is
|
|
247
|
-
* necessary when running micro frontend applications which use storage plugin.
|
|
248
|
-
* The namespace will eliminate the conflict between keys that might overlap.
|
|
249
|
-
* @type {?|undefined}
|
|
250
|
-
*/
|
|
251
|
-
NgxsStoragePluginOptions.prototype.namespace;
|
|
252
|
-
/**
|
|
253
|
-
* Storage engine to use. Deaults to localStorage but can provide
|
|
254
|
-
*
|
|
255
|
-
* sessionStorage or custom implementation of the StorageEngine interface
|
|
256
|
-
* @type {?|undefined}
|
|
257
|
-
*/
|
|
258
|
-
NgxsStoragePluginOptions.prototype.storage;
|
|
259
|
-
/**
|
|
260
|
-
* Migration strategies.
|
|
261
|
-
* @type {?|undefined}
|
|
262
|
-
*/
|
|
263
|
-
NgxsStoragePluginOptions.prototype.migrations;
|
|
264
|
-
/**
|
|
265
|
-
* Serailizer for the object before its pushed into the engine.
|
|
266
|
-
* @param {?} obj
|
|
267
|
-
* @return {?}
|
|
268
|
-
*/
|
|
269
|
-
NgxsStoragePluginOptions.prototype.serialize = function (obj) { };
|
|
270
|
-
/**
|
|
271
|
-
* Deserializer for the object before its pulled out of the engine.
|
|
272
|
-
* @param {?} obj
|
|
273
|
-
* @return {?}
|
|
274
|
-
*/
|
|
275
|
-
NgxsStoragePluginOptions.prototype.deserialize = function (obj) { };
|
|
276
|
-
/**
|
|
277
|
-
* Method to alter object before serialization.
|
|
278
|
-
* @param {?} obj
|
|
279
|
-
* @param {?} key
|
|
280
|
-
* @return {?}
|
|
281
|
-
*/
|
|
282
|
-
NgxsStoragePluginOptions.prototype.beforeSerialize = function (obj, key) { };
|
|
283
|
-
/**
|
|
284
|
-
* Method to alter object after deserialization.
|
|
285
|
-
* @param {?} obj
|
|
286
|
-
* @param {?} key
|
|
287
|
-
* @return {?}
|
|
288
|
-
*/
|
|
289
|
-
NgxsStoragePluginOptions.prototype.afterDeserialize = function (obj, key) { };
|
|
53
|
+
function __extends(d, b) {
|
|
54
|
+
if (typeof b !== "function" && b !== null)
|
|
55
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
56
|
+
extendStatics(d, b);
|
|
57
|
+
function __() { this.constructor = d; }
|
|
58
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
290
59
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
60
|
+
var __assign = function () {
|
|
61
|
+
__assign = Object.assign || function __assign(t) {
|
|
62
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
63
|
+
s = arguments[i];
|
|
64
|
+
for (var p in s)
|
|
65
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
66
|
+
t[p] = s[p];
|
|
67
|
+
}
|
|
68
|
+
return t;
|
|
69
|
+
};
|
|
70
|
+
return __assign.apply(this, arguments);
|
|
71
|
+
};
|
|
72
|
+
function __rest(s, e) {
|
|
73
|
+
var t = {};
|
|
74
|
+
for (var p in s)
|
|
75
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
76
|
+
t[p] = s[p];
|
|
77
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
78
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
79
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
80
|
+
t[p[i]] = s[p[i]];
|
|
81
|
+
}
|
|
82
|
+
return t;
|
|
83
|
+
}
|
|
84
|
+
function __decorate(decorators, target, key, desc) {
|
|
85
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
86
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
87
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
88
|
+
else
|
|
89
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
90
|
+
if (d = decorators[i])
|
|
91
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
92
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
93
|
+
}
|
|
94
|
+
function __param(paramIndex, decorator) {
|
|
95
|
+
return function (target, key) { decorator(target, key, paramIndex); };
|
|
96
|
+
}
|
|
97
|
+
function __metadata(metadataKey, metadataValue) {
|
|
98
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
99
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
100
|
+
}
|
|
101
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
102
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
103
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
104
|
+
function fulfilled(value) { try {
|
|
105
|
+
step(generator.next(value));
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
reject(e);
|
|
109
|
+
} }
|
|
110
|
+
function rejected(value) { try {
|
|
111
|
+
step(generator["throw"](value));
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
reject(e);
|
|
115
|
+
} }
|
|
116
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
117
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function __generator(thisArg, body) {
|
|
121
|
+
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
122
|
+
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
123
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
124
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
125
|
+
function step(op) {
|
|
126
|
+
if (f)
|
|
127
|
+
throw new TypeError("Generator is already executing.");
|
|
128
|
+
while (g && (g = 0, op[0] && (_ = 0)), _)
|
|
129
|
+
try {
|
|
130
|
+
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)
|
|
131
|
+
return t;
|
|
132
|
+
if (y = 0, t)
|
|
133
|
+
op = [op[0] & 2, t.value];
|
|
134
|
+
switch (op[0]) {
|
|
135
|
+
case 0:
|
|
136
|
+
case 1:
|
|
137
|
+
t = op;
|
|
138
|
+
break;
|
|
139
|
+
case 4:
|
|
140
|
+
_.label++;
|
|
141
|
+
return { value: op[1], done: false };
|
|
142
|
+
case 5:
|
|
143
|
+
_.label++;
|
|
144
|
+
y = op[1];
|
|
145
|
+
op = [0];
|
|
146
|
+
continue;
|
|
147
|
+
case 7:
|
|
148
|
+
op = _.ops.pop();
|
|
149
|
+
_.trys.pop();
|
|
150
|
+
continue;
|
|
151
|
+
default:
|
|
152
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
153
|
+
_ = 0;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
157
|
+
_.label = op[1];
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
161
|
+
_.label = t[1];
|
|
162
|
+
t = op;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
if (t && _.label < t[2]) {
|
|
166
|
+
_.label = t[2];
|
|
167
|
+
_.ops.push(op);
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
if (t[2])
|
|
171
|
+
_.ops.pop();
|
|
172
|
+
_.trys.pop();
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
op = body.call(thisArg, _);
|
|
176
|
+
}
|
|
177
|
+
catch (e) {
|
|
178
|
+
op = [6, e];
|
|
179
|
+
y = 0;
|
|
180
|
+
}
|
|
181
|
+
finally {
|
|
182
|
+
f = t = 0;
|
|
183
|
+
}
|
|
184
|
+
if (op[0] & 5)
|
|
185
|
+
throw op[1];
|
|
186
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
190
|
+
if (k2 === undefined)
|
|
191
|
+
k2 = k;
|
|
192
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
193
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
194
|
+
desc = { enumerable: true, get: function () { return m[k]; } };
|
|
195
|
+
}
|
|
196
|
+
Object.defineProperty(o, k2, desc);
|
|
197
|
+
}) : (function (o, m, k, k2) {
|
|
198
|
+
if (k2 === undefined)
|
|
199
|
+
k2 = k;
|
|
200
|
+
o[k2] = m[k];
|
|
201
|
+
});
|
|
202
|
+
function __exportStar(m, o) {
|
|
203
|
+
for (var p in m)
|
|
204
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
205
|
+
__createBinding(o, m, p);
|
|
206
|
+
}
|
|
207
|
+
function __values(o) {
|
|
208
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
209
|
+
if (m)
|
|
210
|
+
return m.call(o);
|
|
211
|
+
if (o && typeof o.length === "number")
|
|
212
|
+
return {
|
|
213
|
+
next: function () {
|
|
214
|
+
if (o && i >= o.length)
|
|
215
|
+
o = void 0;
|
|
216
|
+
return { value: o && o[i++], done: !o };
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
220
|
+
}
|
|
221
|
+
function __read(o, n) {
|
|
222
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
223
|
+
if (!m)
|
|
224
|
+
return o;
|
|
225
|
+
var i = m.call(o), r, ar = [], e;
|
|
226
|
+
try {
|
|
227
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
228
|
+
ar.push(r.value);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
e = { error: error };
|
|
232
|
+
}
|
|
233
|
+
finally {
|
|
234
|
+
try {
|
|
235
|
+
if (r && !r.done && (m = i["return"]))
|
|
236
|
+
m.call(i);
|
|
237
|
+
}
|
|
238
|
+
finally {
|
|
239
|
+
if (e)
|
|
240
|
+
throw e.error;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return ar;
|
|
244
|
+
}
|
|
245
|
+
/** @deprecated */
|
|
246
|
+
function __spread() {
|
|
247
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
248
|
+
ar = ar.concat(__read(arguments[i]));
|
|
249
|
+
return ar;
|
|
250
|
+
}
|
|
251
|
+
/** @deprecated */
|
|
252
|
+
function __spreadArrays() {
|
|
253
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
254
|
+
s += arguments[i].length;
|
|
255
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
256
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
257
|
+
r[k] = a[j];
|
|
258
|
+
return r;
|
|
259
|
+
}
|
|
260
|
+
function __spreadArray(to, from, pack) {
|
|
261
|
+
if (pack || arguments.length === 2)
|
|
262
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
263
|
+
if (ar || !(i in from)) {
|
|
264
|
+
if (!ar)
|
|
265
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
266
|
+
ar[i] = from[i];
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
270
|
+
}
|
|
271
|
+
function __await(v) {
|
|
272
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
273
|
+
}
|
|
274
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
275
|
+
if (!Symbol.asyncIterator)
|
|
276
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
277
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
278
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
279
|
+
function verb(n) { if (g[n])
|
|
280
|
+
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
281
|
+
function resume(n, v) { try {
|
|
282
|
+
step(g[n](v));
|
|
283
|
+
}
|
|
284
|
+
catch (e) {
|
|
285
|
+
settle(q[0][3], e);
|
|
286
|
+
} }
|
|
287
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
288
|
+
function fulfill(value) { resume("next", value); }
|
|
289
|
+
function reject(value) { resume("throw", value); }
|
|
290
|
+
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
291
|
+
resume(q[0][0], q[0][1]); }
|
|
292
|
+
}
|
|
293
|
+
function __asyncDelegator(o) {
|
|
294
|
+
var i, p;
|
|
295
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
296
|
+
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; }
|
|
297
|
+
}
|
|
298
|
+
function __asyncValues(o) {
|
|
299
|
+
if (!Symbol.asyncIterator)
|
|
300
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
301
|
+
var m = o[Symbol.asyncIterator], i;
|
|
302
|
+
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);
|
|
303
|
+
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); }); }; }
|
|
304
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
305
|
+
}
|
|
306
|
+
function __makeTemplateObject(cooked, raw) {
|
|
307
|
+
if (Object.defineProperty) {
|
|
308
|
+
Object.defineProperty(cooked, "raw", { value: raw });
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
cooked.raw = raw;
|
|
312
|
+
}
|
|
313
|
+
return cooked;
|
|
314
|
+
}
|
|
315
|
+
;
|
|
316
|
+
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
317
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
318
|
+
}) : function (o, v) {
|
|
319
|
+
o["default"] = v;
|
|
320
|
+
};
|
|
321
|
+
function __importStar(mod) {
|
|
322
|
+
if (mod && mod.__esModule)
|
|
323
|
+
return mod;
|
|
324
|
+
var result = {};
|
|
325
|
+
if (mod != null)
|
|
326
|
+
for (var k in mod)
|
|
327
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
328
|
+
__createBinding(result, mod, k);
|
|
329
|
+
__setModuleDefault(result, mod);
|
|
330
|
+
return result;
|
|
331
|
+
}
|
|
332
|
+
function __importDefault(mod) {
|
|
333
|
+
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
334
|
+
}
|
|
335
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
336
|
+
if (kind === "a" && !f)
|
|
337
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
338
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
339
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
340
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
341
|
+
}
|
|
342
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
343
|
+
if (kind === "m")
|
|
344
|
+
throw new TypeError("Private method is not writable");
|
|
345
|
+
if (kind === "a" && !f)
|
|
346
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
347
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
348
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
349
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
350
|
+
}
|
|
351
|
+
function __classPrivateFieldIn(state, receiver) {
|
|
352
|
+
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
|
|
353
|
+
throw new TypeError("Cannot use 'in' operator on non-object");
|
|
354
|
+
return typeof state === "function" ? receiver === state : state.has(receiver);
|
|
322
355
|
}
|
|
323
356
|
|
|
324
|
-
/**
|
|
325
|
-
* @fileoverview added by tsickle
|
|
326
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
327
|
-
*/
|
|
328
357
|
/**
|
|
329
358
|
* The following key is used to store the entire serialized
|
|
330
359
|
* state when there's no specific state provided.
|
|
331
|
-
* @type {?}
|
|
332
360
|
*/
|
|
333
361
|
var DEFAULT_STATE_KEY = '@@STATE';
|
|
334
|
-
/**
|
|
335
|
-
* @param {?} options
|
|
336
|
-
* @return {?}
|
|
337
|
-
*/
|
|
338
362
|
function storageOptionsFactory(options) {
|
|
339
|
-
return
|
|
340
|
-
* @param {?} obj
|
|
341
|
-
* @return {?}
|
|
342
|
-
*/
|
|
343
|
-
function (obj) { return obj; }), afterDeserialize: (/**
|
|
344
|
-
* @param {?} obj
|
|
345
|
-
* @return {?}
|
|
346
|
-
*/
|
|
347
|
-
function (obj) { return obj; }) }, options);
|
|
363
|
+
return Object.assign({ key: [DEFAULT_STATE_KEY], storage: 0 /* LocalStorage */, serialize: JSON.stringify, deserialize: JSON.parse, beforeSerialize: function (obj) { return obj; }, afterDeserialize: function (obj) { return obj; } }, options);
|
|
348
364
|
}
|
|
349
|
-
/**
|
|
350
|
-
* @param {?} options
|
|
351
|
-
* @param {?} platformId
|
|
352
|
-
* @return {?}
|
|
353
|
-
*/
|
|
354
365
|
function engineFactory(options, platformId) {
|
|
355
366
|
if (common.isPlatformServer(platformId)) {
|
|
356
367
|
return null;
|
|
@@ -363,49 +374,18 @@
|
|
|
363
374
|
}
|
|
364
375
|
return null;
|
|
365
376
|
}
|
|
366
|
-
/**
|
|
367
|
-
* @param {?} key
|
|
368
|
-
* @param {?=} options
|
|
369
|
-
* @return {?}
|
|
370
|
-
*/
|
|
371
377
|
function getStorageKey(key, options) {
|
|
372
378
|
// Prepends the `namespace` option to any key if it's been provided by a user.
|
|
373
379
|
// So `@@STATE` becomes `my-app:@@STATE`.
|
|
374
380
|
return options && options.namespace ? options.namespace + ":" + key : key;
|
|
375
381
|
}
|
|
376
382
|
|
|
377
|
-
/**
|
|
378
|
-
* @fileoverview added by tsickle
|
|
379
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
380
|
-
*/
|
|
381
|
-
/**
|
|
382
|
-
* This enables the user to provide a storage engine per individual key.
|
|
383
|
-
* @record
|
|
384
|
-
*/
|
|
385
|
-
function KeyWithExplicitEngine() { }
|
|
386
|
-
if (false) {
|
|
387
|
-
/** @type {?} */
|
|
388
|
-
KeyWithExplicitEngine.prototype.key;
|
|
389
|
-
/** @type {?} */
|
|
390
|
-
KeyWithExplicitEngine.prototype.engine;
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Determines whether the provided key has the following structure.
|
|
394
|
-
* @param {?} key
|
|
395
|
-
* @return {?}
|
|
396
|
-
*/
|
|
383
|
+
/** Determines whether the provided key has the following structure. */
|
|
397
384
|
function isKeyWithExplicitEngine(key) {
|
|
398
385
|
return key != null && !!key.engine;
|
|
399
386
|
}
|
|
400
|
-
/**
|
|
401
|
-
* This symbol is used to store the metadata on state classes.
|
|
402
|
-
* @type {?}
|
|
403
|
-
*/
|
|
387
|
+
/** This symbol is used to store the metadata on state classes. */
|
|
404
388
|
var META_OPTIONS_KEY = 'NGXS_OPTIONS_META';
|
|
405
|
-
/**
|
|
406
|
-
* @param {?} storageKey
|
|
407
|
-
* @return {?}
|
|
408
|
-
*/
|
|
409
389
|
function exctractStringKey(storageKey) {
|
|
410
390
|
// Extract the actual key out of the `{ key, engine }` structure.
|
|
411
391
|
if (isKeyWithExplicitEngine(storageKey)) {
|
|
@@ -415,54 +395,24 @@
|
|
|
415
395
|
// We should retrieve its metadata and the `name` property.
|
|
416
396
|
// The `name` property might be a string (state name) or a state token.
|
|
417
397
|
if (storageKey.hasOwnProperty(META_OPTIONS_KEY)) {
|
|
418
|
-
storageKey =
|
|
398
|
+
storageKey = storageKey[META_OPTIONS_KEY].name;
|
|
419
399
|
}
|
|
420
|
-
return storageKey instanceof store.StateToken ? storageKey.getName() :
|
|
400
|
+
return storageKey instanceof store.StateToken ? storageKey.getName() : storageKey;
|
|
421
401
|
}
|
|
422
402
|
|
|
423
|
-
|
|
424
|
-
* @fileoverview added by tsickle
|
|
425
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
426
|
-
*/
|
|
427
|
-
/**
|
|
428
|
-
* @record
|
|
429
|
-
*/
|
|
430
|
-
function FinalNgxsStoragePluginOptions() { }
|
|
431
|
-
if (false) {
|
|
432
|
-
/** @type {?} */
|
|
433
|
-
FinalNgxsStoragePluginOptions.prototype.keysWithEngines;
|
|
434
|
-
}
|
|
435
|
-
/** @type {?} */
|
|
436
|
-
var FINAL_NGXS_STORAGE_PLUGIN_OPTIONS = new core.InjectionToken('FINAL_NGXS_STORAGE_PLUGIN_OPTIONS');
|
|
437
|
-
/**
|
|
438
|
-
* @param {?} injector
|
|
439
|
-
* @param {?} options
|
|
440
|
-
* @return {?}
|
|
441
|
-
*/
|
|
403
|
+
var FINAL_NGXS_STORAGE_PLUGIN_OPTIONS = new i0.InjectionToken('FINAL_NGXS_STORAGE_PLUGIN_OPTIONS');
|
|
442
404
|
function createFinalStoragePluginOptions(injector, options) {
|
|
443
|
-
|
|
444
|
-
var
|
|
445
|
-
/** @type {?} */
|
|
446
|
-
var keysWithEngines = storageKeys.map((/**
|
|
447
|
-
* @param {?} storageKey
|
|
448
|
-
* @return {?}
|
|
449
|
-
*/
|
|
450
|
-
function (storageKey) {
|
|
451
|
-
/** @type {?} */
|
|
405
|
+
var storageKeys = Array.isArray(options.key) ? options.key : [options.key];
|
|
406
|
+
var keysWithEngines = storageKeys.map(function (storageKey) {
|
|
452
407
|
var key = exctractStringKey(storageKey);
|
|
453
|
-
/** @type {?} */
|
|
454
408
|
var engine = isKeyWithExplicitEngine(storageKey)
|
|
455
409
|
? injector.get(storageKey.engine)
|
|
456
410
|
: injector.get(STORAGE_ENGINE);
|
|
457
411
|
return { key: key, engine: engine };
|
|
458
|
-
})
|
|
459
|
-
return
|
|
412
|
+
});
|
|
413
|
+
return Object.assign(Object.assign({}, options), { keysWithEngines: keysWithEngines });
|
|
460
414
|
}
|
|
461
415
|
|
|
462
|
-
/**
|
|
463
|
-
* @fileoverview added by tsickle
|
|
464
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
465
|
-
*/
|
|
466
416
|
var NgxsStoragePlugin = /** @class */ (function () {
|
|
467
417
|
function NgxsStoragePlugin(_options, _platformId) {
|
|
468
418
|
this._options = _options;
|
|
@@ -471,36 +421,18 @@
|
|
|
471
421
|
// We default to `[DEFAULT_STATE_KEY]` if the user explicitly does not provide the `key` option.
|
|
472
422
|
this._usesDefaultStateKey = this._keysWithEngines.length === 1 && this._keysWithEngines[0].key === DEFAULT_STATE_KEY;
|
|
473
423
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
* @param {?} event
|
|
477
|
-
* @param {?} next
|
|
478
|
-
* @return {?}
|
|
479
|
-
*/
|
|
480
|
-
NgxsStoragePlugin.prototype.handle = /**
|
|
481
|
-
* @param {?} state
|
|
482
|
-
* @param {?} event
|
|
483
|
-
* @param {?} next
|
|
484
|
-
* @return {?}
|
|
485
|
-
*/
|
|
486
|
-
function (state, event, next) {
|
|
424
|
+
NgxsStoragePlugin.prototype.handle = function (state, event, next) {
|
|
425
|
+
var e_1, _b;
|
|
487
426
|
var _this = this;
|
|
488
|
-
var e_1, _a;
|
|
489
427
|
if (common.isPlatformServer(this._platformId)) {
|
|
490
428
|
return next(state, event);
|
|
491
429
|
}
|
|
492
|
-
/** @type {?} */
|
|
493
430
|
var matches = store.actionMatcher(event);
|
|
494
|
-
/** @type {?} */
|
|
495
431
|
var isInitAction = matches(store.InitState);
|
|
496
|
-
/** @type {?} */
|
|
497
432
|
var isUpdateAction = matches(store.UpdateState);
|
|
498
|
-
/** @type {?} */
|
|
499
433
|
var isInitOrUpdateAction = isInitAction || isUpdateAction;
|
|
500
|
-
/** @type {?} */
|
|
501
434
|
var hasMigration = false;
|
|
502
435
|
if (isInitOrUpdateAction) {
|
|
503
|
-
/** @type {?} */
|
|
504
436
|
var addedStates = isUpdateAction && event.addedStates;
|
|
505
437
|
var _loop_1 = function (key, engine) {
|
|
506
438
|
// We're checking what states have been added by NGXS and if any of these states should be handled by
|
|
@@ -513,23 +445,18 @@
|
|
|
513
445
|
// The state name should always go first. The below code checks if the `key` includes dot
|
|
514
446
|
// notation and extracts the state name out of the key.
|
|
515
447
|
// Given the `key` is `myState.myProperty`, the `addedStates` will only contain `myState`.
|
|
516
|
-
/** @type {?} */
|
|
517
448
|
var dotNotationIndex = key.indexOf(DOT);
|
|
518
|
-
/** @type {?} */
|
|
519
449
|
var stateName = dotNotationIndex > -1 ? key.slice(0, dotNotationIndex) : key;
|
|
520
450
|
if (!addedStates.hasOwnProperty(stateName)) {
|
|
521
451
|
return "continue";
|
|
522
452
|
}
|
|
523
453
|
}
|
|
524
|
-
/** @type {?} */
|
|
525
454
|
var storageKey = getStorageKey(key, this_1._options);
|
|
526
|
-
/** @type {?} */
|
|
527
455
|
var storedValue = engine.getItem(storageKey);
|
|
528
456
|
if (storedValue !== 'undefined' && storedValue != null) {
|
|
529
457
|
try {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
storedValue = (/** @type {?} */ (this_1._options.afterDeserialize))(newVal, key);
|
|
458
|
+
var newVal = this_1._options.deserialize(storedValue);
|
|
459
|
+
storedValue = this_1._options.afterDeserialize(newVal, key);
|
|
533
460
|
}
|
|
534
461
|
catch (_a) {
|
|
535
462
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
@@ -540,20 +467,14 @@
|
|
|
540
467
|
storedValue = {};
|
|
541
468
|
}
|
|
542
469
|
if (this_1._options.migrations) {
|
|
543
|
-
this_1._options.migrations.forEach((
|
|
544
|
-
* @param {?} strategy
|
|
545
|
-
* @return {?}
|
|
546
|
-
*/
|
|
547
|
-
function (strategy) {
|
|
548
|
-
/** @type {?} */
|
|
470
|
+
this_1._options.migrations.forEach(function (strategy) {
|
|
549
471
|
var versionMatch = strategy.version === store.getValue(storedValue, strategy.versionKey || 'version');
|
|
550
|
-
/** @type {?} */
|
|
551
472
|
var keyMatch = (!strategy.key && _this._usesDefaultStateKey) || strategy.key === key;
|
|
552
473
|
if (versionMatch && keyMatch) {
|
|
553
474
|
storedValue = strategy.migrate(storedValue);
|
|
554
475
|
hasMigration = true;
|
|
555
476
|
}
|
|
556
|
-
})
|
|
477
|
+
});
|
|
557
478
|
}
|
|
558
479
|
if (!this_1._usesDefaultStateKey) {
|
|
559
480
|
state = store.setValue(state, key, storedValue);
|
|
@@ -569,12 +490,7 @@
|
|
|
569
490
|
// The storage plugin will re-hydrate the whole state when the `RouterState` is registered,
|
|
570
491
|
// and the `counter` state will again equal `10` (not `999`).
|
|
571
492
|
if (storedValue && addedStates && Object.keys(addedStates).length > 0) {
|
|
572
|
-
storedValue = Object.keys(addedStates).reduce((
|
|
573
|
-
* @param {?} accumulator
|
|
574
|
-
* @param {?} addedState
|
|
575
|
-
* @return {?}
|
|
576
|
-
*/
|
|
577
|
-
function (accumulator, addedState) {
|
|
493
|
+
storedValue = Object.keys(addedStates).reduce(function (accumulator, addedState) {
|
|
578
494
|
// The `storedValue` may equal the whole state (when the default state key is used).
|
|
579
495
|
// If `addedStates` contains only `router` then we want to merge the state only
|
|
580
496
|
// with the `router` value.
|
|
@@ -586,48 +502,41 @@
|
|
|
586
502
|
accumulator[addedState] = storedValue[addedState];
|
|
587
503
|
}
|
|
588
504
|
return accumulator;
|
|
589
|
-
}
|
|
505
|
+
}, {});
|
|
590
506
|
}
|
|
591
|
-
state =
|
|
507
|
+
state = Object.assign(Object.assign({}, state), storedValue);
|
|
592
508
|
}
|
|
593
509
|
}
|
|
594
510
|
};
|
|
595
511
|
var this_1 = this;
|
|
596
512
|
try {
|
|
597
|
-
for (var
|
|
598
|
-
var
|
|
513
|
+
for (var _c = __values(this._keysWithEngines), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
514
|
+
var _e = _d.value, key = _e.key, engine = _e.engine;
|
|
599
515
|
_loop_1(key, engine);
|
|
600
516
|
}
|
|
601
517
|
}
|
|
602
518
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
603
519
|
finally {
|
|
604
520
|
try {
|
|
605
|
-
if (
|
|
521
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
606
522
|
}
|
|
607
523
|
finally { if (e_1) throw e_1.error; }
|
|
608
524
|
}
|
|
609
525
|
}
|
|
610
|
-
return next(state, event).pipe(operators.tap((
|
|
611
|
-
|
|
612
|
-
* @return {?}
|
|
613
|
-
*/
|
|
614
|
-
function (nextState) {
|
|
615
|
-
var e_2, _a;
|
|
526
|
+
return next(state, event).pipe(operators.tap(function (nextState) {
|
|
527
|
+
var e_2, _b;
|
|
616
528
|
if (!isInitOrUpdateAction || (isInitOrUpdateAction && hasMigration)) {
|
|
617
529
|
try {
|
|
618
|
-
for (var
|
|
619
|
-
var
|
|
620
|
-
/** @type {?} */
|
|
530
|
+
for (var _c = __values(_this._keysWithEngines), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
531
|
+
var _e = _d.value, key = _e.key, engine = _e.engine;
|
|
621
532
|
var storedValue = nextState;
|
|
622
|
-
/** @type {?} */
|
|
623
533
|
var storageKey = getStorageKey(key, _this._options);
|
|
624
534
|
if (key !== DEFAULT_STATE_KEY) {
|
|
625
535
|
storedValue = store.getValue(nextState, key);
|
|
626
536
|
}
|
|
627
537
|
try {
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
engine.setItem(storageKey, (/** @type {?} */ (_this._options.serialize))(newStoredValue));
|
|
538
|
+
var newStoredValue = _this._options.beforeSerialize(storedValue, key);
|
|
539
|
+
engine.setItem(storageKey, _this._options.serialize(newStoredValue));
|
|
631
540
|
}
|
|
632
541
|
catch (error) {
|
|
633
542
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
@@ -648,66 +557,35 @@
|
|
|
648
557
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
649
558
|
finally {
|
|
650
559
|
try {
|
|
651
|
-
if (
|
|
560
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
652
561
|
}
|
|
653
562
|
finally { if (e_2) throw e_2.error; }
|
|
654
563
|
}
|
|
655
564
|
}
|
|
656
|
-
}))
|
|
565
|
+
}));
|
|
657
566
|
};
|
|
658
|
-
NgxsStoragePlugin.decorators = [
|
|
659
|
-
{ type: core.Injectable }
|
|
660
|
-
];
|
|
661
|
-
/** @nocollapse */
|
|
662
|
-
NgxsStoragePlugin.ctorParameters = function () { return [
|
|
663
|
-
{ type: undefined, decorators: [{ type: core.Inject, args: [FINAL_NGXS_STORAGE_PLUGIN_OPTIONS,] }] },
|
|
664
|
-
{ type: String, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] }
|
|
665
|
-
]; };
|
|
666
567
|
return NgxsStoragePlugin;
|
|
667
568
|
}());
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
* @private
|
|
682
|
-
*/
|
|
683
|
-
NgxsStoragePlugin.prototype._options;
|
|
684
|
-
/**
|
|
685
|
-
* @type {?}
|
|
686
|
-
* @private
|
|
687
|
-
*/
|
|
688
|
-
NgxsStoragePlugin.prototype._platformId;
|
|
689
|
-
}
|
|
690
|
-
/** @type {?} */
|
|
569
|
+
/** @nocollapse */ NgxsStoragePlugin.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsStoragePlugin, deps: [{ token: FINAL_NGXS_STORAGE_PLUGIN_OPTIONS }, { token: i0.PLATFORM_ID }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
570
|
+
/** @nocollapse */ NgxsStoragePlugin.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsStoragePlugin });
|
|
571
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsStoragePlugin, decorators: [{
|
|
572
|
+
type: i0.Injectable
|
|
573
|
+
}], ctorParameters: function () {
|
|
574
|
+
return [{ type: undefined, decorators: [{
|
|
575
|
+
type: i0.Inject,
|
|
576
|
+
args: [FINAL_NGXS_STORAGE_PLUGIN_OPTIONS]
|
|
577
|
+
}] }, { type: undefined, decorators: [{
|
|
578
|
+
type: i0.Inject,
|
|
579
|
+
args: [i0.PLATFORM_ID]
|
|
580
|
+
}] }];
|
|
581
|
+
} });
|
|
691
582
|
var DOT = '.';
|
|
692
583
|
|
|
693
|
-
|
|
694
|
-
* @fileoverview added by tsickle
|
|
695
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
696
|
-
*/
|
|
697
|
-
/** @type {?} */
|
|
698
|
-
var USER_OPTIONS = new core.InjectionToken('USER_OPTIONS');
|
|
584
|
+
var USER_OPTIONS = new i0.InjectionToken('USER_OPTIONS');
|
|
699
585
|
var NgxsStoragePluginModule = /** @class */ (function () {
|
|
700
586
|
function NgxsStoragePluginModule() {
|
|
701
587
|
}
|
|
702
|
-
|
|
703
|
-
* @param {?=} options
|
|
704
|
-
* @return {?}
|
|
705
|
-
*/
|
|
706
|
-
NgxsStoragePluginModule.forRoot = /**
|
|
707
|
-
* @param {?=} options
|
|
708
|
-
* @return {?}
|
|
709
|
-
*/
|
|
710
|
-
function (options) {
|
|
588
|
+
NgxsStoragePluginModule.forRoot = function (options) {
|
|
711
589
|
return {
|
|
712
590
|
ngModule: NgxsStoragePluginModule,
|
|
713
591
|
providers: [
|
|
@@ -728,54 +606,48 @@
|
|
|
728
606
|
{
|
|
729
607
|
provide: STORAGE_ENGINE,
|
|
730
608
|
useFactory: engineFactory,
|
|
731
|
-
deps: [NGXS_STORAGE_PLUGIN_OPTIONS,
|
|
609
|
+
deps: [NGXS_STORAGE_PLUGIN_OPTIONS, i0.PLATFORM_ID]
|
|
732
610
|
},
|
|
733
611
|
{
|
|
734
612
|
provide: FINAL_NGXS_STORAGE_PLUGIN_OPTIONS,
|
|
735
613
|
useFactory: createFinalStoragePluginOptions,
|
|
736
|
-
deps: [
|
|
614
|
+
deps: [i0.Injector, NGXS_STORAGE_PLUGIN_OPTIONS]
|
|
737
615
|
}
|
|
738
616
|
]
|
|
739
617
|
};
|
|
740
618
|
};
|
|
741
|
-
NgxsStoragePluginModule.decorators = [
|
|
742
|
-
{ type: core.NgModule }
|
|
743
|
-
];
|
|
744
619
|
return NgxsStoragePluginModule;
|
|
745
620
|
}());
|
|
621
|
+
/** @nocollapse */ NgxsStoragePluginModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsStoragePluginModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
622
|
+
/** @nocollapse */ NgxsStoragePluginModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsStoragePluginModule });
|
|
623
|
+
/** @nocollapse */ NgxsStoragePluginModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsStoragePluginModule });
|
|
624
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsStoragePluginModule, decorators: [{
|
|
625
|
+
type: i0.NgModule
|
|
626
|
+
}] });
|
|
746
627
|
|
|
747
|
-
|
|
748
|
-
* @fileoverview added by tsickle
|
|
749
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
750
|
-
*/
|
|
751
|
-
/** @type {?} */
|
|
752
|
-
var LOCAL_STORAGE_ENGINE = new core.InjectionToken('LOCAL_STORAGE_ENGINE', {
|
|
628
|
+
var LOCAL_STORAGE_ENGINE = new i0.InjectionToken('LOCAL_STORAGE_ENGINE', {
|
|
753
629
|
providedIn: 'root',
|
|
754
|
-
factory: (
|
|
755
|
-
* @return {?}
|
|
756
|
-
*/
|
|
757
|
-
function () { return localStorage; })
|
|
630
|
+
factory: function () { return localStorage; }
|
|
758
631
|
});
|
|
759
|
-
|
|
760
|
-
var SESSION_STORAGE_ENGINE = new core.InjectionToken('SESSION_STORAGE_ENGINE', {
|
|
632
|
+
var SESSION_STORAGE_ENGINE = new i0.InjectionToken('SESSION_STORAGE_ENGINE', {
|
|
761
633
|
providedIn: 'root',
|
|
762
|
-
factory: (
|
|
763
|
-
* @return {?}
|
|
764
|
-
*/
|
|
765
|
-
function () { return sessionStorage; })
|
|
634
|
+
factory: function () { return sessionStorage; }
|
|
766
635
|
});
|
|
767
636
|
|
|
637
|
+
/**
|
|
638
|
+
* The public api for consumers of @ngxs/storage-plugin
|
|
639
|
+
*/
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Generated bundle index. Do not edit.
|
|
643
|
+
*/
|
|
644
|
+
|
|
768
645
|
exports.LOCAL_STORAGE_ENGINE = LOCAL_STORAGE_ENGINE;
|
|
769
646
|
exports.NGXS_STORAGE_PLUGIN_OPTIONS = NGXS_STORAGE_PLUGIN_OPTIONS;
|
|
770
647
|
exports.NgxsStoragePlugin = NgxsStoragePlugin;
|
|
771
648
|
exports.NgxsStoragePluginModule = NgxsStoragePluginModule;
|
|
772
649
|
exports.SESSION_STORAGE_ENGINE = SESSION_STORAGE_ENGINE;
|
|
773
650
|
exports.STORAGE_ENGINE = STORAGE_ENGINE;
|
|
774
|
-
exports.ɵa = USER_OPTIONS;
|
|
775
|
-
exports.ɵc = FINAL_NGXS_STORAGE_PLUGIN_OPTIONS;
|
|
776
|
-
exports.ɵd = createFinalStoragePluginOptions;
|
|
777
|
-
exports.ɵe = storageOptionsFactory;
|
|
778
|
-
exports.ɵf = engineFactory;
|
|
779
651
|
|
|
780
652
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
781
653
|
|