@ngxs/hmr-plugin 3.7.4 → 3.7.5

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.
Files changed (51) hide show
  1. package/README.md +3 -3
  2. package/bundles/ngxs-hmr-plugin.umd.js +665 -665
  3. package/bundles/ngxs-hmr-plugin.umd.js.map +1 -1
  4. package/bundles/ngxs-hmr-plugin.umd.min.js.map +1 -1
  5. package/esm2015/index.js +9 -9
  6. package/esm2015/ngxs-hmr-plugin.js +8 -8
  7. package/esm2015/src/actions/hmr-before-destroy.action.js +24 -24
  8. package/esm2015/src/actions/hmr-init.action.js +24 -24
  9. package/esm2015/src/hmr-bootstrap.js +58 -58
  10. package/esm2015/src/hmr-manager.js +175 -175
  11. package/esm2015/src/internal/hmr-lifecycle.js +160 -160
  12. package/esm2015/src/internal/hmr-options-builder.js +28 -28
  13. package/esm2015/src/internal/hmr-state-context-factory.js +70 -70
  14. package/esm2015/src/internal/hmr-storage.js +35 -35
  15. package/esm2015/src/public_api.js +9 -9
  16. package/esm2015/src/symbols.js +62 -62
  17. package/esm2015/src/utils/externals.js +11 -11
  18. package/esm2015/src/utils/internals.js +22 -22
  19. package/esm5/index.js +9 -9
  20. package/esm5/ngxs-hmr-plugin.js +8 -8
  21. package/esm5/src/actions/hmr-before-destroy.action.js +27 -27
  22. package/esm5/src/actions/hmr-init.action.js +27 -27
  23. package/esm5/src/hmr-bootstrap.js +63 -63
  24. package/esm5/src/hmr-manager.js +222 -222
  25. package/esm5/src/internal/hmr-lifecycle.js +182 -182
  26. package/esm5/src/internal/hmr-options-builder.js +31 -31
  27. package/esm5/src/internal/hmr-state-context-factory.js +86 -86
  28. package/esm5/src/internal/hmr-storage.js +48 -48
  29. package/esm5/src/public_api.js +9 -9
  30. package/esm5/src/symbols.js +62 -62
  31. package/esm5/src/utils/externals.js +11 -11
  32. package/esm5/src/utils/internals.js +22 -22
  33. package/fesm2015/ngxs-hmr-plugin.js +582 -582
  34. package/fesm2015/ngxs-hmr-plugin.js.map +1 -1
  35. package/fesm5/ngxs-hmr-plugin.js +674 -674
  36. package/fesm5/ngxs-hmr-plugin.js.map +1 -1
  37. package/index.d.ts +4 -4
  38. package/ngxs-hmr-plugin.d.ts +4 -4
  39. package/package.json +1 -1
  40. package/src/actions/hmr-before-destroy.action.d.ts +6 -6
  41. package/src/actions/hmr-init.action.d.ts +6 -6
  42. package/src/hmr-bootstrap.d.ts +8 -8
  43. package/src/hmr-manager.d.ts +23 -23
  44. package/src/internal/hmr-lifecycle.d.ts +18 -18
  45. package/src/internal/hmr-options-builder.d.ts +7 -7
  46. package/src/internal/hmr-state-context-factory.d.ts +11 -11
  47. package/src/internal/hmr-storage.d.ts +6 -6
  48. package/src/public_api.d.ts +5 -5
  49. package/src/symbols.d.ts +54 -54
  50. package/src/utils/externals.d.ts +1 -1
  51. package/src/utils/internals.d.ts +2 -2
@@ -4,612 +4,612 @@ import { NgxsBootstrapper, InitialState } from '@ngxs/store/internals';
4
4
  import { Store } from '@ngxs/store';
5
5
  import { isStateOperator } from '@ngxs/store/operators';
6
6
 
