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