@ngrx/store-devtools 6.1.2 → 7.0.0-beta.0
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/store-devtools.umd.js +511 -309
- package/bundles/store-devtools.umd.js.map +1 -1
- package/bundles/store-devtools.umd.min.js +2 -2
- package/bundles/store-devtools.umd.min.js.map +1 -1
- package/esm2015/index.js +3 -3
- package/esm2015/public_api.js +3 -3
- package/esm2015/src/actions.js +72 -24
- package/esm2015/src/config.js +89 -5
- package/esm2015/src/devtools-dispatcher.js +13 -0
- package/esm2015/src/devtools.js +56 -45
- package/esm2015/src/extension.js +95 -77
- package/esm2015/src/index.js +3 -2
- package/esm2015/src/instrument.js +9 -48
- package/esm2015/src/reducer.js +190 -107
- package/esm2015/src/utils.js +56 -3
- package/esm2015/store-devtools.js +5 -5
- package/esm5/index.js +1 -1
- package/esm5/src/actions.js +19 -1
- package/esm5/src/config.js +40 -1
- package/esm5/src/devtools-dispatcher.js +34 -0
- package/esm5/src/devtools.js +39 -38
- package/esm5/src/extension.js +68 -31
- package/esm5/src/index.js +2 -1
- package/esm5/src/instrument.js +16 -33
- package/esm5/src/reducer.js +259 -196
- package/esm5/src/utils.js +50 -14
- package/esm5/store-devtools.js +5 -5
- package/fesm2015/store-devtools.js +443 -181
- package/fesm2015/store-devtools.js.map +1 -1
- package/fesm5/store-devtools.js +504 -303
- package/fesm5/store-devtools.js.map +1 -1
- package/migrations/6_0_0/index.js +1 -1
- package/package.json +3 -3
- package/schematics/ng-add/index.js +4 -4
- package/schematics-core/index.d.ts +4 -4
- package/schematics-core/utility/ast-utils.js +12 -10
- package/schematics-core/utility/change.js +1 -1
- package/schematics-core/utility/config.js +1 -1
- package/schematics-core/utility/find-module.js +1 -1
- package/schematics-core/utility/ngrx-utils.js +6 -6
- package/schematics-core/utility/package.js +1 -1
- package/schematics-core/utility/parse-name.js +1 -1
- package/schematics-core/utility/project.js +1 -1
- package/schematics-core/utility/route-utils.js +1 -1
- package/schematics-core/utility/strings.js +1 -1
- package/schematics-core/utility/update.js +1 -1
- package/src/actions.d.ts +24 -12
- package/src/config.d.ts +7 -0
- package/src/devtools-dispatcher.d.ts +3 -0
- package/src/devtools.d.ts +3 -2
- package/src/extension.d.ts +8 -8
- package/src/index.d.ts +1 -1
- package/src/instrument.d.ts +1 -4
- package/src/reducer.d.ts +8 -2
- package/src/utils.d.ts +13 -1
- package/store-devtools.d.ts +4 -4
- package/store-devtools.metadata.json +1 -1
|
@@ -1,37 +1,115 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license NgRx
|
|
2
|
+
* @license NgRx 7.0.0-beta.0
|
|
3
3
|
* (c) 2015-2018 Brandon Roberts, Mike Ryan, Rob Wormald, Victor Savkin
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
|
-
import { InjectionToken,
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { InjectionToken, Injectable, Inject, ErrorHandler, NgModule } from '@angular/core';
|
|
7
|
+
import { ActionsSubject, UPDATE, INIT, INITIAL_STATE, ReducerObservable, ScannedActionsSubject, ReducerManagerDispatcher, StateObservable } from '@ngrx/store';
|
|
8
|
+
import { empty, of, Observable, merge, queueScheduler, ReplaySubject } from 'rxjs';
|
|
9
|
+
import { filter, map, share, switchMap, takeUntil, concatMap, debounceTime, timeout, catchError, take, observeOn, scan, skip, withLatestFrom } from 'rxjs/operators';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @fileoverview added by tsickle
|
|
13
|
-
* @suppress {checkTypes} checked by tsc
|
|
13
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
14
14
|
*/
|
|
15
15
|
class StoreDevtoolsConfig {
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
const
|
|
17
|
+
/** @type {?} */
|
|
18
|
+
const STORE_DEVTOOLS_CONFIG = new InjectionToken('@ngrx/devtools Options');
|
|
19
|
+
/** @type {?} */
|
|
20
|
+
const INITIAL_OPTIONS = new InjectionToken('@ngrx/devtools Initial Config');
|
|
21
|
+
/**
|
|
22
|
+
* @return {?}
|
|
23
|
+
*/
|
|
24
|
+
function noMonitor() {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
/** @type {?} */
|
|
28
|
+
const DEFAULT_NAME = 'NgRx Store DevTools';
|
|
29
|
+
/**
|
|
30
|
+
* @param {?} _options
|
|
31
|
+
* @return {?}
|
|
32
|
+
*/
|
|
33
|
+
function createConfig(_options) {
|
|
34
|
+
/** @type {?} */
|
|
35
|
+
const DEFAULT_OPTIONS = {
|
|
36
|
+
maxAge: false,
|
|
37
|
+
monitor: noMonitor,
|
|
38
|
+
actionSanitizer: undefined,
|
|
39
|
+
stateSanitizer: undefined,
|
|
40
|
+
name: DEFAULT_NAME,
|
|
41
|
+
serialize: false,
|
|
42
|
+
logOnly: false,
|
|
43
|
+
// Add all features explicitely. This prevent buggy behavior for
|
|
44
|
+
// options like "lock" which might otherwise not show up.
|
|
45
|
+
features: {
|
|
46
|
+
pause: true,
|
|
47
|
+
// start/pause recording of dispatched actions
|
|
48
|
+
lock: true,
|
|
49
|
+
// lock/unlock dispatching actions and side effects
|
|
50
|
+
persist: true,
|
|
51
|
+
// persist states on page reloading
|
|
52
|
+
export: true,
|
|
53
|
+
// export history of actions in a file
|
|
54
|
+
import: 'custom',
|
|
55
|
+
// import history of actions from a file
|
|
56
|
+
jump: true,
|
|
57
|
+
// jump back and forth (time travelling)
|
|
58
|
+
skip: true,
|
|
59
|
+
// skip (cancel) actions
|
|
60
|
+
reorder: true,
|
|
61
|
+
// drag and drop actions in the history list
|
|
62
|
+
dispatch: true,
|
|
63
|
+
// dispatch custom actions or action creators
|
|
64
|
+
test: true,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
/** @type {?} */
|
|
68
|
+
let options = typeof _options === 'function' ? _options() : _options;
|
|
69
|
+
/** @type {?} */
|
|
70
|
+
const logOnly = options.logOnly
|
|
71
|
+
? { pause: true, export: true, test: true }
|
|
72
|
+
: false;
|
|
73
|
+
/** @type {?} */
|
|
74
|
+
const features = options.features || logOnly || DEFAULT_OPTIONS.features;
|
|
75
|
+
/** @type {?} */
|
|
76
|
+
const config = Object.assign({}, DEFAULT_OPTIONS, { features }, options);
|
|
77
|
+
if (config.maxAge && config.maxAge < 2) {
|
|
78
|
+
throw new Error(`Devtools 'maxAge' cannot be less than 2, got ${config.maxAge}`);
|
|
79
|
+
}
|
|
80
|
+
return config;
|
|
81
|
+
}
|
|
19
82
|
|
|
20
83
|
/**
|
|
21
84
|
* @fileoverview added by tsickle
|
|
22
|
-
* @suppress {checkTypes} checked by tsc
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
85
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
86
|
+
*/
|
|
87
|
+
/** @type {?} */
|
|
88
|
+
const PERFORM_ACTION = 'PERFORM_ACTION';
|
|
89
|
+
/** @type {?} */
|
|
90
|
+
const REFRESH = 'REFRESH';
|
|
91
|
+
/** @type {?} */
|
|
92
|
+
const RESET = 'RESET';
|
|
93
|
+
/** @type {?} */
|
|
94
|
+
const ROLLBACK = 'ROLLBACK';
|
|
95
|
+
/** @type {?} */
|
|
96
|
+
const COMMIT = 'COMMIT';
|
|
97
|
+
/** @type {?} */
|
|
98
|
+
const SWEEP = 'SWEEP';
|
|
99
|
+
/** @type {?} */
|
|
100
|
+
const TOGGLE_ACTION = 'TOGGLE_ACTION';
|
|
101
|
+
/** @type {?} */
|
|
102
|
+
const SET_ACTIONS_ACTIVE = 'SET_ACTIONS_ACTIVE';
|
|
103
|
+
/** @type {?} */
|
|
104
|
+
const JUMP_TO_STATE = 'JUMP_TO_STATE';
|
|
105
|
+
/** @type {?} */
|
|
106
|
+
const JUMP_TO_ACTION = 'JUMP_TO_ACTION';
|
|
107
|
+
/** @type {?} */
|
|
108
|
+
const IMPORT_STATE = 'IMPORT_STATE';
|
|
109
|
+
/** @type {?} */
|
|
110
|
+
const LOCK_CHANGES = 'LOCK_CHANGES';
|
|
111
|
+
/** @type {?} */
|
|
112
|
+
const PAUSE_RECORDING = 'PAUSE_RECORDING';
|
|
35
113
|
class PerformAction {
|
|
36
114
|
/**
|
|
37
115
|
* @param {?} action
|
|
@@ -120,10 +198,28 @@ class ImportState {
|
|
|
120
198
|
this.type = IMPORT_STATE;
|
|
121
199
|
}
|
|
122
200
|
}
|
|
201
|
+
class LockChanges {
|
|
202
|
+
/**
|
|
203
|
+
* @param {?} status
|
|
204
|
+
*/
|
|
205
|
+
constructor(status) {
|
|
206
|
+
this.status = status;
|
|
207
|
+
this.type = LOCK_CHANGES;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
class PauseRecording {
|
|
211
|
+
/**
|
|
212
|
+
* @param {?} status
|
|
213
|
+
*/
|
|
214
|
+
constructor(status) {
|
|
215
|
+
this.status = status;
|
|
216
|
+
this.type = PAUSE_RECORDING;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
123
219
|
|
|
124
220
|
/**
|
|
125
221
|
* @fileoverview added by tsickle
|
|
126
|
-
* @suppress {checkTypes} checked by tsc
|
|
222
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
127
223
|
*/
|
|
128
224
|
/**
|
|
129
225
|
* @param {?} first
|
|
@@ -159,7 +255,8 @@ function liftAction(action) {
|
|
|
159
255
|
*/
|
|
160
256
|
function sanitizeActions(actionSanitizer, actions) {
|
|
161
257
|
return Object.keys(actions).reduce((sanitizedActions, actionIdx) => {
|
|
162
|
-
|
|
258
|
+
/** @type {?} */
|
|
259
|
+
const idx = Number(actionIdx);
|
|
163
260
|
sanitizedActions[idx] = sanitizeAction(actionSanitizer, actions[idx], idx);
|
|
164
261
|
return sanitizedActions;
|
|
165
262
|
}, /** @type {?} */ ({}));
|
|
@@ -196,26 +293,91 @@ function sanitizeStates(stateSanitizer, states) {
|
|
|
196
293
|
function sanitizeState(stateSanitizer, state, stateIdx) {
|
|
197
294
|
return stateSanitizer(state, stateIdx);
|
|
198
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* Read the config and tell if actions should be filtered
|
|
298
|
+
* @param {?} config
|
|
299
|
+
* @return {?}
|
|
300
|
+
*/
|
|
301
|
+
function shouldFilterActions(config) {
|
|
302
|
+
return config.predicate || config.actionsWhitelist || config.actionsBlacklist;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Return a full filtered lifted state
|
|
306
|
+
* @param {?} liftedState
|
|
307
|
+
* @param {?=} predicate
|
|
308
|
+
* @param {?=} whitelist
|
|
309
|
+
* @param {?=} blacklist
|
|
310
|
+
* @return {?}
|
|
311
|
+
*/
|
|
312
|
+
function filterLiftedState(liftedState, predicate, whitelist, blacklist) {
|
|
313
|
+
/** @type {?} */
|
|
314
|
+
const filteredStagedActionIds = [];
|
|
315
|
+
/** @type {?} */
|
|
316
|
+
const filteredActionsById = {};
|
|
317
|
+
/** @type {?} */
|
|
318
|
+
const filteredComputedStates = [];
|
|
319
|
+
liftedState.stagedActionIds.forEach((id, idx) => {
|
|
320
|
+
/** @type {?} */
|
|
321
|
+
const liftedAction = liftedState.actionsById[id];
|
|
322
|
+
if (!liftedAction)
|
|
323
|
+
return;
|
|
324
|
+
if (idx &&
|
|
325
|
+
isActionFiltered(liftedState.computedStates[idx], liftedAction, predicate, whitelist, blacklist)) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
filteredActionsById[id] = liftedAction;
|
|
329
|
+
filteredStagedActionIds.push(id);
|
|
330
|
+
filteredComputedStates.push(liftedState.computedStates[idx]);
|
|
331
|
+
});
|
|
332
|
+
return Object.assign({}, liftedState, { stagedActionIds: filteredStagedActionIds, actionsById: filteredActionsById, computedStates: filteredComputedStates });
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Return true is the action should be ignored
|
|
336
|
+
* @param {?} state
|
|
337
|
+
* @param {?} action
|
|
338
|
+
* @param {?=} predicate
|
|
339
|
+
* @param {?=} whitelist
|
|
340
|
+
* @param {?=} blacklist
|
|
341
|
+
* @return {?}
|
|
342
|
+
*/
|
|
343
|
+
function isActionFiltered(state, action, predicate, whitelist, blacklist) {
|
|
344
|
+
return ((predicate && !predicate(state, action.action)) ||
|
|
345
|
+
(whitelist && !action.action.type.match(whitelist.join('|'))) ||
|
|
346
|
+
(blacklist && action.action.type.match(blacklist.join('|'))));
|
|
347
|
+
}
|
|
199
348
|
|
|
200
349
|
/**
|
|
201
350
|
* @fileoverview added by tsickle
|
|
202
|
-
* @suppress {checkTypes} checked by tsc
|
|
351
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
203
352
|
*/
|
|
204
|
-
|
|
353
|
+
class DevtoolsDispatcher extends ActionsSubject {
|
|
354
|
+
}
|
|
355
|
+
DevtoolsDispatcher.decorators = [
|
|
356
|
+
{ type: Injectable }
|
|
357
|
+
];
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* @fileoverview added by tsickle
|
|
361
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
362
|
+
*/
|
|
363
|
+
/** @type {?} */
|
|
364
|
+
const ExtensionActionTypes = {
|
|
205
365
|
START: 'START',
|
|
206
366
|
DISPATCH: 'DISPATCH',
|
|
207
367
|
STOP: 'STOP',
|
|
208
368
|
ACTION: 'ACTION',
|
|
209
369
|
};
|
|
210
|
-
|
|
370
|
+
/** @type {?} */
|
|
371
|
+
const REDUX_DEVTOOLS_EXTENSION = new InjectionToken('Redux Devtools Extension');
|
|
211
372
|
class DevtoolsExtension {
|
|
212
373
|
/**
|
|
213
374
|
* @param {?} devtoolsExtension
|
|
214
375
|
* @param {?} config
|
|
376
|
+
* @param {?} dispatcher
|
|
215
377
|
*/
|
|
216
|
-
constructor(devtoolsExtension, config) {
|
|
378
|
+
constructor(devtoolsExtension, config, dispatcher) {
|
|
217
379
|
this.config = config;
|
|
218
|
-
this.
|
|
380
|
+
this.dispatcher = dispatcher;
|
|
219
381
|
this.devtoolsExtension = devtoolsExtension;
|
|
220
382
|
this.createActionStreams();
|
|
221
383
|
}
|
|
@@ -229,8 +391,8 @@ class DevtoolsExtension {
|
|
|
229
391
|
return;
|
|
230
392
|
}
|
|
231
393
|
// Check to see if the action requires a full update of the liftedState.
|
|
232
|
-
// If it is a simple action generated by the user's app
|
|
233
|
-
// action and the current state (fast).
|
|
394
|
+
// If it is a simple action generated by the user's app and the recording
|
|
395
|
+
// is not locked/paused, only send the action and the current state (fast).
|
|
234
396
|
//
|
|
235
397
|
// A full liftedState update (slow: serializes the entire liftedState) is
|
|
236
398
|
// only required when:
|
|
@@ -242,23 +404,33 @@ class DevtoolsExtension {
|
|
|
242
404
|
// d) any action that is not a PerformAction to err on the side of
|
|
243
405
|
// caution.
|
|
244
406
|
if (action.type === PERFORM_ACTION) {
|
|
245
|
-
|
|
246
|
-
|
|
407
|
+
if (state.isLocked || state.isPaused) {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
/** @type {?} */
|
|
411
|
+
const currentState = unliftState(state);
|
|
412
|
+
if (shouldFilterActions(this.config) &&
|
|
413
|
+
isActionFiltered(currentState, action, this.config.predicate, this.config.actionsWhitelist, this.config.actionsBlacklist)) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
/** @type {?} */
|
|
417
|
+
const sanitizedState = this.config.stateSanitizer
|
|
247
418
|
? sanitizeState(this.config.stateSanitizer, currentState, state.currentStateIndex)
|
|
248
419
|
: currentState;
|
|
249
|
-
|
|
420
|
+
/** @type {?} */
|
|
421
|
+
const sanitizedAction = this.config.actionSanitizer
|
|
250
422
|
? sanitizeAction(this.config.actionSanitizer, action, state.nextActionId)
|
|
251
423
|
: action;
|
|
252
424
|
this.extensionConnection.send(sanitizedAction, sanitizedState);
|
|
253
425
|
}
|
|
254
426
|
else {
|
|
255
|
-
|
|
256
|
-
const
|
|
427
|
+
/** @type {?} */
|
|
428
|
+
const sanitizedLiftedState = Object.assign({}, state, { stagedActionIds: state.stagedActionIds, actionsById: this.config.actionSanitizer
|
|
257
429
|
? sanitizeActions(this.config.actionSanitizer, state.actionsById)
|
|
258
430
|
: state.actionsById, computedStates: this.config.stateSanitizer
|
|
259
431
|
? sanitizeStates(this.config.stateSanitizer, state.computedStates)
|
|
260
432
|
: state.computedStates });
|
|
261
|
-
this.devtoolsExtension.send(null, sanitizedLiftedState, this.getExtensionConfig(this.
|
|
433
|
+
this.devtoolsExtension.send(null, sanitizedLiftedState, this.getExtensionConfig(this.config));
|
|
262
434
|
}
|
|
263
435
|
}
|
|
264
436
|
/**
|
|
@@ -269,7 +441,8 @@ class DevtoolsExtension {
|
|
|
269
441
|
return empty();
|
|
270
442
|
}
|
|
271
443
|
return new Observable(subscriber => {
|
|
272
|
-
|
|
444
|
+
/** @type {?} */
|
|
445
|
+
const connection = this.devtoolsExtension.connect(this.getExtensionConfig(this.config));
|
|
273
446
|
this.extensionConnection = connection;
|
|
274
447
|
connection.init();
|
|
275
448
|
connection.subscribe((change) => subscriber.next(change));
|
|
@@ -280,18 +453,35 @@ class DevtoolsExtension {
|
|
|
280
453
|
* @return {?}
|
|
281
454
|
*/
|
|
282
455
|
createActionStreams() {
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
456
|
+
/** @type {?} */
|
|
457
|
+
const changes$ = this.createChangesObservable().pipe(share());
|
|
458
|
+
/** @type {?} */
|
|
459
|
+
const start$ = changes$.pipe(filter((change) => change.type === ExtensionActionTypes.START));
|
|
460
|
+
/** @type {?} */
|
|
461
|
+
const stop$ = changes$.pipe(filter((change) => change.type === ExtensionActionTypes.STOP));
|
|
462
|
+
/** @type {?} */
|
|
463
|
+
const liftedActions$ = changes$.pipe(filter(change => change.type === ExtensionActionTypes.DISPATCH), map(change => this.unwrapAction(change.payload)), concatMap((action) => {
|
|
464
|
+
if (action.type === IMPORT_STATE) {
|
|
465
|
+
// State imports may happen in two situations:
|
|
466
|
+
// 1. Explicitly by user
|
|
467
|
+
// 2. User activated the "persist state accross reloads" option
|
|
468
|
+
// and now the state is imported during reload.
|
|
469
|
+
// Because of option 2, we need to give possible
|
|
470
|
+
// lazy loaded reducers time to instantiate.
|
|
471
|
+
// As soon as there is no UPDATE action within 1 second,
|
|
472
|
+
// it is assumed that all reducers are loaded.
|
|
473
|
+
return this.dispatcher.pipe(filter(action => action.type === UPDATE), timeout(1000), debounceTime(1000), map(() => action), catchError(() => of(action)), take(1));
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
return of(action);
|
|
477
|
+
}
|
|
478
|
+
}));
|
|
479
|
+
/** @type {?} */
|
|
480
|
+
const actions$ = changes$.pipe(filter(change => change.type === ExtensionActionTypes.ACTION), map(change => this.unwrapAction(change.payload)));
|
|
481
|
+
/** @type {?} */
|
|
482
|
+
const actionsUntilStop$ = actions$.pipe(takeUntil(stop$));
|
|
483
|
+
/** @type {?} */
|
|
484
|
+
const liftedUntilStop$ = liftedActions$.pipe(takeUntil(stop$));
|
|
295
485
|
this.start$ = start$.pipe(takeUntil(stop$));
|
|
296
486
|
// Only take the action sources between the start/stop events
|
|
297
487
|
this.actions$ = this.start$.pipe(switchMap(() => actionsUntilStop$));
|
|
@@ -305,13 +495,12 @@ class DevtoolsExtension {
|
|
|
305
495
|
return typeof action === 'string' ? eval(`(${action})`) : action;
|
|
306
496
|
}
|
|
307
497
|
/**
|
|
308
|
-
* @param {?} instanceId
|
|
309
498
|
* @param {?} config
|
|
310
499
|
* @return {?}
|
|
311
500
|
*/
|
|
312
|
-
getExtensionConfig(
|
|
313
|
-
|
|
314
|
-
|
|
501
|
+
getExtensionConfig(config) {
|
|
502
|
+
/** @type {?} */
|
|
503
|
+
const extensionOptions = {
|
|
315
504
|
name: config.name,
|
|
316
505
|
features: config.features,
|
|
317
506
|
serialize: config.serialize,
|
|
@@ -327,15 +516,21 @@ DevtoolsExtension.decorators = [
|
|
|
327
516
|
];
|
|
328
517
|
/** @nocollapse */
|
|
329
518
|
DevtoolsExtension.ctorParameters = () => [
|
|
330
|
-
{ type: undefined, decorators: [{ type: Inject, args: [REDUX_DEVTOOLS_EXTENSION,] }
|
|
331
|
-
{ type: StoreDevtoolsConfig, decorators: [{ type: Inject, args: [STORE_DEVTOOLS_CONFIG,] }
|
|
519
|
+
{ type: undefined, decorators: [{ type: Inject, args: [REDUX_DEVTOOLS_EXTENSION,] }] },
|
|
520
|
+
{ type: StoreDevtoolsConfig, decorators: [{ type: Inject, args: [STORE_DEVTOOLS_CONFIG,] }] },
|
|
521
|
+
{ type: DevtoolsDispatcher }
|
|
332
522
|
];
|
|
333
523
|
|
|
334
524
|
/**
|
|
335
525
|
* @fileoverview added by tsickle
|
|
336
|
-
* @suppress {checkTypes} checked by tsc
|
|
526
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
337
527
|
*/
|
|
338
|
-
|
|
528
|
+
/** @type {?} */
|
|
529
|
+
const INIT_ACTION = { type: INIT };
|
|
530
|
+
/** @type {?} */
|
|
531
|
+
const RECOMPUTE = /** @type {?} */ ('@ngrx/store-devtools/recompute');
|
|
532
|
+
/** @type {?} */
|
|
533
|
+
const RECOMPUTE_ACTION = { type: RECOMPUTE };
|
|
339
534
|
/**
|
|
340
535
|
* Computes the next entry in the log by applying an action.
|
|
341
536
|
* @param {?} reducer
|
|
@@ -352,12 +547,14 @@ function computeNextEntry(reducer, action, state, error, errorHandler) {
|
|
|
352
547
|
error: 'Interrupted by an error up the chain',
|
|
353
548
|
};
|
|
354
549
|
}
|
|
355
|
-
|
|
356
|
-
let
|
|
550
|
+
/** @type {?} */
|
|
551
|
+
let nextState = state;
|
|
552
|
+
/** @type {?} */
|
|
553
|
+
let nextError;
|
|
357
554
|
try {
|
|
358
555
|
nextState = reducer(state, action);
|
|
359
556
|
}
|
|
360
|
-
catch (
|
|
557
|
+
catch (err) {
|
|
361
558
|
nextError = err.toString();
|
|
362
559
|
errorHandler.handleError(err.stack || err);
|
|
363
560
|
}
|
|
@@ -376,28 +573,44 @@ function computeNextEntry(reducer, action, state, error, errorHandler) {
|
|
|
376
573
|
* @param {?} stagedActionIds
|
|
377
574
|
* @param {?} skippedActionIds
|
|
378
575
|
* @param {?} errorHandler
|
|
576
|
+
* @param {?} isPaused
|
|
379
577
|
* @return {?}
|
|
380
578
|
*/
|
|
381
|
-
function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler) {
|
|
579
|
+
function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused) {
|
|
382
580
|
// Optimization: exit early and return the same reference
|
|
383
581
|
// if we know nothing could have changed.
|
|
384
582
|
if (minInvalidatedStateIndex >= computedStates.length &&
|
|
385
583
|
computedStates.length === stagedActionIds.length) {
|
|
386
584
|
return computedStates;
|
|
387
585
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
const
|
|
586
|
+
/** @type {?} */
|
|
587
|
+
const nextComputedStates = computedStates.slice(0, minInvalidatedStateIndex);
|
|
588
|
+
/** @type {?} */
|
|
589
|
+
const lastIncludedActionId = stagedActionIds.length - (isPaused ? 1 : 0);
|
|
590
|
+
for (let i = minInvalidatedStateIndex; i < lastIncludedActionId; i++) {
|
|
591
|
+
/** @type {?} */
|
|
592
|
+
const actionId = stagedActionIds[i];
|
|
593
|
+
/** @type {?} */
|
|
594
|
+
const action = actionsById[actionId].action;
|
|
595
|
+
/** @type {?} */
|
|
596
|
+
const previousEntry = nextComputedStates[i - 1];
|
|
597
|
+
/** @type {?} */
|
|
598
|
+
const previousState = previousEntry ? previousEntry.state : committedState;
|
|
599
|
+
/** @type {?} */
|
|
600
|
+
const previousError = previousEntry ? previousEntry.error : undefined;
|
|
601
|
+
/** @type {?} */
|
|
602
|
+
const shouldSkip = skippedActionIds.indexOf(actionId) > -1;
|
|
603
|
+
/** @type {?} */
|
|
604
|
+
const entry = shouldSkip
|
|
397
605
|
? previousEntry
|
|
398
606
|
: computeNextEntry(reducer, action, previousState, previousError, errorHandler);
|
|
399
607
|
nextComputedStates.push(entry);
|
|
400
608
|
}
|
|
609
|
+
// If the recording is paused, the last state will not be recomputed,
|
|
610
|
+
// because it's essentially not part of the state history.
|
|
611
|
+
if (isPaused) {
|
|
612
|
+
nextComputedStates.push(computedStates[computedStates.length - 1]);
|
|
613
|
+
}
|
|
401
614
|
return nextComputedStates;
|
|
402
615
|
}
|
|
403
616
|
/**
|
|
@@ -415,6 +628,8 @@ function liftInitialState(initialCommittedState, monitorReducer) {
|
|
|
415
628
|
committedState: initialCommittedState,
|
|
416
629
|
currentStateIndex: 0,
|
|
417
630
|
computedStates: [],
|
|
631
|
+
isLocked: false,
|
|
632
|
+
isPaused: false,
|
|
418
633
|
};
|
|
419
634
|
}
|
|
420
635
|
/**
|
|
@@ -431,7 +646,7 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
431
646
|
* Manages how the history actions modify the history state.
|
|
432
647
|
*/
|
|
433
648
|
return (reducer) => (liftedState, liftedAction) => {
|
|
434
|
-
let { monitorState, actionsById, nextActionId, stagedActionIds, skippedActionIds, committedState, currentStateIndex, computedStates, } = liftedState || initialLiftedState;
|
|
649
|
+
let { monitorState, actionsById, nextActionId, stagedActionIds, skippedActionIds, committedState, currentStateIndex, computedStates, isLocked, isPaused, } = liftedState || initialLiftedState;
|
|
435
650
|
if (!liftedState) {
|
|
436
651
|
// Prevent mutating initialLiftedState
|
|
437
652
|
actionsById = Object.create(actionsById);
|
|
@@ -441,10 +656,11 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
441
656
|
* @return {?}
|
|
442
657
|
*/
|
|
443
658
|
function commitExcessActions(n) {
|
|
444
|
-
|
|
445
|
-
let
|
|
446
|
-
|
|
447
|
-
|
|
659
|
+
/** @type {?} */
|
|
660
|
+
let excess = n;
|
|
661
|
+
/** @type {?} */
|
|
662
|
+
let idsToDelete = stagedActionIds.slice(1, excess + 1);
|
|
663
|
+
for (let i = 0; i < idsToDelete.length; i++) {
|
|
448
664
|
if (computedStates[i + 1].error) {
|
|
449
665
|
// Stop if error is found. Commit actions up to error.
|
|
450
666
|
excess = i;
|
|
@@ -462,11 +678,51 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
462
678
|
currentStateIndex =
|
|
463
679
|
currentStateIndex > excess ? currentStateIndex - excess : 0;
|
|
464
680
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
681
|
+
/**
|
|
682
|
+
* @return {?}
|
|
683
|
+
*/
|
|
684
|
+
function commitChanges() {
|
|
685
|
+
// Consider the last committed state the new starting point.
|
|
686
|
+
// Squash any staged actions into a single committed state.
|
|
687
|
+
actionsById = { 0: liftAction(INIT_ACTION) };
|
|
688
|
+
nextActionId = 1;
|
|
689
|
+
stagedActionIds = [0];
|
|
690
|
+
skippedActionIds = [];
|
|
691
|
+
committedState = computedStates[currentStateIndex].state;
|
|
692
|
+
currentStateIndex = 0;
|
|
693
|
+
computedStates = [];
|
|
694
|
+
}
|
|
695
|
+
/** @type {?} */
|
|
696
|
+
let minInvalidatedStateIndex = 0;
|
|
469
697
|
switch (liftedAction.type) {
|
|
698
|
+
case LOCK_CHANGES: {
|
|
699
|
+
isLocked = liftedAction.status;
|
|
700
|
+
minInvalidatedStateIndex = Infinity;
|
|
701
|
+
break;
|
|
702
|
+
}
|
|
703
|
+
case PAUSE_RECORDING: {
|
|
704
|
+
isPaused = liftedAction.status;
|
|
705
|
+
if (isPaused) {
|
|
706
|
+
// Add a pause action to signal the devtools-user the recording is paused.
|
|
707
|
+
// The corresponding state will be overwritten on each update to always contain
|
|
708
|
+
// the latest state (see Actions.PERFORM_ACTION).
|
|
709
|
+
stagedActionIds = [...stagedActionIds, nextActionId];
|
|
710
|
+
actionsById[nextActionId] = new PerformAction({
|
|
711
|
+
type: '@ngrx/devtools/pause',
|
|
712
|
+
}, +Date.now());
|
|
713
|
+
nextActionId++;
|
|
714
|
+
minInvalidatedStateIndex = stagedActionIds.length - 1;
|
|
715
|
+
computedStates = computedStates.concat(computedStates[computedStates.length - 1]);
|
|
716
|
+
if (currentStateIndex === stagedActionIds.length - 2) {
|
|
717
|
+
currentStateIndex++;
|
|
718
|
+
}
|
|
719
|
+
minInvalidatedStateIndex = Infinity;
|
|
720
|
+
}
|
|
721
|
+
else {
|
|
722
|
+
commitChanges();
|
|
723
|
+
}
|
|
724
|
+
break;
|
|
725
|
+
}
|
|
470
726
|
case RESET: {
|
|
471
727
|
// Get back to the state the store was created with.
|
|
472
728
|
actionsById = { 0: liftAction(INIT_ACTION) };
|
|
@@ -479,15 +735,7 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
479
735
|
break;
|
|
480
736
|
}
|
|
481
737
|
case COMMIT: {
|
|
482
|
-
|
|
483
|
-
// Squash any staged actions into a single committed state.
|
|
484
|
-
actionsById = { 0: liftAction(INIT_ACTION) };
|
|
485
|
-
nextActionId = 1;
|
|
486
|
-
stagedActionIds = [0];
|
|
487
|
-
skippedActionIds = [];
|
|
488
|
-
committedState = computedStates[currentStateIndex].state;
|
|
489
|
-
currentStateIndex = 0;
|
|
490
|
-
computedStates = [];
|
|
738
|
+
commitChanges();
|
|
491
739
|
break;
|
|
492
740
|
}
|
|
493
741
|
case ROLLBACK: {
|
|
@@ -502,10 +750,9 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
502
750
|
break;
|
|
503
751
|
}
|
|
504
752
|
case TOGGLE_ACTION: {
|
|
505
|
-
// Toggle whether an action with given ID is skipped.
|
|
506
|
-
// Being skipped means it is a no-op during the computation.
|
|
507
753
|
const { id: actionId } = liftedAction;
|
|
508
|
-
|
|
754
|
+
/** @type {?} */
|
|
755
|
+
const index = skippedActionIds.indexOf(actionId);
|
|
509
756
|
if (index === -1) {
|
|
510
757
|
skippedActionIds = [actionId, ...skippedActionIds];
|
|
511
758
|
}
|
|
@@ -517,11 +764,10 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
517
764
|
break;
|
|
518
765
|
}
|
|
519
766
|
case SET_ACTIONS_ACTIVE: {
|
|
520
|
-
// Toggle whether an action with given ID is skipped.
|
|
521
|
-
// Being skipped means it is a no-op during the computation.
|
|
522
767
|
const { start, end, active } = liftedAction;
|
|
523
|
-
|
|
524
|
-
|
|
768
|
+
/** @type {?} */
|
|
769
|
+
const actionIds = [];
|
|
770
|
+
for (let i = start; i < end; i++)
|
|
525
771
|
actionIds.push(i);
|
|
526
772
|
if (active) {
|
|
527
773
|
skippedActionIds = difference(skippedActionIds, actionIds);
|
|
@@ -542,9 +788,8 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
542
788
|
break;
|
|
543
789
|
}
|
|
544
790
|
case JUMP_TO_ACTION: {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
const /** @type {?} */ index = stagedActionIds.indexOf(liftedAction.actionId);
|
|
791
|
+
/** @type {?} */
|
|
792
|
+
const index = stagedActionIds.indexOf(liftedAction.actionId);
|
|
548
793
|
if (index !== -1)
|
|
549
794
|
currentStateIndex = index;
|
|
550
795
|
minInvalidatedStateIndex = Infinity;
|
|
@@ -558,6 +803,20 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
558
803
|
break;
|
|
559
804
|
}
|
|
560
805
|
case PERFORM_ACTION: {
|
|
806
|
+
// Ignore action and return state as is if recording is locked
|
|
807
|
+
if (isLocked) {
|
|
808
|
+
return liftedState || initialLiftedState;
|
|
809
|
+
}
|
|
810
|
+
if (isPaused) {
|
|
811
|
+
/** @type {?} */
|
|
812
|
+
const lastState = computedStates[computedStates.length - 1];
|
|
813
|
+
computedStates = [
|
|
814
|
+
...computedStates.slice(0, -1),
|
|
815
|
+
computeNextEntry(reducer, liftedAction.action, lastState.state, lastState.error, errorHandler),
|
|
816
|
+
];
|
|
817
|
+
minInvalidatedStateIndex = Infinity;
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
561
820
|
// Auto-commit as new actions come in.
|
|
562
821
|
if (options.maxAge && stagedActionIds.length === options.maxAge) {
|
|
563
822
|
commitExcessActions(1);
|
|
@@ -565,7 +824,8 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
565
824
|
if (currentStateIndex === stagedActionIds.length - 1) {
|
|
566
825
|
currentStateIndex++;
|
|
567
826
|
}
|
|
568
|
-
|
|
827
|
+
/** @type {?} */
|
|
828
|
+
const actionId = nextActionId++;
|
|
569
829
|
// Mutation! This is the hottest path, and we optimize on purpose.
|
|
570
830
|
// It is safe because we set a new key in a cache dictionary.
|
|
571
831
|
actionsById[actionId] = liftedAction;
|
|
@@ -584,8 +844,10 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
584
844
|
skippedActionIds,
|
|
585
845
|
committedState,
|
|
586
846
|
currentStateIndex,
|
|
847
|
+
computedStates,
|
|
848
|
+
isLocked,
|
|
587
849
|
// prettier-ignore
|
|
588
|
-
|
|
850
|
+
isPaused
|
|
589
851
|
} = liftedAction.nextLiftedState);
|
|
590
852
|
break;
|
|
591
853
|
}
|
|
@@ -594,7 +856,7 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
594
856
|
minInvalidatedStateIndex = 0;
|
|
595
857
|
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
596
858
|
// States must be recomputed before committing excess.
|
|
597
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler);
|
|
859
|
+
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
598
860
|
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
599
861
|
// Avoid double computation.
|
|
600
862
|
minInvalidatedStateIndex = Infinity;
|
|
@@ -602,32 +864,36 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
602
864
|
break;
|
|
603
865
|
}
|
|
604
866
|
case UPDATE: {
|
|
605
|
-
|
|
867
|
+
/** @type {?} */
|
|
868
|
+
const stateHasErrors = computedStates.filter(state => state.error).length > 0;
|
|
606
869
|
if (stateHasErrors) {
|
|
607
870
|
// Recompute all states
|
|
608
871
|
minInvalidatedStateIndex = 0;
|
|
609
872
|
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
610
873
|
// States must be recomputed before committing excess.
|
|
611
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler);
|
|
874
|
+
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
612
875
|
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
613
876
|
// Avoid double computation.
|
|
614
877
|
minInvalidatedStateIndex = Infinity;
|
|
615
878
|
}
|
|
616
879
|
}
|
|
617
880
|
else {
|
|
618
|
-
|
|
619
|
-
|
|
881
|
+
// If not paused/locked, add a new action to signal devtools-user
|
|
882
|
+
// that there was a reducer update.
|
|
883
|
+
if (!isPaused && !isLocked) {
|
|
884
|
+
if (currentStateIndex === stagedActionIds.length - 1) {
|
|
885
|
+
currentStateIndex++;
|
|
886
|
+
}
|
|
887
|
+
/** @type {?} */
|
|
888
|
+
const actionId = nextActionId++;
|
|
889
|
+
actionsById[actionId] = new PerformAction(liftedAction, +Date.now());
|
|
890
|
+
stagedActionIds = [...stagedActionIds, actionId];
|
|
891
|
+
minInvalidatedStateIndex = stagedActionIds.length - 1;
|
|
892
|
+
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
620
893
|
}
|
|
621
|
-
// Add a new action to only recompute state
|
|
622
|
-
const /** @type {?} */ actionId = nextActionId++;
|
|
623
|
-
actionsById[actionId] = new PerformAction(liftedAction, +Date.now());
|
|
624
|
-
stagedActionIds = [...stagedActionIds, actionId];
|
|
625
|
-
minInvalidatedStateIndex = stagedActionIds.length - 1;
|
|
626
|
-
// States must be recomputed before committing excess.
|
|
627
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler);
|
|
628
894
|
// Recompute state history with latest reducer and update action
|
|
629
|
-
computedStates = computedStates.map(cmp => (Object.assign({}, cmp, { state: reducer(cmp.state,
|
|
630
|
-
currentStateIndex =
|
|
895
|
+
computedStates = computedStates.map(cmp => (Object.assign({}, cmp, { state: reducer(cmp.state, RECOMPUTE_ACTION) })));
|
|
896
|
+
currentStateIndex = stagedActionIds.length - 1;
|
|
631
897
|
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
632
898
|
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
633
899
|
}
|
|
@@ -643,7 +909,7 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
643
909
|
break;
|
|
644
910
|
}
|
|
645
911
|
}
|
|
646
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler);
|
|
912
|
+
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
647
913
|
monitorState = monitorReducer(monitorState, liftedAction);
|
|
648
914
|
return {
|
|
649
915
|
monitorState,
|
|
@@ -654,19 +920,16 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
654
920
|
committedState,
|
|
655
921
|
currentStateIndex,
|
|
656
922
|
computedStates,
|
|
923
|
+
isLocked,
|
|
924
|
+
isPaused,
|
|
657
925
|
};
|
|
658
926
|
};
|
|
659
927
|
}
|
|
660
928
|
|
|
661
929
|
/**
|
|
662
930
|
* @fileoverview added by tsickle
|
|
663
|
-
* @suppress {checkTypes} checked by tsc
|
|
931
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
664
932
|
*/
|
|
665
|
-
class DevtoolsDispatcher extends ActionsSubject {
|
|
666
|
-
}
|
|
667
|
-
DevtoolsDispatcher.decorators = [
|
|
668
|
-
{ type: Injectable }
|
|
669
|
-
];
|
|
670
933
|
class StoreDevtools {
|
|
671
934
|
/**
|
|
672
935
|
* @param {?} dispatcher
|
|
@@ -679,30 +942,46 @@ class StoreDevtools {
|
|
|
679
942
|
* @param {?} config
|
|
680
943
|
*/
|
|
681
944
|
constructor(dispatcher, actions$, reducers$, extension, scannedActions, errorHandler, initialState, config) {
|
|
682
|
-
|
|
683
|
-
const
|
|
684
|
-
|
|
685
|
-
const
|
|
686
|
-
|
|
687
|
-
const
|
|
945
|
+
/** @type {?} */
|
|
946
|
+
const liftedInitialState = liftInitialState(initialState, config.monitor);
|
|
947
|
+
/** @type {?} */
|
|
948
|
+
const liftReducer = liftReducerWith(initialState, liftedInitialState, errorHandler, config.monitor, config);
|
|
949
|
+
/** @type {?} */
|
|
950
|
+
const liftedAction$ = merge(merge(actions$.asObservable().pipe(skip(1)), extension.actions$).pipe(map(liftAction)), dispatcher, extension.liftedActions$).pipe(observeOn(queueScheduler));
|
|
951
|
+
/** @type {?} */
|
|
952
|
+
const liftedReducer$ = reducers$.pipe(map(liftReducer));
|
|
953
|
+
/** @type {?} */
|
|
954
|
+
const liftedStateSubject = new ReplaySubject(1);
|
|
955
|
+
/** @type {?} */
|
|
956
|
+
const liftedStateSubscription = liftedAction$
|
|
688
957
|
.pipe(withLatestFrom(liftedReducer$), scan(({ state: liftedState }, [action, reducer]) => {
|
|
689
|
-
|
|
690
|
-
|
|
958
|
+
/** @type {?} */
|
|
959
|
+
let reducedLiftedState = reducer(liftedState, action);
|
|
960
|
+
// On full state update
|
|
961
|
+
// If we have actions filters, we must filter completly our lifted state to be sync with the extension
|
|
962
|
+
if (action.type !== PERFORM_ACTION && shouldFilterActions(config)) {
|
|
963
|
+
reducedLiftedState = filterLiftedState(reducedLiftedState, config.predicate, config.actionsWhitelist, config.actionsBlacklist);
|
|
964
|
+
}
|
|
965
|
+
// Extension should be sent the sanitized lifted state
|
|
691
966
|
extension.notify(action, reducedLiftedState);
|
|
692
967
|
return { state: reducedLiftedState, action };
|
|
693
968
|
}, { state: liftedInitialState, action: /** @type {?} */ (null) }))
|
|
694
969
|
.subscribe(({ state, action }) => {
|
|
695
970
|
liftedStateSubject.next(state);
|
|
696
971
|
if (action.type === PERFORM_ACTION) {
|
|
697
|
-
|
|
972
|
+
/** @type {?} */
|
|
973
|
+
const unliftedAction = (/** @type {?} */ (action)).action;
|
|
698
974
|
scannedActions.next(unliftedAction);
|
|
699
975
|
}
|
|
700
976
|
});
|
|
701
|
-
|
|
977
|
+
/** @type {?} */
|
|
978
|
+
const extensionStartSubscription = extension.start$.subscribe(() => {
|
|
702
979
|
this.refresh();
|
|
703
980
|
});
|
|
704
|
-
|
|
705
|
-
const /** @type {?} */
|
|
981
|
+
/** @type {?} */
|
|
982
|
+
const liftedState$ = /** @type {?} */ (liftedStateSubject.asObservable());
|
|
983
|
+
/** @type {?} */
|
|
984
|
+
const state$ = liftedState$.pipe(map(unliftState));
|
|
706
985
|
this.extensionStartSubscription = extensionStartSubscription;
|
|
707
986
|
this.stateSubscription = liftedStateSubscription;
|
|
708
987
|
this.dispatcher = dispatcher;
|
|
@@ -797,27 +1076,42 @@ class StoreDevtools {
|
|
|
797
1076
|
importState(nextLiftedState) {
|
|
798
1077
|
this.dispatch(new ImportState(nextLiftedState));
|
|
799
1078
|
}
|
|
1079
|
+
/**
|
|
1080
|
+
* @param {?} status
|
|
1081
|
+
* @return {?}
|
|
1082
|
+
*/
|
|
1083
|
+
lockChanges(status) {
|
|
1084
|
+
this.dispatch(new LockChanges(status));
|
|
1085
|
+
}
|
|
1086
|
+
/**
|
|
1087
|
+
* @param {?} status
|
|
1088
|
+
* @return {?}
|
|
1089
|
+
*/
|
|
1090
|
+
pauseRecording(status) {
|
|
1091
|
+
this.dispatch(new PauseRecording(status));
|
|
1092
|
+
}
|
|
800
1093
|
}
|
|
801
1094
|
StoreDevtools.decorators = [
|
|
802
1095
|
{ type: Injectable }
|
|
803
1096
|
];
|
|
804
1097
|
/** @nocollapse */
|
|
805
1098
|
StoreDevtools.ctorParameters = () => [
|
|
806
|
-
{ type: DevtoolsDispatcher
|
|
807
|
-
{ type: ActionsSubject
|
|
808
|
-
{ type: ReducerObservable
|
|
809
|
-
{ type: DevtoolsExtension
|
|
810
|
-
{ type: ScannedActionsSubject
|
|
811
|
-
{ type: ErrorHandler
|
|
812
|
-
{ type: undefined, decorators: [{ type: Inject, args: [INITIAL_STATE,] }
|
|
813
|
-
{ type: StoreDevtoolsConfig, decorators: [{ type: Inject, args: [STORE_DEVTOOLS_CONFIG,] }
|
|
1099
|
+
{ type: DevtoolsDispatcher },
|
|
1100
|
+
{ type: ActionsSubject },
|
|
1101
|
+
{ type: ReducerObservable },
|
|
1102
|
+
{ type: DevtoolsExtension },
|
|
1103
|
+
{ type: ScannedActionsSubject },
|
|
1104
|
+
{ type: ErrorHandler },
|
|
1105
|
+
{ type: undefined, decorators: [{ type: Inject, args: [INITIAL_STATE,] }] },
|
|
1106
|
+
{ type: StoreDevtoolsConfig, decorators: [{ type: Inject, args: [STORE_DEVTOOLS_CONFIG,] }] }
|
|
814
1107
|
];
|
|
815
1108
|
|
|
816
1109
|
/**
|
|
817
1110
|
* @fileoverview added by tsickle
|
|
818
|
-
* @suppress {checkTypes} checked by tsc
|
|
1111
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
819
1112
|
*/
|
|
820
|
-
|
|
1113
|
+
/** @type {?} */
|
|
1114
|
+
const IS_EXTENSION_OR_MONITOR_PRESENT = new InjectionToken('Is Devtools Extension or Monitor Present');
|
|
821
1115
|
/**
|
|
822
1116
|
* @param {?} extension
|
|
823
1117
|
* @param {?} config
|
|
@@ -830,7 +1124,8 @@ function createIsExtensionOrMonitorPresent(extension, config) {
|
|
|
830
1124
|
* @return {?}
|
|
831
1125
|
*/
|
|
832
1126
|
function createReduxDevtoolsExtension() {
|
|
833
|
-
|
|
1127
|
+
/** @type {?} */
|
|
1128
|
+
const extensionKey = '__REDUX_DEVTOOLS_EXTENSION__';
|
|
834
1129
|
if (typeof window === 'object' &&
|
|
835
1130
|
typeof (/** @type {?} */ (window))[extensionKey] !== 'undefined') {
|
|
836
1131
|
return (/** @type {?} */ (window))[extensionKey];
|
|
@@ -846,39 +1141,6 @@ function createReduxDevtoolsExtension() {
|
|
|
846
1141
|
function createStateObservable(devtools) {
|
|
847
1142
|
return devtools.state;
|
|
848
1143
|
}
|
|
849
|
-
/**
|
|
850
|
-
* @return {?}
|
|
851
|
-
*/
|
|
852
|
-
function noMonitor() {
|
|
853
|
-
return null;
|
|
854
|
-
}
|
|
855
|
-
const /** @type {?} */ DEFAULT_NAME = 'NgRx Store DevTools';
|
|
856
|
-
/**
|
|
857
|
-
* @param {?} _options
|
|
858
|
-
* @return {?}
|
|
859
|
-
*/
|
|
860
|
-
function createConfig(_options) {
|
|
861
|
-
const /** @type {?} */ DEFAULT_OPTIONS = {
|
|
862
|
-
maxAge: false,
|
|
863
|
-
monitor: noMonitor,
|
|
864
|
-
actionSanitizer: undefined,
|
|
865
|
-
stateSanitizer: undefined,
|
|
866
|
-
name: DEFAULT_NAME,
|
|
867
|
-
serialize: false,
|
|
868
|
-
logOnly: false,
|
|
869
|
-
features: false,
|
|
870
|
-
};
|
|
871
|
-
let /** @type {?} */ options = typeof _options === 'function' ? _options() : _options;
|
|
872
|
-
const /** @type {?} */ logOnly = options.logOnly
|
|
873
|
-
? { pause: true, export: true, test: true }
|
|
874
|
-
: false;
|
|
875
|
-
const /** @type {?} */ features = options.features || logOnly;
|
|
876
|
-
const /** @type {?} */ config = Object.assign({}, DEFAULT_OPTIONS, { features }, options);
|
|
877
|
-
if (config.maxAge && config.maxAge < 2) {
|
|
878
|
-
throw new Error(`Devtools 'maxAge' cannot be less than 2, got ${config.maxAge}`);
|
|
879
|
-
}
|
|
880
|
-
return config;
|
|
881
|
-
}
|
|
882
1144
|
class StoreDevtoolsModule {
|
|
883
1145
|
/**
|
|
884
1146
|
* @param {?=} options
|
|
@@ -928,22 +1190,22 @@ StoreDevtoolsModule.decorators = [
|
|
|
928
1190
|
|
|
929
1191
|
/**
|
|
930
1192
|
* @fileoverview added by tsickle
|
|
931
|
-
* @suppress {checkTypes} checked by tsc
|
|
1193
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
932
1194
|
*/
|
|
933
1195
|
|
|
934
1196
|
/**
|
|
935
1197
|
* @fileoverview added by tsickle
|
|
936
|
-
* @suppress {checkTypes} checked by tsc
|
|
1198
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
937
1199
|
*/
|
|
938
1200
|
|
|
939
1201
|
/**
|
|
940
1202
|
* @fileoverview added by tsickle
|
|
941
|
-
* @suppress {checkTypes} checked by tsc
|
|
1203
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
942
1204
|
*/
|
|
943
1205
|
|
|
944
1206
|
/**
|
|
945
1207
|
* Generated bundle index. Do not edit.
|
|
946
1208
|
*/
|
|
947
1209
|
|
|
948
|
-
export { INITIAL_OPTIONS as ɵ
|
|
1210
|
+
export { INITIAL_OPTIONS as ɵngrx_modules_store_devtools_store_devtools_f, STORE_DEVTOOLS_CONFIG as ɵngrx_modules_store_devtools_store_devtools_e, createConfig as ɵngrx_modules_store_devtools_store_devtools_h, noMonitor as ɵngrx_modules_store_devtools_store_devtools_g, DevtoolsDispatcher as ɵngrx_modules_store_devtools_store_devtools_k, DevtoolsExtension as ɵngrx_modules_store_devtools_store_devtools_j, REDUX_DEVTOOLS_EXTENSION as ɵngrx_modules_store_devtools_store_devtools_i, IS_EXTENSION_OR_MONITOR_PRESENT as ɵngrx_modules_store_devtools_store_devtools_a, createIsExtensionOrMonitorPresent as ɵngrx_modules_store_devtools_store_devtools_b, createReduxDevtoolsExtension as ɵngrx_modules_store_devtools_store_devtools_c, createStateObservable as ɵngrx_modules_store_devtools_store_devtools_d, StoreDevtoolsModule, RECOMPUTE, StoreDevtools, StoreDevtoolsConfig };
|
|
949
1211
|
//# sourceMappingURL=store-devtools.js.map
|