@ngrx/store-devtools 7.3.0 → 7.4.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 +4 -4
- 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 +1 -2
- package/esm2015/public_api.js +1 -2
- package/esm2015/src/actions.js +2 -6
- package/esm2015/src/config.js +2 -18
- package/esm2015/src/devtools-dispatcher.js +1 -2
- package/esm2015/src/devtools.js +31 -14
- package/esm2015/src/extension.js +151 -42
- package/esm2015/src/index.js +1 -2
- package/esm2015/src/instrument.js +4 -5
- package/esm2015/src/reducer.js +87 -52
- package/esm2015/src/utils.js +28 -10
- package/esm2015/store-devtools.js +0 -1
- package/esm5/index.js +0 -1
- package/esm5/public_api.js +0 -1
- package/esm5/src/actions.js +0 -1
- package/esm5/src/config.js +0 -1
- package/esm5/src/devtools-dispatcher.js +0 -1
- package/esm5/src/devtools.js +2 -3
- package/esm5/src/extension.js +0 -1
- package/esm5/src/index.js +0 -1
- package/esm5/src/instrument.js +0 -1
- package/esm5/src/reducer.js +0 -1
- package/esm5/src/utils.js +0 -1
- package/esm5/store-devtools.js +0 -1
- package/fesm2015/store-devtools.js +196 -54
- package/fesm2015/store-devtools.js.map +1 -1
- package/fesm5/store-devtools.js +4 -4
- package/fesm5/store-devtools.js.map +1 -1
- package/migrations/6_0_0/index.js +2 -2
- package/package.json +2 -2
- package/schematics/ng-add/index.js +24 -61
- package/schematics-core/index.d.ts +1 -2
- package/schematics-core/index.js +4 -5
- package/schematics-core/utility/ast-utils.d.ts +10 -0
- package/schematics-core/utility/ast-utils.js +153 -154
- package/schematics-core/utility/change.js +39 -46
- package/schematics-core/utility/config.js +8 -8
- package/schematics-core/utility/find-module.js +22 -22
- package/schematics-core/utility/ngrx-utils.d.ts +2 -0
- package/schematics-core/utility/ngrx-utils.js +83 -142
- package/schematics-core/utility/package.js +3 -3
- package/schematics-core/utility/parse-name.js +4 -4
- package/schematics-core/utility/project.js +11 -8
- package/schematics-core/utility/strings.d.ts +12 -0
- package/schematics-core/utility/strings.js +27 -12
- package/schematics-core/utility/update.js +13 -13
- package/store-devtools.metadata.json +1 -1
- package/schematics-core/utility/route-utils.d.ts +0 -20
- package/schematics-core/utility/route-utils.js +0 -84
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license NgRx 7.
|
|
2
|
+
* @license NgRx 7.4.0
|
|
3
3
|
* (c) 2015-2018 Brandon Roberts, Mike Ryan, Rob Wormald, Victor Savkin
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
import { InjectionToken, Injectable, Inject, ErrorHandler, NgModule } from '@angular/core';
|
|
7
|
-
import { ActionsSubject, UPDATE, INIT,
|
|
8
|
-
import { empty,
|
|
9
|
-
import {
|
|
7
|
+
import { ActionsSubject, UPDATE, INIT, ReducerObservable, ScannedActionsSubject, INITIAL_STATE, StateObservable, ReducerManagerDispatcher } from '@ngrx/store';
|
|
8
|
+
import { empty, Observable, of, merge, queueScheduler, ReplaySubject } from 'rxjs';
|
|
9
|
+
import { share, filter, map, concatMap, timeout, debounceTime, catchError, take, takeUntil, switchMap, skip, observeOn, withLatestFrom, scan } from 'rxjs/operators';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @fileoverview added by tsickle
|
|
13
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
13
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
14
14
|
*/
|
|
15
15
|
class StoreDevtoolsConfig {
|
|
16
16
|
}
|
|
@@ -82,7 +82,7 @@ function createConfig(_options) {
|
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* @fileoverview added by tsickle
|
|
85
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
85
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
86
86
|
*/
|
|
87
87
|
/** @type {?} */
|
|
88
88
|
const PERFORM_ACTION = 'PERFORM_ACTION';
|
|
@@ -219,7 +219,7 @@ class PauseRecording {
|
|
|
219
219
|
|
|
220
220
|
/**
|
|
221
221
|
* @fileoverview added by tsickle
|
|
222
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
222
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
223
223
|
*/
|
|
224
224
|
/**
|
|
225
225
|
* @param {?} first
|
|
@@ -227,7 +227,11 @@ class PauseRecording {
|
|
|
227
227
|
* @return {?}
|
|
228
228
|
*/
|
|
229
229
|
function difference(first, second) {
|
|
230
|
-
return first.filter(
|
|
230
|
+
return first.filter((/**
|
|
231
|
+
* @param {?} item
|
|
232
|
+
* @return {?}
|
|
233
|
+
*/
|
|
234
|
+
item => second.indexOf(item) < 0));
|
|
231
235
|
}
|
|
232
236
|
/**
|
|
233
237
|
* Provides an app's view into the state of the lifted store.
|
|
@@ -262,12 +266,17 @@ function liftAction(action) {
|
|
|
262
266
|
* @return {?}
|
|
263
267
|
*/
|
|
264
268
|
function sanitizeActions(actionSanitizer, actions) {
|
|
265
|
-
return Object.keys(actions).reduce((
|
|
269
|
+
return Object.keys(actions).reduce((/**
|
|
270
|
+
* @param {?} sanitizedActions
|
|
271
|
+
* @param {?} actionIdx
|
|
272
|
+
* @return {?}
|
|
273
|
+
*/
|
|
274
|
+
(sanitizedActions, actionIdx) => {
|
|
266
275
|
/** @type {?} */
|
|
267
276
|
const idx = Number(actionIdx);
|
|
268
277
|
sanitizedActions[idx] = sanitizeAction(actionSanitizer, actions[idx], idx);
|
|
269
278
|
return sanitizedActions;
|
|
270
|
-
}, /** @type {?} */ ({}));
|
|
279
|
+
}), (/** @type {?} */ ({})));
|
|
271
280
|
}
|
|
272
281
|
/**
|
|
273
282
|
* Sanitizes given action with given function.
|
|
@@ -286,10 +295,15 @@ function sanitizeAction(actionSanitizer, action, actionIdx) {
|
|
|
286
295
|
* @return {?}
|
|
287
296
|
*/
|
|
288
297
|
function sanitizeStates(stateSanitizer, states) {
|
|
289
|
-
return states.map((
|
|
298
|
+
return states.map((/**
|
|
299
|
+
* @param {?} computedState
|
|
300
|
+
* @param {?} idx
|
|
301
|
+
* @return {?}
|
|
302
|
+
*/
|
|
303
|
+
(computedState, idx) => ({
|
|
290
304
|
state: sanitizeState(stateSanitizer, computedState.state, idx),
|
|
291
305
|
error: computedState.error,
|
|
292
|
-
}));
|
|
306
|
+
})));
|
|
293
307
|
}
|
|
294
308
|
/**
|
|
295
309
|
* Sanitizes given state with given function.
|
|
@@ -324,7 +338,12 @@ function filterLiftedState(liftedState, predicate, whitelist, blacklist) {
|
|
|
324
338
|
const filteredActionsById = {};
|
|
325
339
|
/** @type {?} */
|
|
326
340
|
const filteredComputedStates = [];
|
|
327
|
-
liftedState.stagedActionIds.forEach((
|
|
341
|
+
liftedState.stagedActionIds.forEach((/**
|
|
342
|
+
* @param {?} id
|
|
343
|
+
* @param {?} idx
|
|
344
|
+
* @return {?}
|
|
345
|
+
*/
|
|
346
|
+
(id, idx) => {
|
|
328
347
|
/** @type {?} */
|
|
329
348
|
const liftedAction = liftedState.actionsById[id];
|
|
330
349
|
if (!liftedAction)
|
|
@@ -336,7 +355,7 @@ function filterLiftedState(liftedState, predicate, whitelist, blacklist) {
|
|
|
336
355
|
filteredActionsById[id] = liftedAction;
|
|
337
356
|
filteredStagedActionIds.push(id);
|
|
338
357
|
filteredComputedStates.push(liftedState.computedStates[idx]);
|
|
339
|
-
});
|
|
358
|
+
}));
|
|
340
359
|
return Object.assign({}, liftedState, { stagedActionIds: filteredStagedActionIds, actionsById: filteredActionsById, computedStates: filteredComputedStates });
|
|
341
360
|
}
|
|
342
361
|
/**
|
|
@@ -360,7 +379,7 @@ function isActionFiltered(state, action, predicate, whitelist, blacklist) {
|
|
|
360
379
|
|
|
361
380
|
/**
|
|
362
381
|
* @fileoverview added by tsickle
|
|
363
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
382
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
364
383
|
*/
|
|
365
384
|
class DevtoolsDispatcher extends ActionsSubject {
|
|
366
385
|
}
|
|
@@ -370,7 +389,7 @@ DevtoolsDispatcher.decorators = [
|
|
|
370
389
|
|
|
371
390
|
/**
|
|
372
391
|
* @fileoverview added by tsickle
|
|
373
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
392
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
374
393
|
*/
|
|
375
394
|
/** @type {?} */
|
|
376
395
|
const ExtensionActionTypes = {
|
|
@@ -433,46 +452,87 @@ class DevtoolsExtension {
|
|
|
433
452
|
const sanitizedAction = this.config.actionSanitizer
|
|
434
453
|
? sanitizeAction(this.config.actionSanitizer, action, state.nextActionId)
|
|
435
454
|
: action;
|
|
436
|
-
this.sendToReduxDevtools((
|
|
455
|
+
this.sendToReduxDevtools((/**
|
|
456
|
+
* @return {?}
|
|
457
|
+
*/
|
|
458
|
+
() => this.extensionConnection.send(sanitizedAction, sanitizedState)));
|
|
437
459
|
}
|
|
438
460
|
else {
|
|
461
|
+
// Requires full state update
|
|
439
462
|
/** @type {?} */
|
|
440
463
|
const sanitizedLiftedState = Object.assign({}, state, { stagedActionIds: state.stagedActionIds, actionsById: this.config.actionSanitizer
|
|
441
464
|
? sanitizeActions(this.config.actionSanitizer, state.actionsById)
|
|
442
465
|
: state.actionsById, computedStates: this.config.stateSanitizer
|
|
443
466
|
? sanitizeStates(this.config.stateSanitizer, state.computedStates)
|
|
444
467
|
: state.computedStates });
|
|
445
|
-
this.sendToReduxDevtools((
|
|
468
|
+
this.sendToReduxDevtools((/**
|
|
469
|
+
* @return {?}
|
|
470
|
+
*/
|
|
471
|
+
() => this.devtoolsExtension.send(null, sanitizedLiftedState, this.getExtensionConfig(this.config))));
|
|
446
472
|
}
|
|
447
473
|
}
|
|
448
474
|
/**
|
|
475
|
+
* @private
|
|
449
476
|
* @return {?}
|
|
450
477
|
*/
|
|
451
478
|
createChangesObservable() {
|
|
452
479
|
if (!this.devtoolsExtension) {
|
|
453
480
|
return empty();
|
|
454
481
|
}
|
|
455
|
-
return new Observable(
|
|
482
|
+
return new Observable((/**
|
|
483
|
+
* @param {?} subscriber
|
|
484
|
+
* @return {?}
|
|
485
|
+
*/
|
|
486
|
+
subscriber => {
|
|
456
487
|
/** @type {?} */
|
|
457
488
|
const connection = this.devtoolsExtension.connect(this.getExtensionConfig(this.config));
|
|
458
489
|
this.extensionConnection = connection;
|
|
459
490
|
connection.init();
|
|
460
|
-
connection.subscribe((
|
|
491
|
+
connection.subscribe((/**
|
|
492
|
+
* @param {?} change
|
|
493
|
+
* @return {?}
|
|
494
|
+
*/
|
|
495
|
+
(change) => subscriber.next(change)));
|
|
461
496
|
return connection.unsubscribe;
|
|
462
|
-
});
|
|
497
|
+
}));
|
|
463
498
|
}
|
|
464
499
|
/**
|
|
500
|
+
* @private
|
|
465
501
|
* @return {?}
|
|
466
502
|
*/
|
|
467
503
|
createActionStreams() {
|
|
504
|
+
// Listens to all changes
|
|
468
505
|
/** @type {?} */
|
|
469
506
|
const changes$ = this.createChangesObservable().pipe(share());
|
|
507
|
+
// Listen for the start action
|
|
470
508
|
/** @type {?} */
|
|
471
|
-
const start$ = changes$.pipe(filter((
|
|
509
|
+
const start$ = changes$.pipe(filter((/**
|
|
510
|
+
* @param {?} change
|
|
511
|
+
* @return {?}
|
|
512
|
+
*/
|
|
513
|
+
(change) => change.type === ExtensionActionTypes.START)));
|
|
514
|
+
// Listen for the stop action
|
|
472
515
|
/** @type {?} */
|
|
473
|
-
const stop$ = changes$.pipe(filter((
|
|
516
|
+
const stop$ = changes$.pipe(filter((/**
|
|
517
|
+
* @param {?} change
|
|
518
|
+
* @return {?}
|
|
519
|
+
*/
|
|
520
|
+
(change) => change.type === ExtensionActionTypes.STOP)));
|
|
521
|
+
// Listen for lifted actions
|
|
474
522
|
/** @type {?} */
|
|
475
|
-
const liftedActions$ = changes$.pipe(filter(
|
|
523
|
+
const liftedActions$ = changes$.pipe(filter((/**
|
|
524
|
+
* @param {?} change
|
|
525
|
+
* @return {?}
|
|
526
|
+
*/
|
|
527
|
+
change => change.type === ExtensionActionTypes.DISPATCH)), map((/**
|
|
528
|
+
* @param {?} change
|
|
529
|
+
* @return {?}
|
|
530
|
+
*/
|
|
531
|
+
change => this.unwrapAction(change.payload))), concatMap((/**
|
|
532
|
+
* @param {?} action
|
|
533
|
+
* @return {?}
|
|
534
|
+
*/
|
|
535
|
+
(action) => {
|
|
476
536
|
if (action.type === IMPORT_STATE) {
|
|
477
537
|
// State imports may happen in two situations:
|
|
478
538
|
// 1. Explicitly by user
|
|
@@ -482,24 +542,50 @@ class DevtoolsExtension {
|
|
|
482
542
|
// lazy loaded reducers time to instantiate.
|
|
483
543
|
// As soon as there is no UPDATE action within 1 second,
|
|
484
544
|
// it is assumed that all reducers are loaded.
|
|
485
|
-
return this.dispatcher.pipe(filter(
|
|
545
|
+
return this.dispatcher.pipe(filter((/**
|
|
546
|
+
* @param {?} action
|
|
547
|
+
* @return {?}
|
|
548
|
+
*/
|
|
549
|
+
action => action.type === UPDATE)), timeout(1000), debounceTime(1000), map((/**
|
|
550
|
+
* @return {?}
|
|
551
|
+
*/
|
|
552
|
+
() => action)), catchError((/**
|
|
553
|
+
* @return {?}
|
|
554
|
+
*/
|
|
555
|
+
() => of(action))), take(1));
|
|
486
556
|
}
|
|
487
557
|
else {
|
|
488
558
|
return of(action);
|
|
489
559
|
}
|
|
490
|
-
}));
|
|
560
|
+
})));
|
|
561
|
+
// Listen for unlifted actions
|
|
491
562
|
/** @type {?} */
|
|
492
|
-
const actions$ = changes$.pipe(filter(
|
|
563
|
+
const actions$ = changes$.pipe(filter((/**
|
|
564
|
+
* @param {?} change
|
|
565
|
+
* @return {?}
|
|
566
|
+
*/
|
|
567
|
+
change => change.type === ExtensionActionTypes.ACTION)), map((/**
|
|
568
|
+
* @param {?} change
|
|
569
|
+
* @return {?}
|
|
570
|
+
*/
|
|
571
|
+
change => this.unwrapAction(change.payload))));
|
|
493
572
|
/** @type {?} */
|
|
494
573
|
const actionsUntilStop$ = actions$.pipe(takeUntil(stop$));
|
|
495
574
|
/** @type {?} */
|
|
496
575
|
const liftedUntilStop$ = liftedActions$.pipe(takeUntil(stop$));
|
|
497
576
|
this.start$ = start$.pipe(takeUntil(stop$));
|
|
498
577
|
// Only take the action sources between the start/stop events
|
|
499
|
-
this.actions$ = this.start$.pipe(switchMap((
|
|
500
|
-
|
|
578
|
+
this.actions$ = this.start$.pipe(switchMap((/**
|
|
579
|
+
* @return {?}
|
|
580
|
+
*/
|
|
581
|
+
() => actionsUntilStop$)));
|
|
582
|
+
this.liftedActions$ = this.start$.pipe(switchMap((/**
|
|
583
|
+
* @return {?}
|
|
584
|
+
*/
|
|
585
|
+
() => liftedUntilStop$)));
|
|
501
586
|
}
|
|
502
587
|
/**
|
|
588
|
+
* @private
|
|
503
589
|
* @param {?} action
|
|
504
590
|
* @return {?}
|
|
505
591
|
*/
|
|
@@ -507,6 +593,7 @@ class DevtoolsExtension {
|
|
|
507
593
|
return typeof action === 'string' ? eval(`(${action})`) : action;
|
|
508
594
|
}
|
|
509
595
|
/**
|
|
596
|
+
* @private
|
|
510
597
|
* @param {?} config
|
|
511
598
|
* @return {?}
|
|
512
599
|
*/
|
|
@@ -523,6 +610,7 @@ class DevtoolsExtension {
|
|
|
523
610
|
return extensionOptions;
|
|
524
611
|
}
|
|
525
612
|
/**
|
|
613
|
+
* @private
|
|
526
614
|
* @param {?} send
|
|
527
615
|
* @return {?}
|
|
528
616
|
*/
|
|
@@ -547,12 +635,12 @@ DevtoolsExtension.ctorParameters = () => [
|
|
|
547
635
|
|
|
548
636
|
/**
|
|
549
637
|
* @fileoverview added by tsickle
|
|
550
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
638
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
551
639
|
*/
|
|
552
640
|
/** @type {?} */
|
|
553
641
|
const INIT_ACTION = { type: INIT };
|
|
554
642
|
/** @type {?} */
|
|
555
|
-
const RECOMPUTE = /** @type {?} */ ('@ngrx/store-devtools/recompute');
|
|
643
|
+
const RECOMPUTE = (/** @type {?} */ ('@ngrx/store-devtools/recompute'));
|
|
556
644
|
/** @type {?} */
|
|
557
645
|
const RECOMPUTE_ACTION = { type: RECOMPUTE };
|
|
558
646
|
/**
|
|
@@ -609,6 +697,8 @@ function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, comm
|
|
|
609
697
|
}
|
|
610
698
|
/** @type {?} */
|
|
611
699
|
const nextComputedStates = computedStates.slice(0, minInvalidatedStateIndex);
|
|
700
|
+
// If the recording is paused, recompute all states up until the pause state,
|
|
701
|
+
// else recompute all states.
|
|
612
702
|
/** @type {?} */
|
|
613
703
|
const lastIncludedActionId = stagedActionIds.length - (isPaused ? 1 : 0);
|
|
614
704
|
for (let i = minInvalidatedStateIndex; i < lastIncludedActionId; i++) {
|
|
@@ -667,9 +757,18 @@ function liftInitialState(initialCommittedState, monitorReducer) {
|
|
|
667
757
|
*/
|
|
668
758
|
function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler, monitorReducer, options = {}) {
|
|
669
759
|
/**
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
return (
|
|
760
|
+
* Manages how the history actions modify the history state.
|
|
761
|
+
*/
|
|
762
|
+
return (/**
|
|
763
|
+
* @param {?} reducer
|
|
764
|
+
* @return {?}
|
|
765
|
+
*/
|
|
766
|
+
(reducer) => (/**
|
|
767
|
+
* @param {?} liftedState
|
|
768
|
+
* @param {?} liftedAction
|
|
769
|
+
* @return {?}
|
|
770
|
+
*/
|
|
771
|
+
(liftedState, liftedAction) => {
|
|
673
772
|
let { monitorState, actionsById, nextActionId, stagedActionIds, skippedActionIds, committedState, currentStateIndex, computedStates, isLocked, isPaused, } = liftedState || initialLiftedState;
|
|
674
773
|
if (!liftedState) {
|
|
675
774
|
// Prevent mutating initialLiftedState
|
|
@@ -680,6 +779,7 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
680
779
|
* @return {?}
|
|
681
780
|
*/
|
|
682
781
|
function commitExcessActions(n) {
|
|
782
|
+
// Auto-commits n-number of excess actions.
|
|
683
783
|
/** @type {?} */
|
|
684
784
|
let excess = n;
|
|
685
785
|
/** @type {?} */
|
|
@@ -695,7 +795,11 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
695
795
|
delete actionsById[idsToDelete[i]];
|
|
696
796
|
}
|
|
697
797
|
}
|
|
698
|
-
skippedActionIds = skippedActionIds.filter(
|
|
798
|
+
skippedActionIds = skippedActionIds.filter((/**
|
|
799
|
+
* @param {?} id
|
|
800
|
+
* @return {?}
|
|
801
|
+
*/
|
|
802
|
+
id => idsToDelete.indexOf(id) === -1));
|
|
699
803
|
stagedActionIds = [0, ...stagedActionIds.slice(excess + 1)];
|
|
700
804
|
committedState = computedStates[excess].state;
|
|
701
805
|
computedStates = computedStates.slice(excess);
|
|
@@ -716,6 +820,9 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
716
820
|
currentStateIndex = 0;
|
|
717
821
|
computedStates = [];
|
|
718
822
|
}
|
|
823
|
+
// By default, aggressively recompute every state whatever happens.
|
|
824
|
+
// This has O(n) performance, so we'll override this to a sensible
|
|
825
|
+
// value whenever we feel like we don't have to recompute the states.
|
|
719
826
|
/** @type {?} */
|
|
720
827
|
let minInvalidatedStateIndex = 0;
|
|
721
828
|
switch (liftedAction.type) {
|
|
@@ -774,6 +881,8 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
774
881
|
break;
|
|
775
882
|
}
|
|
776
883
|
case TOGGLE_ACTION: {
|
|
884
|
+
// Toggle whether an action with given ID is skipped.
|
|
885
|
+
// Being skipped means it is a no-op during the computation.
|
|
777
886
|
const { id: actionId } = liftedAction;
|
|
778
887
|
/** @type {?} */
|
|
779
888
|
const index = skippedActionIds.indexOf(actionId);
|
|
@@ -781,13 +890,19 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
781
890
|
skippedActionIds = [actionId, ...skippedActionIds];
|
|
782
891
|
}
|
|
783
892
|
else {
|
|
784
|
-
skippedActionIds = skippedActionIds.filter(
|
|
893
|
+
skippedActionIds = skippedActionIds.filter((/**
|
|
894
|
+
* @param {?} id
|
|
895
|
+
* @return {?}
|
|
896
|
+
*/
|
|
897
|
+
id => id !== actionId));
|
|
785
898
|
}
|
|
786
899
|
// Optimization: we know history before this action hasn't changed
|
|
787
900
|
minInvalidatedStateIndex = stagedActionIds.indexOf(actionId);
|
|
788
901
|
break;
|
|
789
902
|
}
|
|
790
903
|
case SET_ACTIONS_ACTIVE: {
|
|
904
|
+
// Toggle whether an action with given ID is skipped.
|
|
905
|
+
// Being skipped means it is a no-op during the computation.
|
|
791
906
|
const { start, end, active } = liftedAction;
|
|
792
907
|
/** @type {?} */
|
|
793
908
|
const actionIds = [];
|
|
@@ -812,6 +927,8 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
812
927
|
break;
|
|
813
928
|
}
|
|
814
929
|
case JUMP_TO_ACTION: {
|
|
930
|
+
// Jumps to a corresponding state to a specific action.
|
|
931
|
+
// Useful when filtering actions.
|
|
815
932
|
/** @type {?} */
|
|
816
933
|
const index = stagedActionIds.indexOf(liftedAction.actionId);
|
|
817
934
|
if (index !== -1)
|
|
@@ -834,6 +951,10 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
834
951
|
if (isPaused ||
|
|
835
952
|
(liftedState &&
|
|
836
953
|
isActionFiltered(liftedState.computedStates[currentStateIndex], liftedAction, options.predicate, options.actionsWhitelist, options.actionsBlacklist))) {
|
|
954
|
+
// If recording is paused or if the action should be ignored, overwrite the last state
|
|
955
|
+
// (corresponds to the pause action) and keep everything else as is.
|
|
956
|
+
// This way, the app gets the new current state while the devtools
|
|
957
|
+
// do not record another action.
|
|
837
958
|
/** @type {?} */
|
|
838
959
|
const lastState = computedStates[computedStates.length - 1];
|
|
839
960
|
computedStates = [
|
|
@@ -891,7 +1012,11 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
891
1012
|
}
|
|
892
1013
|
case UPDATE: {
|
|
893
1014
|
/** @type {?} */
|
|
894
|
-
const stateHasErrors = computedStates.filter(
|
|
1015
|
+
const stateHasErrors = computedStates.filter((/**
|
|
1016
|
+
* @param {?} state
|
|
1017
|
+
* @return {?}
|
|
1018
|
+
*/
|
|
1019
|
+
state => state.error)).length > 0;
|
|
895
1020
|
if (stateHasErrors) {
|
|
896
1021
|
// Recompute all states
|
|
897
1022
|
minInvalidatedStateIndex = 0;
|
|
@@ -910,6 +1035,7 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
910
1035
|
if (currentStateIndex === stagedActionIds.length - 1) {
|
|
911
1036
|
currentStateIndex++;
|
|
912
1037
|
}
|
|
1038
|
+
// Add a new action to only recompute state
|
|
913
1039
|
/** @type {?} */
|
|
914
1040
|
const actionId = nextActionId++;
|
|
915
1041
|
actionsById[actionId] = new PerformAction(liftedAction, +Date.now());
|
|
@@ -918,7 +1044,11 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
918
1044
|
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
919
1045
|
}
|
|
920
1046
|
// Recompute state history with latest reducer and update action
|
|
921
|
-
computedStates = computedStates.map(
|
|
1047
|
+
computedStates = computedStates.map((/**
|
|
1048
|
+
* @param {?} cmp
|
|
1049
|
+
* @return {?}
|
|
1050
|
+
*/
|
|
1051
|
+
cmp => (Object.assign({}, cmp, { state: reducer(cmp.state, RECOMPUTE_ACTION) }))));
|
|
922
1052
|
currentStateIndex = stagedActionIds.length - 1;
|
|
923
1053
|
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
924
1054
|
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
@@ -949,12 +1079,12 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
949
1079
|
isLocked,
|
|
950
1080
|
isPaused,
|
|
951
1081
|
};
|
|
952
|
-
};
|
|
1082
|
+
}));
|
|
953
1083
|
}
|
|
954
1084
|
|
|
955
1085
|
/**
|
|
956
1086
|
* @fileoverview added by tsickle
|
|
957
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
1087
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
958
1088
|
*/
|
|
959
1089
|
class StoreDevtools {
|
|
960
1090
|
/**
|
|
@@ -980,7 +1110,12 @@ class StoreDevtools {
|
|
|
980
1110
|
const liftedStateSubject = new ReplaySubject(1);
|
|
981
1111
|
/** @type {?} */
|
|
982
1112
|
const liftedStateSubscription = liftedAction$
|
|
983
|
-
.pipe(withLatestFrom(liftedReducer$), scan((
|
|
1113
|
+
.pipe(withLatestFrom(liftedReducer$), scan((/**
|
|
1114
|
+
* @param {?} __0
|
|
1115
|
+
* @param {?} __1
|
|
1116
|
+
* @return {?}
|
|
1117
|
+
*/
|
|
1118
|
+
({ state: liftedState }, [action, reducer]) => {
|
|
984
1119
|
/** @type {?} */
|
|
985
1120
|
let reducedLiftedState = reducer(liftedState, action);
|
|
986
1121
|
// On full state update
|
|
@@ -991,21 +1126,28 @@ class StoreDevtools {
|
|
|
991
1126
|
// Extension should be sent the sanitized lifted state
|
|
992
1127
|
extension.notify(action, reducedLiftedState);
|
|
993
1128
|
return { state: reducedLiftedState, action };
|
|
994
|
-
}, { state: liftedInitialState, action: /** @type {?} */ (null) }))
|
|
995
|
-
.subscribe((
|
|
1129
|
+
}), { state: liftedInitialState, action: (/** @type {?} */ (null)) }))
|
|
1130
|
+
.subscribe((/**
|
|
1131
|
+
* @param {?} __0
|
|
1132
|
+
* @return {?}
|
|
1133
|
+
*/
|
|
1134
|
+
({ state, action }) => {
|
|
996
1135
|
liftedStateSubject.next(state);
|
|
997
1136
|
if (action.type === PERFORM_ACTION) {
|
|
998
1137
|
/** @type {?} */
|
|
999
|
-
const unliftedAction = (/** @type {?} */ (action)).action;
|
|
1138
|
+
const unliftedAction = ((/** @type {?} */ (action))).action;
|
|
1000
1139
|
scannedActions.next(unliftedAction);
|
|
1001
1140
|
}
|
|
1002
|
-
});
|
|
1141
|
+
}));
|
|
1003
1142
|
/** @type {?} */
|
|
1004
|
-
const extensionStartSubscription = extension.start$.subscribe((
|
|
1143
|
+
const extensionStartSubscription = extension.start$.subscribe((/**
|
|
1144
|
+
* @return {?}
|
|
1145
|
+
*/
|
|
1146
|
+
() => {
|
|
1005
1147
|
this.refresh();
|
|
1006
|
-
});
|
|
1148
|
+
}));
|
|
1007
1149
|
/** @type {?} */
|
|
1008
|
-
const liftedState$ = /** @type {?} */ (liftedStateSubject.asObservable());
|
|
1150
|
+
const liftedState$ = (/** @type {?} */ (liftedStateSubject.asObservable()));
|
|
1009
1151
|
/** @type {?} */
|
|
1010
1152
|
const state$ = liftedState$.pipe(map(unliftState));
|
|
1011
1153
|
this.extensionStartSubscription = extensionStartSubscription;
|
|
@@ -1134,7 +1276,7 @@ StoreDevtools.ctorParameters = () => [
|
|
|
1134
1276
|
|
|
1135
1277
|
/**
|
|
1136
1278
|
* @fileoverview added by tsickle
|
|
1137
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
1279
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1138
1280
|
*/
|
|
1139
1281
|
/** @type {?} */
|
|
1140
1282
|
const IS_EXTENSION_OR_MONITOR_PRESENT = new InjectionToken('Is Devtools Extension or Monitor Present');
|
|
@@ -1153,8 +1295,8 @@ function createReduxDevtoolsExtension() {
|
|
|
1153
1295
|
/** @type {?} */
|
|
1154
1296
|
const extensionKey = '__REDUX_DEVTOOLS_EXTENSION__';
|
|
1155
1297
|
if (typeof window === 'object' &&
|
|
1156
|
-
typeof (/** @type {?} */ (window))[extensionKey] !== 'undefined') {
|
|
1157
|
-
return (/** @type {?} */ (window))[extensionKey];
|
|
1298
|
+
typeof ((/** @type {?} */ (window)))[extensionKey] !== 'undefined') {
|
|
1299
|
+
return ((/** @type {?} */ (window)))[extensionKey];
|
|
1158
1300
|
}
|
|
1159
1301
|
else {
|
|
1160
1302
|
return null;
|
|
@@ -1216,17 +1358,17 @@ StoreDevtoolsModule.decorators = [
|
|
|
1216
1358
|
|
|
1217
1359
|
/**
|
|
1218
1360
|
* @fileoverview added by tsickle
|
|
1219
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
1361
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1220
1362
|
*/
|
|
1221
1363
|
|
|
1222
1364
|
/**
|
|
1223
1365
|
* @fileoverview added by tsickle
|
|
1224
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
1366
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1225
1367
|
*/
|
|
1226
1368
|
|
|
1227
1369
|
/**
|
|
1228
1370
|
* @fileoverview added by tsickle
|
|
1229
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
1371
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1230
1372
|
*/
|
|
1231
1373
|
|
|
1232
1374
|
/**
|