@ngxs/router-plugin 3.7.3 → 3.7.4

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-router-plugin.js","sources":["ng://@ngxs/router-plugin/src/router.actions.ts","ng://@ngxs/router-plugin/src/serializer.ts","ng://@ngxs/router-plugin/src/router.state.ts","ng://@ngxs/router-plugin/src/router.module.ts"],"sourcesContent":["import {\r\n NavigationCancel,\r\n NavigationError,\r\n NavigationExtras,\r\n Params,\r\n RouterStateSnapshot,\r\n RoutesRecognized,\r\n ResolveEnd\r\n} from '@angular/router';\r\n\r\nimport { RouterTrigger } from './router.state';\r\n\r\n/**\r\n * Public event api of the router\r\n */\r\nexport class Navigate {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] Navigate';\r\n }\r\n constructor(\r\n public path: any[],\r\n public queryParams?: Params,\r\n public extras?: NavigationExtras\r\n ) {}\r\n}\r\n\r\n/**\r\n *\r\n * Angular Routers internal state events\r\n *\r\n */\r\n\r\n/**\r\n * An action dispatched when the router navigates.\r\n */\r\nexport class RouterNavigation<T = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterNavigation';\r\n }\r\n constructor(\r\n public routerState: T,\r\n public event: RoutesRecognized,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An action dispatched when the router cancel navigation.\r\n */\r\nexport class RouterCancel<T, V = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterCancel';\r\n }\r\n constructor(\r\n public routerState: V,\r\n public storeState: T,\r\n public event: NavigationCancel,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An action dispatched when the router errors.\r\n */\r\nexport class RouterError<T, V = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterError';\r\n }\r\n constructor(\r\n public routerState: V,\r\n public storeState: T,\r\n public event: NavigationError,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An action dispatched when the `ResolveEnd` event is triggered.\r\n */\r\nexport class RouterDataResolved<T = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterDataResolved';\r\n }\r\n constructor(\r\n public routerState: T,\r\n public event: ResolveEnd,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An union type of router actions.\r\n */\r\nexport type RouterAction<T, V = RouterStateSnapshot> =\r\n | RouterNavigation<V>\r\n | RouterCancel<T, V>\r\n | RouterError<T, V>\r\n | RouterDataResolved<V>;\r\n","import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\r\n\r\nexport abstract class RouterStateSerializer<T> {\r\n abstract serialize(routerState: RouterStateSnapshot): T;\r\n}\r\n\r\nexport interface SerializedRouterStateSnapshot {\r\n root: ActivatedRouteSnapshot;\r\n url: string;\r\n}\r\n\r\nexport class DefaultRouterStateSerializer\r\n implements RouterStateSerializer<SerializedRouterStateSnapshot> {\r\n serialize(routerState: RouterStateSnapshot): SerializedRouterStateSnapshot {\r\n return {\r\n root: this.serializeRoute(routerState.root),\r\n url: routerState.url\r\n };\r\n }\r\n\r\n private serializeRoute(route: ActivatedRouteSnapshot): ActivatedRouteSnapshot {\r\n const children = route.children.map(c => this.serializeRoute(c));\r\n return {\r\n url: route.url,\r\n params: route.params,\r\n queryParams: route.queryParams,\r\n fragment: route.fragment,\r\n data: route.data,\r\n outlet: route.outlet,\r\n component: null,\r\n routeConfig: null,\r\n root: null as any,\r\n parent: null,\r\n firstChild: children[0],\r\n children: children,\r\n pathFromRoot: null as any,\r\n paramMap: route.paramMap,\r\n queryParamMap: route.queryParamMap,\r\n toString: route.toString\r\n };\r\n }\r\n}\r\n","import { NgZone, Injectable } from '@angular/core';\r\nimport {\r\n NavigationCancel,\r\n NavigationError,\r\n Router,\r\n RouterStateSnapshot,\r\n RoutesRecognized,\r\n ResolveEnd,\r\n UrlSerializer,\r\n NavigationStart,\r\n NavigationEnd\r\n} from '@angular/router';\r\nimport { LocationStrategy, Location } from '@angular/common';\r\nimport { Action, Selector, State, StateContext, Store } from '@ngxs/store';\r\nimport { isAngularInTestMode } from '@ngxs/store/internals';\r\nimport { first } from 'rxjs/operators';\r\n\r\nimport {\r\n Navigate,\r\n RouterAction,\r\n RouterCancel,\r\n RouterError,\r\n RouterNavigation,\r\n RouterDataResolved\r\n} from './router.actions';\r\nimport { RouterStateSerializer } from './serializer';\r\n\r\nexport interface RouterStateModel<T = RouterStateSnapshot> {\r\n state?: T;\r\n navigationId?: number;\r\n trigger: RouterTrigger;\r\n}\r\n\r\nexport type RouterTrigger = 'none' | 'router' | 'store';\r\n\r\n@State<RouterStateModel>({\r\n name: 'router',\r\n defaults: {\r\n state: undefined,\r\n navigationId: undefined,\r\n trigger: 'none'\r\n }\r\n})\r\n@Injectable()\r\nexport class RouterState {\r\n /**\r\n * Determines how navigation was performed by the `RouterState` itself\r\n * or outside via `new Navigate(...)`\r\n */\r\n private _trigger: RouterTrigger = 'none';\r\n\r\n /**\r\n * That's the serialized state from the `Router` class\r\n */\r\n private _routerState: RouterStateSnapshot | null = null;\r\n\r\n /**\r\n * That's the value of the `RouterState` state\r\n */\r\n private _storeState: RouterStateModel | null = null;\r\n\r\n private _lastRoutesRecognized: RoutesRecognized = null!;\r\n\r\n @Selector()\r\n static state<T = RouterStateSnapshot>(state: RouterStateModel<T>) {\r\n return state && state.state;\r\n }\r\n\r\n @Selector()\r\n static url(state: RouterStateModel): string | undefined {\r\n return state && state.state && state.state.url;\r\n }\r\n\r\n constructor(\r\n private _store: Store,\r\n private _router: Router,\r\n private _serializer: RouterStateSerializer<RouterStateSnapshot>,\r\n private _ngZone: NgZone,\r\n private _urlSerializer: UrlSerializer,\r\n private _locationStrategy: LocationStrategy,\r\n private _location: Location\r\n ) {\r\n this.setUpStoreListener();\r\n this.setUpRouterEventsListener();\r\n this.checkInitialNavigationOnce();\r\n }\r\n\r\n @Action(Navigate)\r\n navigate(_: StateContext<RouterStateModel>, action: Navigate) {\r\n return this._ngZone.run(() =>\r\n this._router.navigate(action.path, {\r\n queryParams: action.queryParams,\r\n ...action.extras\r\n })\r\n );\r\n }\r\n\r\n @Action([RouterNavigation, RouterError, RouterCancel, RouterDataResolved])\r\n angularRouterAction(\r\n ctx: StateContext<RouterStateModel>,\r\n action: RouterAction<RouterStateModel, RouterStateSnapshot>\r\n ): void {\r\n ctx.setState({\r\n ...ctx.getState(),\r\n trigger: action.trigger,\r\n state: action.routerState,\r\n navigationId: action.event.id\r\n });\r\n }\r\n\r\n private setUpStoreListener(): void {\r\n this._store.select(RouterState).subscribe((state: RouterStateModel | undefined) => {\r\n this.navigateIfNeeded(state);\r\n });\r\n }\r\n\r\n private setUpRouterEventsListener(): void {\r\n this._router.events.subscribe(event => {\r\n if (event instanceof NavigationStart) {\r\n this.navigationStart();\r\n } else if (event instanceof RoutesRecognized) {\r\n this._lastRoutesRecognized = event;\r\n } else if (event instanceof ResolveEnd) {\r\n this.dispatchRouterDataResolved(event);\r\n } else if (event instanceof NavigationCancel) {\r\n this.dispatchRouterCancel(event);\r\n this.reset();\r\n } else if (event instanceof NavigationError) {\r\n this.dispatchRouterError(event);\r\n this.reset();\r\n } else if (event instanceof NavigationEnd) {\r\n this.navigationEnd();\r\n this.reset();\r\n }\r\n });\r\n }\r\n\r\n private navigationStart(): void {\r\n this._routerState = this._serializer.serialize(this._router.routerState.snapshot);\r\n\r\n if (this._trigger !== 'none') {\r\n this._storeState = this._store.selectSnapshot(RouterState);\r\n }\r\n }\r\n\r\n private navigationEnd(): void {\r\n if (this.shouldDispatchRouterNavigation()) {\r\n this.dispatchRouterNavigation();\r\n }\r\n }\r\n\r\n private shouldDispatchRouterNavigation(): boolean {\r\n if (!this._storeState) return true;\r\n return this._trigger !== 'store';\r\n }\r\n\r\n private navigateIfNeeded(state: RouterStateModel | undefined): void {\r\n const canSkipNavigation =\r\n !this._storeState ||\r\n !this._storeState.state ||\r\n !state ||\r\n state.trigger === 'router' ||\r\n this._router.url === this._storeState.state.url;\r\n\r\n if (canSkipNavigation) {\r\n return;\r\n }\r\n\r\n this._trigger = 'store';\r\n this._ngZone.run(() => {\r\n this._router.navigateByUrl(this._storeState!.state!.url);\r\n });\r\n }\r\n\r\n private dispatchRouterNavigation(): void {\r\n const nextRouterState = this._serializer.serialize(this._lastRoutesRecognized.state);\r\n\r\n this.dispatchRouterAction(\r\n new RouterNavigation(\r\n nextRouterState,\r\n new RoutesRecognized(\r\n this._lastRoutesRecognized.id,\r\n this._lastRoutesRecognized.url,\r\n this._lastRoutesRecognized.urlAfterRedirects,\r\n nextRouterState\r\n ),\r\n this._trigger\r\n )\r\n );\r\n }\r\n\r\n private dispatchRouterCancel(event: NavigationCancel): void {\r\n this.dispatchRouterAction(\r\n new RouterCancel(this._routerState!, this._storeState, event, this._trigger)\r\n );\r\n }\r\n\r\n private dispatchRouterError(event: NavigationError): void {\r\n this.dispatchRouterAction(\r\n new RouterError(\r\n this._routerState!,\r\n this._storeState,\r\n new NavigationError(event.id, event.url, `${event}`),\r\n this._trigger\r\n )\r\n );\r\n }\r\n\r\n private dispatchRouterAction<T>(action: RouterAction<T>): void {\r\n this._trigger = 'router';\r\n\r\n try {\r\n this._store.dispatch(action);\r\n } finally {\r\n this._trigger = 'none';\r\n }\r\n }\r\n\r\n private dispatchRouterDataResolved(event: ResolveEnd): void {\r\n const routerState = this._serializer.serialize(event.state);\r\n this.dispatchRouterAction(new RouterDataResolved(routerState, event, this._trigger));\r\n }\r\n\r\n private reset(): void {\r\n this._trigger = 'none';\r\n this._storeState = null;\r\n this._routerState = null;\r\n }\r\n\r\n /**\r\n * No sense to mess up the `setUpRouterEventsListener` method as we have\r\n * to perform this check only once and unsubscribe after the first event\r\n * is triggered\r\n */\r\n private checkInitialNavigationOnce(): void {\r\n if (isAngularInTestMode()) {\r\n return;\r\n }\r\n\r\n this._router.events\r\n .pipe(first((event): event is RoutesRecognized => event instanceof RoutesRecognized))\r\n .subscribe(({ url }) => {\r\n // `location.pathname` always equals manually entered URL in the address bar\r\n // e.g. `location.pathname === '/foo'`, but the `router` state has been initialized\r\n // with another URL (e.g. used in combination with `NgxsStoragePlugin`), thus the\r\n // `RouterNavigation` action will be dispatched and the user will be redirected to the\r\n // previously saved URL. We want to prevent such behavior, so we perform this check\r\n\r\n // `url` is a recognized URL by the Angular's router, while `currentUrl` is an actual URL\r\n // entered in the browser's address bar\r\n // `PathLocationStrategy.prototype.path()` returns a concatenation of\r\n // `PlatformLocation.pathname` and normalized `PlatformLocation.search`.\r\n\r\n // `Location.prototype.normalize` strips base href from the URL,\r\n // if `baseHref` (declared in angular.json) for example is `/en`\r\n // and the URL is `/test#anchor` - then `_locationStrategy.path(true)` will return `/en/test#anchor`,\r\n // but `/en/test#anchor` is not known to the Angular's router, so we have to strip `/en`\r\n // from the URL\r\n const currentUrl = this._location.normalize(this._locationStrategy.path(true));\r\n const currentUrlTree = this._urlSerializer.parse(currentUrl);\r\n // We need to serialize the URL because in that example `/test/?redirect=https://google.com/`\r\n // Angular will recognize it as `/test?redirect=https:%2F%2Fwww.google.com%2F`\r\n // so we have to run the `currentUrl` via the `UrlSerializer` that will encode characters\r\n const currentSerializedUrl = this._urlSerializer.serialize(currentUrlTree);\r\n\r\n // If URLs differ from each other - we've got to perform a redirect to the manually entered URL\r\n // in the address bar, as it must have a priority\r\n if (currentSerializedUrl !== url) {\r\n this._router.navigateByUrl(currentUrl);\r\n }\r\n });\r\n }\r\n}\r\n","import { ModuleWithProviders, NgModule } from '@angular/core';\r\nimport { NgxsModule } from '@ngxs/store';\r\n\r\nimport { RouterState } from './router.state';\r\nimport { DefaultRouterStateSerializer, RouterStateSerializer } from './serializer';\r\n\r\n@NgModule({\r\n imports: [NgxsModule.forFeature([RouterState])]\r\n})\r\nexport class NgxsRouterPluginModule {\r\n static forRoot(): ModuleWithProviders<NgxsRouterPluginModule> {\r\n return {\r\n ngModule: NgxsRouterPluginModule,\r\n providers: [{ provide: RouterStateSerializer, useClass: DefaultRouterStateSerializer }]\r\n };\r\n }\r\n}\r\n"],"names":["tslib_1.__decorate"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,QAAQ;;;;;;IAKnB,YACS,IAAW,EACX,WAAoB,EACpB,MAAyB;QAFzB,SAAI,GAAJ,IAAI,CAAO;QACX,gBAAW,GAAX,WAAW,CAAS;QACpB,WAAM,GAAN,MAAM,CAAmB;KAC9B;;;;IARJ,WAAW,IAAI;;QAEb,OAAO,mBAAmB,CAAC;KAC5B;CAMF;;;IAJG,wBAAkB;;IAClB,+BAA2B;;IAC3B,0BAAgC;;;;;;;;;;;AAapC,MAAa,gBAAgB;;;;;;IAK3B,YACS,WAAc,EACd,KAAuB,EACvB,UAAyB,MAAM;QAF/B,gBAAW,GAAX,WAAW,CAAG;QACd,UAAK,GAAL,KAAK,CAAkB;QACvB,YAAO,GAAP,OAAO,CAAwB;KACpC;;;;IARJ,WAAW,IAAI;;QAEb,OAAO,2BAA2B,CAAC;KACpC;CAMF;;;IAJG,uCAAqB;;IACrB,iCAA8B;;IAC9B,mCAAsC;;;;;;AAO1C,MAAa,YAAY;;;;;;;IAKvB,YACS,WAAc,EACd,UAAa,EACb,KAAuB,EACvB,UAAyB,MAAM;QAH/B,gBAAW,GAAX,WAAW,CAAG;QACd,eAAU,GAAV,UAAU,CAAG;QACb,UAAK,GAAL,KAAK,CAAkB;QACvB,YAAO,GAAP,OAAO,CAAwB;KACpC;;;;IAT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ts","ng://@ngxs/router-plugin/src/serializer.ts","ng://@ngxs/router-plugin/src/router.state.ts","ng://@ngxs/router-plugin/src/router.module.ts"],"sourcesContent":["import {\r\n NavigationCancel,\r\n NavigationError,\r\n NavigationExtras,\r\n Params,\r\n RouterStateSnapshot,\r\n RoutesRecognized,\r\n ResolveEnd\r\n} from '@angular/router';\r\n\r\nimport { RouterTrigger } from './router.state';\r\n\r\n/**\r\n * Public event api of the router\r\n */\r\nexport class Navigate {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] Navigate';\r\n }\r\n constructor(\r\n public path: any[],\r\n public queryParams?: Params,\r\n public extras?: NavigationExtras\r\n ) {}\r\n}\r\n\r\n/**\r\n *\r\n * Angular Routers internal state events\r\n *\r\n */\r\n\r\n/**\r\n * An action dispatched when the router navigates.\r\n */\r\nexport class RouterNavigation<T = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterNavigation';\r\n }\r\n constructor(\r\n public routerState: T,\r\n public event: RoutesRecognized,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An action dispatched when the router cancel navigation.\r\n */\r\nexport class RouterCancel<T, V = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterCancel';\r\n }\r\n constructor(\r\n public routerState: V,\r\n public storeState: T,\r\n public event: NavigationCancel,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An action dispatched when the router errors.\r\n */\r\nexport class RouterError<T, V = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterError';\r\n }\r\n constructor(\r\n public routerState: V,\r\n public storeState: T,\r\n public event: NavigationError,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An action dispatched when the `ResolveEnd` event is triggered.\r\n */\r\nexport class RouterDataResolved<T = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterDataResolved';\r\n }\r\n constructor(\r\n public routerState: T,\r\n public event: ResolveEnd,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An union type of router actions.\r\n */\r\nexport type RouterAction<T, V = RouterStateSnapshot> =\r\n | RouterNavigation<V>\r\n | RouterCancel<T, V>\r\n | RouterError<T, V>\r\n | RouterDataResolved<V>;\r\n","import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\r\n\r\nexport abstract class RouterStateSerializer<T> {\r\n abstract serialize(routerState: RouterStateSnapshot): T;\r\n}\r\n\r\nexport interface SerializedRouterStateSnapshot {\r\n root: ActivatedRouteSnapshot;\r\n url: string;\r\n}\r\n\r\nexport class DefaultRouterStateSerializer\r\n implements RouterStateSerializer<SerializedRouterStateSnapshot> {\r\n serialize(routerState: RouterStateSnapshot): SerializedRouterStateSnapshot {\r\n return {\r\n root: this.serializeRoute(routerState.root),\r\n url: routerState.url\r\n };\r\n }\r\n\r\n private serializeRoute(route: ActivatedRouteSnapshot): ActivatedRouteSnapshot {\r\n const children = route.children.map(c => this.serializeRoute(c));\r\n return {\r\n url: route.url,\r\n params: route.params,\r\n queryParams: route.queryParams,\r\n fragment: route.fragment,\r\n data: route.data,\r\n outlet: route.outlet,\r\n component: null,\r\n routeConfig: null,\r\n root: null as any,\r\n parent: null,\r\n firstChild: children[0],\r\n children: children,\r\n pathFromRoot: null as any,\r\n paramMap: route.paramMap,\r\n queryParamMap: route.queryParamMap,\r\n toString: route.toString\r\n };\r\n }\r\n}\r\n","import { NgZone, Injectable, OnDestroy } from '@angular/core';\r\nimport {\r\n NavigationCancel,\r\n NavigationError,\r\n Router,\r\n RouterStateSnapshot,\r\n RoutesRecognized,\r\n ResolveEnd,\r\n UrlSerializer,\r\n NavigationStart,\r\n NavigationEnd\r\n} from '@angular/router';\r\nimport { LocationStrategy, Location } from '@angular/common';\r\nimport { Action, Selector, State, StateContext, Store } from '@ngxs/store';\r\nimport { isAngularInTestMode } from '@ngxs/store/internals';\r\nimport { Subscription } from 'rxjs';\r\nimport { first } from 'rxjs/operators';\r\n\r\nimport {\r\n Navigate,\r\n RouterAction,\r\n RouterCancel,\r\n RouterError,\r\n RouterNavigation,\r\n RouterDataResolved\r\n} from './router.actions';\r\nimport { RouterStateSerializer } from './serializer';\r\n\r\nexport interface RouterStateModel<T = RouterStateSnapshot> {\r\n state?: T;\r\n navigationId?: number;\r\n trigger: RouterTrigger;\r\n}\r\n\r\nexport type RouterTrigger = 'none' | 'router' | 'store';\r\n\r\n/**\r\n * @description Will be provided through Terser global definitions by Angular CLI\r\n * during the production build. This is how Angular does tree-shaking internally.\r\n */\r\ndeclare const ngDevMode: boolean;\r\n\r\n@State<RouterStateModel>({\r\n name: 'router',\r\n defaults: {\r\n state: undefined,\r\n navigationId: undefined,\r\n trigger: 'none'\r\n }\r\n})\r\n@Injectable()\r\nexport class RouterState implements OnDestroy {\r\n /**\r\n * Determines how navigation was performed by the `RouterState` itself\r\n * or outside via `new Navigate(...)`\r\n */\r\n private _trigger: RouterTrigger = 'none';\r\n\r\n /**\r\n * That's the serialized state from the `Router` class\r\n */\r\n private _routerState: RouterStateSnapshot | null = null;\r\n\r\n /**\r\n * That's the value of the `RouterState` state\r\n */\r\n private _storeState: RouterStateModel | null = null;\r\n\r\n private _lastRoutesRecognized: RoutesRecognized = null!;\r\n\r\n private _subscription = new Subscription();\r\n\r\n @Selector()\r\n static state<T = RouterStateSnapshot>(state: RouterStateModel<T>) {\r\n return state && state.state;\r\n }\r\n\r\n @Selector()\r\n static url(state: RouterStateModel): string | undefined {\r\n return state && state.state && state.state.url;\r\n }\r\n\r\n constructor(\r\n private _store: Store,\r\n private _router: Router,\r\n private _serializer: RouterStateSerializer<RouterStateSnapshot>,\r\n private _ngZone: NgZone,\r\n private _urlSerializer: UrlSerializer,\r\n private _locationStrategy: LocationStrategy,\r\n private _location: Location\r\n ) {\r\n this.setUpStoreListener();\r\n this.setUpRouterEventsListener();\r\n this.checkInitialNavigationOnce();\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this._subscription.unsubscribe();\r\n }\r\n\r\n @Action(Navigate)\r\n navigate(_: StateContext<RouterStateModel>, action: Navigate) {\r\n return this._ngZone.run(() =>\r\n this._router.navigate(action.path, {\r\n queryParams: action.queryParams,\r\n ...action.extras\r\n })\r\n );\r\n }\r\n\r\n @Action([RouterNavigation, RouterError, RouterCancel, RouterDataResolved])\r\n angularRouterAction(\r\n ctx: StateContext<RouterStateModel>,\r\n action: RouterAction<RouterStateModel, RouterStateSnapshot>\r\n ): void {\r\n ctx.setState({\r\n ...ctx.getState(),\r\n trigger: action.trigger,\r\n state: action.routerState,\r\n navigationId: action.event.id\r\n });\r\n }\r\n\r\n private setUpStoreListener(): void {\r\n const subscription = this._store\r\n .select(RouterState)\r\n .subscribe((state: RouterStateModel | undefined) => {\r\n this.navigateIfNeeded(state);\r\n });\r\n\r\n this._subscription.add(subscription);\r\n }\r\n\r\n private setUpRouterEventsListener(): void {\r\n const subscription = this._router.events.subscribe(event => {\r\n if (event instanceof NavigationStart) {\r\n this.navigationStart();\r\n } else if (event instanceof RoutesRecognized) {\r\n this._lastRoutesRecognized = event;\r\n } else if (event instanceof ResolveEnd) {\r\n this.dispatchRouterDataResolved(event);\r\n } else if (event instanceof NavigationCancel) {\r\n this.dispatchRouterCancel(event);\r\n this.reset();\r\n } else if (event instanceof NavigationError) {\r\n this.dispatchRouterError(event);\r\n this.reset();\r\n } else if (event instanceof NavigationEnd) {\r\n this.navigationEnd();\r\n this.reset();\r\n }\r\n });\r\n\r\n this._subscription.add(subscription);\r\n }\r\n\r\n private navigationStart(): void {\r\n this._routerState = this._serializer.serialize(this._router.routerState.snapshot);\r\n\r\n if (this._trigger !== 'none') {\r\n this._storeState = this._store.selectSnapshot(RouterState);\r\n }\r\n }\r\n\r\n private navigationEnd(): void {\r\n if (this.shouldDispatchRouterNavigation()) {\r\n this.dispatchRouterNavigation();\r\n }\r\n }\r\n\r\n private shouldDispatchRouterNavigation(): boolean {\r\n if (!this._storeState) return true;\r\n return this._trigger !== 'store';\r\n }\r\n\r\n private navigateIfNeeded(state: RouterStateModel | undefined): void {\r\n const canSkipNavigation =\r\n !this._storeState ||\r\n !this._storeState.state ||\r\n !state ||\r\n state.trigger === 'router' ||\r\n this._router.url === this._storeState.state.url;\r\n\r\n if (canSkipNavigation) {\r\n return;\r\n }\r\n\r\n this._trigger = 'store';\r\n this._ngZone.run(() => {\r\n this._router.navigateByUrl(this._storeState!.state!.url);\r\n });\r\n }\r\n\r\n private dispatchRouterNavigation(): void {\r\n const nextRouterState = this._serializer.serialize(this._lastRoutesRecognized.state);\r\n\r\n this.dispatchRouterAction(\r\n new RouterNavigation(\r\n nextRouterState,\r\n new RoutesRecognized(\r\n this._lastRoutesRecognized.id,\r\n this._lastRoutesRecognized.url,\r\n this._lastRoutesRecognized.urlAfterRedirects,\r\n nextRouterState\r\n ),\r\n this._trigger\r\n )\r\n );\r\n }\r\n\r\n private dispatchRouterCancel(event: NavigationCancel): void {\r\n this.dispatchRouterAction(\r\n new RouterCancel(this._routerState!, this._storeState, event, this._trigger)\r\n );\r\n }\r\n\r\n private dispatchRouterError(event: NavigationError): void {\r\n this.dispatchRouterAction(\r\n new RouterError(\r\n this._routerState!,\r\n this._storeState,\r\n new NavigationError(event.id, event.url, `${event}`),\r\n this._trigger\r\n )\r\n );\r\n }\r\n\r\n private dispatchRouterAction<T>(action: RouterAction<T>): void {\r\n this._trigger = 'router';\r\n\r\n try {\r\n this._store.dispatch(action);\r\n } finally {\r\n this._trigger = 'none';\r\n }\r\n }\r\n\r\n private dispatchRouterDataResolved(event: ResolveEnd): void {\r\n const routerState = this._serializer.serialize(event.state);\r\n this.dispatchRouterAction(new RouterDataResolved(routerState, event, this._trigger));\r\n }\r\n\r\n private reset(): void {\r\n this._trigger = 'none';\r\n this._storeState = null;\r\n this._routerState = null;\r\n }\r\n\r\n /**\r\n * No sense to mess up the `setUpRouterEventsListener` method as we have\r\n * to perform this check only once and unsubscribe after the first event\r\n * is triggered\r\n */\r\n private checkInitialNavigationOnce(): void {\r\n // Caretaker note: we have still left the `typeof` condition in order to avoid\r\n // creating a breaking change for projects that still use the View Engine.\r\n if (\r\n (typeof ngDevMode === 'undefined' || ngDevMode) &&\r\n // Angular is running tests in development mode thus we can be sure that this method will be\r\n // skipped in tests.\r\n isAngularInTestMode()\r\n ) {\r\n return;\r\n }\r\n\r\n const subscription = this._router.events\r\n .pipe(first((event): event is RoutesRecognized => event instanceof RoutesRecognized))\r\n .subscribe(({ url }) => {\r\n // `location.pathname` always equals manually entered URL in the address bar\r\n // e.g. `location.pathname === '/foo'`, but the `router` state has been initialized\r\n // with another URL (e.g. used in combination with `NgxsStoragePlugin`), thus the\r\n // `RouterNavigation` action will be dispatched and the user will be redirected to the\r\n // previously saved URL. We want to prevent such behavior, so we perform this check\r\n\r\n // `url` is a recognized URL by the Angular's router, while `currentUrl` is an actual URL\r\n // entered in the browser's address bar\r\n // `PathLocationStrategy.prototype.path()` returns a concatenation of\r\n // `PlatformLocation.pathname` and normalized `PlatformLocation.search`.\r\n\r\n // `Location.prototype.normalize` strips base href from the URL,\r\n // if `baseHref` (declared in angular.json) for example is `/en`\r\n // and the URL is `/test#anchor` - then `_locationStrategy.path(true)` will return `/en/test#anchor`,\r\n // but `/en/test#anchor` is not known to the Angular's router, so we have to strip `/en`\r\n // from the URL\r\n const currentUrl = this._location.normalize(this._locationStrategy.path(true));\r\n const currentUrlTree = this._urlSerializer.parse(currentUrl);\r\n // We need to serialize the URL because in that example `/test/?redirect=https://google.com/`\r\n // Angular will recognize it as `/test?redirect=https:%2F%2Fwww.google.com%2F`\r\n // so we have to run the `currentUrl` via the `UrlSerializer` that will encode characters\r\n const currentSerializedUrl = this._urlSerializer.serialize(currentUrlTree);\r\n\r\n // If URLs differ from each other - we've got to perform a redirect to the manually entered URL\r\n // in the address bar, as it must have a priority\r\n if (currentSerializedUrl !== url) {\r\n this._router.navigateByUrl(currentUrl);\r\n }\r\n });\r\n\r\n this._subscription.add(subscription);\r\n }\r\n}\r\n","import { ModuleWithProviders, NgModule } from '@angular/core';\r\nimport { NgxsModule } from '@ngxs/store';\r\n\r\nimport { RouterState } from './router.state';\r\nimport { DefaultRouterStateSerializer, RouterStateSerializer } from './serializer';\r\n\r\n@NgModule({\r\n imports: [NgxsModule.forFeature([RouterState])]\r\n})\r\nexport class NgxsRouterPluginModule {\r\n static forRoot(): ModuleWithProviders<NgxsRouterPluginModule> {\r\n return {\r\n ngModule: NgxsRouterPluginModule,\r\n providers: [{ provide: RouterStateSerializer, useClass: DefaultRouterStateSerializer }]\r\n };\r\n }\r\n}\r\n"],"names":["tslib_1.__decorate"],"mappings":";;;;;;;;;;;;;;;;AAeA,MAAa,QAAQ;;;;;;IAKnB,YACS,IAAW,EACX,WAAoB,EACpB,MAAyB;QAFzB,SAAI,GAAJ,IAAI,CAAO;QACX,gBAAW,GAAX,WAAW,CAAS;QACpB,WAAM,GAAN,MAAM,CAAmB;KAC9B;;;;IARJ,WAAW,IAAI;;QAEb,OAAO,mBAAmB,CAAC;KAC5B;CAMF;;;IAJG,wBAAkB;;IAClB,+BAA2B;;IAC3B,0BAAgC;;;;;;;;;;;AAapC,MAAa,gBAAgB;;;;;;IAK3B,YACS,WAAc,EACd,KAAuB,EACvB,UAAyB,MAAM;QAF/B,gBAAW,GAAX,WAAW,CAAG;QACd,UAAK,GAAL,KAAK,CAAkB;QACvB,YAAO,GAAP,OAAO,CAAwB;KACpC;;;;IARJ,WAAW,IAAI;;QAEb,OAAO,2BAA2B,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,aAAa;QACV,gBAAgB;QACxB,QAAQ;GAtClB,WAAW,CAyPvB;;;;;;;;IApPC,+BAAyC;;;;;;IAKzC,mCAAwD;;;;;;IAKxD,kCAAoD;;;;;IAEpD,4CAAwD;;;;;IAExD,oCAA2C;;;;;IAazC,6BAAqB;;;;;IACrB,8BAAuB;;;;;IACvB,kCAA+D;;;;;IAC/D,8BAAuB;;;;;IACvB,qCAAqC;;;;;IACrC,wCAA2C;;;;;IAC3C,gCAA2B;;;;;;;ACzF/B,MASa,sBAAsB;;;;IACjC,OAAO,OAAO;QACZ,OAAO;YACL,QAAQ,EAAE,sBAAsB;YAChC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,4BAA4B,EAAE,CAAC;SACxF,CAAC;KACH;;;YATF,QAAQ,SAAC;gBACR,OAAO,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;aAChD;;;;;;;;;;;;;;;;;;;;"}
@@ -4,6 +4,7 @@ import { __assign, __decorate, __metadata } from 'tslib';
4
4
  import { NavigationStart, RoutesRecognized, ResolveEnd, NavigationCancel, NavigationError, NavigationEnd, Router, UrlSerializer } from '@angular/router';
