@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,136 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, PLATFORM_ID, Injectable, Inject, Injector, NgModule } from '@angular/core';
|
|
2
3
|
import { StateToken, actionMatcher, InitState, UpdateState, getValue, setValue, NGXS_PLUGINS } from '@ngxs/store';
|
|
3
4
|
import { isPlatformServer } from '@angular/common';
|
|
4
5
|
import { tap } from 'rxjs/operators';
|
|
5
6
|
|
|
6
|
-
/**
|
|
7
|
-
* @fileoverview added by tsickle
|
|
8
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
9
|
-
*/
|
|
10
|
-
/** @enum {number} */
|
|
11
|
-
const StorageOption = {
|
|
12
|
-
LocalStorage: 0,
|
|
13
|
-
SessionStorage: 1,
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* @record
|
|
17
|
-
*/
|
|
18
|
-
function NgxsStoragePluginOptions() { }
|
|
19
|
-
if (false) {
|
|
20
|
-
/**
|
|
21
|
-
* Key for the state slice to store in the storage engine.
|
|
22
|
-
* @type {?|undefined}
|
|
23
|
-
*/
|
|
24
|
-
NgxsStoragePluginOptions.prototype.key;
|
|
25
|
-
/**
|
|
26
|
-
* The namespace is used to prefix the key for the state slice. This is
|
|
27
|
-
* necessary when running micro frontend applications which use storage plugin.
|
|
28
|
-
* The namespace will eliminate the conflict between keys that might overlap.
|
|
29
|
-
* @type {?|undefined}
|
|
30
|
-
*/
|
|
31
|
-
NgxsStoragePluginOptions.prototype.namespace;
|
|
32
|
-
/**
|
|
33
|
-
* Storage engine to use. Deaults to localStorage but can provide
|
|
34
|
-
*
|
|
35
|
-
* sessionStorage or custom implementation of the StorageEngine interface
|
|
36
|
-
* @type {?|undefined}
|
|
37
|
-
*/
|
|
38
|
-
NgxsStoragePluginOptions.prototype.storage;
|
|
39
|
-
/**
|
|
40
|
-
* Migration strategies.
|
|
41
|
-
* @type {?|undefined}
|
|
42
|
-
*/
|
|
43
|
-
NgxsStoragePluginOptions.prototype.migrations;
|
|
44
|
-
/**
|
|
45
|
-
* Serailizer for the object before its pushed into the engine.
|
|
46
|
-
* @param {?} obj
|
|
47
|
-
* @return {?}
|
|
48
|
-
*/
|
|
49
|
-
NgxsStoragePluginOptions.prototype.serialize = function (obj) { };
|
|
50
|
-
/**
|
|
51
|
-
* Deserializer for the object before its pulled out of the engine.
|
|
52
|
-
* @param {?} obj
|
|
53
|
-
* @return {?}
|
|
54
|
-
*/
|
|
55
|
-
NgxsStoragePluginOptions.prototype.deserialize = function (obj) { };
|
|
56
|
-
/**
|
|
57
|
-
* Method to alter object before serialization.
|
|
58
|
-
* @param {?} obj
|
|
59
|
-
* @param {?} key
|
|
60
|
-
* @return {?}
|
|
61
|
-
*/
|
|
62
|
-
NgxsStoragePluginOptions.prototype.beforeSerialize = function (obj, key) { };
|
|
63
|
-
/**
|
|
64
|
-
* Method to alter object after deserialization.
|
|
65
|
-
* @param {?} obj
|
|
66
|
-
* @param {?} key
|
|
67
|
-
* @return {?}
|
|
68
|
-
*/
|
|
69
|
-
NgxsStoragePluginOptions.prototype.afterDeserialize = function (obj, key) { };
|
|
70
|
-
}
|
|
71
|
-
/** @type {?} */
|
|
72
7
|
const NGXS_STORAGE_PLUGIN_OPTIONS = new InjectionToken('NGXS_STORAGE_PLUGIN_OPTIONS');
|
|
73
|
-
/** @type {?} */
|
|
74
8
|
const STORAGE_ENGINE = new InjectionToken('STORAGE_ENGINE');
|
|
75
|
-
/**
|
|
76
|
-
* @record
|
|
77
|
-
*/
|
|
78
|
-
function StorageEngine() { }
|
|
79
|
-
if (false) {
|
|
80
|
-
/** @type {?} */
|
|
81
|
-
StorageEngine.prototype.length;
|
|
82
|
-
/**
|
|
83
|
-
* @param {?} key
|
|
84
|
-
* @return {?}
|
|
85
|
-
*/
|
|
86
|
-
StorageEngine.prototype.getItem = function (key) { };
|
|
87
|
-
/**
|
|
88
|
-
* @param {?} key
|
|
89
|
-
* @param {?} val
|
|
90
|
-
* @return {?}
|
|
91
|
-
*/
|
|
92
|
-
StorageEngine.prototype.setItem = function (key, val) { };
|
|
93
|
-
/**
|
|
94
|
-
* @param {?} key
|
|
95
|
-
* @return {?}
|
|
96
|
-
*/
|
|
97
|
-
StorageEngine.prototype.removeItem = function (key) { };
|
|
98
|
-
/**
|
|
99
|
-
* @return {?}
|
|
100
|
-
*/
|
|
101
|
-
StorageEngine.prototype.clear = function () { };
|
|
102
|
-
}
|
|
103
9
|
|
|
104
|
-
/**
|
|
105
|
-
* @fileoverview added by tsickle
|
|
106
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
107
|
-
*/
|
|
108
10
|
/**
|
|
109
11
|
* The following key is used to store the entire serialized
|
|
110
12
|
* state when there's no specific state provided.
|
|
111
|
-
* @type {?}
|
|
112
13
|
*/
|
|
113
14
|
const DEFAULT_STATE_KEY = '@@STATE';
|
|
114
|
-
/**
|
|
115
|
-
* @param {?} options
|
|
116
|
-
* @return {?}
|
|
117
|
-
*/
|
|
118
15
|
function storageOptionsFactory(options) {
|
|
119
|
-
return Object.assign({ key: [DEFAULT_STATE_KEY], storage: 0 /* LocalStorage */, serialize: JSON.stringify, deserialize: JSON.parse, beforeSerialize:
|
|
120
|
-
* @param {?} obj
|
|
121
|
-
* @return {?}
|
|
122
|
-
*/
|
|
123
|
-
obj => obj), afterDeserialize: (/**
|
|
124
|
-
* @param {?} obj
|
|
125
|
-
* @return {?}
|
|
126
|
-
*/
|
|
127
|
-
obj => obj) }, options);
|
|
16
|
+
return Object.assign({ key: [DEFAULT_STATE_KEY], storage: 0 /* LocalStorage */, serialize: JSON.stringify, deserialize: JSON.parse, beforeSerialize: obj => obj, afterDeserialize: obj => obj }, options);
|
|
128
17
|
}
|
|
129
|
-
/**
|
|
130
|
-
* @param {?} options
|
|
131
|
-
* @param {?} platformId
|
|
132
|
-
* @return {?}
|
|
133
|
-
*/
|
|
134
18
|
function engineFactory(options, platformId) {
|
|
135
19
|
if (isPlatformServer(platformId)) {
|
|
136
20
|
return null;
|
|
@@ -143,49 +27,18 @@ function engineFactory(options, platformId) {
|
|
|
143
27
|
}
|
|
144
28
|
return null;
|
|
145
29
|
}
|
|
146
|
-
/**
|
|
147
|
-
* @param {?} key
|
|
148
|
-
* @param {?=} options
|
|
149
|
-
* @return {?}
|
|
150
|
-
*/
|
|
151
30
|
function getStorageKey(key, options) {
|
|
152
31
|
// Prepends the `namespace` option to any key if it's been provided by a user.
|
|
153
32
|
// So `@@STATE` becomes `my-app:@@STATE`.
|
|
154
33
|
return options && options.namespace ? `${options.namespace}:${key}` : key;
|
|
155
34
|
}
|
|
156
35
|
|
|
157
|
-
/**
|
|
158
|
-
* @fileoverview added by tsickle
|
|
159
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
160
|
-
*/
|
|
161
|
-
/**
|
|
162
|
-
* This enables the user to provide a storage engine per individual key.
|
|
163
|
-
* @record
|
|
164
|
-
*/
|
|
165
|
-
function KeyWithExplicitEngine() { }
|
|
166
|
-
if (false) {
|
|
167
|
-
/** @type {?} */
|
|
168
|
-
KeyWithExplicitEngine.prototype.key;
|
|
169
|
-
/** @type {?} */
|
|
170
|
-
KeyWithExplicitEngine.prototype.engine;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Determines whether the provided key has the following structure.
|
|
174
|
-
* @param {?} key
|
|
175
|
-
* @return {?}
|
|
176
|
-
*/
|
|
36
|
+
/** Determines whether the provided key has the following structure. */
|
|
177
37
|
function isKeyWithExplicitEngine(key) {
|
|
178
38
|
return key != null && !!key.engine;
|
|
179
39
|
}
|
|
180
|
-
/**
|
|
181
|
-
* This symbol is used to store the metadata on state classes.
|
|
182
|
-
* @type {?}
|
|
183
|
-
*/
|
|
40
|
+
/** This symbol is used to store the metadata on state classes. */
|
|
184
41
|
const META_OPTIONS_KEY = 'NGXS_OPTIONS_META';
|
|
185
|
-
/**
|
|
186
|
-
* @param {?} storageKey
|
|
187
|
-
* @return {?}
|
|
188
|
-
*/
|
|
189
42
|
function exctractStringKey(storageKey) {
|
|
190
43
|
// Extract the actual key out of the `{ key, engine }` structure.
|
|
191
44
|
if (isKeyWithExplicitEngine(storageKey)) {
|
|
@@ -195,59 +48,25 @@ function exctractStringKey(storageKey) {
|
|
|
195
48
|
// We should retrieve its metadata and the `name` property.
|
|
196
49
|
// The `name` property might be a string (state name) or a state token.
|
|
197
50
|
if (storageKey.hasOwnProperty(META_OPTIONS_KEY)) {
|
|
198
|
-
storageKey =
|
|
51
|
+
storageKey = storageKey[META_OPTIONS_KEY].name;
|
|
199
52
|
}
|
|
200
|
-
return storageKey instanceof StateToken ? storageKey.getName() :
|
|
53
|
+
return storageKey instanceof StateToken ? storageKey.getName() : storageKey;
|
|
201
54
|
}
|
|
202
55
|
|
|
203
|
-
/**
|
|
204
|
-
* @fileoverview added by tsickle
|
|
205
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
206
|
-
*/
|
|
207
|
-
/**
|
|
208
|
-
* @record
|
|
209
|
-
*/
|
|
210
|
-
function FinalNgxsStoragePluginOptions() { }
|
|
211
|
-
if (false) {
|
|
212
|
-
/** @type {?} */
|
|
213
|
-
FinalNgxsStoragePluginOptions.prototype.keysWithEngines;
|
|
214
|
-
}
|
|
215
|
-
/** @type {?} */
|
|
216
56
|
const FINAL_NGXS_STORAGE_PLUGIN_OPTIONS = new InjectionToken('FINAL_NGXS_STORAGE_PLUGIN_OPTIONS');
|
|
217
|
-
/**
|
|
218
|
-
* @param {?} injector
|
|
219
|
-
* @param {?} options
|
|
220
|
-
* @return {?}
|
|
221
|
-
*/
|
|
222
57
|
function createFinalStoragePluginOptions(injector, options) {
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
/** @type {?} */
|
|
226
|
-
const keysWithEngines = storageKeys.map((/**
|
|
227
|
-
* @param {?} storageKey
|
|
228
|
-
* @return {?}
|
|
229
|
-
*/
|
|
230
|
-
(storageKey) => {
|
|
231
|
-
/** @type {?} */
|
|
58
|
+
const storageKeys = Array.isArray(options.key) ? options.key : [options.key];
|
|
59
|
+
const keysWithEngines = storageKeys.map((storageKey) => {
|
|
232
60
|
const key = exctractStringKey(storageKey);
|
|
233
|
-
/** @type {?} */
|
|
234
61
|
const engine = isKeyWithExplicitEngine(storageKey)
|
|
235
62
|
? injector.get(storageKey.engine)
|
|
236
63
|
: injector.get(STORAGE_ENGINE);
|
|
237
64
|
return { key, engine };
|
|
238
|
-
})
|
|
239
|
-
return Object.assign({}, options, { keysWithEngines });
|
|
65
|
+
});
|
|
66
|
+
return Object.assign(Object.assign({}, options), { keysWithEngines });
|
|
240
67
|
}
|
|
241
68
|
|
|
242
|
-
/**
|
|
243
|
-
* @fileoverview added by tsickle
|
|
244
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
245
|
-
*/
|
|
246
69
|
class NgxsStoragePlugin {
|
|
247
|
-
/**
|
|
248
|
-
* @param {?} _options
|
|
249
|
-
* @param {?} _platformId
|
|
250
|
-
*/
|
|
251
70
|
constructor(_options, _platformId) {
|
|
252
71
|
this._options = _options;
|
|
253
72
|
this._platformId = _platformId;
|
|
@@ -255,28 +74,16 @@ class NgxsStoragePlugin {
|
|
|
255
74
|
// We default to `[DEFAULT_STATE_KEY]` if the user explicitly does not provide the `key` option.
|
|
256
75
|
this._usesDefaultStateKey = this._keysWithEngines.length === 1 && this._keysWithEngines[0].key === DEFAULT_STATE_KEY;
|
|
257
76
|
}
|
|
258
|
-
/**
|
|
259
|
-
* @param {?} state
|
|
260
|
-
* @param {?} event
|
|
261
|
-
* @param {?} next
|
|
262
|
-
* @return {?}
|
|
263
|
-
*/
|
|
264
77
|
handle(state, event, next) {
|
|
265
78
|
if (isPlatformServer(this._platformId)) {
|
|
266
79
|
return next(state, event);
|
|
267
80
|
}
|
|
268
|
-
/** @type {?} */
|
|
269
81
|
const matches = actionMatcher(event);
|
|
270
|
-
/** @type {?} */
|
|
271
82
|
const isInitAction = matches(InitState);
|
|
272
|
-
/** @type {?} */
|
|
273
83
|
const isUpdateAction = matches(UpdateState);
|
|
274
|
-
/** @type {?} */
|
|
275
84
|
const isInitOrUpdateAction = isInitAction || isUpdateAction;
|
|
276
|
-
/** @type {?} */
|
|
277
85
|
let hasMigration = false;
|
|
278
86
|
if (isInitOrUpdateAction) {
|
|
279
|
-
/** @type {?} */
|
|
280
87
|
const addedStates = isUpdateAction && event.addedStates;
|
|
281
88
|
for (const { key, engine } of this._keysWithEngines) {
|
|
282
89
|
// We're checking what states have been added by NGXS and if any of these states should be handled by
|
|
@@ -289,23 +96,18 @@ class NgxsStoragePlugin {
|
|
|
289
96
|
// The state name should always go first. The below code checks if the `key` includes dot
|
|
290
97
|
// notation and extracts the state name out of the key.
|
|
291
98
|
// Given the `key` is `myState.myProperty`, the `addedStates` will only contain `myState`.
|
|
292
|
-
/** @type {?} */
|
|
293
99
|
const dotNotationIndex = key.indexOf(DOT);
|
|
294
|
-
/** @type {?} */
|
|
295
100
|
const stateName = dotNotationIndex > -1 ? key.slice(0, dotNotationIndex) : key;
|
|
296
101
|
if (!addedStates.hasOwnProperty(stateName)) {
|
|
297
102
|
continue;
|
|
298
103
|
}
|
|
299
104
|
}
|
|
300
|
-
/** @type {?} */
|
|
301
105
|
const storageKey = getStorageKey(key, this._options);
|
|
302
|
-
/** @type {?} */
|
|
303
106
|
let storedValue = engine.getItem(storageKey);
|
|
304
107
|
if (storedValue !== 'undefined' && storedValue != null) {
|
|
305
108
|
try {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
storedValue = (/** @type {?} */ (this._options.afterDeserialize))(newVal, key);
|
|
109
|
+
const newVal = this._options.deserialize(storedValue);
|
|
110
|
+
storedValue = this._options.afterDeserialize(newVal, key);
|
|
309
111
|
}
|
|
310
112
|
catch (_a) {
|
|
311
113
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
@@ -316,20 +118,14 @@ class NgxsStoragePlugin {
|
|
|
316
118
|
storedValue = {};
|
|
317
119
|
}
|
|
318
120
|
if (this._options.migrations) {
|
|
319
|
-
this._options.migrations.forEach(
|
|
320
|
-
* @param {?} strategy
|
|
321
|
-
* @return {?}
|
|
322
|
-
*/
|
|
323
|
-
strategy => {
|
|
324
|
-
/** @type {?} */
|
|
121
|
+
this._options.migrations.forEach(strategy => {
|
|
325
122
|
const versionMatch = strategy.version === getValue(storedValue, strategy.versionKey || 'version');
|
|
326
|
-
/** @type {?} */
|
|
327
123
|
const keyMatch = (!strategy.key && this._usesDefaultStateKey) || strategy.key === key;
|
|
328
124
|
if (versionMatch && keyMatch) {
|
|
329
125
|
storedValue = strategy.migrate(storedValue);
|
|
330
126
|
hasMigration = true;
|
|
331
127
|
}
|
|
332
|
-
})
|
|
128
|
+
});
|
|
333
129
|
}
|
|
334
130
|
if (!this._usesDefaultStateKey) {
|
|
335
131
|
state = setValue(state, key, storedValue);
|
|
@@ -345,12 +141,7 @@ class NgxsStoragePlugin {
|
|
|
345
141
|
// The storage plugin will re-hydrate the whole state when the `RouterState` is registered,
|
|
346
142
|
// and the `counter` state will again equal `10` (not `999`).
|
|
347
143
|
if (storedValue && addedStates && Object.keys(addedStates).length > 0) {
|
|
348
|
-
storedValue = Object.keys(addedStates).reduce((
|
|
349
|
-
* @param {?} accumulator
|
|
350
|
-
* @param {?} addedState
|
|
351
|
-
* @return {?}
|
|
352
|
-
*/
|
|
353
|
-
(accumulator, addedState) => {
|
|
144
|
+
storedValue = Object.keys(addedStates).reduce((accumulator, addedState) => {
|
|
354
145
|
// The `storedValue` may equal the whole state (when the default state key is used).
|
|
355
146
|
// If `addedStates` contains only `router` then we want to merge the state only
|
|
356
147
|
// with the `router` value.
|
|
@@ -362,31 +153,24 @@ class NgxsStoragePlugin {
|
|
|
362
153
|
accumulator[addedState] = storedValue[addedState];
|
|
363
154
|
}
|
|
364
155
|
return accumulator;
|
|
365
|
-
}
|
|
156
|
+
}, {});
|
|
366
157
|
}
|
|
367
|
-
state = Object.assign({}, state, storedValue);
|
|
158
|
+
state = Object.assign(Object.assign({}, state), storedValue);
|
|
368
159
|
}
|
|
369
160
|
}
|
|
370
161
|
}
|
|
371
162
|
}
|
|
372
|
-
return next(state, event).pipe(tap(
|
|
373
|
-
* @param {?} nextState
|
|
374
|
-
* @return {?}
|
|
375
|
-
*/
|
|
376
|
-
nextState => {
|
|
163
|
+
return next(state, event).pipe(tap(nextState => {
|
|
377
164
|
if (!isInitOrUpdateAction || (isInitOrUpdateAction && hasMigration)) {
|
|
378
165
|
for (const { key, engine } of this._keysWithEngines) {
|
|
379
|
-
/** @type {?} */
|
|
380
166
|
let storedValue = nextState;
|
|
381
|
-
/** @type {?} */
|
|
382
167
|
const storageKey = getStorageKey(key, this._options);
|
|
383
168
|
if (key !== DEFAULT_STATE_KEY) {
|
|
384
169
|
storedValue = getValue(nextState, key);
|
|
385
170
|
}
|
|
386
171
|
try {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
engine.setItem(storageKey, (/** @type {?} */ (this._options.serialize))(newStoredValue));
|
|
172
|
+
const newStoredValue = this._options.beforeSerialize(storedValue, key);
|
|
173
|
+
engine.setItem(storageKey, this._options.serialize(newStoredValue));
|
|
390
174
|
}
|
|
391
175
|
catch (error) {
|
|
392
176
|
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
@@ -404,53 +188,24 @@ class NgxsStoragePlugin {
|
|
|
404
188
|
}
|
|
405
189
|
}
|
|
406
190
|
}
|
|
407
|
-
}))
|
|
191
|
+
}));
|
|
408
192
|
}
|
|
409
193
|
}
|
|
410
|
-
NgxsStoragePlugin
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
]
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
* @private
|
|
422
|
-
*/
|
|
423
|
-
NgxsStoragePlugin.prototype._keysWithEngines;
|
|
424
|
-
/**
|
|
425
|
-
* @type {?}
|
|
426
|
-
* @private
|
|
427
|
-
*/
|
|
428
|
-
NgxsStoragePlugin.prototype._usesDefaultStateKey;
|
|
429
|
-
/**
|
|
430
|
-
* @type {?}
|
|
431
|
-
* @private
|
|
432
|
-
*/
|
|
433
|
-
NgxsStoragePlugin.prototype._options;
|
|
434
|
-
/**
|
|
435
|
-
* @type {?}
|
|
436
|
-
* @private
|
|
437
|
-
*/
|
|
438
|
-
NgxsStoragePlugin.prototype._platformId;
|
|
439
|
-
}
|
|
440
|
-
/** @type {?} */
|
|
194
|
+
/** @nocollapse */ NgxsStoragePlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsStoragePlugin, deps: [{ token: FINAL_NGXS_STORAGE_PLUGIN_OPTIONS }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
195
|
+
/** @nocollapse */ NgxsStoragePlugin.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsStoragePlugin });
|
|
196
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsStoragePlugin, decorators: [{
|
|
197
|
+
type: Injectable
|
|
198
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
199
|
+
type: Inject,
|
|
200
|
+
args: [FINAL_NGXS_STORAGE_PLUGIN_OPTIONS]
|
|
201
|
+
}] }, { type: undefined, decorators: [{
|
|
202
|
+
type: Inject,
|
|
203
|
+
args: [PLATFORM_ID]
|
|
204
|
+
}] }]; } });
|
|
441
205
|
const DOT = '.';
|
|
442
206
|
|
|
443
|
-
/**
|
|
444
|
-
* @fileoverview added by tsickle
|
|
445
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
446
|
-
*/
|
|
447
|
-
/** @type {?} */
|
|
448
207
|
const USER_OPTIONS = new InjectionToken('USER_OPTIONS');
|
|
449
208
|
class NgxsStoragePluginModule {
|
|
450
|
-
/**
|
|
451
|
-
* @param {?=} options
|
|
452
|
-
* @return {?}
|
|
453
|
-
*/
|
|
454
209
|
static forRoot(options) {
|
|
455
210
|
return {
|
|
456
211
|
ngModule: NgxsStoragePluginModule,
|
|
@@ -483,45 +238,29 @@ class NgxsStoragePluginModule {
|
|
|
483
238
|
};
|
|
484
239
|
}
|
|
485
240
|
}
|
|
486
|
-
NgxsStoragePluginModule
|
|
487
|
-
|
|
488
|
-
|
|
241
|
+
/** @nocollapse */ NgxsStoragePluginModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsStoragePluginModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
242
|
+
/** @nocollapse */ NgxsStoragePluginModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsStoragePluginModule });
|
|
243
|
+
/** @nocollapse */ NgxsStoragePluginModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsStoragePluginModule });
|
|
244
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsStoragePluginModule, decorators: [{
|
|
245
|
+
type: NgModule
|
|
246
|
+
}] });
|
|
489
247
|
|
|
490
|
-
/**
|
|
491
|
-
* @fileoverview added by tsickle
|
|
492
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
493
|
-
*/
|
|
494
|
-
/** @type {?} */
|
|
495
248
|
const LOCAL_STORAGE_ENGINE = new InjectionToken('LOCAL_STORAGE_ENGINE', {
|
|
496
249
|
providedIn: 'root',
|
|
497
|
-
factory: (
|
|
498
|
-
* @return {?}
|
|
499
|
-
*/
|
|
500
|
-
() => localStorage)
|
|
250
|
+
factory: () => localStorage
|
|
501
251
|
});
|
|
502
|
-
/** @type {?} */
|
|
503
252
|
const SESSION_STORAGE_ENGINE = new InjectionToken('SESSION_STORAGE_ENGINE', {
|
|
504
253
|
providedIn: 'root',
|
|
505
|
-
factory: (
|
|
506
|
-
* @return {?}
|
|
507
|
-
*/
|
|
508
|
-
() => sessionStorage)
|
|
254
|
+
factory: () => sessionStorage
|
|
509
255
|
});
|
|
510
256
|
|
|
511
257
|
/**
|
|
512
|
-
*
|
|
513
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
514
|
-
*/
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* @fileoverview added by tsickle
|
|
518
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
258
|
+
* The public api for consumers of @ngxs/storage-plugin
|
|
519
259
|
*/
|
|
520
260
|
|
|
521
261
|
/**
|
|
522
|
-
*
|
|
523
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
262
|
+
* Generated bundle index. Do not edit.
|
|
524
263
|
*/
|
|
525
264
|
|
|
526
|
-
export { LOCAL_STORAGE_ENGINE, NGXS_STORAGE_PLUGIN_OPTIONS, NgxsStoragePlugin, NgxsStoragePluginModule, SESSION_STORAGE_ENGINE, STORAGE_ENGINE
|
|
265
|
+
export { LOCAL_STORAGE_ENGINE, NGXS_STORAGE_PLUGIN_OPTIONS, NgxsStoragePlugin, NgxsStoragePluginModule, SESSION_STORAGE_ENGINE, STORAGE_ENGINE };
|
|
527
266
|
//# sourceMappingURL=ngxs-storage-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-storage-plugin.js","sources":["ng://@ngxs/storage-plugin/src/symbols.ts","ng://@ngxs/storage-plugin/src/internals.ts","ng://@ngxs/storage-plugin/src/internals/storage-key.ts","ng://@ngxs/storage-plugin/src/internals/final-options.ts","ng://@ngxs/storage-plugin/src/storage.plugin.ts","ng://@ngxs/storage-plugin/src/storage.module.ts","ng://@ngxs/storage-plugin/src/engines.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nimport { StorageKey } from './internals/storage-key';\n\nexport const enum StorageOption {\n LocalStorage,\n SessionStorage\n}\n\nexport interface NgxsStoragePluginOptions {\n /**\n * Key for the state slice to store in the storage engine.\n */\n key?: undefined | StorageKey | StorageKey[];\n\n /**\n * The namespace is used to prefix the key for the state slice. This is\n * necessary when running micro frontend applications which use storage plugin.\n * The namespace will eliminate the conflict between keys that might overlap.\n */\n namespace?: string;\n\n /**\n * Storage engine to use. Deaults to localStorage but can provide\n *\n * sessionStorage or custom implementation of the StorageEngine interface\n */\n storage?: StorageOption;\n\n /**\n * Migration strategies.\n */\n migrations?: {\n /**\n * Version to key off.\n */\n version: number | string;\n\n /**\n * Method to migrate the previous state.\n */\n migrate: (state: any) => any;\n\n /**\n * Key to migrate.\n */\n key?: string;\n\n /**\n * Key for the version. Defaults to 'version'.\n */\n versionKey?: string;\n }[];\n\n /**\n * Serailizer for the object before its pushed into the engine.\n */\n serialize?(obj: any): string;\n\n /**\n * Deserializer for the object before its pulled out of the engine.\n */\n deserialize?(obj: any): any;\n\n /**\n * Method to alter object before serialization.\n */\n beforeSerialize?(obj: any, key: string): any;\n\n /**\n * Method to alter object after deserialization.\n */\n afterDeserialize?(obj: any, key: string): any;\n}\n\nexport const NGXS_STORAGE_PLUGIN_OPTIONS = new InjectionToken('NGXS_STORAGE_PLUGIN_OPTIONS');\n\nexport const STORAGE_ENGINE = new InjectionToken<StorageEngine>('STORAGE_ENGINE');\n\nexport interface StorageEngine {\n readonly length: number;\n getItem(key: string): any;\n setItem(key: string, val: any): void;\n removeItem(key: string): void;\n clear(): void;\n}\n","import { isPlatformServer } from '@angular/common';\n\nimport { StorageOption, StorageEngine, NgxsStoragePluginOptions } from './symbols';\n\n/**\n * The following key is used to store the entire serialized\n * state when there's no specific state provided.\n */\nexport const DEFAULT_STATE_KEY = '@@STATE';\n\nexport function storageOptionsFactory(\n options: NgxsStoragePluginOptions | undefined\n): NgxsStoragePluginOptions {\n return {\n key: [DEFAULT_STATE_KEY],\n storage: StorageOption.LocalStorage,\n serialize: JSON.stringify,\n deserialize: JSON.parse,\n beforeSerialize: obj => obj,\n afterDeserialize: obj => obj,\n ...options\n };\n}\n\nexport function engineFactory(\n options: NgxsStoragePluginOptions,\n platformId: string\n): StorageEngine | null {\n if (isPlatformServer(platformId)) {\n return null;\n }\n\n if (options.storage === StorageOption.LocalStorage) {\n return localStorage;\n } else if (options.storage === StorageOption.SessionStorage) {\n return sessionStorage;\n }\n\n return null;\n}\n\nexport function getStorageKey(key: string, options?: NgxsStoragePluginOptions): string {\n // Prepends the `namespace` option to any key if it's been provided by a user.\n // So `@@STATE` becomes `my-app:@@STATE`.\n return options && options.namespace ? `${options.namespace}:${key}` : key;\n}\n","import { InjectionToken, Type } from '@angular/core';\nimport { StateToken } from '@ngxs/store';\nimport { StateClass } from '@ngxs/store/internals';\n\nimport { StorageEngine } from '../symbols';\n\n/** This enables the user to provide a storage engine per individual key. */\nexport interface KeyWithExplicitEngine {\n key: string | StateClass | StateToken<any>;\n engine: Type<StorageEngine> | InjectionToken<StorageEngine>;\n}\n\n/** Determines whether the provided key has the following structure. */\nexport function isKeyWithExplicitEngine(key: any): key is KeyWithExplicitEngine {\n return key != null && !!key.engine;\n}\n\n/**\n * This tuples all of the possible types allowed in the `key` property.\n * This is not exposed publicly and used internally only.\n */\nexport type StorageKey = string | StateClass | StateToken<any> | KeyWithExplicitEngine;\n\n/** This symbol is used to store the metadata on state classes. */\nconst META_OPTIONS_KEY = 'NGXS_OPTIONS_META';\nexport function exctractStringKey(storageKey: StorageKey): string {\n // Extract the actual key out of the `{ key, engine }` structure.\n if (isKeyWithExplicitEngine(storageKey)) {\n storageKey = storageKey.key;\n }\n\n // Given the `storageKey` is a class, for instance, `AuthState`.\n // We should retrieve its metadata and the `name` property.\n // The `name` property might be a string (state name) or a state token.\n if (storageKey.hasOwnProperty(META_OPTIONS_KEY)) {\n storageKey = (storageKey as any)[META_OPTIONS_KEY].name;\n }\n\n return storageKey instanceof StateToken ? storageKey.getName() : <string>storageKey;\n}\n","import { InjectionToken, Injector } from '@angular/core';\n\nimport { exctractStringKey, isKeyWithExplicitEngine, StorageKey } from './storage-key';\nimport { NgxsStoragePluginOptions, StorageEngine, STORAGE_ENGINE } from '../symbols';\n\nexport interface FinalNgxsStoragePluginOptions extends NgxsStoragePluginOptions {\n keysWithEngines: {\n key: string;\n engine: StorageEngine;\n }[];\n}\n\nexport const FINAL_NGXS_STORAGE_PLUGIN_OPTIONS = new InjectionToken<\n FinalNgxsStoragePluginOptions\n>('FINAL_NGXS_STORAGE_PLUGIN_OPTIONS');\n\nexport function createFinalStoragePluginOptions(\n injector: Injector,\n options: NgxsStoragePluginOptions\n): FinalNgxsStoragePluginOptions {\n const storageKeys: StorageKey[] = Array.isArray(options.key) ? options.key : [options.key!];\n\n const keysWithEngines = storageKeys.map((storageKey: StorageKey) => {\n const key = exctractStringKey(storageKey);\n const engine = isKeyWithExplicitEngine(storageKey)\n ? injector.get(storageKey.engine)\n : injector.get(STORAGE_ENGINE);\n return { key, engine };\n });\n\n return {\n ...options,\n keysWithEngines\n };\n}\n","import { PLATFORM_ID, Inject, Injectable } from '@angular/core';\nimport { isPlatformServer } from '@angular/common';\nimport { PlainObject } from '@ngxs/store/internals';\nimport {\n NgxsPlugin,\n setValue,\n getValue,\n InitState,\n UpdateState,\n actionMatcher,\n NgxsNextPluginFn\n} from '@ngxs/store';\nimport { tap } from 'rxjs/operators';\n\nimport { DEFAULT_STATE_KEY, getStorageKey } from './internals';\nimport {\n FinalNgxsStoragePluginOptions,\n FINAL_NGXS_STORAGE_PLUGIN_OPTIONS\n} from './internals/final-options';\n\n/**\n * @description Will be provided through Terser global definitions by Angular CLI\n * during the production build. This is how Angular does tree-shaking internally.\n */\ndeclare const ngDevMode: boolean;\n\n@Injectable()\nexport class NgxsStoragePlugin implements NgxsPlugin {\n private _keysWithEngines = this._options.keysWithEngines;\n // We default to `[DEFAULT_STATE_KEY]` if the user explicitly does not provide the `key` option.\n private _usesDefaultStateKey =\n this._keysWithEngines.length === 1 && this._keysWithEngines[0].key === DEFAULT_STATE_KEY;\n\n constructor(\n @Inject(FINAL_NGXS_STORAGE_PLUGIN_OPTIONS) private _options: FinalNgxsStoragePluginOptions,\n @Inject(PLATFORM_ID) private _platformId: string\n ) {}\n\n handle(state: any, event: any, next: NgxsNextPluginFn) {\n if (isPlatformServer(this._platformId)) {\n return next(state, event);\n }\n\n const matches = actionMatcher(event);\n const isInitAction = matches(InitState);\n const isUpdateAction = matches(UpdateState);\n const isInitOrUpdateAction = isInitAction || isUpdateAction;\n let hasMigration = false;\n\n if (isInitOrUpdateAction) {\n const addedStates = isUpdateAction && event.addedStates;\n\n for (const { key, engine } of this._keysWithEngines) {\n // We're checking what states have been added by NGXS and if any of these states should be handled by\n // the storage plugin. For instance, we only want to deserialize the `auth` state, NGXS has added\n // the `user` state, the storage plugin will be rerun and will do redundant deserialization.\n // `usesDefaultStateKey` is necessary to check since `event.addedStates` never contains `@@STATE`.\n if (!this._usesDefaultStateKey && addedStates) {\n // We support providing keys that can be deeply nested via dot notation, for instance,\n // `keys: ['myState.myProperty']` is a valid key.\n // The state name should always go first. The below code checks if the `key` includes dot\n // notation and extracts the state name out of the key.\n // Given the `key` is `myState.myProperty`, the `addedStates` will only contain `myState`.\n const dotNotationIndex = key.indexOf(DOT);\n const stateName = dotNotationIndex > -1 ? key.slice(0, dotNotationIndex) : key;\n if (!addedStates.hasOwnProperty(stateName)) {\n continue;\n }\n }\n\n const storageKey = getStorageKey(key, this._options);\n let storedValue: any = engine.getItem(storageKey);\n\n if (storedValue !== 'undefined' && storedValue != null) {\n try {\n const newVal = this._options.deserialize!(storedValue);\n storedValue = this._options.afterDeserialize!(newVal, key);\n } catch {\n // Caretaker note: we have still left the `typeof` condition in order to avoid\n // creating a breaking change for projects that still use the View Engine.\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n console.error(\n `Error ocurred while deserializing the ${storageKey} store value, falling back to empty object, the value obtained from the store: `,\n storedValue\n );\n }\n storedValue = {};\n }\n\n if (this._options.migrations) {\n this._options.migrations.forEach(strategy => {\n const versionMatch =\n strategy.version === getValue(storedValue, strategy.versionKey || 'version');\n const keyMatch =\n (!strategy.key && this._usesDefaultStateKey) || strategy.key === key;\n if (versionMatch && keyMatch) {\n storedValue = strategy.migrate(storedValue);\n hasMigration = true;\n }\n });\n }\n\n if (!this._usesDefaultStateKey) {\n state = setValue(state, key, storedValue);\n } else {\n // The `UpdateState` action is dispatched whenever the feature state is added.\n // The below condition is met only when the `UpdateState` is dispatched.\n // Let's assume that we have 2 states `counter` and `@ngxs/router-plugin` state.\n // `CounterState` is provided on the root level when calling `NgxsModule.forRoot()`\n // and `@ngxs/router-plugin` is provided as a feature state.\n // The storage plugin may save the `counter` state value as `10` before.\n // The `CounterState` may implement the `ngxsOnInit` hook and call `ctx.setState(999)`.\n // The storage plugin will re-hydrate the whole state when the `RouterState` is registered,\n // and the `counter` state will again equal `10` (not `999`).\n if (storedValue && addedStates && Object.keys(addedStates).length > 0) {\n storedValue = Object.keys(addedStates).reduce((accumulator, addedState) => {\n // The `storedValue` may equal the whole state (when the default state key is used).\n // If `addedStates` contains only `router` then we want to merge the state only\n // with the `router` value.\n // Let's assume that the `storedValue` is an object:\n // `{ counter: 10, router: {...} }`\n // This will pick only the `router` object from the `storedValue` and `counter`\n // state will not be re-hydrated unnecessary.\n if (storedValue.hasOwnProperty(addedState)) {\n accumulator[addedState] = storedValue[addedState];\n }\n return accumulator;\n }, <PlainObject>{});\n }\n\n state = { ...state, ...storedValue };\n }\n }\n }\n }\n\n return next(state, event).pipe(\n tap(nextState => {\n if (!isInitOrUpdateAction || (isInitOrUpdateAction && hasMigration)) {\n for (const { key, engine } of this._keysWithEngines) {\n let storedValue = nextState;\n\n const storageKey = getStorageKey(key, this._options);\n\n if (key !== DEFAULT_STATE_KEY) {\n storedValue = getValue(nextState, key);\n }\n\n try {\n const newStoredValue = this._options.beforeSerialize!(storedValue, key);\n engine.setItem(storageKey, this._options.serialize!(newStoredValue));\n } catch (error) {\n // Caretaker note: we have still left the `typeof` condition in order to avoid\n // creating a breaking change for projects that still use the View Engine.\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n if (\n error &&\n (error.name === 'QuotaExceededError' ||\n error.name === 'NS_ERROR_DOM_QUOTA_REACHED')\n ) {\n console.error(\n `The ${storageKey} store value exceeds the browser storage quota: `,\n storedValue\n );\n } else {\n console.error(\n `Error ocurred while serializing the ${storageKey} store value, value not updated, the value obtained from the store: `,\n storedValue\n );\n }\n }\n }\n }\n }\n })\n );\n }\n}\n\nconst DOT = '.';\n","import {\n NgModule,\n ModuleWithProviders,\n PLATFORM_ID,\n InjectionToken,\n Injector\n} from '@angular/core';\nimport { NGXS_PLUGINS } from '@ngxs/store';\n\nimport {\n NgxsStoragePluginOptions,\n STORAGE_ENGINE,\n NGXS_STORAGE_PLUGIN_OPTIONS\n} from './symbols';\nimport { NgxsStoragePlugin } from './storage.plugin';\nimport { engineFactory, storageOptionsFactory } from './internals';\nimport {\n createFinalStoragePluginOptions,\n FINAL_NGXS_STORAGE_PLUGIN_OPTIONS\n} from './internals/final-options';\n\nexport const USER_OPTIONS = new InjectionToken('USER_OPTIONS');\n\n@NgModule()\nexport class NgxsStoragePluginModule {\n static forRoot(\n options?: NgxsStoragePluginOptions\n ): ModuleWithProviders<NgxsStoragePluginModule> {\n return {\n ngModule: NgxsStoragePluginModule,\n providers: [\n {\n provide: NGXS_PLUGINS,\n useClass: NgxsStoragePlugin,\n multi: true\n },\n {\n provide: USER_OPTIONS,\n useValue: options\n },\n {\n provide: NGXS_STORAGE_PLUGIN_OPTIONS,\n useFactory: storageOptionsFactory,\n deps: [USER_OPTIONS]\n },\n {\n provide: STORAGE_ENGINE,\n useFactory: engineFactory,\n deps: [NGXS_STORAGE_PLUGIN_OPTIONS, PLATFORM_ID]\n },\n {\n provide: FINAL_NGXS_STORAGE_PLUGIN_OPTIONS,\n useFactory: createFinalStoragePluginOptions,\n deps: [Injector, NGXS_STORAGE_PLUGIN_OPTIONS]\n }\n ]\n };\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nimport { StorageEngine } from './symbols';\n\nexport const LOCAL_STORAGE_ENGINE = new InjectionToken<StorageEngine>('LOCAL_STORAGE_ENGINE', {\n providedIn: 'root',\n factory: () => localStorage\n});\n\nexport const SESSION_STORAGE_ENGINE = new InjectionToken<StorageEngine>(\n 'SESSION_STORAGE_ENGINE',\n {\n providedIn: 'root',\n factory: () => sessionStorage\n }\n);\n"],"names":[],"mappings":";;;;;;;;;AAAA;;IAKE,eAAY;IACZ,iBAAc;;;;;AAGhB,uCAgEC;;;;;;IA5DC,uCAA4C;;;;;;;IAO5C,6CAAmB;;;;;;;IAOnB,2CAAwB;;;;;IAKxB,8CAoBI;;;;;;IAKJ,kEAA6B;;;;;;IAK7B,oEAA4B;;;;;;;IAK5B,6EAA6C;;;;;;;IAK7C,8EAA8C;;;AAGhD,MAAa,2BAA2B,GAAG,IAAI,cAAc,CAAC,6BAA6B,CAAC;;AAE5F,MAAa,cAAc,GAAG,IAAI,cAAc,CAAgB,gBAAgB,CAAC;;;;AAEjF,4BAMC;;;IALC,+BAAwB;;;;;IACxB,qDAA0B;;;;;;IAC1B,0DAAqC;;;;;IACrC,wDAA8B;;;;IAC9B,gDAAc;;;;;;;ACpFhB;;;;;AAQA,MAAa,iBAAiB,GAAG,SAAS;;;;;AAE1C,SAAgB,qBAAqB,CACnC,OAA6C;IAE7C,uBACE,GAAG,EAAE,CAAC,iBAAiB,CAAC,EACxB,OAAO,wBACP,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,WAAW,EAAE,IAAI,CAAC,KAAK,EACvB,eAAe;;;;QAAE,GAAG,IAAI,GAAG,GAC3B,gBAAgB;;;;QAAE,GAAG,IAAI,GAAG,KAC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AAI;iBACZ;gBACD;oBACE,OAAO,EAAE,YAAY;oBACrB,QAAQ,EAAE,OAAO;iBAClB;gBACD;oBACE,OAAO,EAAE,2BAA2B;oBACpC,UAAU,EAAE,qBAAqB;oBACjC,IAAI,EAAE,CAAC,YAAY,CAAC;iBACrB;gBACD;oBACE,OAAO,EAAE,cAAc;oBACvB,UAAU,EAAE,aAAa;oBACzB,IAAI,EAAE,CAAC,2BAA2B,EAAE,WAAW,CAAC;iBACjD;gBACD;oBACE,OAAO,EAAE,iCAAiC;oBAC1C,UAAU,EAAE,+BAA+B;oBAC3C,IAAI,EAAE,CAAC,QAAQ,EAAE,2BAA2B,CAAC;iBAC9C;aACF;SACF,CAAC;KACH;;;YAlCF,QAAQ;;;;;;;ACvBT;AAIA,MAAa,oBAAoB,GAAG,IAAI,cAAc,CAAgB,sBAAsB,EAAE;IAC5F,UAAU,EAAE,MAAM;IAClB,OAAO;;;IAAE,MAAM,YAAY,CAAA;CAC5B,CAAC;;AAEF,MAAa,sBAAsB,GAAG,IAAI,cAAc,CACtD,wBAAwB,EACxB;IACE,UAAU,EAAE,MAAM;IAClB,OAAO;;;IAAE,MAAM,cAAc,CAAA;CAC9B,CACF;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"ngxs-storage-plugin.js","sources":["../../../packages/storage-plugin/src/symbols.ts","../../../packages/storage-plugin/src/internals.ts","../../../packages/storage-plugin/src/internals/storage-key.ts","../../../packages/storage-plugin/src/internals/final-options.ts","../../../packages/storage-plugin/src/storage.plugin.ts","../../../packages/storage-plugin/src/storage.module.ts","../../../packages/storage-plugin/src/engines.ts","../../../packages/storage-plugin/index.ts","../../../packages/storage-plugin/ngxs-storage-plugin.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nimport { StorageKey } from './internals/storage-key';\n\nexport const enum StorageOption {\n LocalStorage,\n SessionStorage\n}\n\nexport interface NgxsStoragePluginOptions {\n /**\n * Key for the state slice to store in the storage engine.\n */\n key?: undefined | StorageKey | StorageKey[];\n\n /**\n * The namespace is used to prefix the key for the state slice. This is\n * necessary when running micro frontend applications which use storage plugin.\n * The namespace will eliminate the conflict between keys that might overlap.\n */\n namespace?: string;\n\n /**\n * Storage engine to use. Deaults to localStorage but can provide\n *\n * sessionStorage or custom implementation of the StorageEngine interface\n */\n storage?: StorageOption;\n\n /**\n * Migration strategies.\n */\n migrations?: {\n /**\n * Version to key off.\n */\n version: number | string;\n\n /**\n * Method to migrate the previous state.\n */\n migrate: (state: any) => any;\n\n /**\n * Key to migrate.\n */\n key?: string;\n\n /**\n * Key for the version. Defaults to 'version'.\n */\n versionKey?: string;\n }[];\n\n /**\n * Serailizer for the object before its pushed into the engine.\n */\n serialize?(obj: any): string;\n\n /**\n * Deserializer for the object before its pulled out of the engine.\n */\n deserialize?(obj: any): any;\n\n /**\n * Method to alter object before serialization.\n */\n beforeSerialize?(obj: any, key: string): any;\n\n /**\n * Method to alter object after deserialization.\n */\n afterDeserialize?(obj: any, key: string): any;\n}\n\nexport const NGXS_STORAGE_PLUGIN_OPTIONS = new InjectionToken('NGXS_STORAGE_PLUGIN_OPTIONS');\n\nexport const STORAGE_ENGINE = new InjectionToken<StorageEngine>('STORAGE_ENGINE');\n\nexport interface StorageEngine {\n readonly length: number;\n getItem(key: string): any;\n setItem(key: string, val: any): void;\n removeItem(key: string): void;\n clear(): void;\n}\n","import { isPlatformServer } from '@angular/common';\n\nimport { StorageOption, StorageEngine, NgxsStoragePluginOptions } from './symbols';\n\n/**\n * The following key is used to store the entire serialized\n * state when there's no specific state provided.\n */\nexport const DEFAULT_STATE_KEY = '@@STATE';\n\nexport function storageOptionsFactory(\n options: NgxsStoragePluginOptions | undefined\n): NgxsStoragePluginOptions {\n return {\n key: [DEFAULT_STATE_KEY],\n storage: StorageOption.LocalStorage,\n serialize: JSON.stringify,\n deserialize: JSON.parse,\n beforeSerialize: obj => obj,\n afterDeserialize: obj => obj,\n ...options\n };\n}\n\nexport function engineFactory(\n options: NgxsStoragePluginOptions,\n platformId: string\n): StorageEngine | null {\n if (isPlatformServer(platformId)) {\n return null;\n }\n\n if (options.storage === StorageOption.LocalStorage) {\n return localStorage;\n } else if (options.storage === StorageOption.SessionStorage) {\n return sessionStorage;\n }\n\n return null;\n}\n\nexport function getStorageKey(key: string, options?: NgxsStoragePluginOptions): string {\n // Prepends the `namespace` option to any key if it's been provided by a user.\n // So `@@STATE` becomes `my-app:@@STATE`.\n return options && options.namespace ? `${options.namespace}:${key}` : key;\n}\n","import { InjectionToken, Type } from '@angular/core';\nimport { StateToken } from '@ngxs/store';\nimport { StateClass } from '@ngxs/store/internals';\n\nimport { StorageEngine } from '../symbols';\n\n/** This enables the user to provide a storage engine per individual key. */\nexport interface KeyWithExplicitEngine {\n key: string | StateClass | StateToken<any>;\n engine: Type<StorageEngine> | InjectionToken<StorageEngine>;\n}\n\n/** Determines whether the provided key has the following structure. */\nexport function isKeyWithExplicitEngine(key: any): key is KeyWithExplicitEngine {\n return key != null && !!key.engine;\n}\n\n/**\n * This tuples all of the possible types allowed in the `key` property.\n * This is not exposed publicly and used internally only.\n */\nexport type StorageKey = string | StateClass | StateToken<any> | KeyWithExplicitEngine;\n\n/** This symbol is used to store the metadata on state classes. */\nconst META_OPTIONS_KEY = 'NGXS_OPTIONS_META';\nexport function exctractStringKey(storageKey: StorageKey): string {\n // Extract the actual key out of the `{ key, engine }` structure.\n if (isKeyWithExplicitEngine(storageKey)) {\n storageKey = storageKey.key;\n }\n\n // Given the `storageKey` is a class, for instance, `AuthState`.\n // We should retrieve its metadata and the `name` property.\n // The `name` property might be a string (state name) or a state token.\n if (storageKey.hasOwnProperty(META_OPTIONS_KEY)) {\n storageKey = (storageKey as any)[META_OPTIONS_KEY].name;\n }\n\n return storageKey instanceof StateToken ? storageKey.getName() : <string>storageKey;\n}\n","import { InjectionToken, Injector } from '@angular/core';\n\nimport { exctractStringKey, isKeyWithExplicitEngine, StorageKey } from './storage-key';\nimport { NgxsStoragePluginOptions, StorageEngine, STORAGE_ENGINE } from '../symbols';\n\nexport interface FinalNgxsStoragePluginOptions extends NgxsStoragePluginOptions {\n keysWithEngines: {\n key: string;\n engine: StorageEngine;\n }[];\n}\n\nexport const FINAL_NGXS_STORAGE_PLUGIN_OPTIONS = new InjectionToken<\n FinalNgxsStoragePluginOptions\n>('FINAL_NGXS_STORAGE_PLUGIN_OPTIONS');\n\nexport function createFinalStoragePluginOptions(\n injector: Injector,\n options: NgxsStoragePluginOptions\n): FinalNgxsStoragePluginOptions {\n const storageKeys: StorageKey[] = Array.isArray(options.key) ? options.key : [options.key!];\n\n const keysWithEngines = storageKeys.map((storageKey: StorageKey) => {\n const key = exctractStringKey(storageKey);\n const engine = isKeyWithExplicitEngine(storageKey)\n ? injector.get(storageKey.engine)\n : injector.get(STORAGE_ENGINE);\n return { key, engine };\n });\n\n return {\n ...options,\n keysWithEngines\n };\n}\n","import { PLATFORM_ID, Inject, Injectable } from '@angular/core';\nimport { isPlatformServer } from '@angular/common';\nimport { PlainObject } from '@ngxs/store/internals';\nimport {\n NgxsPlugin,\n setValue,\n getValue,\n InitState,\n UpdateState,\n actionMatcher,\n NgxsNextPluginFn\n} from '@ngxs/store';\nimport { tap } from 'rxjs/operators';\n\nimport { DEFAULT_STATE_KEY, getStorageKey } from './internals';\nimport {\n FinalNgxsStoragePluginOptions,\n FINAL_NGXS_STORAGE_PLUGIN_OPTIONS\n} from './internals/final-options';\n\n/**\n * @description Will be provided through Terser global definitions by Angular CLI\n * during the production build. This is how Angular does tree-shaking internally.\n */\ndeclare const ngDevMode: boolean;\n\n@Injectable()\nexport class NgxsStoragePlugin implements NgxsPlugin {\n private _keysWithEngines = this._options.keysWithEngines;\n // We default to `[DEFAULT_STATE_KEY]` if the user explicitly does not provide the `key` option.\n private _usesDefaultStateKey =\n this._keysWithEngines.length === 1 && this._keysWithEngines[0].key === DEFAULT_STATE_KEY;\n\n constructor(\n @Inject(FINAL_NGXS_STORAGE_PLUGIN_OPTIONS) private _options: FinalNgxsStoragePluginOptions,\n @Inject(PLATFORM_ID) private _platformId: string\n ) {}\n\n handle(state: any, event: any, next: NgxsNextPluginFn) {\n if (isPlatformServer(this._platformId)) {\n return next(state, event);\n }\n\n const matches = actionMatcher(event);\n const isInitAction = matches(InitState);\n const isUpdateAction = matches(UpdateState);\n const isInitOrUpdateAction = isInitAction || isUpdateAction;\n let hasMigration = false;\n\n if (isInitOrUpdateAction) {\n const addedStates = isUpdateAction && event.addedStates;\n\n for (const { key, engine } of this._keysWithEngines) {\n // We're checking what states have been added by NGXS and if any of these states should be handled by\n // the storage plugin. For instance, we only want to deserialize the `auth` state, NGXS has added\n // the `user` state, the storage plugin will be rerun and will do redundant deserialization.\n // `usesDefaultStateKey` is necessary to check since `event.addedStates` never contains `@@STATE`.\n if (!this._usesDefaultStateKey && addedStates) {\n // We support providing keys that can be deeply nested via dot notation, for instance,\n // `keys: ['myState.myProperty']` is a valid key.\n // The state name should always go first. The below code checks if the `key` includes dot\n // notation and extracts the state name out of the key.\n // Given the `key` is `myState.myProperty`, the `addedStates` will only contain `myState`.\n const dotNotationIndex = key.indexOf(DOT);\n const stateName = dotNotationIndex > -1 ? key.slice(0, dotNotationIndex) : key;\n if (!addedStates.hasOwnProperty(stateName)) {\n continue;\n }\n }\n\n const storageKey = getStorageKey(key, this._options);\n let storedValue: any = engine.getItem(storageKey);\n\n if (storedValue !== 'undefined' && storedValue != null) {\n try {\n const newVal = this._options.deserialize!(storedValue);\n storedValue = this._options.afterDeserialize!(newVal, key);\n } catch {\n // Caretaker note: we have still left the `typeof` condition in order to avoid\n // creating a breaking change for projects that still use the View Engine.\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n console.error(\n `Error ocurred while deserializing the ${storageKey} store value, falling back to empty object, the value obtained from the store: `,\n storedValue\n );\n }\n storedValue = {};\n }\n\n if (this._options.migrations) {\n this._options.migrations.forEach(strategy => {\n const versionMatch =\n strategy.version === getValue(storedValue, strategy.versionKey || 'version');\n const keyMatch =\n (!strategy.key && this._usesDefaultStateKey) || strategy.key === key;\n if (versionMatch && keyMatch) {\n storedValue = strategy.migrate(storedValue);\n hasMigration = true;\n }\n });\n }\n\n if (!this._usesDefaultStateKey) {\n state = setValue(state, key, storedValue);\n } else {\n // The `UpdateState` action is dispatched whenever the feature state is added.\n // The below condition is met only when the `UpdateState` is dispatched.\n // Let's assume that we have 2 states `counter` and `@ngxs/router-plugin` state.\n // `CounterState` is provided on the root level when calling `NgxsModule.forRoot()`\n // and `@ngxs/router-plugin` is provided as a feature state.\n // The storage plugin may save the `counter` state value as `10` before.\n // The `CounterState` may implement the `ngxsOnInit` hook and call `ctx.setState(999)`.\n // The storage plugin will re-hydrate the whole state when the `RouterState` is registered,\n // and the `counter` state will again equal `10` (not `999`).\n if (storedValue && addedStates && Object.keys(addedStates).length > 0) {\n storedValue = Object.keys(addedStates).reduce((accumulator, addedState) => {\n // The `storedValue` may equal the whole state (when the default state key is used).\n // If `addedStates` contains only `router` then we want to merge the state only\n // with the `router` value.\n // Let's assume that the `storedValue` is an object:\n // `{ counter: 10, router: {...} }`\n // This will pick only the `router` object from the `storedValue` and `counter`\n // state will not be re-hydrated unnecessary.\n if (storedValue.hasOwnProperty(addedState)) {\n accumulator[addedState] = storedValue[addedState];\n }\n return accumulator;\n }, <PlainObject>{});\n }\n\n state = { ...state, ...storedValue };\n }\n }\n }\n }\n\n return next(state, event).pipe(\n tap(nextState => {\n if (!isInitOrUpdateAction || (isInitOrUpdateAction && hasMigration)) {\n for (const { key, engine } of this._keysWithEngines) {\n let storedValue = nextState;\n\n const storageKey = getStorageKey(key, this._options);\n\n if (key !== DEFAULT_STATE_KEY) {\n storedValue = getValue(nextState, key);\n }\n\n try {\n const newStoredValue = this._options.beforeSerialize!(storedValue, key);\n engine.setItem(storageKey, this._options.serialize!(newStoredValue));\n } catch (error) {\n // Caretaker note: we have still left the `typeof` condition in order to avoid\n // creating a breaking change for projects that still use the View Engine.\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n if (\n error &&\n (error.name === 'QuotaExceededError' ||\n error.name === 'NS_ERROR_DOM_QUOTA_REACHED')\n ) {\n console.error(\n `The ${storageKey} store value exceeds the browser storage quota: `,\n storedValue\n );\n } else {\n console.error(\n `Error ocurred while serializing the ${storageKey} store value, value not updated, the value obtained from the store: `,\n storedValue\n );\n }\n }\n }\n }\n }\n })\n );\n }\n}\n\nconst DOT = '.';\n","import {\n NgModule,\n ModuleWithProviders,\n PLATFORM_ID,\n InjectionToken,\n Injector\n} from '@angular/core';\nimport { NGXS_PLUGINS } from '@ngxs/store';\n\nimport {\n NgxsStoragePluginOptions,\n STORAGE_ENGINE,\n NGXS_STORAGE_PLUGIN_OPTIONS\n} from './symbols';\nimport { NgxsStoragePlugin } from './storage.plugin';\nimport { engineFactory, storageOptionsFactory } from './internals';\nimport {\n createFinalStoragePluginOptions,\n FINAL_NGXS_STORAGE_PLUGIN_OPTIONS\n} from './internals/final-options';\n\nexport const USER_OPTIONS = new InjectionToken('USER_OPTIONS');\n\n@NgModule()\nexport class NgxsStoragePluginModule {\n static forRoot(\n options?: NgxsStoragePluginOptions\n ): ModuleWithProviders<NgxsStoragePluginModule> {\n return {\n ngModule: NgxsStoragePluginModule,\n providers: [\n {\n provide: NGXS_PLUGINS,\n useClass: NgxsStoragePlugin,\n multi: true\n },\n {\n provide: USER_OPTIONS,\n useValue: options\n },\n {\n provide: NGXS_STORAGE_PLUGIN_OPTIONS,\n useFactory: storageOptionsFactory,\n deps: [USER_OPTIONS]\n },\n {\n provide: STORAGE_ENGINE,\n useFactory: engineFactory,\n deps: [NGXS_STORAGE_PLUGIN_OPTIONS, PLATFORM_ID]\n },\n {\n provide: FINAL_NGXS_STORAGE_PLUGIN_OPTIONS,\n useFactory: createFinalStoragePluginOptions,\n deps: [Injector, NGXS_STORAGE_PLUGIN_OPTIONS]\n }\n ]\n };\n }\n}\n","import { InjectionToken } from '@angular/core';\n\nimport { StorageEngine } from './symbols';\n\nexport const LOCAL_STORAGE_ENGINE = new InjectionToken<StorageEngine>('LOCAL_STORAGE_ENGINE', {\n providedIn: 'root',\n factory: () => localStorage\n});\n\nexport const SESSION_STORAGE_ENGINE = new InjectionToken<StorageEngine>(\n 'SESSION_STORAGE_ENGINE',\n {\n providedIn: 'root',\n factory: () => sessionStorage\n }\n);\n","/**\n * The public api for consumers of @ngxs/storage-plugin\n */\nexport * from './src/public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;MA2Ea,2BAA2B,GAAG,IAAI,cAAc,CAAC,6BAA6B,EAAE;MAEhF,cAAc,GAAG,IAAI,cAAc,CAAgB,gBAAgB;;ACzEhF;;;AAGG;AACI,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAErC,SAAU,qBAAqB,CACnC,OAA6C,EAAA;AAE7C,IAAA,OAAA,MAAA,CAAA,MAAA,CAAA,EACE,GAAG,EAAE,CAAC,iBAAiB,CAAC,EACxB,OAAO,EAAA,CAAA,qBACP,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,WAAW,EAAE,IAAI,CAAC,KAAK,EACvB,eAAe,EAAE,GAAG,IAAI,GAAG,EAC3B,gBAAgB,EAAE,GAAG,IAAI,GAAG,EAAA,EACzB,OAAO,CACV,CAAA;AACJ,CAAC;AAEe,SAAA,aAAa,CAC3B,OAAiC,EACjC,UAAkB,EAAA;AAElB,IAAA,IAAI,gBAAgB,CAAC,UAAU,CAAC,EAAE;AAChC,QAAA,OAAO,IAAI,CAAC;AACb,KAAA;AAED,IAAA,IAAI,OAAO,CAAC,OAAO,KAAA,CAAA,qBAAiC;AAClD,QAAA,OAAO,YAAY,CAAC;AACrB,KAAA;AAAM,SAAA,IAAI,OAAO,CAAC,OAAO,KAAA,CAAA,uBAAmC;AAC3D,QAAA,OAAO,cAAc,CAAC;AACvB,KAAA;AAED,IAAA,OAAO,IAAI,CAAC;AACd,CAAC;AAEe,SAAA,aAAa,CAAC,GAAW,EAAE,OAAkC,EAAA;;;AAG3E,IAAA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;wIAjCU,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;yIAAvB,uBAAuB,EAAA,CAAA,CAAA;yIAAvB,uBAAuB,EAAA,CAAA,CAAA;4FAAvB,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBADnC,QAAQ;;;MCnBI,oBAAoB,GAAG,IAAI,cAAc,CAAgB,sBAAsB,EAAE;AAC5F,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,MAAM,YAAY;AAC5B,CAAA,EAAE;MAEU,sBAAsB,GAAG,IAAI,cAAc,CACtD,wBAAwB,EACxB;AACE,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,MAAM,cAAc;AAC9B,CAAA;;ACdH;;AAEG;;ACFH;;AAEG;;;;"}
|
package/ngxs-storage-plugin.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generated bundle index. Do not edit.
|
|
3
3
|
*/
|
|
4
|
+
/// <amd-module name="@ngxs/storage-plugin" />
|
|
4
5
|
export * from './index';
|
|
5
|
-
export { engineFactory as ɵf, storageOptionsFactory as ɵe } from './src/internals';
|
|
6
|
-
export { FINAL_NGXS_STORAGE_PLUGIN_OPTIONS as ɵc, FinalNgxsStoragePluginOptions as ɵb, createFinalStoragePluginOptions as ɵd } from './src/internals/final-options';
|
|
7
|
-
export { USER_OPTIONS as ɵa } from './src/storage.module';
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "../../node_modules/ng-packagr/package.schema.json",
|
|
3
3
|
"name": "@ngxs/storage-plugin",
|
|
4
4
|
"description": "extendable storage plugin for @ngxs/store",
|
|
5
|
-
"version": "3.7.6-dev.master-
|
|
5
|
+
"version": "3.7.6-dev.master-dcdd391",
|
|
6
6
|
"sideEffects": true,
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"@angular/core": ">=6.1.0 <16.0.0",
|
|
@@ -10,16 +10,13 @@
|
|
|
10
10
|
"rxjs": ">=6.5.5"
|
|
11
11
|
},
|
|
12
12
|
"main": "bundles/ngxs-storage-plugin.umd.js",
|
|
13
|
-
"module": "
|
|
13
|
+
"module": "fesm2015/ngxs-storage-plugin.js",
|
|
14
14
|
"es2015": "fesm2015/ngxs-storage-plugin.js",
|
|
15
|
-
"esm5": "esm5/ngxs-storage-plugin.js",
|
|
16
15
|
"esm2015": "esm2015/ngxs-storage-plugin.js",
|
|
17
|
-
"fesm5": "fesm5/ngxs-storage-plugin.js",
|
|
18
16
|
"fesm2015": "fesm2015/ngxs-storage-plugin.js",
|
|
19
17
|
"typings": "ngxs-storage-plugin.d.ts",
|
|
20
|
-
"metadata": "ngxs-storage-plugin.metadata.json",
|
|
21
18
|
"dependencies": {
|
|
22
|
-
"tslib": "^
|
|
19
|
+
"tslib": "^2.2.0"
|
|
23
20
|
},
|
|
24
21
|
"repository": {
|
|
25
22
|
"type": "git",
|