@angular/router 12.2.8 → 13.0.0-next.11
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/{esm2015/index.js → esm2020/index.mjs} +0 -0
- package/{esm2015/public_api.js → esm2020/public_api.mjs} +0 -0
- package/esm2020/router.mjs +5 -0
- package/{esm2015/src/apply_redirects.js → esm2020/src/apply_redirects.mjs} +0 -0
- package/esm2020/src/components/empty_outlet.mjs +29 -0
- package/esm2020/src/config.mjs +14 -0
- package/{esm2015/src/create_router_state.js → esm2020/src/create_router_state.mjs} +0 -0
- package/{esm2015/src/create_url_tree.js → esm2020/src/create_url_tree.mjs} +0 -0
- package/esm2020/src/directives/router_link.mjs +353 -0
- package/esm2020/src/directives/router_link_active.mjs +215 -0
- package/esm2020/src/directives/router_outlet.mjs +219 -0
- package/{esm2015/src/events.js → esm2020/src/events.mjs} +0 -0
- package/{esm2015/src/index.js → esm2020/src/index.mjs} +1 -1
- package/{esm2015/src/interfaces.js → esm2020/src/interfaces.mjs} +1 -1
- package/{esm2015/src/operators/activate_routes.js → esm2020/src/operators/activate_routes.mjs} +0 -0
- package/esm2020/src/operators/apply_redirects.mjs +14 -0
- package/esm2020/src/operators/check_guards.mjs +138 -0
- package/{esm2015/src/operators/prioritized_guard_value.js → esm2020/src/operators/prioritized_guard_value.mjs} +0 -0
- package/esm2020/src/operators/recognize.mjs +14 -0
- package/esm2020/src/operators/resolve_data.mjs +59 -0
- package/{esm2015/src/operators/switch_tap.js → esm2020/src/operators/switch_tap.mjs} +0 -0
- package/{esm2015/src/private_export.js → esm2020/src/private_export.mjs} +0 -0
- package/esm2020/src/recognize.mjs +262 -0
- package/{esm2015/src/route_reuse_strategy.js → esm2020/src/route_reuse_strategy.mjs} +0 -0
- package/esm2020/src/router.mjs +1009 -0
- package/esm2020/src/router_config_loader.mjs +71 -0
- package/esm2020/src/router_module.mjs +367 -0
- package/{esm2015/src/router_outlet_context.js → esm2020/src/router_outlet_context.mjs} +0 -0
- package/esm2020/src/router_preloader.mjs +127 -0
- package/esm2020/src/router_scroller.mjs +95 -0
- package/esm2020/src/router_state.mjs +404 -0
- package/{esm2015/src/shared.js → esm2020/src/shared.mjs} +0 -0
- package/{esm2015/src/url_handling_strategy.js → esm2020/src/url_handling_strategy.mjs} +0 -0
- package/{esm2015/src/url_tree.js → esm2020/src/url_tree.mjs} +2 -2
- package/{esm2015/src/utils/collection.js → esm2020/src/utils/collection.mjs} +0 -0
- package/{esm2015/src/utils/config.js → esm2020/src/utils/config.mjs} +2 -2
- package/esm2020/src/utils/config_matching.mjs +145 -0
- package/{esm2015/src/utils/preactivation.js → esm2020/src/utils/preactivation.mjs} +0 -0
- package/{esm2015/src/utils/tree.js → esm2020/src/utils/tree.mjs} +0 -0
- package/{esm2015/src/utils/type_guards.js → esm2020/src/utils/type_guards.mjs} +0 -0
- package/{esm2015/src/version.js → esm2020/src/version.mjs} +1 -1
- package/{esm2015/testing/index.js → esm2020/testing/index.mjs} +0 -0
- package/{esm2015/testing/public_api.js → esm2020/testing/public_api.mjs} +0 -0
- package/esm2020/testing/src/extra_router_testing_providers.mjs +10 -0
- package/esm2020/testing/src/router_testing_module.mjs +122 -0
- package/esm2020/testing/src/spy_ng_module_factory_loader.mjs +10 -0
- package/esm2020/testing/src/testing.mjs +15 -0
- package/{esm2015/testing/testing.js → esm2020/testing/testing.mjs} +0 -0
- package/{esm2015/upgrade/index.js → esm2020/upgrade/index.mjs} +0 -0
- package/{esm2015/upgrade/public_api.js → esm2020/upgrade/public_api.mjs} +0 -0
- package/esm2020/upgrade/src/upgrade.mjs +120 -0
- package/{esm2015/upgrade/upgrade.js → esm2020/upgrade/upgrade.mjs} +0 -0
- package/fesm2015/{router.js → router.mjs} +593 -588
- package/fesm2015/router.mjs.map +1 -0
- package/fesm2015/testing.mjs +179 -0
- package/fesm2015/testing.mjs.map +1 -0
- package/fesm2015/{upgrade.js → upgrade.mjs} +4 -5
- package/fesm2015/upgrade.mjs.map +1 -0
- package/fesm2020/router.mjs +6162 -0
- package/fesm2020/router.mjs.map +1 -0
- package/fesm2020/testing.mjs +179 -0
- package/fesm2020/testing.mjs.map +1 -0
- package/fesm2020/upgrade.mjs +150 -0
- package/fesm2020/upgrade.mjs.map +1 -0
- package/package.json +34 -10
- package/router.d.ts +149 -140
- package/testing/package.json +5 -5
- package/testing/testing.d.ts +9 -66
- package/upgrade/package.json +5 -5
- package/upgrade/upgrade.d.ts +1 -1
- package/bundles/router-testing.umd.js +0 -541
- package/bundles/router-testing.umd.js.map +0 -1
- package/bundles/router-upgrade.umd.js +0 -157
- package/bundles/router-upgrade.umd.js.map +0 -1
- package/bundles/router.umd.js +0 -6879
- package/bundles/router.umd.js.map +0 -1
- package/esm2015/router.externs.js +0 -6
- package/esm2015/router.js +0 -9
- package/esm2015/src/components/empty_outlet.js +0 -24
- package/esm2015/src/config.js +0 -14
- package/esm2015/src/directives/router_link.js +0 -293
- package/esm2015/src/directives/router_link_active.js +0 -190
- package/esm2015/src/directives/router_outlet.js +0 -193
- package/esm2015/src/operators/apply_redirects.js +0 -14
- package/esm2015/src/operators/check_guards.js +0 -138
- package/esm2015/src/operators/recognize.js +0 -14
- package/esm2015/src/operators/resolve_data.js +0 -56
- package/esm2015/src/recognize.js +0 -262
- package/esm2015/src/router.js +0 -1079
- package/esm2015/src/router_config_loader.js +0 -76
- package/esm2015/src/router_module.js +0 -363
- package/esm2015/src/router_preloader.js +0 -130
- package/esm2015/src/router_scroller.js +0 -95
- package/esm2015/src/router_state.js +0 -404
- package/esm2015/src/utils/config_matching.js +0 -145
- package/esm2015/testing/src/router_testing_module.js +0 -166
- package/esm2015/testing/src/testing.js +0 -14
- package/esm2015/testing/testing.externs.js +0 -6
- package/esm2015/upgrade/src/upgrade.js +0 -122
- package/esm2015/upgrade/upgrade.externs.js +0 -6
- package/fesm2015/router.js.map +0 -1
- package/fesm2015/testing.js +0 -204
- package/fesm2015/testing.js.map +0 -1
- package/fesm2015/upgrade.js.map +0 -1
- package/router.metadata.json +0 -1
- package/testing/testing.metadata.json +0 -1
- package/testing.d.ts +0 -7
- package/testing.metadata.json +0 -1
- package/upgrade/upgrade.metadata.json +0 -1
- package/upgrade.d.ts +0 -7
- package/upgrade.metadata.json +0 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular
|
|
2
|
+
* @license Angular v13.0.0-next.11
|
|
3
3
|
* (c) 2010-2021 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import { ɵisObservable, ɵisPromise, Component, NgModuleRef, InjectionToken, InjectFlags, NgModuleFactory, ɵConsole, NgZone, Injectable,
|
|
7
|
+
import * as i0 from '@angular/core';
|
|
8
|
+
import { ɵisObservable, ɵisPromise, EventEmitter, Directive, Attribute, Output, Component, NgModuleRef, InjectionToken, InjectFlags, NgModuleFactory, ɵConsole, NgZone, Injectable, Input, HostListener, HostBinding, Optional, ContentChildren, Injector, Compiler, NgProbeToken, ANALYZE_FOR_ENTRY_COMPONENTS, SkipSelf, Inject, APP_INITIALIZER, APP_BOOTSTRAP_LISTENER, NgModule, ApplicationRef, Version } from '@angular/core';
|
|
9
9
|
import { from, of, BehaviorSubject, combineLatest, Observable, EmptyError, concat, defer, EMPTY, ConnectableObservable, Subject } from 'rxjs';
|
|
10
10
|
import { map, switchMap, take, startWith, scan, filter, catchError, concatMap, last as last$1, first, mergeMap, tap, takeLast, refCount, finalize, mergeAll } from 'rxjs/operators';
|
|
11
|
+
import * as i3 from '@angular/common';
|
|
12
|
+
import { Location, LocationStrategy, PlatformLocation, APP_BASE_HREF, ViewportScroller, HashLocationStrategy, PathLocationStrategy, LOCATION_INITIALIZED } from '@angular/common';
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* @license
|
|
@@ -992,7 +994,7 @@ function matchQueryParams(str) {
|
|
|
992
994
|
const match = str.match(QUERY_PARAM_RE);
|
|
993
995
|
return match ? match[0] : '';
|
|
994
996
|
}
|
|
995
|
-
const QUERY_PARAM_VALUE_RE = /^[
|
|
997
|
+
const QUERY_PARAM_VALUE_RE = /^[^&#]+/;
|
|
996
998
|
// Return the value of the query param at the start of the string or an empty string
|
|
997
999
|
function matchUrlQueryParamValue(str) {
|
|
998
1000
|
const match = str.match(QUERY_PARAM_VALUE_RE);
|
|
@@ -2280,6 +2282,294 @@ function prioritizedGuardValue() {
|
|
|
2280
2282
|
});
|
|
2281
2283
|
}
|
|
2282
2284
|
|
|
2285
|
+
/**
|
|
2286
|
+
* @license
|
|
2287
|
+
* Copyright Google LLC All Rights Reserved.
|
|
2288
|
+
*
|
|
2289
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
2290
|
+
* found in the LICENSE file at https://angular.io/license
|
|
2291
|
+
*/
|
|
2292
|
+
/**
|
|
2293
|
+
* Store contextual information about a `RouterOutlet`
|
|
2294
|
+
*
|
|
2295
|
+
* @publicApi
|
|
2296
|
+
*/
|
|
2297
|
+
class OutletContext {
|
|
2298
|
+
constructor() {
|
|
2299
|
+
this.outlet = null;
|
|
2300
|
+
this.route = null;
|
|
2301
|
+
this.resolver = null;
|
|
2302
|
+
this.children = new ChildrenOutletContexts();
|
|
2303
|
+
this.attachRef = null;
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
/**
|
|
2307
|
+
* Store contextual information about the children (= nested) `RouterOutlet`
|
|
2308
|
+
*
|
|
2309
|
+
* @publicApi
|
|
2310
|
+
*/
|
|
2311
|
+
class ChildrenOutletContexts {
|
|
2312
|
+
constructor() {
|
|
2313
|
+
// contexts for child outlets, by name.
|
|
2314
|
+
this.contexts = new Map();
|
|
2315
|
+
}
|
|
2316
|
+
/** Called when a `RouterOutlet` directive is instantiated */
|
|
2317
|
+
onChildOutletCreated(childName, outlet) {
|
|
2318
|
+
const context = this.getOrCreateContext(childName);
|
|
2319
|
+
context.outlet = outlet;
|
|
2320
|
+
this.contexts.set(childName, context);
|
|
2321
|
+
}
|
|
2322
|
+
/**
|
|
2323
|
+
* Called when a `RouterOutlet` directive is destroyed.
|
|
2324
|
+
* We need to keep the context as the outlet could be destroyed inside a NgIf and might be
|
|
2325
|
+
* re-created later.
|
|
2326
|
+
*/
|
|
2327
|
+
onChildOutletDestroyed(childName) {
|
|
2328
|
+
const context = this.getContext(childName);
|
|
2329
|
+
if (context) {
|
|
2330
|
+
context.outlet = null;
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
/**
|
|
2334
|
+
* Called when the corresponding route is deactivated during navigation.
|
|
2335
|
+
* Because the component get destroyed, all children outlet are destroyed.
|
|
2336
|
+
*/
|
|
2337
|
+
onOutletDeactivated() {
|
|
2338
|
+
const contexts = this.contexts;
|
|
2339
|
+
this.contexts = new Map();
|
|
2340
|
+
return contexts;
|
|
2341
|
+
}
|
|
2342
|
+
onOutletReAttached(contexts) {
|
|
2343
|
+
this.contexts = contexts;
|
|
2344
|
+
}
|
|
2345
|
+
getOrCreateContext(childName) {
|
|
2346
|
+
let context = this.getContext(childName);
|
|
2347
|
+
if (!context) {
|
|
2348
|
+
context = new OutletContext();
|
|
2349
|
+
this.contexts.set(childName, context);
|
|
2350
|
+
}
|
|
2351
|
+
return context;
|
|
2352
|
+
}
|
|
2353
|
+
getContext(childName) {
|
|
2354
|
+
return this.contexts.get(childName) || null;
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
/**
|
|
2359
|
+
* @license
|
|
2360
|
+
* Copyright Google LLC All Rights Reserved.
|
|
2361
|
+
*
|
|
2362
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
2363
|
+
* found in the LICENSE file at https://angular.io/license
|
|
2364
|
+
*/
|
|
2365
|
+
/**
|
|
2366
|
+
* @description
|
|
2367
|
+
*
|
|
2368
|
+
* Acts as a placeholder that Angular dynamically fills based on the current router state.
|
|
2369
|
+
*
|
|
2370
|
+
* Each outlet can have a unique name, determined by the optional `name` attribute.
|
|
2371
|
+
* The name cannot be set or changed dynamically. If not set, default value is "primary".
|
|
2372
|
+
*
|
|
2373
|
+
* ```
|
|
2374
|
+
* <router-outlet></router-outlet>
|
|
2375
|
+
* <router-outlet name='left'></router-outlet>
|
|
2376
|
+
* <router-outlet name='right'></router-outlet>
|
|
2377
|
+
* ```
|
|
2378
|
+
*
|
|
2379
|
+
* Named outlets can be the targets of secondary routes.
|
|
2380
|
+
* The `Route` object for a secondary route has an `outlet` property to identify the target outlet:
|
|
2381
|
+
*
|
|
2382
|
+
* `{path: <base-path>, component: <component>, outlet: <target_outlet_name>}`
|
|
2383
|
+
*
|
|
2384
|
+
* Using named outlets and secondary routes, you can target multiple outlets in
|
|
2385
|
+
* the same `RouterLink` directive.
|
|
2386
|
+
*
|
|
2387
|
+
* The router keeps track of separate branches in a navigation tree for each named outlet and
|
|
2388
|
+
* generates a representation of that tree in the URL.
|
|
2389
|
+
* The URL for a secondary route uses the following syntax to specify both the primary and secondary
|
|
2390
|
+
* routes at the same time:
|
|
2391
|
+
*
|
|
2392
|
+
* `http://base-path/primary-route-path(outlet-name:route-path)`
|
|
2393
|
+
*
|
|
2394
|
+
* A router outlet emits an activate event when a new component is instantiated,
|
|
2395
|
+
* deactivate event when a component is destroyed.
|
|
2396
|
+
* An attached event emits when the `RouteReuseStrategy` instructs the outlet to reattach the
|
|
2397
|
+
* subtree, and the detached event emits when the `RouteReuseStrategy` instructs the outlet to
|
|
2398
|
+
* detach the subtree.
|
|
2399
|
+
*
|
|
2400
|
+
* ```
|
|
2401
|
+
* <router-outlet
|
|
2402
|
+
* (activate)='onActivate($event)'
|
|
2403
|
+
* (deactivate)='onDeactivate($event)'
|
|
2404
|
+
* (attach)='onAttach($event)'
|
|
2405
|
+
* (detach)='onDetach($event)'></router-outlet>
|
|
2406
|
+
* ```
|
|
2407
|
+
*
|
|
2408
|
+
* @see [Routing tutorial](guide/router-tutorial-toh#named-outlets "Example of a named
|
|
2409
|
+
* outlet and secondary route configuration").
|
|
2410
|
+
* @see `RouterLink`
|
|
2411
|
+
* @see `Route`
|
|
2412
|
+
* @ngModule RouterModule
|
|
2413
|
+
*
|
|
2414
|
+
* @publicApi
|
|
2415
|
+
*/
|
|
2416
|
+
class RouterOutlet {
|
|
2417
|
+
constructor(parentContexts, location, resolver, name, changeDetector) {
|
|
2418
|
+
this.parentContexts = parentContexts;
|
|
2419
|
+
this.location = location;
|
|
2420
|
+
this.resolver = resolver;
|
|
2421
|
+
this.changeDetector = changeDetector;
|
|
2422
|
+
this.activated = null;
|
|
2423
|
+
this._activatedRoute = null;
|
|
2424
|
+
this.activateEvents = new EventEmitter();
|
|
2425
|
+
this.deactivateEvents = new EventEmitter();
|
|
2426
|
+
/**
|
|
2427
|
+
* Emits an attached component instance when the `RouteReuseStrategy` instructs to re-attach a
|
|
2428
|
+
* previously detached subtree.
|
|
2429
|
+
**/
|
|
2430
|
+
this.attachEvents = new EventEmitter();
|
|
2431
|
+
/**
|
|
2432
|
+
* Emits a detached component instance when the `RouteReuseStrategy` instructs to detach the
|
|
2433
|
+
* subtree.
|
|
2434
|
+
*/
|
|
2435
|
+
this.detachEvents = new EventEmitter();
|
|
2436
|
+
this.name = name || PRIMARY_OUTLET;
|
|
2437
|
+
parentContexts.onChildOutletCreated(this.name, this);
|
|
2438
|
+
}
|
|
2439
|
+
/** @nodoc */
|
|
2440
|
+
ngOnDestroy() {
|
|
2441
|
+
this.parentContexts.onChildOutletDestroyed(this.name);
|
|
2442
|
+
}
|
|
2443
|
+
/** @nodoc */
|
|
2444
|
+
ngOnInit() {
|
|
2445
|
+
if (!this.activated) {
|
|
2446
|
+
// If the outlet was not instantiated at the time the route got activated we need to populate
|
|
2447
|
+
// the outlet when it is initialized (ie inside a NgIf)
|
|
2448
|
+
const context = this.parentContexts.getContext(this.name);
|
|
2449
|
+
if (context && context.route) {
|
|
2450
|
+
if (context.attachRef) {
|
|
2451
|
+
// `attachRef` is populated when there is an existing component to mount
|
|
2452
|
+
this.attach(context.attachRef, context.route);
|
|
2453
|
+
}
|
|
2454
|
+
else {
|
|
2455
|
+
// otherwise the component defined in the configuration is created
|
|
2456
|
+
this.activateWith(context.route, context.resolver || null);
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
get isActivated() {
|
|
2462
|
+
return !!this.activated;
|
|
2463
|
+
}
|
|
2464
|
+
/**
|
|
2465
|
+
* @returns The currently activated component instance.
|
|
2466
|
+
* @throws An error if the outlet is not activated.
|
|
2467
|
+
*/
|
|
2468
|
+
get component() {
|
|
2469
|
+
if (!this.activated)
|
|
2470
|
+
throw new Error('Outlet is not activated');
|
|
2471
|
+
return this.activated.instance;
|
|
2472
|
+
}
|
|
2473
|
+
get activatedRoute() {
|
|
2474
|
+
if (!this.activated)
|
|
2475
|
+
throw new Error('Outlet is not activated');
|
|
2476
|
+
return this._activatedRoute;
|
|
2477
|
+
}
|
|
2478
|
+
get activatedRouteData() {
|
|
2479
|
+
if (this._activatedRoute) {
|
|
2480
|
+
return this._activatedRoute.snapshot.data;
|
|
2481
|
+
}
|
|
2482
|
+
return {};
|
|
2483
|
+
}
|
|
2484
|
+
/**
|
|
2485
|
+
* Called when the `RouteReuseStrategy` instructs to detach the subtree
|
|
2486
|
+
*/
|
|
2487
|
+
detach() {
|
|
2488
|
+
if (!this.activated)
|
|
2489
|
+
throw new Error('Outlet is not activated');
|
|
2490
|
+
this.location.detach();
|
|
2491
|
+
const cmp = this.activated;
|
|
2492
|
+
this.activated = null;
|
|
2493
|
+
this._activatedRoute = null;
|
|
2494
|
+
this.detachEvents.emit(cmp.instance);
|
|
2495
|
+
return cmp;
|
|
2496
|
+
}
|
|
2497
|
+
/**
|
|
2498
|
+
* Called when the `RouteReuseStrategy` instructs to re-attach a previously detached subtree
|
|
2499
|
+
*/
|
|
2500
|
+
attach(ref, activatedRoute) {
|
|
2501
|
+
this.activated = ref;
|
|
2502
|
+
this._activatedRoute = activatedRoute;
|
|
2503
|
+
this.location.insert(ref.hostView);
|
|
2504
|
+
this.attachEvents.emit(ref.instance);
|
|
2505
|
+
}
|
|
2506
|
+
deactivate() {
|
|
2507
|
+
if (this.activated) {
|
|
2508
|
+
const c = this.component;
|
|
2509
|
+
this.activated.destroy();
|
|
2510
|
+
this.activated = null;
|
|
2511
|
+
this._activatedRoute = null;
|
|
2512
|
+
this.deactivateEvents.emit(c);
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
activateWith(activatedRoute, resolver) {
|
|
2516
|
+
if (this.isActivated) {
|
|
2517
|
+
throw new Error('Cannot activate an already activated outlet');
|
|
2518
|
+
}
|
|
2519
|
+
this._activatedRoute = activatedRoute;
|
|
2520
|
+
const snapshot = activatedRoute._futureSnapshot;
|
|
2521
|
+
const component = snapshot.routeConfig.component;
|
|
2522
|
+
resolver = resolver || this.resolver;
|
|
2523
|
+
const factory = resolver.resolveComponentFactory(component);
|
|
2524
|
+
const childContexts = this.parentContexts.getOrCreateContext(this.name).children;
|
|
2525
|
+
const injector = new OutletInjector(activatedRoute, childContexts, this.location.injector);
|
|
2526
|
+
this.activated = this.location.createComponent(factory, this.location.length, injector);
|
|
2527
|
+
// Calling `markForCheck` to make sure we will run the change detection when the
|
|
2528
|
+
// `RouterOutlet` is inside a `ChangeDetectionStrategy.OnPush` component.
|
|
2529
|
+
this.changeDetector.markForCheck();
|
|
2530
|
+
this.activateEvents.emit(this.activated.instance);
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
RouterOutlet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterOutlet, deps: [{ token: ChildrenOutletContexts }, { token: i0.ViewContainerRef }, { token: i0.ComponentFactoryResolver }, { token: 'name', attribute: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2534
|
+
RouterOutlet.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.11", type: RouterOutlet, selector: "router-outlet", outputs: { activateEvents: "activate", deactivateEvents: "deactivate", attachEvents: "attach", detachEvents: "detach" }, exportAs: ["outlet"], ngImport: i0 });
|
|
2535
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterOutlet, decorators: [{
|
|
2536
|
+
type: Directive,
|
|
2537
|
+
args: [{ selector: 'router-outlet', exportAs: 'outlet' }]
|
|
2538
|
+
}], ctorParameters: function () {
|
|
2539
|
+
return [{ type: ChildrenOutletContexts }, { type: i0.ViewContainerRef }, { type: i0.ComponentFactoryResolver }, { type: undefined, decorators: [{
|
|
2540
|
+
type: Attribute,
|
|
2541
|
+
args: ['name']
|
|
2542
|
+
}] }, { type: i0.ChangeDetectorRef }];
|
|
2543
|
+
}, propDecorators: { activateEvents: [{
|
|
2544
|
+
type: Output,
|
|
2545
|
+
args: ['activate']
|
|
2546
|
+
}], deactivateEvents: [{
|
|
2547
|
+
type: Output,
|
|
2548
|
+
args: ['deactivate']
|
|
2549
|
+
}], attachEvents: [{
|
|
2550
|
+
type: Output,
|
|
2551
|
+
args: ['attach']
|
|
2552
|
+
}], detachEvents: [{
|
|
2553
|
+
type: Output,
|
|
2554
|
+
args: ['detach']
|
|
2555
|
+
}] } });
|
|
2556
|
+
class OutletInjector {
|
|
2557
|
+
constructor(route, childContexts, parent) {
|
|
2558
|
+
this.route = route;
|
|
2559
|
+
this.childContexts = childContexts;
|
|
2560
|
+
this.parent = parent;
|
|
2561
|
+
}
|
|
2562
|
+
get(token, notFoundValue) {
|
|
2563
|
+
if (token === ActivatedRoute) {
|
|
2564
|
+
return this.route;
|
|
2565
|
+
}
|
|
2566
|
+
if (token === ChildrenOutletContexts) {
|
|
2567
|
+
return this.childContexts;
|
|
2568
|
+
}
|
|
2569
|
+
return this.parent.get(token, notFoundValue);
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2283
2573
|
/**
|
|
2284
2574
|
* @license
|
|
2285
2575
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -2298,9 +2588,12 @@ function prioritizedGuardValue() {
|
|
|
2298
2588
|
*/
|
|
2299
2589
|
class ɵEmptyOutletComponent {
|
|
2300
2590
|
}
|
|
2301
|
-
ɵEmptyOutletComponent
|
|
2302
|
-
|
|
2303
|
-
|
|
2591
|
+
ɵEmptyOutletComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: ɵEmptyOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2592
|
+
ɵEmptyOutletComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0-next.11", type: ɵEmptyOutletComponent, selector: "ng-component", ngImport: i0, template: `<router-outlet></router-outlet>`, isInline: true, directives: [{ type: RouterOutlet, selector: "router-outlet", outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] });
|
|
2593
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: ɵEmptyOutletComponent, decorators: [{
|
|
2594
|
+
type: Component,
|
|
2595
|
+
args: [{ template: `<router-outlet></router-outlet>` }]
|
|
2596
|
+
}] });
|
|
2304
2597
|
|
|
2305
2598
|
/**
|
|
2306
2599
|
* @license
|
|
@@ -2428,7 +2721,7 @@ function sortByMatchingOutlets(routes, outletName) {
|
|
|
2428
2721
|
* Use of this source code is governed by an MIT-style license that can be
|
|
2429
2722
|
* found in the LICENSE file at https://angular.io/license
|
|
2430
2723
|
*/
|
|
2431
|
-
const noMatch = {
|
|
2724
|
+
const noMatch$1 = {
|
|
2432
2725
|
matched: false,
|
|
2433
2726
|
consumedSegments: [],
|
|
2434
2727
|
lastChild: 0,
|
|
@@ -2439,7 +2732,7 @@ function match(segmentGroup, route, segments) {
|
|
|
2439
2732
|
var _a;
|
|
2440
2733
|
if (route.path === '') {
|
|
2441
2734
|
if (route.pathMatch === 'full' && (segmentGroup.hasChildren() || segments.length > 0)) {
|
|
2442
|
-
return Object.assign({}, noMatch);
|
|
2735
|
+
return Object.assign({}, noMatch$1);
|
|
2443
2736
|
}
|
|
2444
2737
|
return {
|
|
2445
2738
|
matched: true,
|
|
@@ -2452,7 +2745,7 @@ function match(segmentGroup, route, segments) {
|
|
|
2452
2745
|
const matcher = route.matcher || defaultUrlMatcher;
|
|
2453
2746
|
const res = matcher(segments, segmentGroup, route);
|
|
2454
2747
|
if (!res)
|
|
2455
|
-
return Object.assign({}, noMatch);
|
|
2748
|
+
return Object.assign({}, noMatch$1);
|
|
2456
2749
|
const posParams = {};
|
|
2457
2750
|
forEach(res.posParams, (v, k) => {
|
|
2458
2751
|
posParams[k] = v.path;
|
|
@@ -2569,7 +2862,7 @@ function noLeftoversInUrl(segmentGroup, segments, outlet) {
|
|
|
2569
2862
|
* Use of this source code is governed by an MIT-style license that can be
|
|
2570
2863
|
* found in the LICENSE file at https://angular.io/license
|
|
2571
2864
|
*/
|
|
2572
|
-
class NoMatch {
|
|
2865
|
+
class NoMatch$1 {
|
|
2573
2866
|
constructor(segmentGroup) {
|
|
2574
2867
|
this.segmentGroup = segmentGroup || null;
|
|
2575
2868
|
}
|
|
@@ -2579,8 +2872,8 @@ class AbsoluteRedirect {
|
|
|
2579
2872
|
this.urlTree = urlTree;
|
|
2580
2873
|
}
|
|
2581
2874
|
}
|
|
2582
|
-
function noMatch
|
|
2583
|
-
return new Observable((obs) => obs.error(new NoMatch(segmentGroup)));
|
|
2875
|
+
function noMatch(segmentGroup) {
|
|
2876
|
+
return new Observable((obs) => obs.error(new NoMatch$1(segmentGroup)));
|
|
2584
2877
|
}
|
|
2585
2878
|
function absoluteRedirect(newTree) {
|
|
2586
2879
|
return new Observable((obs) => obs.error(new AbsoluteRedirect(newTree)));
|
|
@@ -2596,7 +2889,7 @@ function canLoadFails(route) {
|
|
|
2596
2889
|
*
|
|
2597
2890
|
* Lazy modules are loaded along the way.
|
|
2598
2891
|
*/
|
|
2599
|
-
function applyRedirects(moduleInjector, configLoader, urlSerializer, urlTree, config) {
|
|
2892
|
+
function applyRedirects$1(moduleInjector, configLoader, urlSerializer, urlTree, config) {
|
|
2600
2893
|
return new ApplyRedirects(moduleInjector, configLoader, urlSerializer, urlTree, config).apply();
|
|
2601
2894
|
}
|
|
2602
2895
|
class ApplyRedirects {
|
|
@@ -2629,7 +2922,7 @@ class ApplyRedirects {
|
|
|
2629
2922
|
// we need to run matching, so we can fetch all lazy-loaded modules
|
|
2630
2923
|
return this.match(e.urlTree);
|
|
2631
2924
|
}
|
|
2632
|
-
if (e instanceof NoMatch) {
|
|
2925
|
+
if (e instanceof NoMatch$1) {
|
|
2633
2926
|
throw this.noMatchError(e);
|
|
2634
2927
|
}
|
|
2635
2928
|
throw e;
|
|
@@ -2641,7 +2934,7 @@ class ApplyRedirects {
|
|
|
2641
2934
|
return this.createUrlTree(squashSegmentGroup(rootSegmentGroup), tree.queryParams, tree.fragment);
|
|
2642
2935
|
}));
|
|
2643
2936
|
return mapped$.pipe(catchError((e) => {
|
|
2644
|
-
if (e instanceof NoMatch) {
|
|
2937
|
+
if (e instanceof NoMatch$1) {
|
|
2645
2938
|
throw this.noMatchError(e);
|
|
2646
2939
|
}
|
|
2647
2940
|
throw e;
|
|
@@ -2694,7 +2987,7 @@ class ApplyRedirects {
|
|
|
2694
2987
|
return from(routes).pipe(concatMap((r) => {
|
|
2695
2988
|
const expanded$ = this.expandSegmentAgainstRoute(ngModule, segmentGroup, routes, r, segments, outlet, allowRedirects);
|
|
2696
2989
|
return expanded$.pipe(catchError((e) => {
|
|
2697
|
-
if (e instanceof NoMatch) {
|
|
2990
|
+
if (e instanceof NoMatch$1) {
|
|
2698
2991
|
return of(null);
|
|
2699
2992
|
}
|
|
2700
2993
|
throw e;
|
|
@@ -2704,14 +2997,14 @@ class ApplyRedirects {
|
|
|
2704
2997
|
if (noLeftoversInUrl(segmentGroup, segments, outlet)) {
|
|
2705
2998
|
return of(new UrlSegmentGroup([], {}));
|
|
2706
2999
|
}
|
|
2707
|
-
throw new NoMatch(segmentGroup);
|
|
3000
|
+
throw new NoMatch$1(segmentGroup);
|
|
2708
3001
|
}
|
|
2709
3002
|
throw e;
|
|
2710
3003
|
}));
|
|
2711
3004
|
}
|
|
2712
3005
|
expandSegmentAgainstRoute(ngModule, segmentGroup, routes, route, paths, outlet, allowRedirects) {
|
|
2713
3006
|
if (!isImmediateMatch(route, segmentGroup, paths, outlet)) {
|
|
2714
|
-
return noMatch
|
|
3007
|
+
return noMatch(segmentGroup);
|
|
2715
3008
|
}
|
|
2716
3009
|
if (route.redirectTo === undefined) {
|
|
2717
3010
|
return this.matchSegmentAgainstRoute(ngModule, segmentGroup, route, paths, outlet);
|
|
@@ -2719,7 +3012,7 @@ class ApplyRedirects {
|
|
|
2719
3012
|
if (allowRedirects && this.allowRedirects) {
|
|
2720
3013
|
return this.expandSegmentAgainstRouteUsingRedirect(ngModule, segmentGroup, routes, route, paths, outlet);
|
|
2721
3014
|
}
|
|
2722
|
-
return noMatch
|
|
3015
|
+
return noMatch(segmentGroup);
|
|
2723
3016
|
}
|
|
2724
3017
|
expandSegmentAgainstRouteUsingRedirect(ngModule, segmentGroup, routes, route, segments, outlet) {
|
|
2725
3018
|
if (route.path === '**') {
|
|
@@ -2740,7 +3033,7 @@ class ApplyRedirects {
|
|
|
2740
3033
|
expandRegularSegmentAgainstRouteUsingRedirect(ngModule, segmentGroup, routes, route, segments, outlet) {
|
|
2741
3034
|
const { matched, consumedSegments, lastChild, positionalParamSegments } = match(segmentGroup, route, segments);
|
|
2742
3035
|
if (!matched)
|
|
2743
|
-
return noMatch
|
|
3036
|
+
return noMatch(segmentGroup);
|
|
2744
3037
|
const newTree = this.applyRedirectCommands(consumedSegments, route.redirectTo, positionalParamSegments);
|
|
2745
3038
|
if (route.redirectTo.startsWith('/')) {
|
|
2746
3039
|
return absoluteRedirect(newTree);
|
|
@@ -2763,7 +3056,7 @@ class ApplyRedirects {
|
|
|
2763
3056
|
}
|
|
2764
3057
|
const { matched, consumedSegments, lastChild } = match(rawSegmentGroup, route, segments);
|
|
2765
3058
|
if (!matched)
|
|
2766
|
-
return noMatch
|
|
3059
|
+
return noMatch(rawSegmentGroup);
|
|
2767
3060
|
const rawSlicedSegments = segments.slice(lastChild);
|
|
2768
3061
|
const childConfig$ = this.getChildConfig(ngModule, route, segments);
|
|
2769
3062
|
return childConfig$.pipe(mergeMap((routerConfig) => {
|
|
@@ -2941,8 +3234,8 @@ function squashSegmentGroup(segmentGroup) {
|
|
|
2941
3234
|
* Use of this source code is governed by an MIT-style license that can be
|
|
2942
3235
|
* found in the LICENSE file at https://angular.io/license
|
|
2943
3236
|
*/
|
|
2944
|
-
function applyRedirects
|
|
2945
|
-
return switchMap(t => applyRedirects(moduleInjector, configLoader, urlSerializer, t.extractedUrl, config)
|
|
3237
|
+
function applyRedirects(moduleInjector, configLoader, urlSerializer, config) {
|
|
3238
|
+
return switchMap(t => applyRedirects$1(moduleInjector, configLoader, urlSerializer, t.extractedUrl, config)
|
|
2946
3239
|
.pipe(map(urlAfterRedirects => (Object.assign(Object.assign({}, t), { urlAfterRedirects })))));
|
|
2947
3240
|
}
|
|
2948
3241
|
|
|
@@ -3234,18 +3527,18 @@ function runCanDeactivate(component, currARS, currRSS, futureRSS, moduleInjector
|
|
|
3234
3527
|
* Use of this source code is governed by an MIT-style license that can be
|
|
3235
3528
|
* found in the LICENSE file at https://angular.io/license
|
|
3236
3529
|
*/
|
|
3237
|
-
class NoMatch
|
|
3530
|
+
class NoMatch {
|
|
3238
3531
|
}
|
|
3239
3532
|
function newObservableError(e) {
|
|
3240
3533
|
// TODO(atscott): This pattern is used throughout the router code and can be `throwError` instead.
|
|
3241
3534
|
return new Observable((obs) => obs.error(e));
|
|
3242
3535
|
}
|
|
3243
|
-
function recognize(rootComponentType, config, urlTree, url, paramsInheritanceStrategy = 'emptyOnly', relativeLinkResolution = 'legacy') {
|
|
3536
|
+
function recognize$1(rootComponentType, config, urlTree, url, paramsInheritanceStrategy = 'emptyOnly', relativeLinkResolution = 'legacy') {
|
|
3244
3537
|
try {
|
|
3245
3538
|
const result = new Recognizer(rootComponentType, config, urlTree, url, paramsInheritanceStrategy, relativeLinkResolution)
|
|
3246
3539
|
.recognize();
|
|
3247
3540
|
if (result === null) {
|
|
3248
|
-
return newObservableError(new NoMatch
|
|
3541
|
+
return newObservableError(new NoMatch());
|
|
3249
3542
|
}
|
|
3250
3543
|
else {
|
|
3251
3544
|
return of(result);
|
|
@@ -3489,8 +3782,8 @@ function getResolve(route) {
|
|
|
3489
3782
|
* Use of this source code is governed by an MIT-style license that can be
|
|
3490
3783
|
* found in the LICENSE file at https://angular.io/license
|
|
3491
3784
|
*/
|
|
3492
|
-
function recognize
|
|
3493
|
-
return mergeMap(t => recognize(rootComponentType, config, t.urlAfterRedirects, serializer(t.urlAfterRedirects), paramsInheritanceStrategy, relativeLinkResolution)
|
|
3785
|
+
function recognize(rootComponentType, config, serializer, paramsInheritanceStrategy, relativeLinkResolution) {
|
|
3786
|
+
return mergeMap(t => recognize$1(rootComponentType, config, t.urlAfterRedirects, serializer(t.urlAfterRedirects), paramsInheritanceStrategy, relativeLinkResolution)
|
|
3494
3787
|
.pipe(map(targetSnapshot => (Object.assign(Object.assign({}, t), { targetSnapshot })))));
|
|
3495
3788
|
}
|
|
3496
3789
|
|
|
@@ -3652,8 +3945,8 @@ class DefaultRouteReuseStrategy extends BaseRouteReuseStrategy {
|
|
|
3652
3945
|
*/
|
|
3653
3946
|
const ROUTES = new InjectionToken('ROUTES');
|
|
3654
3947
|
class RouterConfigLoader {
|
|
3655
|
-
constructor(
|
|
3656
|
-
this.
|
|
3948
|
+
constructor(injector, compiler, onLoadStartListener, onLoadEndListener) {
|
|
3949
|
+
this.injector = injector;
|
|
3657
3950
|
this.compiler = compiler;
|
|
3658
3951
|
this.onLoadStartListener = onLoadStartListener;
|
|
3659
3952
|
this.onLoadEndListener = onLoadEndListener;
|
|
@@ -3687,92 +3980,14 @@ class RouterConfigLoader {
|
|
|
3687
3980
|
return route._loader$;
|
|
3688
3981
|
}
|
|
3689
3982
|
loadModuleFactory(loadChildren) {
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
else {
|
|
3699
|
-
return from(this.compiler.compileModuleAsync(t));
|
|
3700
|
-
}
|
|
3701
|
-
}));
|
|
3702
|
-
}
|
|
3703
|
-
}
|
|
3704
|
-
}
|
|
3705
|
-
|
|
3706
|
-
/**
|
|
3707
|
-
* @license
|
|
3708
|
-
* Copyright Google LLC All Rights Reserved.
|
|
3709
|
-
*
|
|
3710
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
3711
|
-
* found in the LICENSE file at https://angular.io/license
|
|
3712
|
-
*/
|
|
3713
|
-
/**
|
|
3714
|
-
* Store contextual information about a `RouterOutlet`
|
|
3715
|
-
*
|
|
3716
|
-
* @publicApi
|
|
3717
|
-
*/
|
|
3718
|
-
class OutletContext {
|
|
3719
|
-
constructor() {
|
|
3720
|
-
this.outlet = null;
|
|
3721
|
-
this.route = null;
|
|
3722
|
-
this.resolver = null;
|
|
3723
|
-
this.children = new ChildrenOutletContexts();
|
|
3724
|
-
this.attachRef = null;
|
|
3725
|
-
}
|
|
3726
|
-
}
|
|
3727
|
-
/**
|
|
3728
|
-
* Store contextual information about the children (= nested) `RouterOutlet`
|
|
3729
|
-
*
|
|
3730
|
-
* @publicApi
|
|
3731
|
-
*/
|
|
3732
|
-
class ChildrenOutletContexts {
|
|
3733
|
-
constructor() {
|
|
3734
|
-
// contexts for child outlets, by name.
|
|
3735
|
-
this.contexts = new Map();
|
|
3736
|
-
}
|
|
3737
|
-
/** Called when a `RouterOutlet` directive is instantiated */
|
|
3738
|
-
onChildOutletCreated(childName, outlet) {
|
|
3739
|
-
const context = this.getOrCreateContext(childName);
|
|
3740
|
-
context.outlet = outlet;
|
|
3741
|
-
this.contexts.set(childName, context);
|
|
3742
|
-
}
|
|
3743
|
-
/**
|
|
3744
|
-
* Called when a `RouterOutlet` directive is destroyed.
|
|
3745
|
-
* We need to keep the context as the outlet could be destroyed inside a NgIf and might be
|
|
3746
|
-
* re-created later.
|
|
3747
|
-
*/
|
|
3748
|
-
onChildOutletDestroyed(childName) {
|
|
3749
|
-
const context = this.getContext(childName);
|
|
3750
|
-
if (context) {
|
|
3751
|
-
context.outlet = null;
|
|
3752
|
-
}
|
|
3753
|
-
}
|
|
3754
|
-
/**
|
|
3755
|
-
* Called when the corresponding route is deactivated during navigation.
|
|
3756
|
-
* Because the component get destroyed, all children outlet are destroyed.
|
|
3757
|
-
*/
|
|
3758
|
-
onOutletDeactivated() {
|
|
3759
|
-
const contexts = this.contexts;
|
|
3760
|
-
this.contexts = new Map();
|
|
3761
|
-
return contexts;
|
|
3762
|
-
}
|
|
3763
|
-
onOutletReAttached(contexts) {
|
|
3764
|
-
this.contexts = contexts;
|
|
3765
|
-
}
|
|
3766
|
-
getOrCreateContext(childName) {
|
|
3767
|
-
let context = this.getContext(childName);
|
|
3768
|
-
if (!context) {
|
|
3769
|
-
context = new OutletContext();
|
|
3770
|
-
this.contexts.set(childName, context);
|
|
3771
|
-
}
|
|
3772
|
-
return context;
|
|
3773
|
-
}
|
|
3774
|
-
getContext(childName) {
|
|
3775
|
-
return this.contexts.get(childName) || null;
|
|
3983
|
+
return wrapIntoObservable(loadChildren()).pipe(mergeMap((t) => {
|
|
3984
|
+
if (t instanceof NgModuleFactory) {
|
|
3985
|
+
return of(t);
|
|
3986
|
+
}
|
|
3987
|
+
else {
|
|
3988
|
+
return from(this.compiler.compileModuleAsync(t));
|
|
3989
|
+
}
|
|
3990
|
+
}));
|
|
3776
3991
|
}
|
|
3777
3992
|
}
|
|
3778
3993
|
|
|
@@ -3806,14 +4021,7 @@ class DefaultUrlHandlingStrategy {
|
|
|
3806
4021
|
return newUrlPart;
|
|
3807
4022
|
}
|
|
3808
4023
|
}
|
|
3809
|
-
|
|
3810
|
-
/**
|
|
3811
|
-
* @license
|
|
3812
|
-
* Copyright Google LLC All Rights Reserved.
|
|
3813
|
-
*
|
|
3814
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
3815
|
-
* found in the LICENSE file at https://angular.io/license
|
|
3816
|
-
*/
|
|
4024
|
+
|
|
3817
4025
|
function defaultErrorHandler(error) {
|
|
3818
4026
|
throw error;
|
|
3819
4027
|
}
|
|
@@ -3863,7 +4071,7 @@ class Router {
|
|
|
3863
4071
|
* Creates the router service.
|
|
3864
4072
|
*/
|
|
3865
4073
|
// TODO: vsavkin make internal after the final is out.
|
|
3866
|
-
constructor(rootComponentType, urlSerializer, rootContexts, location, injector,
|
|
4074
|
+
constructor(rootComponentType, urlSerializer, rootContexts, location, injector, compiler, config) {
|
|
3867
4075
|
this.rootComponentType = rootComponentType;
|
|
3868
4076
|
this.urlSerializer = urlSerializer;
|
|
3869
4077
|
this.rootContexts = rootContexts;
|
|
@@ -3872,11 +4080,6 @@ class Router {
|
|
|
3872
4080
|
this.lastSuccessfulNavigation = null;
|
|
3873
4081
|
this.currentNavigation = null;
|
|
3874
4082
|
this.disposed = false;
|
|
3875
|
-
/**
|
|
3876
|
-
* Tracks the previously seen location change from the location subscription so we can compare
|
|
3877
|
-
* the two latest to see if they are duplicates. See setUpLocationChangeListener.
|
|
3878
|
-
*/
|
|
3879
|
-
this.lastLocationChangeInfo = null;
|
|
3880
4083
|
this.navigationId = 0;
|
|
3881
4084
|
/**
|
|
3882
4085
|
* The id of the currently active page in the router.
|
|
@@ -3967,19 +4170,24 @@ class Router {
|
|
|
3967
4170
|
* Configures how the Router attempts to restore state when a navigation is cancelled.
|
|
3968
4171
|
*
|
|
3969
4172
|
* 'replace' - Always uses `location.replaceState` to set the browser state to the state of the
|
|
3970
|
-
* router before the navigation started.
|
|
4173
|
+
* router before the navigation started. This means that if the URL of the browser is updated
|
|
4174
|
+
* _before_ the navigation is canceled, the Router will simply replace the item in history rather
|
|
4175
|
+
* than trying to restore to the previous location in the session history. This happens most
|
|
4176
|
+
* frequently with `urlUpdateStrategy: 'eager'` and navigations with the browser back/forward
|
|
4177
|
+
* buttons.
|
|
3971
4178
|
*
|
|
3972
|
-
* 'computed' - Will
|
|
3973
|
-
* when the navigation gets cancelled
|
|
4179
|
+
* 'computed' - Will attempt to return to the same index in the session history that corresponds
|
|
4180
|
+
* to the Angular route when the navigation gets cancelled. For example, if the browser back
|
|
4181
|
+
* button is clicked and the navigation is cancelled, the Router will trigger a forward navigation
|
|
4182
|
+
* and vice versa.
|
|
3974
4183
|
*
|
|
3975
|
-
*
|
|
4184
|
+
* Note: the 'computed' option is incompatible with any `UrlHandlingStrategy` which only
|
|
4185
|
+
* handles a portion of the URL because the history restoration navigates to the previous place in
|
|
4186
|
+
* the browser history rather than simply resetting a portion of the URL.
|
|
4187
|
+
*
|
|
4188
|
+
* The default value is `replace`.
|
|
3976
4189
|
*
|
|
3977
|
-
* @internal
|
|
3978
4190
|
*/
|
|
3979
|
-
// TODO(atscott): Determine how/when/if to make this public API
|
|
3980
|
-
// This shouldn’t be an option at all but may need to be in order to allow migration without a
|
|
3981
|
-
// breaking change. We need to determine if it should be made into public api (or if we forgo
|
|
3982
|
-
// the option and release as a breaking change bug fix in a major version).
|
|
3983
4191
|
this.canceledNavigationResolution = 'replace';
|
|
3984
4192
|
const onLoadStart = (r) => this.triggerEvent(new RouteConfigLoadStart(r));
|
|
3985
4193
|
const onLoadEnd = (r) => this.triggerEvent(new RouteConfigLoadEnd(r));
|
|
@@ -3991,7 +4199,7 @@ class Router {
|
|
|
3991
4199
|
this.currentUrlTree = createEmptyUrlTree();
|
|
3992
4200
|
this.rawUrlTree = this.currentUrlTree;
|
|
3993
4201
|
this.browserUrlTree = this.currentUrlTree;
|
|
3994
|
-
this.configLoader = new RouterConfigLoader(
|
|
4202
|
+
this.configLoader = new RouterConfigLoader(injector, compiler, onLoadStart, onLoadEnd);
|
|
3995
4203
|
this.routerState = createEmptyState(this.currentUrlTree, this.rootComponentType);
|
|
3996
4204
|
this.transitions = new BehaviorSubject({
|
|
3997
4205
|
id: 0,
|
|
@@ -4077,25 +4285,20 @@ class Router {
|
|
|
4077
4285
|
return Promise.resolve(t);
|
|
4078
4286
|
}),
|
|
4079
4287
|
// ApplyRedirects
|
|
4080
|
-
applyRedirects
|
|
4288
|
+
applyRedirects(this.ngModule.injector, this.configLoader, this.urlSerializer, this.config),
|
|
4081
4289
|
// Update the currentNavigation
|
|
4290
|
+
// `urlAfterRedirects` is guaranteed to be set after this point
|
|
4082
4291
|
tap(t => {
|
|
4083
4292
|
this.currentNavigation = Object.assign(Object.assign({}, this.currentNavigation), { finalUrl: t.urlAfterRedirects });
|
|
4084
4293
|
}),
|
|
4085
4294
|
// Recognize
|
|
4086
|
-
recognize
|
|
4295
|
+
recognize(this.rootComponentType, this.config, (url) => this.serializeUrl(url), this.paramsInheritanceStrategy, this.relativeLinkResolution),
|
|
4087
4296
|
// Update URL if in `eager` update mode
|
|
4088
4297
|
tap(t => {
|
|
4089
4298
|
if (this.urlUpdateStrategy === 'eager') {
|
|
4090
4299
|
if (!t.extras.skipLocationChange) {
|
|
4091
|
-
this.
|
|
4092
|
-
|
|
4093
|
-
// only the part that is handled by the router. It should merge
|
|
4094
|
-
// that with the rawUrl so the url includes segments not handled
|
|
4095
|
-
// by the router:
|
|
4096
|
-
// const rawUrl = this.urlHandlingStrategy.merge(
|
|
4097
|
-
// t.urlAfterRedirects, t.rawUrl);
|
|
4098
|
-
// this.setBrowserUrl(rawUrl, t);
|
|
4300
|
+
const rawUrl = this.urlHandlingStrategy.merge(t.urlAfterRedirects, t.rawUrl);
|
|
4301
|
+
this.setBrowserUrl(rawUrl, t);
|
|
4099
4302
|
}
|
|
4100
4303
|
this.browserUrlTree = t.urlAfterRedirects;
|
|
4101
4304
|
}
|
|
@@ -4124,7 +4327,6 @@ class Router {
|
|
|
4124
4327
|
* in the browser.
|
|
4125
4328
|
*/
|
|
4126
4329
|
this.rawUrlTree = t.rawUrl;
|
|
4127
|
-
this.browserUrlTree = t.urlAfterRedirects;
|
|
4128
4330
|
t.resolve(null);
|
|
4129
4331
|
return EMPTY;
|
|
4130
4332
|
}
|
|
@@ -4232,28 +4434,7 @@ class Router {
|
|
|
4232
4434
|
* means. */
|
|
4233
4435
|
if (!completed && !errored) {
|
|
4234
4436
|
const cancelationReason = `Navigation ID ${t.id} is not equal to the current navigation id ${this.navigationId}`;
|
|
4235
|
-
|
|
4236
|
-
// Must reset to current URL tree here to ensure history.state is set. On
|
|
4237
|
-
// a fresh page load, if a new navigation comes in before a successful
|
|
4238
|
-
// navigation completes, there will be nothing in
|
|
4239
|
-
// history.state.navigationId. This can cause sync problems with
|
|
4240
|
-
// AngularJS sync code which looks for a value here in order to determine
|
|
4241
|
-
// whether or not to handle a given popstate event or to leave it to the
|
|
4242
|
-
// Angular router.
|
|
4243
|
-
this.restoreHistory(t);
|
|
4244
|
-
this.cancelNavigationTransition(t, cancelationReason);
|
|
4245
|
-
}
|
|
4246
|
-
else {
|
|
4247
|
-
// We cannot trigger a `location.historyGo` if the
|
|
4248
|
-
// cancellation was due to a new navigation before the previous could
|
|
4249
|
-
// complete. This is because `location.historyGo` triggers a `popstate`
|
|
4250
|
-
// which would also trigger another navigation. Instead, treat this as a
|
|
4251
|
-
// redirect and do not reset the state.
|
|
4252
|
-
this.cancelNavigationTransition(t, cancelationReason);
|
|
4253
|
-
// TODO(atscott): The same problem happens here with a fresh page load
|
|
4254
|
-
// and a new navigation before that completes where we won't set a page
|
|
4255
|
-
// id.
|
|
4256
|
-
}
|
|
4437
|
+
this.cancelNavigationTransition(t, cancelationReason);
|
|
4257
4438
|
}
|
|
4258
4439
|
// currentNavigation should always be reset to null here. If navigation was
|
|
4259
4440
|
// successful, lastSuccessfulTransition will have already been set. Therefore
|
|
@@ -4283,7 +4464,7 @@ class Router {
|
|
|
4283
4464
|
// This is only applicable with initial navigation, so setting
|
|
4284
4465
|
// `navigated` only when not redirecting resolves this scenario.
|
|
4285
4466
|
this.navigated = true;
|
|
4286
|
-
this.restoreHistory(t
|
|
4467
|
+
this.restoreHistory(t);
|
|
4287
4468
|
}
|
|
4288
4469
|
const navCancel = new NavigationCancel(t.id, this.serializeUrl(t.extractedUrl), e.message);
|
|
4289
4470
|
eventsSubject.next(navCancel);
|
|
@@ -4315,7 +4496,7 @@ class Router {
|
|
|
4315
4496
|
* the pre-error state. */
|
|
4316
4497
|
}
|
|
4317
4498
|
else {
|
|
4318
|
-
this.restoreHistory(t
|
|
4499
|
+
this.restoreHistory(t);
|
|
4319
4500
|
const navError = new NavigationError(t.id, this.serializeUrl(t.extractedUrl), e);
|
|
4320
4501
|
eventsSubject.next(navError);
|
|
4321
4502
|
try {
|
|
@@ -4340,22 +4521,8 @@ class Router {
|
|
|
4340
4521
|
// this will simplify the lifecycle of the router.
|
|
4341
4522
|
this.routerState.root.component = this.rootComponentType;
|
|
4342
4523
|
}
|
|
4343
|
-
getTransition() {
|
|
4344
|
-
const transition = this.transitions.value;
|
|
4345
|
-
// TODO(atscott): This comment doesn't make it clear why this value needs to be set. In the case
|
|
4346
|
-
// described below (where we don't handle previous or current url), the `browserUrlTree` is set
|
|
4347
|
-
// to the `urlAfterRedirects` value. However, these values *are already the same* because of the
|
|
4348
|
-
// line below. So it seems that we should be able to remove the line below and the line where
|
|
4349
|
-
// `browserUrlTree` is updated when we aren't handling any part of the navigation url.
|
|
4350
|
-
// Run TGP to confirm that this can be done.
|
|
4351
|
-
// This value needs to be set. Other values such as extractedUrl are set on initial navigation
|
|
4352
|
-
// but the urlAfterRedirects may not get set if we aren't processing the new URL *and* not
|
|
4353
|
-
// processing the previous URL.
|
|
4354
|
-
transition.urlAfterRedirects = this.browserUrlTree;
|
|
4355
|
-
return transition;
|
|
4356
|
-
}
|
|
4357
4524
|
setTransition(t) {
|
|
4358
|
-
this.transitions.next(Object.assign(Object.assign({}, this.
|
|
4525
|
+
this.transitions.next(Object.assign(Object.assign({}, this.transitions.value), t));
|
|
4359
4526
|
}
|
|
4360
4527
|
/**
|
|
4361
4528
|
* Sets up the location change listener and performs the initial navigation.
|
|
@@ -4377,13 +4544,16 @@ class Router {
|
|
|
4377
4544
|
// run into ngZone
|
|
4378
4545
|
if (!this.locationSubscription) {
|
|
4379
4546
|
this.locationSubscription = this.location.subscribe(event => {
|
|
4380
|
-
const
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4547
|
+
const source = event['type'] === 'popstate' ? 'popstate' : 'hashchange';
|
|
4548
|
+
if (source === 'popstate') {
|
|
4549
|
+
// The `setTimeout` was added in #12160 and is likely to support Angular/AngularJS
|
|
4550
|
+
// hybrid apps.
|
|
4384
4551
|
setTimeout(() => {
|
|
4385
|
-
|
|
4552
|
+
var _a;
|
|
4386
4553
|
const extras = { replaceUrl: true };
|
|
4554
|
+
// Navigations coming from Angular router have a navigationId state
|
|
4555
|
+
// property. When this exists, restore the state.
|
|
4556
|
+
const state = ((_a = event.state) === null || _a === void 0 ? void 0 : _a.navigationId) ? event.state : null;
|
|
4387
4557
|
if (state) {
|
|
4388
4558
|
const stateCopy = Object.assign({}, state);
|
|
4389
4559
|
delete stateCopy.navigationId;
|
|
@@ -4392,45 +4562,13 @@ class Router {
|
|
|
4392
4562
|
extras.state = stateCopy;
|
|
4393
4563
|
}
|
|
4394
4564
|
}
|
|
4565
|
+
const urlTree = this.parseUrl(event['url']);
|
|
4395
4566
|
this.scheduleNavigation(urlTree, source, state, extras);
|
|
4396
4567
|
}, 0);
|
|
4397
4568
|
}
|
|
4398
|
-
this.lastLocationChangeInfo = currentChange;
|
|
4399
4569
|
});
|
|
4400
4570
|
}
|
|
4401
4571
|
}
|
|
4402
|
-
/** Extracts router-related information from a `PopStateEvent`. */
|
|
4403
|
-
extractLocationChangeInfoFromEvent(change) {
|
|
4404
|
-
var _a;
|
|
4405
|
-
return {
|
|
4406
|
-
source: change['type'] === 'popstate' ? 'popstate' : 'hashchange',
|
|
4407
|
-
urlTree: this.parseUrl(change['url']),
|
|
4408
|
-
// Navigations coming from Angular router have a navigationId state
|
|
4409
|
-
// property. When this exists, restore the state.
|
|
4410
|
-
state: ((_a = change.state) === null || _a === void 0 ? void 0 : _a.navigationId) ? change.state : null,
|
|
4411
|
-
transitionId: this.getTransition().id
|
|
4412
|
-
};
|
|
4413
|
-
}
|
|
4414
|
-
/**
|
|
4415
|
-
* Determines whether two events triggered by the Location subscription are due to the same
|
|
4416
|
-
* navigation. The location subscription can fire two events (popstate and hashchange) for a
|
|
4417
|
-
* single navigation. The second one should be ignored, that is, we should not schedule another
|
|
4418
|
-
* navigation in the Router.
|
|
4419
|
-
*/
|
|
4420
|
-
shouldScheduleNavigation(previous, current) {
|
|
4421
|
-
if (!previous)
|
|
4422
|
-
return true;
|
|
4423
|
-
const sameDestination = current.urlTree.toString() === previous.urlTree.toString();
|
|
4424
|
-
const eventsOccurredAtSameTime = current.transitionId === previous.transitionId;
|
|
4425
|
-
if (!eventsOccurredAtSameTime || !sameDestination) {
|
|
4426
|
-
return true;
|
|
4427
|
-
}
|
|
4428
|
-
if ((current.source === 'hashchange' && previous.source === 'popstate') ||
|
|
4429
|
-
(current.source === 'popstate' && previous.source === 'hashchange')) {
|
|
4430
|
-
return false;
|
|
4431
|
-
}
|
|
4432
|
-
return true;
|
|
4433
|
-
}
|
|
4434
4572
|
/** The current URL. */
|
|
4435
4573
|
get url() {
|
|
4436
4574
|
return this.serializeUrl(this.currentUrlTree);
|
|
@@ -4673,20 +4811,18 @@ class Router {
|
|
|
4673
4811
|
});
|
|
4674
4812
|
}
|
|
4675
4813
|
scheduleNavigation(rawUrl, source, restoredState, extras, priorPromise) {
|
|
4676
|
-
var _a, _b;
|
|
4814
|
+
var _a, _b, _c;
|
|
4677
4815
|
if (this.disposed) {
|
|
4678
4816
|
return Promise.resolve(false);
|
|
4679
4817
|
}
|
|
4680
|
-
// *
|
|
4681
|
-
//
|
|
4682
|
-
// navs. Duplicates may also be triggered by attempts to sync AngularJS and Angular router
|
|
4683
|
-
// states.
|
|
4818
|
+
// * Duplicate navigations may also be triggered by attempts to sync AngularJS and Angular
|
|
4819
|
+
// router states.
|
|
4684
4820
|
// * Imperative navigations can be cancelled by router guards, meaning the URL won't change. If
|
|
4685
4821
|
// the user follows that with a navigation using the back/forward button or manual URL change,
|
|
4686
4822
|
// the destination may be the same as the previous imperative attempt. We should not skip
|
|
4687
4823
|
// these navigations because it's a separate case from the one above -- it's not a duplicate
|
|
4688
4824
|
// navigation.
|
|
4689
|
-
const lastNavigation = this.
|
|
4825
|
+
const lastNavigation = this.transitions.value;
|
|
4690
4826
|
// We don't want to skip duplicate successful navs if they're imperative because
|
|
4691
4827
|
// onSameUrlNavigation could be 'reload' (so the duplicate is intended).
|
|
4692
4828
|
const browserNavPrecededByRouterNav = isBrowserTriggeredNavigation(source) && lastNavigation &&
|
|
@@ -4696,7 +4832,7 @@ class Router {
|
|
|
4696
4832
|
// However, if it failed, we should compare to the final result (urlAfterRedirects).
|
|
4697
4833
|
const lastNavigationUrl = (lastNavigationSucceeded || this.currentNavigation) ?
|
|
4698
4834
|
lastNavigation.rawUrl :
|
|
4699
|
-
lastNavigation.urlAfterRedirects;
|
|
4835
|
+
((_a = lastNavigation.urlAfterRedirects) !== null && _a !== void 0 ? _a : this.browserUrlTree);
|
|
4700
4836
|
const duplicateNav = lastNavigationUrl.toString() === rawUrl.toString();
|
|
4701
4837
|
if (browserNavPrecededByRouterNav && duplicateNav) {
|
|
4702
4838
|
return Promise.resolve(true); // return value is not used
|
|
@@ -4732,10 +4868,10 @@ class Router {
|
|
|
4732
4868
|
// If we're replacing the URL or doing a silent navigation, we do not want to increment the
|
|
4733
4869
|
// page id because we aren't pushing a new entry to history.
|
|
4734
4870
|
if (extras.replaceUrl || extras.skipLocationChange) {
|
|
4735
|
-
targetPageId = (
|
|
4871
|
+
targetPageId = (_b = this.browserPageId) !== null && _b !== void 0 ? _b : 0;
|
|
4736
4872
|
}
|
|
4737
4873
|
else {
|
|
4738
|
-
targetPageId = ((
|
|
4874
|
+
targetPageId = ((_c = this.browserPageId) !== null && _c !== void 0 ? _c : 0) + 1;
|
|
4739
4875
|
}
|
|
4740
4876
|
}
|
|
4741
4877
|
}
|
|
@@ -4778,7 +4914,7 @@ class Router {
|
|
|
4778
4914
|
* Performs the necessary rollback action to restore the browser URL to the
|
|
4779
4915
|
* state before the transition.
|
|
4780
4916
|
*/
|
|
4781
|
-
restoreHistory(t
|
|
4917
|
+
restoreHistory(t) {
|
|
4782
4918
|
var _a, _b;
|
|
4783
4919
|
if (this.canceledNavigationResolution === 'computed') {
|
|
4784
4920
|
const targetPagePosition = this.currentPageId - t.targetPageId;
|
|
@@ -4800,7 +4936,6 @@ class Router {
|
|
|
4800
4936
|
// TODO(atscott): resetting the `browserUrlTree` should really be done in `resetState`.
|
|
4801
4937
|
// Investigate if this can be done by running TGP.
|
|
4802
4938
|
this.browserUrlTree = t.currentUrlTree;
|
|
4803
|
-
this.resetUrlToCurrentUrlTree();
|
|
4804
4939
|
}
|
|
4805
4940
|
else {
|
|
4806
4941
|
// The browser URL and router state was not updated before the navigation cancelled so
|
|
@@ -4808,20 +4943,19 @@ class Router {
|
|
|
4808
4943
|
}
|
|
4809
4944
|
}
|
|
4810
4945
|
else if (this.canceledNavigationResolution === 'replace') {
|
|
4811
|
-
|
|
4812
|
-
// for `deferred` navigations that haven't change the internal state yet because guards
|
|
4813
|
-
// reject. For 'eager' navigations, it seems like we also really should reset the state
|
|
4814
|
-
// because the navigation was cancelled. Investigate if this can be done by running TGP.
|
|
4815
|
-
if (restoringFromCaughtError) {
|
|
4816
|
-
this.resetState(t);
|
|
4817
|
-
}
|
|
4818
|
-
this.resetUrlToCurrentUrlTree();
|
|
4946
|
+
this.resetState(t);
|
|
4819
4947
|
}
|
|
4820
4948
|
}
|
|
4821
4949
|
resetState(t) {
|
|
4822
4950
|
this.routerState = t.currentRouterState;
|
|
4823
4951
|
this.currentUrlTree = t.currentUrlTree;
|
|
4952
|
+
// Note here that we use the urlHandlingStrategy to get the reset `rawUrlTree` because it may be
|
|
4953
|
+
// configured to handle only part of the navigation URL. This means we would only want to reset
|
|
4954
|
+
// the part of the navigation handled by the Angular router rather than the whole URL. In
|
|
4955
|
+
// addition, the URLHandlingStrategy may be configured to specifically preserve parts of the URL
|
|
4956
|
+
// when merging, such as the query params so they are not lost on a refresh.
|
|
4824
4957
|
this.rawUrlTree = this.urlHandlingStrategy.merge(this.currentUrlTree, t.rawUrl);
|
|
4958
|
+
this.resetUrlToCurrentUrlTree();
|
|
4825
4959
|
}
|
|
4826
4960
|
resetUrlToCurrentUrlTree() {
|
|
4827
4961
|
this.location.replaceState(this.urlSerializer.serialize(this.rawUrlTree), '', this.generateNgRouterState(this.lastSuccessfulId, this.currentPageId));
|
|
@@ -4838,19 +4972,11 @@ class Router {
|
|
|
4838
4972
|
return { navigationId };
|
|
4839
4973
|
}
|
|
4840
4974
|
}
|
|
4841
|
-
Router
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
{ type: UrlSerializer },
|
|
4847
|
-
{ type: ChildrenOutletContexts },
|
|
4848
|
-
{ type: Location },
|
|
4849
|
-
{ type: Injector },
|
|
4850
|
-
{ type: NgModuleFactoryLoader },
|
|
4851
|
-
{ type: Compiler },
|
|
4852
|
-
{ type: undefined }
|
|
4853
|
-
];
|
|
4975
|
+
Router.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: Router, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
|
|
4976
|
+
Router.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: Router });
|
|
4977
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: Router, decorators: [{
|
|
4978
|
+
type: Injectable
|
|
4979
|
+
}], ctorParameters: function () { return [{ type: i0.Type }, { type: UrlSerializer }, { type: ChildrenOutletContexts }, { type: i3.Location }, { type: i0.Injector }, { type: i0.Compiler }, { type: undefined }]; } });
|
|
4854
4980
|
function validateCommands(commands) {
|
|
4855
4981
|
for (let i = 0; i < commands.length; i++) {
|
|
4856
4982
|
const cmd = commands[i];
|
|
@@ -4863,13 +4989,6 @@ function isBrowserTriggeredNavigation(source) {
|
|
|
4863
4989
|
return source !== 'imperative';
|
|
4864
4990
|
}
|
|
4865
4991
|
|
|
4866
|
-
/**
|
|
4867
|
-
* @license
|
|
4868
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4869
|
-
*
|
|
4870
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
4871
|
-
* found in the LICENSE file at https://angular.io/license
|
|
4872
|
-
*/
|
|
4873
4992
|
/**
|
|
4874
4993
|
* @description
|
|
4875
4994
|
*
|
|
@@ -4968,14 +5087,32 @@ function isBrowserTriggeredNavigation(source) {
|
|
|
4968
5087
|
* @publicApi
|
|
4969
5088
|
*/
|
|
4970
5089
|
class RouterLink {
|
|
4971
|
-
constructor(router, route,
|
|
5090
|
+
constructor(router, route, tabIndexAttribute, renderer, el) {
|
|
4972
5091
|
this.router = router;
|
|
4973
5092
|
this.route = route;
|
|
4974
|
-
this.
|
|
5093
|
+
this.tabIndexAttribute = tabIndexAttribute;
|
|
5094
|
+
this.renderer = renderer;
|
|
5095
|
+
this.el = el;
|
|
5096
|
+
this.commands = null;
|
|
4975
5097
|
/** @internal */
|
|
4976
5098
|
this.onChanges = new Subject();
|
|
4977
|
-
|
|
4978
|
-
|
|
5099
|
+
this.setTabIndexIfNotOnNativeEl('0');
|
|
5100
|
+
}
|
|
5101
|
+
/**
|
|
5102
|
+
* Modifies the tab index if there was not a tabindex attribute on the element during
|
|
5103
|
+
* instantiation.
|
|
5104
|
+
*/
|
|
5105
|
+
setTabIndexIfNotOnNativeEl(newTabIndex) {
|
|
5106
|
+
if (this.tabIndexAttribute != null /* both `null` and `undefined` */) {
|
|
5107
|
+
return;
|
|
5108
|
+
}
|
|
5109
|
+
const renderer = this.renderer;
|
|
5110
|
+
const nativeElement = this.el.nativeElement;
|
|
5111
|
+
if (newTabIndex !== null) {
|
|
5112
|
+
renderer.setAttribute(nativeElement, 'tabindex', newTabIndex);
|
|
5113
|
+
}
|
|
5114
|
+
else {
|
|
5115
|
+
renderer.removeAttribute(nativeElement, 'tabindex');
|
|
4979
5116
|
}
|
|
4980
5117
|
}
|
|
4981
5118
|
/** @nodoc */
|
|
@@ -4988,19 +5125,24 @@ class RouterLink {
|
|
|
4988
5125
|
* Commands to pass to {@link Router#createUrlTree Router#createUrlTree}.
|
|
4989
5126
|
* - **array**: commands to pass to {@link Router#createUrlTree Router#createUrlTree}.
|
|
4990
5127
|
* - **string**: shorthand for array of commands with just the string, i.e. `['/route']`
|
|
4991
|
-
* - **null|undefined**:
|
|
5128
|
+
* - **null|undefined**: effectively disables the `routerLink`
|
|
4992
5129
|
* @see {@link Router#createUrlTree Router#createUrlTree}
|
|
4993
5130
|
*/
|
|
4994
5131
|
set routerLink(commands) {
|
|
4995
5132
|
if (commands != null) {
|
|
4996
5133
|
this.commands = Array.isArray(commands) ? commands : [commands];
|
|
5134
|
+
this.setTabIndexIfNotOnNativeEl('0');
|
|
4997
5135
|
}
|
|
4998
5136
|
else {
|
|
4999
|
-
this.commands =
|
|
5137
|
+
this.commands = null;
|
|
5138
|
+
this.setTabIndexIfNotOnNativeEl(null);
|
|
5000
5139
|
}
|
|
5001
5140
|
}
|
|
5002
5141
|
/** @nodoc */
|
|
5003
5142
|
onClick() {
|
|
5143
|
+
if (this.urlTree === null) {
|
|
5144
|
+
return true;
|
|
5145
|
+
}
|
|
5004
5146
|
const extras = {
|
|
5005
5147
|
skipLocationChange: attrBoolValue(this.skipLocationChange),
|
|
5006
5148
|
replaceUrl: attrBoolValue(this.replaceUrl),
|
|
@@ -5010,6 +5152,9 @@ class RouterLink {
|
|
|
5010
5152
|
return true;
|
|
5011
5153
|
}
|
|
5012
5154
|
get urlTree() {
|
|
5155
|
+
if (this.commands === null) {
|
|
5156
|
+
return null;
|
|
5157
|
+
}
|
|
5013
5158
|
return this.router.createUrlTree(this.commands, {
|
|
5014
5159
|
// If the `relativeTo` input is not defined, we want to use `this.route` by default.
|
|
5015
5160
|
// Otherwise, we should use the value provided by the user in the input.
|
|
@@ -5021,28 +5166,38 @@ class RouterLink {
|
|
|
5021
5166
|
});
|
|
5022
5167
|
}
|
|
5023
5168
|
}
|
|
5024
|
-
RouterLink
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
];
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5169
|
+
RouterLink.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterLink, deps: [{ token: Router }, { token: ActivatedRoute }, { token: 'tabindex', attribute: true }, { token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
5170
|
+
RouterLink.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.11", type: RouterLink, selector: ":not(a):not(area)[routerLink]", inputs: { queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick()" } }, usesOnChanges: true, ngImport: i0 });
|
|
5171
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterLink, decorators: [{
|
|
5172
|
+
type: Directive,
|
|
5173
|
+
args: [{ selector: ':not(a):not(area)[routerLink]' }]
|
|
5174
|
+
}], ctorParameters: function () {
|
|
5175
|
+
return [{ type: Router }, { type: ActivatedRoute }, { type: undefined, decorators: [{
|
|
5176
|
+
type: Attribute,
|
|
5177
|
+
args: ['tabindex']
|
|
5178
|
+
}] }, { type: i0.Renderer2 }, { type: i0.ElementRef }];
|
|
5179
|
+
}, propDecorators: { queryParams: [{
|
|
5180
|
+
type: Input
|
|
5181
|
+
}], fragment: [{
|
|
5182
|
+
type: Input
|
|
5183
|
+
}], queryParamsHandling: [{
|
|
5184
|
+
type: Input
|
|
5185
|
+
}], preserveFragment: [{
|
|
5186
|
+
type: Input
|
|
5187
|
+
}], skipLocationChange: [{
|
|
5188
|
+
type: Input
|
|
5189
|
+
}], replaceUrl: [{
|
|
5190
|
+
type: Input
|
|
5191
|
+
}], state: [{
|
|
5192
|
+
type: Input
|
|
5193
|
+
}], relativeTo: [{
|
|
5194
|
+
type: Input
|
|
5195
|
+
}], routerLink: [{
|
|
5196
|
+
type: Input
|
|
5197
|
+
}], onClick: [{
|
|
5198
|
+
type: HostListener,
|
|
5199
|
+
args: ['click']
|
|
5200
|
+
}] } });
|
|
5046
5201
|
/**
|
|
5047
5202
|
* @description
|
|
5048
5203
|
*
|
|
@@ -5059,7 +5214,11 @@ class RouterLinkWithHref {
|
|
|
5059
5214
|
this.router = router;
|
|
5060
5215
|
this.route = route;
|
|
5061
5216
|
this.locationStrategy = locationStrategy;
|
|
5062
|
-
this.commands =
|
|
5217
|
+
this.commands = null;
|
|
5218
|
+
// the url displayed on the anchor element.
|
|
5219
|
+
// @HostBinding('attr.href') is used rather than @HostBinding() because it removes the
|
|
5220
|
+
// href attribute when it becomes `null`.
|
|
5221
|
+
this.href = null;
|
|
5063
5222
|
/** @internal */
|
|
5064
5223
|
this.onChanges = new Subject();
|
|
5065
5224
|
this.subscription = router.events.subscribe((s) => {
|
|
@@ -5072,7 +5231,7 @@ class RouterLinkWithHref {
|
|
|
5072
5231
|
* Commands to pass to {@link Router#createUrlTree Router#createUrlTree}.
|
|
5073
5232
|
* - **array**: commands to pass to {@link Router#createUrlTree Router#createUrlTree}.
|
|
5074
5233
|
* - **string**: shorthand for array of commands with just the string, i.e. `['/route']`
|
|
5075
|
-
* - **null|undefined**:
|
|
5234
|
+
* - **null|undefined**: Disables the link by removing the `href`
|
|
5076
5235
|
* @see {@link Router#createUrlTree Router#createUrlTree}
|
|
5077
5236
|
*/
|
|
5078
5237
|
set routerLink(commands) {
|
|
@@ -5080,7 +5239,7 @@ class RouterLinkWithHref {
|
|
|
5080
5239
|
this.commands = Array.isArray(commands) ? commands : [commands];
|
|
5081
5240
|
}
|
|
5082
5241
|
else {
|
|
5083
|
-
this.commands =
|
|
5242
|
+
this.commands = null;
|
|
5084
5243
|
}
|
|
5085
5244
|
}
|
|
5086
5245
|
/** @nodoc */
|
|
@@ -5097,7 +5256,7 @@ class RouterLinkWithHref {
|
|
|
5097
5256
|
if (button !== 0 || ctrlKey || shiftKey || altKey || metaKey) {
|
|
5098
5257
|
return true;
|
|
5099
5258
|
}
|
|
5100
|
-
if (typeof this.target === 'string' && this.target != '_self') {
|
|
5259
|
+
if (typeof this.target === 'string' && this.target != '_self' || this.urlTree === null) {
|
|
5101
5260
|
return true;
|
|
5102
5261
|
}
|
|
5103
5262
|
const extras = {
|
|
@@ -5109,9 +5268,14 @@ class RouterLinkWithHref {
|
|
|
5109
5268
|
return false;
|
|
5110
5269
|
}
|
|
5111
5270
|
updateTargetUrlAndHref() {
|
|
5112
|
-
this.href = this.
|
|
5271
|
+
this.href = this.urlTree !== null ?
|
|
5272
|
+
this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.urlTree)) :
|
|
5273
|
+
null;
|
|
5113
5274
|
}
|
|
5114
5275
|
get urlTree() {
|
|
5276
|
+
if (this.commands === null) {
|
|
5277
|
+
return null;
|
|
5278
|
+
}
|
|
5115
5279
|
return this.router.createUrlTree(this.commands, {
|
|
5116
5280
|
// If the `relativeTo` input is not defined, we want to use `this.route` by default.
|
|
5117
5281
|
// Otherwise, we should use the value provided by the user in the input.
|
|
@@ -5123,29 +5287,42 @@ class RouterLinkWithHref {
|
|
|
5123
5287
|
});
|
|
5124
5288
|
}
|
|
5125
5289
|
}
|
|
5126
|
-
RouterLinkWithHref
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
]
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
}
|
|
5290
|
+
RouterLinkWithHref.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterLinkWithHref, deps: [{ token: Router }, { token: ActivatedRoute }, { token: i3.LocationStrategy }], target: i0.ɵɵFactoryTarget.Directive });
|
|
5291
|
+
RouterLinkWithHref.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.11", type: RouterLinkWithHref, selector: "a[routerLink],area[routerLink]", inputs: { target: "target", queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick($event.button,$event.ctrlKey,$event.shiftKey,$event.altKey,$event.metaKey)" }, properties: { "attr.target": "this.target", "attr.href": "this.href" } }, usesOnChanges: true, ngImport: i0 });
|
|
5292
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterLinkWithHref, decorators: [{
|
|
5293
|
+
type: Directive,
|
|
5294
|
+
args: [{ selector: 'a[routerLink],area[routerLink]' }]
|
|
5295
|
+
}], ctorParameters: function () { return [{ type: Router }, { type: ActivatedRoute }, { type: i3.LocationStrategy }]; }, propDecorators: { target: [{
|
|
5296
|
+
type: HostBinding,
|
|
5297
|
+
args: ['attr.target']
|
|
5298
|
+
}, {
|
|
5299
|
+
type: Input
|
|
5300
|
+
}], queryParams: [{
|
|
5301
|
+
type: Input
|
|
5302
|
+
}], fragment: [{
|
|
5303
|
+
type: Input
|
|
5304
|
+
}], queryParamsHandling: [{
|
|
5305
|
+
type: Input
|
|
5306
|
+
}], preserveFragment: [{
|
|
5307
|
+
type: Input
|
|
5308
|
+
}], skipLocationChange: [{
|
|
5309
|
+
type: Input
|
|
5310
|
+
}], replaceUrl: [{
|
|
5311
|
+
type: Input
|
|
5312
|
+
}], state: [{
|
|
5313
|
+
type: Input
|
|
5314
|
+
}], relativeTo: [{
|
|
5315
|
+
type: Input
|
|
5316
|
+
}], href: [{
|
|
5317
|
+
type: HostBinding,
|
|
5318
|
+
args: ['attr.href']
|
|
5319
|
+
}], routerLink: [{
|
|
5320
|
+
type: Input
|
|
5321
|
+
}], onClick: [{
|
|
5322
|
+
type: HostListener,
|
|
5323
|
+
args: ['click',
|
|
5324
|
+
['$event.button', '$event.ctrlKey', '$event.shiftKey', '$event.altKey', '$event.metaKey']]
|
|
5325
|
+
}] } });
|
|
5149
5326
|
function attrBoolValue(s) {
|
|
5150
5327
|
return s === '' || !!s;
|
|
5151
5328
|
}
|
|
@@ -5234,6 +5411,23 @@ class RouterLinkActive {
|
|
|
5234
5411
|
* @see Router.isActive
|
|
5235
5412
|
*/
|
|
5236
5413
|
this.routerLinkActiveOptions = { exact: false };
|
|
5414
|
+
/**
|
|
5415
|
+
*
|
|
5416
|
+
* You can use the output `isActiveChange` to get notified each time the link becomes
|
|
5417
|
+
* active or inactive.
|
|
5418
|
+
*
|
|
5419
|
+
* Emits:
|
|
5420
|
+
* true -> Route is active
|
|
5421
|
+
* false -> Route is inactive
|
|
5422
|
+
*
|
|
5423
|
+
* ```
|
|
5424
|
+
* <a
|
|
5425
|
+
* routerLink="/user/bob"
|
|
5426
|
+
* routerLinkActive="active-link"
|
|
5427
|
+
* (isActiveChange)="this.onRouterLinkActive($event)">Bob</a>
|
|
5428
|
+
* ```
|
|
5429
|
+
*/
|
|
5430
|
+
this.isActiveChange = new EventEmitter();
|
|
5237
5431
|
this.routerEventsSubscription = router.events.subscribe((s) => {
|
|
5238
5432
|
if (s instanceof NavigationEnd) {
|
|
5239
5433
|
this.update();
|
|
@@ -5290,6 +5484,8 @@ class RouterLinkActive {
|
|
|
5290
5484
|
this.renderer.removeClass(this.element.nativeElement, c);
|
|
5291
5485
|
}
|
|
5292
5486
|
});
|
|
5487
|
+
// Emit on isActiveChange after classes are updated
|
|
5488
|
+
this.isActiveChange.emit(hasActiveLinks);
|
|
5293
5489
|
}
|
|
5294
5490
|
});
|
|
5295
5491
|
}
|
|
@@ -5298,7 +5494,7 @@ class RouterLinkActive {
|
|
|
5298
5494
|
this.routerLinkActiveOptions :
|
|
5299
5495
|
// While the types should disallow `undefined` here, it's possible without strict inputs
|
|
5300
5496
|
(this.routerLinkActiveOptions.exact || false);
|
|
5301
|
-
return (link) => router.isActive(link.urlTree, options);
|
|
5497
|
+
return (link) => link.urlTree ? router.isActive(link.urlTree, options) : false;
|
|
5302
5498
|
}
|
|
5303
5499
|
hasActiveLinks() {
|
|
5304
5500
|
const isActiveCheckFn = this.isLinkActive(this.router);
|
|
@@ -5307,26 +5503,33 @@ class RouterLinkActive {
|
|
|
5307
5503
|
this.links.some(isActiveCheckFn) || this.linksWithHrefs.some(isActiveCheckFn);
|
|
5308
5504
|
}
|
|
5309
5505
|
}
|
|
5310
|
-
RouterLinkActive
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
]
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
];
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
}
|
|
5506
|
+
RouterLinkActive.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterLinkActive, deps: [{ token: Router }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: RouterLink, optional: true }, { token: RouterLinkWithHref, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
5507
|
+
RouterLinkActive.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.11", type: RouterLinkActive, selector: "[routerLinkActive]", inputs: { routerLinkActiveOptions: "routerLinkActiveOptions", routerLinkActive: "routerLinkActive" }, outputs: { isActiveChange: "isActiveChange" }, queries: [{ propertyName: "links", predicate: RouterLink, descendants: true }, { propertyName: "linksWithHrefs", predicate: RouterLinkWithHref, descendants: true }], exportAs: ["routerLinkActive"], usesOnChanges: true, ngImport: i0 });
|
|
5508
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterLinkActive, decorators: [{
|
|
5509
|
+
type: Directive,
|
|
5510
|
+
args: [{
|
|
5511
|
+
selector: '[routerLinkActive]',
|
|
5512
|
+
exportAs: 'routerLinkActive',
|
|
5513
|
+
}]
|
|
5514
|
+
}], ctorParameters: function () {
|
|
5515
|
+
return [{ type: Router }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.ChangeDetectorRef }, { type: RouterLink, decorators: [{
|
|
5516
|
+
type: Optional
|
|
5517
|
+
}] }, { type: RouterLinkWithHref, decorators: [{
|
|
5518
|
+
type: Optional
|
|
5519
|
+
}] }];
|
|
5520
|
+
}, propDecorators: { links: [{
|
|
5521
|
+
type: ContentChildren,
|
|
5522
|
+
args: [RouterLink, { descendants: true }]
|
|
5523
|
+
}], linksWithHrefs: [{
|
|
5524
|
+
type: ContentChildren,
|
|
5525
|
+
args: [RouterLinkWithHref, { descendants: true }]
|
|
5526
|
+
}], routerLinkActiveOptions: [{
|
|
5527
|
+
type: Input
|
|
5528
|
+
}], isActiveChange: [{
|
|
5529
|
+
type: Output
|
|
5530
|
+
}], routerLinkActive: [{
|
|
5531
|
+
type: Input
|
|
5532
|
+
}] } });
|
|
5330
5533
|
/**
|
|
5331
5534
|
* Use instead of `'paths' in options` to be compatible with property renaming
|
|
5332
5535
|
*/
|
|
@@ -5334,195 +5537,6 @@ function isActiveMatchOptions(options) {
|
|
|
5334
5537
|
return !!options.paths;
|
|
5335
5538
|
}
|
|
5336
5539
|
|
|
5337
|
-
/**
|
|
5338
|
-
* @license
|
|
5339
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5340
|
-
*
|
|
5341
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
5342
|
-
* found in the LICENSE file at https://angular.io/license
|
|
5343
|
-
*/
|
|
5344
|
-
/**
|
|
5345
|
-
* @description
|
|
5346
|
-
*
|
|
5347
|
-
* Acts as a placeholder that Angular dynamically fills based on the current router state.
|
|
5348
|
-
*
|
|
5349
|
-
* Each outlet can have a unique name, determined by the optional `name` attribute.
|
|
5350
|
-
* The name cannot be set or changed dynamically. If not set, default value is "primary".
|
|
5351
|
-
*
|
|
5352
|
-
* ```
|
|
5353
|
-
* <router-outlet></router-outlet>
|
|
5354
|
-
* <router-outlet name='left'></router-outlet>
|
|
5355
|
-
* <router-outlet name='right'></router-outlet>
|
|
5356
|
-
* ```
|
|
5357
|
-
*
|
|
5358
|
-
* Named outlets can be the targets of secondary routes.
|
|
5359
|
-
* The `Route` object for a secondary route has an `outlet` property to identify the target outlet:
|
|
5360
|
-
*
|
|
5361
|
-
* `{path: <base-path>, component: <component>, outlet: <target_outlet_name>}`
|
|
5362
|
-
*
|
|
5363
|
-
* Using named outlets and secondary routes, you can target multiple outlets in
|
|
5364
|
-
* the same `RouterLink` directive.
|
|
5365
|
-
*
|
|
5366
|
-
* The router keeps track of separate branches in a navigation tree for each named outlet and
|
|
5367
|
-
* generates a representation of that tree in the URL.
|
|
5368
|
-
* The URL for a secondary route uses the following syntax to specify both the primary and secondary
|
|
5369
|
-
* routes at the same time:
|
|
5370
|
-
*
|
|
5371
|
-
* `http://base-path/primary-route-path(outlet-name:route-path)`
|
|
5372
|
-
*
|
|
5373
|
-
* A router outlet emits an activate event when a new component is instantiated,
|
|
5374
|
-
* and a deactivate event when a component is destroyed.
|
|
5375
|
-
*
|
|
5376
|
-
* ```
|
|
5377
|
-
* <router-outlet
|
|
5378
|
-
* (activate)='onActivate($event)'
|
|
5379
|
-
* (deactivate)='onDeactivate($event)'></router-outlet>
|
|
5380
|
-
* ```
|
|
5381
|
-
*
|
|
5382
|
-
* @see [Routing tutorial](guide/router-tutorial-toh#named-outlets "Example of a named
|
|
5383
|
-
* outlet and secondary route configuration").
|
|
5384
|
-
* @see `RouterLink`
|
|
5385
|
-
* @see `Route`
|
|
5386
|
-
* @ngModule RouterModule
|
|
5387
|
-
*
|
|
5388
|
-
* @publicApi
|
|
5389
|
-
*/
|
|
5390
|
-
class RouterOutlet {
|
|
5391
|
-
constructor(parentContexts, location, resolver, name, changeDetector) {
|
|
5392
|
-
this.parentContexts = parentContexts;
|
|
5393
|
-
this.location = location;
|
|
5394
|
-
this.resolver = resolver;
|
|
5395
|
-
this.changeDetector = changeDetector;
|
|
5396
|
-
this.activated = null;
|
|
5397
|
-
this._activatedRoute = null;
|
|
5398
|
-
this.activateEvents = new EventEmitter();
|
|
5399
|
-
this.deactivateEvents = new EventEmitter();
|
|
5400
|
-
this.name = name || PRIMARY_OUTLET;
|
|
5401
|
-
parentContexts.onChildOutletCreated(this.name, this);
|
|
5402
|
-
}
|
|
5403
|
-
/** @nodoc */
|
|
5404
|
-
ngOnDestroy() {
|
|
5405
|
-
this.parentContexts.onChildOutletDestroyed(this.name);
|
|
5406
|
-
}
|
|
5407
|
-
/** @nodoc */
|
|
5408
|
-
ngOnInit() {
|
|
5409
|
-
if (!this.activated) {
|
|
5410
|
-
// If the outlet was not instantiated at the time the route got activated we need to populate
|
|
5411
|
-
// the outlet when it is initialized (ie inside a NgIf)
|
|
5412
|
-
const context = this.parentContexts.getContext(this.name);
|
|
5413
|
-
if (context && context.route) {
|
|
5414
|
-
if (context.attachRef) {
|
|
5415
|
-
// `attachRef` is populated when there is an existing component to mount
|
|
5416
|
-
this.attach(context.attachRef, context.route);
|
|
5417
|
-
}
|
|
5418
|
-
else {
|
|
5419
|
-
// otherwise the component defined in the configuration is created
|
|
5420
|
-
this.activateWith(context.route, context.resolver || null);
|
|
5421
|
-
}
|
|
5422
|
-
}
|
|
5423
|
-
}
|
|
5424
|
-
}
|
|
5425
|
-
get isActivated() {
|
|
5426
|
-
return !!this.activated;
|
|
5427
|
-
}
|
|
5428
|
-
/**
|
|
5429
|
-
* @returns The currently activated component instance.
|
|
5430
|
-
* @throws An error if the outlet is not activated.
|
|
5431
|
-
*/
|
|
5432
|
-
get component() {
|
|
5433
|
-
if (!this.activated)
|
|
5434
|
-
throw new Error('Outlet is not activated');
|
|
5435
|
-
return this.activated.instance;
|
|
5436
|
-
}
|
|
5437
|
-
get activatedRoute() {
|
|
5438
|
-
if (!this.activated)
|
|
5439
|
-
throw new Error('Outlet is not activated');
|
|
5440
|
-
return this._activatedRoute;
|
|
5441
|
-
}
|
|
5442
|
-
get activatedRouteData() {
|
|
5443
|
-
if (this._activatedRoute) {
|
|
5444
|
-
return this._activatedRoute.snapshot.data;
|
|
5445
|
-
}
|
|
5446
|
-
return {};
|
|
5447
|
-
}
|
|
5448
|
-
/**
|
|
5449
|
-
* Called when the `RouteReuseStrategy` instructs to detach the subtree
|
|
5450
|
-
*/
|
|
5451
|
-
detach() {
|
|
5452
|
-
if (!this.activated)
|
|
5453
|
-
throw new Error('Outlet is not activated');
|
|
5454
|
-
this.location.detach();
|
|
5455
|
-
const cmp = this.activated;
|
|
5456
|
-
this.activated = null;
|
|
5457
|
-
this._activatedRoute = null;
|
|
5458
|
-
return cmp;
|
|
5459
|
-
}
|
|
5460
|
-
/**
|
|
5461
|
-
* Called when the `RouteReuseStrategy` instructs to re-attach a previously detached subtree
|
|
5462
|
-
*/
|
|
5463
|
-
attach(ref, activatedRoute) {
|
|
5464
|
-
this.activated = ref;
|
|
5465
|
-
this._activatedRoute = activatedRoute;
|
|
5466
|
-
this.location.insert(ref.hostView);
|
|
5467
|
-
}
|
|
5468
|
-
deactivate() {
|
|
5469
|
-
if (this.activated) {
|
|
5470
|
-
const c = this.component;
|
|
5471
|
-
this.activated.destroy();
|
|
5472
|
-
this.activated = null;
|
|
5473
|
-
this._activatedRoute = null;
|
|
5474
|
-
this.deactivateEvents.emit(c);
|
|
5475
|
-
}
|
|
5476
|
-
}
|
|
5477
|
-
activateWith(activatedRoute, resolver) {
|
|
5478
|
-
if (this.isActivated) {
|
|
5479
|
-
throw new Error('Cannot activate an already activated outlet');
|
|
5480
|
-
}
|
|
5481
|
-
this._activatedRoute = activatedRoute;
|
|
5482
|
-
const snapshot = activatedRoute._futureSnapshot;
|
|
5483
|
-
const component = snapshot.routeConfig.component;
|
|
5484
|
-
resolver = resolver || this.resolver;
|
|
5485
|
-
const factory = resolver.resolveComponentFactory(component);
|
|
5486
|
-
const childContexts = this.parentContexts.getOrCreateContext(this.name).children;
|
|
5487
|
-
const injector = new OutletInjector(activatedRoute, childContexts, this.location.injector);
|
|
5488
|
-
this.activated = this.location.createComponent(factory, this.location.length, injector);
|
|
5489
|
-
// Calling `markForCheck` to make sure we will run the change detection when the
|
|
5490
|
-
// `RouterOutlet` is inside a `ChangeDetectionStrategy.OnPush` component.
|
|
5491
|
-
this.changeDetector.markForCheck();
|
|
5492
|
-
this.activateEvents.emit(this.activated.instance);
|
|
5493
|
-
}
|
|
5494
|
-
}
|
|
5495
|
-
RouterOutlet.decorators = [
|
|
5496
|
-
{ type: Directive, args: [{ selector: 'router-outlet', exportAs: 'outlet' },] }
|
|
5497
|
-
];
|
|
5498
|
-
RouterOutlet.ctorParameters = () => [
|
|
5499
|
-
{ type: ChildrenOutletContexts },
|
|
5500
|
-
{ type: ViewContainerRef },
|
|
5501
|
-
{ type: ComponentFactoryResolver },
|
|
5502
|
-
{ type: String, decorators: [{ type: Attribute, args: ['name',] }] },
|
|
5503
|
-
{ type: ChangeDetectorRef }
|
|
5504
|
-
];
|
|
5505
|
-
RouterOutlet.propDecorators = {
|
|
5506
|
-
activateEvents: [{ type: Output, args: ['activate',] }],
|
|
5507
|
-
deactivateEvents: [{ type: Output, args: ['deactivate',] }]
|
|
5508
|
-
};
|
|
5509
|
-
class OutletInjector {
|
|
5510
|
-
constructor(route, childContexts, parent) {
|
|
5511
|
-
this.route = route;
|
|
5512
|
-
this.childContexts = childContexts;
|
|
5513
|
-
this.parent = parent;
|
|
5514
|
-
}
|
|
5515
|
-
get(token, notFoundValue) {
|
|
5516
|
-
if (token === ActivatedRoute) {
|
|
5517
|
-
return this.route;
|
|
5518
|
-
}
|
|
5519
|
-
if (token === ChildrenOutletContexts) {
|
|
5520
|
-
return this.childContexts;
|
|
5521
|
-
}
|
|
5522
|
-
return this.parent.get(token, notFoundValue);
|
|
5523
|
-
}
|
|
5524
|
-
}
|
|
5525
|
-
|
|
5526
5540
|
/**
|
|
5527
5541
|
* @license
|
|
5528
5542
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -5582,13 +5596,13 @@ class NoPreloading {
|
|
|
5582
5596
|
* @publicApi
|
|
5583
5597
|
*/
|
|
5584
5598
|
class RouterPreloader {
|
|
5585
|
-
constructor(router,
|
|
5599
|
+
constructor(router, compiler, injector, preloadingStrategy) {
|
|
5586
5600
|
this.router = router;
|
|
5587
5601
|
this.injector = injector;
|
|
5588
5602
|
this.preloadingStrategy = preloadingStrategy;
|
|
5589
5603
|
const onStartLoad = (r) => router.triggerEvent(new RouteConfigLoadStart(r));
|
|
5590
5604
|
const onEndLoad = (r) => router.triggerEvent(new RouteConfigLoadEnd(r));
|
|
5591
|
-
this.loader = new RouterConfigLoader(
|
|
5605
|
+
this.loader = new RouterConfigLoader(injector, compiler, onStartLoad, onEndLoad);
|
|
5592
5606
|
}
|
|
5593
5607
|
setUpPreloading() {
|
|
5594
5608
|
this.subscription =
|
|
@@ -5636,24 +5650,12 @@ class RouterPreloader {
|
|
|
5636
5650
|
});
|
|
5637
5651
|
}
|
|
5638
5652
|
}
|
|
5639
|
-
RouterPreloader
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
{ type: NgModuleFactoryLoader },
|
|
5645
|
-
{ type: Compiler },
|
|
5646
|
-
{ type: Injector },
|
|
5647
|
-
{ type: PreloadingStrategy }
|
|
5648
|
-
];
|
|
5653
|
+
RouterPreloader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterPreloader, deps: [{ token: Router }, { token: i0.Compiler }, { token: i0.Injector }, { token: PreloadingStrategy }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
5654
|
+
RouterPreloader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterPreloader });
|
|
5655
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterPreloader, decorators: [{
|
|
5656
|
+
type: Injectable
|
|
5657
|
+
}], ctorParameters: function () { return [{ type: Router }, { type: i0.Compiler }, { type: i0.Injector }, { type: PreloadingStrategy }]; } });
|
|
5649
5658
|
|
|
5650
|
-
/**
|
|
5651
|
-
* @license
|
|
5652
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5653
|
-
*
|
|
5654
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
5655
|
-
* found in the LICENSE file at https://angular.io/license
|
|
5656
|
-
*/
|
|
5657
5659
|
class RouterScroller {
|
|
5658
5660
|
constructor(router,
|
|
5659
5661
|
/** @docsNotRequired */ viewportScroller, options = {}) {
|
|
@@ -5729,14 +5731,11 @@ class RouterScroller {
|
|
|
5729
5731
|
}
|
|
5730
5732
|
}
|
|
5731
5733
|
}
|
|
5732
|
-
RouterScroller
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
{ type: ViewportScroller },
|
|
5738
|
-
{ type: undefined }
|
|
5739
|
-
];
|
|
5734
|
+
RouterScroller.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterScroller, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
|
|
5735
|
+
RouterScroller.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterScroller });
|
|
5736
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterScroller, decorators: [{
|
|
5737
|
+
type: Injectable
|
|
5738
|
+
}], ctorParameters: function () { return [{ type: Router }, { type: i3.ViewportScroller }, { type: undefined }]; } });
|
|
5740
5739
|
|
|
5741
5740
|
/**
|
|
5742
5741
|
* @license
|
|
@@ -5759,7 +5758,6 @@ const ROUTER_CONFIGURATION = new InjectionToken('ROUTER_CONFIGURATION');
|
|
|
5759
5758
|
* @docsNotRequired
|
|
5760
5759
|
*/
|
|
5761
5760
|
const ROUTER_FORROOT_GUARD = new InjectionToken('ROUTER_FORROOT_GUARD');
|
|
5762
|
-
const ɵ0 = { enableTracing: false };
|
|
5763
5761
|
const ROUTER_PROVIDERS = [
|
|
5764
5762
|
Location,
|
|
5765
5763
|
{ provide: UrlSerializer, useClass: DefaultUrlSerializer },
|
|
@@ -5767,18 +5765,17 @@ const ROUTER_PROVIDERS = [
|
|
|
5767
5765
|
provide: Router,
|
|
5768
5766
|
useFactory: setupRouter,
|
|
5769
5767
|
deps: [
|
|
5770
|
-
UrlSerializer, ChildrenOutletContexts, Location, Injector,
|
|
5771
|
-
|
|
5768
|
+
UrlSerializer, ChildrenOutletContexts, Location, Injector, Compiler, ROUTES,
|
|
5769
|
+
ROUTER_CONFIGURATION, [UrlHandlingStrategy, new Optional()],
|
|
5772
5770
|
[RouteReuseStrategy, new Optional()]
|
|
5773
5771
|
]
|
|
5774
5772
|
},
|
|
5775
5773
|
ChildrenOutletContexts,
|
|
5776
5774
|
{ provide: ActivatedRoute, useFactory: rootRoute, deps: [Router] },
|
|
5777
|
-
{ provide: NgModuleFactoryLoader, useClass: SystemJsNgModuleLoader },
|
|
5778
5775
|
RouterPreloader,
|
|
5779
5776
|
NoPreloading,
|
|
5780
5777
|
PreloadAllModules,
|
|
5781
|
-
{ provide: ROUTER_CONFIGURATION, useValue:
|
|
5778
|
+
{ provide: ROUTER_CONFIGURATION, useValue: { enableTracing: false } },
|
|
5782
5779
|
];
|
|
5783
5780
|
function routerNgProbeToken() {
|
|
5784
5781
|
return new NgProbeToken('Router', Router);
|
|
@@ -5877,17 +5874,26 @@ class RouterModule {
|
|
|
5877
5874
|
return { ngModule: RouterModule, providers: [provideRoutes(routes)] };
|
|
5878
5875
|
}
|
|
5879
5876
|
}
|
|
5880
|
-
RouterModule
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
]
|
|
5877
|
+
RouterModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterModule, deps: [{ token: ROUTER_FORROOT_GUARD, optional: true }, { token: Router, optional: true }], target: i0.ɵɵFactoryTarget.NgModule });
|
|
5878
|
+
RouterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterModule, declarations: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent], exports: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent] });
|
|
5879
|
+
RouterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterModule });
|
|
5880
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterModule, decorators: [{
|
|
5881
|
+
type: NgModule,
|
|
5882
|
+
args: [{
|
|
5883
|
+
declarations: ROUTER_DIRECTIVES,
|
|
5884
|
+
exports: ROUTER_DIRECTIVES,
|
|
5885
|
+
entryComponents: [ɵEmptyOutletComponent]
|
|
5886
|
+
}]
|
|
5887
|
+
}], ctorParameters: function () {
|
|
5888
|
+
return [{ type: undefined, decorators: [{
|
|
5889
|
+
type: Optional
|
|
5890
|
+
}, {
|
|
5891
|
+
type: Inject,
|
|
5892
|
+
args: [ROUTER_FORROOT_GUARD]
|
|
5893
|
+
}] }, { type: Router, decorators: [{
|
|
5894
|
+
type: Optional
|
|
5895
|
+
}] }];
|
|
5896
|
+
} });
|
|
5891
5897
|
function createRouterScroller(router, viewportScroller, config) {
|
|
5892
5898
|
if (config.scrollOffset) {
|
|
5893
5899
|
viewportScroller.setOffset(config.scrollOffset);
|
|
@@ -5926,8 +5932,8 @@ function provideRoutes(routes) {
|
|
|
5926
5932
|
{ provide: ROUTES, multi: true, useValue: routes },
|
|
5927
5933
|
];
|
|
5928
5934
|
}
|
|
5929
|
-
function setupRouter(urlSerializer, contexts, location, injector,
|
|
5930
|
-
const router = new Router(null, urlSerializer, contexts, location, injector,
|
|
5935
|
+
function setupRouter(urlSerializer, contexts, location, injector, compiler, config, opts = {}, urlHandlingStrategy, routeReuseStrategy) {
|
|
5936
|
+
const router = new Router(null, urlSerializer, contexts, location, injector, compiler, flatten(config));
|
|
5931
5937
|
if (urlHandlingStrategy) {
|
|
5932
5938
|
router.urlHandlingStrategy = urlHandlingStrategy;
|
|
5933
5939
|
}
|
|
@@ -6050,12 +6056,11 @@ class RouterInitializer {
|
|
|
6050
6056
|
this.destroyed = true;
|
|
6051
6057
|
}
|
|
6052
6058
|
}
|
|
6053
|
-
RouterInitializer
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
];
|
|
6059
|
+
RouterInitializer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterInitializer, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
6060
|
+
RouterInitializer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterInitializer });
|
|
6061
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.11", ngImport: i0, type: RouterInitializer, decorators: [{
|
|
6062
|
+
type: Injectable
|
|
6063
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }]; } });
|
|
6059
6064
|
function getAppInitializer(r) {
|
|
6060
6065
|
return r.appInitializer.bind(r);
|
|
6061
6066
|
}
|
|
@@ -6093,7 +6098,7 @@ function provideRouterInitializer() {
|
|
|
6093
6098
|
/**
|
|
6094
6099
|
* @publicApi
|
|
6095
6100
|
*/
|
|
6096
|
-
const VERSION = new Version('
|
|
6101
|
+
const VERSION = new Version('13.0.0-next.11');
|
|
6097
6102
|
|
|
6098
6103
|
/**
|
|
6099
6104
|
* @license
|
|
@@ -6132,5 +6137,5 @@ const VERSION = new Version('12.2.8');
|
|
|
6132
6137
|
* Generated bundle index. Do not edit.
|
|
6133
6138
|
*/
|
|
6134
6139
|
|
|
6135
|
-
export { ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, BaseRouteReuseStrategy, ChildActivationEnd, ChildActivationStart, ChildrenOutletContexts, DefaultUrlSerializer, GuardsCheckEnd, GuardsCheckStart, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, NoPreloading, OutletContext, PRIMARY_OUTLET, PreloadAllModules, PreloadingStrategy, ROUTER_CONFIGURATION, ROUTER_INITIALIZER, ROUTES, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, Router, RouterEvent, RouterLink, RouterLinkActive, RouterLinkWithHref, RouterModule, RouterOutlet, RouterPreloader, RouterState, RouterStateSnapshot, RoutesRecognized, Scroll, UrlHandlingStrategy, UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree, VERSION, convertToParamMap, provideRoutes, ɵEmptyOutletComponent, ROUTER_PROVIDERS as ɵROUTER_PROVIDERS,
|
|
6136
|
-
//# sourceMappingURL=router.
|
|
6140
|
+
export { ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, BaseRouteReuseStrategy, ChildActivationEnd, ChildActivationStart, ChildrenOutletContexts, DefaultUrlSerializer, GuardsCheckEnd, GuardsCheckStart, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, NoPreloading, OutletContext, PRIMARY_OUTLET, PreloadAllModules, PreloadingStrategy, ROUTER_CONFIGURATION, ROUTER_INITIALIZER, ROUTES, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, Router, RouterEvent, RouterLink, RouterLinkActive, RouterLinkWithHref, RouterModule, RouterOutlet, RouterPreloader, RouterState, RouterStateSnapshot, RoutesRecognized, Scroll, UrlHandlingStrategy, UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree, VERSION, convertToParamMap, provideRoutes, ɵEmptyOutletComponent, ROUTER_PROVIDERS as ɵROUTER_PROVIDERS, assignExtraOptionsToRouter as ɵassignExtraOptionsToRouter, flatten as ɵflatten };
|
|
6141
|
+
//# sourceMappingURL=router.mjs.map
|