@ngrx/store-devtools 12.5.1 → 13.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.
@@ -1,5 +1,7 @@
1
- import { InjectionToken, Injectable, Inject, ErrorHandler, NgModule } from '@angular/core';
2
- import { ActionsSubject, UPDATE, INIT, ReducerObservable, ScannedActionsSubject, INITIAL_STATE, StateObservable, ReducerManagerDispatcher } from '@ngrx/store';
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, Injectable, Inject, NgModule } from '@angular/core';
3
+ import * as i2 from '@ngrx/store';
4
+ import { INIT, UPDATE, ActionsSubject, INITIAL_STATE, StateObservable, ReducerManagerDispatcher } from '@ngrx/store';
3
5
  import { EMPTY, Observable, of, merge, queueScheduler, ReplaySubject } from 'rxjs';
4
6
  import { share, filter, map, concatMap, timeout, debounceTime, catchError, take, takeUntil, switchMap, skip, observeOn, withLatestFrom, scan } from 'rxjs/operators';
5
7
 
@@ -160,13 +162,6 @@ class PauseRecording {
160
162
  }
161
163
  }
162
164
 
163
- class DevtoolsDispatcher extends ActionsSubject {
164
- }
165
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
166
- DevtoolsDispatcher.decorators = [
167
- { type: Injectable }
168
- ];
169
-
170
165
  function difference(first, second) {
171
166
  return first.filter((item) => second.indexOf(item) < 0);
172
167
  }
@@ -272,158 +267,6 @@ function escapeRegExp(s) {
272
267
  return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
273
268
  }
274
269
 
