@ngrx/store-devtools 7.0.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 +20 -9
- 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 +91 -54
- package/esm2015/src/utils.js +43 -13
- 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 +6 -5
- package/esm5/src/utils.js +13 -5
- package/esm5/store-devtools.js +0 -1
- package/fesm2015/store-devtools.js +214 -58
- package/fesm2015/store-devtools.js.map +1 -1
- package/fesm5/store-devtools.js +20 -9
- 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/ng-add/schema.json +5 -0
- 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/libs-version.d.ts +1 -1
- package/schematics-core/utility/libs-version.js +2 -2
- 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.
|
|
@@ -236,6 +240,14 @@ function difference(first, second) {
|
|
|
236
240
|
*/
|
|
237
241
|
function unliftState(liftedState) {
|
|
238
242
|
const { computedStates, currentStateIndex } = liftedState;
|
|
243
|
+
// At start up NgRx dispatches init actions,
|
|
244
|
+
// When these init actions are being filtered out by the predicate or black/white list options
|
|
245
|
+
// we don't have a complete computed states yet.
|
|
246
|
+
// At this point it could happen that we're out of bounds, when this happens we fall back to the last known state
|
|
247
|
+
if (currentStateIndex >= computedStates.length) {
|
|
248
|
+
const { state } = computedStates[computedStates.length - 1];
|
|
249
|
+
return state;
|
|
250
|
+
}
|
|
239
251
|
const { state } = computedStates[currentStateIndex];
|
|
240
252
|
return state;
|
|
241
253
|
}
|
|
@@ -254,12 +266,17 @@ function liftAction(action) {
|
|
|
254
266
|
* @return {?}
|
|
255
267
|
*/
|
|
256
268
|
function sanitizeActions(actionSanitizer, actions) {
|
|
257
|
-
return Object.keys(actions).reduce((
|
|
269
|
+
return Object.keys(actions).reduce((/**
|
|
270
|
+
* @param {?} sanitizedActions
|
|
271
|
+
* @param {?} actionIdx
|
|
272
|
+
* @return {?}
|
|
273
|
+
*/
|
|
274
|
+
(sanitizedActions, actionIdx) => {
|
|
258
275
|
/** @type {?} */
|
|
259
276
|
const idx = Number(actionIdx);
|
|
260
277
|
sanitizedActions[idx] = sanitizeAction(actionSanitizer, actions[idx], idx);
|
|
261
278
|
return sanitizedActions;
|
|
262
|
-
}, /** @type {?} */ ({}));
|
|
279
|
+
}), (/** @type {?} */ ({})));
|
|
263
280
|
}
|
|
264
281
|
/**
|
|
265
282
|
* Sanitizes given action with given function.
|
|
@@ -278,10 +295,15 @@ function sanitizeAction(actionSanitizer, action, actionIdx) {
|
|
|
278
295
|
* @return {?}
|
|
279
296
|
*/
|
|
280
297
|
function sanitizeStates(stateSanitizer, states) {
|
|
281
|
-
return states.map((
|
|
298
|
+
return states.map((/**
|
|
299
|
+
* @param {?} computedState
|
|
300
|
+
* @param {?} idx
|
|
301
|
+
* @return {?}
|
|
302
|
+
*/
|
|
303
|
+
(computedState, idx) => ({
|
|
282
304
|
state: sanitizeState(stateSanitizer, computedState.state, idx),
|
|
283
305
|
error: computedState.error,
|
|
284
|
-
}));
|
|
306
|
+
})));
|
|
285
307
|
}
|
|
286
308
|
/**
|
|
287
309
|
* Sanitizes given state with given function.
|
|
@@ -316,7 +338,12 @@ function filterLiftedState(liftedState, predicate, whitelist, blacklist) {
|
|
|
316
338
|
const filteredActionsById = {};
|
|
317
339
|
/** @type {?} */
|
|
318
340
|
const filteredComputedStates = [];
|
|
319
|
-
liftedState.stagedActionIds.forEach((
|
|
341
|
+
liftedState.stagedActionIds.forEach((/**
|
|
342
|
+
* @param {?} id
|
|
343
|
+
* @param {?} idx
|
|
344
|
+
* @return {?}
|
|
345
|
+
*/
|
|
346
|
+
(id, idx) => {
|
|
320
347
|
/** @type {?} */
|
|
321
348
|
const liftedAction = liftedState.actionsById[id];
|
|
322
349
|
if (!liftedAction)
|
|
@@ -328,7 +355,7 @@ function filterLiftedState(liftedState, predicate, whitelist, blacklist) {
|
|
|
328
355
|
filteredActionsById[id] = liftedAction;
|
|
329
356
|
filteredStagedActionIds.push(id);
|
|
330
357
|
filteredComputedStates.push(liftedState.computedStates[idx]);
|
|
331
|
-
});
|
|
358
|
+
}));
|
|
332
359
|
return Object.assign({}, liftedState, { stagedActionIds: filteredStagedActionIds, actionsById: filteredActionsById, computedStates: filteredComputedStates });
|
|
333
360
|
}
|
|
334
361
|
/**
|
|
@@ -341,14 +368,18 @@ function filterLiftedState(liftedState, predicate, whitelist, blacklist) {
|
|
|
341
368
|
* @return {?}
|
|
342
369
|
*/
|
|
343
370
|
function isActionFiltered(state, action, predicate, whitelist, blacklist) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
371
|
+
/** @type {?} */
|
|
372
|
+
const predicateMatch = predicate && !predicate(state, action.action);
|
|
373
|
+
/** @type {?} */
|
|
374
|
+
const whitelistMatch = whitelist && !action.action.type.match(whitelist.join('|'));
|
|
375
|
+
/** @type {?} */
|
|
376
|
+
const blacklistMatch = blacklist && action.action.type.match(blacklist.join('|'));
|
|
377
|
+
return predicateMatch || whitelistMatch || blacklistMatch;
|
|
347
378
|
}
|
|
348
379
|
|
|
349
380
|
/**
|
|
350
381
|
* @fileoverview added by tsickle
|
|
351
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
382
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
352
383
|
*/
|
|
353
384
|
class DevtoolsDispatcher extends ActionsSubject {
|
|
354
385
|
}
|
|
@@ -358,7 +389,7 @@ DevtoolsDispatcher.decorators = [
|
|
|
358
389
|
|
|
359
390
|
/**
|
|
360
391
|
* @fileoverview added by tsickle
|
|
361
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
392
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
362
393
|
*/
|
|
363
394
|
/** @type {?} */
|
|
364
395
|
const ExtensionActionTypes = {
|
|
@@ -421,46 +452,87 @@ class DevtoolsExtension {
|
|
|
421
452
|
const sanitizedAction = this.config.actionSanitizer
|
|
422
453
|
? sanitizeAction(this.config.actionSanitizer, action, state.nextActionId)
|
|
423
454
|
: action;
|
|
424
|
-
this.sendToReduxDevtools((
|
|
455
|
+
this.sendToReduxDevtools((/**
|
|
456
|
+
* @return {?}
|
|
457
|
+
*/
|
|
458
|
+
() => this.extensionConnection.send(sanitizedAction, sanitizedState)));
|
|
425
459
|
}
|
|
426
460
|
else {
|
|
461
|
+
// Requires full state update
|
|
427
462
|
/** @type {?} */
|
|
428
463
|
const sanitizedLiftedState = Object.assign({}, state, { stagedActionIds: state.stagedActionIds, actionsById: this.config.actionSanitizer
|
|
429
464
|
? sanitizeActions(this.config.actionSanitizer, state.actionsById)
|
|
430
465
|
: state.actionsById, computedStates: this.config.stateSanitizer
|
|
431
466
|
? sanitizeStates(this.config.stateSanitizer, state.computedStates)
|
|
432
467
|
: state.computedStates });
|
|
433
|
-
this.sendToReduxDevtools((
|
|
468
|
+
this.sendToReduxDevtools((/**
|
|
469
|
+
* @return {?}
|
|
470
|
+
*/
|
|
471
|
+
() => this.devtoolsExtension.send(null, sanitizedLiftedState, this.getExtensionConfig(this.config))));
|
|
434
472
|
}
|
|
435
473
|
}
|
|
436
474
|
/**
|
|
475
|
+
* @private
|
|
437
476
|
* @return {?}
|
|
438
477
|
*/
|
|
439
478
|
createChangesObservable() {
|
|
440
479
|
if (!this.devtoolsExtension) {
|
|
441
480
|
return empty();
|
|
442
481
|
}
|
|
443
|
-
return new Observable(
|
|
482
|
+
return new Observable((/**
|
|
483
|
+
* @param {?} subscriber
|
|
484
|
+
* @return {?}
|
|
485
|
+
*/
|
|
486
|
+
subscriber => {
|
|
444
487
|
/** @type {?} */
|
|
445
488
|
const connection = this.devtoolsExtension.connect(this.getExtensionConfig(this.config));
|
|
446
489
|
this.extensionConnection = connection;
|
|
447
490
|
connection.init();
|
|
448
|
-
connection.subscribe((
|
|
491
|
+
connection.subscribe((/**
|
|
492
|
+
* @param {?} change
|
|
493
|
+
* @return {?}
|
|
494
|
+
*/
|
|
495
|
+
(change) => subscriber.next(change)));
|
|
449
496
|
return connection.unsubscribe;
|
|
450
|
-
});
|
|
497
|
+
}));
|
|
451
498
|
}
|
|
452
499
|
/**
|
|
500
|
+
* @private
|
|
453
501
|
* @return {?}
|
|
454
502
|
*/
|
|
455
503
|
createActionStreams() {
|
|
504
|
+
// Listens to all changes
|
|
456
505
|
/** @type {?} */
|
|
457
506
|
const changes$ = this.createChangesObservable().pipe(share());
|
|
507
|
+
// Listen for the start action
|
|
458
508
|
/** @type {?} */
|
|
459
|
-
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
|
|
460
515
|
/** @type {?} */
|
|
461
|
-
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
|
|
462
522
|
/** @type {?} */
|
|
463
|
-
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) => {
|
|
464
536
|
if (action.type === IMPORT_STATE) {
|
|
465
537
|
// State imports may happen in two situations:
|
|
466
538
|
// 1. Explicitly by user
|
|
@@ -470,24 +542,50 @@ class DevtoolsExtension {
|
|
|
470
542
|
// lazy loaded reducers time to instantiate.
|
|
471
543
|
// As soon as there is no UPDATE action within 1 second,
|
|
472
544
|
// it is assumed that all reducers are loaded.
|
|
473
|
-
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));
|
|
474
556
|
}
|
|
475
557
|
else {
|
|
476
558
|
return of(action);
|
|
477
559
|
}
|
|
478
|
-
}));
|
|
560
|
+
})));
|
|
561
|
+
// Listen for unlifted actions
|
|
479
562
|
/** @type {?} */
|
|
480
|
-
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))));
|
|
481
572
|
/** @type {?} */
|
|
482
573
|
const actionsUntilStop$ = actions$.pipe(takeUntil(stop$));
|
|
483
574
|
/** @type {?} */
|
|
484
575
|
const liftedUntilStop$ = liftedActions$.pipe(takeUntil(stop$));
|
|
485
576
|
this.start$ = start$.pipe(takeUntil(stop$));
|
|
486
577
|
// Only take the action sources between the start/stop events
|
|
487
|
-
this.actions$ = this.start$.pipe(switchMap((
|
|
488
|
-
|
|
578
|
+
this.actions$ = this.start$.pipe(switchMap((/**
|
|
579
|
+
* @return {?}
|
|
580
|
+
*/
|
|
581
|
+
() => actionsUntilStop$)));
|
|
582
|
+
this.liftedActions$ = this.start$.pipe(switchMap((/**
|
|
583
|
+
* @return {?}
|
|
584
|
+
*/
|
|
585
|
+
() => liftedUntilStop$)));
|
|
489
586
|
}
|
|
490
587
|
/**
|
|
588
|
+
* @private
|
|
491
589
|
* @param {?} action
|
|
492
590
|
* @return {?}
|
|
493
591
|
*/
|
|
@@ -495,6 +593,7 @@ class DevtoolsExtension {
|
|
|
495
593
|
return typeof action === 'string' ? eval(`(${action})`) : action;
|
|
496
594
|
}
|
|
497
595
|
/**
|
|
596
|
+
* @private
|
|
498
597
|
* @param {?} config
|
|
499
598
|
* @return {?}
|
|
500
599
|
*/
|
|
@@ -511,6 +610,7 @@ class DevtoolsExtension {
|
|
|
511
610
|
return extensionOptions;
|
|
512
611
|
}
|
|
513
612
|
/**
|
|
613
|
+
* @private
|
|
514
614
|
* @param {?} send
|
|
515
615
|
* @return {?}
|
|
516
616
|
*/
|
|
@@ -535,12 +635,12 @@ DevtoolsExtension.ctorParameters = () => [
|
|
|
535
635
|
|
|
536
636
|
/**
|
|
537
637
|
* @fileoverview added by tsickle
|
|
538
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
638
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
539
639
|
*/
|
|
540
640
|
/** @type {?} */
|
|
541
641
|
const INIT_ACTION = { type: INIT };
|
|
542
642
|
/** @type {?} */
|
|
543
|
-
const RECOMPUTE = /** @type {?} */ ('@ngrx/store-devtools/recompute');
|
|
643
|
+
const RECOMPUTE = (/** @type {?} */ ('@ngrx/store-devtools/recompute'));
|
|
544
644
|
/** @type {?} */
|
|
545
645
|
const RECOMPUTE_ACTION = { type: RECOMPUTE };
|
|
546
646
|
/**
|
|
@@ -597,6 +697,8 @@ function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, comm
|
|
|
597
697
|
}
|
|
598
698
|
/** @type {?} */
|
|
599
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.
|
|
600
702
|
/** @type {?} */
|
|
601
703
|
const lastIncludedActionId = stagedActionIds.length - (isPaused ? 1 : 0);
|
|
602
704
|
for (let i = minInvalidatedStateIndex; i < lastIncludedActionId; i++) {
|
|
@@ -655,9 +757,18 @@ function liftInitialState(initialCommittedState, monitorReducer) {
|
|
|
655
757
|
*/
|
|
656
758
|
function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler, monitorReducer, options = {}) {
|
|
657
759
|
/**
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
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) => {
|
|
661
772
|
let { monitorState, actionsById, nextActionId, stagedActionIds, skippedActionIds, committedState, currentStateIndex, computedStates, isLocked, isPaused, } = liftedState || initialLiftedState;
|
|
662
773
|
if (!liftedState) {
|
|
663
774
|
// Prevent mutating initialLiftedState
|
|
@@ -668,6 +779,7 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
668
779
|
* @return {?}
|
|
669
780
|
*/
|
|
670
781
|
function commitExcessActions(n) {
|
|
782
|
+
// Auto-commits n-number of excess actions.
|
|
671
783
|
/** @type {?} */
|
|
672
784
|
let excess = n;
|
|
673
785
|
/** @type {?} */
|
|
@@ -683,7 +795,11 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
683
795
|
delete actionsById[idsToDelete[i]];
|
|
684
796
|
}
|
|
685
797
|
}
|
|
686
|
-
skippedActionIds = skippedActionIds.filter(
|
|
798
|
+
skippedActionIds = skippedActionIds.filter((/**
|
|
799
|
+
* @param {?} id
|
|
800
|
+
* @return {?}
|
|
801
|
+
*/
|
|
802
|
+
id => idsToDelete.indexOf(id) === -1));
|
|
687
803
|
stagedActionIds = [0, ...stagedActionIds.slice(excess + 1)];
|
|
688
804
|
committedState = computedStates[excess].state;
|
|
689
805
|
computedStates = computedStates.slice(excess);
|
|
@@ -704,6 +820,9 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
704
820
|
currentStateIndex = 0;
|
|
705
821
|
computedStates = [];
|
|
706
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.
|
|
707
826
|
/** @type {?} */
|
|
708
827
|
let minInvalidatedStateIndex = 0;
|
|
709
828
|
switch (liftedAction.type) {
|
|
@@ -762,6 +881,8 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
762
881
|
break;
|
|
763
882
|
}
|
|
764
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.
|
|
765
886
|
const { id: actionId } = liftedAction;
|
|
766
887
|
/** @type {?} */
|
|
767
888
|
const index = skippedActionIds.indexOf(actionId);
|
|
@@ -769,13 +890,19 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
769
890
|
skippedActionIds = [actionId, ...skippedActionIds];
|
|
770
891
|
}
|
|
771
892
|
else {
|
|
772
|
-
skippedActionIds = skippedActionIds.filter(
|
|
893
|
+
skippedActionIds = skippedActionIds.filter((/**
|
|
894
|
+
* @param {?} id
|
|
895
|
+
* @return {?}
|
|
896
|
+
*/
|
|
897
|
+
id => id !== actionId));
|
|
773
898
|
}
|
|
774
899
|
// Optimization: we know history before this action hasn't changed
|
|
775
900
|
minInvalidatedStateIndex = stagedActionIds.indexOf(actionId);
|
|
776
901
|
break;
|
|
777
902
|
}
|
|
778
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.
|
|
779
906
|
const { start, end, active } = liftedAction;
|
|
780
907
|
/** @type {?} */
|
|
781
908
|
const actionIds = [];
|
|
@@ -800,6 +927,8 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
800
927
|
break;
|
|
801
928
|
}
|
|
802
929
|
case JUMP_TO_ACTION: {
|
|
930
|
+
// Jumps to a corresponding state to a specific action.
|
|
931
|
+
// Useful when filtering actions.
|
|
803
932
|
/** @type {?} */
|
|
804
933
|
const index = stagedActionIds.indexOf(liftedAction.actionId);
|
|
805
934
|
if (index !== -1)
|
|
@@ -819,7 +948,13 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
819
948
|
if (isLocked) {
|
|
820
949
|
return liftedState || initialLiftedState;
|
|
821
950
|
}
|
|
822
|
-
if (isPaused
|
|
951
|
+
if (isPaused ||
|
|
952
|
+
(liftedState &&
|
|
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.
|
|
823
958
|
/** @type {?} */
|
|
824
959
|
const lastState = computedStates[computedStates.length - 1];
|
|
825
960
|
computedStates = [
|
|
@@ -877,7 +1012,11 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
877
1012
|
}
|
|
878
1013
|
case UPDATE: {
|
|
879
1014
|
/** @type {?} */
|
|
880
|
-
const stateHasErrors = computedStates.filter(
|
|
1015
|
+
const stateHasErrors = computedStates.filter((/**
|
|
1016
|
+
* @param {?} state
|
|
1017
|
+
* @return {?}
|
|
1018
|
+
*/
|
|
1019
|
+
state => state.error)).length > 0;
|
|
881
1020
|
if (stateHasErrors) {
|
|
882
1021
|
// Recompute all states
|
|
883
1022
|
minInvalidatedStateIndex = 0;
|
|
@@ -896,6 +1035,7 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
896
1035
|
if (currentStateIndex === stagedActionIds.length - 1) {
|
|
897
1036
|
currentStateIndex++;
|
|
898
1037
|
}
|
|
1038
|
+
// Add a new action to only recompute state
|
|
899
1039
|
/** @type {?} */
|
|
900
1040
|
const actionId = nextActionId++;
|
|
901
1041
|
actionsById[actionId] = new PerformAction(liftedAction, +Date.now());
|
|
@@ -904,7 +1044,11 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
904
1044
|
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
905
1045
|
}
|
|
906
1046
|
// Recompute state history with latest reducer and update action
|
|
907
|
-
computedStates = computedStates.map(
|
|
1047
|
+
computedStates = computedStates.map((/**
|
|
1048
|
+
* @param {?} cmp
|
|
1049
|
+
* @return {?}
|
|
1050
|
+
*/
|
|
1051
|
+
cmp => (Object.assign({}, cmp, { state: reducer(cmp.state, RECOMPUTE_ACTION) }))));
|
|
908
1052
|
currentStateIndex = stagedActionIds.length - 1;
|
|
909
1053
|
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
910
1054
|
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
@@ -935,12 +1079,12 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
935
1079
|
isLocked,
|
|
936
1080
|
isPaused,
|
|
937
1081
|
};
|
|
938
|
-
};
|
|
1082
|
+
}));
|
|
939
1083
|
}
|
|
940
1084
|
|
|
941
1085
|
/**
|
|
942
1086
|
* @fileoverview added by tsickle
|
|
943
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
1087
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
944
1088
|
*/
|
|
945
1089
|
class StoreDevtools {
|
|
946
1090
|
/**
|
|
@@ -966,7 +1110,12 @@ class StoreDevtools {
|
|
|
966
1110
|
const liftedStateSubject = new ReplaySubject(1);
|
|
967
1111
|
/** @type {?} */
|
|
968
1112
|
const liftedStateSubscription = liftedAction$
|
|
969
|
-
.pipe(withLatestFrom(liftedReducer$), scan((
|
|
1113
|
+
.pipe(withLatestFrom(liftedReducer$), scan((/**
|
|
1114
|
+
* @param {?} __0
|
|
1115
|
+
* @param {?} __1
|
|
1116
|
+
* @return {?}
|
|
1117
|
+
*/
|
|
1118
|
+
({ state: liftedState }, [action, reducer]) => {
|
|
970
1119
|
/** @type {?} */
|
|
971
1120
|
let reducedLiftedState = reducer(liftedState, action);
|
|
972
1121
|
// On full state update
|
|
@@ -977,21 +1126,28 @@ class StoreDevtools {
|
|
|
977
1126
|
// Extension should be sent the sanitized lifted state
|
|
978
1127
|
extension.notify(action, reducedLiftedState);
|
|
979
1128
|
return { state: reducedLiftedState, action };
|
|
980
|
-
}, { state: liftedInitialState, action: /** @type {?} */ (null) }))
|
|
981
|
-
.subscribe((
|
|
1129
|
+
}), { state: liftedInitialState, action: (/** @type {?} */ (null)) }))
|
|
1130
|
+
.subscribe((/**
|
|
1131
|
+
* @param {?} __0
|
|
1132
|
+
* @return {?}
|
|
1133
|
+
*/
|
|
1134
|
+
({ state, action }) => {
|
|
982
1135
|
liftedStateSubject.next(state);
|
|
983
1136
|
if (action.type === PERFORM_ACTION) {
|
|
984
1137
|
/** @type {?} */
|
|
985
|
-
const unliftedAction = (/** @type {?} */ (action)).action;
|
|
1138
|
+
const unliftedAction = ((/** @type {?} */ (action))).action;
|
|
986
1139
|
scannedActions.next(unliftedAction);
|
|
987
1140
|
}
|
|
988
|
-
});
|
|
1141
|
+
}));
|
|
989
1142
|
/** @type {?} */
|
|
990
|
-
const extensionStartSubscription = extension.start$.subscribe((
|
|
1143
|
+
const extensionStartSubscription = extension.start$.subscribe((/**
|
|
1144
|
+
* @return {?}
|
|
1145
|
+
*/
|
|
1146
|
+
() => {
|
|
991
1147
|
this.refresh();
|
|
992
|
-
});
|
|
1148
|
+
}));
|
|
993
1149
|
/** @type {?} */
|
|
994
|
-
const liftedState$ = /** @type {?} */ (liftedStateSubject.asObservable());
|
|
1150
|
+
const liftedState$ = (/** @type {?} */ (liftedStateSubject.asObservable()));
|
|
995
1151
|
/** @type {?} */
|
|
996
1152
|
const state$ = liftedState$.pipe(map(unliftState));
|
|
997
1153
|
this.extensionStartSubscription = extensionStartSubscription;
|
|
@@ -1120,7 +1276,7 @@ StoreDevtools.ctorParameters = () => [
|
|
|
1120
1276
|
|
|
1121
1277
|
/**
|
|
1122
1278
|
* @fileoverview added by tsickle
|
|
1123
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
1279
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1124
1280
|
*/
|
|
1125
1281
|
/** @type {?} */
|
|
1126
1282
|
const IS_EXTENSION_OR_MONITOR_PRESENT = new InjectionToken('Is Devtools Extension or Monitor Present');
|
|
@@ -1139,8 +1295,8 @@ function createReduxDevtoolsExtension() {
|
|
|
1139
1295
|
/** @type {?} */
|
|
1140
1296
|
const extensionKey = '__REDUX_DEVTOOLS_EXTENSION__';
|
|
1141
1297
|
if (typeof window === 'object' &&
|
|
1142
|
-
typeof (/** @type {?} */ (window))[extensionKey] !== 'undefined') {
|
|
1143
|
-
return (/** @type {?} */ (window))[extensionKey];
|
|
1298
|
+
typeof ((/** @type {?} */ (window)))[extensionKey] !== 'undefined') {
|
|
1299
|
+
return ((/** @type {?} */ (window)))[extensionKey];
|
|
1144
1300
|
}
|
|
1145
1301
|
else {
|
|
1146
1302
|
return null;
|
|
@@ -1202,17 +1358,17 @@ StoreDevtoolsModule.decorators = [
|
|
|
1202
1358
|
|
|
1203
1359
|
/**
|
|
1204
1360
|
* @fileoverview added by tsickle
|
|
1205
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
1361
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1206
1362
|
*/
|
|
1207
1363
|
|
|
1208
1364
|
/**
|
|
1209
1365
|
* @fileoverview added by tsickle
|
|
1210
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
1366
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1211
1367
|
*/
|
|
1212
1368
|
|
|
1213
1369
|
/**
|
|
1214
1370
|
* @fileoverview added by tsickle
|
|
1215
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
1371
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1216
1372
|
*/
|
|
1217
1373
|
|
|
1218
1374
|
/**
|