@ngrx/store-devtools
Version:
Developer tools for @ngrx/store
253 lines (244 loc) • 8.58 kB
TypeScript
import * as i0 from '@angular/core';
import { InjectionToken, ModuleWithProviders, OnDestroy, ErrorHandler, EnvironmentProviders } from '@angular/core';
import { ActionReducer, Action, ActionsSubject, StateObservable, ReducerObservable, ScannedActionsSubject } from '@ngrx/store';
import { Observable, Observer } from 'rxjs';
type ActionSanitizer = (action: Action, id: number) => Action;
type StateSanitizer = (state: any, index: number) => any;
type SerializationOptions = {
options?: boolean | any;
replacer?: (key: any, value: any) => {};
reviver?: (key: any, value: any) => {};
immutable?: any;
refs?: Array<any>;
};
type Predicate = (state: any, action: Action) => boolean;
/**
* Chrome extension documentation
* @see https://github.com/reduxjs/redux-devtools/blob/main/extension/docs/API/Arguments.md#features
* Firefox extension documentation
* @see https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md#features
*/
interface DevToolsFeatureOptions {
/**
* Start/pause recording of dispatched actions
*/
pause?: boolean;
/**
* Lock/unlock dispatching actions and side effects
*/
lock?: boolean;
/**
* Persist states on page reloading
*/
persist?: boolean;
/**
* Export history of actions in a file
*/
export?: boolean;
/**
* Import history of actions from a file
*/
import?: 'custom' | boolean;
/**
* Jump back and forth (time travelling)
*/
jump?: boolean;
/**
* Skip (cancel) actions
*/
skip?: boolean;
/**
* Drag and drop actions in the history list
*/
reorder?: boolean;
/**
* Dispatch custom actions or action creators
*/
dispatch?: boolean;
/**
* Generate tests for the selected actions
*/
test?: boolean;
}
/**
* Chrome extension documentation
* @see https://github.com/reduxjs/redux-devtools/blob/main/extension/docs/API/Arguments.md
* Firefox extension documentation
* @see https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md
*/
declare class StoreDevtoolsConfig {
/**
* Maximum allowed actions to be stored in the history tree (default: `false`)
*/
maxAge: number | false;
monitor?: ActionReducer<any, any>;
/**
* Function which takes `action` object and id number as arguments, and should return `action` object back.
*/
actionSanitizer?: ActionSanitizer;
/**
* Function which takes `state` object and index as arguments, and should return `state` object back.
*/
stateSanitizer?: StateSanitizer;
/**
* The instance name to be shown on the monitor page (default: `document.title`)
*/
name?: string;
serialize?: boolean | SerializationOptions;
logOnly?: boolean;
features?: DevToolsFeatureOptions;
/**
* Action types to be hidden in the monitors. If `actionsSafelist` specified, `actionsBlocklist` is ignored.
*/
actionsBlocklist?: string[];
/**
* Action types to be shown in the monitors
*/
actionsSafelist?: string[];
/**
* Called for every action before sending, takes state and action object, and returns true in case it allows sending the current data to the monitor.
*/
predicate?: Predicate;
/**
* Auto pauses when the extension’s window is not opened, and so has zero impact on your app when not in use.
*/
autoPause?: boolean;
/**
* If set to true, will include stack trace for every dispatched action
*/
trace?: boolean | (() => string);
/**
* Maximum stack trace frames to be stored (in case trace option was provided as true).
*/
traceLimit?: number;
/**
* The property determines whether the extension connection is established within the
* Angular zone or not. It is set to `false` by default.
*/
connectInZone?: boolean;
}
/**
* Used to provide a `StoreDevtoolsConfig` for the store-devtools.
*/
declare const INITIAL_OPTIONS: InjectionToken<StoreDevtoolsConfig>;
type StoreDevtoolsOptions = Partial<StoreDevtoolsConfig> | (() => Partial<StoreDevtoolsConfig>);
declare class StoreDevtoolsModule {
static instrument(options?: StoreDevtoolsOptions): ModuleWithProviders<StoreDevtoolsModule>;
static ɵfac: i0.ɵɵFactoryDeclaration<StoreDevtoolsModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<StoreDevtoolsModule, never, never, never>;
static ɵinj: i0.ɵɵInjectorDeclaration<StoreDevtoolsModule>;
}
declare const RECOMPUTE: "@ngrx/store-devtools/recompute";
interface ComputedState {
state: any;
error: any;
}
interface LiftedAction {
type: string;
action: Action;
}
interface LiftedActions {
[id: number]: LiftedAction;
}
interface LiftedState {
monitorState: any;
nextActionId: number;
actionsById: LiftedActions;
stagedActionIds: number[];
skippedActionIds: number[];
committedState: any;
currentStateIndex: number;
computedStates: ComputedState[];
isLocked: boolean;
isPaused: boolean;
}
declare class DevtoolsDispatcher extends ActionsSubject {
static ɵfac: i0.ɵɵFactoryDeclaration<DevtoolsDispatcher, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<DevtoolsDispatcher>;
}
declare const REDUX_DEVTOOLS_EXTENSION: InjectionToken<ReduxDevtoolsExtension>;
interface ReduxDevtoolsExtensionConnection {
subscribe(listener: (change: any) => void): void;
unsubscribe(): void;
send(action: any, state: any): void;
init(state?: any): void;
error(anyErr: any): void;
}
interface ReduxDevtoolsExtensionConfig {
features?: object | boolean;
name: string | undefined;
maxAge?: number;
autoPause?: boolean;
serialize?: boolean | SerializationOptions;
trace?: boolean | (() => string);
traceLimit?: number;
}
interface ReduxDevtoolsExtension {
connect(options: ReduxDevtoolsExtensionConfig): ReduxDevtoolsExtensionConnection;
send(action: any, state: any, options: ReduxDevtoolsExtensionConfig): void;
}
declare class DevtoolsExtension {
private config;
private dispatcher;
private devtoolsExtension;
private extensionConnection;
liftedActions$: Observable<any>;
actions$: Observable<any>;
start$: Observable<any>;
private zoneConfig;
constructor(devtoolsExtension: ReduxDevtoolsExtension, config: StoreDevtoolsConfig, dispatcher: DevtoolsDispatcher);
notify(action: LiftedAction, state: LiftedState): void;
private createChangesObservable;
private createActionStreams;
private unwrapAction;
private getExtensionConfig;
private sendToReduxDevtools;
static ɵfac: i0.ɵɵFactoryDeclaration<DevtoolsExtension, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<DevtoolsExtension>;
}
declare class StoreDevtools implements Observer<any>, OnDestroy {
private liftedStateSubscription;
private extensionStartSubscription;
dispatcher: ActionsSubject;
liftedState: Observable<LiftedState>;
state: StateObservable;
constructor(dispatcher: DevtoolsDispatcher, actions$: ActionsSubject, reducers$: ReducerObservable, extension: DevtoolsExtension, scannedActions: ScannedActionsSubject, errorHandler: ErrorHandler, initialState: any, config: StoreDevtoolsConfig);
ngOnDestroy(): void;
dispatch(action: Action): void;
next(action: any): void;
error(error: any): void;
complete(): void;
performAction(action: any): void;
refresh(): void;
reset(): void;
rollback(): void;
commit(): void;
sweep(): void;
toggleAction(id: number): void;
jumpToAction(actionId: number): void;
jumpToState(index: number): void;
importState(nextLiftedState: any): void;
lockChanges(status: boolean): void;
pauseRecording(status: boolean): void;
static ɵfac: i0.ɵɵFactoryDeclaration<StoreDevtools, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<StoreDevtools>;
}
/**
* Provides developer tools and instrumentation for `Store`.
*
* @usageNotes
*
* ```ts
* bootstrapApplication(AppComponent, {
* providers: [
* provideStoreDevtools({
* maxAge: 25,
* logOnly: !isDevMode(),
* }),
* ],
* });
* ```
*/
declare function provideStoreDevtools(options?: StoreDevtoolsOptions): EnvironmentProviders;
export { INITIAL_OPTIONS, RECOMPUTE, REDUX_DEVTOOLS_EXTENSION, StoreDevtools, StoreDevtoolsConfig, StoreDevtoolsModule, provideStoreDevtools };
export type { DevToolsFeatureOptions, LiftedState, StoreDevtoolsOptions };