@ngrx/store-devtools 6.0.1 → 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 +807 -604
- 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 +96 -78
- package/esm2015/src/index.js +3 -2
- package/esm2015/src/instrument.js +9 -48
- package/esm2015/src/reducer.js +190 -106
- 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 +69 -32
- package/esm5/src/index.js +2 -1
- package/esm5/src/instrument.js +16 -33
- package/esm5/src/reducer.js +259 -194
- package/esm5/src/utils.js +50 -14
- package/esm5/store-devtools.js +5 -5
- package/fesm2015/store-devtools.js +425 -201
- package/fesm2015/store-devtools.js.map +1 -1
- package/fesm5/store-devtools.js +509 -307
- package/fesm5/store-devtools.js.map +1 -1
- package/migrations/6_0_0/index.js +3 -3
- package/package.json +4 -3
- package/schematics/collection.json +10 -0
- package/schematics/ng-add/index.d.ts +4 -0
- package/schematics/ng-add/index.js +119 -0
- package/schematics/ng-add/schema.d.ts +8 -0
- package/schematics/ng-add/schema.js +13 -0
- package/schematics/ng-add/schema.json +34 -0
- package/schematics-core/index.d.ts +6 -6
- package/schematics-core/index.js +5 -3
- package/schematics-core/utility/ast-utils.js +13 -11
- package/schematics-core/utility/change.js +1 -1
- package/schematics-core/utility/config.js +1 -1
- package/schematics-core/utility/find-module.js +2 -2
- package/schematics-core/utility/ngrx-utils.d.ts +1 -1
- package/schematics-core/utility/ngrx-utils.js +12 -12
- package/schematics-core/utility/package.js +1 -1
- package/schematics-core/utility/parse-name.js +1 -1
- package/schematics-core/utility/project.d.ts +12 -0
- package/schematics-core/utility/project.js +12 -3
- 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 +15 -1
- package/src/devtools-dispatcher.d.ts +3 -0
- package/src/devtools.d.ts +3 -2
- package/src/extension.d.ts +10 -10
- 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 {
|
|
7
|
-
import { ActionsSubject, INIT, INITIAL_STATE,
|
|
8
|
-
import {
|
|
9
|
-
import { filter, map,
|
|
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
|
+
/** @type {?} */
|
|
17
18
|
const STORE_DEVTOOLS_CONFIG = new InjectionToken('@ngrx/devtools Options');
|
|
19
|
+
/** @type {?} */
|
|
18
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
|
|
85
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
23
86
|
*/
|
|
87
|
+
/** @type {?} */
|
|
24
88
|
const PERFORM_ACTION = 'PERFORM_ACTION';
|
|
89
|
+
/** @type {?} */
|
|
25
90
|
const REFRESH = 'REFRESH';
|
|
91
|
+
/** @type {?} */
|
|
26
92
|
const RESET = 'RESET';
|
|
93
|
+
/** @type {?} */
|
|
27
94
|
const ROLLBACK = 'ROLLBACK';
|
|
95
|
+
/** @type {?} */
|
|
28
96
|
const COMMIT = 'COMMIT';
|
|
97
|
+
/** @type {?} */
|
|
29
98
|
const SWEEP = 'SWEEP';
|
|
99
|
+
/** @type {?} */
|
|
30
100
|
const TOGGLE_ACTION = 'TOGGLE_ACTION';
|
|
101
|
+
/** @type {?} */
|
|
31
102
|
const SET_ACTIONS_ACTIVE = 'SET_ACTIONS_ACTIVE';
|
|
103
|
+
/** @type {?} */
|
|
32
104
|
const JUMP_TO_STATE = 'JUMP_TO_STATE';
|
|
105
|
+
/** @type {?} */
|
|
33
106
|
const JUMP_TO_ACTION = 'JUMP_TO_ACTION';
|
|
107
|
+
/** @type {?} */
|
|
34
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
|
|
@@ -93,7 +171,6 @@ class ToggleAction {
|
|
|
93
171
|
this.type = TOGGLE_ACTION;
|
|
94
172
|
}
|
|
95
173
|
}
|
|
96
|
-
|
|
97
174
|
class JumpToState {
|
|
98
175
|
/**
|
|
99
176
|
* @param {?} index
|
|
@@ -121,10 +198,28 @@ class ImportState {
|
|
|
121
198
|
this.type = IMPORT_STATE;
|
|
122
199
|
}
|
|
123
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
|
+
}
|
|
124
219
|
|
|
125
220
|
/**
|
|
126
221
|
* @fileoverview added by tsickle
|
|
127
|
-
* @suppress {checkTypes} checked by tsc
|
|
222
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
128
223
|
*/
|
|
129
224
|
/**
|
|
130
225
|
* @param {?} first
|
|
@@ -144,11 +239,6 @@ function unliftState(liftedState) {
|
|
|
144
239
|
const { state } = computedStates[currentStateIndex];
|
|
145
240
|
return state;
|
|
146
241
|
}
|
|
147
|
-
/**
|
|
148
|
-
* @param {?} liftedState
|
|
149
|
-
* @return {?}
|
|
150
|
-
*/
|
|
151
|
-
|
|
152
242
|
/**
|
|
153
243
|
* Lifts an app's action into an action on the lifted store.
|
|
154
244
|
* @param {?} action
|
|
@@ -165,7 +255,8 @@ function liftAction(action) {
|
|
|
165
255
|
*/
|
|
166
256
|
function sanitizeActions(actionSanitizer, actions) {
|
|
167
257
|
return Object.keys(actions).reduce((sanitizedActions, actionIdx) => {
|
|
168
|
-
|
|
258
|
+
/** @type {?} */
|
|
259
|
+
const idx = Number(actionIdx);
|
|
169
260
|
sanitizedActions[idx] = sanitizeAction(actionSanitizer, actions[idx], idx);
|
|
170
261
|
return sanitizedActions;
|
|
171
262
|
}, /** @type {?} */ ({}));
|
|
@@ -202,38 +293,91 @@ function sanitizeStates(stateSanitizer, states) {
|
|
|
202
293
|
function sanitizeState(stateSanitizer, state, stateIdx) {
|
|
203
294
|
return stateSanitizer(state, stateIdx);
|
|
204
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
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* @fileoverview added by tsickle
|
|
351
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
352
|
+
*/
|
|
353
|
+
class DevtoolsDispatcher extends ActionsSubject {
|
|
354
|
+
}
|
|
355
|
+
DevtoolsDispatcher.decorators = [
|
|
356
|
+
{ type: Injectable }
|
|
357
|
+
];
|
|
205
358
|
|
|
206
359
|
/**
|
|
207
360
|
* @fileoverview added by tsickle
|
|
208
|
-
* @suppress {checkTypes} checked by tsc
|
|
361
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
209
362
|
*/
|
|
363
|
+
/** @type {?} */
|
|
210
364
|
const ExtensionActionTypes = {
|
|
211
365
|
START: 'START',
|
|
212
366
|
DISPATCH: 'DISPATCH',
|
|
213
367
|
STOP: 'STOP',
|
|
214
368
|
ACTION: 'ACTION',
|
|
215
369
|
};
|
|
370
|
+
/** @type {?} */
|
|
216
371
|
const REDUX_DEVTOOLS_EXTENSION = new InjectionToken('Redux Devtools Extension');
|
|
217
|
-
/**
|
|
218
|
-
* @record
|
|
219
|
-
*/
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* @record
|
|
223
|
-
*/
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* @record
|
|
227
|
-
*/
|
|
228
|
-
|
|
229
372
|
class DevtoolsExtension {
|
|
230
373
|
/**
|
|
231
374
|
* @param {?} devtoolsExtension
|
|
232
375
|
* @param {?} config
|
|
376
|
+
* @param {?} dispatcher
|
|
233
377
|
*/
|
|
234
|
-
constructor(devtoolsExtension, config) {
|
|
378
|
+
constructor(devtoolsExtension, config, dispatcher) {
|
|
235
379
|
this.config = config;
|
|
236
|
-
this.
|
|
380
|
+
this.dispatcher = dispatcher;
|
|
237
381
|
this.devtoolsExtension = devtoolsExtension;
|
|
238
382
|
this.createActionStreams();
|
|
239
383
|
}
|
|
@@ -247,8 +391,8 @@ class DevtoolsExtension {
|
|
|
247
391
|
return;
|
|
248
392
|
}
|
|
249
393
|
// Check to see if the action requires a full update of the liftedState.
|
|
250
|
-
// If it is a simple action generated by the user's app
|
|
251
|
-
// 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).
|
|
252
396
|
//
|
|
253
397
|
// A full liftedState update (slow: serializes the entire liftedState) is
|
|
254
398
|
// only required when:
|
|
@@ -260,23 +404,33 @@ class DevtoolsExtension {
|
|
|
260
404
|
// d) any action that is not a PerformAction to err on the side of
|
|
261
405
|
// caution.
|
|
262
406
|
if (action.type === PERFORM_ACTION) {
|
|
263
|
-
|
|
264
|
-
|
|
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
|
|
265
418
|
? sanitizeState(this.config.stateSanitizer, currentState, state.currentStateIndex)
|
|
266
419
|
: currentState;
|
|
267
|
-
|
|
420
|
+
/** @type {?} */
|
|
421
|
+
const sanitizedAction = this.config.actionSanitizer
|
|
268
422
|
? sanitizeAction(this.config.actionSanitizer, action, state.nextActionId)
|
|
269
423
|
: action;
|
|
270
424
|
this.extensionConnection.send(sanitizedAction, sanitizedState);
|
|
271
425
|
}
|
|
272
426
|
else {
|
|
273
|
-
|
|
274
|
-
const
|
|
427
|
+
/** @type {?} */
|
|
428
|
+
const sanitizedLiftedState = Object.assign({}, state, { stagedActionIds: state.stagedActionIds, actionsById: this.config.actionSanitizer
|
|
275
429
|
? sanitizeActions(this.config.actionSanitizer, state.actionsById)
|
|
276
430
|
: state.actionsById, computedStates: this.config.stateSanitizer
|
|
277
431
|
? sanitizeStates(this.config.stateSanitizer, state.computedStates)
|
|
278
432
|
: state.computedStates });
|
|
279
|
-
this.devtoolsExtension.send(null, sanitizedLiftedState, this.getExtensionConfig(this.
|
|
433
|
+
this.devtoolsExtension.send(null, sanitizedLiftedState, this.getExtensionConfig(this.config));
|
|
280
434
|
}
|
|
281
435
|
}
|
|
282
436
|
/**
|
|
@@ -287,7 +441,8 @@ class DevtoolsExtension {
|
|
|
287
441
|
return empty();
|
|
288
442
|
}
|
|
289
443
|
return new Observable(subscriber => {
|
|
290
|
-
|
|
444
|
+
/** @type {?} */
|
|
445
|
+
const connection = this.devtoolsExtension.connect(this.getExtensionConfig(this.config));
|
|
291
446
|
this.extensionConnection = connection;
|
|
292
447
|
connection.init();
|
|
293
448
|
connection.subscribe((change) => subscriber.next(change));
|
|
@@ -298,18 +453,35 @@ class DevtoolsExtension {
|
|
|
298
453
|
* @return {?}
|
|
299
454
|
*/
|
|
300
455
|
createActionStreams() {
|
|
301
|
-
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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$));
|
|
313
485
|
this.start$ = start$.pipe(takeUntil(stop$));
|
|
314
486
|
// Only take the action sources between the start/stop events
|
|
315
487
|
this.actions$ = this.start$.pipe(switchMap(() => actionsUntilStop$));
|
|
@@ -323,13 +495,12 @@ class DevtoolsExtension {
|
|
|
323
495
|
return typeof action === 'string' ? eval(`(${action})`) : action;
|
|
324
496
|
}
|
|
325
497
|
/**
|
|
326
|
-
* @param {?} instanceId
|
|
327
498
|
* @param {?} config
|
|
328
499
|
* @return {?}
|
|
329
500
|
*/
|
|
330
|
-
getExtensionConfig(
|
|
331
|
-
|
|
332
|
-
|
|
501
|
+
getExtensionConfig(config) {
|
|
502
|
+
/** @type {?} */
|
|
503
|
+
const extensionOptions = {
|
|
333
504
|
name: config.name,
|
|
334
505
|
features: config.features,
|
|
335
506
|
serialize: config.serialize,
|
|
@@ -345,31 +516,21 @@ DevtoolsExtension.decorators = [
|
|
|
345
516
|
];
|
|
346
517
|
/** @nocollapse */
|
|
347
518
|
DevtoolsExtension.ctorParameters = () => [
|
|
348
|
-
{ type: undefined, decorators: [{ type: Inject, args: [REDUX_DEVTOOLS_EXTENSION,] }
|
|
349
|
-
{ 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 }
|
|
350
522
|
];
|
|
351
523
|
|
|
352
524
|
/**
|
|
353
525
|
* @fileoverview added by tsickle
|
|
354
|
-
* @suppress {checkTypes} checked by tsc
|
|
526
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
355
527
|
*/
|
|
528
|
+
/** @type {?} */
|
|
356
529
|
const INIT_ACTION = { type: INIT };
|
|
357
|
-
/**
|
|
358
|
-
|
|
359
|
-
*/
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* @record
|
|
363
|
-
*/
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* @record
|
|
367
|
-
*/
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* @record
|
|
371
|
-
*/
|
|
372
|
-
|
|
530
|
+
/** @type {?} */
|
|
531
|
+
const RECOMPUTE = /** @type {?} */ ('@ngrx/store-devtools/recompute');
|
|
532
|
+
/** @type {?} */
|
|
533
|
+
const RECOMPUTE_ACTION = { type: RECOMPUTE };
|
|
373
534
|
/**
|
|
374
535
|
* Computes the next entry in the log by applying an action.
|
|
375
536
|
* @param {?} reducer
|
|
@@ -386,12 +547,14 @@ function computeNextEntry(reducer, action, state, error, errorHandler) {
|
|
|
386
547
|
error: 'Interrupted by an error up the chain',
|
|
387
548
|
};
|
|
388
549
|
}
|
|
389
|
-
|
|
390
|
-
let
|
|
550
|
+
/** @type {?} */
|
|
551
|
+
let nextState = state;
|
|
552
|
+
/** @type {?} */
|
|
553
|
+
let nextError;
|
|
391
554
|
try {
|
|
392
555
|
nextState = reducer(state, action);
|
|
393
556
|
}
|
|
394
|
-
catch (
|
|
557
|
+
catch (err) {
|
|
395
558
|
nextError = err.toString();
|
|
396
559
|
errorHandler.handleError(err.stack || err);
|
|
397
560
|
}
|
|
@@ -410,28 +573,44 @@ function computeNextEntry(reducer, action, state, error, errorHandler) {
|
|
|
410
573
|
* @param {?} stagedActionIds
|
|
411
574
|
* @param {?} skippedActionIds
|
|
412
575
|
* @param {?} errorHandler
|
|
576
|
+
* @param {?} isPaused
|
|
413
577
|
* @return {?}
|
|
414
578
|
*/
|
|
415
|
-
function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler) {
|
|
579
|
+
function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused) {
|
|
416
580
|
// Optimization: exit early and return the same reference
|
|
417
581
|
// if we know nothing could have changed.
|
|
418
582
|
if (minInvalidatedStateIndex >= computedStates.length &&
|
|
419
583
|
computedStates.length === stagedActionIds.length) {
|
|
420
584
|
return computedStates;
|
|
421
585
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
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
|
|
431
605
|
? previousEntry
|
|
432
606
|
: computeNextEntry(reducer, action, previousState, previousError, errorHandler);
|
|
433
607
|
nextComputedStates.push(entry);
|
|
434
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
|
+
}
|
|
435
614
|
return nextComputedStates;
|
|
436
615
|
}
|
|
437
616
|
/**
|
|
@@ -449,6 +628,8 @@ function liftInitialState(initialCommittedState, monitorReducer) {
|
|
|
449
628
|
committedState: initialCommittedState,
|
|
450
629
|
currentStateIndex: 0,
|
|
451
630
|
computedStates: [],
|
|
631
|
+
isLocked: false,
|
|
632
|
+
isPaused: false,
|
|
452
633
|
};
|
|
453
634
|
}
|
|
454
635
|
/**
|
|
@@ -465,7 +646,7 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
465
646
|
* Manages how the history actions modify the history state.
|
|
466
647
|
*/
|
|
467
648
|
return (reducer) => (liftedState, liftedAction) => {
|
|
468
|
-
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;
|
|
469
650
|
if (!liftedState) {
|
|
470
651
|
// Prevent mutating initialLiftedState
|
|
471
652
|
actionsById = Object.create(actionsById);
|
|
@@ -475,10 +656,11 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
475
656
|
* @return {?}
|
|
476
657
|
*/
|
|
477
658
|
function commitExcessActions(n) {
|
|
478
|
-
|
|
479
|
-
let
|
|
480
|
-
|
|
481
|
-
|
|
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++) {
|
|
482
664
|
if (computedStates[i + 1].error) {
|
|
483
665
|
// Stop if error is found. Commit actions up to error.
|
|
484
666
|
excess = i;
|
|
@@ -496,11 +678,51 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
496
678
|
currentStateIndex =
|
|
497
679
|
currentStateIndex > excess ? currentStateIndex - excess : 0;
|
|
498
680
|
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
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;
|
|
503
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
|
+
}
|
|
504
726
|
case RESET: {
|
|
505
727
|
// Get back to the state the store was created with.
|
|
506
728
|
actionsById = { 0: liftAction(INIT_ACTION) };
|
|
@@ -513,15 +735,7 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
513
735
|
break;
|
|
514
736
|
}
|
|
515
737
|
case COMMIT: {
|
|
516
|
-
|
|
517
|
-
// Squash any staged actions into a single committed state.
|
|
518
|
-
actionsById = { 0: liftAction(INIT_ACTION) };
|
|
519
|
-
nextActionId = 1;
|
|
520
|
-
stagedActionIds = [0];
|
|
521
|
-
skippedActionIds = [];
|
|
522
|
-
committedState = computedStates[currentStateIndex].state;
|
|
523
|
-
currentStateIndex = 0;
|
|
524
|
-
computedStates = [];
|
|
738
|
+
commitChanges();
|
|
525
739
|
break;
|
|
526
740
|
}
|
|
527
741
|
case ROLLBACK: {
|
|
@@ -536,10 +750,9 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
536
750
|
break;
|
|
537
751
|
}
|
|
538
752
|
case TOGGLE_ACTION: {
|
|
539
|
-
// Toggle whether an action with given ID is skipped.
|
|
540
|
-
// Being skipped means it is a no-op during the computation.
|
|
541
753
|
const { id: actionId } = liftedAction;
|
|
542
|
-
|
|
754
|
+
/** @type {?} */
|
|
755
|
+
const index = skippedActionIds.indexOf(actionId);
|
|
543
756
|
if (index === -1) {
|
|
544
757
|
skippedActionIds = [actionId, ...skippedActionIds];
|
|
545
758
|
}
|
|
@@ -551,11 +764,10 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
551
764
|
break;
|
|
552
765
|
}
|
|
553
766
|
case SET_ACTIONS_ACTIVE: {
|
|
554
|
-
// Toggle whether an action with given ID is skipped.
|
|
555
|
-
// Being skipped means it is a no-op during the computation.
|
|
556
767
|
const { start, end, active } = liftedAction;
|
|
557
|
-
|
|
558
|
-
|
|
768
|
+
/** @type {?} */
|
|
769
|
+
const actionIds = [];
|
|
770
|
+
for (let i = start; i < end; i++)
|
|
559
771
|
actionIds.push(i);
|
|
560
772
|
if (active) {
|
|
561
773
|
skippedActionIds = difference(skippedActionIds, actionIds);
|
|
@@ -576,9 +788,8 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
576
788
|
break;
|
|
577
789
|
}
|
|
578
790
|
case JUMP_TO_ACTION: {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
const /** @type {?} */ index = stagedActionIds.indexOf(liftedAction.actionId);
|
|
791
|
+
/** @type {?} */
|
|
792
|
+
const index = stagedActionIds.indexOf(liftedAction.actionId);
|
|
582
793
|
if (index !== -1)
|
|
583
794
|
currentStateIndex = index;
|
|
584
795
|
minInvalidatedStateIndex = Infinity;
|
|
@@ -592,6 +803,20 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
592
803
|
break;
|
|
593
804
|
}
|
|
594
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
|
+
}
|
|
595
820
|
// Auto-commit as new actions come in.
|
|
596
821
|
if (options.maxAge && stagedActionIds.length === options.maxAge) {
|
|
597
822
|
commitExcessActions(1);
|
|
@@ -599,7 +824,8 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
599
824
|
if (currentStateIndex === stagedActionIds.length - 1) {
|
|
600
825
|
currentStateIndex++;
|
|
601
826
|
}
|
|
602
|
-
|
|
827
|
+
/** @type {?} */
|
|
828
|
+
const actionId = nextActionId++;
|
|
603
829
|
// Mutation! This is the hottest path, and we optimize on purpose.
|
|
604
830
|
// It is safe because we set a new key in a cache dictionary.
|
|
605
831
|
actionsById[actionId] = liftedAction;
|
|
@@ -619,6 +845,9 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
619
845
|
committedState,
|
|
620
846
|
currentStateIndex,
|
|
621
847
|
computedStates,
|
|
848
|
+
isLocked,
|
|
849
|
+
// prettier-ignore
|
|
850
|
+
isPaused
|
|
622
851
|
} = liftedAction.nextLiftedState);
|
|
623
852
|
break;
|
|
624
853
|
}
|
|
@@ -627,7 +856,7 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
627
856
|
minInvalidatedStateIndex = 0;
|
|
628
857
|
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
629
858
|
// States must be recomputed before committing excess.
|
|
630
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler);
|
|
859
|
+
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
631
860
|
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
632
861
|
// Avoid double computation.
|
|
633
862
|
minInvalidatedStateIndex = Infinity;
|
|
@@ -635,32 +864,36 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
635
864
|
break;
|
|
636
865
|
}
|
|
637
866
|
case UPDATE: {
|
|
638
|
-
|
|
867
|
+
/** @type {?} */
|
|
868
|
+
const stateHasErrors = computedStates.filter(state => state.error).length > 0;
|
|
639
869
|
if (stateHasErrors) {
|
|
640
870
|
// Recompute all states
|
|
641
871
|
minInvalidatedStateIndex = 0;
|
|
642
872
|
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
643
873
|
// States must be recomputed before committing excess.
|
|
644
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler);
|
|
874
|
+
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
645
875
|
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
646
876
|
// Avoid double computation.
|
|
647
877
|
minInvalidatedStateIndex = Infinity;
|
|
648
878
|
}
|
|
649
879
|
}
|
|
650
880
|
else {
|
|
651
|
-
|
|
652
|
-
|
|
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);
|
|
653
893
|
}
|
|
654
|
-
// Add a new action to only recompute state
|
|
655
|
-
const /** @type {?} */ actionId = nextActionId++;
|
|
656
|
-
actionsById[actionId] = new PerformAction(liftedAction, +Date.now());
|
|
657
|
-
stagedActionIds = [...stagedActionIds, actionId];
|
|
658
|
-
minInvalidatedStateIndex = stagedActionIds.length - 1;
|
|
659
|
-
// States must be recomputed before committing excess.
|
|
660
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler);
|
|
661
894
|
// Recompute state history with latest reducer and update action
|
|
662
|
-
computedStates = computedStates.map(cmp => (Object.assign({}, cmp, { state: reducer(cmp.state,
|
|
663
|
-
currentStateIndex =
|
|
895
|
+
computedStates = computedStates.map(cmp => (Object.assign({}, cmp, { state: reducer(cmp.state, RECOMPUTE_ACTION) })));
|
|
896
|
+
currentStateIndex = stagedActionIds.length - 1;
|
|
664
897
|
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
665
898
|
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
666
899
|
}
|
|
@@ -676,7 +909,7 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
676
909
|
break;
|
|
677
910
|
}
|
|
678
911
|
}
|
|
679
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler);
|
|
912
|
+
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
680
913
|
monitorState = monitorReducer(monitorState, liftedAction);
|
|
681
914
|
return {
|
|
682
915
|
monitorState,
|
|
@@ -687,19 +920,16 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
687
920
|
committedState,
|
|
688
921
|
currentStateIndex,
|
|
689
922
|
computedStates,
|
|
923
|
+
isLocked,
|
|
924
|
+
isPaused,
|
|
690
925
|
};
|
|
691
926
|
};
|
|
692
927
|
}
|
|
693
928
|
|
|
694
929
|
/**
|
|
695
930
|
* @fileoverview added by tsickle
|
|
696
|
-
* @suppress {checkTypes} checked by tsc
|
|
931
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
697
932
|
*/
|
|
698
|
-
class DevtoolsDispatcher extends ActionsSubject {
|
|
699
|
-
}
|
|
700
|
-
DevtoolsDispatcher.decorators = [
|
|
701
|
-
{ type: Injectable }
|
|
702
|
-
];
|
|
703
933
|
class StoreDevtools {
|
|
704
934
|
/**
|
|
705
935
|
* @param {?} dispatcher
|
|
@@ -712,30 +942,46 @@ class StoreDevtools {
|
|
|
712
942
|
* @param {?} config
|
|
713
943
|
*/
|
|
714
944
|
constructor(dispatcher, actions$, reducers$, extension, scannedActions, errorHandler, initialState, config) {
|
|
715
|
-
|
|
716
|
-
const
|
|
717
|
-
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
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$
|
|
721
957
|
.pipe(withLatestFrom(liftedReducer$), scan(({ state: liftedState }, [action, reducer]) => {
|
|
722
|
-
|
|
723
|
-
|
|
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
|
|
724
966
|
extension.notify(action, reducedLiftedState);
|
|
725
967
|
return { state: reducedLiftedState, action };
|
|
726
968
|
}, { state: liftedInitialState, action: /** @type {?} */ (null) }))
|
|
727
969
|
.subscribe(({ state, action }) => {
|
|
728
970
|
liftedStateSubject.next(state);
|
|
729
971
|
if (action.type === PERFORM_ACTION) {
|
|
730
|
-
|
|
972
|
+
/** @type {?} */
|
|
973
|
+
const unliftedAction = (/** @type {?} */ (action)).action;
|
|
731
974
|
scannedActions.next(unliftedAction);
|
|
732
975
|
}
|
|
733
976
|
});
|
|
734
|
-
|
|
977
|
+
/** @type {?} */
|
|
978
|
+
const extensionStartSubscription = extension.start$.subscribe(() => {
|
|
735
979
|
this.refresh();
|
|
736
980
|
});
|
|
737
|
-
|
|
738
|
-
const /** @type {?} */
|
|
981
|
+
/** @type {?} */
|
|
982
|
+
const liftedState$ = /** @type {?} */ (liftedStateSubject.asObservable());
|
|
983
|
+
/** @type {?} */
|
|
984
|
+
const state$ = liftedState$.pipe(map(unliftState));
|
|
739
985
|
this.extensionStartSubscription = extensionStartSubscription;
|
|
740
986
|
this.stateSubscription = liftedStateSubscription;
|
|
741
987
|
this.dispatcher = dispatcher;
|
|
@@ -830,26 +1076,41 @@ class StoreDevtools {
|
|
|
830
1076
|
importState(nextLiftedState) {
|
|
831
1077
|
this.dispatch(new ImportState(nextLiftedState));
|
|
832
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
|
+
}
|
|
833
1093
|
}
|
|
834
1094
|
StoreDevtools.decorators = [
|
|
835
1095
|
{ type: Injectable }
|
|
836
1096
|
];
|
|
837
1097
|
/** @nocollapse */
|
|
838
1098
|
StoreDevtools.ctorParameters = () => [
|
|
839
|
-
{ type: DevtoolsDispatcher
|
|
840
|
-
{ type: ActionsSubject
|
|
841
|
-
{ type: ReducerObservable
|
|
842
|
-
{ type: DevtoolsExtension
|
|
843
|
-
{ type: ScannedActionsSubject
|
|
844
|
-
{ type: ErrorHandler
|
|
845
|
-
{ type: undefined, decorators: [{ type: Inject, args: [INITIAL_STATE,] }
|
|
846
|
-
{ 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,] }] }
|
|
847
1107
|
];
|
|
848
1108
|
|
|
849
1109
|
/**
|
|
850
1110
|
* @fileoverview added by tsickle
|
|
851
|
-
* @suppress {checkTypes} checked by tsc
|
|
1111
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
852
1112
|
*/
|
|
1113
|
+
/** @type {?} */
|
|
853
1114
|
const IS_EXTENSION_OR_MONITOR_PRESENT = new InjectionToken('Is Devtools Extension or Monitor Present');
|
|
854
1115
|
/**
|
|
855
1116
|
* @param {?} extension
|
|
@@ -863,7 +1124,8 @@ function createIsExtensionOrMonitorPresent(extension, config) {
|
|
|
863
1124
|
* @return {?}
|
|
864
1125
|
*/
|
|
865
1126
|
function createReduxDevtoolsExtension() {
|
|
866
|
-
|
|
1127
|
+
/** @type {?} */
|
|
1128
|
+
const extensionKey = '__REDUX_DEVTOOLS_EXTENSION__';
|
|
867
1129
|
if (typeof window === 'object' &&
|
|
868
1130
|
typeof (/** @type {?} */ (window))[extensionKey] !== 'undefined') {
|
|
869
1131
|
return (/** @type {?} */ (window))[extensionKey];
|
|
@@ -879,39 +1141,6 @@ function createReduxDevtoolsExtension() {
|
|
|
879
1141
|
function createStateObservable(devtools) {
|
|
880
1142
|
return devtools.state;
|
|
881
1143
|
}
|
|
882
|
-
/**
|
|
883
|
-
* @return {?}
|
|
884
|
-
*/
|
|
885
|
-
function noMonitor() {
|
|
886
|
-
return null;
|
|
887
|
-
}
|
|
888
|
-
const DEFAULT_NAME = 'NgRx Store DevTools';
|
|
889
|
-
/**
|
|
890
|
-
* @param {?} _options
|
|
891
|
-
* @return {?}
|
|
892
|
-
*/
|
|
893
|
-
function createConfig(_options) {
|
|
894
|
-
const /** @type {?} */ DEFAULT_OPTIONS = {
|
|
895
|
-
maxAge: false,
|
|
896
|
-
monitor: noMonitor,
|
|
897
|
-
actionSanitizer: undefined,
|
|
898
|
-
stateSanitizer: undefined,
|
|
899
|
-
name: DEFAULT_NAME,
|
|
900
|
-
serialize: false,
|
|
901
|
-
logOnly: false,
|
|
902
|
-
features: false,
|
|
903
|
-
};
|
|
904
|
-
let /** @type {?} */ options = typeof _options === 'function' ? _options() : _options;
|
|
905
|
-
const /** @type {?} */ logOnly = options.logOnly
|
|
906
|
-
? { pause: true, export: true, test: true }
|
|
907
|
-
: false;
|
|
908
|
-
const /** @type {?} */ features = options.features || logOnly;
|
|
909
|
-
const /** @type {?} */ config = Object.assign({}, DEFAULT_OPTIONS, { features }, options);
|
|
910
|
-
if (config.maxAge && config.maxAge < 2) {
|
|
911
|
-
throw new Error(`Devtools 'maxAge' cannot be less than 2, got ${config.maxAge}`);
|
|
912
|
-
}
|
|
913
|
-
return config;
|
|
914
|
-
}
|
|
915
1144
|
class StoreDevtoolsModule {
|
|
916
1145
|
/**
|
|
917
1146
|
* @param {?=} options
|
|
@@ -961,27 +1190,22 @@ StoreDevtoolsModule.decorators = [
|
|
|
961
1190
|
|
|
962
1191
|
/**
|
|
963
1192
|
* @fileoverview added by tsickle
|
|
964
|
-
* @suppress {checkTypes} checked by tsc
|
|
1193
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
965
1194
|
*/
|
|
966
1195
|
|
|
967
1196
|
/**
|
|
968
1197
|
* @fileoverview added by tsickle
|
|
969
|
-
* @suppress {checkTypes} checked by tsc
|
|
1198
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
970
1199
|
*/
|
|
971
1200
|
|
|
972
1201
|
/**
|
|
973
1202
|
* @fileoverview added by tsickle
|
|
974
|
-
* @suppress {checkTypes} checked by tsc
|
|
975
|
-
*/
|
|
976
|
-
/**
|
|
977
|
-
* DO NOT EDIT
|
|
978
|
-
*
|
|
979
|
-
* This file is automatically generated at build
|
|
1203
|
+
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
980
1204
|
*/
|
|
981
1205
|
|
|
982
1206
|
/**
|
|
983
1207
|
* Generated bundle index. Do not edit.
|
|
984
1208
|
*/
|
|
985
1209
|
|
|
986
|
-
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 };
|
|
987
1211
|
//# sourceMappingURL=store-devtools.js.map
|