@angular/router 7.2.0-beta.0 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/router-testing.umd.js +1 -1
- package/bundles/router-testing.umd.js.map +1 -1
- package/bundles/router-testing.umd.min.js +1 -1
- package/bundles/router-testing.umd.min.js.map +1 -1
- package/bundles/router-upgrade.umd.js +1 -1
- package/bundles/router-upgrade.umd.js.map +1 -1
- package/bundles/router-upgrade.umd.min.js +1 -1
- package/bundles/router-upgrade.umd.min.js.map +1 -1
- package/bundles/router.umd.js +87 -18
- package/bundles/router.umd.js.map +1 -1
- package/bundles/router.umd.min.js +6 -6
- package/bundles/router.umd.min.js.map +1 -1
- package/esm2015/index.js +2 -3
- package/esm2015/public_api.js +2 -4
- package/esm2015/router.externs.js +7 -3
- package/esm2015/router.js +1 -2
- package/esm2015/src/apply_redirects.js +60 -21
- package/esm2015/src/components/empty_outlet.js +2 -3
- package/esm2015/src/config.js +40 -66
- package/esm2015/src/create_router_state.js +3 -4
- package/esm2015/src/create_url_tree.js +3 -6
- package/esm2015/src/directives/router_link.js +71 -13
- package/esm2015/src/directives/router_link_active.js +30 -10
- package/esm2015/src/directives/router_outlet.js +46 -15
- package/esm2015/src/events.js +47 -35
- package/esm2015/src/index.js +2 -3
- package/esm2015/src/interfaces.js +44 -25
- package/esm2015/src/operators/activate_routes.js +31 -9
- package/esm2015/src/operators/apply_redirects.js +2 -3
- package/esm2015/src/operators/check_guards.js +8 -9
- package/esm2015/src/operators/prioritized_guard_value.js +4 -6
- package/esm2015/src/operators/recognize.js +2 -3
- package/esm2015/src/operators/resolve_data.js +3 -4
- package/esm2015/src/operators/switch_tap.js +2 -3
- package/esm2015/src/private_export.js +2 -3
- package/esm2015/src/recognize.js +41 -21
- package/esm2015/src/route_reuse_strategy.js +2 -9
- package/esm2015/src/router.js +304 -199
- package/esm2015/src/router_config_loader.js +24 -10
- package/esm2015/src/router_module.js +202 -188
- package/esm2015/src/router_outlet_context.js +7 -4
- package/esm2015/src/router_preloader.js +27 -8
- package/esm2015/src/router_scroller.js +37 -11
- package/esm2015/src/router_state.js +12 -19
- package/esm2015/src/shared.js +42 -34
- package/esm2015/src/url_handling_strategy.js +2 -3
- package/esm2015/src/url_tree.js +31 -7
- package/esm2015/src/utils/collection.js +2 -3
- package/esm2015/src/utils/preactivation.js +10 -5
- package/esm2015/src/utils/tree.js +5 -3
- package/esm2015/src/utils/type_guards.js +2 -3
- package/esm2015/src/version.js +11 -6
- package/esm2015/testing/index.js +2 -3
- package/esm2015/testing/public_api.js +2 -4
- package/esm2015/testing/src/router_testing_module.js +9 -6
- package/esm2015/testing/src/testing.js +2 -3
- package/esm2015/testing/testing.js +1 -2
- package/esm2015/upgrade/index.js +2 -3
- package/esm2015/upgrade/public_api.js +2 -4
- package/esm2015/upgrade/src/upgrade.js +9 -8
- package/esm2015/upgrade/upgrade.js +1 -2
- package/esm5/index.js +1 -2
- package/esm5/public_api.js +1 -2
- package/esm5/router.js +1 -2
- package/esm5/src/apply_redirects.js +1 -2
- package/esm5/src/components/empty_outlet.js +1 -2
- package/esm5/src/config.js +1 -2
- package/esm5/src/create_router_state.js +1 -2
- package/esm5/src/create_url_tree.js +1 -2
- package/esm5/src/directives/router_link.js +31 -2
- package/esm5/src/directives/router_link_active.js +1 -2
- package/esm5/src/directives/router_outlet.js +1 -2
- package/esm5/src/events.js +1 -2
- package/esm5/src/index.js +1 -2
- package/esm5/src/interfaces.js +1 -2
- package/esm5/src/operators/activate_routes.js +1 -2
- package/esm5/src/operators/apply_redirects.js +1 -2
- package/esm5/src/operators/check_guards.js +1 -2
- package/esm5/src/operators/prioritized_guard_value.js +1 -2
- package/esm5/src/operators/recognize.js +1 -2
- package/esm5/src/operators/resolve_data.js +1 -2
- package/esm5/src/operators/switch_tap.js +1 -2
- package/esm5/src/private_export.js +1 -2
- package/esm5/src/recognize.js +1 -2
- package/esm5/src/route_reuse_strategy.js +1 -2
- package/esm5/src/router.js +50 -18
- package/esm5/src/router_config_loader.js +1 -2
- package/esm5/src/router_module.js +1 -2
- package/esm5/src/router_outlet_context.js +1 -2
- package/esm5/src/router_preloader.js +1 -2
- package/esm5/src/router_scroller.js +1 -2
- package/esm5/src/router_state.js +1 -2
- package/esm5/src/shared.js +1 -2
- package/esm5/src/url_handling_strategy.js +1 -2
- package/esm5/src/url_tree.js +1 -2
- package/esm5/src/utils/collection.js +1 -2
- package/esm5/src/utils/preactivation.js +7 -2
- package/esm5/src/utils/tree.js +1 -2
- package/esm5/src/utils/type_guards.js +1 -2
- package/esm5/src/version.js +2 -3
- package/esm5/testing/index.js +1 -2
- package/esm5/testing/public_api.js +1 -2
- package/esm5/testing/src/router_testing_module.js +1 -2
- package/esm5/testing/src/testing.js +1 -2
- package/esm5/testing/testing.js +1 -2
- package/esm5/upgrade/index.js +1 -2
- package/esm5/upgrade/public_api.js +1 -2
- package/esm5/upgrade/src/upgrade.js +1 -2
- package/esm5/upgrade/upgrade.js +1 -2
- package/fesm2015/router.js +387 -202
- package/fesm2015/router.js.map +1 -1
- package/fesm2015/testing.js +7 -8
- package/fesm2015/testing.js.map +1 -1
- package/fesm2015/upgrade.js +11 -10
- package/fesm2015/upgrade.js.map +1 -1
- package/fesm5/router.js +87 -18
- package/fesm5/router.js.map +1 -1
- package/fesm5/testing.js +1 -1
- package/fesm5/testing.js.map +1 -1
- package/fesm5/upgrade.js +1 -1
- package/fesm5/upgrade.js.map +1 -1
- package/package.json +4 -4
- package/router.metadata.json +1 -1
- package/src/config.d.ts +9 -2
- package/src/directives/router_link.d.ts +27 -0
- package/src/events.d.ts +6 -2
- package/src/index.d.ts +1 -1
- package/src/router.d.ts +74 -3
- package/testing.d.ts +5 -0
- package/upgrade.d.ts +5 -0
package/fesm2015/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v7.2.0
|
|
2
|
+
* @license Angular v7.2.0
|
|
3
3
|
* (c) 2010-2018 Google, Inc. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -11,7 +11,7 @@ import { ChildrenOutletContexts, NoPreloading, PreloadingStrategy, ROUTER_CONFIG
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @fileoverview added by tsickle
|
|
14
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
14
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
15
15
|
*/
|
|
16
16
|
/**
|
|
17
17
|
* \@description
|
|
@@ -80,7 +80,7 @@ class SpyNgModuleFactoryLoader {
|
|
|
80
80
|
return this._stubbedModules[path];
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
|
-
return /** @type {?} */ (Promise.reject(new Error(`Cannot find module ${path}`)));
|
|
83
|
+
return (/** @type {?} */ (Promise.reject(new Error(`Cannot find module ${path}`))));
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -117,7 +117,7 @@ function isUrlHandlingStrategy(opts) {
|
|
|
117
117
|
*/
|
|
118
118
|
function setupTestingRouter(urlSerializer, contexts, location, loader, compiler, injector, routes, opts, urlHandlingStrategy) {
|
|
119
119
|
/** @type {?} */
|
|
120
|
-
const router = new Router(/** @type {?} */ (
|
|
120
|
+
const router = new Router((/** @type {?} */ (null)), urlSerializer, contexts, location, injector, loader, compiler, ɵflatten(routes));
|
|
121
121
|
if (opts) {
|
|
122
122
|
// Handle deprecated argument ordering.
|
|
123
123
|
if (isUrlHandlingStrategy(opts)) {
|
|
@@ -201,18 +201,17 @@ RouterTestingModule.decorators = [
|
|
|
201
201
|
|
|
202
202
|
/**
|
|
203
203
|
* @fileoverview added by tsickle
|
|
204
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
204
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
205
205
|
*/
|
|
206
206
|
|
|
207
207
|
/**
|
|
208
208
|
* @fileoverview added by tsickle
|
|
209
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
209
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
210
210
|
*/
|
|
211
|
-
// This file only reexports content of the `src` folder. Keep it that way.
|
|
212
211
|
|
|
213
212
|
/**
|
|
214
213
|
* @fileoverview added by tsickle
|
|
215
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
214
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
216
215
|
*/
|
|
217
216
|
|
|
218
217
|
/**
|
package/fesm2015/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","sources":["../testing/src/router_testing_module.ts","../testing/testing.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Location, LocationStrategy} from '@angular/common';\nimport {MockLocationStrategy, SpyLocation} from '@angular/common/testing';\nimport {Compiler, Injectable, Injector, ModuleWithProviders, NgModule, NgModuleFactory, NgModuleFactoryLoader, Optional} from '@angular/core';\nimport {ChildrenOutletContexts, ExtraOptions, NoPreloading, PreloadingStrategy, ROUTER_CONFIGURATION, ROUTES, Route, Router, RouterModule, Routes, UrlHandlingStrategy, UrlSerializer, provideRoutes, ɵROUTER_PROVIDERS as ROUTER_PROVIDERS, ɵflatten as flatten} from '@angular/router';\n\n\n\n/**\n * @description\n *\n * Allows to simulate the loading of ng modules in tests.\n *\n * ```\n * const loader = TestBed.get(NgModuleFactoryLoader);\n *\n * @Component({template: 'lazy-loaded'})\n * class LazyLoadedComponent {}\n * @NgModule({\n * declarations: [LazyLoadedComponent],\n * imports: [RouterModule.forChild([{path: 'loaded', component: LazyLoadedComponent}])]\n * })\n *\n * class LoadedModule {}\n *\n * // sets up stubbedModules\n * loader.stubbedModules = {lazyModule: LoadedModule};\n *\n * router.resetConfig([\n * {path: 'lazy', loadChildren: 'lazyModule'},\n * ]);\n *\n * router.navigateByUrl('/lazy/loaded');\n * ```\n *\n * @publicApi\n */\n@Injectable()\nexport class SpyNgModuleFactoryLoader implements NgModuleFactoryLoader {\n /**\n * @docsNotRequired\n */\n private _stubbedModules: {[path: string]: Promise<NgModuleFactory<any>>} = {};\n\n /**\n * @docsNotRequired\n */\n set stubbedModules(modules: {[path: string]: any}) {\n const res: {[path: string]: any} = {};\n for (const t of Object.keys(modules)) {\n res[t] = this.compiler.compileModuleAsync(modules[t]);\n }\n this._stubbedModules = res;\n }\n\n /**\n * @docsNotRequired\n */\n get stubbedModules(): {[path: string]: any} { return this._stubbedModules; }\n\n constructor(private compiler: Compiler) {}\n\n load(path: string): Promise<NgModuleFactory<any>> {\n if (this._stubbedModules[path]) {\n return this._stubbedModules[path];\n } else {\n return <any>Promise.reject(new Error(`Cannot find module ${path}`));\n }\n }\n}\n\nfunction isUrlHandlingStrategy(opts: ExtraOptions | UrlHandlingStrategy):\n opts is UrlHandlingStrategy {\n // This property check is needed because UrlHandlingStrategy is an interface and doesn't exist at\n // runtime.\n return 'shouldProcessUrl' in opts;\n}\n\n/**\n * Router setup factory function used for testing.\n *\n * @publicApi\n */\nexport function setupTestingRouter(\n urlSerializer: UrlSerializer, contexts: ChildrenOutletContexts, location: Location,\n loader: NgModuleFactoryLoader, compiler: Compiler, injector: Injector, routes: Route[][],\n opts?: ExtraOptions, urlHandlingStrategy?: UrlHandlingStrategy): Router;\n\n/**\n * Router setup factory function used for testing.\n *\n * @deprecated As of v5.2. The 2nd-to-last argument should be `ExtraOptions`, not\n * `UrlHandlingStrategy`\n * @publicApi\n */\nexport function setupTestingRouter(\n urlSerializer: UrlSerializer, contexts: ChildrenOutletContexts, location: Location,\n loader: NgModuleFactoryLoader, compiler: Compiler, injector: Injector, routes: Route[][],\n urlHandlingStrategy?: UrlHandlingStrategy): Router;\n\n/**\n * Router setup factory function used for testing.\n *\n * @publicApi\n */\nexport function setupTestingRouter(\n urlSerializer: UrlSerializer, contexts: ChildrenOutletContexts, location: Location,\n loader: NgModuleFactoryLoader, compiler: Compiler, injector: Injector, routes: Route[][],\n opts?: ExtraOptions | UrlHandlingStrategy, urlHandlingStrategy?: UrlHandlingStrategy) {\n const router = new Router(\n null !, urlSerializer, contexts, location, injector, loader, compiler, flatten(routes));\n if (opts) {\n // Handle deprecated argument ordering.\n if (isUrlHandlingStrategy(opts)) {\n router.urlHandlingStrategy = opts;\n } else {\n // Handle ExtraOptions\n\n if (opts.malformedUriErrorHandler) {\n router.malformedUriErrorHandler = opts.malformedUriErrorHandler;\n }\n\n if (opts.paramsInheritanceStrategy) {\n router.paramsInheritanceStrategy = opts.paramsInheritanceStrategy;\n }\n }\n }\n\n if (urlHandlingStrategy) {\n router.urlHandlingStrategy = urlHandlingStrategy;\n }\n return router;\n}\n\n/**\n * @description\n *\n * Sets up the router to be used for testing.\n *\n * The modules sets up the router to be used for testing.\n * It provides spy implementations of `Location`, `LocationStrategy`, and {@link\n * NgModuleFactoryLoader}.\n *\n * @usageNotes\n * ### Example\n *\n * ```\n * beforeEach(() => {\n * TestBed.configureTestModule({\n * imports: [\n * RouterTestingModule.withRoutes(\n * [{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}]\n * )\n * ]\n * });\n * });\n * ```\n *\n * @publicApi\n */\n@NgModule({\n exports: [RouterModule],\n providers: [\n ROUTER_PROVIDERS, {provide: Location, useClass: SpyLocation},\n {provide: LocationStrategy, useClass: MockLocationStrategy},\n {provide: NgModuleFactoryLoader, useClass: SpyNgModuleFactoryLoader}, {\n provide: Router,\n useFactory: setupTestingRouter,\n deps: [\n UrlSerializer, ChildrenOutletContexts, Location, NgModuleFactoryLoader, Compiler, Injector,\n ROUTES, ROUTER_CONFIGURATION, [UrlHandlingStrategy, new Optional()]\n ]\n },\n {provide: PreloadingStrategy, useExisting: NoPreloading}, provideRoutes([])\n ]\n})\nexport class RouterTestingModule {\n static withRoutes(routes: Routes, config?: ExtraOptions):\n ModuleWithProviders<RouterTestingModule> {\n return {\n ngModule: RouterTestingModule,\n providers: [\n provideRoutes(routes),\n {provide: ROUTER_CONFIGURATION, useValue: config ? config : {}},\n ]\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["flatten","ROUTER_PROVIDERS"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAa,wBAAwB;;;;IAsBnC,YAAoB,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU
|
|
1
|
+
{"version":3,"file":"testing.js","sources":["../npm_package.es6/packages/packages/router/testing/src/router_testing_module.ts","../npm_package.es6/packages/router/testing/testing.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Location, LocationStrategy} from '@angular/common';\nimport {MockLocationStrategy, SpyLocation} from '@angular/common/testing';\nimport {Compiler, Injectable, Injector, ModuleWithProviders, NgModule, NgModuleFactory, NgModuleFactoryLoader, Optional} from '@angular/core';\nimport {ChildrenOutletContexts, ExtraOptions, NoPreloading, PreloadingStrategy, ROUTER_CONFIGURATION, ROUTES, Route, Router, RouterModule, Routes, UrlHandlingStrategy, UrlSerializer, provideRoutes, ɵROUTER_PROVIDERS as ROUTER_PROVIDERS, ɵflatten as flatten} from '@angular/router';\n\n\n\n/**\n * @description\n *\n * Allows to simulate the loading of ng modules in tests.\n *\n * ```\n * const loader = TestBed.get(NgModuleFactoryLoader);\n *\n * @Component({template: 'lazy-loaded'})\n * class LazyLoadedComponent {}\n * @NgModule({\n * declarations: [LazyLoadedComponent],\n * imports: [RouterModule.forChild([{path: 'loaded', component: LazyLoadedComponent}])]\n * })\n *\n * class LoadedModule {}\n *\n * // sets up stubbedModules\n * loader.stubbedModules = {lazyModule: LoadedModule};\n *\n * router.resetConfig([\n * {path: 'lazy', loadChildren: 'lazyModule'},\n * ]);\n *\n * router.navigateByUrl('/lazy/loaded');\n * ```\n *\n * @publicApi\n */\n@Injectable()\nexport class SpyNgModuleFactoryLoader implements NgModuleFactoryLoader {\n /**\n * @docsNotRequired\n */\n private _stubbedModules: {[path: string]: Promise<NgModuleFactory<any>>} = {};\n\n /**\n * @docsNotRequired\n */\n set stubbedModules(modules: {[path: string]: any}) {\n const res: {[path: string]: any} = {};\n for (const t of Object.keys(modules)) {\n res[t] = this.compiler.compileModuleAsync(modules[t]);\n }\n this._stubbedModules = res;\n }\n\n /**\n * @docsNotRequired\n */\n get stubbedModules(): {[path: string]: any} { return this._stubbedModules; }\n\n constructor(private compiler: Compiler) {}\n\n load(path: string): Promise<NgModuleFactory<any>> {\n if (this._stubbedModules[path]) {\n return this._stubbedModules[path];\n } else {\n return <any>Promise.reject(new Error(`Cannot find module ${path}`));\n }\n }\n}\n\nfunction isUrlHandlingStrategy(opts: ExtraOptions | UrlHandlingStrategy):\n opts is UrlHandlingStrategy {\n // This property check is needed because UrlHandlingStrategy is an interface and doesn't exist at\n // runtime.\n return 'shouldProcessUrl' in opts;\n}\n\n/**\n * Router setup factory function used for testing.\n *\n * @publicApi\n */\nexport function setupTestingRouter(\n urlSerializer: UrlSerializer, contexts: ChildrenOutletContexts, location: Location,\n loader: NgModuleFactoryLoader, compiler: Compiler, injector: Injector, routes: Route[][],\n opts?: ExtraOptions, urlHandlingStrategy?: UrlHandlingStrategy): Router;\n\n/**\n * Router setup factory function used for testing.\n *\n * @deprecated As of v5.2. The 2nd-to-last argument should be `ExtraOptions`, not\n * `UrlHandlingStrategy`\n * @publicApi\n */\nexport function setupTestingRouter(\n urlSerializer: UrlSerializer, contexts: ChildrenOutletContexts, location: Location,\n loader: NgModuleFactoryLoader, compiler: Compiler, injector: Injector, routes: Route[][],\n urlHandlingStrategy?: UrlHandlingStrategy): Router;\n\n/**\n * Router setup factory function used for testing.\n *\n * @publicApi\n */\nexport function setupTestingRouter(\n urlSerializer: UrlSerializer, contexts: ChildrenOutletContexts, location: Location,\n loader: NgModuleFactoryLoader, compiler: Compiler, injector: Injector, routes: Route[][],\n opts?: ExtraOptions | UrlHandlingStrategy, urlHandlingStrategy?: UrlHandlingStrategy) {\n const router = new Router(\n null !, urlSerializer, contexts, location, injector, loader, compiler, flatten(routes));\n if (opts) {\n // Handle deprecated argument ordering.\n if (isUrlHandlingStrategy(opts)) {\n router.urlHandlingStrategy = opts;\n } else {\n // Handle ExtraOptions\n\n if (opts.malformedUriErrorHandler) {\n router.malformedUriErrorHandler = opts.malformedUriErrorHandler;\n }\n\n if (opts.paramsInheritanceStrategy) {\n router.paramsInheritanceStrategy = opts.paramsInheritanceStrategy;\n }\n }\n }\n\n if (urlHandlingStrategy) {\n router.urlHandlingStrategy = urlHandlingStrategy;\n }\n return router;\n}\n\n/**\n * @description\n *\n * Sets up the router to be used for testing.\n *\n * The modules sets up the router to be used for testing.\n * It provides spy implementations of `Location`, `LocationStrategy`, and {@link\n * NgModuleFactoryLoader}.\n *\n * @usageNotes\n * ### Example\n *\n * ```\n * beforeEach(() => {\n * TestBed.configureTestModule({\n * imports: [\n * RouterTestingModule.withRoutes(\n * [{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}]\n * )\n * ]\n * });\n * });\n * ```\n *\n * @publicApi\n */\n@NgModule({\n exports: [RouterModule],\n providers: [\n ROUTER_PROVIDERS, {provide: Location, useClass: SpyLocation},\n {provide: LocationStrategy, useClass: MockLocationStrategy},\n {provide: NgModuleFactoryLoader, useClass: SpyNgModuleFactoryLoader}, {\n provide: Router,\n useFactory: setupTestingRouter,\n deps: [\n UrlSerializer, ChildrenOutletContexts, Location, NgModuleFactoryLoader, Compiler, Injector,\n ROUTES, ROUTER_CONFIGURATION, [UrlHandlingStrategy, new Optional()]\n ]\n },\n {provide: PreloadingStrategy, useExisting: NoPreloading}, provideRoutes([])\n ]\n})\nexport class RouterTestingModule {\n static withRoutes(routes: Routes, config?: ExtraOptions):\n ModuleWithProviders<RouterTestingModule> {\n return {\n ngModule: RouterTestingModule,\n providers: [\n provideRoutes(routes),\n {provide: ROUTER_CONFIGURATION, useValue: config ? config : {}},\n ]\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["flatten","ROUTER_PROVIDERS"],"mappings":"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"}
|
package/fesm2015/upgrade.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v7.2.0
|
|
2
|
+
* @license Angular v7.2.0
|
|
3
3
|
* (c) 2010-2018 Google, Inc. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -11,9 +11,9 @@ import { UpgradeModule } from '@angular/upgrade/static';
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @fileoverview added by tsickle
|
|
14
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
14
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
15
15
|
*/
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
17
|
* \@description
|
|
18
18
|
*
|
|
19
19
|
* Creates an initializer that in addition to setting up the Angular
|
|
@@ -35,11 +35,12 @@ import { UpgradeModule } from '@angular/upgrade/static';
|
|
|
35
35
|
* ```
|
|
36
36
|
*
|
|
37
37
|
* \@publicApi
|
|
38
|
-
|
|
38
|
+
* @type {?}
|
|
39
|
+
*/
|
|
39
40
|
const RouterUpgradeInitializer = {
|
|
40
41
|
provide: APP_BOOTSTRAP_LISTENER,
|
|
41
42
|
multi: true,
|
|
42
|
-
useFactory: /** @type {?} */ (locationSyncBootstrapListener),
|
|
43
|
+
useFactory: (/** @type {?} */ (locationSyncBootstrapListener)),
|
|
43
44
|
deps: [UpgradeModule]
|
|
44
45
|
};
|
|
45
46
|
/**
|
|
@@ -82,7 +83,7 @@ function setUpLocationSync(ngUpgrade) {
|
|
|
82
83
|
router.navigateByUrl(path + url.search + url.hash);
|
|
83
84
|
});
|
|
84
85
|
}
|
|
85
|
-
/**
|
|
86
|
+
/**
|
|
86
87
|
* Normalize and parse a URL.
|
|
87
88
|
*
|
|
88
89
|
* - Normalizing means that a relative URL will be resolved into an absolute URL in the context of
|
|
@@ -99,7 +100,8 @@ function setUpLocationSync(ngUpgrade) {
|
|
|
99
100
|
* See
|
|
100
101
|
* https://github.com/angular/angular.js/blob/2c7400e7d07b0f6cec1817dab40b9250ce8ebce6/src/ng/urlUtils.js#L26-L33
|
|
101
102
|
* for more info.
|
|
102
|
-
|
|
103
|
+
* @type {?}
|
|
104
|
+
*/
|
|
103
105
|
let anchor;
|
|
104
106
|
/**
|
|
105
107
|
* @param {?} url
|
|
@@ -121,13 +123,12 @@ function resolveUrl(url) {
|
|
|
121
123
|
|
|
122
124
|
/**
|
|
123
125
|
* @fileoverview added by tsickle
|
|
124
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
126
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
125
127
|
*/
|
|
126
|
-
// This file only reexports content of the `src` folder. Keep it that way.
|
|
127
128
|
|
|
128
129
|
/**
|
|
129
130
|
* @fileoverview added by tsickle
|
|
130
|
-
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
|
|
131
|
+
* @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
131
132
|
*/
|
|
132
133
|
|
|
133
134
|
/**
|
package/fesm2015/upgrade.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.js","sources":["../upgrade/src/upgrade.ts","../upgrade/upgrade.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Location} from '@angular/common';\nimport {APP_BOOTSTRAP_LISTENER, ComponentRef, InjectionToken} from '@angular/core';\nimport {Router} from '@angular/router';\nimport {UpgradeModule} from '@angular/upgrade/static';\n\n/**\n * @description\n *\n * Creates an initializer that in addition to setting up the Angular\n * router sets up the ngRoute integration.\n *\n * ```\n * @NgModule({\n * imports: [\n * RouterModule.forRoot(SOME_ROUTES),\n * UpgradeModule\n * ],\n * providers: [\n * RouterUpgradeInitializer\n * ]\n * })\n * export class AppModule {\n * ngDoBootstrap() {}\n * }\n * ```\n *\n * @publicApi\n */\nexport const RouterUpgradeInitializer = {\n provide: APP_BOOTSTRAP_LISTENER,\n multi: true,\n useFactory: locationSyncBootstrapListener as(ngUpgrade: UpgradeModule) => () => void,\n deps: [UpgradeModule]\n};\n\n/**\n * @internal\n */\nexport function locationSyncBootstrapListener(ngUpgrade: UpgradeModule) {\n return () => { setUpLocationSync(ngUpgrade); };\n}\n\n/**\n * @description\n *\n * Sets up a location synchronization.\n *\n * History.pushState does not fire onPopState, so the Angular location\n * doesn't detect it. The workaround is to attach a location change listener\n *\n * @publicApi\n */\nexport function setUpLocationSync(ngUpgrade: UpgradeModule) {\n if (!ngUpgrade.$injector) {\n throw new Error(`\n RouterUpgradeInitializer can be used only after UpgradeModule.bootstrap has been called.\n Remove RouterUpgradeInitializer and call setUpLocationSync after UpgradeModule.bootstrap.\n `);\n }\n\n const router: Router = ngUpgrade.injector.get(Router);\n const location: Location = ngUpgrade.injector.get(Location);\n\n ngUpgrade.$injector.get('$rootScope')\n .$on('$locationChangeStart', (_: any, next: string, __: string) => {\n const url = resolveUrl(next);\n const path = location.normalize(url.pathname);\n router.navigateByUrl(path + url.search + url.hash);\n });\n}\n\n/**\n * Normalize and parse a URL.\n *\n * - Normalizing means that a relative URL will be resolved into an absolute URL in the context of\n * the application document.\n * - Parsing means that the anchor's `protocol`, `hostname`, `port`, `pathname` and related\n * properties are all populated to reflect the normalized URL.\n *\n * While this approach has wide compatibility, it doesn't work as expected on IE. On IE, normalizing\n * happens similar to other browsers, but the parsed components will not be set. (E.g. if you assign\n * `a.href = 'foo'`, then `a.protocol`, `a.host`, etc. will not be correctly updated.)\n * We work around that by performing the parsing in a 2nd step by taking a previously normalized URL\n * and assigning it again. This correctly populates all properties.\n *\n * See\n * https://github.com/angular/angular.js/blob/2c7400e7d07b0f6cec1817dab40b9250ce8ebce6/src/ng/urlUtils.js#L26-L33\n * for more info.\n */\nlet anchor: HTMLAnchorElement|undefined;\nfunction resolveUrl(url: string): {pathname: string, search: string, hash: string} {\n if (!anchor) {\n anchor = document.createElement('a');\n }\n\n anchor.setAttribute('href', url);\n anchor.setAttribute('href', anchor.href);\n\n return {\n // IE does not start `pathname` with `/` like other browsers.\n pathname: `/${anchor.pathname.replace(/^\\//, '')}`,\n search: anchor.search,\n hash: anchor.hash\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upgrade.js","sources":["../npm_package.es6/packages/packages/router/upgrade/src/upgrade.ts","../npm_package.es6/packages/router/upgrade/upgrade.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {Location} from '@angular/common';\nimport {APP_BOOTSTRAP_LISTENER, ComponentRef, InjectionToken} from '@angular/core';\nimport {Router} from '@angular/router';\nimport {UpgradeModule} from '@angular/upgrade/static';\n\n/**\n * @description\n *\n * Creates an initializer that in addition to setting up the Angular\n * router sets up the ngRoute integration.\n *\n * ```\n * @NgModule({\n * imports: [\n * RouterModule.forRoot(SOME_ROUTES),\n * UpgradeModule\n * ],\n * providers: [\n * RouterUpgradeInitializer\n * ]\n * })\n * export class AppModule {\n * ngDoBootstrap() {}\n * }\n * ```\n *\n * @publicApi\n */\nexport const RouterUpgradeInitializer = {\n provide: APP_BOOTSTRAP_LISTENER,\n multi: true,\n useFactory: locationSyncBootstrapListener as(ngUpgrade: UpgradeModule) => () => void,\n deps: [UpgradeModule]\n};\n\n/**\n * @internal\n */\nexport function locationSyncBootstrapListener(ngUpgrade: UpgradeModule) {\n return () => { setUpLocationSync(ngUpgrade); };\n}\n\n/**\n * @description\n *\n * Sets up a location synchronization.\n *\n * History.pushState does not fire onPopState, so the Angular location\n * doesn't detect it. The workaround is to attach a location change listener\n *\n * @publicApi\n */\nexport function setUpLocationSync(ngUpgrade: UpgradeModule) {\n if (!ngUpgrade.$injector) {\n throw new Error(`\n RouterUpgradeInitializer can be used only after UpgradeModule.bootstrap has been called.\n Remove RouterUpgradeInitializer and call setUpLocationSync after UpgradeModule.bootstrap.\n `);\n }\n\n const router: Router = ngUpgrade.injector.get(Router);\n const location: Location = ngUpgrade.injector.get(Location);\n\n ngUpgrade.$injector.get('$rootScope')\n .$on('$locationChangeStart', (_: any, next: string, __: string) => {\n const url = resolveUrl(next);\n const path = location.normalize(url.pathname);\n router.navigateByUrl(path + url.search + url.hash);\n });\n}\n\n/**\n * Normalize and parse a URL.\n *\n * - Normalizing means that a relative URL will be resolved into an absolute URL in the context of\n * the application document.\n * - Parsing means that the anchor's `protocol`, `hostname`, `port`, `pathname` and related\n * properties are all populated to reflect the normalized URL.\n *\n * While this approach has wide compatibility, it doesn't work as expected on IE. On IE, normalizing\n * happens similar to other browsers, but the parsed components will not be set. (E.g. if you assign\n * `a.href = 'foo'`, then `a.protocol`, `a.host`, etc. will not be correctly updated.)\n * We work around that by performing the parsing in a 2nd step by taking a previously normalized URL\n * and assigning it again. This correctly populates all properties.\n *\n * See\n * https://github.com/angular/angular.js/blob/2c7400e7d07b0f6cec1817dab40b9250ce8ebce6/src/ng/urlUtils.js#L26-L33\n * for more info.\n */\nlet anchor: HTMLAnchorElement|undefined;\nfunction resolveUrl(url: string): {pathname: string, search: string, hash: string} {\n if (!anchor) {\n anchor = document.createElement('a');\n }\n\n anchor.setAttribute('href', url);\n anchor.setAttribute('href', anchor.href);\n\n return {\n // IE does not start `pathname` with `/` like other browsers.\n pathname: `/${anchor.pathname.replace(/^\\//, '')}`,\n search: anchor.search,\n hash: anchor.hash\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,wBAAwB,GAAG;IACtC,OAAO,EAAE,sBAAsB;IAC/B,KAAK,EAAE,IAAI;IACX,UAAU,qBAAE,6BAA6B,EAA2C;IACpF,IAAI,EAAE,CAAC,aAAa,CAAC;CACtB;;;;;;AAKD,SAAgB,6BAA6B,CAAC,SAAwB;IACpE,OAAO,QAAQ,iBAAiB,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;CAChD;;;;;;;;;;;;;AAYD,SAAgB,iBAAiB,CAAC,SAAwB;IACxD,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC;;;OAGb,CAAC,CAAC;KACN;;UAEK,MAAM,GAAW,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC;;UAC/C,QAAQ,GAAa,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC;IAE3D,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC;SAChC,GAAG,CAAC,sBAAsB,EAAE,CAAC,CAAM,EAAE,IAAY,EAAE,EAAU;;cACtD,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC;;cACtB,IAAI,GAAG,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC7C,MAAM,CAAC,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;KACpD,CAAC,CAAC;CACR;;;;;;;;;;;;;;;;;;;;IAoBG,MAAmC;;;;;AACvC,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;KACtC;IAED,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAEzC,OAAO;;QAEL,QAAQ,EAAE,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE;QAClD,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,IAAI,EAAE,MAAM,CAAC,IAAI;KAClB,CAAC;CACH;;;;;;;;;;;;AChHD;;GAEG;;;;"}
|
package/fesm5/router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v7.2.0
|
|
2
|
+
* @license Angular v7.2.0
|
|
3
3
|
* (c) 2010-2018 Google, Inc. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -2940,9 +2940,15 @@ function getRouteGuards(futureNode, currNode, parentContexts, futurePath, checks
|
|
|
2940
2940
|
return checks;
|
|
2941
2941
|
}
|
|
2942
2942
|
function shouldRunGuardsAndResolvers(curr, future, mode) {
|
|
2943
|
+
if (typeof mode === 'function') {
|
|
2944
|
+
return mode(curr, future);
|
|
2945
|
+
}
|
|
2943
2946
|
switch (mode) {
|
|
2944
2947
|
case 'pathParamsChange':
|
|
2945
2948
|
return !equalPath(curr.url, future.url);
|
|
2949
|
+
case 'pathParamsOrQueryParamsChange':
|
|
2950
|
+
return !equalPath(curr.url, future.url) ||
|
|
2951
|
+
!shallowEqual(curr.queryParams, future.queryParams);
|
|
2946
2952
|
case 'always':
|
|
2947
2953
|
return true;
|
|
2948
2954
|
case 'paramsOrQueryParamsChange':
|
|
@@ -3694,6 +3700,8 @@ var Router = /** @class */ (function () {
|
|
|
3694
3700
|
this.rootContexts = rootContexts;
|
|
3695
3701
|
this.location = location;
|
|
3696
3702
|
this.config = config;
|
|
3703
|
+
this.lastSuccessfulNavigation = null;
|
|
3704
|
+
this.currentNavigation = null;
|
|
3697
3705
|
this.navigationId = 0;
|
|
3698
3706
|
this.isNgZoneEnabled = false;
|
|
3699
3707
|
this.events = new Subject();
|
|
@@ -3782,7 +3790,7 @@ var Router = /** @class */ (function () {
|
|
|
3782
3790
|
reject: null,
|
|
3783
3791
|
promise: Promise.resolve(true),
|
|
3784
3792
|
source: 'imperative',
|
|
3785
|
-
|
|
3793
|
+
restoredState: null,
|
|
3786
3794
|
currentSnapshot: this.routerState.snapshot,
|
|
3787
3795
|
targetSnapshot: null,
|
|
3788
3796
|
currentRouterState: this.routerState,
|
|
@@ -3799,6 +3807,18 @@ var Router = /** @class */ (function () {
|
|
|
3799
3807
|
return transitions.pipe(filter(function (t) { return t.id !== 0; }),
|
|
3800
3808
|
// Extract URL
|
|
3801
3809
|
map(function (t) { return (__assign({}, t, { extractedUrl: _this.urlHandlingStrategy.extract(t.rawUrl) })); }),
|
|
3810
|
+
// Store the Navigation object
|
|
3811
|
+
tap(function (t) {
|
|
3812
|
+
_this.currentNavigation = {
|
|
3813
|
+
id: t.id,
|
|
3814
|
+
initialUrl: t.currentRawUrl,
|
|
3815
|
+
extractedUrl: t.extractedUrl,
|
|
3816
|
+
trigger: t.source,
|
|
3817
|
+
extras: t.extras,
|
|
3818
|
+
previousNavigation: _this.lastSuccessfulNavigation ? __assign({}, _this.lastSuccessfulNavigation, { previousNavigation: null }) :
|
|
3819
|
+
null
|
|
3820
|
+
};
|
|
3821
|
+
}),
|
|
3802
3822
|
// Using switchMap so we cancel executing navigations when a new one comes in
|
|
3803
3823
|
switchMap(function (t) {
|
|
3804
3824
|
var completed = false;
|
|
@@ -3809,13 +3829,10 @@ var Router = /** @class */ (function () {
|
|
|
3809
3829
|
_this.urlHandlingStrategy.shouldProcessUrl(t.rawUrl);
|
|
3810
3830
|
if (processCurrentUrl) {
|
|
3811
3831
|
return of(t).pipe(
|
|
3812
|
-
// Update URL if in `eager` update mode
|
|
3813
|
-
tap(function (t) { return _this.urlUpdateStrategy === 'eager' && !t.extras.skipLocationChange &&
|
|
3814
|
-
_this.setBrowserUrl(t.rawUrl, !!t.extras.replaceUrl, t.id); }),
|
|
3815
3832
|
// Fire NavigationStart event
|
|
3816
3833
|
switchMap(function (t) {
|
|
3817
3834
|
var transition = _this.transitions.getValue();
|
|
3818
|
-
eventsSubject.next(new NavigationStart(t.id, _this.serializeUrl(t.extractedUrl), t.source, t.
|
|
3835
|
+
eventsSubject.next(new NavigationStart(t.id, _this.serializeUrl(t.extractedUrl), t.source, t.restoredState));
|
|
3819
3836
|
if (transition !== _this.transitions.getValue()) {
|
|
3820
3837
|
return EMPTY;
|
|
3821
3838
|
}
|
|
@@ -3826,8 +3843,15 @@ var Router = /** @class */ (function () {
|
|
|
3826
3843
|
switchMap(function (t) { return Promise.resolve(t); }),
|
|
3827
3844
|
// ApplyRedirects
|
|
3828
3845
|
applyRedirects$1(_this.ngModule.injector, _this.configLoader, _this.urlSerializer, _this.config),
|
|
3846
|
+
// Update the currentNavigation
|
|
3847
|
+
tap(function (t) {
|
|
3848
|
+
_this.currentNavigation = __assign({}, _this.currentNavigation, { finalUrl: t.urlAfterRedirects });
|
|
3849
|
+
}),
|
|
3829
3850
|
// Recognize
|
|
3830
3851
|
recognize$1(_this.rootComponentType, _this.config, function (url) { return _this.serializeUrl(url); }, _this.paramsInheritanceStrategy, _this.relativeLinkResolution),
|
|
3852
|
+
// Update URL if in `eager` update mode
|
|
3853
|
+
tap(function (t) { return _this.urlUpdateStrategy === 'eager' && !t.extras.skipLocationChange &&
|
|
3854
|
+
_this.setBrowserUrl(t.urlAfterRedirects, !!t.extras.replaceUrl, t.id); }),
|
|
3831
3855
|
// Fire RoutesRecognized
|
|
3832
3856
|
tap(function (t) {
|
|
3833
3857
|
var routesRecognized = new RoutesRecognized(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
|
|
@@ -3841,8 +3865,8 @@ var Router = /** @class */ (function () {
|
|
|
3841
3865
|
* handle this "error condition" by navigating to the previously successful URL,
|
|
3842
3866
|
* but leaving the URL intact.*/
|
|
3843
3867
|
if (processPreviousUrl) {
|
|
3844
|
-
var id = t.id, extractedUrl = t.extractedUrl, source = t.source,
|
|
3845
|
-
var navStart = new NavigationStart(id, _this.serializeUrl(extractedUrl), source,
|
|
3868
|
+
var id = t.id, extractedUrl = t.extractedUrl, source = t.source, restoredState = t.restoredState, extras = t.extras;
|
|
3869
|
+
var navStart = new NavigationStart(id, _this.serializeUrl(extractedUrl), source, restoredState);
|
|
3846
3870
|
eventsSubject.next(navStart);
|
|
3847
3871
|
var targetSnapshot = createEmptyState(extractedUrl, _this.rootComponentType).snapshot;
|
|
3848
3872
|
return of(__assign({}, t, { targetSnapshot: targetSnapshot, urlAfterRedirects: extractedUrl, extras: __assign({}, extras, { skipLocationChange: false, replaceUrl: false }) }));
|
|
@@ -3930,7 +3954,7 @@ var Router = /** @class */ (function () {
|
|
|
3930
3954
|
_this.rawUrlTree = _this.urlHandlingStrategy.merge(_this.currentUrlTree, t.rawUrl);
|
|
3931
3955
|
_this.routerState = t.targetRouterState;
|
|
3932
3956
|
if (_this.urlUpdateStrategy === 'deferred' && !t.extras.skipLocationChange) {
|
|
3933
|
-
_this.setBrowserUrl(_this.rawUrlTree, !!t.extras.replaceUrl, t.id);
|
|
3957
|
+
_this.setBrowserUrl(_this.rawUrlTree, !!t.extras.replaceUrl, t.id, t.extras.state);
|
|
3934
3958
|
}
|
|
3935
3959
|
}), activateRoutes(_this.rootContexts, _this.routeReuseStrategy, function (evt) { return _this.triggerEvent(evt); }), tap({ next: function () { completed = true; }, complete: function () { completed = true; } }), finalize(function () {
|
|
3936
3960
|
/* When the navigation stream finishes either through error or success, we set the
|
|
@@ -3950,6 +3974,10 @@ var Router = /** @class */ (function () {
|
|
|
3950
3974
|
eventsSubject.next(navCancel);
|
|
3951
3975
|
t.resolve(false);
|
|
3952
3976
|
}
|
|
3977
|
+
// currentNavigation should always be reset to null here. If navigation was
|
|
3978
|
+
// successful, lastSuccessfulTransition will have already been set. Therefore we
|
|
3979
|
+
// can safely set currentNavigation to null here.
|
|
3980
|
+
_this.currentNavigation = null;
|
|
3953
3981
|
}), catchError(function (e) {
|
|
3954
3982
|
errored = true;
|
|
3955
3983
|
/* This error type is issued during Redirect, and is handled as a cancellation
|
|
@@ -4020,9 +4048,9 @@ var Router = /** @class */ (function () {
|
|
|
4020
4048
|
this.locationSubscription = this.location.subscribe(function (change) {
|
|
4021
4049
|
var rawUrlTree = _this.parseUrl(change['url']);
|
|
4022
4050
|
var source = change['type'] === 'popstate' ? 'popstate' : 'hashchange';
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4051
|
+
// Navigations coming from Angular router have a navigationId state property. When this
|
|
4052
|
+
// exists, restore the state.
|
|
4053
|
+
var state = change.state && change.state.navigationId ? change.state : null;
|
|
4026
4054
|
setTimeout(function () { _this.scheduleNavigation(rawUrlTree, source, state, { replaceUrl: true }); }, 0);
|
|
4027
4055
|
});
|
|
4028
4056
|
}
|
|
@@ -4033,6 +4061,8 @@ var Router = /** @class */ (function () {
|
|
|
4033
4061
|
enumerable: true,
|
|
4034
4062
|
configurable: true
|
|
4035
4063
|
});
|
|
4064
|
+
/** The current Navigation object if one exists */
|
|
4065
|
+
Router.prototype.getCurrentNavigation = function () { return this.currentNavigation; };
|
|
4036
4066
|
/** @internal */
|
|
4037
4067
|
Router.prototype.triggerEvent = function (event) { this.events.next(event); };
|
|
4038
4068
|
/**
|
|
@@ -4194,6 +4224,11 @@ var Router = /** @class */ (function () {
|
|
|
4194
4224
|
* The first parameter of `navigate()` is a delta to be applied to the current URL
|
|
4195
4225
|
* or the one provided in the `relativeTo` property of the second parameter (the
|
|
4196
4226
|
* `NavigationExtras`).
|
|
4227
|
+
*
|
|
4228
|
+
* In order to affect this browser's `history.state` entry, the `state`
|
|
4229
|
+
* parameter can be passed. This must be an object because the router
|
|
4230
|
+
* will add the `navigationId` property to this object before creating
|
|
4231
|
+
* the new history item.
|
|
4197
4232
|
*/
|
|
4198
4233
|
Router.prototype.navigate = function (commands, extras) {
|
|
4199
4234
|
if (extras === void 0) { extras = { skipLocationChange: false }; }
|
|
@@ -4237,10 +4272,12 @@ var Router = /** @class */ (function () {
|
|
|
4237
4272
|
_this.lastSuccessfulId = t.id;
|
|
4238
4273
|
_this.events
|
|
4239
4274
|
.next(new NavigationEnd(t.id, _this.serializeUrl(t.extractedUrl), _this.serializeUrl(_this.currentUrlTree)));
|
|
4275
|
+
_this.lastSuccessfulNavigation = _this.currentNavigation;
|
|
4276
|
+
_this.currentNavigation = null;
|
|
4240
4277
|
t.resolve(true);
|
|
4241
4278
|
}, function (e) { _this.console.warn("Unhandled Navigation Error: "); });
|
|
4242
4279
|
};
|
|
4243
|
-
Router.prototype.scheduleNavigation = function (rawUrl, source,
|
|
4280
|
+
Router.prototype.scheduleNavigation = function (rawUrl, source, restoredState, extras) {
|
|
4244
4281
|
var lastNavigation = this.getTransition();
|
|
4245
4282
|
// If the user triggers a navigation imperatively (e.g., by using navigateByUrl),
|
|
4246
4283
|
// and that navigation results in 'replaceState' that leads to the same URL,
|
|
@@ -4273,7 +4310,7 @@ var Router = /** @class */ (function () {
|
|
|
4273
4310
|
this.setTransition({
|
|
4274
4311
|
id: id,
|
|
4275
4312
|
source: source,
|
|
4276
|
-
|
|
4313
|
+
restoredState: restoredState,
|
|
4277
4314
|
currentUrlTree: this.currentUrlTree,
|
|
4278
4315
|
currentRawUrl: this.rawUrlTree, rawUrl: rawUrl, extras: extras, resolve: resolve, reject: reject, promise: promise,
|
|
4279
4316
|
currentSnapshot: this.routerState.snapshot,
|
|
@@ -4283,13 +4320,15 @@ var Router = /** @class */ (function () {
|
|
|
4283
4320
|
// handler does not rethrow
|
|
4284
4321
|
return promise.catch(function (e) { return Promise.reject(e); });
|
|
4285
4322
|
};
|
|
4286
|
-
Router.prototype.setBrowserUrl = function (url, replaceUrl, id) {
|
|
4323
|
+
Router.prototype.setBrowserUrl = function (url, replaceUrl, id, state) {
|
|
4287
4324
|
var path = this.urlSerializer.serialize(url);
|
|
4325
|
+
state = state || {};
|
|
4288
4326
|
if (this.location.isCurrentPathEqualTo(path) || replaceUrl) {
|
|
4289
|
-
|
|
4327
|
+
// TODO(jasonaden): Remove first `navigationId` and rely on `ng` namespace.
|
|
4328
|
+
this.location.replaceState(path, '', __assign({}, state, { navigationId: id }));
|
|
4290
4329
|
}
|
|
4291
4330
|
else {
|
|
4292
|
-
this.location.go(path, '', { navigationId: id });
|
|
4331
|
+
this.location.go(path, '', __assign({}, state, { navigationId: id }));
|
|
4293
4332
|
}
|
|
4294
4333
|
};
|
|
4295
4334
|
Router.prototype.resetStateAndUrl = function (storedState, storedUrl, rawUrl) {
|
|
@@ -4379,6 +4418,27 @@ function validateCommands(commands) {
|
|
|
4379
4418
|
* </a>
|
|
4380
4419
|
* ```
|
|
4381
4420
|
*
|
|
4421
|
+
* You can provide a `state` value to be persisted to the browser's History.state
|
|
4422
|
+
* property (See https://developer.mozilla.org/en-US/docs/Web/API/History#Properties). It's
|
|
4423
|
+
* used as follows:
|
|
4424
|
+
*
|
|
4425
|
+
* ```
|
|
4426
|
+
* <a [routerLink]="['/user/bob']" [state]="{tracingId: 123}">
|
|
4427
|
+
* link to user component
|
|
4428
|
+
* </a>
|
|
4429
|
+
* ```
|
|
4430
|
+
*
|
|
4431
|
+
* And later the value can be read from the router through `router.getCurrentNavigation`.
|
|
4432
|
+
* For example, to capture the `tracingId` above during the `NavigationStart` event:
|
|
4433
|
+
*
|
|
4434
|
+
* ```
|
|
4435
|
+
* // Get NavigationStart events
|
|
4436
|
+
* router.events.pipe(filter(e => e instanceof NavigationStart)).subscribe(e => {
|
|
4437
|
+
* const navigation = router.getCurrentNavigation();
|
|
4438
|
+
* tracingService.trace({id: navigation.extras.state.tracingId});
|
|
4439
|
+
* });
|
|
4440
|
+
* ```
|
|
4441
|
+
*
|
|
4382
4442
|
* The router link directive always treats the provided input as a delta to the current url.
|
|
4383
4443
|
*
|
|
4384
4444
|
* For instance, if the current url is `/user/(box//aux:team)`.
|
|
@@ -4472,6 +4532,10 @@ var RouterLink = /** @class */ (function () {
|
|
|
4472
4532
|
Input(),
|
|
4473
4533
|
__metadata("design:type", Boolean)
|
|
4474
4534
|
], RouterLink.prototype, "replaceUrl", void 0);
|
|
4535
|
+
__decorate([
|
|
4536
|
+
Input(),
|
|
4537
|
+
__metadata("design:type", Object)
|
|
4538
|
+
], RouterLink.prototype, "state", void 0);
|
|
4475
4539
|
__decorate([
|
|
4476
4540
|
Input(),
|
|
4477
4541
|
__metadata("design:type", Object),
|
|
@@ -4553,6 +4617,7 @@ var RouterLinkWithHref = /** @class */ (function () {
|
|
|
4553
4617
|
var extras = {
|
|
4554
4618
|
skipLocationChange: attrBoolValue(this.skipLocationChange),
|
|
4555
4619
|
replaceUrl: attrBoolValue(this.replaceUrl),
|
|
4620
|
+
state: this.state
|
|
4556
4621
|
};
|
|
4557
4622
|
this.router.navigateByUrl(this.urlTree, extras);
|
|
4558
4623
|
return false;
|
|
@@ -4602,6 +4667,10 @@ var RouterLinkWithHref = /** @class */ (function () {
|
|
|
4602
4667
|
Input(),
|
|
4603
4668
|
__metadata("design:type", Boolean)
|
|
4604
4669
|
], RouterLinkWithHref.prototype, "replaceUrl", void 0);
|
|
4670
|
+
__decorate([
|
|
4671
|
+
Input(),
|
|
4672
|
+
__metadata("design:type", Object)
|
|
4673
|
+
], RouterLinkWithHref.prototype, "state", void 0);
|
|
4605
4674
|
__decorate([
|
|
4606
4675
|
HostBinding(),
|
|
4607
4676
|
__metadata("design:type", String)
|
|
@@ -5633,7 +5702,7 @@ function provideRouterInitializer() {
|
|
|
5633
5702
|
/**
|
|
5634
5703
|
* @publicApi
|
|
5635
5704
|
*/
|
|
5636
|
-
var VERSION = new Version('7.2.0
|
|
5705
|
+
var VERSION = new Version('7.2.0');
|
|
5637
5706
|
|
|
5638
5707
|
/**
|
|
5639
5708
|
* @license
|