7
- /**
8
- * @fileoverview added by tsickle
9
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
10
- */
11
- class HmrInitAction {
12
- /**
13
- * @param {?} payload
14
- */
15
- constructor(payload) {
16
- this.payload = payload;
17
- }
18
- /**
19
- * @return {?}
20
- */
21
- static get type() {
22
- // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
23
- return '@@HMR_INIT';
24
- }
25
- }
26
- if (false) {
27
- /** @type {?} */
28
- HmrInitAction.prototype.payload;
7
+ /**
8
+ * @fileoverview added by tsickle
9
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
10
+ */
11
+ class HmrInitAction {
12
+ /**
13
+ * @param {?} payload
14
+ */
15
+ constructor(payload) {
16
+ this.payload = payload;
17
+ }
18
+ /**
19
+ * @return {?}
20
+ */
21
+ static get type() {
22
+ // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
23
+ return '@@HMR_INIT';
24
+ }
25
+ }
26
+ if (false) {
27
+ /** @type {?} */
28
+ HmrInitAction.prototype.payload;
29
29
  }
30
30
 
31
- /**
32
- * @fileoverview added by tsickle
33
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
34
- */
35
- class HmrBeforeDestroyAction {
36
- /**
37
- * @param {?} payload
38
- */
39
- constructor(payload) {
40
- this.payload = payload;
41
- }
42
- /**
43
- * @return {?}
44
- */
45
- static get type() {
46
- // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
47
- return '@@HMR_BEFORE_DESTROY';
48
- }
49
- }
50
- if (false) {
51
- /** @type {?} */
52
- HmrBeforeDestroyAction.prototype.payload;
31
+ /**
32
+ * @fileoverview added by tsickle
33
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
34
+ */
35
+ class HmrBeforeDestroyAction {
36
+ /**
37
+ * @param {?} payload
38
+ */
39
+ constructor(payload) {
40
+ this.payload = payload;
41
+ }
42
+ /**
43
+ * @return {?}
44
+ */
45
+ static get type() {
46
+ // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
47
+ return '@@HMR_BEFORE_DESTROY';
48
+ }
49
+ }
50
+ if (false) {
51
+ /** @type {?} */
52
+ HmrBeforeDestroyAction.prototype.payload;
53
53
  }
54
54
 
55
- /**
56
- * @fileoverview added by tsickle
57
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
58
- */
59
- /**
60
- * @template T, S
61
- */
62
- class HmrStateContextFactory {
63
- /**
64
- * @param {?} module
65
- */
66
- constructor(module) {
67
- /** @type {?} */
68
- const store = module.injector.get(Store, undefined);
69
- if (!store) {
70
- throw new Error('Store not found, maybe you forgot to import the NgxsModule');
71
- }
72
- this.store = store;
73
- }
74
- /**
75
- * \@description
76
- * must be taken out into \@ngxs/store/internals
77
- * @return {?}
78
- */
79
- createStateContext() {
80
- return {
81
- dispatch: (/**
82
- * @param {?} actions
83
- * @return {?}
84
- */
85
- actions => (/** @type {?} */ (this.store)).dispatch(actions)),
86
- getState: (/**
87
- * @return {?}
88
- */
89
- () => (/** @type {?} */ ((/** @type {?} */ (this.store)).snapshot()))),
90
- setState: (/**
91
- * @param {?} val
92
- * @return {?}
93
- */
94
- val => {
95
- if (isStateOperator(val)) {
96
- /** @type {?} */
97
- const currentState = (/** @type {?} */ (this.store)).snapshot();
98
- val = val(currentState);
99
- }
100
- (/** @type {?} */ (this.store)).reset(val);
101
- return (/** @type {?} */ (val));
102
- }),
103
- patchState: (/**
104
- * @param {?} val
105
- * @return {?}
106
- */
107
- val => {
108
- /** @type {?} */
109
- const currentState = (/** @type {?} */ (this.store)).snapshot();
110
- /** @type {?} */
111
- const newState = Object.assign({}, currentState, ((/** @type {?} */ (val))));
112
- (/** @type {?} */ (this.store)).reset(newState);
113
- return newState;
114
- })
115
- };
116
- }
117
- }
118
- if (false) {
119
- /** @type {?} */
120
- HmrStateContextFactory.prototype.store;
55
+ /**
56
+ * @fileoverview added by tsickle
57
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
58
+ */
59
+ /**
60
+ * @template T, S
61
+ */
62
+ class HmrStateContextFactory {
63
+ /**
64
+ * @param {?} module
65
+ */
66
+ constructor(module) {
67
+ /** @type {?} */
68
+ const store = module.injector.get(Store, undefined);
69
+ if (!store) {
70
+ throw new Error('Store not found, maybe you forgot to import the NgxsModule');
71
+ }
72
+ this.store = store;
73
+ }
74
+ /**
75
+ * \@description
76
+ * must be taken out into \@ngxs/store/internals
77
+ * @return {?}
78
+ */
79
+ createStateContext() {
80
+ return {
81
+ dispatch: (/**
82
+ * @param {?} actions
83
+ * @return {?}
84
+ */
85
+ actions => (/** @type {?} */ (this.store)).dispatch(actions)),
86
+ getState: (/**
87
+ * @return {?}
88
+ */
89
+ () => (/** @type {?} */ ((/** @type {?} */ (this.store)).snapshot()))),
90
+ setState: (/**
91
+ * @param {?} val
92
+ * @return {?}
93
+ */
94
+ val => {
95
+ if (isStateOperator(val)) {
96
+ /** @type {?} */
97
+ const currentState = (/** @type {?} */ (this.store)).snapshot();
98
+ val = val(currentState);
99
+ }
100
+ (/** @type {?} */ (this.store)).reset(val);
101
+ return (/** @type {?} */ (val));
102
+ }),
103
+ patchState: (/**
104
+ * @param {?} val
105
+ * @return {?}
106
+ */
107
+ val => {
108
+ /** @type {?} */
109
+ const currentState = (/** @type {?} */ (this.store)).snapshot();
110
+ /** @type {?} */
111
+ const newState = Object.assign({}, currentState, ((/** @type {?} */ (val))));
112
+ (/** @type {?} */ (this.store)).reset(newState);
113
+ return newState;
114
+ })
115
+ };
116
+ }
117
+ }
118
+ if (false) {
119
+ /** @type {?} */
120
+ HmrStateContextFactory.prototype.store;
121
121
  }
122
122
 
123
- /**
124
- * @fileoverview added by tsickle
125
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
126
- */
127
- class HmrOptionBuilder {
128
- /**
129
- * @param {?} __0
130
- */
131
- constructor({ deferTime, autoClearLogs }) {
132
- this.deferTime = deferTime || 100;
133
- this.autoClearLogs = autoClearLogs === undefined ? true : autoClearLogs;
134
- }
135
- /**
136
- * @return {?}
137
- */
138
- clearLogs() {
139
- if (this.autoClearLogs) {
140
- console.clear();
141
- }
142
- }
143
- }
144
- if (false) {
145
- /** @type {?} */
146
- HmrOptionBuilder.prototype.deferTime;
147
- /** @type {?} */
148
- HmrOptionBuilder.prototype.autoClearLogs;
123
+ /**
124
+ * @fileoverview added by tsickle
125
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
126
+ */
127
+ class HmrOptionBuilder {
128
+ /**
129
+ * @param {?} __0
130
+ */
131
+ constructor({ deferTime, autoClearLogs }) {
132
+ this.deferTime = deferTime || 100;
133
+ this.autoClearLogs = autoClearLogs === undefined ? true : autoClearLogs;
134
+ }
135
+ /**
136
+ * @return {?}
137
+ */
138
+ clearLogs() {
139
+ if (this.autoClearLogs) {
140
+ console.clear();
141
+ }
142
+ }
143
+ }
144
+ if (false) {
145
+ /** @type {?} */
146
+ HmrOptionBuilder.prototype.deferTime;
147
+ /** @type {?} */
148
+ HmrOptionBuilder.prototype.autoClearLogs;
149
149
  }
150
150
 
151
- /**
152
- * @fileoverview added by tsickle
153
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
154
- */
155
- /**
156
- * @template T, S
157
- */
158
- class HmrLifecycle {
159
- /**
160
- * @param {?} ngAppModule
161
- * @param {?} bootstrap
162
- * @param {?} storage
163
- * @param {?} context
164
- * @param {?} options
165
- */
166
- constructor(ngAppModule, bootstrap, storage, context, options) {
167
- this.ngAppModule = ngAppModule;
168
- this.bootstrap = bootstrap;
169
- this.storage = storage;
170
- this.context = context;
171
- this.options = options;
172
- }
173
- /**
174
- * @param {?} hmrAfterOnInit
175
- * @return {?}
176
- */
177
- hmrNgxsStoreOnInit(hmrAfterOnInit) {
178
- /** @type {?} */
179
- let moduleHmrInit = this.getModuleHmrInitCallback();
180
- moduleHmrInit = moduleHmrInit.bind(this.ngAppModule);
181
- this.detectIvyWithJIT();
182
- this.stateEventLoop((/**
183
- * @param {?} ctx
184
- * @param {?} state
185
- * @return {?}
186
- */
187
- (ctx, state) => {
188
- moduleHmrInit(ctx, state);
189
- hmrAfterOnInit(ctx, state);
190
- }));
191
- }
192
- /**
193
- * @private
194
- * @return {?}
195
- */
196
- getModuleHmrInitCallback() {
197
- if (typeof this.ngAppModule.hmrNgxsStoreOnInit === 'function') {
198
- return this.ngAppModule.hmrNgxsStoreOnInit;
199
- }
200
- return (/**
201
- * @param {?} ctx
202
- * @param {?} state
203
- * @return {?}
204
- */
205
- function defaultModuleHmrInit(ctx, state) {
206
- ctx.patchState(state);
207
- });
208
- }
209
- /**
210
- * @return {?}
211
- */
212
- hmrNgxsStoreBeforeOnDestroy() {
213
- /** @type {?} */
214
- let state = {};
215
- /** @type {?} */
216
- const ctx = this.context.createStateContext();
217
- if (typeof this.ngAppModule.hmrNgxsStoreBeforeOnDestroy === 'function') {
218
- state = this.ngAppModule.hmrNgxsStoreBeforeOnDestroy(ctx);
219
- }
220
- else {
221
- state = ctx.getState();
222
- }
223
- ctx.dispatch(new HmrBeforeDestroyAction(state));
224
- return state;
225
- }
226
- /**
227
- * @private
228
- * @param {?} callback
229
- * @return {?}
230
- */
231
- stateEventLoop(callback) {
232
- if (!this.storage.hasData())
233
- return;
234
- /** @type {?} */
235
- const appBootstrapped$ = this.bootstrap.appBootstrapped$;
236
- /** @type {?} */
237
- const state$ = this.context.store.select((/**
238
- * @param {?} state
239
- * @return {?}
240
- */
241
- state => state));
242
- appBootstrapped$.subscribe((/**
243
- * @return {?}
244
- */
245
- () => {
246
- /** @type {?} */
247
- let eventId;
248
- /** @type {?} */
249
- const storeEventId = state$.subscribe((/**
250
- * @return {?}
251
- */
252
- () => {
253
- // setTimeout used for zone detection after set hmr state
254
- clearInterval(eventId);
255
- eventId = window.setTimeout((/**
256
- * @return {?}
257
- */
258
- () => {
259
- // close check on the message queue
260
- storeEventId.unsubscribe();
261
- // if events are no longer running on the call stack,
262
- // then we can update the state
263
- callback(this.context.createStateContext(), (/** @type {?} */ (this.storage.snapshot)));
264
- }), this.options.deferTime);
265
- }));
266
- }));
267
- }
268
- /**
269
- * @private
270
- * @return {?}
271
- */
272
- detectIvyWithJIT() {
273
- /** @type {?} */
274
- const jit = this.ngAppModule.constructor.hasOwnProperty('__annotations__');
275
- /** @type {?} */
276
- const ivy = this.ngAppModule.constructor.hasOwnProperty('ɵmod');
277
- if (jit && ivy) {
278
- throw new Error(`@ngxs/hmr-plugin doesn't work with JIT mode in Angular Ivy. Please use AOT mode.`);
279
- }
280
- }
281
- }
282
- if (false) {
283
- /**
284
- * @type {?}
285
- * @private
286
- */
287
- HmrLifecycle.prototype.ngAppModule;
288
- /**
289
- * @type {?}
290
- * @private
291
- */
292
- HmrLifecycle.prototype.bootstrap;
293
- /**
294
- * @type {?}
295
- * @private
296
- */
297
- HmrLifecycle.prototype.storage;
298
- /**
299
- * @type {?}
300
- * @private
301
- */
302
- HmrLifecycle.prototype.context;
303
- /**
304
- * @type {?}
305
- * @private
306
- */
307
- HmrLifecycle.prototype.options;
151
+ /**
152
+ * @fileoverview added by tsickle
153
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
154
+ */
155
+ /**
156
+ * @template T, S
157
+ */
158
+ class HmrLifecycle {
159
+ /**
160
+ * @param {?} ngAppModule
161
+ * @param {?} bootstrap
162
+ * @param {?} storage
163
+ * @param {?} context
164
+ * @param {?} options
165
+ */
166
+ constructor(ngAppModule, bootstrap, storage, context, options) {
167
+ this.ngAppModule = ngAppModule;
168
+ this.bootstrap = bootstrap;
169
+ this.storage = storage;
170
+ this.context = context;
171
+ this.options = options;
172
+ }
173
+ /**
174
+ * @param {?} hmrAfterOnInit
175
+ * @return {?}
176
+ */
177
+ hmrNgxsStoreOnInit(hmrAfterOnInit) {
178
+ /** @type {?} */
179
+ let moduleHmrInit = this.getModuleHmrInitCallback();
180
+ moduleHmrInit = moduleHmrInit.bind(this.ngAppModule);
181
+ this.detectIvyWithJIT();
182
+ this.stateEventLoop((/**
183
+ * @param {?} ctx
184
+ * @param {?} state
185
+ * @return {?}
186
+ */
187
+ (ctx, state) => {
188
+ moduleHmrInit(ctx, state);
189
+ hmrAfterOnInit(ctx, state);
190
+ }));
191
+ }
192
+ /**
193
+ * @private
194
+ * @return {?}
195
+ */
196
+ getModuleHmrInitCallback() {
197
+ if (typeof this.ngAppModule.hmrNgxsStoreOnInit === 'function') {
198
+ return this.ngAppModule.hmrNgxsStoreOnInit;
199
+ }
200
+ return (/**
201
+ * @param {?} ctx
202
+ * @param {?} state
203
+ * @return {?}
204
+ */
205
+ function defaultModuleHmrInit(ctx, state) {
206
+ ctx.patchState(state);
207
+ });
208
+ }
209
+ /**
210
+ * @return {?}
211
+ */
212
+ hmrNgxsStoreBeforeOnDestroy() {
213
+ /** @type {?} */
214
+ let state = {};
215
+ /** @type {?} */
216
+ const ctx = this.context.createStateContext();
217
+ if (typeof this.ngAppModule.hmrNgxsStoreBeforeOnDestroy === 'function') {
218
+ state = this.ngAppModule.hmrNgxsStoreBeforeOnDestroy(ctx);
219
+ }
220
+ else {
221
+ state = ctx.getState();
222
+ }
223
+ ctx.dispatch(new HmrBeforeDestroyAction(state));
224
+ return state;
225
+ }
226
+ /**
227
+ * @private
228
+ * @param {?} callback
229
+ * @return {?}
230
+ */
231
+ stateEventLoop(callback) {
232
+ if (!this.storage.hasData())
233
+ return;
234
+ /** @type {?} */
235
+ const appBootstrapped$ = this.bootstrap.appBootstrapped$;
236
+ /** @type {?} */
237
+ const state$ = this.context.store.select((/**
238
+ * @param {?} state
239
+ * @return {?}
240
+ */
241
+ state => state));
242
+ appBootstrapped$.subscribe((/**
243
+ * @return {?}
244
+ */
245
+ () => {
246
+ /** @type {?} */
247
+ let eventId;
248
+ /** @type {?} */
249
+ const storeEventId = state$.subscribe((/**
250
+ * @return {?}
251
+ */
252
+ () => {
253
+ // setTimeout used for zone detection after set hmr state
254
+ clearInterval(eventId);
255
+ eventId = window.setTimeout((/**
256
+ * @return {?}
257
+ */
258
+ () => {
259
+ // close check on the message queue
260
+ storeEventId.unsubscribe();
261
+ // if events are no longer running on the call stack,
262
+ // then we can update the state
263
+ callback(this.context.createStateContext(), (/** @type {?} */ (this.storage.snapshot)));
264
+ }), this.options.deferTime);
265
+ }));
266
+ }));
267
+ }
268
+ /**
269
+ * @private
270
+ * @return {?}
271
+ */
272
+ detectIvyWithJIT() {
273
+ /** @type {?} */
274
+ const jit = this.ngAppModule.constructor.hasOwnProperty('__annotations__');
275
+ /** @type {?} */
276
+ const ivy = this.ngAppModule.constructor.hasOwnProperty('ɵmod');
277
+ if (jit && ivy) {
278
+ throw new Error(`@ngxs/hmr-plugin doesn't work with JIT mode in Angular Ivy. Please use AOT mode.`);
279
+ }
280
+ }
281
+ }
282
+ if (false) {
283
+ /**
284
+ * @type {?}
285
+ * @private
286
+ */
287
+ HmrLifecycle.prototype.ngAppModule;
288
+ /**
289
+ * @type {?}
290
+ * @private
291
+ */
292
+ HmrLifecycle.prototype.bootstrap;
293
+ /**
294
+ * @type {?}
295
+ * @private
296
+ */
297
+ HmrLifecycle.prototype.storage;
298
+ /**
299
+ * @type {?}
300
+ * @private
301
+ */
302
+ HmrLifecycle.prototype.context;
303
+ /**
304
+ * @type {?}
305
+ * @private
306
+ */
307
+ HmrLifecycle.prototype.options;
308
308
  }
309
309
 
310
- /**
311
- * @fileoverview added by tsickle
312
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
313
- */
314
- /**
315
- * @template T, S
316
- */
317
- class HmrManager {
318
- /**
319
- * @param {?} options
320
- * @param {?} storage
321
- */
322
- constructor(options, storage) {
323
- this.storage = storage;
324
- this.optionsBuilder = new HmrOptionBuilder(options);
325
- }
326
- /**
327
- * @private
328
- * @return {?}
329
- */
330
- get applicationRef() {
331
- return this.ngModule.injector.get(ApplicationRef);
332
- }
333
- /**
334
- * @private
335
- * @return {?}
336
- */
337
- get bootstrap() {
338
- return this.ngModule.injector.get(NgxsBootstrapper);
339
- }
340
- /**
341
- * @param {?} bootstrapFn
342
- * @param {?} tick
343
- * @return {?}
344
- */
345
- hmrModule(bootstrapFn, tick) {
346
- return __awaiter(this, void 0, void 0, function* () {
347
- InitialState.set(this.storage.snapshot);
348
- this.ngModule = yield bootstrapFn();
349
- this.context = new HmrStateContextFactory(this.ngModule);
350
- this.lifecycle = this.createLifecycle();
351
- tick();
352
- InitialState.pop();
353
- return this.ngModule;
354
- });
355
- }
356
- /**
357
- * @return {?}
358
- */
359
- beforeModuleBootstrap() {
360
- this.lifecycle.hmrNgxsStoreOnInit((/**
361
- * @param {?} ctx
362
- * @param {?} state
363
- * @return {?}
364
- */
365
- (ctx, state) => {
366
- ctx.dispatch(new HmrInitAction(state));
367
- }));
368
- }
369
- /**
370
- * @return {?}
371
- */
372
- beforeModuleOnDestroy() {
373
- this.optionsBuilder.clearLogs();
374
- return this.lifecycle.hmrNgxsStoreBeforeOnDestroy();
375
- }
376
- /**
377
- * @return {?}
378
- */
379
- createNewModule() {
380
- /** @type {?} */
381
- const removeOldHosts = this.cloneHostsBeforeDestroy();
382
- this.removeNgStyles();
383
- this.ngModule.destroy();
384
- removeOldHosts();
385
- }
386
- /**
387
- * @private
388
- * @return {?}
389
- */
390
- createLifecycle() {
391
- return new HmrLifecycle(this.ngModule.instance, this.bootstrap, this.storage, this.context, this.optionsBuilder);
392
- }
393
- /**
394
- * @private
395
- * @return {?}
396
- */
397
- cloneHostsBeforeDestroy() {
398
- /** @type {?} */
399
- const elements = this.applicationRef.components.map((/**
400
- * @param {?} component
401
- * @return {?}
402
- */
403
- (component) => component.location.nativeElement));
404
- /** @type {?} */
405
- const removableList = elements.map((/**
406
- * @param {?} componentNode
407
- * @return {?}
408
- */
409
- (componentNode) => {
410
- /** @type {?} */
411
- const newNode = document.createElement(componentNode.tagName);
412
- /** @type {?} */
413
- const parentNode = (/** @type {?} */ (componentNode.parentNode));
414
- /** @type {?} */
415
- const currentDisplay = newNode.style.display;
416
- newNode.style.display = 'none';
417
- parentNode.insertBefore(newNode, componentNode);
418
- return (/**
419
- * @return {?}
420
- */
421
- () => {
422
- newNode.style.display = currentDisplay;
423
- try {
424
- parentNode.removeChild(componentNode);
425
- }
426
- catch (_a) { }
427
- });
428
- }));
429
- return (/**
430
- * @return {?}
431
- */
432
- function removeOldHosts() {
433
- removableList.forEach((/**
434
- * @param {?} removeOldHost
435
- * @return {?}
436
- */
437
- (removeOldHost) => removeOldHost()));
438
- });
439
- }
440
- /**
441
- * @private
442
- * @return {?}
443
- */
444
- removeNgStyles() {
445
- /** @type {?} */
446
- const head = (/** @type {?} */ (document.head));
447
- /** @type {?} */
448
- const styles = Array.from((/** @type {?} */ (head)).querySelectorAll('style'));
449
- styles
450
- .filter((/**
451
- * @param {?} style
452
- * @return {?}
453
- */
454
- (style) => style.innerText.includes('_ng')))
455
- .map((/**
456
- * @param {?} style
457
- * @return {?}
458
- */
459
- (style) => (/** @type {?} */ (head)).removeChild(style)));
460
- }
461
- }
462
- if (false) {
463
- /** @type {?} */
464
- HmrManager.prototype.storage;
465
- /** @type {?} */
466
- HmrManager.prototype.context;
467
- /** @type {?} */
468
- HmrManager.prototype.lifecycle;
469
- /** @type {?} */
470
- HmrManager.prototype.optionsBuilder;
471
- /**
472
- * @type {?}
473
- * @private
474
- */
475
- HmrManager.prototype.ngModule;
310
+ /**
311
+ * @fileoverview added by tsickle
312
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
313
+ */
314
+ /**
315
+ * @template T, S
316
+ */
317
+ class HmrManager {
318
+ /**
319
+ * @param {?} options
320
+ * @param {?} storage
321
+ */
322
+ constructor(options, storage) {
323
+ this.storage = storage;
324
+ this.optionsBuilder = new HmrOptionBuilder(options);
325
+ }
326
+ /**
327
+ * @private
328
+ * @return {?}
329
+ */
330
+ get applicationRef() {
331
+ return this.ngModule.injector.get(ApplicationRef);
332
+ }
333
+ /**
334
+ * @private
335
+ * @return {?}
336
+ */
337
+ get bootstrap() {
338
+ return this.ngModule.injector.get(NgxsBootstrapper);
339
+ }
340
+ /**
341
+ * @param {?} bootstrapFn
342
+ * @param {?} tick
343
+ * @return {?}
344
+ */
345
+ hmrModule(bootstrapFn, tick) {
346
+ return __awaiter(this, void 0, void 0, function* () {
347
+ InitialState.set(this.storage.snapshot);
348
+ this.ngModule = yield bootstrapFn();
349
+ this.context = new HmrStateContextFactory(this.ngModule);
350
+ this.lifecycle = this.createLifecycle();
351
+ tick();
352
+ InitialState.pop();
353
+ return this.ngModule;
354
+ });
355
+ }
356
+ /**
357
+ * @return {?}
358
+ */
359
+ beforeModuleBootstrap() {
360
+ this.lifecycle.hmrNgxsStoreOnInit((/**
361
+ * @param {?} ctx
362
+ * @param {?} state
363
+ * @return {?}
364
+ */
365
+ (ctx, state) => {
366
+ ctx.dispatch(new HmrInitAction(state));
367
+ }));
368
+ }
369
+ /**
370
+ * @return {?}
371
+ */
372
+ beforeModuleOnDestroy() {
373
+ this.optionsBuilder.clearLogs();
374
+ return this.lifecycle.hmrNgxsStoreBeforeOnDestroy();
375
+ }
376
+ /**
377
+ * @return {?}
378
+ */
379
+ createNewModule() {
380
+ /** @type {?} */
381
+ const removeOldHosts = this.cloneHostsBeforeDestroy();
382
+ this.removeNgStyles();
383
+ this.ngModule.destroy();
384
+ removeOldHosts();
385
+ }
386
+ /**
387
+ * @private
388
+ * @return {?}
389
+ */
390
+ createLifecycle() {
391
+ return new HmrLifecycle(this.ngModule.instance, this.bootstrap, this.storage, this.context, this.optionsBuilder);
392
+ }
393
+ /**
394
+ * @private
395
+ * @return {?}
396
+ */
397
+ cloneHostsBeforeDestroy() {
398
+ /** @type {?} */
399
+ const elements = this.applicationRef.components.map((/**
400
+ * @param {?} component
401
+ * @return {?}
402
+ */
403
+ (component) => component.location.nativeElement));
404
+ /** @type {?} */
405
+ const removableList = elements.map((/**
406
+ * @param {?} componentNode
407
+ * @return {?}
408
+ */
409
+ (componentNode) => {
410
+ /** @type {?} */
411
+ const newNode = document.createElement(componentNode.tagName);
412
+ /** @type {?} */
413
+ const parentNode = (/** @type {?} */ (componentNode.parentNode));
414
+ /** @type {?} */
415
+ const currentDisplay = newNode.style.display;
416
+ newNode.style.display = 'none';
417
+ parentNode.insertBefore(newNode, componentNode);
418
+ return (/**
419
+ * @return {?}
420
+ */
421
+ () => {
422
+ newNode.style.display = currentDisplay;
423
+ try {
424
+ parentNode.removeChild(componentNode);
425
+ }
426
+ catch (_a) { }
427
+ });
428
+ }));
429
+ return (/**
430
+ * @return {?}
431
+ */
432
+ function removeOldHosts() {
433
+ removableList.forEach((/**
434
+ * @param {?} removeOldHost
435
+ * @return {?}
436
+ */
437
+ (removeOldHost) => removeOldHost()));
438
+ });
439
+ }
440
+ /**
441
+ * @private
442
+ * @return {?}
443
+ */
444
+ removeNgStyles() {
445
+ /** @type {?} */
446
+ const head = (/** @type {?} */ (document.head));
447
+ /** @type {?} */
448
+ const styles = Array.from((/** @type {?} */ (head)).querySelectorAll('style'));
449
+ styles
450
+ .filter((/**
451
+ * @param {?} style
452
+ * @return {?}
453
+ */
454
+ (style) => style.innerText.includes('_ng')))
455
+ .map((/**
456
+ * @param {?} style
457
+ * @return {?}
458
+ */
459
+ (style) => (/** @type {?} */ (head)).removeChild(style)));
460
+ }
461
+ }
462
+ if (false) {
463
+ /** @type {?} */
464
+ HmrManager.prototype.storage;
465
+ /** @type {?} */
466
+ HmrManager.prototype.context;
467
+ /** @type {?} */
468
+ HmrManager.prototype.lifecycle;
469
+ /** @type {?} */
470
+ HmrManager.prototype.optionsBuilder;
471
+ /**
472
+ * @type {?}
473
+ * @private
474
+ */
475
+ HmrManager.prototype.ngModule;
476
476
  }
477
477
 
478
- /**
479
- * @fileoverview added by tsickle
480
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
481
- */
482
- /**
483
- * @template S
484
- */
485
- class HmrStorage {
486
- /**
487
- * @param {?=} _snapshot
488
- */
489
- constructor(_snapshot = {}) {
490
- this._snapshot = _snapshot;
491
- }
492
- /**
493
- * @return {?}
494
- */
495
- hasData() {
496
- return Object.keys(this._snapshot).length > 0;
497
- }
498
- /**
499
- * @return {?}
500
- */
501
- get snapshot() {
502
- return this._snapshot;
503
- }
504
- }
505
- if (false) {
506
- /**
507
- * @type {?}
508
- * @private
509
- */
510
- HmrStorage.prototype._snapshot;
478
+ /**
479
+ * @fileoverview added by tsickle
480
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
481
+ */
482
+ /**
483
+ * @template S
484
+ */
485
+ class HmrStorage {
486
+ /**
487
+ * @param {?=} _snapshot
488
+ */
489
+ constructor(_snapshot = {}) {
490
+ this._snapshot = _snapshot;
491
+ }
492
+ /**
493
+ * @return {?}
494
+ */
495
+ hasData() {
496
+ return Object.keys(this._snapshot).length > 0;
497
+ }
498
+ /**
499
+ * @return {?}
500
+ */
501
+ get snapshot() {
502
+ return this._snapshot;
503
+ }
504
+ }
505
+ if (false) {
506
+ /**
507
+ * @type {?}
508
+ * @private
509
+ */
510
+ HmrStorage.prototype._snapshot;
511
511
  }
512
512
 
513
- /**
514
- * @fileoverview added by tsickle
515
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
516
- */
517
- /**
518
- * @param {?} value
519
- * @return {?}
520
- */
521
- function setHmrReloadedTo(value) {
522
- if (window["NGXS_HMR_LIFECYCLE_STATUS" /* Status */]) {
523
- window["NGXS_HMR_LIFECYCLE_STATUS" /* Status */].hmrReloaded = value;
524
- }
525
- }
526
- /**
527
- * @return {?}
528
- */
529
- function markApplicationAsHmrReloaded() {
530
- window["NGXS_HMR_LIFECYCLE_STATUS" /* Status */] = window["NGXS_HMR_LIFECYCLE_STATUS" /* Status */] || {
531
- hmrReloaded: false
532
- };
513
+ /**
514
+ * @fileoverview added by tsickle
515
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
516
+ */
517
+ /**
518
+ * @param {?} value
519
+ * @return {?}
520
+ */
521
+ function setHmrReloadedTo(value) {
522
+ if (window["NGXS_HMR_LIFECYCLE_STATUS" /* Status */]) {
523
+ window["NGXS_HMR_LIFECYCLE_STATUS" /* Status */].hmrReloaded = value;
524
+ }
525
+ }
526
+ /**
527
+ * @return {?}
528
+ */
529
+ function markApplicationAsHmrReloaded() {
530
+ window["NGXS_HMR_LIFECYCLE_STATUS" /* Status */] = window["NGXS_HMR_LIFECYCLE_STATUS" /* Status */] || {
531
+ hmrReloaded: false
532
+ };
533
533
  }
534
534
 
535
- /**
536
- * @fileoverview added by tsickle
537
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
538
- */
539
- /**
540
- * Hot Module Replacement plugin for NGXS
541
- * @deprecated As of Angular v10, HMR is no longer supported and will be deprecated.
542
- * More information [here](https://www.ngxs.io/plugins/hmr).
543
- * @template T
544
- * @param {?} webpackModule
545
- * @param {?} bootstrapFn
546
- * @param {?=} options
547
- * @return {?}
548
- */
549
- function hmr(webpackModule, bootstrapFn, options = {}) {
550
- return __awaiter(this, void 0, void 0, function* () {
551
- if (!webpackModule.hot) {
552
- console.error('Are you using the --hmr flag for ng serve?');
553
- throw new Error('HMR is not enabled for webpack-dev-server!');
554
- }
555
- markApplicationAsHmrReloaded();
556
- webpackModule.hot.accept();
557
- /**
558
- * @record
559
- */
560
- function HmrDataTransfer() { }
561
- if (false) {
562
- /** @type {?|undefined} */
563
- HmrDataTransfer.prototype.snapshot;
564
- }
565
- /** @type {?} */
566
- const dataTransfer = webpackModule.hot.data || {};
567
- /** @type {?} */
568
- const storage = new HmrStorage(dataTransfer.snapshot || {});
569
- /** @type {?} */
570
- const manager = new HmrManager(options, storage);
571
- return yield manager.hmrModule(bootstrapFn, (/**
572
- * @return {?}
573
- */
574
- () => {
575
- manager.beforeModuleBootstrap();
576
- (/** @type {?} */ (webpackModule.hot)).dispose((/**
577
- * @param {?} data
578
- * @return {?}
579
- */
580
- (data) => {
581
- setHmrReloadedTo(true);
582
- data.snapshot = manager.beforeModuleOnDestroy();
583
- manager.createNewModule();
584
- }));
585
- }));
586
- });
535
+ /**
536
+ * @fileoverview added by tsickle
537
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
538
+ */
539
+ /**
540
+ * Hot Module Replacement plugin for NGXS
541
+ * @deprecated As of Angular v10, HMR is no longer supported and will be deprecated.
542
+ * More information [here](https://www.ngxs.io/plugins/hmr).
543
+ * @template T
544
+ * @param {?} webpackModule
545
+ * @param {?} bootstrapFn
546
+ * @param {?=} options
547
+ * @return {?}
548
+ */
549
+ function hmr(webpackModule, bootstrapFn, options = {}) {
550
+ return __awaiter(this, void 0, void 0, function* () {
551
+ if (!webpackModule.hot) {
552
+ console.error('Are you using the --hmr flag for ng serve?');
553
+ throw new Error('HMR is not enabled for webpack-dev-server!');
554
+ }
555
+ markApplicationAsHmrReloaded();
556
+ webpackModule.hot.accept();
557
+ /**
558
+ * @record
559
+ */
560
+ function HmrDataTransfer() { }
561
+ if (false) {
562
+ /** @type {?|undefined} */
563
+ HmrDataTransfer.prototype.snapshot;
564
+ }
565
+ /** @type {?} */
566
+ const dataTransfer = webpackModule.hot.data || {};
567
+ /** @type {?} */
568
+ const storage = new HmrStorage(dataTransfer.snapshot || {});
569
+ /** @type {?} */
570
+ const manager = new HmrManager(options, storage);
571
+ return yield manager.hmrModule(bootstrapFn, (/**
572
+ * @return {?}
573
+ */
574
+ () => {
575
+ manager.beforeModuleBootstrap();
576
+ (/** @type {?} */ (webpackModule.hot)).dispose((/**
577
+ * @param {?} data
578
+ * @return {?}
579
+ */
580
+ (data) => {
581
+ setHmrReloadedTo(true);
582
+ data.snapshot = manager.beforeModuleOnDestroy();
583
+ manager.createNewModule();
584
+ }));
585
+ }));
586
+ });
587
587
  }
588
588
 
589
- /**
590
- * @fileoverview added by tsickle
591
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
592
- */
593
- /**
594
- * @return {?}
595
- */
596
- function hmrIsReloaded() {
597
- return !!(window["NGXS_HMR_LIFECYCLE_STATUS" /* Status */] && window["NGXS_HMR_LIFECYCLE_STATUS" /* Status */].hmrReloaded);
589
+ /**
590
+ * @fileoverview added by tsickle
591
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
592
+ */
593
+ /**
594
+ * @return {?}
595
+ */
596
+ function hmrIsReloaded() {
597
+ return !!(window["NGXS_HMR_LIFECYCLE_STATUS" /* Status */] && window["NGXS_HMR_LIFECYCLE_STATUS" /* Status */].hmrReloaded);
598
598
  }
599
599
 
600
- /**
601
- * @fileoverview added by tsickle
602
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
600
+ /**
601
+ * @fileoverview added by tsickle
602
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
603
603
  */
604
604
 
605
- /**
606
- * @fileoverview added by tsickle
607
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
605
+ /**
606
+ * @fileoverview added by tsickle
607
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
608
608
  */
609
609
 
610
- /**
611
- * @fileoverview added by tsickle
612
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
610
+ /**
611
+ * @fileoverview added by tsickle
612
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
613
613
  */
614
614
 
615
615
  export { HmrBeforeDestroyAction, HmrInitAction, hmr, hmrIsReloaded };