275
- const ExtensionActionTypes = {
276
- START: 'START',
277
- DISPATCH: 'DISPATCH',
278
- STOP: 'STOP',
279
- ACTION: 'ACTION',
280
- };
281
- const REDUX_DEVTOOLS_EXTENSION = new InjectionToken('@ngrx/store-devtools Redux Devtools Extension');
282
- class DevtoolsExtension {
283
- constructor(devtoolsExtension, config, dispatcher) {
284
- this.config = config;
285
- this.dispatcher = dispatcher;
286
- this.devtoolsExtension = devtoolsExtension;
287
- this.createActionStreams();
288
- }
289
- notify(action, state) {
290
- if (!this.devtoolsExtension) {
291
- return;
292
- }
293
- // Check to see if the action requires a full update of the liftedState.
294
- // If it is a simple action generated by the user's app and the recording
295
- // is not locked/paused, only send the action and the current state (fast).
296
- //
297
- // A full liftedState update (slow: serializes the entire liftedState) is
298
- // only required when:
299
- // a) redux-devtools-extension fires the @@Init action (ignored by
300
- // @ngrx/store-devtools)
301
- // b) an action is generated by an @ngrx module (e.g. @ngrx/effects/init
302
- // or @ngrx/store/update-reducers)
303
- // c) the state has been recomputed due to time-traveling
304
- // d) any action that is not a PerformAction to err on the side of
305
- // caution.
306
- if (action.type === PERFORM_ACTION) {
307
- if (state.isLocked || state.isPaused) {
308
- return;
309
- }
310
- const currentState = unliftState(state);
311
- if (shouldFilterActions(this.config) &&
312
- isActionFiltered(currentState, action, this.config.predicate, this.config.actionsSafelist, this.config.actionsBlocklist)) {
313
- return;
314
- }
315
- const sanitizedState = this.config.stateSanitizer
316
- ? sanitizeState(this.config.stateSanitizer, currentState, state.currentStateIndex)
317
- : currentState;
318
- const sanitizedAction = this.config.actionSanitizer
319
- ? sanitizeAction(this.config.actionSanitizer, action, state.nextActionId)
320
- : action;
321
- this.sendToReduxDevtools(() => this.extensionConnection.send(sanitizedAction, sanitizedState));
322
- }
323
- else {
324
- // Requires full state update
325
- const sanitizedLiftedState = Object.assign(Object.assign({}, state), { stagedActionIds: state.stagedActionIds, actionsById: this.config.actionSanitizer
326
- ? sanitizeActions(this.config.actionSanitizer, state.actionsById)
327
- : state.actionsById, computedStates: this.config.stateSanitizer
328
- ? sanitizeStates(this.config.stateSanitizer, state.computedStates)
329
- : state.computedStates });
330
- this.sendToReduxDevtools(() => this.devtoolsExtension.send(null, sanitizedLiftedState, this.getExtensionConfig(this.config)));
331
- }
332
- }
333
- createChangesObservable() {
334
- if (!this.devtoolsExtension) {
335
- return EMPTY;
336
- }
337
- return new Observable((subscriber) => {
338
- const connection = this.devtoolsExtension.connect(this.getExtensionConfig(this.config));
339
- this.extensionConnection = connection;
340
- connection.init();
341
- connection.subscribe((change) => subscriber.next(change));
342
- return connection.unsubscribe;
343
- });
344
- }
345
- createActionStreams() {
346
- // Listens to all changes
347
- const changes$ = this.createChangesObservable().pipe(share());
348
- // Listen for the start action
349
- const start$ = changes$.pipe(filter((change) => change.type === ExtensionActionTypes.START));
350
- // Listen for the stop action
351
- const stop$ = changes$.pipe(filter((change) => change.type === ExtensionActionTypes.STOP));
352
- // Listen for lifted actions
353
- const liftedActions$ = changes$.pipe(filter((change) => change.type === ExtensionActionTypes.DISPATCH), map((change) => this.unwrapAction(change.payload)), concatMap((action) => {
354
- if (action.type === IMPORT_STATE) {
355
- // State imports may happen in two situations:
356
- // 1. Explicitly by user
357
- // 2. User activated the "persist state accross reloads" option
358
- // and now the state is imported during reload.
359
- // Because of option 2, we need to give possible
360
- // lazy loaded reducers time to instantiate.
361
- // As soon as there is no UPDATE action within 1 second,
362
- // it is assumed that all reducers are loaded.
363
- return this.dispatcher.pipe(filter((action) => action.type === UPDATE), timeout(1000), debounceTime(1000), map(() => action), catchError(() => of(action)), take(1));
364
- }
365
- else {
366
- return of(action);
367
- }
368
- }));
369
- // Listen for unlifted actions
370
- const actions$ = changes$.pipe(filter((change) => change.type === ExtensionActionTypes.ACTION), map((change) => this.unwrapAction(change.payload)));
371
- const actionsUntilStop$ = actions$.pipe(takeUntil(stop$));
372
- const liftedUntilStop$ = liftedActions$.pipe(takeUntil(stop$));
373
- this.start$ = start$.pipe(takeUntil(stop$));
374
- // Only take the action sources between the start/stop events
375
- this.actions$ = this.start$.pipe(switchMap(() => actionsUntilStop$));
376
- this.liftedActions$ = this.start$.pipe(switchMap(() => liftedUntilStop$));
377
- }
378
- unwrapAction(action) {
379
- return typeof action === 'string' ? eval(`(${action})`) : action;
380
- }
381
- getExtensionConfig(config) {
382
- var _a;
383
- const extensionOptions = {
384
- name: config.name,
385
- features: config.features,
386
- serialize: config.serialize,
387
- autoPause: (_a = config.autoPause) !== null && _a !== void 0 ? _a : false,
388
- // The action/state sanitizers are not added to the config
389
- // because sanitation is done in this class already.
390
- // It is done before sending it to the devtools extension for consistency:
391
- // - If we call extensionConnection.send(...),
392
- // the extension would call the sanitizers.
393
- // - If we call devtoolsExtension.send(...) (aka full state update),
394
- // the extension would NOT call the sanitizers, so we have to do it ourselves.
395
- };
396
- if (config.maxAge !== false /* support === 0 */) {
397
- extensionOptions.maxAge = config.maxAge;
398
- }
399
- return extensionOptions;
400
- }
401
- sendToReduxDevtools(send) {
402
- try {
403
- send();
404
- }
405
- catch (err) {
406
- console.warn('@ngrx/store-devtools: something went wrong inside the redux devtools', err);
407
- }
408
- }
409
- }
410
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
411
- DevtoolsExtension.decorators = [
412
- { type: Injectable }
413
- ];
414
- /**
415
- * @type {function(): !Array<(null|{
416
- * type: ?,
417
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
418
- * })>}
419
- * @nocollapse
420
- */
421
- DevtoolsExtension.ctorParameters = () => [
422
- { type: undefined, decorators: [{ type: Inject, args: [REDUX_DEVTOOLS_EXTENSION,] }] },
423
- { type: StoreDevtoolsConfig, decorators: [{ type: Inject, args: [STORE_DEVTOOLS_CONFIG,] }] },
424
- { type: DevtoolsDispatcher }
425
- ];
426
-
427
270
  const INIT_ACTION = { type: INIT };
