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