@ngxs/storage-plugin 3.7.4-temp → 3.7.5-dev.master-8fa3ea5

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.
@@ -3,372 +3,420 @@ import { StateToken, actionMatcher, InitState, UpdateState, getValue, setValue,
3
3
  import { isPlatformServer } from '@angular/common';
4
4
  import { tap } from 'rxjs/operators';
5
5
 
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
- * Storage engine to use. Deaults to localStorage but can provide
27
- *
28
- * sessionStorage or custom implementation of the StorageEngine interface
29
- * @type {?|undefined}
30
- */
31
- NgxsStoragePluginOptions.prototype.storage;
32
- /**
33
- * Migration strategies.
34
- * @type {?|undefined}
35
- */
36
- NgxsStoragePluginOptions.prototype.migrations;
37
- /**
38
- * Serailizer for the object before its pushed into the engine.
39
- * @param {?} obj
40
- * @return {?}
41
- */
42
- NgxsStoragePluginOptions.prototype.serialize = function (obj) { };
43
- /**
44
- * Deserializer for the object before its pulled out of the engine.
45
- * @param {?} obj
46
- * @return {?}
47
- */
48
- NgxsStoragePluginOptions.prototype.deserialize = function (obj) { };
49
- /**
50
- * Method to alter object before serialization.
51
- * @param {?} obj
52
- * @param {?} key
53
- * @return {?}
54
- */
55
- NgxsStoragePluginOptions.prototype.beforeSerialize = function (obj, key) { };
56
- /**
57
- * Method to alter object after deserialization.
58
- * @param {?} obj
59
- * @param {?} key
60
- * @return {?}
61
- */
62
- NgxsStoragePluginOptions.prototype.afterDeserialize = function (obj, key) { };
63
- }
64
- /** @type {?} */
65
- const NGXS_STORAGE_PLUGIN_OPTIONS = new InjectionToken('NGXS_STORAGE_PLUGIN_OPTION');
66
- /** @type {?} */
67
- const STORAGE_ENGINE = new InjectionToken('STORAGE_ENGINE');
68
- /**
69
- * @record
70
- */
71
- function StorageEngine() { }
72
- if (false) {
73
- /** @type {?} */
74
- StorageEngine.prototype.length;
75
- /**
76
- * @param {?} key
77
- * @return {?}
78
- */
79
- StorageEngine.prototype.getItem = function (key) { };
80
- /**
81
- * @param {?} key
82
- * @param {?} val
83
- * @return {?}
84
- */
85
- StorageEngine.prototype.setItem = function (key, val) { };
86
- /**
87
- * @param {?} key
88
- * @return {?}
89
- */
90
- StorageEngine.prototype.removeItem = function (key) { };
91
- /**
92
- * @return {?}
93
- */
94
- StorageEngine.prototype.clear = function () { };
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
+ * Storage engine to use. Deaults to localStorage but can provide
27
+ *
28
+ * sessionStorage or custom implementation of the StorageEngine interface
29
+ * @type {?|undefined}
30
+ */
31
+ NgxsStoragePluginOptions.prototype.storage;
32
+ /**
33
+ * Migration strategies.
34
+ * @type {?|undefined}
35
+ */
36
+ NgxsStoragePluginOptions.prototype.migrations;
37
+ /**
38
+ * Serailizer for the object before its pushed into the engine.
39
+ * @param {?} obj
40
+ * @return {?}
41
+ */
42
+ NgxsStoragePluginOptions.prototype.serialize = function (obj) { };
43
+ /**
44
+ * Deserializer for the object before its pulled out of the engine.
45
+ * @param {?} obj
46
+ * @return {?}
47
+ */
48
+ NgxsStoragePluginOptions.prototype.deserialize = function (obj) { };
49
+ /**
50
+ * Method to alter object before serialization.
51
+ * @param {?} obj
52
+ * @param {?} key
53
+ * @return {?}
54
+ */
55
+ NgxsStoragePluginOptions.prototype.beforeSerialize = function (obj, key) { };
56
+ /**
57
+ * Method to alter object after deserialization.
58
+ * @param {?} obj
59
+ * @param {?} key
60
+ * @return {?}
61
+ */
62
+ NgxsStoragePluginOptions.prototype.afterDeserialize = function (obj, key) { };
63
+ }
64
+ /** @type {?} */
65
+ const NGXS_STORAGE_PLUGIN_OPTIONS = new InjectionToken('NGXS_STORAGE_PLUGIN_OPTION');
66
+ /** @type {?} */
67
+ const STORAGE_ENGINE = new InjectionToken('STORAGE_ENGINE');
68
+ /**
69
+ * @record
70
+ */
71
+ function StorageEngine() { }
72
+ if (false) {
73
+ /** @type {?} */
74
+ StorageEngine.prototype.length;
75
+ /**
76
+ * @param {?} key
77
+ * @return {?}
78
+ */
79
+ StorageEngine.prototype.getItem = function (key) { };
80
+ /**
81
+ * @param {?} key
82
+ * @param {?} val
83
+ * @return {?}
84
+ */
85
+ StorageEngine.prototype.setItem = function (key, val) { };
86
+ /**
87
+ * @param {?} key
88
+ * @return {?}
89
+ */
90
+ StorageEngine.prototype.removeItem = function (key) { };
91
+ /**
92
+ * @return {?}
93
+ */
94
+ StorageEngine.prototype.clear = function () { };
95
95
  }