428
271
  const RECOMPUTE = '@ngrx/store-devtools/recompute';
429
272
  const RECOMPUTE_ACTION = { type: RECOMPUTE };
@@ -785,6 +628,161 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
785
628
  };
786
629
  }
787
630
 
631
+ class DevtoolsDispatcher extends ActionsSubject {
632
+ }
633
+ /** @nocollapse */ DevtoolsDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: DevtoolsDispatcher, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
634
+ /** @nocollapse */ DevtoolsDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: DevtoolsDispatcher });
635
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: DevtoolsDispatcher, decorators: [{
636
+ type: Injectable
637
+ }] });
638
+
639
+ const ExtensionActionTypes = {
640
+ START: 'START',
641
+ DISPATCH: 'DISPATCH',
642
+ STOP: 'STOP',
643
+ ACTION: 'ACTION',
644
+ };
645
+ const REDUX_DEVTOOLS_EXTENSION = new InjectionToken('@ngrx/store-devtools Redux Devtools Extension');
646
+ class DevtoolsExtension {
647
+ constructor(devtoolsExtension, config, dispatcher) {
648
+ this.config = config;
649
+ this.dispatcher = dispatcher;
650
+ this.devtoolsExtension = devtoolsExtension;
651
+ this.createActionStreams();
652
+ }
653
+ notify(action, state) {
654
+ if (!this.devtoolsExtension) {
655
+ return;
656
+ }
657
+ // Check to see if the action requires a full update of the liftedState.
658
+ // If it is a simple action generated by the user's app and the recording
659
+ // is not locked/paused, only send the action and the current state (fast).
660
+ //
661
+ // A full liftedState update (slow: serializes the entire liftedState) is
662
+ // only required when:
663
+ // a) redux-devtools-extension fires the @@Init action (ignored by
664
+ // @ngrx/store-devtools)
665
+ // b) an action is generated by an @ngrx module (e.g. @ngrx/effects/init
666
+ // or @ngrx/store/update-reducers)
667
+ // c) the state has been recomputed due to time-traveling
668
+ // d) any action that is not a PerformAction to err on the side of
669
+ // caution.
670
+ if (action.type === PERFORM_ACTION) {
671
+ if (state.isLocked || state.isPaused) {
672
+ return;
673
+ }
674
+ const currentState = unliftState(state);
675
+ if (shouldFilterActions(this.config) &&
676
+ isActionFiltered(currentState, action, this.config.predicate, this.config.actionsSafelist, this.config.actionsBlocklist)) {
677
+ return;
678
+ }
679
+ const sanitizedState = this.config.stateSanitizer
680
+ ? sanitizeState(this.config.stateSanitizer, currentState, state.currentStateIndex)
681
+ : currentState;
682
+ const sanitizedAction = this.config.actionSanitizer
683
+ ? sanitizeAction(this.config.actionSanitizer, action, state.nextActionId)
684
+ : action;
685
+ this.sendToReduxDevtools(() => this.extensionConnection.send(sanitizedAction, sanitizedState));
686
+ }
687
+ else {
688
+ // Requires full state update
689
+ const sanitizedLiftedState = Object.assign(Object.assign({}, state), { stagedActionIds: state.stagedActionIds, actionsById: this.config.actionSanitizer
690
+ ? sanitizeActions(this.config.actionSanitizer, state.actionsById)
691
+ : state.actionsById, computedStates: this.config.stateSanitizer
692
+ ? sanitizeStates(this.config.stateSanitizer, state.computedStates)
693
+ : state.computedStates });
694
+ this.sendToReduxDevtools(() => this.devtoolsExtension.send(null, sanitizedLiftedState, this.getExtensionConfig(this.config)));
695
+ }
696
+ }
697
+ createChangesObservable() {
698
+ if (!this.devtoolsExtension) {
699
+ return EMPTY;
700
+ }
701
+ return new Observable((subscriber) => {
702
+ const connection = this.devtoolsExtension.connect(this.getExtensionConfig(this.config));
703
+ this.extensionConnection = connection;
704
+ connection.init();
705
+ connection.subscribe((change) => subscriber.next(change));
706
+ return connection.unsubscribe;
707
+ });
708
+ }
709
+ createActionStreams() {
710
+ // Listens to all changes
711
+ const changes$ = this.createChangesObservable().pipe(share());
712
+ // Listen for the start action
713
+ const start$ = changes$.pipe(filter((change) => change.type === ExtensionActionTypes.START));
714
+ // Listen for the stop action
715
+ const stop$ = changes$.pipe(filter((change) => change.type === ExtensionActionTypes.STOP));
716
+ // Listen for lifted actions
717
+ const liftedActions$ = changes$.pipe(filter((change) => change.type === ExtensionActionTypes.DISPATCH), map((change) => this.unwrapAction(change.payload)), concatMap((action) => {
718
+ if (action.type === IMPORT_STATE) {
719
+ // State imports may happen in two situations:
720
+ // 1. Explicitly by user
721
+ // 2. User activated the "persist state accross reloads" option
722
+ // and now the state is imported during reload.
723
+ // Because of option 2, we need to give possible
724
+ // lazy loaded reducers time to instantiate.
725
+ // As soon as there is no UPDATE action within 1 second,
726
+ // it is assumed that all reducers are loaded.
727
+ return this.dispatcher.pipe(filter((action) => action.type === UPDATE), timeout(1000), debounceTime(1000), map(() => action), catchError(() => of(action)), take(1));
728
+ }
729
+ else {
730
+ return of(action);
731
+ }
732
+ }));
733
+ // Listen for unlifted actions
734
+ const actions$ = changes$.pipe(filter((change) => change.type === ExtensionActionTypes.ACTION), map((change) => this.unwrapAction(change.payload)));
735
+ const actionsUntilStop$ = actions$.pipe(takeUntil(stop$));
736
+ const liftedUntilStop$ = liftedActions$.pipe(takeUntil(stop$));
737
+ this.start$ = start$.pipe(takeUntil(stop$));
738
+ // Only take the action sources between the start/stop events
739
+ this.actions$ = this.start$.pipe(switchMap(() => actionsUntilStop$));
740
+ this.liftedActions$ = this.start$.pipe(switchMap(() => liftedUntilStop$));
741
+ }
742
+ unwrapAction(action) {
743
+ return typeof action === 'string' ? eval(`(${action})`) : action;
744
+ }
745
+ getExtensionConfig(config) {
746
+ var _a;
747
+ const extensionOptions = {
748
+ name: config.name,
749
+ features: config.features,
750
+ serialize: config.serialize,
751
+ autoPause: (_a = config.autoPause) !== null && _a !== void 0 ? _a : false,
752
+ // The action/state sanitizers are not added to the config
753
+ // because sanitation is done in this class already.
754
+ // It is done before sending it to the devtools extension for consistency:
755
+ // - If we call extensionConnection.send(...),
756
+ // the extension would call the sanitizers.
757
+ // - If we call devtoolsExtension.send(...) (aka full state update),
758
+ // the extension would NOT call the sanitizers, so we have to do it ourselves.
759
+ };
760
+ if (config.maxAge !== false /* support === 0 */) {
761
+ extensionOptions.maxAge = config.maxAge;
762
+ }
763
+ return extensionOptions;
764
+ }
765
+ sendToReduxDevtools(send) {
766
+ try {
767
+ send();
768
+ }
769
+ catch (err) {
770
+ console.warn('@ngrx/store-devtools: something went wrong inside the redux devtools', err);
771
+ }
772
+ }
773
+ }
774
+ /** @nocollapse */ DevtoolsExtension.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: DevtoolsExtension, deps: [{ token: REDUX_DEVTOOLS_EXTENSION }, { token: STORE_DEVTOOLS_CONFIG }, { token: DevtoolsDispatcher }], target: i0.ɵɵFactoryTarget.Injectable });
775
+ /** @nocollapse */ DevtoolsExtension.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: DevtoolsExtension });
776
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: DevtoolsExtension, decorators: [{
777
+ type: Injectable
778
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
779
+ type: Inject,
780
+ args: [REDUX_DEVTOOLS_EXTENSION]
781
+ }] }, { type: StoreDevtoolsConfig, decorators: [{
782
+ type: Inject,
783
+ args: [STORE_DEVTOOLS_CONFIG]
784
+ }] }, { type: DevtoolsDispatcher }]; } });
785
+
788
786
  class StoreDevtools {
789
787
  constructor(dispatcher, actions$, reducers$, extension, scannedActions, errorHandler, initialState, config) {
790
788
  const liftedInitialState = liftInitialState(initialState, config.monitor);
@@ -867,27 +865,17 @@ class StoreDevtools {
867
865
  this.dispatch(new PauseRecording(status));
868
866
  }
869
867
  }
870
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
871
- StoreDevtools.decorators = [
872
- { type: Injectable }
873
- ];
874
- /**
875
- * @type {function(): !Array<(null|{
876
- * type: ?,
877
- * decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
878
- * })>}
879
- * @nocollapse
880
- */
881
- StoreDevtools.ctorParameters = () => [
882
- { type: DevtoolsDispatcher },
883
- { type: ActionsSubject },
884
- { type: ReducerObservable },
885
- { type: DevtoolsExtension },
886
- { type: ScannedActionsSubject },
887
- { type: ErrorHandler },
888
- { type: undefined, decorators: [{ type: Inject, args: [INITIAL_STATE,] }] },
889
- { type: StoreDevtoolsConfig, decorators: [{ type: Inject, args: [STORE_DEVTOOLS_CONFIG,] }] }
890
- ];
868
+ /** @nocollapse */ StoreDevtools.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: StoreDevtools, deps: [{ token: DevtoolsDispatcher }, { token: i2.ActionsSubject }, { token: i2.ReducerObservable }, { token: DevtoolsExtension }, { token: i2.ScannedActionsSubject }, { token: i0.ErrorHandler }, { token: INITIAL_STATE }, { token: STORE_DEVTOOLS_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
869
+ /** @nocollapse */ StoreDevtools.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: StoreDevtools });
870
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: StoreDevtools, decorators: [{
871
+ type: Injectable
872
+ }], ctorParameters: function () { return [{ type: DevtoolsDispatcher }, { type: i2.ActionsSubject }, { type: i2.ReducerObservable }, { type: DevtoolsExtension }, { type: i2.ScannedActionsSubject }, { type: i0.ErrorHandler }, { type: undefined, decorators: [{
873
+ type: Inject,
874
+ args: [INITIAL_STATE]
875
+ }] }, { type: StoreDevtoolsConfig, decorators: [{
876
+ type: Inject,
877
+ args: [STORE_DEVTOOLS_CONFIG]
878
+ }] }]; } });
891
879
 