5
5
  import { LocationStrategy, Location } from '@angular/common';
6
6
  import { isAngularInTestMode } from '@ngxs/store/internals';
7
+ import { Subscription } from 'rxjs';
7
8
  import { first } from 'rxjs/operators';
8
9
 
9
10
  /**
@@ -336,6 +337,7 @@ var RouterState = /** @class */ (function () {
336
337
  */
337
338
  this._storeState = null;
338
339
  this._lastRoutesRecognized = (/** @type {?} */ (null));
340
+ this._subscription = new Subscription();
339
341
  this.setUpStoreListener();
340
342
  this.setUpRouterEventsListener();
341
343
  this.checkInitialNavigationOnce();
@@ -365,6 +367,15 @@ var RouterState = /** @class */ (function () {
365
367
  function (state) {
366
368
  return state && state.state && state.state.url;
367
369
  };
370
+ /**
371
+ * @return {?}
372
+ */
373
+ RouterState.prototype.ngOnDestroy = /**
374
+ * @return {?}
375
+ */
376
+ function () {
377
+ this._subscription.unsubscribe();
378
+ };
368
379
  /**
369
380
  * @param {?} _
370
381
  * @param {?} action
@@ -407,13 +418,17 @@ var RouterState = /** @class */ (function () {
407
418
  */
408
419
  function () {
409
420
  var _this = this;
410
- this._store.select(RouterState_1).subscribe((/**
421
+ /** @type {?} */
422
+ var subscription = this._store
423
+ .select(RouterState_1)
424
+ .subscribe((/**
411
425
  * @param {?} state
412
426
  * @return {?}
413
427
  */
414
428
  function (state) {
415
429
  _this.navigateIfNeeded(state);
416
430
  }));
431
+ this._subscription.add(subscription);
417
432
  };
418
433
  /**
419
434
  * @private
@@ -425,7 +440,8 @@ var RouterState = /** @class */ (function () {
425
440
  */
426
441
  function () {
427
442
  var _this = this;
428
- this._router.events.subscribe((/**
443
+ /** @type {?} */
444
+ var subscription = this._router.events.subscribe((/**
429
445
  * @param {?} event
430
446
  * @return {?}
431
447
  */
@@ -452,6 +468,7 @@ var RouterState = /** @class */ (function () {
452
468
  _this.reset();
453
469
  }
454
470
  }));
471
+ this._subscription.add(subscription);
455
472
  };
456
473
  /**
457
474
  * @private
@@ -631,10 +648,16 @@ var RouterState = /** @class */ (function () {
631
648
  */
632
649
  function () {
633
650
  var _this = this;
634
- if (isAngularInTestMode()) {
651
+ // Caretaker note: we have still left the `typeof` condition in order to avoid
652
+ // creating a breaking change for projects that still use the View Engine.
653
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) &&
654
+ // Angular is running tests in development mode thus we can be sure that this method will be
655
+ // skipped in tests.
656
+ isAngularInTestMode()) {
635
657
  return;
636
658
  }
637
- this._router.events
659
+ /** @type {?} */
660
+ var subscription = this._router.events
638
661
  .pipe(first((/**
639
662
  * @param {?} event
640
663
  * @return {?}
@@ -680,6 +703,7 @@ var RouterState = /** @class */ (function () {
680
703
  _this._router.navigateByUrl(currentUrl);
681
704
  }
682
705
  }));
706
+ this._subscription.add(subscription);
683
707
  };
684
708
  var RouterState_1;
685
709
  RouterState.ctorParameters = function () { return [
@@ -772,6 +796,11 @@ if (false) {
772
796
  * @private
773
797
  */
774
798
  RouterState.prototype._lastRoutesRecognized;
799
+ /**
800
+ * @type {?}
801
+ * @private
802
+ */
803
+ RouterState.prototype._subscription;
775
804
  /**
776
805
  * @type {?}
777
806
  * @private
@@ -1 +1 @@
1
- {"version":3,"file":"ngxs-router-plugin.js","sources":["ng://@ngxs/router-plugin/src/router.actions.ts","ng://@ngxs/router-plugin/src/serializer.ts","ng://@ngxs/router-plugin/src/router.state.ts","ng://@ngxs/router-plugin/src/router.module.ts"],"sourcesContent":["import {\r\n NavigationCancel,\r\n NavigationError,\r\n NavigationExtras,\r\n Params,\r\n RouterStateSnapshot,\r\n RoutesRecognized,\r\n ResolveEnd\r\n} from '@angular/router';\r\n\r\nimport { RouterTrigger } from './router.state';\r\n\r\n/**\r\n * Public event api of the router\r\n */\r\nexport class Navigate {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] Navigate';\r\n }\r\n constructor(\r\n public path: any[],\r\n public queryParams?: Params,\r\n public extras?: NavigationExtras\r\n ) {}\r\n}\r\n\r\n/**\r\n *\r\n * Angular Routers internal state events\r\n *\r\n */\r\n\r\n/**\r\n * An action dispatched when the router navigates.\r\n */\r\nexport class RouterNavigation<T = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterNavigation';\r\n }\r\n constructor(\r\n public routerState: T,\r\n public event: RoutesRecognized,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An action dispatched when the router cancel navigation.\r\n */\r\nexport class RouterCancel<T, V = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterCancel';\r\n }\r\n constructor(\r\n public routerState: V,\r\n public storeState: T,\r\n public event: NavigationCancel,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An action dispatched when the router errors.\r\n */\r\nexport class RouterError<T, V = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterError';\r\n }\r\n constructor(\r\n public routerState: V,\r\n public storeState: T,\r\n public event: NavigationError,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An action dispatched when the `ResolveEnd` event is triggered.\r\n */\r\nexport class RouterDataResolved<T = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterDataResolved';\r\n }\r\n constructor(\r\n public routerState: T,\r\n public event: ResolveEnd,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An union type of router actions.\r\n */\r\nexport type RouterAction<T, V = RouterStateSnapshot> =\r\n | RouterNavigation<V>\r\n | RouterCancel<T, V>\r\n | RouterError<T, V>\r\n | RouterDataResolved<V>;\r\n","import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\r\n\r\nexport abstract class RouterStateSerializer<T> {\r\n abstract serialize(routerState: RouterStateSnapshot): T;\r\n}\r\n\r\nexport interface SerializedRouterStateSnapshot {\r\n root: ActivatedRouteSnapshot;\r\n url: string;\r\n}\r\n\r\nexport class DefaultRouterStateSerializer\r\n implements RouterStateSerializer<SerializedRouterStateSnapshot> {\r\n serialize(routerState: RouterStateSnapshot): SerializedRouterStateSnapshot {\r\n return {\r\n root: this.serializeRoute(routerState.root),\r\n url: routerState.url\r\n };\r\n }\r\n\r\n private serializeRoute(route: ActivatedRouteSnapshot): ActivatedRouteSnapshot {\r\n const children = route.children.map(c => this.serializeRoute(c));\r\n return {\r\n url: route.url,\r\n params: route.params,\r\n queryParams: route.queryParams,\r\n fragment: route.fragment,\r\n data: route.data,\r\n outlet: route.outlet,\r\n component: null,\r\n routeConfig: null,\r\n root: null as any,\r\n parent: null,\r\n firstChild: children[0],\r\n children: children,\r\n pathFromRoot: null as any,\r\n paramMap: route.paramMap,\r\n queryParamMap: route.queryParamMap,\r\n toString: route.toString\r\n };\r\n }\r\n}\r\n","import { NgZone, Injectable } from '@angular/core';\r\nimport {\r\n NavigationCancel,\r\n NavigationError,\r\n Router,\r\n RouterStateSnapshot,\r\n RoutesRecognized,\r\n ResolveEnd,\r\n UrlSerializer,\r\n NavigationStart,\r\n NavigationEnd\r\n} from '@angular/router';\r\nimport { LocationStrategy, Location } from '@angular/common';\r\nimport { Action, Selector, State, StateContext, Store } from '@ngxs/store';\r\nimport { isAngularInTestMode } from '@ngxs/store/internals';\r\nimport { first } from 'rxjs/operators';\r\n\r\nimport {\r\n Navigate,\r\n RouterAction,\r\n RouterCancel,\r\n RouterError,\r\n RouterNavigation,\r\n RouterDataResolved\r\n} from './router.actions';\r\nimport { RouterStateSerializer } from './serializer';\r\n\r\nexport interface RouterStateModel<T = RouterStateSnapshot> {\r\n state?: T;\r\n navigationId?: number;\r\n trigger: RouterTrigger;\r\n}\r\n\r\nexport type RouterTrigger = 'none' | 'router' | 'store';\r\n\r\n@State<RouterStateModel>({\r\n name: 'router',\r\n defaults: {\r\n state: undefined,\r\n navigationId: undefined,\r\n trigger: 'none'\r\n }\r\n})\r\n@Injectable()\r\nexport class RouterState {\r\n /**\r\n * Determines how navigation was performed by the `RouterState` itself\r\n * or outside via `new Navigate(...)`\r\n */\r\n private _trigger: RouterTrigger = 'none';\r\n\r\n /**\r\n * That's the serialized state from the `Router` class\r\n */\r\n private _routerState: RouterStateSnapshot | null = null;\r\n\r\n /**\r\n * That's the value of the `RouterState` state\r\n */\r\n private _storeState: RouterStateModel | null = null;\r\n\r\n private _lastRoutesRecognized: RoutesRecognized = null!;\r\n\r\n @Selector()\r\n static state<T = RouterStateSnapshot>(state: RouterStateModel<T>) {\r\n return state && state.state;\r\n }\r\n\r\n @Selector()\r\n static url(state: RouterStateModel): string | undefined {\r\n return state && state.state && state.state.url;\r\n }\r\n\r\n constructor(\r\n private _store: Store,\r\n private _router: Router,\r\n private _serializer: RouterStateSerializer<RouterStateSnapshot>,\r\n private _ngZone: NgZone,\r\n private _urlSerializer: UrlSerializer,\r\n private _locationStrategy: LocationStrategy,\r\n private _location: Location\r\n ) {\r\n this.setUpStoreListener();\r\n this.setUpRouterEventsListener();\r\n this.checkInitialNavigationOnce();\r\n }\r\n\r\n @Action(Navigate)\r\n navigate(_: StateContext<RouterStateModel>, action: Navigate) {\r\n return this._ngZone.run(() =>\r\n this._router.navigate(action.path, {\r\n queryParams: action.queryParams,\r\n ...action.extras\r\n })\r\n );\r\n }\r\n\r\n @Action([RouterNavigation, RouterError, RouterCancel, RouterDataResolved])\r\n angularRouterAction(\r\n ctx: StateContext<RouterStateModel>,\r\n action: RouterAction<RouterStateModel, RouterStateSnapshot>\r\n ): void {\r\n ctx.setState({\r\n ...ctx.getState(),\r\n trigger: action.trigger,\r\n state: action.routerState,\r\n navigationId: action.event.id\r\n });\r\n }\r\n\r\n private setUpStoreListener(): void {\r\n this._store.select(RouterState).subscribe((state: RouterStateModel | undefined) => {\r\n this.navigateIfNeeded(state);\r\n });\r\n }\r\n\r\n private setUpRouterEventsListener(): void {\r\n this._router.events.subscribe(event => {\r\n if (event instanceof NavigationStart) {\r\n this.navigationStart();\r\n } else if (event instanceof RoutesRecognized) {\r\n this._lastRoutesRecognized = event;\r\n } else if (event instanceof ResolveEnd) {\r\n this.dispatchRouterDataResolved(event);\r\n } else if (event instanceof NavigationCancel) {\r\n this.dispatchRouterCancel(event);\r\n this.reset();\r\n } else if (event instanceof NavigationError) {\r\n this.dispatchRouterError(event);\r\n this.reset();\r\n } else if (event instanceof NavigationEnd) {\r\n this.navigationEnd();\r\n this.reset();\r\n }\r\n });\r\n }\r\n\r\n private navigationStart(): void {\r\n this._routerState = this._serializer.serialize(this._router.routerState.snapshot);\r\n\r\n if (this._trigger !== 'none') {\r\n this._storeState = this._store.selectSnapshot(RouterState);\r\n }\r\n }\r\n\r\n private navigationEnd(): void {\r\n if (this.shouldDispatchRouterNavigation()) {\r\n this.dispatchRouterNavigation();\r\n }\r\n }\r\n\r\n private shouldDispatchRouterNavigation(): boolean {\r\n if (!this._storeState) return true;\r\n return this._trigger !== 'store';\r\n }\r\n\r\n private navigateIfNeeded(state: RouterStateModel | undefined): void {\r\n const canSkipNavigation =\r\n !this._storeState ||\r\n !this._storeState.state ||\r\n !state ||\r\n state.trigger === 'router' ||\r\n this._router.url === this._storeState.state.url;\r\n\r\n if (canSkipNavigation) {\r\n return;\r\n }\r\n\r\n this._trigger = 'store';\r\n this._ngZone.run(() => {\r\n this._router.navigateByUrl(this._storeState!.state!.url);\r\n });\r\n }\r\n\r\n private dispatchRouterNavigation(): void {\r\n const nextRouterState = this._serializer.serialize(this._lastRoutesRecognized.state);\r\n\r\n this.dispatchRouterAction(\r\n new RouterNavigation(\r\n nextRouterState,\r\n new RoutesRecognized(\r\n this._lastRoutesRecognized.id,\r\n this._lastRoutesRecognized.url,\r\n this._lastRoutesRecognized.urlAfterRedirects,\r\n nextRouterState\r\n ),\r\n this._trigger\r\n )\r\n );\r\n }\r\n\r\n private dispatchRouterCancel(event: NavigationCancel): void {\r\n this.dispatchRouterAction(\r\n new RouterCancel(this._routerState!, this._storeState, event, this._trigger)\r\n );\r\n }\r\n\r\n private dispatchRouterError(event: NavigationError): void {\r\n this.dispatchRouterAction(\r\n new RouterError(\r\n this._routerState!,\r\n this._storeState,\r\n new NavigationError(event.id, event.url, `${event}`),\r\n this._trigger\r\n )\r\n );\r\n }\r\n\r\n private dispatchRouterAction<T>(action: RouterAction<T>): void {\r\n this._trigger = 'router';\r\n\r\n try {\r\n this._store.dispatch(action);\r\n } finally {\r\n this._trigger = 'none';\r\n }\r\n }\r\n\r\n private dispatchRouterDataResolved(event: ResolveEnd): void {\r\n const routerState = this._serializer.serialize(event.state);\r\n this.dispatchRouterAction(new RouterDataResolved(routerState, event, this._trigger));\r\n }\r\n\r\n private reset(): void {\r\n this._trigger = 'none';\r\n this._storeState = null;\r\n this._routerState = null;\r\n }\r\n\r\n /**\r\n * No sense to mess up the `setUpRouterEventsListener` method as we have\r\n * to perform this check only once and unsubscribe after the first event\r\n * is triggered\r\n */\r\n private checkInitialNavigationOnce(): void {\r\n if (isAngularInTestMode()) {\r\n return;\r\n }\r\n\r\n this._router.events\r\n .pipe(first((event): event is RoutesRecognized => event instanceof RoutesRecognized))\r\n .subscribe(({ url }) => {\r\n // `location.pathname` always equals manually entered URL in the address bar\r\n // e.g. `location.pathname === '/foo'`, but the `router` state has been initialized\r\n // with another URL (e.g. used in combination with `NgxsStoragePlugin`), thus the\r\n // `RouterNavigation` action will be dispatched and the user will be redirected to the\r\n // previously saved URL. We want to prevent such behavior, so we perform this check\r\n\r\n // `url` is a recognized URL by the Angular's router, while `currentUrl` is an actual URL\r\n // entered in the browser's address bar\r\n // `PathLocationStrategy.prototype.path()` returns a concatenation of\r\n // `PlatformLocation.pathname` and normalized `PlatformLocation.search`.\r\n\r\n // `Location.prototype.normalize` strips base href from the URL,\r\n // if `baseHref` (declared in angular.json) for example is `/en`\r\n // and the URL is `/test#anchor` - then `_locationStrategy.path(true)` will return `/en/test#anchor`,\r\n // but `/en/test#anchor` is not known to the Angular's router, so we have to strip `/en`\r\n // from the URL\r\n const currentUrl = this._location.normalize(this._locationStrategy.path(true));\r\n const currentUrlTree = this._urlSerializer.parse(currentUrl);\r\n // We need to serialize the URL because in that example `/test/?redirect=https://google.com/`\r\n // Angular will recognize it as `/test?redirect=https:%2F%2Fwww.google.com%2F`\r\n // so we have to run the `currentUrl` via the `UrlSerializer` that will encode characters\r\n const currentSerializedUrl = this._urlSerializer.serialize(currentUrlTree);\r\n\r\n // If URLs differ from each other - we've got to perform a redirect to the manually entered URL\r\n // in the address bar, as it must have a priority\r\n if (currentSerializedUrl !== url) {\r\n this._router.navigateByUrl(currentUrl);\r\n }\r\n });\r\n }\r\n}\r\n","import { ModuleWithProviders, NgModule } from '@angular/core';\r\nimport { NgxsModule } from '@ngxs/store';\r\n\r\nimport { RouterState } from './router.state';\r\nimport { DefaultRouterStateSerializer, RouterStateSerializer } from './serializer';\r\n\r\n@NgModule({\r\n imports: [NgxsModule.forFeature([RouterState])]\r\n})\r\nexport class NgxsRouterPluginModule {\r\n static forRoot(): ModuleWithProviders<NgxsRouterPluginModule> {\r\n return {\r\n ngModule: NgxsRouterPluginModule,\r\n providers: [{ provide: RouterStateSerializer, useClass: DefaultRouterStateSerializer }]\r\n };\r\n }\r\n}\r\n"],"names":["tslib_1.__decorate"],"mappings":";;;;;;;;;;;;;;;AAeA;;;;IAKE,kBACS,IAAW,EACX,WAAoB,EACpB,MAAyB;QAFzB,SAAI,GAAJ,IAAI,CAAO;QACX,gBAAW,GAAX,WAAW,CAAS;QACpB,WAAM,GAAN,MAAM,CAAmB;KAC9B;IARJ,sBAAW,gBAAI;;;;QAAf;;YAEE,OAAO,mBAAmB,CAAC;SAC5B;;;OAAA;IAMH,eAAC;CAAA,IAAA;;;IAJG,wBAAkB;;IAClB,+BAA2B;;IAC3B,0BAAgC;;;;;;;;;;;AAapC;;;;;;;;;;IAKE,0BACS,WAAc,EACd,KAAuB,EACvB,OAA+B;QAA/B,wBAAA,EAAA,gBAA+B;QAF/B,gBAAW,GAAX,WAAW,CAAG;QACd,UAAK,GAAL,KAAK,CAAkB;QACvB,YAAO,GAAP,OAAO,CAAwB;KACpC;IARJ,sBAAW,wBAAI;;;;QAAf;;YAEE,OAAO,2BAA2B,CAAC;SACpC;;;OAAA;IAMH,uBAAC;CAAA,IAAA;;;IAJG,uCAAqB;;IACrB,iCAA8B;;IAC9B,mCAAsC;;;;;;AAO1C;;;;;IAKE,sBACS,WAAc,EACd,UAAa,EACb,KAAuB,EACvB,OAA+B;QAA/B,wBAA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ACxB,QAAQ;OApClB,WAAW,CAoOvB;IAAD,kBAAC;CAAA,IAAA;;;;;;;;IA/NC,+BAAyC;;;;;;IAKzC,mCAAwD;;;;;;IAKxD,kCAAoD;;;;;IAEpD,4CAAwD;;;;;IAatD,6BAAqB;;;;;IACrB,8BAAuB;;;;;IACvB,kCAA+D;;;;;IAC/D,8BAAuB;;;;;IACvB,qCAAqC;;;;;IACrC,wCAA2C;;;;;IAC3C,gCAA2B;;;;;;;AChF/B;IAMA;KAUC;;;;IANQ,8BAAO;;;IAAd;QACE,OAAO;YACL,QAAQ,EAAE,sBAAsB;YAChC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,4BAA4B,EAAE,CAAC;SACxF,CAAC;KACH;;gBATF,QAAQ,SAAC;oBACR,OAAO,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;iBAChD;;IAQD,6BAAC;CAVD;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"ngxs-router-plugin.js","sources":["ng://@ngxs/router-plugin/src/router.actions.ts","ng://@ngxs/router-plugin/src/serializer.ts","ng://@ngxs/router-plugin/src/router.state.ts","ng://@ngxs/router-plugin/src/router.module.ts"],"sourcesContent":["import {\r\n NavigationCancel,\r\n NavigationError,\r\n NavigationExtras,\r\n Params,\r\n RouterStateSnapshot,\r\n RoutesRecognized,\r\n ResolveEnd\r\n} from '@angular/router';\r\n\r\nimport { RouterTrigger } from './router.state';\r\n\r\n/**\r\n * Public event api of the router\r\n */\r\nexport class Navigate {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] Navigate';\r\n }\r\n constructor(\r\n public path: any[],\r\n public queryParams?: Params,\r\n public extras?: NavigationExtras\r\n ) {}\r\n}\r\n\r\n/**\r\n *\r\n * Angular Routers internal state events\r\n *\r\n */\r\n\r\n/**\r\n * An action dispatched when the router navigates.\r\n */\r\nexport class RouterNavigation<T = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterNavigation';\r\n }\r\n constructor(\r\n public routerState: T,\r\n public event: RoutesRecognized,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An action dispatched when the router cancel navigation.\r\n */\r\nexport class RouterCancel<T, V = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterCancel';\r\n }\r\n constructor(\r\n public routerState: V,\r\n public storeState: T,\r\n public event: NavigationCancel,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An action dispatched when the router errors.\r\n */\r\nexport class RouterError<T, V = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterError';\r\n }\r\n constructor(\r\n public routerState: V,\r\n public storeState: T,\r\n public event: NavigationError,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An action dispatched when the `ResolveEnd` event is triggered.\r\n */\r\nexport class RouterDataResolved<T = RouterStateSnapshot> {\r\n static get type() {\r\n // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138\r\n return '[Router] RouterDataResolved';\r\n }\r\n constructor(\r\n public routerState: T,\r\n public event: ResolveEnd,\r\n public trigger: RouterTrigger = 'none'\r\n ) {}\r\n}\r\n\r\n/**\r\n * An union type of router actions.\r\n */\r\nexport type RouterAction<T, V = RouterStateSnapshot> =\r\n | RouterNavigation<V>\r\n | RouterCancel<T, V>\r\n | RouterError<T, V>\r\n | RouterDataResolved<V>;\r\n","import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\r\n\r\nexport abstract class RouterStateSerializer<T> {\r\n abstract serialize(routerState: RouterStateSnapshot): T;\r\n}\r\n\r\nexport interface SerializedRouterStateSnapshot {\r\n root: ActivatedRouteSnapshot;\r\n url: string;\r\n}\r\n\r\nexport class DefaultRouterStateSerializer\r\n implements RouterStateSerializer<SerializedRouterStateSnapshot> {\r\n serialize(routerState: RouterStateSnapshot): SerializedRouterStateSnapshot {\r\n return {\r\n root: this.serializeRoute(routerState.root),\r\n url: routerState.url\r\n };\r\n }\r\n\r\n private serializeRoute(route: ActivatedRouteSnapshot): ActivatedRouteSnapshot {\r\n const children = route.children.map(c => this.serializeRoute(c));\r\n return {\r\n url: route.url,\r\n params: route.params,\r\n queryParams: route.queryParams,\r\n fragment: route.fragment,\r\n data: route.data,\r\n outlet: route.outlet,\r\n component: null,\r\n routeConfig: null,\r\n root: null as any,\r\n parent: null,\r\n firstChild: children[0],\r\n children: children,\r\n pathFromRoot: null as any,\r\n paramMap: route.paramMap,\r\n queryParamMap: route.queryParamMap,\r\n toString: route.toString\r\n };\r\n }\r\n}\r\n","import { NgZone, Injectable, OnDestroy } from '@angular/core';\r\nimport {\r\n NavigationCancel,\r\n NavigationError,\r\n Router,\r\n RouterStateSnapshot,\r\n RoutesRecognized,\r\n ResolveEnd,\r\n UrlSerializer,\r\n NavigationStart,\r\n NavigationEnd\r\n} from '@angular/router';\r\nimport { LocationStrategy, Location } from '@angular/common';\r\nimport { Action, Selector, State, StateContext, Store } from '@ngxs/store';\r\nimport { isAngularInTestMode } from '@ngxs/store/internals';\r\nimport { Subscription } from 'rxjs';\r\nimport { first } from 'rxjs/operators';\r\n\r\nimport {\r\n Navigate,\r\n RouterAction,\r\n RouterCancel,\r\n RouterError,\r\n RouterNavigation,\r\n RouterDataResolved\r\n} from './router.actions';\r\nimport { RouterStateSerializer } from './serializer';\r\n\r\nexport interface RouterStateModel<T = RouterStateSnapshot> {\r\n state?: T;\r\n navigationId?: number;\r\n trigger: RouterTrigger;\r\n}\r\n\r\nexport type RouterTrigger = 'none' | 'router' | 'store';\r\n\r\n/**\r\n * @description Will be provided through Terser global definitions by Angular CLI\r\n * during the production build. This is how Angular does tree-shaking internally.\r\n */\r\ndeclare const ngDevMode: boolean;\r\n\r\n@State<RouterStateModel>({\r\n name: 'router',\r\n defaults: {\r\n state: undefined,\r\n navigationId: undefined,\r\n trigger: 'none'\r\n }\r\n})\r\n@Injectable()\r\nexport class RouterState implements OnDestroy {\r\n /**\r\n * Determines how navigation was performed by the `RouterState` itself\r\n * or outside via `new Navigate(...)`\r\n */\r\n private _trigger: RouterTrigger = 'none';\r\n\r\n /**\r\n * That's the serialized state from the `Router` class\r\n */\r\n private _routerState: RouterStateSnapshot | null = null;\r\n\r\n /**\r\n * That's the value of the `RouterState` state\r\n */\r\n private _storeState: RouterStateModel | null = null;\r\n\r\n private _lastRoutesRecognized: RoutesRecognized = null!;\r\n\r\n private _subscription = new Subscription();\r\n\r\n @Selector()\r\n static state<T = RouterStateSnapshot>(state: RouterStateModel<T>) {\r\n return state && state.state;\r\n }\r\n\r\n @Selector()\r\n static url(state: RouterStateModel): string | undefined {\r\n return state && state.state && state.state.url;\r\n }\r\n\r\n constructor(\r\n private _store: Store,\r\n private _router: Router,\r\n private _serializer: RouterStateSerializer<RouterStateSnapshot>,\r\n private _ngZone: NgZone,\r\n private _urlSerializer: UrlSerializer,\r\n private _locationStrategy: LocationStrategy,\r\n private _location: Location\r\n ) {\r\n this.setUpStoreListener();\r\n this.setUpRouterEventsListener();\r\n this.checkInitialNavigationOnce();\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this._subscription.unsubscribe();\r\n }\r\n\r\n @Action(Navigate)\r\n navigate(_: StateContext<RouterStateModel>, action: Navigate) {\r\n return this._ngZone.run(() =>\r\n this._router.navigate(action.path, {\r\n queryParams: action.queryParams,\r\n ...action.extras\r\n })\r\n );\r\n }\r\n\r\n @Action([RouterNavigation, RouterError, RouterCancel, RouterDataResolved])\r\n angularRouterAction(\r\n ctx: StateContext<RouterStateModel>,\r\n action: RouterAction<RouterStateModel, RouterStateSnapshot>\r\n ): void {\r\n ctx.setState({\r\n ...ctx.getState(),\r\n trigger: action.trigger,\r\n state: action.routerState,\r\n navigationId: action.event.id\r\n });\r\n }\r\n\r\n private setUpStoreListener(): void {\r\n const subscription = this._store\r\n .select(RouterState)\r\n .subscribe((state: RouterStateModel | undefined) => {\r\n this.navigateIfNeeded(state);\r\n });\r\n\r\n this._subscription.add(subscription);\r\n }\r\n\r\n private setUpRouterEventsListener(): void {\r\n const subscription = this._router.events.subscribe(event => {\r\n if (event instanceof NavigationStart) {\r\n this.navigationStart();\r\n } else if (event instanceof RoutesRecognized) {\r\n this._lastRoutesRecognized = event;\r\n } else if (event instanceof ResolveEnd) {\r\n this.dispatchRouterDataResolved(event);\r\n } else if (event instanceof NavigationCancel) {\r\n this.dispatchRouterCancel(event);\r\n this.reset();\r\n } else if (event instanceof NavigationError) {\r\n this.dispatchRouterError(event);\r\n this.reset();\r\n } else if (event instanceof NavigationEnd) {\r\n this.navigationEnd();\r\n this.reset();\r\n }\r\n });\r\n\r\n this._subscription.add(subscription);\r\n }\r\n\r\n private navigationStart(): void {\r\n this._routerState = this._serializer.serialize(this._router.routerState.snapshot);\r\n\r\n if (this._trigger !== 'none') {\r\n this._storeState = this._store.selectSnapshot(RouterState);\r\n }\r\n }\r\n\r\n private navigationEnd(): void {\r\n if (this.shouldDispatchRouterNavigation()) {\r\n this.dispatchRouterNavigation();\r\n }\r\n }\r\n\r\n private shouldDispatchRouterNavigation(): boolean {\r\n if (!this._storeState) return true;\r\n return this._trigger !== 'store';\r\n }\r\n\r\n private navigateIfNeeded(state: RouterStateModel | undefined): void {\r\n const canSkipNavigation =\r\n !this._storeState ||\r\n !this._storeState.state ||\r\n !state ||\r\n state.trigger === 'router' ||\r\n this._router.url === this._storeState.state.url;\r\n\r\n if (canSkipNavigation) {\r\n return;\r\n }\r\n\r\n this._trigger = 'store';\r\n this._ngZone.run(() => {\r\n this._router.navigateByUrl(this._storeState!.state!.url);\r\n });\r\n }\r\n\r\n private dispatchRouterNavigation(): void {\r\n const nextRouterState = this._serializer.serialize(this._lastRoutesRecognized.state);\r\n\r\n this.dispatchRouterAction(\r\n new RouterNavigation(\r\n nextRouterState,\r\n new RoutesRecognized(\r\n this._lastRoutesRecognized.id,\r\n this._lastRoutesRecognized.url,\r\n this._lastRoutesRecognized.urlAfterRedirects,\r\n nextRouterState\r\n ),\r\n this._trigger\r\n )\r\n );\r\n }\r\n\r\n private dispatchRouterCancel(event: NavigationCancel): void {\r\n this.dispatchRouterAction(\r\n new RouterCancel(this._routerState!, this._storeState, event, this._trigger)\r\n );\r\n }\r\n\r\n private dispatchRouterError(event: NavigationError): void {\r\n this.dispatchRouterAction(\r\n new RouterError(\r\n this._routerState!,\r\n this._storeState,\r\n new NavigationError(event.id, event.url, `${event}`),\r\n this._trigger\r\n )\r\n );\r\n }\r\n\r\n private dispatchRouterAction<T>(action: RouterAction<T>): void {\r\n this._trigger = 'router';\r\n\r\n try {\r\n this._store.dispatch(action);\r\n } finally {\r\n this._trigger = 'none';\r\n }\r\n }\r\n\r\n private dispatchRouterDataResolved(event: ResolveEnd): void {\r\n const routerState = this._serializer.serialize(event.state);\r\n this.dispatchRouterAction(new RouterDataResolved(routerState, event, this._trigger));\r\n }\r\n\r\n private reset(): void {\r\n this._trigger = 'none';\r\n this._storeState = null;\r\n this._routerState = null;\r\n }\r\n\r\n /**\r\n * No sense to mess up the `setUpRouterEventsListener` method as we have\r\n * to perform this check only once and unsubscribe after the first event\r\n * is triggered\r\n */\r\n private checkInitialNavigationOnce(): void {\r\n // Caretaker note: we have still left the `typeof` condition in order to avoid\r\n // creating a breaking change for projects that still use the View Engine.\r\n if (\r\n (typeof ngDevMode === 'undefined' || ngDevMode) &&\r\n // Angular is running tests in development mode thus we can be sure that this method will be\r\n // skipped in tests.\r\n isAngularInTestMode()\r\n ) {\r\n return;\r\n }\r\n\r\n const subscription = this._router.events\r\n .pipe(first((event): event is RoutesRecognized => event instanceof RoutesRecognized))\r\n .subscribe(({ url }) => {\r\n // `location.pathname` always equals manually entered URL in the address bar\r\n // e.g. `location.pathname === '/foo'`, but the `router` state has been initialized\r\n // with another URL (e.g. used in combination with `NgxsStoragePlugin`), thus the\r\n // `RouterNavigation` action will be dispatched and the user will be redirected to the\r\n // previously saved URL. We want to prevent such behavior, so we perform this check\r\n\r\n // `url` is a recognized URL by the Angular's router, while `currentUrl` is an actual URL\r\n // entered in the browser's address bar\r\n // `PathLocationStrategy.prototype.path()` returns a concatenation of\r\n // `PlatformLocation.pathname` and normalized `PlatformLocation.search`.\r\n\r\n // `Location.prototype.normalize` strips base href from the URL,\r\n // if `baseHref` (declared in angular.json) for example is `/en`\r\n // and the URL is `/test#anchor` - then `_locationStrategy.path(true)` will return `/en/test#anchor`,\r\n // but `/en/test#anchor` is not known to the Angular's router, so we have to strip `/en`\r\n // from the URL\r\n const currentUrl = this._location.normalize(this._locationStrategy.path(true));\r\n const currentUrlTree = this._urlSerializer.parse(currentUrl);\r\n // We need to serialize the URL because in that example `/test/?redirect=https://google.com/`\r\n // Angular will recognize it as `/test?redirect=https:%2F%2Fwww.google.com%2F`\r\n // so we have to run the `currentUrl` via the `UrlSerializer` that will encode characters\r\n const currentSerializedUrl = this._urlSerializer.serialize(currentUrlTree);\r\n\r\n // If URLs differ from each other - we've got to perform a redirect to the manually entered URL\r\n // in the address bar, as it must have a priority\r\n if (currentSerializedUrl !== url) {\r\n this._router.navigateByUrl(currentUrl);\r\n }\r\n });\r\n\r\n this._subscription.add(subscription);\r\n }\r\n}\r\n","import { ModuleWithProviders, NgModule } from '@angular/core';\r\nimport { NgxsModule } from '@ngxs/store';\r\n\r\nimport { RouterState } from './router.state';\r\nimport { DefaultRouterStateSerializer, RouterStateSerializer } from './serializer';\r\n\r\n@NgModule({\r\n imports: [NgxsModule.forFeature([RouterState])]\r\n})\r\nexport class NgxsRouterPluginModule {\r\n static forRoot(): ModuleWithProviders<NgxsRouterPluginModule> {\r\n return {\r\n ngModule: NgxsRouterPluginModule,\r\n providers: [{ provide: RouterStateSerializer, useClass: DefaultRouterStateSerializer }]\r\n };\r\n }\r\n}\r\n"],"names":["tslib_1.__decorate"],"mappings":";;;;;;;;;;;;;;;;AAeA;;;;IAKE,kBACS,IAAW,EACX,WAAoB,EACpB,MAAyB;QAFzB,SAAI,GAAJ,IAAI,CAAO;QACX,gBAAW,GAAX,WAAW,CAAS;QACpB,WAAM,GAAN,MAAM,CAAmB;KAC9B;IARJ,sBAAW,gBAAI;;;;QAAf;;YAEE,OAAO,mBAAmB,CAAC;SAC5B;;;OAAA;IAMH,eAAC;CAAA,IAAA;;;IAJG,wBAAkB;;IAClB,+BAA2B;;IAC3B,0BAAgC;;;;;;;;;;;AAapC;;;;;;;;;;IAKE,0BACS,WAAc,EACd,KAAuB,EACvB,OAA+B;QAA/B,wBAAA,EAAA,gBAA+B;QAF/B,gBAAW,GAAX,WAAW,CAAG;QACd,UAAK,GAAL,KAAK,CAAkB;QACvB,YAAO,GAAP,OAAO,CAAwB;KACpC;IARJ,sBAAW,wBAAI;;;;QAAf;;YAEE,OAAO,2BAA2B,CAAC;SACpC;;;OAAA;IAMH,uBAAC;CAAA,IAAA;;;IAJG,uCAAqB;;IACrB,iCAA8B;;IAC9B,mCAAsC;;;;;;AAO1C;;;;;IAKE,sBACS,WAAc,EACd,UAAa,EACb,KAAuB,EACvB,OAA+B;QAA/B,wBAAA,EAAA,gBAA+B;QAH/B,gBAAW,GAAX,WAAW,CAAG;QACd,eAAU,GAAV,UAAU,CAAG;QACb,UAAK,GAAL,KAAK,CAAkB;QACvB,YAAO,GAAP,OAAO,CAAwB;KACpC;IATJ,sBAAW,oBAAI;;;;QAAf;;YAEE,OAAO,uBAAuB,CAAC;SAChC;;;OAAA;IAOH,mBAAC;CAAA,IAAA;;;IALG,mCAAqB;;IACrB,kCAAoB;;IACpB,6BAA8B;;IAC9B,+BAAsC;;;;;;AAO1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AK;YACJ,MAAM;YACF,qBAAqB;YACzB,MAAM;YACC,aAAa;YACV,gBAAgB;YACxB,QAAQ;OAtClB,WAAW,CAyPvB;IAAD,kBAAC;CAAA,IAAA;;;;;;;;IApPC,+BAAyC;;;;;;IAKzC,mCAAwD;;;;;;IAKxD,kCAAoD;;;;;IAEpD,4CAAwD;;;;;IAExD,oCAA2C;;;;;IAazC,6BAAqB;;;;;IACrB,8BAAuB;;;;;IACvB,kCAA+D;;;;;IAC/D,8BAAuB;;;;;IACvB,qCAAqC;;;;;IACrC,wCAA2C;;;;;IAC3C,gCAA2B;;;;;;;ACzF/B;IAMA;KAUC;;;;IANQ,8BAAO;;;IAAd;QACE,OAAO;YACL,QAAQ,EAAE,sBAAsB;YAChC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,4BAA4B,EAAE,CAAC;SACxF,CAAC;KACH;;gBATF,QAAQ,SAAC;oBACR,OAAO,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;iBAChD;;IAQD,6BAAC;CAVD;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"__symbolic":"module","version":4,"metadata":{"ɵa":{"__symbolic":"interface"},"NgxsRouterPluginModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":6,"character":1},"arguments":[{"imports":[{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","module":"@ngxs/store","name":"NgxsModule","line":7,"character":12},"member":"forFeature"},"arguments":[[{"__symbolic":"reference","name":"RouterState"}]]}]}]}],"members":{},"statics":{"forRoot":{"__symbolic":"function","parameters":[],"value":{"ngModule":{"__symbolic":"reference","name":"NgxsRouterPluginModule"},"providers":[{"provide":{"__symbolic":"reference","name":"RouterStateSerializer"},"useClass":{"__symbolic":"reference","name":"DefaultRouterStateSerializer"}}]}}}},"RouterState":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ngxs/store","name":"State","line":35,"character":1},"arguments":[{"name":"router","defaults":{"state":{"__symbolic":"reference","name":"undefined"},"navigationId":{"__symbolic":"reference","name":"undefined"},"trigger":"none"}}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":43,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@ngxs/store","name":"Store","line":74,"character":20},{"__symbolic":"reference","module":"@angular/router","name":"Router","line":75,"character":21},{"__symbolic":"reference","name":"RouterStateSerializer"},{"__symbolic":"reference","module":"@angular/core","name":"NgZone","line":77,"character":21},{"__symbolic":"reference","module":"@angular/router","name":"UrlSerializer","line":78,"character":28},{"__symbolic":"reference","module":"@angular/common","name":"LocationStrategy","line":79,"character":31},{"__symbolic":"reference","module":"@angular/common","name":"Location","line":80,"character":23}]}],"navigate":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ngxs/store","name":"Action","line":87,"character":3},"arguments":[{"__symbolic":"reference","name":"Navigate"}]}]}],"angularRouterAction":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ngxs/store","name":"Action","line":97,"character":3},"arguments":[[{"__symbolic":"reference","name":"RouterNavigation"},{"__symbolic":"reference","name":"RouterError"},{"__symbolic":"reference","name":"RouterCancel"},{"__symbolic":"reference","name":"RouterDataResolved"}]]}]}],"setUpStoreListener":[{"__symbolic":"method"}],"setUpRouterEventsListener":[{"__symbolic":"method"}],"navigationStart":[{"__symbolic":"method"}],"navigationEnd":[{"__symbolic":"method"}],"shouldDispatchRouterNavigation":[{"__symbolic":"method"}],"navigateIfNeeded":[{"__symbolic":"method"}],"dispatchRouterNavigation":[{"__symbolic":"method"}],"dispatchRouterCancel":[{"__symbolic":"method"}],"dispatchRouterError":[{"__symbolic":"method"}],"dispatchRouterAction":[{"__symbolic":"method"}],"dispatchRouterDataResolved":[{"__symbolic":"method"}],"reset":[{"__symbolic":"method"}],"checkInitialNavigationOnce":[{"__symbolic":"method"}]},"statics":{"state":{"__symbolic":"function","parameters":["state"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"reference","name":"state"},"right":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"state"},"member":"state"}}},"url":{"__symbolic":"function","parameters":["state"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"reference","name":"state"},"right":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"state"},"member":"state"}},"right":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"state"},"member":"state"},"member":"url"}}}}},"RouterStateModel":{"__symbolic":"interface"},"RouterStateSerializer":{"__symbolic":"class","arity":1,"members":{"serialize":[{"__symbolic":"method"}]}},"DefaultRouterStateSerializer":{"__symbolic":"class","members":{"serialize":[{"__symbolic":"method"}],"serializeRoute":[{"__symbolic":"method"}]}},"SerializedRouterStateSnapshot":{"__symbolic":"interface"},"Navigate":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","name":"any"}]},{"__symbolic":"reference","module":"@angular/router","name":"Params","line":22,"character":25},{"__symbolic":"reference","module":"@angular/router","name":"NavigationExtras","line":23,"character":20}]}]},"statics":{"type":{"__symbolic":"error","message":"Variable not initialized","line":16,"character":13}}},"RouterNavigation":{"__symbolic":"class","arity":1,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":42,"character":24,"context":{"typeName":"T"},"module":"./src/router.actions"},{"__symbolic":"reference","module":"@angular/router","name":"RoutesRecognized","line":43,"character":18},{"__symbolic":"reference","name":"ɵa"}]}]},"statics":{"type":{"__symbolic":"error","message":"Variable not initialized","line":37,"character":13}}},"RouterCancel":{"__symbolic":"class","arity":2,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":57,"character":24,"context":{"typeName":"V"},"module":"./src/router.actions"},{"__symbolic":"error","message":"Could not resolve type","line":58,"character":23,"context":{"typeName":"T"},"module":"./src/router.actions"},{"__symbolic":"reference","module":"@angular/router","name":"NavigationCancel","line":59,"character":18},{"__symbolic":"reference","name":"ɵa"}]}]},"statics":{"type":{"__symbolic":"error","message":"Variable not initialized","line":52,"character":13}}},"RouterError":{"__symbolic":"class","arity":2,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":73,"character":24,"context":{"typeName":"V"},"module":"./src/router.actions"},{"__symbolic":"error","message":"Could not resolve type","line":74,"character":23,"context":{"typeName":"T"},"module":"./src/router.actions"},{"__symbolic":"reference","module":"@angular/router","name":"NavigationError","line":75,"character":18},{"__symbolic":"reference","name":"ɵa"}]}]},"statics":{"type":{"__symbolic":"error","message":"Variable not initialized","line":68,"character":13}}},"RouterDataResolved":{"__symbolic":"class","arity":1,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":89,"character":24,"context":{"typeName":"T"},"module":"./src/router.actions"},{"__symbolic":"reference","module":"@angular/router","name":"ResolveEnd","line":90,"character":18},{"__symbolic":"reference","name":"ɵa"}]}]},"statics":{"type":{"__symbolic":"error","message":"Variable not initialized","line":84,"character":13}}},"RouterAction":{"__symbolic":"interface"}},"origins":{"ɵa":"./src/router.state","NgxsRouterPluginModule":"./src/router.module","RouterState":"./src/router.state","RouterStateModel":"./src/router.state","RouterStateSerializer":"./src/serializer","DefaultRouterStateSerializer":"./src/serializer","SerializedRouterStateSnapshot":"./src/serializer","Navigate":"./src/router.actions","RouterNavigation":"./src/router.actions","RouterCancel":"./src/router.actions","RouterError":"./src/router.actions","RouterDataResolved":"./src/router.actions","RouterAction":"./src/router.actions"},"importAs":"@ngxs/router-plugin"}
1
+ {"__symbolic":"module","version":4,"metadata":{"ɵa":{"__symbolic":"interface"},"NgxsRouterPluginModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":6,"character":1},"arguments":[{"imports":[{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","module":"@ngxs/store","name":"NgxsModule","line":7,"character":12},"member":"forFeature"},"arguments":[[{"__symbolic":"reference","name":"RouterState"}]]}]}]}],"members":{},"statics":{"forRoot":{"__symbolic":"function","parameters":[],"value":{"ngModule":{"__symbolic":"reference","name":"NgxsRouterPluginModule"},"providers":[{"provide":{"__symbolic":"reference","name":"RouterStateSerializer"},"useClass":{"__symbolic":"reference","name":"DefaultRouterStateSerializer"}}]}}}},"RouterState":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ngxs/store","name":"State","line":42,"character":1},"arguments":[{"name":"router","defaults":{"state":{"__symbolic":"reference","name":"undefined"},"navigationId":{"__symbolic":"reference","name":"undefined"},"trigger":"none"}}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":50,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@ngxs/store","name":"Store","line":83,"character":20},{"__symbolic":"reference","module":"@angular/router","name":"Router","line":84,"character":21},{"__symbolic":"reference","name":"RouterStateSerializer"},{"__symbolic":"reference","module":"@angular/core","name":"NgZone","line":86,"character":21},{"__symbolic":"reference","module":"@angular/router","name":"UrlSerializer","line":87,"character":28},{"__symbolic":"reference","module":"@angular/common","name":"LocationStrategy","line":88,"character":31},{"__symbolic":"reference","module":"@angular/common","name":"Location","line":89,"character":23}]}],"ngOnDestroy":[{"__symbolic":"method"}],"navigate":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ngxs/store","name":"Action","line":100,"character":3},"arguments":[{"__symbolic":"reference","name":"Navigate"}]}]}],"angularRouterAction":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ngxs/store","name":"Action","line":110,"character":3},"arguments":[[{"__symbolic":"reference","name":"RouterNavigation"},{"__symbolic":"reference","name":"RouterError"},{"__symbolic":"reference","name":"RouterCancel"},{"__symbolic":"reference","name":"RouterDataResolved"}]]}]}],"setUpStoreListener":[{"__symbolic":"method"}],"setUpRouterEventsListener":[{"__symbolic":"method"}],"navigationStart":[{"__symbolic":"method"}],"navigationEnd":[{"__symbolic":"method"}],"shouldDispatchRouterNavigation":[{"__symbolic":"method"}],"navigateIfNeeded":[{"__symbolic":"method"}],"dispatchRouterNavigation":[{"__symbolic":"method"}],"dispatchRouterCancel":[{"__symbolic":"method"}],"dispatchRouterError":[{"__symbolic":"method"}],"dispatchRouterAction":[{"__symbolic":"method"}],"dispatchRouterDataResolved":[{"__symbolic":"method"}],"reset":[{"__symbolic":"method"}],"checkInitialNavigationOnce":[{"__symbolic":"method"}]},"statics":{"state":{"__symbolic":"function","parameters":["state"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"reference","name":"state"},"right":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"state"},"member":"state"}}},"url":{"__symbolic":"function","parameters":["state"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"reference","name":"state"},"right":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"state"},"member":"state"}},"right":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"state"},"member":"state"},"member":"url"}}}}},"RouterStateModel":{"__symbolic":"interface"},"RouterStateSerializer":{"__symbolic":"class","arity":1,"members":{"serialize":[{"__symbolic":"method"}]}},"DefaultRouterStateSerializer":{"__symbolic":"class","members":{"serialize":[{"__symbolic":"method"}],"serializeRoute":[{"__symbolic":"method"}]}},"SerializedRouterStateSnapshot":{"__symbolic":"interface"},"Navigate":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","name":"any"}]},{"__symbolic":"reference","module":"@angular/router","name":"Params","line":22,"character":25},{"__symbolic":"reference","module":"@angular/router","name":"NavigationExtras","line":23,"character":20}]}]},"statics":{"type":{"__symbolic":"error","message":"Variable not initialized","line":16,"character":13}}},"RouterNavigation":{"__symbolic":"class","arity":1,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":42,"character":24,"context":{"typeName":"T"},"module":"./src/router.actions"},{"__symbolic":"reference","module":"@angular/router","name":"RoutesRecognized","line":43,"character":18},{"__symbolic":"reference","name":"ɵa"}]}]},"statics":{"type":{"__symbolic":"error","message":"Variable not initialized","line":37,"character":13}}},"RouterCancel":{"__symbolic":"class","arity":2,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":57,"character":24,"context":{"typeName":"V"},"module":"./src/router.actions"},{"__symbolic":"error","message":"Could not resolve type","line":58,"character":23,"context":{"typeName":"T"},"module":"./src/router.actions"},{"__symbolic":"reference","module":"@angular/router","name":"NavigationCancel","line":59,"character":18},{"__symbolic":"reference","name":"ɵa"}]}]},"statics":{"type":{"__symbolic":"error","message":"Variable not initialized","line":52,"character":13}}},"RouterError":{"__symbolic":"class","arity":2,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":73,"character":24,"context":{"typeName":"V"},"module":"./src/router.actions"},{"__symbolic":"error","message":"Could not resolve type","line":74,"character":23,"context":{"typeName":"T"},"module":"./src/router.actions"},{"__symbolic":"reference","module":"@angular/router","name":"NavigationError","line":75,"character":18},{"__symbolic":"reference","name":"ɵa"}]}]},"statics":{"type":{"__symbolic":"error","message":"Variable not initialized","line":68,"character":13}}},"RouterDataResolved":{"__symbolic":"class","arity":1,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":89,"character":24,"context":{"typeName":"T"},"module":"./src/router.actions"},{"__symbolic":"reference","module":"@angular/router","name":"ResolveEnd","line":90,"character":18},{"__symbolic":"reference","name":"ɵa"}]}]},"statics":{"type":{"__symbolic":"error","message":"Variable not initialized","line":84,"character":13}}},"RouterAction":{"__symbolic":"interface"}},"origins":{"ɵa":"./src/router.state","NgxsRouterPluginModule":"./src/router.module","RouterState":"./src/router.state","RouterStateModel":"./src/router.state","RouterStateSerializer":"./src/serializer","DefaultRouterStateSerializer":"./src/serializer","SerializedRouterStateSnapshot":"./src/serializer","Navigate":"./src/router.actions","RouterNavigation":"./src/router.actions","RouterCancel":"./src/router.actions","RouterError":"./src/router.actions","RouterDataResolved":"./src/router.actions","RouterAction":"./src/router.actions"},"importAs":"@ngxs/router-plugin"}
package/package.json CHANGED
@@ -2,12 +2,12 @@
2
2
  "$schema": "../../node_modules/ng-packagr/package.schema.json",
3
3
  "name": "@ngxs/router-plugin",
4
4
  "description": "router plugin for @ngxs/store",
5
- "version": "3.7.3",
5
+ "version": "3.7.4",
6
6
  "sideEffects": true,
7
7
  "peerDependencies": {
8
- "@ngxs/store": "^3.7.3 || ^3.7.3-dev",
9
- "@angular/core": ">=6.1.0 <14.0.0",
10
- "@angular/router": ">=6.1.0 <14.0.0",
8
+ "@ngxs/store": "^3.7.4 || ^3.7.4-dev",
9
+ "@angular/core": ">=6.1.0 <15.0.0",
10
+ "@angular/router": ">=6.1.0 <15.0.0",
11
11
  "rxjs": ">=6.5.5"
12
12
  },
13
13
  "main": "bundles/ngxs-router-plugin.umd.js",
@@ -1,4 +1,4 @@
1
- import { NgZone } from '@angular/core';
1
+ import { NgZone, OnDestroy } from '@angular/core';
2
2
  import { Router, RouterStateSnapshot, UrlSerializer } from '@angular/router';
3
3
  import { LocationStrategy, Location } from '@angular/common';
4
4
  import { StateContext, Store } from '@ngxs/store';
@@ -10,7 +10,7 @@ export interface RouterStateModel<T = RouterStateSnapshot> {
10
10
  trigger: RouterTrigger;
11
11
  }
12
12
  export declare type RouterTrigger = 'none' | 'router' | 'store';
13
- export declare class RouterState {
13
+ export declare class RouterState implements OnDestroy {
14
14
  private _store;
15
15
  private _router;
16
16
  private _serializer;
@@ -32,9 +32,11 @@ export declare class RouterState {
32
32
  */
33
33
  private _storeState;
34
34
  private _lastRoutesRecognized;
35
+ private _subscription;
35
36
  static state<T = RouterStateSnapshot>(state: RouterStateModel<T>): T | undefined;
36
37
  static url(state: RouterStateModel): string | undefined;
37
38
  constructor(_store: Store, _router: Router, _serializer: RouterStateSerializer<RouterStateSnapshot>, _ngZone: NgZone, _urlSerializer: UrlSerializer, _locationStrategy: LocationStrategy, _location: Location);
39
+ ngOnDestroy(): void;
38
40
  navigate(_: StateContext<RouterStateModel>, action: Navigate): Promise<boolean>;
39
41
  angularRouterAction(ctx: StateContext<RouterStateModel>, action: RouterAction<RouterStateModel, RouterStateSnapshot>): void;
40
42
  private setUpStoreListener;