@ngxs/storage-plugin 3.7.3-dev.master-f88f1ef → 3.7.4

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,372 @@ 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
+ }
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;
315
315
  }
316
316
 
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 }
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 }
357
357
  ];
358
358
 
359
- /**
360
- * @fileoverview added by tsickle
361
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
359
+ /**
360
+ * @fileoverview added by tsickle
361
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
362
362
  */
363
363
 
364
- /**
365
- * @fileoverview added by tsickle
366
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
364
+ /**
365
+ * @fileoverview added by tsickle
366
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
367
367
  */
368
368
 
369
- /**
370
- * @fileoverview added by tsickle
371
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
369
+ /**
370
+ * @fileoverview added by tsickle
371
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
372
372
  */
373
373
 
374
374
  export { NGXS_STORAGE_PLUGIN_OPTIONS, NgxsStoragePlugin, NgxsStoragePluginModule, STORAGE_ENGINE, USER_OPTIONS as ɵa, storageOptionsFactory as ɵb, engineFactory as ɵc };