892
880
  const IS_EXTENSION_OR_MONITOR_PRESENT = new InjectionToken('@ngrx/store-devtools Is Devtools Extension or Monitor Present');
893
881
  function createIsExtensionOrMonitorPresent(extension, config) {
@@ -945,10 +933,13 @@ class StoreDevtoolsModule {
945
933
  };
946
934
  }
947
935
  }
948
- /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
949
- StoreDevtoolsModule.decorators = [
950
- { type: NgModule, args: [{},] }
951
- ];
936
+ /** @nocollapse */ StoreDevtoolsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: StoreDevtoolsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
937
+ /** @nocollapse */ StoreDevtoolsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: StoreDevtoolsModule });
938
+ /** @nocollapse */ StoreDevtoolsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: StoreDevtoolsModule });
939
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: StoreDevtoolsModule, decorators: [{
940
+ type: NgModule,
941
+ args: [{}]
942
+ }] });
952
943
 
953
944
  /**
954
945
  * DO NOT EDIT
@@ -960,5 +951,5 @@ StoreDevtoolsModule.decorators = [
960
951
  * Generated bundle index. Do not edit.
961
952
  */
962
953
 
963
- export { INITIAL_OPTIONS, RECOMPUTE, StoreDevtools, StoreDevtoolsConfig, StoreDevtoolsModule, IS_EXTENSION_OR_MONITOR_PRESENT as ɵa, createIsExtensionOrMonitorPresent as ɵb, createReduxDevtoolsExtension as ɵc, createStateObservable as ɵd, STORE_DEVTOOLS_CONFIG as ɵe, noMonitor as ɵf, createConfig as ɵg, REDUX_DEVTOOLS_EXTENSION as ɵh, DevtoolsExtension as ɵi, DevtoolsDispatcher as ɵj };
954
+ export { INITIAL_OPTIONS, RECOMPUTE, StoreDevtools, StoreDevtoolsConfig, StoreDevtoolsModule };
964
955
  //# sourceMappingURL=ngrx-store-devtools.js.map