@ngxs/devtools-plugin 3.7.6-dev.master-5f9405c → 3.7.6-dev.master-5bdcd2a
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-devtools-plugin.umd.js","sources":["../../../packages/devtools-plugin/src/symbols.ts","../../../packages/devtools-plugin/src/devtools.plugin.ts","../../../packages/devtools-plugin/src/devtools.module.ts","../../../packages/devtools-plugin/index.ts","../../../packages/devtools-plugin/ngxs-devtools-plugin.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\n/**\n * Interface for the redux-devtools-extension API.\n */\nexport interface NgxsDevtoolsExtension {\n init(state: any): void;\n send(action: any, state?: any): void;\n subscribe(fn: (message: NgxsDevtoolsAction) => void): VoidFunction;\n}\n\nexport interface NgxsDevtoolsAction {\n type: string;\n payload: any;\n state: any;\n id: number;\n source: string;\n}\n\nexport interface NgxsDevtoolsOptions {\n /**\n * The name of the extension\n */\n name?: string;\n\n /**\n * Whether the dev tools is enabled or note. Useful for setting during production.\n */\n disabled?: boolean;\n\n /**\n * Max number of entiries to keep.\n */\n maxAge?: number;\n\n /**\n * If more than one action is dispatched in the indicated interval, all new actions will be collected\n * and sent at once. It is the joint between performance and speed. When set to 0, all actions will be\n * sent instantly. Set it to a higher value when experiencing perf issues (also maxAge to a lower value).\n * Default is 500 ms.\n */\n latency?: number;\n\n /**\n * string or array of strings as regex - actions types to be hidden in the monitors (while passed to the reducers).\n * If actionsWhitelist specified, actionsBlacklist is ignored.\n */\n actionsBlacklist?: string | string[];\n\n /**\n * string or array of strings as regex - actions types to be shown in the monitors (while passed to the reducers).\n * If actionsWhitelist specified, actionsBlacklist is ignored.\n */\n actionsWhitelist?: string | string[];\n\n\n /**\n * called for every action before sending, takes state and action object, and returns true in case it allows\n * sending the current data to the monitor. Use it as a more advanced version of\n * actionsBlacklist/actionsWhitelist parameters\n */\n predicate?: (state: any, action: any) => boolean;\n\n /**\n * Reformat actions before sending to dev tools\n */\n actionSanitizer?: (action: any) => void;\n\n /**\n * Reformat state before sending to devtools\n */\n stateSanitizer?: (state: any) => void;\n}\n\nexport const NGXS_DEVTOOLS_OPTIONS = new InjectionToken('NGXS_DEVTOOLS_OPTIONS');\n","import { Inject, Injectable, Injector, NgZone, OnDestroy, ɵglobal } from '@angular/core';\nimport { getActionTypeFromInstance, NgxsNextPluginFn, NgxsPlugin, Store } from '@ngxs/store';\nimport { tap, catchError } from 'rxjs/operators';\n\nimport {\n NGXS_DEVTOOLS_OPTIONS,\n NgxsDevtoolsAction,\n NgxsDevtoolsExtension,\n NgxsDevtoolsOptions\n} from './symbols';\n\nconst enum ReduxDevtoolsActionType {\n Dispatch = 'DISPATCH',\n Action = 'ACTION'\n}\n\nconst enum ReduxDevtoolsPayloadType {\n JumpToAction = 'JUMP_TO_ACTION',\n JumpToState = 'JUMP_TO_STATE',\n ToggleAction = 'TOGGLE_ACTION',\n ImportState = 'IMPORT_STATE'\n}\n\n/**\n * Adds support for the Redux Devtools extension:\n * http://extension.remotedev.io/\n */\n@Injectable()\nexport class NgxsReduxDevtoolsPlugin implements OnDestroy, NgxsPlugin {\n private devtoolsExtension: NgxsDevtoolsExtension | null = null;\n private readonly globalDevtools =\n ɵglobal['__REDUX_DEVTOOLS_EXTENSION__'] || ɵglobal['devToolsExtension'];\n\n private unsubscribe: VoidFunction | null = null;\n\n constructor(\n @Inject(NGXS_DEVTOOLS_OPTIONS) private _options: NgxsDevtoolsOptions,\n private _injector: Injector,\n private _ngZone: NgZone\n ) {\n this.connect();\n }\n\n ngOnDestroy(): void {\n if (this.unsubscribe !== null) {\n this.unsubscribe();\n }\n if (this.globalDevtools) {\n this.globalDevtools.disconnect();\n }\n }\n\n /**\n * Lazy get the store for circular dependency issues\n */\n private get store(): Store {\n return this._injector.get<Store>(Store);\n }\n\n /**\n * Middleware handle function\n */\n handle(state: any, action: any, next: NgxsNextPluginFn) {\n if (!this.devtoolsExtension || this._options.disabled) {\n return next(state, action);\n }\n\n return next(state, action).pipe(\n catchError(error => {\n const newState = this.store.snapshot();\n this.sendToDevTools(state, action, newState);\n throw error;\n }),\n tap(newState => {\n this.sendToDevTools(state, action, newState);\n })\n );\n }\n\n private sendToDevTools(state: any, action: any, newState: any) {\n const type = getActionTypeFromInstance(action);\n // if init action, send initial state to dev tools\n const isInitAction = type === '@@INIT';\n if (isInitAction) {\n this.devtoolsExtension!.init(state);\n } else {\n this.devtoolsExtension!.send({ ...action, action: null, type }, newState);\n }\n }\n\n /**\n * Handle the action from the dev tools subscription\n */\n dispatched(action: NgxsDevtoolsAction) {\n if (action.type === ReduxDevtoolsActionType.Dispatch) {\n if (\n action.payload.type === ReduxDevtoolsPayloadType.JumpToAction ||\n action.payload.type === ReduxDevtoolsPayloadType.JumpToState\n ) {\n const prevState = JSON.parse(action.state);\n // This makes the DevTools and Router plugins friends with each other.\n // We're checking for the `router` state to exist, and it also should\n // have the `trigger` property, so we're sure that this is our router\n // state (coming from `@ngxs/router-plugin`). This enables a time-traveling\n // feature since it doesn't only restore the state but also allows the `RouterState`\n // to navigate back when the action is jumped.\n if (prevState.router && prevState.router.trigger) {\n prevState.router.trigger = 'devtools';\n }\n this.store.reset(prevState);\n } else if (action.payload.type === ReduxDevtoolsPayloadType.ToggleAction) {\n console.warn('Skip is not supported at this time.');\n } else if (action.payload.type === ReduxDevtoolsPayloadType.ImportState) {\n const {\n actionsById,\n computedStates,\n currentStateIndex\n } = action.payload.nextLiftedState;\n this.devtoolsExtension!.init(computedStates[0].state);\n Object.keys(actionsById)\n .filter(actionId => actionId !== '0')\n .forEach(actionId =>\n this.devtoolsExtension!.send(actionsById[actionId], computedStates[actionId].state)\n );\n this.store.reset(computedStates[currentStateIndex].state);\n }\n } else if (action.type === ReduxDevtoolsActionType.Action) {\n const actionPayload = JSON.parse(action.payload);\n this.store.dispatch(actionPayload);\n }\n }\n\n private connect(): void {\n if (!this.globalDevtools || this._options.disabled) {\n return;\n }\n\n // The `connect` method adds `message` event listener since it communicates\n // with an extension through `window.postMessage` and message events.\n // We handle only 2 events; thus, we don't want to run many change detections\n // because the extension sends events that we don't have to handle.\n this.devtoolsExtension = this._ngZone.runOutsideAngular(\n () => <NgxsDevtoolsExtension>this.globalDevtools.connect(this._options)\n );\n\n this.unsubscribe = this.devtoolsExtension.subscribe(action => {\n if (\n action.type === ReduxDevtoolsActionType.Dispatch ||\n action.type === ReduxDevtoolsActionType.Action\n ) {\n this._ngZone.run(() => {\n this.dispatched(action);\n });\n }\n });\n }\n}\n","import { NgModule, ModuleWithProviders, InjectionToken } from '@angular/core';\nimport { NGXS_PLUGINS } from '@ngxs/store';\n\nimport { NgxsDevtoolsOptions, NGXS_DEVTOOLS_OPTIONS } from './symbols';\nimport { NgxsReduxDevtoolsPlugin } from './devtools.plugin';\n\nexport function devtoolsOptionsFactory(options: NgxsDevtoolsOptions) {\n return {\n name: 'NGXS',\n ...options\n };\n}\n\nexport const USER_OPTIONS = new InjectionToken('USER_OPTIONS');\n\n@NgModule()\nexport class NgxsReduxDevtoolsPluginModule {\n static forRoot(\n options?: NgxsDevtoolsOptions\n ): ModuleWithProviders<NgxsReduxDevtoolsPluginModule> {\n return {\n ngModule: NgxsReduxDevtoolsPluginModule,\n providers: [\n {\n provide: NGXS_PLUGINS,\n useClass: NgxsReduxDevtoolsPlugin,\n multi: true\n },\n {\n provide: USER_OPTIONS,\n useValue: options\n },\n {\n provide: NGXS_DEVTOOLS_OPTIONS,\n useFactory: devtoolsOptionsFactory,\n deps: [USER_OPTIONS]\n }\n ]\n };\n }\n}\n","/**\n * The public api for consumers of @ngxs/devtools-plugin\n */\nexport * from './src/public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["InjectionToken","ɵglobal","Store","catchError","tap","getActionTypeFromInstance","i0","Injectable","Inject","NGXS_PLUGINS","NgModule"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;QA0Ea,qBAA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B,EAAA,CAAA,CAAA;sHAA7B,6BAA6B,EAAA,UAAA,EAAA,CAAA;sBADzCI,WAAQ;;;ICfT;;IAEG;;ICFH;;IAEG;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"ngxs-devtools-plugin.umd.js","sources":["../../../packages/devtools-plugin/src/symbols.ts","../../../packages/devtools-plugin/src/devtools.plugin.ts","../../../packages/devtools-plugin/src/devtools.module.ts","../../../packages/devtools-plugin/index.ts","../../../packages/devtools-plugin/ngxs-devtools-plugin.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\n/**\n * Interface for the redux-devtools-extension API.\n */\nexport interface NgxsDevtoolsExtension {\n init(state: any): void;\n send(action: any, state?: any): void;\n subscribe(fn: (message: NgxsDevtoolsAction) => void): VoidFunction;\n}\n\nexport interface NgxsDevtoolsAction {\n type: string;\n payload: any;\n state: any;\n id: number;\n source: string;\n}\n\nexport interface NgxsDevtoolsOptions {\n /**\n * The name of the extension\n */\n name?: string;\n\n /**\n * Whether the dev tools is enabled or note. Useful for setting during production.\n */\n disabled?: boolean;\n\n /**\n * Max number of entiries to keep.\n */\n maxAge?: number;\n\n /**\n * If more than one action is dispatched in the indicated interval, all new actions will be collected\n * and sent at once. It is the joint between performance and speed. When set to 0, all actions will be\n * sent instantly. Set it to a higher value when experiencing perf issues (also maxAge to a lower value).\n * Default is 500 ms.\n */\n latency?: number;\n\n /**\n * string or array of strings as regex - actions types to be hidden in the monitors (while passed to the reducers).\n * If actionsWhitelist specified, actionsBlacklist is ignored.\n */\n actionsBlacklist?: string | string[];\n\n /**\n * string or array of strings as regex - actions types to be shown in the monitors (while passed to the reducers).\n * If actionsWhitelist specified, actionsBlacklist is ignored.\n */\n actionsWhitelist?: string | string[];\n\n /**\n * called for every action before sending, takes state and action object, and returns true in case it allows\n * sending the current data to the monitor. Use it as a more advanced version of\n * actionsBlacklist/actionsWhitelist parameters\n */\n predicate?: (state: any, action: any) => boolean;\n\n /**\n * Reformat actions before sending to dev tools\n */\n actionSanitizer?: (action: any) => void;\n\n /**\n * Reformat state before sending to devtools\n */\n stateSanitizer?: (state: any) => void;\n\n /**\n * If set to true, will include stack trace for every dispatched action\n */\n trace?: boolean | (() => string);\n\n /**\n * Maximum stack trace frames to be stored (in case trace option was provided as true)\n */\n traceLimit?: number;\n}\n\nexport const NGXS_DEVTOOLS_OPTIONS = new InjectionToken('NGXS_DEVTOOLS_OPTIONS');\n","import { Inject, Injectable, Injector, NgZone, OnDestroy, ɵglobal } from '@angular/core';\nimport { getActionTypeFromInstance, NgxsNextPluginFn, NgxsPlugin, Store } from '@ngxs/store';\nimport { tap, catchError } from 'rxjs/operators';\n\nimport {\n NGXS_DEVTOOLS_OPTIONS,\n NgxsDevtoolsAction,\n NgxsDevtoolsExtension,\n NgxsDevtoolsOptions\n} from './symbols';\n\nconst enum ReduxDevtoolsActionType {\n Dispatch = 'DISPATCH',\n Action = 'ACTION'\n}\n\nconst enum ReduxDevtoolsPayloadType {\n JumpToAction = 'JUMP_TO_ACTION',\n JumpToState = 'JUMP_TO_STATE',\n ToggleAction = 'TOGGLE_ACTION',\n ImportState = 'IMPORT_STATE'\n}\n\n/**\n * Adds support for the Redux Devtools extension:\n * http://extension.remotedev.io/\n */\n@Injectable()\nexport class NgxsReduxDevtoolsPlugin implements OnDestroy, NgxsPlugin {\n private devtoolsExtension: NgxsDevtoolsExtension | null = null;\n private readonly globalDevtools =\n ɵglobal['__REDUX_DEVTOOLS_EXTENSION__'] || ɵglobal['devToolsExtension'];\n\n private unsubscribe: VoidFunction | null = null;\n\n constructor(\n @Inject(NGXS_DEVTOOLS_OPTIONS) private _options: NgxsDevtoolsOptions,\n private _injector: Injector,\n private _ngZone: NgZone\n ) {\n this.connect();\n }\n\n ngOnDestroy(): void {\n if (this.unsubscribe !== null) {\n this.unsubscribe();\n }\n if (this.globalDevtools) {\n this.globalDevtools.disconnect();\n }\n }\n\n /**\n * Lazy get the store for circular dependency issues\n */\n private get store(): Store {\n return this._injector.get<Store>(Store);\n }\n\n /**\n * Middleware handle function\n */\n handle(state: any, action: any, next: NgxsNextPluginFn) {\n if (!this.devtoolsExtension || this._options.disabled) {\n return next(state, action);\n }\n\n return next(state, action).pipe(\n catchError(error => {\n const newState = this.store.snapshot();\n this.sendToDevTools(state, action, newState);\n throw error;\n }),\n tap(newState => {\n this.sendToDevTools(state, action, newState);\n })\n );\n }\n\n private sendToDevTools(state: any, action: any, newState: any) {\n const type = getActionTypeFromInstance(action);\n // if init action, send initial state to dev tools\n const isInitAction = type === '@@INIT';\n if (isInitAction) {\n this.devtoolsExtension!.init(state);\n } else {\n this.devtoolsExtension!.send({ ...action, action: null, type }, newState);\n }\n }\n\n /**\n * Handle the action from the dev tools subscription\n */\n dispatched(action: NgxsDevtoolsAction) {\n if (action.type === ReduxDevtoolsActionType.Dispatch) {\n if (\n action.payload.type === ReduxDevtoolsPayloadType.JumpToAction ||\n action.payload.type === ReduxDevtoolsPayloadType.JumpToState\n ) {\n const prevState = JSON.parse(action.state);\n // This makes the DevTools and Router plugins friends with each other.\n // We're checking for the `router` state to exist, and it also should\n // have the `trigger` property, so we're sure that this is our router\n // state (coming from `@ngxs/router-plugin`). This enables a time-traveling\n // feature since it doesn't only restore the state but also allows the `RouterState`\n // to navigate back when the action is jumped.\n if (prevState.router && prevState.router.trigger) {\n prevState.router.trigger = 'devtools';\n }\n this.store.reset(prevState);\n } else if (action.payload.type === ReduxDevtoolsPayloadType.ToggleAction) {\n console.warn('Skip is not supported at this time.');\n } else if (action.payload.type === ReduxDevtoolsPayloadType.ImportState) {\n const {\n actionsById,\n computedStates,\n currentStateIndex\n } = action.payload.nextLiftedState;\n this.devtoolsExtension!.init(computedStates[0].state);\n Object.keys(actionsById)\n .filter(actionId => actionId !== '0')\n .forEach(actionId =>\n this.devtoolsExtension!.send(actionsById[actionId], computedStates[actionId].state)\n );\n this.store.reset(computedStates[currentStateIndex].state);\n }\n } else if (action.type === ReduxDevtoolsActionType.Action) {\n const actionPayload = JSON.parse(action.payload);\n this.store.dispatch(actionPayload);\n }\n }\n\n private connect(): void {\n if (!this.globalDevtools || this._options.disabled) {\n return;\n }\n\n // The `connect` method adds `message` event listener since it communicates\n // with an extension through `window.postMessage` and message events.\n // We handle only 2 events; thus, we don't want to run many change detections\n // because the extension sends events that we don't have to handle.\n this.devtoolsExtension = this._ngZone.runOutsideAngular(\n () => <NgxsDevtoolsExtension>this.globalDevtools.connect(this._options)\n );\n\n this.unsubscribe = this.devtoolsExtension.subscribe(action => {\n if (\n action.type === ReduxDevtoolsActionType.Dispatch ||\n action.type === ReduxDevtoolsActionType.Action\n ) {\n this._ngZone.run(() => {\n this.dispatched(action);\n });\n }\n });\n }\n}\n","import { NgModule, ModuleWithProviders, InjectionToken } from '@angular/core';\nimport { NGXS_PLUGINS } from '@ngxs/store';\n\nimport { NgxsDevtoolsOptions, NGXS_DEVTOOLS_OPTIONS } from './symbols';\nimport { NgxsReduxDevtoolsPlugin } from './devtools.plugin';\n\nexport function devtoolsOptionsFactory(options: NgxsDevtoolsOptions) {\n return {\n name: 'NGXS',\n ...options\n };\n}\n\nexport const USER_OPTIONS = new InjectionToken('USER_OPTIONS');\n\n@NgModule()\nexport class NgxsReduxDevtoolsPluginModule {\n static forRoot(\n options?: NgxsDevtoolsOptions\n ): ModuleWithProviders<NgxsReduxDevtoolsPluginModule> {\n return {\n ngModule: NgxsReduxDevtoolsPluginModule,\n providers: [\n {\n provide: NGXS_PLUGINS,\n useClass: NgxsReduxDevtoolsPlugin,\n multi: true\n },\n {\n provide: USER_OPTIONS,\n useValue: options\n },\n {\n provide: NGXS_DEVTOOLS_OPTIONS,\n useFactory: devtoolsOptionsFactory,\n deps: [USER_OPTIONS]\n }\n ]\n };\n }\n}\n","/**\n * The public api for consumers of @ngxs/devtools-plugin\n */\nexport * from './src/public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["InjectionToken","ɵglobal","Store","catchError","tap","getActionTypeFromInstance","i0","Injectable","Inject","N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A,EAAA,CAAA,CAAA;yKAA7B,6BAA6B,EAAA,CAAA,CAAA;yKAA7B,6BAA6B,EAAA,CAAA,CAAA;sHAA7B,6BAA6B,EAAA,UAAA,EAAA,CAAA;sBADzCI,WAAQ;;;ICfT;;IAEG;;ICFH;;IAEG;;;;;;;;;;;;"}
|
package/esm2015/src/symbols.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
2
|
export const NGXS_DEVTOOLS_OPTIONS = new InjectionToken('NGXS_DEVTOOLS_OPTIONS');
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3ltYm9scy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3BhY2thZ2VzL2RldnRvb2xzLXBsdWdpbi9zcmMvc3ltYm9scy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBbUYvQyxNQUFNLENBQUMsTUFBTSxxQkFBcUIsR0FBRyxJQUFJLGNBQWMsQ0FBQyx1QkFBdUIsQ0FBQyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgSW5qZWN0aW9uVG9rZW4gfSBmcm9tICdAYW5ndWxhci9jb3JlJztcblxuLyoqXG4gKiBJbnRlcmZhY2UgZm9yIHRoZSByZWR1eC1kZXZ0b29scy1leHRlbnNpb24gQVBJLlxuICovXG5leHBvcnQgaW50ZXJmYWNlIE5neHNEZXZ0b29sc0V4dGVuc2lvbiB7XG4gIGluaXQoc3RhdGU6IGFueSk6IHZvaWQ7XG4gIHNlbmQoYWN0aW9uOiBhbnksIHN0YXRlPzogYW55KTogdm9pZDtcbiAgc3Vic2NyaWJlKGZuOiAobWVzc2FnZTogTmd4c0RldnRv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NhdGU/OiAoc3RhdGU6IGFueSwgYWN0aW9uOiBhbnkpID0+IGJvb2xlYW47XG5cbiAgLyoqXG4gICAqIFJlZm9ybWF0IGFjdGlvbnMgYmVmb3JlIHNlbmRpbmcgdG8gZGV2IHRvb2xzXG4gICAqL1xuICBhY3Rpb25TYW5pdGl6ZXI/OiAoYWN0aW9uOiBhbnkpID0+IHZvaWQ7XG5cbiAgLyoqXG4gICAqIFJlZm9ybWF0IHN0YXRlIGJlZm9yZSBzZW5kaW5nIHRvIGRldnRvb2xzXG4gICAqL1xuICBzdGF0ZVNhbml0aXplcj86IChzdGF0ZTogYW55KSA9PiB2b2lkO1xuXG4gIC8qKlxuICAgKiBJZiBzZXQgdG8gdHJ1ZSwgd2lsbCBpbmNsdWRlIHN0YWNrIHRyYWNlIGZvciBldmVyeSBkaXNwYXRjaGVkIGFjdGlvblxuICAgKi9cbiAgdHJhY2U/OiBib29sZWFuIHwgKCgpID0+IHN0cmluZyk7XG5cbiAgLyoqXG4gICAqIE1heGltdW0gc3RhY2sgdHJhY2UgZnJhbWVzIHRvIGJlIHN0b3JlZCAoaW4gY2FzZSB0cmFjZSBvcHRpb24gd2FzIHByb3ZpZGVkIGFzIHRydWUpXG4gICAqL1xuICB0cmFjZUxpbWl0PzogbnVtYmVyO1xufVxuXG5leHBvcnQgY29uc3QgTkdYU19ERVZUT09MU19PUFRJT05TID0gbmV3IEluamVjdGlvblRva2VuKCdOR1hTX0RFVlRPT0xTX09QVElPTlMnKTtcbiJdfQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-devtools-plugin.js","sources":["../../../packages/devtools-plugin/src/symbols.ts","../../../packages/devtools-plugin/src/devtools.plugin.ts","../../../packages/devtools-plugin/src/devtools.module.ts","../../../packages/devtools-plugin/index.ts","../../../packages/devtools-plugin/ngxs-devtools-plugin.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\n/**\n * Interface for the redux-devtools-extension API.\n */\nexport interface NgxsDevtoolsExtension {\n init(state: any): void;\n send(action: any, state?: any): void;\n subscribe(fn: (message: NgxsDevtoolsAction) => void): VoidFunction;\n}\n\nexport interface NgxsDevtoolsAction {\n type: string;\n payload: any;\n state: any;\n id: number;\n source: string;\n}\n\nexport interface NgxsDevtoolsOptions {\n /**\n * The name of the extension\n */\n name?: string;\n\n /**\n * Whether the dev tools is enabled or note. Useful for setting during production.\n */\n disabled?: boolean;\n\n /**\n * Max number of entiries to keep.\n */\n maxAge?: number;\n\n /**\n * If more than one action is dispatched in the indicated interval, all new actions will be collected\n * and sent at once. It is the joint between performance and speed. When set to 0, all actions will be\n * sent instantly. Set it to a higher value when experiencing perf issues (also maxAge to a lower value).\n * Default is 500 ms.\n */\n latency?: number;\n\n /**\n * string or array of strings as regex - actions types to be hidden in the monitors (while passed to the reducers).\n * If actionsWhitelist specified, actionsBlacklist is ignored.\n */\n actionsBlacklist?: string | string[];\n\n /**\n * string or array of strings as regex - actions types to be shown in the monitors (while passed to the reducers).\n * If actionsWhitelist specified, actionsBlacklist is ignored.\n */\n actionsWhitelist?: string | string[];\n\n\n /**\n * called for every action before sending, takes state and action object, and returns true in case it allows\n * sending the current data to the monitor. Use it as a more advanced version of\n * actionsBlacklist/actionsWhitelist parameters\n */\n predicate?: (state: any, action: any) => boolean;\n\n /**\n * Reformat actions before sending to dev tools\n */\n actionSanitizer?: (action: any) => void;\n\n /**\n * Reformat state before sending to devtools\n */\n stateSanitizer?: (state: any) => void;\n}\n\nexport const NGXS_DEVTOOLS_OPTIONS = new InjectionToken('NGXS_DEVTOOLS_OPTIONS');\n","import { Inject, Injectable, Injector, NgZone, OnDestroy, ɵglobal } from '@angular/core';\nimport { getActionTypeFromInstance, NgxsNextPluginFn, NgxsPlugin, Store } from '@ngxs/store';\nimport { tap, catchError } from 'rxjs/operators';\n\nimport {\n NGXS_DEVTOOLS_OPTIONS,\n NgxsDevtoolsAction,\n NgxsDevtoolsExtension,\n NgxsDevtoolsOptions\n} from './symbols';\n\nconst enum ReduxDevtoolsActionType {\n Dispatch = 'DISPATCH',\n Action = 'ACTION'\n}\n\nconst enum ReduxDevtoolsPayloadType {\n JumpToAction = 'JUMP_TO_ACTION',\n JumpToState = 'JUMP_TO_STATE',\n ToggleAction = 'TOGGLE_ACTION',\n ImportState = 'IMPORT_STATE'\n}\n\n/**\n * Adds support for the Redux Devtools extension:\n * http://extension.remotedev.io/\n */\n@Injectable()\nexport class NgxsReduxDevtoolsPlugin implements OnDestroy, NgxsPlugin {\n private devtoolsExtension: NgxsDevtoolsExtension | null = null;\n private readonly globalDevtools =\n ɵglobal['__REDUX_DEVTOOLS_EXTENSION__'] || ɵglobal['devToolsExtension'];\n\n private unsubscribe: VoidFunction | null = null;\n\n constructor(\n @Inject(NGXS_DEVTOOLS_OPTIONS) private _options: NgxsDevtoolsOptions,\n private _injector: Injector,\n private _ngZone: NgZone\n ) {\n this.connect();\n }\n\n ngOnDestroy(): void {\n if (this.unsubscribe !== null) {\n this.unsubscribe();\n }\n if (this.globalDevtools) {\n this.globalDevtools.disconnect();\n }\n }\n\n /**\n * Lazy get the store for circular dependency issues\n */\n private get store(): Store {\n return this._injector.get<Store>(Store);\n }\n\n /**\n * Middleware handle function\n */\n handle(state: any, action: any, next: NgxsNextPluginFn) {\n if (!this.devtoolsExtension || this._options.disabled) {\n return next(state, action);\n }\n\n return next(state, action).pipe(\n catchError(error => {\n const newState = this.store.snapshot();\n this.sendToDevTools(state, action, newState);\n throw error;\n }),\n tap(newState => {\n this.sendToDevTools(state, action, newState);\n })\n );\n }\n\n private sendToDevTools(state: any, action: any, newState: any) {\n const type = getActionTypeFromInstance(action);\n // if init action, send initial state to dev tools\n const isInitAction = type === '@@INIT';\n if (isInitAction) {\n this.devtoolsExtension!.init(state);\n } else {\n this.devtoolsExtension!.send({ ...action, action: null, type }, newState);\n }\n }\n\n /**\n * Handle the action from the dev tools subscription\n */\n dispatched(action: NgxsDevtoolsAction) {\n if (action.type === ReduxDevtoolsActionType.Dispatch) {\n if (\n action.payload.type === ReduxDevtoolsPayloadType.JumpToAction ||\n action.payload.type === ReduxDevtoolsPayloadType.JumpToState\n ) {\n const prevState = JSON.parse(action.state);\n // This makes the DevTools and Router plugins friends with each other.\n // We're checking for the `router` state to exist, and it also should\n // have the `trigger` property, so we're sure that this is our router\n // state (coming from `@ngxs/router-plugin`). This enables a time-traveling\n // feature since it doesn't only restore the state but also allows the `RouterState`\n // to navigate back when the action is jumped.\n if (prevState.router && prevState.router.trigger) {\n prevState.router.trigger = 'devtools';\n }\n this.store.reset(prevState);\n } else if (action.payload.type === ReduxDevtoolsPayloadType.ToggleAction) {\n console.warn('Skip is not supported at this time.');\n } else if (action.payload.type === ReduxDevtoolsPayloadType.ImportState) {\n const {\n actionsById,\n computedStates,\n currentStateIndex\n } = action.payload.nextLiftedState;\n this.devtoolsExtension!.init(computedStates[0].state);\n Object.keys(actionsById)\n .filter(actionId => actionId !== '0')\n .forEach(actionId =>\n this.devtoolsExtension!.send(actionsById[actionId], computedStates[actionId].state)\n );\n this.store.reset(computedStates[currentStateIndex].state);\n }\n } else if (action.type === ReduxDevtoolsActionType.Action) {\n const actionPayload = JSON.parse(action.payload);\n this.store.dispatch(actionPayload);\n }\n }\n\n private connect(): void {\n if (!this.globalDevtools || this._options.disabled) {\n return;\n }\n\n // The `connect` method adds `message` event listener since it communicates\n // with an extension through `window.postMessage` and message events.\n // We handle only 2 events; thus, we don't want to run many change detections\n // because the extension sends events that we don't have to handle.\n this.devtoolsExtension = this._ngZone.runOutsideAngular(\n () => <NgxsDevtoolsExtension>this.globalDevtools.connect(this._options)\n );\n\n this.unsubscribe = this.devtoolsExtension.subscribe(action => {\n if (\n action.type === ReduxDevtoolsActionType.Dispatch ||\n action.type === ReduxDevtoolsActionType.Action\n ) {\n this._ngZone.run(() => {\n this.dispatched(action);\n });\n }\n });\n }\n}\n","import { NgModule, ModuleWithProviders, InjectionToken } from '@angular/core';\nimport { NGXS_PLUGINS } from '@ngxs/store';\n\nimport { NgxsDevtoolsOptions, NGXS_DEVTOOLS_OPTIONS } from './symbols';\nimport { NgxsReduxDevtoolsPlugin } from './devtools.plugin';\n\nexport function devtoolsOptionsFactory(options: NgxsDevtoolsOptions) {\n return {\n name: 'NGXS',\n ...options\n };\n}\n\nexport const USER_OPTIONS = new InjectionToken('USER_OPTIONS');\n\n@NgModule()\nexport class NgxsReduxDevtoolsPluginModule {\n static forRoot(\n options?: NgxsDevtoolsOptions\n ): ModuleWithProviders<NgxsReduxDevtoolsPluginModule> {\n return {\n ngModule: NgxsReduxDevtoolsPluginModule,\n providers: [\n {\n provide: NGXS_PLUGINS,\n useClass: NgxsReduxDevtoolsPlugin,\n multi: true\n },\n {\n provide: USER_OPTIONS,\n useValue: options\n },\n {\n provide: NGXS_DEVTOOLS_OPTIONS,\n useFactory: devtoolsOptionsFactory,\n deps: [USER_OPTIONS]\n }\n ]\n };\n }\n}\n","/**\n * The public api for consumers of @ngxs/devtools-plugin\n */\nexport * from './src/public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MA0Ea,qBAAqB,GAAG,IAAI,cAAc,CAAC,uBAAuB;;ACnD/E;;;AAGG;MAEU,uBAAuB,CAAA;AAOlC,IAAA,WAAA,CACyC,QAA6B,EAC5D,SAAmB,EACnB,OAAe,EAAA;QAFgB,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAqB;QAC5D,IAAS,CAAA,SAAA,GAAT,SAAS,CAAU;QACnB,IAAO,CAAA,OAAA,GAAP,OAAO,CAAQ;QATjB,IAAiB,CAAA,iBAAA,GAAiC,IAAI,CAAC;QAC9C,IAAc,CAAA,cAAA,GAC7B,OAAO,CAAC,8BAA8B,CAAC,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAElE,IAAW,CAAA,WAAA,GAAwB,IAAI,CAAC;QAO9C,IAAI,CAAC,OAAO,EAAE,CAAC;KAChB;IAED,WAAW,GAAA;AACT,QAAA,IAAI,IAAI,CAA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EAAA,UAAA,EAAA,CAAA;kBADzC,QAAQ;;;ACfT;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngxs-devtools-plugin.js","sources":["../../../packages/devtools-plugin/src/symbols.ts","../../../packages/devtools-plugin/src/devtools.plugin.ts","../../../packages/devtools-plugin/src/devtools.module.ts","../../../packages/devtools-plugin/index.ts","../../../packages/devtools-plugin/ngxs-devtools-plugin.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\n/**\n * Interface for the redux-devtools-extension API.\n */\nexport interface NgxsDevtoolsExtension {\n init(state: any): void;\n send(action: any, state?: any): void;\n subscribe(fn: (message: NgxsDevtoolsAction) => void): VoidFunction;\n}\n\nexport interface NgxsDevtoolsAction {\n type: string;\n payload: any;\n state: any;\n id: number;\n source: string;\n}\n\nexport interface NgxsDevtoolsOptions {\n /**\n * The name of the extension\n */\n name?: string;\n\n /**\n * Whether the dev tools is enabled or note. Useful for setting during production.\n */\n disabled?: boolean;\n\n /**\n * Max number of entiries to keep.\n */\n maxAge?: number;\n\n /**\n * If more than one action is dispatched in the indicated interval, all new actions will be collected\n * and sent at once. It is the joint between performance and speed. When set to 0, all actions will be\n * sent instantly. Set it to a higher value when experiencing perf issues (also maxAge to a lower value).\n * Default is 500 ms.\n */\n latency?: number;\n\n /**\n * string or array of strings as regex - actions types to be hidden in the monitors (while passed to the reducers).\n * If actionsWhitelist specified, actionsBlacklist is ignored.\n */\n actionsBlacklist?: string | string[];\n\n /**\n * string or array of strings as regex - actions types to be shown in the monitors (while passed to the reducers).\n * If actionsWhitelist specified, actionsBlacklist is ignored.\n */\n actionsWhitelist?: string | string[];\n\n /**\n * called for every action before sending, takes state and action object, and returns true in case it allows\n * sending the current data to the monitor. Use it as a more advanced version of\n * actionsBlacklist/actionsWhitelist parameters\n */\n predicate?: (state: any, action: any) => boolean;\n\n /**\n * Reformat actions before sending to dev tools\n */\n actionSanitizer?: (action: any) => void;\n\n /**\n * Reformat state before sending to devtools\n */\n stateSanitizer?: (state: any) => void;\n\n /**\n * If set to true, will include stack trace for every dispatched action\n */\n trace?: boolean | (() => string);\n\n /**\n * Maximum stack trace frames to be stored (in case trace option was provided as true)\n */\n traceLimit?: number;\n}\n\nexport const NGXS_DEVTOOLS_OPTIONS = new InjectionToken('NGXS_DEVTOOLS_OPTIONS');\n","import { Inject, Injectable, Injector, NgZone, OnDestroy, ɵglobal } from '@angular/core';\nimport { getActionTypeFromInstance, NgxsNextPluginFn, NgxsPlugin, Store } from '@ngxs/store';\nimport { tap, catchError } from 'rxjs/operators';\n\nimport {\n NGXS_DEVTOOLS_OPTIONS,\n NgxsDevtoolsAction,\n NgxsDevtoolsExtension,\n NgxsDevtoolsOptions\n} from './symbols';\n\nconst enum ReduxDevtoolsActionType {\n Dispatch = 'DISPATCH',\n Action = 'ACTION'\n}\n\nconst enum ReduxDevtoolsPayloadType {\n JumpToAction = 'JUMP_TO_ACTION',\n JumpToState = 'JUMP_TO_STATE',\n ToggleAction = 'TOGGLE_ACTION',\n ImportState = 'IMPORT_STATE'\n}\n\n/**\n * Adds support for the Redux Devtools extension:\n * http://extension.remotedev.io/\n */\n@Injectable()\nexport class NgxsReduxDevtoolsPlugin implements OnDestroy, NgxsPlugin {\n private devtoolsExtension: NgxsDevtoolsExtension | null = null;\n private readonly globalDevtools =\n ɵglobal['__REDUX_DEVTOOLS_EXTENSION__'] || ɵglobal['devToolsExtension'];\n\n private unsubscribe: VoidFunction | null = null;\n\n constructor(\n @Inject(NGXS_DEVTOOLS_OPTIONS) private _options: NgxsDevtoolsOptions,\n private _injector: Injector,\n private _ngZone: NgZone\n ) {\n this.connect();\n }\n\n ngOnDestroy(): void {\n if (this.unsubscribe !== null) {\n this.unsubscribe();\n }\n if (this.globalDevtools) {\n this.globalDevtools.disconnect();\n }\n }\n\n /**\n * Lazy get the store for circular dependency issues\n */\n private get store(): Store {\n return this._injector.get<Store>(Store);\n }\n\n /**\n * Middleware handle function\n */\n handle(state: any, action: any, next: NgxsNextPluginFn) {\n if (!this.devtoolsExtension || this._options.disabled) {\n return next(state, action);\n }\n\n return next(state, action).pipe(\n catchError(error => {\n const newState = this.store.snapshot();\n this.sendToDevTools(state, action, newState);\n throw error;\n }),\n tap(newState => {\n this.sendToDevTools(state, action, newState);\n })\n );\n }\n\n private sendToDevTools(state: any, action: any, newState: any) {\n const type = getActionTypeFromInstance(action);\n // if init action, send initial state to dev tools\n const isInitAction = type === '@@INIT';\n if (isInitAction) {\n this.devtoolsExtension!.init(state);\n } else {\n this.devtoolsExtension!.send({ ...action, action: null, type }, newState);\n }\n }\n\n /**\n * Handle the action from the dev tools subscription\n */\n dispatched(action: NgxsDevtoolsAction) {\n if (action.type === ReduxDevtoolsActionType.Dispatch) {\n if (\n action.payload.type === ReduxDevtoolsPayloadType.JumpToAction ||\n action.payload.type === ReduxDevtoolsPayloadType.JumpToState\n ) {\n const prevState = JSON.parse(action.state);\n // This makes the DevTools and Router plugins friends with each other.\n // We're checking for the `router` state to exist, and it also should\n // have the `trigger` property, so we're sure that this is our router\n // state (coming from `@ngxs/router-plugin`). This enables a time-traveling\n // feature since it doesn't only restore the state but also allows the `RouterState`\n // to navigate back when the action is jumped.\n if (prevState.router && prevState.router.trigger) {\n prevState.router.trigger = 'devtools';\n }\n this.store.reset(prevState);\n } else if (action.payload.type === ReduxDevtoolsPayloadType.ToggleAction) {\n console.warn('Skip is not supported at this time.');\n } else if (action.payload.type === ReduxDevtoolsPayloadType.ImportState) {\n const {\n actionsById,\n computedStates,\n currentStateIndex\n } = action.payload.nextLiftedState;\n this.devtoolsExtension!.init(computedStates[0].state);\n Object.keys(actionsById)\n .filter(actionId => actionId !== '0')\n .forEach(actionId =>\n this.devtoolsExtension!.send(actionsById[actionId], computedStates[actionId].state)\n );\n this.store.reset(computedStates[currentStateIndex].state);\n }\n } else if (action.type === ReduxDevtoolsActionType.Action) {\n const actionPayload = JSON.parse(action.payload);\n this.store.dispatch(actionPayload);\n }\n }\n\n private connect(): void {\n if (!this.globalDevtools || this._options.disabled) {\n return;\n }\n\n // The `connect` method adds `message` event listener since it communicates\n // with an extension through `window.postMessage` and message events.\n // We handle only 2 events; thus, we don't want to run many change detections\n // because the extension sends events that we don't have to handle.\n this.devtoolsExtension = this._ngZone.runOutsideAngular(\n () => <NgxsDevtoolsExtension>this.globalDevtools.connect(this._options)\n );\n\n this.unsubscribe = this.devtoolsExtension.subscribe(action => {\n if (\n action.type === ReduxDevtoolsActionType.Dispatch ||\n action.type === ReduxDevtoolsActionType.Action\n ) {\n this._ngZone.run(() => {\n this.dispatched(action);\n });\n }\n });\n }\n}\n","import { NgModule, ModuleWithProviders, InjectionToken } from '@angular/core';\nimport { NGXS_PLUGINS } from '@ngxs/store';\n\nimport { NgxsDevtoolsOptions, NGXS_DEVTOOLS_OPTIONS } from './symbols';\nimport { NgxsReduxDevtoolsPlugin } from './devtools.plugin';\n\nexport function devtoolsOptionsFactory(options: NgxsDevtoolsOptions) {\n return {\n name: 'NGXS',\n ...options\n };\n}\n\nexport const USER_OPTIONS = new InjectionToken('USER_OPTIONS');\n\n@NgModule()\nexport class NgxsReduxDevtoolsPluginModule {\n static forRoot(\n options?: NgxsDevtoolsOptions\n ): ModuleWithProviders<NgxsReduxDevtoolsPluginModule> {\n return {\n ngModule: NgxsReduxDevtoolsPluginModule,\n providers: [\n {\n provide: NGXS_PLUGINS,\n useClass: NgxsReduxDevtoolsPlugin,\n multi: true\n },\n {\n provide: USER_OPTIONS,\n useValue: options\n },\n {\n provide: NGXS_DEVTOOLS_OPTIONS,\n useFactory: devtoolsOptionsFactory,\n deps: [USER_OPTIONS]\n }\n ]\n };\n }\n}\n","/**\n * The public api for consumers of @ngxs/devtools-plugin\n */\nexport * from './src/public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MAmFa,qBAAqB,GAAG,IAAI,cAAc,CAAC,uBAAuB;;AC5D/E;;;AAGG;MAEU,uBAAuB,CAAA;AAOlC,IAA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E,IAAI;AACZ,iBAAA;AACD,gBAAA;AACE,oBAAA,OAAO,EAAE,YAAY;AACrB,oBAAA,QAAQ,EAAE,OAAO;AAClB,iBAAA;AACD,gBAAA;AACE,oBAAA,OAAO,EAAE,qBAAqB;AAC9B,oBAAA,UAAU,EAAE,sBAAsB;oBAClC,IAAI,EAAE,CAAC,YAAY,CAAC;AACrB,iBAAA;AACF,aAAA;SACF,CAAC;KACH;;8IAvBU,6BAA6B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;+IAA7B,6BAA6B,EAAA,CAAA,CAAA;+IAA7B,6BAA6B,EAAA,CAAA,CAAA;4FAA7B,6BAA6B,EAAA,UAAA,EAAA,CAAA;kBADzC,QAAQ;;;ACfT;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "../../node_modules/ng-packagr/package.schema.json",
|
|
3
3
|
"name": "@ngxs/devtools-plugin",
|
|
4
4
|
"description": "redux devtools plugin for @ngxs/store",
|
|
5
|
-
"version": "3.7.6-dev.master-
|
|
5
|
+
"version": "3.7.6-dev.master-5bdcd2a",
|
|
6
6
|
"sideEffects": true,
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"@angular/core": ">=6.1.0 <16.0.0",
|
package/src/devtools.module.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export declare function devtoolsOptionsFactory(options: NgxsDevtoolsOptions): {
|
|
|
11
11
|
predicate?: ((state: any, action: any) => boolean) | undefined;
|
|
12
12
|
actionSanitizer?: ((action: any) => void) | undefined;
|
|
13
13
|
stateSanitizer?: ((state: any) => void) | undefined;
|
|
14
|
+
trace?: boolean | (() => string) | undefined;
|
|
15
|
+
traceLimit?: number | undefined;
|
|
14
16
|
};
|
|
15
17
|
export declare const USER_OPTIONS: InjectionToken<unknown>;
|
|
16
18
|
export declare class NgxsReduxDevtoolsPluginModule {
|
package/src/symbols.d.ts
CHANGED
|
@@ -58,5 +58,13 @@ export interface NgxsDevtoolsOptions {
|
|
|
58
58
|
* Reformat state before sending to devtools
|
|
59
59
|
*/
|
|
60
60
|
stateSanitizer?: (state: any) => void;
|
|
61
|
+
/**
|
|
62
|
+
* If set to true, will include stack trace for every dispatched action
|
|
63
|
+
*/
|
|
64
|
+
trace?: boolean | (() => string);
|
|
65
|
+
/**
|
|
66
|
+
* Maximum stack trace frames to be stored (in case trace option was provided as true)
|
|
67
|
+
*/
|
|
68
|
+
traceLimit?: number;
|
|
61
69
|
}
|
|
62
70
|
export declare const NGXS_DEVTOOLS_OPTIONS: InjectionToken<unknown>;
|