@ngxs/storage-plugin 3.7.6 → 3.8.0-dev.master-743a236
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 +467 -499
- package/bundles/ngxs-storage-plugin.umd.js.map +1 -1
- package/esm2015/index.js +2 -6
- package/esm2015/ngxs-storage-plugin.js +2 -8
- package/esm2015/src/engines.js +10 -0
- package/esm2015/src/internals/final-options.js +16 -0
- package/esm2015/src/internals/storage-key.js +21 -0
- package/esm2015/src/internals.js +9 -58
- package/esm2015/src/public_api.js +3 -6
- package/esm2015/src/storage.module.js +16 -15
- package/esm2015/src/storage.plugin.js +41 -109
- package/esm2015/src/symbols.js +2 -91
- package/fesm2015/ngxs-storage-plugin.js +103 -273
- package/fesm2015/ngxs-storage-plugin.js.map +1 -1
- package/ngxs-storage-plugin.d.ts +1 -2
- package/package.json +5 -8
- package/src/engines.d.ts +4 -0
- package/src/internals/final-options.d.ts +10 -0
- package/src/internals/storage-key.d.ts +17 -0
- package/src/internals.d.ts +3 -9
- package/src/public_api.d.ts +1 -0
- package/src/storage.module.d.ts +5 -1
- package/src/storage.plugin.d.ts +6 -4
- package/src/symbols.d.ts +10 -4
- 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 -11
- package/esm5/src/internals.js +0 -77
- package/esm5/src/public_api.js +0 -8
- package/esm5/src/storage.module.js +0 -55
- package/esm5/src/storage.plugin.js +0 -244
- package/esm5/src/symbols.js +0 -93
- package/fesm5/ngxs-storage-plugin.js +0 -473
- package/fesm5/ngxs-storage-plugin.js.map +0 -1
- package/ngxs-storage-plugin.metadata.json +0 -1
|
@@ -1,380 +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
|
-
* Storage engine to use. Deaults to localStorage but can provide
|
|
247
|
-
*
|
|
248
|
-
* sessionStorage or custom implementation of the StorageEngine interface
|
|
249
|
-
* @type {?|undefined}
|
|
250
|
-
*/
|
|
251
|
-
NgxsStoragePluginOptions.prototype.storage;
|
|
252
|
-
/**
|
|
253
|
-
* Migration strategies.
|
|
254
|
-
* @type {?|undefined}
|
|
255
|
-
*/
|
|
256
|
-
NgxsStoragePluginOptions.prototype.migrations;
|
|
257
|
-
/**
|
|
258
|
-
* Serailizer for the object before its pushed into the engine.
|
|
259
|
-
* @param {?} obj
|
|
260
|
-
* @return {?}
|
|
261
|
-
*/
|
|
262
|
-
NgxsStoragePluginOptions.prototype.serialize = function (obj) { };
|
|
263
|
-
/**
|
|
264
|
-
* Deserializer for the object before its pulled out of the engine.
|
|
265
|
-
* @param {?} obj
|
|
266
|
-
* @return {?}
|
|
267
|
-
*/
|
|
268
|
-
NgxsStoragePluginOptions.prototype.deserialize = function (obj) { };
|
|
269
|
-
/**
|
|
270
|
-
* Method to alter object before serialization.
|
|
271
|
-
* @param {?} obj
|
|
272
|
-
* @param {?} key
|
|
273
|
-
* @return {?}
|
|
274
|
-
*/
|
|
275
|
-
NgxsStoragePluginOptions.prototype.beforeSerialize = function (obj, key) { };
|
|
276
|
-
/**
|
|
277
|
-
* Method to alter object after deserialization.
|
|
278
|
-
* @param {?} obj
|
|
279
|
-
* @param {?} key
|
|
280
|
-
* @return {?}
|
|
281
|
-
*/
|
|
282
|
-
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 __());
|
|
283
59
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
* @param {?} key
|
|
308
|
-
* @return {?}
|
|
309
|
-
*/
|
|
310
|
-
StorageEngine.prototype.removeItem = function (key) { };
|
|
311
|
-
/**
|
|
312
|
-
* @return {?}
|
|
313
|
-
*/
|
|
314
|
-
StorageEngine.prototype.clear = function () { };
|
|
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;
|
|
315
83
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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);
|
|
340
229
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
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;
|
|
351
241
|
}
|
|
352
|
-
|
|
353
|
-
|
|
242
|
+
}
|
|
243
|
+
return ar;
|
|
354
244
|
}
|
|
355
|
-
/**
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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));
|
|
362
283
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
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; }
|
|
372
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);
|
|
355
|
+
}
|
|
356
|
+
|
|
373
357
|
/**
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
* @return {?}
|
|
358
|
+
* The following key is used to store the entire serialized
|
|
359
|
+
* state when there's no specific state provided.
|
|
377
360
|
*/
|
|
361
|
+
var DEFAULT_STATE_KEY = '@@STATE';
|
|
362
|
+
function storageOptionsFactory(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);
|
|
364
|
+
}
|
|
378
365
|
function engineFactory(options, platformId) {
|
|
379
366
|
if (common.isPlatformServer(platformId)) {
|
|
380
367
|
return null;
|
|
@@ -387,54 +374,67 @@
|
|
|
387
374
|
}
|
|
388
375
|
return null;
|
|
389
376
|
}
|
|
377
|
+
function getStorageKey(key, options) {
|
|
378
|
+
// Prepends the `namespace` option to any key if it's been provided by a user.
|
|
379
|
+
// So `@@STATE` becomes `my-app:@@STATE`.
|
|
380
|
+
return options && options.namespace ? options.namespace + ":" + key : key;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/** Determines whether the provided key has the following structure. */
|
|
384
|
+
function isKeyWithExplicitEngine(key) {
|
|
385
|
+
return key != null && !!key.engine;
|
|
386
|
+
}
|
|
387
|
+
/** This symbol is used to store the metadata on state classes. */
|
|
388
|
+
var META_OPTIONS_KEY = 'NGXS_OPTIONS_META';
|
|
389
|
+
function exctractStringKey(storageKey) {
|
|
390
|
+
// Extract the actual key out of the `{ key, engine }` structure.
|
|
391
|
+
if (isKeyWithExplicitEngine(storageKey)) {
|
|
392
|
+
storageKey = storageKey.key;
|
|
393
|
+
}
|
|
394
|
+
// Given the `storageKey` is a class, for instance, `AuthState`.
|
|
395
|
+
// We should retrieve its metadata and the `name` property.
|
|
396
|
+
// The `name` property might be a string (state name) or a state token.
|
|
397
|
+
if (storageKey.hasOwnProperty(META_OPTIONS_KEY)) {
|
|
398
|
+
storageKey = storageKey[META_OPTIONS_KEY].name;
|
|
399
|
+
}
|
|
400
|
+
return storageKey instanceof store.StateToken ? storageKey.getName() : storageKey;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
var FINAL_NGXS_STORAGE_PLUGIN_OPTIONS = new i0.InjectionToken('FINAL_NGXS_STORAGE_PLUGIN_OPTIONS');
|
|
404
|
+
function createFinalStoragePluginOptions(injector, options) {
|
|
405
|
+
var storageKeys = Array.isArray(options.key) ? options.key : [options.key];
|
|
406
|
+
var keysWithEngines = storageKeys.map(function (storageKey) {
|
|
407
|
+
var key = exctractStringKey(storageKey);
|
|
408
|
+
var engine = isKeyWithExplicitEngine(storageKey)
|
|
409
|
+
? injector.get(storageKey.engine)
|
|
410
|
+
: injector.get(STORAGE_ENGINE);
|
|
411
|
+
return { key: key, engine: engine };
|
|
412
|
+
});
|
|
413
|
+
return Object.assign(Object.assign({}, options), { keysWithEngines: keysWithEngines });
|
|
414
|
+
}
|
|
390
415
|
|
|
391
|
-
/**
|
|
392
|
-
* @fileoverview added by tsickle
|
|
393
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
394
|
-
*/
|
|
395
416
|
var NgxsStoragePlugin = /** @class */ (function () {
|
|
396
|
-
function NgxsStoragePlugin(_options,
|
|
417
|
+
function NgxsStoragePlugin(_options, _platformId) {
|
|
397
418
|
this._options = _options;
|
|
398
|
-
this._engine = _engine;
|
|
399
419
|
this._platformId = _platformId;
|
|
400
|
-
|
|
401
|
-
// transformed by the `storageOptionsFactory` function that provided token.
|
|
402
|
-
this._keys = (/** @type {?} */ (this._options.key));
|
|
420
|
+
this._keysWithEngines = this._options.keysWithEngines;
|
|
403
421
|
// We default to `[DEFAULT_STATE_KEY]` if the user explicitly does not provide the `key` option.
|
|
404
|
-
this._usesDefaultStateKey = this.
|
|
422
|
+
this._usesDefaultStateKey = this._keysWithEngines.length === 1 && this._keysWithEngines[0].key === DEFAULT_STATE_KEY;
|
|
405
423
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
* @param {?} event
|
|
409
|
-
* @param {?} next
|
|
410
|
-
* @return {?}
|
|
411
|
-
*/
|
|
412
|
-
NgxsStoragePlugin.prototype.handle = /**
|
|
413
|
-
* @param {?} state
|
|
414
|
-
* @param {?} event
|
|
415
|
-
* @param {?} next
|
|
416
|
-
* @return {?}
|
|
417
|
-
*/
|
|
418
|
-
function (state, event, next) {
|
|
424
|
+
NgxsStoragePlugin.prototype.handle = function (state, event, next) {
|
|
425
|
+
var e_1, _b;
|
|
419
426
|
var _this = this;
|
|
420
|
-
|
|
421
|
-
if (common.isPlatformServer(this._platformId) && this._engine === null) {
|
|
427
|
+
if (common.isPlatformServer(this._platformId)) {
|
|
422
428
|
return next(state, event);
|
|
423
429
|
}
|
|
424
|
-
/** @type {?} */
|
|
425
430
|
var matches = store.actionMatcher(event);
|
|
426
|
-
/** @type {?} */
|
|
427
431
|
var isInitAction = matches(store.InitState);
|
|
428
|
-
/** @type {?} */
|
|
429
432
|
var isUpdateAction = matches(store.UpdateState);
|
|
430
|
-
/** @type {?} */
|
|
431
433
|
var isInitOrUpdateAction = isInitAction || isUpdateAction;
|
|
432
|
-
/** @type {?} */
|
|
433
434
|
var hasMigration = false;
|
|
434
435
|
if (isInitOrUpdateAction) {
|
|
435
|
-
/** @type {?} */
|
|
436
436
|
var addedStates = isUpdateAction && event.addedStates;
|
|
437
|
-
var _loop_1 = function (key) {
|
|
437
|
+
var _loop_1 = function (key, engine) {
|
|
438
438
|
// We're checking what states have been added by NGXS and if any of these states should be handled by
|
|
439
439
|
// the storage plugin. For instance, we only want to deserialize the `auth` state, NGXS has added
|
|
440
440
|
// the `user` state, the storage plugin will be rerun and will do redundant deserialization.
|
|
@@ -445,48 +445,39 @@
|
|
|
445
445
|
// The state name should always go first. The below code checks if the `key` includes dot
|
|
446
446
|
// notation and extracts the state name out of the key.
|
|
447
447
|
// Given the `key` is `myState.myProperty`, the `addedStates` will only contain `myState`.
|
|
448
|
-
/** @type {?} */
|
|
449
448
|
var dotNotationIndex = key.indexOf(DOT);
|
|
450
|
-
/** @type {?} */
|
|
451
449
|
var stateName = dotNotationIndex > -1 ? key.slice(0, dotNotationIndex) : key;
|
|
452
450
|
if (!addedStates.hasOwnProperty(stateName)) {
|
|
453
451
|
return "continue";
|
|
454
452
|
}
|
|
455
453
|
}
|
|
456
|
-
|
|
457
|
-
var storedValue =
|
|
454
|
+
var storageKey = getStorageKey(key, this_1._options);
|
|
455
|
+
var storedValue = engine.getItem(storageKey);
|
|
458
456
|
if (storedValue !== 'undefined' && storedValue != null) {
|
|
459
457
|
try {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
storedValue = (/** @type {?} */ (this_1._options.afterDeserialize))(newVal, key);
|
|
458
|
+
var newVal = this_1._options.deserialize(storedValue);
|
|
459
|
+
storedValue = this_1._options.afterDeserialize(newVal, key);
|
|
463
460
|
}
|
|
464
461
|
catch (_a) {
|
|
465
462
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
466
463
|
// creating a breaking change for projects that still use the View Engine.
|
|
467
464
|
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
468
|
-
console.error("Error ocurred while deserializing the " +
|
|
465
|
+
console.error("Error ocurred while deserializing the " + storageKey + " store value, falling back to empty object, the value obtained from the store: ", storedValue);
|
|
469
466
|
}
|
|
470
467
|
storedValue = {};
|
|
471
468
|
}
|
|
472
469
|
if (this_1._options.migrations) {
|
|
473
|
-
this_1._options.migrations.forEach((
|
|
474
|
-
* @param {?} strategy
|
|
475
|
-
* @return {?}
|
|
476
|
-
*/
|
|
477
|
-
function (strategy) {
|
|
478
|
-
/** @type {?} */
|
|
470
|
+
this_1._options.migrations.forEach(function (strategy) {
|
|
479
471
|
var versionMatch = strategy.version === store.getValue(storedValue, strategy.versionKey || 'version');
|
|
480
|
-
/** @type {?} */
|
|
481
472
|
var keyMatch = (!strategy.key && _this._usesDefaultStateKey) || strategy.key === key;
|
|
482
473
|
if (versionMatch && keyMatch) {
|
|
483
474
|
storedValue = strategy.migrate(storedValue);
|
|
484
475
|
hasMigration = true;
|
|
485
476
|
}
|
|
486
|
-
})
|
|
477
|
+
});
|
|
487
478
|
}
|
|
488
479
|
if (!this_1._usesDefaultStateKey) {
|
|
489
|
-
state = store.setValue(state,
|
|
480
|
+
state = store.setValue(state, key, storedValue);
|
|
490
481
|
}
|
|
491
482
|
else {
|
|
492
483
|
// The `UpdateState` action is dispatched whenever the feature state is added.
|
|
@@ -499,12 +490,7 @@
|
|
|
499
490
|
// The storage plugin will re-hydrate the whole state when the `RouterState` is registered,
|
|
500
491
|
// and the `counter` state will again equal `10` (not `999`).
|
|
501
492
|
if (storedValue && addedStates && Object.keys(addedStates).length > 0) {
|
|
502
|
-
storedValue = Object.keys(addedStates).reduce((
|
|
503
|
-
* @param {?} accumulator
|
|
504
|
-
* @param {?} addedState
|
|
505
|
-
* @return {?}
|
|
506
|
-
*/
|
|
507
|
-
function (accumulator, addedState) {
|
|
493
|
+
storedValue = Object.keys(addedStates).reduce(function (accumulator, addedState) {
|
|
508
494
|
// The `storedValue` may equal the whole state (when the default state key is used).
|
|
509
495
|
// If `addedStates` contains only `router` then we want to merge the state only
|
|
510
496
|
// with the `router` value.
|
|
@@ -516,46 +502,41 @@
|
|
|
516
502
|
accumulator[addedState] = storedValue[addedState];
|
|
517
503
|
}
|
|
518
504
|
return accumulator;
|
|
519
|
-
}
|
|
505
|
+
}, {});
|
|
520
506
|
}
|
|
521
|
-
state =
|
|
507
|
+
state = Object.assign(Object.assign({}, state), storedValue);
|
|
522
508
|
}
|
|
523
509
|
}
|
|
524
510
|
};
|
|
525
511
|
var this_1 = this;
|
|
526
512
|
try {
|
|
527
|
-
for (var
|
|
528
|
-
var key =
|
|
529
|
-
_loop_1(key);
|
|
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;
|
|
515
|
+
_loop_1(key, engine);
|
|
530
516
|
}
|
|
531
517
|
}
|
|
532
518
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
533
519
|
finally {
|
|
534
520
|
try {
|
|
535
|
-
if (
|
|
521
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
536
522
|
}
|
|
537
523
|
finally { if (e_1) throw e_1.error; }
|
|
538
524
|
}
|
|
539
525
|
}
|
|
540
|
-
return next(state, event).pipe(operators.tap((
|
|
541
|
-
|
|
542
|
-
* @return {?}
|
|
543
|
-
*/
|
|
544
|
-
function (nextState) {
|
|
545
|
-
var e_2, _a;
|
|
526
|
+
return next(state, event).pipe(operators.tap(function (nextState) {
|
|
527
|
+
var e_2, _b;
|
|
546
528
|
if (!isInitOrUpdateAction || (isInitOrUpdateAction && hasMigration)) {
|
|
547
529
|
try {
|
|
548
|
-
for (var
|
|
549
|
-
var key =
|
|
550
|
-
|
|
551
|
-
var
|
|
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;
|
|
532
|
+
var storedValue = nextState;
|
|
533
|
+
var storageKey = getStorageKey(key, _this._options);
|
|
552
534
|
if (key !== DEFAULT_STATE_KEY) {
|
|
553
|
-
|
|
535
|
+
storedValue = store.getValue(nextState, key);
|
|
554
536
|
}
|
|
555
537
|
try {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
_this._engine.setItem((/** @type {?} */ (key)), (/** @type {?} */ (_this._options.serialize))(newVal));
|
|
538
|
+
var newStoredValue = _this._options.beforeSerialize(storedValue, key);
|
|
539
|
+
engine.setItem(storageKey, _this._options.serialize(newStoredValue));
|
|
559
540
|
}
|
|
560
541
|
catch (error) {
|
|
561
542
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
@@ -564,10 +545,10 @@
|
|
|
564
545
|
if (error &&
|
|
565
546
|
(error.name === 'QuotaExceededError' ||
|
|
566
547
|
error.name === 'NS_ERROR_DOM_QUOTA_REACHED')) {
|
|
567
|
-
console.error("The " +
|
|
548
|
+
console.error("The " + storageKey + " store value exceeds the browser storage quota: ", storedValue);
|
|
568
549
|
}
|
|
569
550
|
else {
|
|
570
|
-
console.error("Error ocurred while serializing the " +
|
|
551
|
+
console.error("Error ocurred while serializing the " + storageKey + " store value, value not updated, the value obtained from the store: ", storedValue);
|
|
571
552
|
}
|
|
572
553
|
}
|
|
573
554
|
}
|
|
@@ -576,72 +557,35 @@
|
|
|
576
557
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
577
558
|
finally {
|
|
578
559
|
try {
|
|
579
|
-
if (
|
|
560
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
580
561
|
}
|
|
581
562
|
finally { if (e_2) throw e_2.error; }
|
|
582
563
|
}
|
|
583
564
|
}
|
|
584
|
-
}))
|
|
565
|
+
}));
|
|
585
566
|
};
|
|
586
|
-
NgxsStoragePlugin.decorators = [
|
|
587
|
-
{ type: core.Injectable }
|
|
588
|
-
];
|
|
589
|
-
/** @nocollapse */
|
|
590
|
-
NgxsStoragePlugin.ctorParameters = function () { return [
|
|
591
|
-
{ type: undefined, decorators: [{ type: core.Inject, args: [NGXS_STORAGE_PLUGIN_OPTIONS,] }] },
|
|
592
|
-
{ type: undefined, decorators: [{ type: core.Inject, args: [STORAGE_ENGINE,] }] },
|
|
593
|
-
{ type: String, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] }
|
|
594
|
-
]; };
|
|
595
567
|
return NgxsStoragePlugin;
|
|
596
568
|
}());
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
* @private
|
|
611
|
-
*/
|
|
612
|
-
NgxsStoragePlugin.prototype._options;
|
|
613
|
-
/**
|
|
614
|
-
* @type {?}
|
|
615
|
-
* @private
|
|
616
|
-
*/
|
|
617
|
-
NgxsStoragePlugin.prototype._engine;
|
|
618
|
-
/**
|
|
619
|
-
* @type {?}
|
|
620
|
-
* @private
|
|
621
|
-
*/
|
|
622
|
-
NgxsStoragePlugin.prototype._platformId;
|
|
623
|
-
}
|
|
624
|
-
/** @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
|
+
} });
|
|
625
582
|
var DOT = '.';
|
|
626
583
|
|
|
627
|
-
|
|
628
|
-
* @fileoverview added by tsickle
|
|
629
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
630
|
-
*/
|
|
631
|
-
/** @type {?} */
|
|
632
|
-
var USER_OPTIONS = new core.InjectionToken('USER_OPTIONS');
|
|
584
|
+
var USER_OPTIONS = new i0.InjectionToken('USER_OPTIONS');
|
|
633
585
|
var NgxsStoragePluginModule = /** @class */ (function () {
|
|
634
586
|
function NgxsStoragePluginModule() {
|
|
635
587
|
}
|
|
636
|
-
|
|
637
|
-
* @param {?=} options
|
|
638
|
-
* @return {?}
|
|
639
|
-
*/
|
|
640
|
-
NgxsStoragePluginModule.forRoot = /**
|
|
641
|
-
* @param {?=} options
|
|
642
|
-
* @return {?}
|
|
643
|
-
*/
|
|
644
|
-
function (options) {
|
|
588
|
+
NgxsStoragePluginModule.forRoot = function (options) {
|
|
645
589
|
return {
|
|
646
590
|
ngModule: NgxsStoragePluginModule,
|
|
647
591
|
providers: [
|
|
@@ -662,24 +606,48 @@
|
|
|
662
606
|
{
|
|
663
607
|
provide: STORAGE_ENGINE,
|
|
664
608
|
useFactory: engineFactory,
|
|
665
|
-
deps: [NGXS_STORAGE_PLUGIN_OPTIONS,
|
|
609
|
+
deps: [NGXS_STORAGE_PLUGIN_OPTIONS, i0.PLATFORM_ID]
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
provide: FINAL_NGXS_STORAGE_PLUGIN_OPTIONS,
|
|
613
|
+
useFactory: createFinalStoragePluginOptions,
|
|
614
|
+
deps: [i0.Injector, NGXS_STORAGE_PLUGIN_OPTIONS]
|
|
666
615
|
}
|
|
667
616
|
]
|
|
668
617
|
};
|
|
669
618
|
};
|
|
670
|
-
NgxsStoragePluginModule.decorators = [
|
|
671
|
-
{ type: core.NgModule }
|
|
672
|
-
];
|
|
673
619
|
return NgxsStoragePluginModule;
|
|
674
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
|
+
}] });
|
|
627
|
+
|
|
628
|
+
var LOCAL_STORAGE_ENGINE = new i0.InjectionToken('LOCAL_STORAGE_ENGINE', {
|
|
629
|
+
providedIn: 'root',
|
|
630
|
+
factory: function () { return localStorage; }
|
|
631
|
+
});
|
|
632
|
+
var SESSION_STORAGE_ENGINE = new i0.InjectionToken('SESSION_STORAGE_ENGINE', {
|
|
633
|
+
providedIn: 'root',
|
|
634
|
+
factory: function () { return sessionStorage; }
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* The public api for consumers of @ngxs/storage-plugin
|
|
639
|
+
*/
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Generated bundle index. Do not edit.
|
|
643
|
+
*/
|
|
675
644
|
|
|
645
|
+
exports.LOCAL_STORAGE_ENGINE = LOCAL_STORAGE_ENGINE;
|
|
676
646
|
exports.NGXS_STORAGE_PLUGIN_OPTIONS = NGXS_STORAGE_PLUGIN_OPTIONS;
|
|
677
647
|
exports.NgxsStoragePlugin = NgxsStoragePlugin;
|
|
678
648
|
exports.NgxsStoragePluginModule = NgxsStoragePluginModule;
|
|
649
|
+
exports.SESSION_STORAGE_ENGINE = SESSION_STORAGE_ENGINE;
|
|
679
650
|
exports.STORAGE_ENGINE = STORAGE_ENGINE;
|
|
680
|
-
exports.ɵa = USER_OPTIONS;
|
|
681
|
-
exports.ɵb = storageOptionsFactory;
|
|
682
|
-
exports.ɵc = engineFactory;
|
|
683
651
|
|
|
684
652
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
685
653
|
|