96
96
 
97
- /**
98
- * @fileoverview added by tsickle
99
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
100
- */
101
- /**
102
- * If the `key` option is not provided then the below constant
103
- * will be used as a default key
104
- * @type {?}
105
- */
106
- const DEFAULT_STATE_KEY = '@@STATE';
107
- /**
108
- * This key is used to retrieve static metadatas on state classes.
109
- * This constant is taken from the core codebase
110
- * @type {?}
111
- */
112
- const META_OPTIONS_KEY = 'NGXS_OPTIONS_META';
113
- /**
114
- * @param {?} key
115
- * @return {?}
116
- */
117
- function transformKeyOption(key) {
118
- if (!Array.isArray(key)) {
119
- key = [key];
120
- }
121
- return key.map((/**
122
- * @param {?} token
123
- * @return {?}
124
- */
125
- (token) => {
126
- // If it has the `NGXS_OPTIONS_META` key then it means the developer
127
- // has provided state class like `key: [AuthState]`.
128
- if (token.hasOwnProperty(META_OPTIONS_KEY)) {
129
- // The `name` property will be an actual state name or a `StateToken`.
130
- token = ((/** @type {?} */ (token)))[META_OPTIONS_KEY].name;
131
- }
132
- return token instanceof StateToken ? token.getName() : ((/** @type {?} */ (token)));
133
- }));
134
- }
135
- /**
136
- * @param {?} options
137
- * @return {?}
138
- */
139
- function storageOptionsFactory(options) {
140
- if (options !== undefined && options.key) {
141
- options.key = transformKeyOption(options.key);
142
- }
143
- return Object.assign({ key: [DEFAULT_STATE_KEY], storage: 0 /* LocalStorage */, serialize: JSON.stringify, deserialize: JSON.parse, beforeSerialize: (/**
144
- * @param {?} obj
145
- * @return {?}
146
- */
147
- obj => obj), afterDeserialize: (/**
148
- * @param {?} obj
149
- * @return {?}
150
- */
151
- obj => obj) }, options);
152
- }
153
- /**
154
- * @param {?} options
155
- * @param {?} platformId
156
- * @return {?}
157
- */
158
- function engineFactory(options, platformId) {
159
- if (isPlatformServer(platformId)) {
160
- return null;
161
- }
162
- if (options.storage === 0 /* LocalStorage */) {
163
- return localStorage;
164
- }
165
- else if (options.storage === 1 /* SessionStorage */) {
166
- return sessionStorage;
167
- }
168
- return null;
97
+ /**
98
+ * @fileoverview added by tsickle
99
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
100
+ */
101
+ /**
102
+ * If the `key` option is not provided then the below constant
103
+ * will be used as a default key
104
+ * @type {?}
105
+ */
106
+ const DEFAULT_STATE_KEY = '@@STATE';
107
+ /**
108
+ * This key is used to retrieve static metadatas on state classes.
109
+ * This constant is taken from the core codebase
110
+ * @type {?}
111
+ */
112
+ const META_OPTIONS_KEY = 'NGXS_OPTIONS_META';
113
+ /**
114
+ * @param {?} key
115
+ * @return {?}
116
+ */
117
+ function transformKeyOption(key) {
118
+ if (!Array.isArray(key)) {
119
+ key = [key];
120
+ }
121
+ return key.map((/**
122
+ * @param {?} token
123
+ * @return {?}
124
+ */
125
+ (token) => {
126
+ // If it has the `NGXS_OPTIONS_META` key then it means the developer
127
+ // has provided state class like `key: [AuthState]`.
128
+ if (token.hasOwnProperty(META_OPTIONS_KEY)) {
129
+ // The `name` property will be an actual state name or a `StateToken`.
130
+ token = ((/** @type {?} */ (token)))[META_OPTIONS_KEY].name;
131
+ }
132
+ return token instanceof StateToken ? token.getName() : ((/** @type {?} */ (token)));
133
+ }));
134
+ }
135
+ /**
136
+ * @param {?} options
137
+ * @return {?}
138
+ */
139
+ function storageOptionsFactory(options) {
140
+ if (options !== undefined && options.key) {
141
+ options.key = transformKeyOption(options.key);
142
+ }
143
+ return Object.assign({ key: [DEFAULT_STATE_KEY], storage: 0 /* LocalStorage */, serialize: JSON.stringify, deserialize: JSON.parse, beforeSerialize: (/**
144
+ * @param {?} obj
145
+ * @return {?}
146
+ */
147
+ obj => obj), afterDeserialize: (/**
148
+ * @param {?} obj
149
+ * @return {?}
150
+ */
151
+ obj => obj) }, options);
152
+ }
153
+ /**
154
+ * @param {?} options
155
+ * @param {?} platformId
156
+ * @return {?}
157
+ */
158
+ function engineFactory(options, platformId) {
159
+ if (isPlatformServer(platformId)) {
160
+ return null;
161
+ }
162
+ if (options.storage === 0 /* LocalStorage */) {
163
+ return localStorage;
164
+ }
165
+ else if (options.storage === 1 /* SessionStorage */) {
166
+ return sessionStorage;
167
+ }
168
+ return null;
169
169
  }
170
170
 
171
- /**
172
- * @fileoverview added by tsickle
173
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
174
- */
175
- class NgxsStoragePlugin {
176
- /**
177
- * @param {?} _options
178
- * @param {?} _engine
179
- * @param {?} _platformId
180
- */
181
- constructor(_options, _engine, _platformId) {
182
- this._options = _options;
183
- this._engine = _engine;
184
- this._platformId = _platformId;
185
- }
186
- /**
187
- * @param {?} state
188
- * @param {?} event
189
- * @param {?} next
190
- * @return {?}
191
- */
192
- handle(state, event, next) {
193
- if (isPlatformServer(this._platformId) && this._engine === null) {
194
- return next(state, event);
195
- }
196
- // We cast to `string[]` here as we're sure that this option has been
197
- // transformed by the `storageOptionsFactory` function that provided token
198
- /** @type {?} */
199
- const keys = (/** @type {?} */ (this._options.key));
200
- /** @type {?} */
201
- const matches = actionMatcher(event);
202
- /** @type {?} */
203
- const isInitAction = matches(InitState);
204
- /** @type {?} */
205
- const isUpdateAction = matches(UpdateState);
206
- /** @type {?} */
207
- const isInitOrUpdateAction = isInitAction || isUpdateAction;
208
- /** @type {?} */
209
- let hasMigration = false;
210
- if (isInitOrUpdateAction) {
211
- for (const key of keys) {
212
- // We're checking what states have been added by NGXS and if any of these states should be handled by
213
- // the storage plugin. For instance, we only want to deserialize the `auth` state, NGXS has added
214
- // the `user` state, the storage plugin will be rerun and will do redundant deserialization.
215
- if (isUpdateAction && event.addedStates && !event.addedStates.hasOwnProperty(key)) {
216
- continue;
217
- }
218
- /** @type {?} */
219
- const isMaster = key === DEFAULT_STATE_KEY;
220
- /** @type {?} */
221
- let val = this._engine.getItem((/** @type {?} */ (key)));
222
- if (val !== 'undefined' && val != null) {
223
- try {
224
- /** @type {?} */
225
- const newVal = (/** @type {?} */ (this._options.deserialize))(val);
226
- val = (/** @type {?} */ (this._options.afterDeserialize))(newVal, key);
227
- }
228
- catch (e) {
229
- // Caretaker note: we have still left the `typeof` condition in order to avoid
230
- // creating a breaking change for projects that still use the View Engine.
231
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
232
- console.error(`Error ocurred while deserializing the ${key} store value, falling back to empty object, the value obtained from the store: `, val);
233
- }
234
- val = {};
235
- }
236
- if (this._options.migrations) {
237
- this._options.migrations.forEach((/**
238
- * @param {?} strategy
239
- * @return {?}
240
- */
241
- strategy => {
242
- /** @type {?} */
243
- const versionMatch = strategy.version === getValue(val, strategy.versionKey || 'version');
244
- /** @type {?} */
245
- const keyMatch = (!strategy.key && isMaster) || strategy.key === key;
246
- if (versionMatch && keyMatch) {
247
- val = strategy.migrate(val);
248
- hasMigration = true;
249
- }
250
- }));
251
- }
252
- if (!isMaster) {
253
- state = setValue(state, (/** @type {?} */ (key)), val);
254
- }
255
- else {
256
- state = Object.assign({}, state, val);
257
- }
258
- }
259
- }
260
- }
261
- return next(state, event).pipe(tap((/**
262
- * @param {?} nextState
263
- * @return {?}
264
- */
265
- nextState => {
266
- if (!isInitOrUpdateAction || (isInitOrUpdateAction && hasMigration)) {
267
- for (const key of keys) {
268
- /** @type {?} */
269
- let val = nextState;
270
- if (key !== DEFAULT_STATE_KEY) {
271
- val = getValue(nextState, (/** @type {?} */ (key)));
272
- }
273
- try {
274
- /** @type {?} */
275
- const newVal = (/** @type {?} */ (this._options.beforeSerialize))(val, key);
276
- this._engine.setItem((/** @type {?} */ (key)), (/** @type {?} */ (this._options.serialize))(newVal));
277
- }
278
- catch (e) {
279
- // Caretaker note: we have still left the `typeof` condition in order to avoid
280
- // creating a breaking change for projects that still use the View Engine.
281
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
282
- console.error(`Error ocurred while serializing the ${key} store value, value not updated, the value obtained from the store: `, val);
283
- }
284
- }
285
- }
286
- }
287
- })));
288
- }
289
- }
290
- NgxsStoragePlugin.decorators = [
291
- { type: Injectable }
292
- ];
293
- /** @nocollapse */
294
- NgxsStoragePlugin.ctorParameters = () => [
295
- { type: undefined, decorators: [{ type: Inject, args: [NGXS_STORAGE_PLUGIN_OPTIONS,] }] },
296
- { type: undefined, decorators: [{ type: Inject, args: [STORAGE_ENGINE,] }] },
297
- { type: String, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] }
298
- ];
299
- if (false) {
300
- /**
301
- * @type {?}
302
- * @private
303
- */
304
- NgxsStoragePlugin.prototype._options;
305
- /**
306
- * @type {?}
307
- * @private
308
- */
309
- NgxsStoragePlugin.prototype._engine;
310
- /**
311
- * @type {?}
312
- * @private
313
- */
314
- NgxsStoragePlugin.prototype._platformId;
171
+ /**
172
+ * @fileoverview added by tsickle
173
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
174
+ */
175
+ class NgxsStoragePlugin {
176
+ /**
177
+ * @param {?} _options
178
+ * @param {?} _engine
179
+ * @param {?} _platformId
180
+ */
181
+ constructor(_options, _engine, _platformId) {
182
+ this._options = _options;
183
+ this._engine = _engine;
184
+ this._platformId = _platformId;
185
+ // We cast to `string[]` here as we're sure that this option has been
186
+ // transformed by the `storageOptionsFactory` function that provided token.
187
+ this._keys = (/** @type {?} */ (this._options.key));
188
+ // We default to `[DEFAULT_STATE_KEY]` if the user explicitly does not provide the `key` option.
189
+ this._usesDefaultStateKey = this._keys.length === 1 && this._keys[0] === DEFAULT_STATE_KEY;
190
+ }
191
+ /**
192
+ * @param {?} state
193
+ * @param {?} event
194
+ * @param {?} next
195
+ * @return {?}
196
+ */
197
+ handle(state, event, next) {
198
+ if (isPlatformServer(this._platformId) && this._engine === null) {
199
+ return next(state, event);
200
+ }
201
+ /** @type {?} */
202
+ const matches = actionMatcher(event);
203
+ /** @type {?} */
204
+ const isInitAction = matches(InitState);
205
+ /** @type {?} */
206
+ const isUpdateAction = matches(UpdateState);
207
+ /** @type {?} */
208
+ const isInitOrUpdateAction = isInitAction || isUpdateAction;
209
+ /** @type {?} */
210
+ let hasMigration = false;
211
+ if (isInitOrUpdateAction) {
212
+ /** @type {?} */
213
+ const addedStates = isUpdateAction && event.addedStates;
214
+ for (const key of this._keys) {
215
+ // We're checking what states have been added by NGXS and if any of these states should be handled by
216
+ // the storage plugin. For instance, we only want to deserialize the `auth` state, NGXS has added
217
+ // the `user` state, the storage plugin will be rerun and will do redundant deserialization.
218
+ // `usesDefaultStateKey` is necessary to check since `event.addedStates` never contains `@@STATE`.
219
+ if (!this._usesDefaultStateKey && addedStates && !addedStates.hasOwnProperty(key)) {
220
+ continue;
221
+ }
222
+ /** @type {?} */
223
+ let storedValue = this._engine.getItem((/** @type {?} */ (key)));
224
+ if (storedValue !== 'undefined' && storedValue != null) {
225
+ try {
226
+ /** @type {?} */
227
+ const newVal = (/** @type {?} */ (this._options.deserialize))(storedValue);
228
+ storedValue = (/** @type {?} */ (this._options.afterDeserialize))(newVal, key);
229
+ }
230
+ catch (_a) {
231
+ // Caretaker note: we have still left the `typeof` condition in order to avoid
232
+ // creating a breaking change for projects that still use the View Engine.
233
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
234
+ console.error(`Error ocurred while deserializing the ${key} store value, falling back to empty object, the value obtained from the store: `, storedValue);
235
+ }
236
+ storedValue = {};
237
+ }
238
+ if (this._options.migrations) {
239
+ this._options.migrations.forEach((/**
240
+ * @param {?} strategy
241
+ * @return {?}
242
+ */
243
+ strategy => {
244
+ /** @type {?} */
245
+ const versionMatch = strategy.version === getValue(storedValue, strategy.versionKey || 'version');
246
+ /** @type {?} */
247
+ const keyMatch = (!strategy.key && this._usesDefaultStateKey) || strategy.key === key;
248
+ if (versionMatch && keyMatch) {
249
+ storedValue = strategy.migrate(storedValue);
250
+ hasMigration = true;
251
+ }
252
+ }));
253
+ }
254
+ if (!this._usesDefaultStateKey) {
255
+ state = setValue(state, (/** @type {?} */ (key)), storedValue);
256
+ }
257
+ else {
258
+ // The `UpdateState` action is dispatched whenever the feature state is added.
259
+ // The below condition is met only when the `UpdateState` is dispatched.
260
+ // Let's assume that we have 2 states `counter` and `@ngxs/router-plugin` state.
261
+ // `CounterState` is provided on the root level when calling `NgxsModule.forRoot()`
262
+ // and `@ngxs/router-plugin` is provided as a feature state.
263
+ // The storage plugin may save the `counter` state value as `10` before.
264
+ // The `CounterState` may implement the `ngxsOnInit` hook and call `ctx.setState(999)`.
265
+ // The storage plugin will re-hydrate the whole state when the `RouterState` is registered,
266
+ // and the `counter` state will again equal `10` (not `999`).
267
+ if (storedValue && addedStates && Object.keys(addedStates).length > 0) {
268
+ storedValue = Object.keys(addedStates).reduce((/**
269
+ * @param {?} accumulator
270
+ * @param {?} addedState
271
+ * @return {?}
272
+ */
273
+ (accumulator, addedState) => {
274
+ // The `storedValue` may equal the whole state (when the default state key is used).
275
+ // If `addedStates` contains only `router` then we want to merge the state only
276
+ // with the `router` value.
277
+ // Let's assume that the `storedValue` is an object:
278
+ // `{ counter: 10, router: {...} }`
279
+ // This will pick only the `router` object from the `storedValue` and `counter`
280
+ // state will not be re-hydrated unnecessary.
281
+ if (storedValue.hasOwnProperty(addedState)) {
282
+ accumulator[addedState] = storedValue[addedState];
283
+ }
284
+ return accumulator;
285
+ }), (/** @type {?} */ ({})));
286
+ }
287
+ state = Object.assign({}, state, storedValue);
288
+ }
289
+ }
290
+ }
291
+ }
292
+ return next(state, event).pipe(tap((/**
293
+ * @param {?} nextState
294
+ * @return {?}
295
+ */
296
+ nextState => {
297
+ if (!isInitOrUpdateAction || (isInitOrUpdateAction && hasMigration)) {
298
+ for (const key of this._keys) {
299
+ /** @type {?} */
300
+ let val = nextState;
301
+ if (key !== DEFAULT_STATE_KEY) {
302
+ val = getValue(nextState, (/** @type {?} */ (key)));
303
+ }
304
+ try {
305
+ /** @type {?} */
306
+ const newVal = (/** @type {?} */ (this._options.beforeSerialize))(val, key);
307
+ this._engine.setItem((/** @type {?} */ (key)), (/** @type {?} */ (this._options.serialize))(newVal));
308
+ }
309
+ catch (error) {
310
+ // Caretaker note: we have still left the `typeof` condition in order to avoid
311
+ // creating a breaking change for projects that still use the View Engine.
312
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
313
+ if (error &&
314
+ (error.name === 'QuotaExceededError' ||
315
+ error.name === 'NS_ERROR_DOM_QUOTA_REACHED')) {
316
+ console.error(`The ${key} store value exceeds the browser storage quota: `, val);
317
+ }
318
+ else {
319
+ console.error(`Error ocurred while serializing the ${key} store value, value not updated, the value obtained from the store: `, val);
320
+ }
321
+ }
322
+ }
323
+ }
324
+ }
325
+ })));
326
+ }
327
+ }
328
+ NgxsStoragePlugin.decorators = [
329
+ { type: Injectable }
330
+ ];
331
+ /** @nocollapse */
332
+ NgxsStoragePlugin.ctorParameters = () => [
333
+ { type: undefined, decorators: [{ type: Inject, args: [NGXS_STORAGE_PLUGIN_OPTIONS,] }] },
334
+ { type: undefined, decorators: [{ type: Inject, args: [STORAGE_ENGINE,] }] },
335
+ { type: String, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] }
336
+ ];
337
+ if (false) {
338
+ /**
339
+ * @type {?}
340
+ * @private
341
+ */
342
+ NgxsStoragePlugin.prototype._keys;
343
+ /**
344
+ * @type {?}
345
+ * @private
346
+ */
347
+ NgxsStoragePlugin.prototype._usesDefaultStateKey;
348
+ /**
349
+ * @type {?}
350
+ * @private
351
+ */
352
+ NgxsStoragePlugin.prototype._options;
353
+ /**
354
+ * @type {?}
355
+ * @private
356
+ */
357
+ NgxsStoragePlugin.prototype._engine;
358
+ /**
359
+ * @type {?}
360
+ * @private
361
+ */
362
+ NgxsStoragePlugin.prototype._platformId;
315
363
  }
316
364
 
317
- /**
318
- * @fileoverview added by tsickle
319
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
320
- */
321
- /** @type {?} */
322
- const USER_OPTIONS = new InjectionToken('USER_OPTIONS');
323
- class NgxsStoragePluginModule {
324
- /**
325
- * @param {?=} options
326
- * @return {?}
327
- */
328
- static forRoot(options) {
329
- return {
330
- ngModule: NgxsStoragePluginModule,
331
- providers: [
332
- {
333
- provide: NGXS_PLUGINS,
334
- useClass: NgxsStoragePlugin,
335
- multi: true
336
- },
337
- {
338
- provide: USER_OPTIONS,
339
- useValue: options
340
- },
341
- {
342
- provide: NGXS_STORAGE_PLUGIN_OPTIONS,
343
- useFactory: storageOptionsFactory,
344
- deps: [USER_OPTIONS]
345
- },
346
- {
347
- provide: STORAGE_ENGINE,
348
- useFactory: engineFactory,
349
- deps: [NGXS_STORAGE_PLUGIN_OPTIONS, PLATFORM_ID]
350
- }
351
- ]
352
- };
353
- }
354
- }
355
- NgxsStoragePluginModule.decorators = [
356
- { type: NgModule }
365
+ /**
366
+ * @fileoverview added by tsickle
367
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
368
+ */
369
+ /** @type {?} */
370
+ const USER_OPTIONS = new InjectionToken('USER_OPTIONS');
371
+ class NgxsStoragePluginModule {
372
+ /**
373
+ * @param {?=} options
374
+ * @return {?}
375
+ */
376
+ static forRoot(options) {
377
+ return {
378
+ ngModule: NgxsStoragePluginModule,
379
+ providers: [
380
+ {
381
+ provide: NGXS_PLUGINS,
382
+ useClass: NgxsStoragePlugin,
383
+ multi: true
384
+ },
385
+ {
386
+ provide: USER_OPTIONS,
387
+ useValue: options
388
+ },
389
+ {
390
+ provide: NGXS_STORAGE_PLUGIN_OPTIONS,
391
+ useFactory: storageOptionsFactory,
392
+ deps: [USER_OPTIONS]
393
+ },
394
+ {
395
+ provide: STORAGE_ENGINE,
396
+ useFactory: engineFactory,
397
+ deps: [NGXS_STORAGE_PLUGIN_OPTIONS, PLATFORM_ID]
398
+ }
399
+ ]
400
+ };
401
+ }
402
+ }
403
+ NgxsStoragePluginModule.decorators = [
404
+ { type: NgModule }
357
405
  ];
358
406
 
359
- /**
360
- * @fileoverview added by tsickle
361
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
407
+ /**
408
+ * @fileoverview added by tsickle
409
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
362
410
  */
363
411
 
364
- /**
365
- * @fileoverview added by tsickle
366
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
412
+ /**
413
+ * @fileoverview added by tsickle
414
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
367
415
  */
368
416
 
369
- /**
370
- * @fileoverview added by tsickle
371
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
417
+ /**
418
+ * @fileoverview added by tsickle
419
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
372
420
  */
373
421
 
374
422
  export { NGXS_STORAGE_PLUGIN_OPTIONS, NgxsStoragePlugin, NgxsStoragePluginModule, STORAGE_ENGINE, USER_OPTIONS as ɵa, storageOptionsFactory as ɵb, engineFactory as ɵc };