@angular/router 21.0.0-next.0 → 21.0.0-next.10
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/fesm2022/_router-chunk.mjs +4991 -0
- package/fesm2022/_router-chunk.mjs.map +1 -0
- package/fesm2022/_router_module-chunk.mjs +1210 -0
- package/fesm2022/_router_module-chunk.mjs.map +1 -0
- package/fesm2022/router.mjs +10 -63
- package/fesm2022/router.mjs.map +1 -1
- package/fesm2022/testing.mjs +205 -173
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/upgrade.mjs +42 -116
- package/fesm2022/upgrade.mjs.map +1 -1
- package/package.json +8 -8
- package/{router_module.d.d.ts → types/_router_module-chunk.d.ts} +28 -2
- package/{index.d.ts → types/router.d.ts} +45 -10
- package/{testing/index.d.ts → types/testing.d.ts} +4 -4
- package/{upgrade/index.d.ts → types/upgrade.d.ts} +6 -6
- package/fesm2022/router2.mjs +0 -5996
- package/fesm2022/router2.mjs.map +0 -1
- package/fesm2022/router_module.mjs +0 -1678
- package/fesm2022/router_module.mjs.map +0 -1
|
@@ -0,0 +1,1210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Angular v21.0.0-next.10
|
|
3
|
+
* (c) 2010-2025 Google LLC. https://angular.dev/
|
|
4
|
+
* License: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as i3 from '@angular/common';
|
|
8
|
+
import { PlatformNavigation, Location, ɵNavigationAdapterForLocation as _NavigationAdapterForLocation, LOCATION_INITIALIZED, ViewportScroller, LocationStrategy, HashLocationStrategy, PathLocationStrategy } from '@angular/common';
|
|
9
|
+
import * as i0 from '@angular/core';
|
|
10
|
+
import { signal, untracked, inject, ɵINTERNAL_APPLICATION_ERROR_HANDLER as _INTERNAL_APPLICATION_ERROR_HANDLER, HostAttributeToken, ɵRuntimeError as _RuntimeError, booleanAttribute, Directive, Attribute, HostBinding, Input, HostListener, EventEmitter, Optional, ContentChildren, Output, Injectable, createEnvironmentInjector, InjectionToken, ɵpublishExternalGlobalUtil as _publishExternalGlobalUtil, makeEnvironmentProviders, APP_BOOTSTRAP_LISTENER, provideEnvironmentInitializer, Injector, ApplicationRef, ɵIS_ENABLED_BLOCKING_INITIAL_NAVIGATION as _IS_ENABLED_BLOCKING_INITIAL_NAVIGATION, provideAppInitializer, ɵperformanceMarkFeature as _performanceMarkFeature, ENVIRONMENT_INITIALIZER, NgZone, NgModule } from '@angular/core';
|
|
11
|
+
import { ROUTER_CONFIGURATION, NavigationEnd, isUrlTree, Router, ActivatedRoute, RouterConfigLoader, IMPERATIVE_NAVIGATION, NavigationStart, NavigationSkipped, NavigationSkippedCode, Scroll, UrlSerializer, NavigationTransitions, HistoryStateManager, ROUTES, afterNextNavigation, StateManager, stringifyEvent, NAVIGATION_ERROR_HANDLER, RoutedComponentInputBinder, INPUT_BINDER, CREATE_VIEW_TRANSITION, createViewTransition, VIEW_TRANSITION_OPTIONS, DefaultUrlSerializer, ChildrenOutletContexts, RouterOutlet, ɵEmptyOutletComponent as _EmptyOutletComponent } from './_router-chunk.mjs';
|
|
12
|
+
import { Subject, of, from } from 'rxjs';
|
|
13
|
+
import { mergeAll, catchError, filter, concatMap, mergeMap } from 'rxjs/operators';
|
|
14
|
+
|
|
15
|
+
class RouterLink {
|
|
16
|
+
router;
|
|
17
|
+
route;
|
|
18
|
+
tabIndexAttribute;
|
|
19
|
+
renderer;
|
|
20
|
+
el;
|
|
21
|
+
locationStrategy;
|
|
22
|
+
reactiveHref = signal(null, ...(ngDevMode ? [{
|
|
23
|
+
debugName: "reactiveHref"
|
|
24
|
+
}] : []));
|
|
25
|
+
get href() {
|
|
26
|
+
return untracked(this.reactiveHref);
|
|
27
|
+
}
|
|
28
|
+
set href(value) {
|
|
29
|
+
this.reactiveHref.set(value);
|
|
30
|
+
}
|
|
31
|
+
target;
|
|
32
|
+
queryParams;
|
|
33
|
+
fragment;
|
|
34
|
+
queryParamsHandling;
|
|
35
|
+
state;
|
|
36
|
+
info;
|
|
37
|
+
relativeTo;
|
|
38
|
+
isAnchorElement;
|
|
39
|
+
subscription;
|
|
40
|
+
onChanges = new Subject();
|
|
41
|
+
applicationErrorHandler = inject(_INTERNAL_APPLICATION_ERROR_HANDLER);
|
|
42
|
+
options = inject(ROUTER_CONFIGURATION, {
|
|
43
|
+
optional: true
|
|
44
|
+
});
|
|
45
|
+
constructor(router, route, tabIndexAttribute, renderer, el, locationStrategy) {
|
|
46
|
+
this.router = router;
|
|
47
|
+
this.route = route;
|
|
48
|
+
this.tabIndexAttribute = tabIndexAttribute;
|
|
49
|
+
this.renderer = renderer;
|
|
50
|
+
this.el = el;
|
|
51
|
+
this.locationStrategy = locationStrategy;
|
|
52
|
+
this.reactiveHref.set(inject(new HostAttributeToken('href'), {
|
|
53
|
+
optional: true
|
|
54
|
+
}));
|
|
55
|
+
const tagName = el.nativeElement.tagName?.toLowerCase();
|
|
56
|
+
this.isAnchorElement = tagName === 'a' || tagName === 'area' || !!(typeof customElements === 'object' && customElements.get(tagName)?.observedAttributes?.includes?.('href'));
|
|
57
|
+
if (!this.isAnchorElement) {
|
|
58
|
+
this.subscribeToNavigationEventsIfNecessary();
|
|
59
|
+
} else {
|
|
60
|
+
this.setTabIndexIfNotOnNativeEl('0');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
subscribeToNavigationEventsIfNecessary() {
|
|
64
|
+
if (this.subscription !== undefined || !this.isAnchorElement) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
let createSubcription = this.preserveFragment;
|
|
68
|
+
const dependsOnRouterState = handling => handling === 'merge' || handling === 'preserve';
|
|
69
|
+
createSubcription ||= dependsOnRouterState(this.queryParamsHandling);
|
|
70
|
+
createSubcription ||= !this.queryParamsHandling && !dependsOnRouterState(this.options?.defaultQueryParamsHandling);
|
|
71
|
+
if (!createSubcription) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.subscription = this.router.events.subscribe(s => {
|
|
75
|
+
if (s instanceof NavigationEnd) {
|
|
76
|
+
this.updateHref();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
preserveFragment = false;
|
|
81
|
+
skipLocationChange = false;
|
|
82
|
+
replaceUrl = false;
|
|
83
|
+
setTabIndexIfNotOnNativeEl(newTabIndex) {
|
|
84
|
+
if (this.tabIndexAttribute != null || this.isAnchorElement) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.applyAttributeValue('tabindex', newTabIndex);
|
|
88
|
+
}
|
|
89
|
+
ngOnChanges(changes) {
|
|
90
|
+
if (ngDevMode && isUrlTree(this.routerLinkInput) && (this.fragment !== undefined || this.queryParams || this.queryParamsHandling || this.preserveFragment || this.relativeTo)) {
|
|
91
|
+
throw new _RuntimeError(4017, 'Cannot configure queryParams or fragment when using a UrlTree as the routerLink input value.');
|
|
92
|
+
}
|
|
93
|
+
if (this.isAnchorElement) {
|
|
94
|
+
this.updateHref();
|
|
95
|
+
this.subscribeToNavigationEventsIfNecessary();
|
|
96
|
+
}
|
|
97
|
+
this.onChanges.next(this);
|
|
98
|
+
}
|
|
99
|
+
routerLinkInput = null;
|
|
100
|
+
set routerLink(commandsOrUrlTree) {
|
|
101
|
+
if (commandsOrUrlTree == null) {
|
|
102
|
+
this.routerLinkInput = null;
|
|
103
|
+
this.setTabIndexIfNotOnNativeEl(null);
|
|
104
|
+
} else {
|
|
105
|
+
if (isUrlTree(commandsOrUrlTree)) {
|
|
106
|
+
this.routerLinkInput = commandsOrUrlTree;
|
|
107
|
+
} else {
|
|
108
|
+
this.routerLinkInput = Array.isArray(commandsOrUrlTree) ? commandsOrUrlTree : [commandsOrUrlTree];
|
|
109
|
+
}
|
|
110
|
+
this.setTabIndexIfNotOnNativeEl('0');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
onClick(button, ctrlKey, shiftKey, altKey, metaKey) {
|
|
114
|
+
const urlTree = this.urlTree;
|
|
115
|
+
if (urlTree === null) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
if (this.isAnchorElement) {
|
|
119
|
+
if (button !== 0 || ctrlKey || shiftKey || altKey || metaKey) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
if (typeof this.target === 'string' && this.target != '_self') {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const extras = {
|
|
127
|
+
skipLocationChange: this.skipLocationChange,
|
|
128
|
+
replaceUrl: this.replaceUrl,
|
|
129
|
+
state: this.state,
|
|
130
|
+
info: this.info
|
|
131
|
+
};
|
|
132
|
+
this.router.navigateByUrl(urlTree, extras)?.catch(e => {
|
|
133
|
+
this.applicationErrorHandler(e);
|
|
134
|
+
});
|
|
135
|
+
return !this.isAnchorElement;
|
|
136
|
+
}
|
|
137
|
+
ngOnDestroy() {
|
|
138
|
+
this.subscription?.unsubscribe();
|
|
139
|
+
}
|
|
140
|
+
updateHref() {
|
|
141
|
+
const urlTree = this.urlTree;
|
|
142
|
+
this.reactiveHref.set(urlTree !== null && this.locationStrategy ? this.locationStrategy?.prepareExternalUrl(this.router.serializeUrl(urlTree)) ?? '' : null);
|
|
143
|
+
}
|
|
144
|
+
applyAttributeValue(attrName, attrValue) {
|
|
145
|
+
const renderer = this.renderer;
|
|
146
|
+
const nativeElement = this.el.nativeElement;
|
|
147
|
+
if (attrValue !== null) {
|
|
148
|
+
renderer.setAttribute(nativeElement, attrName, attrValue);
|
|
149
|
+
} else {
|
|
150
|
+
renderer.removeAttribute(nativeElement, attrName);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
get urlTree() {
|
|
154
|
+
if (this.routerLinkInput === null) {
|
|
155
|
+
return null;
|
|
156
|
+
} else if (isUrlTree(this.routerLinkInput)) {
|
|
157
|
+
return this.routerLinkInput;
|
|
158
|
+
}
|
|
159
|
+
return this.router.createUrlTree(this.routerLinkInput, {
|
|
160
|
+
relativeTo: this.relativeTo !== undefined ? this.relativeTo : this.route,
|
|
161
|
+
queryParams: this.queryParams,
|
|
162
|
+
fragment: this.fragment,
|
|
163
|
+
queryParamsHandling: this.queryParamsHandling,
|
|
164
|
+
preserveFragment: this.preserveFragment
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
168
|
+
minVersion: "12.0.0",
|
|
169
|
+
version: "21.0.0-next.10",
|
|
170
|
+
ngImport: i0,
|
|
171
|
+
type: RouterLink,
|
|
172
|
+
deps: [{
|
|
173
|
+
token: Router
|
|
174
|
+
}, {
|
|
175
|
+
token: ActivatedRoute
|
|
176
|
+
}, {
|
|
177
|
+
token: 'tabindex',
|
|
178
|
+
attribute: true
|
|
179
|
+
}, {
|
|
180
|
+
token: i0.Renderer2
|
|
181
|
+
}, {
|
|
182
|
+
token: i0.ElementRef
|
|
183
|
+
}, {
|
|
184
|
+
token: i3.LocationStrategy
|
|
185
|
+
}],
|
|
186
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
187
|
+
});
|
|
188
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
189
|
+
minVersion: "16.1.0",
|
|
190
|
+
version: "21.0.0-next.10",
|
|
191
|
+
type: RouterLink,
|
|
192
|
+
isStandalone: true,
|
|
193
|
+
selector: "[routerLink]",
|
|
194
|
+
inputs: {
|
|
195
|
+
target: "target",
|
|
196
|
+
queryParams: "queryParams",
|
|
197
|
+
fragment: "fragment",
|
|
198
|
+
queryParamsHandling: "queryParamsHandling",
|
|
199
|
+
state: "state",
|
|
200
|
+
info: "info",
|
|
201
|
+
relativeTo: "relativeTo",
|
|
202
|
+
preserveFragment: ["preserveFragment", "preserveFragment", booleanAttribute],
|
|
203
|
+
skipLocationChange: ["skipLocationChange", "skipLocationChange", booleanAttribute],
|
|
204
|
+
replaceUrl: ["replaceUrl", "replaceUrl", booleanAttribute],
|
|
205
|
+
routerLink: "routerLink"
|
|
206
|
+
},
|
|
207
|
+
host: {
|
|
208
|
+
listeners: {
|
|
209
|
+
"click": "onClick($event.button,$event.ctrlKey,$event.shiftKey,$event.altKey,$event.metaKey)"
|
|
210
|
+
},
|
|
211
|
+
properties: {
|
|
212
|
+
"attr.href": "reactiveHref()",
|
|
213
|
+
"attr.target": "this.target"
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
usesOnChanges: true,
|
|
217
|
+
ngImport: i0
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
221
|
+
minVersion: "12.0.0",
|
|
222
|
+
version: "21.0.0-next.10",
|
|
223
|
+
ngImport: i0,
|
|
224
|
+
type: RouterLink,
|
|
225
|
+
decorators: [{
|
|
226
|
+
type: Directive,
|
|
227
|
+
args: [{
|
|
228
|
+
selector: '[routerLink]',
|
|
229
|
+
host: {
|
|
230
|
+
'[attr.href]': 'reactiveHref()'
|
|
231
|
+
}
|
|
232
|
+
}]
|
|
233
|
+
}],
|
|
234
|
+
ctorParameters: () => [{
|
|
235
|
+
type: Router
|
|
236
|
+
}, {
|
|
237
|
+
type: ActivatedRoute
|
|
238
|
+
}, {
|
|
239
|
+
type: undefined,
|
|
240
|
+
decorators: [{
|
|
241
|
+
type: Attribute,
|
|
242
|
+
args: ['tabindex']
|
|
243
|
+
}]
|
|
244
|
+
}, {
|
|
245
|
+
type: i0.Renderer2
|
|
246
|
+
}, {
|
|
247
|
+
type: i0.ElementRef
|
|
248
|
+
}, {
|
|
249
|
+
type: i3.LocationStrategy
|
|
250
|
+
}],
|
|
251
|
+
propDecorators: {
|
|
252
|
+
target: [{
|
|
253
|
+
type: HostBinding,
|
|
254
|
+
args: ['attr.target']
|
|
255
|
+
}, {
|
|
256
|
+
type: Input
|
|
257
|
+
}],
|
|
258
|
+
queryParams: [{
|
|
259
|
+
type: Input
|
|
260
|
+
}],
|
|
261
|
+
fragment: [{
|
|
262
|
+
type: Input
|
|
263
|
+
}],
|
|
264
|
+
queryParamsHandling: [{
|
|
265
|
+
type: Input
|
|
266
|
+
}],
|
|
267
|
+
state: [{
|
|
268
|
+
type: Input
|
|
269
|
+
}],
|
|
270
|
+
info: [{
|
|
271
|
+
type: Input
|
|
272
|
+
}],
|
|
273
|
+
relativeTo: [{
|
|
274
|
+
type: Input
|
|
275
|
+
}],
|
|
276
|
+
preserveFragment: [{
|
|
277
|
+
type: Input,
|
|
278
|
+
args: [{
|
|
279
|
+
transform: booleanAttribute
|
|
280
|
+
}]
|
|
281
|
+
}],
|
|
282
|
+
skipLocationChange: [{
|
|
283
|
+
type: Input,
|
|
284
|
+
args: [{
|
|
285
|
+
transform: booleanAttribute
|
|
286
|
+
}]
|
|
287
|
+
}],
|
|
288
|
+
replaceUrl: [{
|
|
289
|
+
type: Input,
|
|
290
|
+
args: [{
|
|
291
|
+
transform: booleanAttribute
|
|
292
|
+
}]
|
|
293
|
+
}],
|
|
294
|
+
routerLink: [{
|
|
295
|
+
type: Input
|
|
296
|
+
}],
|
|
297
|
+
onClick: [{
|
|
298
|
+
type: HostListener,
|
|
299
|
+
args: ['click', ['$event.button', '$event.ctrlKey', '$event.shiftKey', '$event.altKey', '$event.metaKey']]
|
|
300
|
+
}]
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
class RouterLinkActive {
|
|
305
|
+
router;
|
|
306
|
+
element;
|
|
307
|
+
renderer;
|
|
308
|
+
cdr;
|
|
309
|
+
link;
|
|
310
|
+
links;
|
|
311
|
+
classes = [];
|
|
312
|
+
routerEventsSubscription;
|
|
313
|
+
linkInputChangesSubscription;
|
|
314
|
+
_isActive = false;
|
|
315
|
+
get isActive() {
|
|
316
|
+
return this._isActive;
|
|
317
|
+
}
|
|
318
|
+
routerLinkActiveOptions = {
|
|
319
|
+
exact: false
|
|
320
|
+
};
|
|
321
|
+
ariaCurrentWhenActive;
|
|
322
|
+
isActiveChange = new EventEmitter();
|
|
323
|
+
constructor(router, element, renderer, cdr, link) {
|
|
324
|
+
this.router = router;
|
|
325
|
+
this.element = element;
|
|
326
|
+
this.renderer = renderer;
|
|
327
|
+
this.cdr = cdr;
|
|
328
|
+
this.link = link;
|
|
329
|
+
this.routerEventsSubscription = router.events.subscribe(s => {
|
|
330
|
+
if (s instanceof NavigationEnd) {
|
|
331
|
+
this.update();
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
ngAfterContentInit() {
|
|
336
|
+
of(this.links.changes, of(null)).pipe(mergeAll()).subscribe(_ => {
|
|
337
|
+
this.update();
|
|
338
|
+
this.subscribeToEachLinkOnChanges();
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
subscribeToEachLinkOnChanges() {
|
|
342
|
+
this.linkInputChangesSubscription?.unsubscribe();
|
|
343
|
+
const allLinkChanges = [...this.links.toArray(), this.link].filter(link => !!link).map(link => link.onChanges);
|
|
344
|
+
this.linkInputChangesSubscription = from(allLinkChanges).pipe(mergeAll()).subscribe(link => {
|
|
345
|
+
if (this._isActive !== this.isLinkActive(this.router)(link)) {
|
|
346
|
+
this.update();
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
set routerLinkActive(data) {
|
|
351
|
+
const classes = Array.isArray(data) ? data : data.split(' ');
|
|
352
|
+
this.classes = classes.filter(c => !!c);
|
|
353
|
+
}
|
|
354
|
+
ngOnChanges(changes) {
|
|
355
|
+
this.update();
|
|
356
|
+
}
|
|
357
|
+
ngOnDestroy() {
|
|
358
|
+
this.routerEventsSubscription.unsubscribe();
|
|
359
|
+
this.linkInputChangesSubscription?.unsubscribe();
|
|
360
|
+
}
|
|
361
|
+
update() {
|
|
362
|
+
if (!this.links || !this.router.navigated) return;
|
|
363
|
+
queueMicrotask(() => {
|
|
364
|
+
const hasActiveLinks = this.hasActiveLinks();
|
|
365
|
+
this.classes.forEach(c => {
|
|
366
|
+
if (hasActiveLinks) {
|
|
367
|
+
this.renderer.addClass(this.element.nativeElement, c);
|
|
368
|
+
} else {
|
|
369
|
+
this.renderer.removeClass(this.element.nativeElement, c);
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
if (hasActiveLinks && this.ariaCurrentWhenActive !== undefined) {
|
|
373
|
+
this.renderer.setAttribute(this.element.nativeElement, 'aria-current', this.ariaCurrentWhenActive.toString());
|
|
374
|
+
} else {
|
|
375
|
+
this.renderer.removeAttribute(this.element.nativeElement, 'aria-current');
|
|
376
|
+
}
|
|
377
|
+
if (this._isActive !== hasActiveLinks) {
|
|
378
|
+
this._isActive = hasActiveLinks;
|
|
379
|
+
this.cdr.markForCheck();
|
|
380
|
+
this.isActiveChange.emit(hasActiveLinks);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
isLinkActive(router) {
|
|
385
|
+
const options = isActiveMatchOptions(this.routerLinkActiveOptions) ? this.routerLinkActiveOptions : this.routerLinkActiveOptions.exact || false;
|
|
386
|
+
return link => {
|
|
387
|
+
const urlTree = link.urlTree;
|
|
388
|
+
return urlTree ? router.isActive(urlTree, options) : false;
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
hasActiveLinks() {
|
|
392
|
+
const isActiveCheckFn = this.isLinkActive(this.router);
|
|
393
|
+
return this.link && isActiveCheckFn(this.link) || this.links.some(isActiveCheckFn);
|
|
394
|
+
}
|
|
395
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
396
|
+
minVersion: "12.0.0",
|
|
397
|
+
version: "21.0.0-next.10",
|
|
398
|
+
ngImport: i0,
|
|
399
|
+
type: RouterLinkActive,
|
|
400
|
+
deps: [{
|
|
401
|
+
token: Router
|
|
402
|
+
}, {
|
|
403
|
+
token: i0.ElementRef
|
|
404
|
+
}, {
|
|
405
|
+
token: i0.Renderer2
|
|
406
|
+
}, {
|
|
407
|
+
token: i0.ChangeDetectorRef
|
|
408
|
+
}, {
|
|
409
|
+
token: RouterLink,
|
|
410
|
+
optional: true
|
|
411
|
+
}],
|
|
412
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
413
|
+
});
|
|
414
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
415
|
+
minVersion: "14.0.0",
|
|
416
|
+
version: "21.0.0-next.10",
|
|
417
|
+
type: RouterLinkActive,
|
|
418
|
+
isStandalone: true,
|
|
419
|
+
selector: "[routerLinkActive]",
|
|
420
|
+
inputs: {
|
|
421
|
+
routerLinkActiveOptions: "routerLinkActiveOptions",
|
|
422
|
+
ariaCurrentWhenActive: "ariaCurrentWhenActive",
|
|
423
|
+
routerLinkActive: "routerLinkActive"
|
|
424
|
+
},
|
|
425
|
+
outputs: {
|
|
426
|
+
isActiveChange: "isActiveChange"
|
|
427
|
+
},
|
|
428
|
+
queries: [{
|
|
429
|
+
propertyName: "links",
|
|
430
|
+
predicate: RouterLink,
|
|
431
|
+
descendants: true
|
|
432
|
+
}],
|
|
433
|
+
exportAs: ["routerLinkActive"],
|
|
434
|
+
usesOnChanges: true,
|
|
435
|
+
ngImport: i0
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
439
|
+
minVersion: "12.0.0",
|
|
440
|
+
version: "21.0.0-next.10",
|
|
441
|
+
ngImport: i0,
|
|
442
|
+
type: RouterLinkActive,
|
|
443
|
+
decorators: [{
|
|
444
|
+
type: Directive,
|
|
445
|
+
args: [{
|
|
446
|
+
selector: '[routerLinkActive]',
|
|
447
|
+
exportAs: 'routerLinkActive'
|
|
448
|
+
}]
|
|
449
|
+
}],
|
|
450
|
+
ctorParameters: () => [{
|
|
451
|
+
type: Router
|
|
452
|
+
}, {
|
|
453
|
+
type: i0.ElementRef
|
|
454
|
+
}, {
|
|
455
|
+
type: i0.Renderer2
|
|
456
|
+
}, {
|
|
457
|
+
type: i0.ChangeDetectorRef
|
|
458
|
+
}, {
|
|
459
|
+
type: RouterLink,
|
|
460
|
+
decorators: [{
|
|
461
|
+
type: Optional
|
|
462
|
+
}]
|
|
463
|
+
}],
|
|
464
|
+
propDecorators: {
|
|
465
|
+
links: [{
|
|
466
|
+
type: ContentChildren,
|
|
467
|
+
args: [RouterLink, {
|
|
468
|
+
descendants: true
|
|
469
|
+
}]
|
|
470
|
+
}],
|
|
471
|
+
routerLinkActiveOptions: [{
|
|
472
|
+
type: Input
|
|
473
|
+
}],
|
|
474
|
+
ariaCurrentWhenActive: [{
|
|
475
|
+
type: Input
|
|
476
|
+
}],
|
|
477
|
+
isActiveChange: [{
|
|
478
|
+
type: Output
|
|
479
|
+
}],
|
|
480
|
+
routerLinkActive: [{
|
|
481
|
+
type: Input
|
|
482
|
+
}]
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
function isActiveMatchOptions(options) {
|
|
486
|
+
return !!options.paths;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
class PreloadingStrategy {}
|
|
490
|
+
class PreloadAllModules {
|
|
491
|
+
preload(route, fn) {
|
|
492
|
+
return fn().pipe(catchError(() => of(null)));
|
|
493
|
+
}
|
|
494
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
495
|
+
minVersion: "12.0.0",
|
|
496
|
+
version: "21.0.0-next.10",
|
|
497
|
+
ngImport: i0,
|
|
498
|
+
type: PreloadAllModules,
|
|
499
|
+
deps: [],
|
|
500
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
501
|
+
});
|
|
502
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
503
|
+
minVersion: "12.0.0",
|
|
504
|
+
version: "21.0.0-next.10",
|
|
505
|
+
ngImport: i0,
|
|
506
|
+
type: PreloadAllModules,
|
|
507
|
+
providedIn: 'root'
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
511
|
+
minVersion: "12.0.0",
|
|
512
|
+
version: "21.0.0-next.10",
|
|
513
|
+
ngImport: i0,
|
|
514
|
+
type: PreloadAllModules,
|
|
515
|
+
decorators: [{
|
|
516
|
+
type: Injectable,
|
|
517
|
+
args: [{
|
|
518
|
+
providedIn: 'root'
|
|
519
|
+
}]
|
|
520
|
+
}]
|
|
521
|
+
});
|
|
522
|
+
class NoPreloading {
|
|
523
|
+
preload(route, fn) {
|
|
524
|
+
return of(null);
|
|
525
|
+
}
|
|
526
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
527
|
+
minVersion: "12.0.0",
|
|
528
|
+
version: "21.0.0-next.10",
|
|
529
|
+
ngImport: i0,
|
|
530
|
+
type: NoPreloading,
|
|
531
|
+
deps: [],
|
|
532
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
533
|
+
});
|
|
534
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
535
|
+
minVersion: "12.0.0",
|
|
536
|
+
version: "21.0.0-next.10",
|
|
537
|
+
ngImport: i0,
|
|
538
|
+
type: NoPreloading,
|
|
539
|
+
providedIn: 'root'
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
543
|
+
minVersion: "12.0.0",
|
|
544
|
+
version: "21.0.0-next.10",
|
|
545
|
+
ngImport: i0,
|
|
546
|
+
type: NoPreloading,
|
|
547
|
+
decorators: [{
|
|
548
|
+
type: Injectable,
|
|
549
|
+
args: [{
|
|
550
|
+
providedIn: 'root'
|
|
551
|
+
}]
|
|
552
|
+
}]
|
|
553
|
+
});
|
|
554
|
+
class RouterPreloader {
|
|
555
|
+
router;
|
|
556
|
+
injector;
|
|
557
|
+
preloadingStrategy;
|
|
558
|
+
loader;
|
|
559
|
+
subscription;
|
|
560
|
+
constructor(router, injector, preloadingStrategy, loader) {
|
|
561
|
+
this.router = router;
|
|
562
|
+
this.injector = injector;
|
|
563
|
+
this.preloadingStrategy = preloadingStrategy;
|
|
564
|
+
this.loader = loader;
|
|
565
|
+
}
|
|
566
|
+
setUpPreloading() {
|
|
567
|
+
this.subscription = this.router.events.pipe(filter(e => e instanceof NavigationEnd), concatMap(() => this.preload())).subscribe(() => {});
|
|
568
|
+
}
|
|
569
|
+
preload() {
|
|
570
|
+
return this.processRoutes(this.injector, this.router.config);
|
|
571
|
+
}
|
|
572
|
+
ngOnDestroy() {
|
|
573
|
+
if (this.subscription) {
|
|
574
|
+
this.subscription.unsubscribe();
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
processRoutes(injector, routes) {
|
|
578
|
+
const res = [];
|
|
579
|
+
for (const route of routes) {
|
|
580
|
+
if (route.providers && !route._injector) {
|
|
581
|
+
route._injector = createEnvironmentInjector(route.providers, injector, `Route: ${route.path}`);
|
|
582
|
+
}
|
|
583
|
+
const injectorForCurrentRoute = route._injector ?? injector;
|
|
584
|
+
const injectorForChildren = route._loadedInjector ?? injectorForCurrentRoute;
|
|
585
|
+
if (route.loadChildren && !route._loadedRoutes && route.canLoad === undefined || route.loadComponent && !route._loadedComponent) {
|
|
586
|
+
res.push(this.preloadConfig(injectorForCurrentRoute, route));
|
|
587
|
+
}
|
|
588
|
+
if (route.children || route._loadedRoutes) {
|
|
589
|
+
res.push(this.processRoutes(injectorForChildren, route.children ?? route._loadedRoutes));
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
return from(res).pipe(mergeAll());
|
|
593
|
+
}
|
|
594
|
+
preloadConfig(injector, route) {
|
|
595
|
+
return this.preloadingStrategy.preload(route, () => {
|
|
596
|
+
let loadedChildren$;
|
|
597
|
+
if (route.loadChildren && route.canLoad === undefined) {
|
|
598
|
+
loadedChildren$ = from(this.loader.loadChildren(injector, route));
|
|
599
|
+
} else {
|
|
600
|
+
loadedChildren$ = of(null);
|
|
601
|
+
}
|
|
602
|
+
const recursiveLoadChildren$ = loadedChildren$.pipe(mergeMap(config => {
|
|
603
|
+
if (config === null) {
|
|
604
|
+
return of(void 0);
|
|
605
|
+
}
|
|
606
|
+
route._loadedRoutes = config.routes;
|
|
607
|
+
route._loadedInjector = config.injector;
|
|
608
|
+
return this.processRoutes(config.injector ?? injector, config.routes);
|
|
609
|
+
}));
|
|
610
|
+
if (route.loadComponent && !route._loadedComponent) {
|
|
611
|
+
const loadComponent$ = this.loader.loadComponent(injector, route);
|
|
612
|
+
return from([recursiveLoadChildren$, loadComponent$]).pipe(mergeAll());
|
|
613
|
+
} else {
|
|
614
|
+
return recursiveLoadChildren$;
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
619
|
+
minVersion: "12.0.0",
|
|
620
|
+
version: "21.0.0-next.10",
|
|
621
|
+
ngImport: i0,
|
|
622
|
+
type: RouterPreloader,
|
|
623
|
+
deps: [{
|
|
624
|
+
token: Router
|
|
625
|
+
}, {
|
|
626
|
+
token: i0.EnvironmentInjector
|
|
627
|
+
}, {
|
|
628
|
+
token: PreloadingStrategy
|
|
629
|
+
}, {
|
|
630
|
+
token: RouterConfigLoader
|
|
631
|
+
}],
|
|
632
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
633
|
+
});
|
|
634
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
635
|
+
minVersion: "12.0.0",
|
|
636
|
+
version: "21.0.0-next.10",
|
|
637
|
+
ngImport: i0,
|
|
638
|
+
type: RouterPreloader,
|
|
639
|
+
providedIn: 'root'
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
643
|
+
minVersion: "12.0.0",
|
|
644
|
+
version: "21.0.0-next.10",
|
|
645
|
+
ngImport: i0,
|
|
646
|
+
type: RouterPreloader,
|
|
647
|
+
decorators: [{
|
|
648
|
+
type: Injectable,
|
|
649
|
+
args: [{
|
|
650
|
+
providedIn: 'root'
|
|
651
|
+
}]
|
|
652
|
+
}],
|
|
653
|
+
ctorParameters: () => [{
|
|
654
|
+
type: Router
|
|
655
|
+
}, {
|
|
656
|
+
type: i0.EnvironmentInjector
|
|
657
|
+
}, {
|
|
658
|
+
type: PreloadingStrategy
|
|
659
|
+
}, {
|
|
660
|
+
type: RouterConfigLoader
|
|
661
|
+
}]
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
const ROUTER_SCROLLER = new InjectionToken('');
|
|
665
|
+
class RouterScroller {
|
|
666
|
+
urlSerializer;
|
|
667
|
+
transitions;
|
|
668
|
+
viewportScroller;
|
|
669
|
+
zone;
|
|
670
|
+
options;
|
|
671
|
+
routerEventsSubscription;
|
|
672
|
+
scrollEventsSubscription;
|
|
673
|
+
lastId = 0;
|
|
674
|
+
lastSource = IMPERATIVE_NAVIGATION;
|
|
675
|
+
restoredId = 0;
|
|
676
|
+
store = {};
|
|
677
|
+
constructor(urlSerializer, transitions, viewportScroller, zone, options = {}) {
|
|
678
|
+
this.urlSerializer = urlSerializer;
|
|
679
|
+
this.transitions = transitions;
|
|
680
|
+
this.viewportScroller = viewportScroller;
|
|
681
|
+
this.zone = zone;
|
|
682
|
+
this.options = options;
|
|
683
|
+
options.scrollPositionRestoration ||= 'disabled';
|
|
684
|
+
options.anchorScrolling ||= 'disabled';
|
|
685
|
+
}
|
|
686
|
+
init() {
|
|
687
|
+
if (this.options.scrollPositionRestoration !== 'disabled') {
|
|
688
|
+
this.viewportScroller.setHistoryScrollRestoration('manual');
|
|
689
|
+
}
|
|
690
|
+
this.routerEventsSubscription = this.createScrollEvents();
|
|
691
|
+
this.scrollEventsSubscription = this.consumeScrollEvents();
|
|
692
|
+
}
|
|
693
|
+
createScrollEvents() {
|
|
694
|
+
return this.transitions.events.subscribe(e => {
|
|
695
|
+
if (e instanceof NavigationStart) {
|
|
696
|
+
this.store[this.lastId] = this.viewportScroller.getScrollPosition();
|
|
697
|
+
this.lastSource = e.navigationTrigger;
|
|
698
|
+
this.restoredId = e.restoredState ? e.restoredState.navigationId : 0;
|
|
699
|
+
} else if (e instanceof NavigationEnd) {
|
|
700
|
+
this.lastId = e.id;
|
|
701
|
+
this.scheduleScrollEvent(e, this.urlSerializer.parse(e.urlAfterRedirects).fragment);
|
|
702
|
+
} else if (e instanceof NavigationSkipped && e.code === NavigationSkippedCode.IgnoredSameUrlNavigation) {
|
|
703
|
+
this.lastSource = undefined;
|
|
704
|
+
this.restoredId = 0;
|
|
705
|
+
this.scheduleScrollEvent(e, this.urlSerializer.parse(e.url).fragment);
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
consumeScrollEvents() {
|
|
710
|
+
return this.transitions.events.subscribe(e => {
|
|
711
|
+
if (!(e instanceof Scroll)) return;
|
|
712
|
+
const instantScroll = {
|
|
713
|
+
behavior: 'instant'
|
|
714
|
+
};
|
|
715
|
+
if (e.position) {
|
|
716
|
+
if (this.options.scrollPositionRestoration === 'top') {
|
|
717
|
+
this.viewportScroller.scrollToPosition([0, 0], instantScroll);
|
|
718
|
+
} else if (this.options.scrollPositionRestoration === 'enabled') {
|
|
719
|
+
this.viewportScroller.scrollToPosition(e.position, instantScroll);
|
|
720
|
+
}
|
|
721
|
+
} else {
|
|
722
|
+
if (e.anchor && this.options.anchorScrolling === 'enabled') {
|
|
723
|
+
this.viewportScroller.scrollToAnchor(e.anchor);
|
|
724
|
+
} else if (this.options.scrollPositionRestoration !== 'disabled') {
|
|
725
|
+
this.viewportScroller.scrollToPosition([0, 0]);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
scheduleScrollEvent(routerEvent, anchor) {
|
|
731
|
+
this.zone.runOutsideAngular(async () => {
|
|
732
|
+
await new Promise(resolve => {
|
|
733
|
+
setTimeout(resolve);
|
|
734
|
+
if (typeof requestAnimationFrame !== 'undefined') {
|
|
735
|
+
requestAnimationFrame(resolve);
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
this.zone.run(() => {
|
|
739
|
+
this.transitions.events.next(new Scroll(routerEvent, this.lastSource === 'popstate' ? this.store[this.restoredId] : null, anchor));
|
|
740
|
+
});
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
ngOnDestroy() {
|
|
744
|
+
this.routerEventsSubscription?.unsubscribe();
|
|
745
|
+
this.scrollEventsSubscription?.unsubscribe();
|
|
746
|
+
}
|
|
747
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
748
|
+
minVersion: "12.0.0",
|
|
749
|
+
version: "21.0.0-next.10",
|
|
750
|
+
ngImport: i0,
|
|
751
|
+
type: RouterScroller,
|
|
752
|
+
deps: "invalid",
|
|
753
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
754
|
+
});
|
|
755
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
756
|
+
minVersion: "12.0.0",
|
|
757
|
+
version: "21.0.0-next.10",
|
|
758
|
+
ngImport: i0,
|
|
759
|
+
type: RouterScroller
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
763
|
+
minVersion: "12.0.0",
|
|
764
|
+
version: "21.0.0-next.10",
|
|
765
|
+
ngImport: i0,
|
|
766
|
+
type: RouterScroller,
|
|
767
|
+
decorators: [{
|
|
768
|
+
type: Injectable
|
|
769
|
+
}],
|
|
770
|
+
ctorParameters: () => [{
|
|
771
|
+
type: UrlSerializer
|
|
772
|
+
}, {
|
|
773
|
+
type: NavigationTransitions
|
|
774
|
+
}, {
|
|
775
|
+
type: i3.ViewportScroller
|
|
776
|
+
}, {
|
|
777
|
+
type: i0.NgZone
|
|
778
|
+
}, {
|
|
779
|
+
type: undefined
|
|
780
|
+
}]
|
|
781
|
+
});
|
|
782
|
+
|
|
783
|
+
function getLoadedRoutes(route) {
|
|
784
|
+
return route._loadedRoutes;
|
|
785
|
+
}
|
|
786
|
+
function getRouterInstance(injector) {
|
|
787
|
+
return injector.get(Router, null, {
|
|
788
|
+
optional: true
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
function navigateByUrl(router, url) {
|
|
792
|
+
if (!(router instanceof Router)) {
|
|
793
|
+
throw new Error('The provided router is not an Angular Router.');
|
|
794
|
+
}
|
|
795
|
+
return router.navigateByUrl(url);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
class NavigationStateManager extends HistoryStateManager {
|
|
799
|
+
navigation = inject(PlatformNavigation);
|
|
800
|
+
registerNonRouterCurrentEntryChangeListener(listener) {
|
|
801
|
+
return this.location.subscribe(event => {
|
|
802
|
+
if (event['type'] === 'popstate') {
|
|
803
|
+
const state = this.navigation.currentEntry?.getState();
|
|
804
|
+
listener(event['url'], state, 'popstate');
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
809
|
+
minVersion: "12.0.0",
|
|
810
|
+
version: "21.0.0-next.10",
|
|
811
|
+
ngImport: i0,
|
|
812
|
+
type: NavigationStateManager,
|
|
813
|
+
deps: null,
|
|
814
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
815
|
+
});
|
|
816
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
817
|
+
minVersion: "12.0.0",
|
|
818
|
+
version: "21.0.0-next.10",
|
|
819
|
+
ngImport: i0,
|
|
820
|
+
type: NavigationStateManager,
|
|
821
|
+
providedIn: 'root'
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
825
|
+
minVersion: "12.0.0",
|
|
826
|
+
version: "21.0.0-next.10",
|
|
827
|
+
ngImport: i0,
|
|
828
|
+
type: NavigationStateManager,
|
|
829
|
+
decorators: [{
|
|
830
|
+
type: Injectable,
|
|
831
|
+
args: [{
|
|
832
|
+
providedIn: 'root'
|
|
833
|
+
}]
|
|
834
|
+
}]
|
|
835
|
+
});
|
|
836
|
+
|
|
837
|
+
function provideRouter(routes, ...features) {
|
|
838
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
839
|
+
_publishExternalGlobalUtil('ɵgetLoadedRoutes', getLoadedRoutes);
|
|
840
|
+
_publishExternalGlobalUtil('ɵgetRouterInstance', getRouterInstance);
|
|
841
|
+
_publishExternalGlobalUtil('ɵnavigateByUrl', navigateByUrl);
|
|
842
|
+
}
|
|
843
|
+
return makeEnvironmentProviders([{
|
|
844
|
+
provide: ROUTES,
|
|
845
|
+
multi: true,
|
|
846
|
+
useValue: routes
|
|
847
|
+
}, typeof ngDevMode === 'undefined' || ngDevMode ? {
|
|
848
|
+
provide: ROUTER_IS_PROVIDED,
|
|
849
|
+
useValue: true
|
|
850
|
+
} : [], {
|
|
851
|
+
provide: ActivatedRoute,
|
|
852
|
+
useFactory: rootRoute
|
|
853
|
+
}, {
|
|
854
|
+
provide: APP_BOOTSTRAP_LISTENER,
|
|
855
|
+
multi: true,
|
|
856
|
+
useFactory: getBootstrapListener
|
|
857
|
+
}, features.map(feature => feature.ɵproviders)]);
|
|
858
|
+
}
|
|
859
|
+
function rootRoute() {
|
|
860
|
+
return inject(Router).routerState.root;
|
|
861
|
+
}
|
|
862
|
+
function routerFeature(kind, providers) {
|
|
863
|
+
return {
|
|
864
|
+
ɵkind: kind,
|
|
865
|
+
ɵproviders: providers
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
const ROUTER_IS_PROVIDED = new InjectionToken('', {
|
|
869
|
+
providedIn: 'root',
|
|
870
|
+
factory: () => false
|
|
871
|
+
});
|
|
872
|
+
const routerIsProvidedDevModeCheck = {
|
|
873
|
+
provide: ENVIRONMENT_INITIALIZER,
|
|
874
|
+
multi: true,
|
|
875
|
+
useFactory() {
|
|
876
|
+
return () => {
|
|
877
|
+
if (!inject(ROUTER_IS_PROVIDED)) {
|
|
878
|
+
console.warn('`provideRoutes` was called without `provideRouter` or `RouterModule.forRoot`. ' + 'This is likely a mistake.');
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
function provideRoutes(routes) {
|
|
884
|
+
return [{
|
|
885
|
+
provide: ROUTES,
|
|
886
|
+
multi: true,
|
|
887
|
+
useValue: routes
|
|
888
|
+
}, typeof ngDevMode === 'undefined' || ngDevMode ? routerIsProvidedDevModeCheck : []];
|
|
889
|
+
}
|
|
890
|
+
function withInMemoryScrolling(options = {}) {
|
|
891
|
+
const providers = [{
|
|
892
|
+
provide: ROUTER_SCROLLER,
|
|
893
|
+
useFactory: () => {
|
|
894
|
+
const viewportScroller = inject(ViewportScroller);
|
|
895
|
+
const zone = inject(NgZone);
|
|
896
|
+
const transitions = inject(NavigationTransitions);
|
|
897
|
+
const urlSerializer = inject(UrlSerializer);
|
|
898
|
+
return new RouterScroller(urlSerializer, transitions, viewportScroller, zone, options);
|
|
899
|
+
}
|
|
900
|
+
}];
|
|
901
|
+
return routerFeature(4, providers);
|
|
902
|
+
}
|
|
903
|
+
function withPlatformNavigation() {
|
|
904
|
+
const devModeLocationCheck = typeof ngDevMode === 'undefined' || ngDevMode ? [provideEnvironmentInitializer(() => {
|
|
905
|
+
const locationInstance = inject(Location);
|
|
906
|
+
if (!(locationInstance instanceof _NavigationAdapterForLocation)) {
|
|
907
|
+
const locationConstructorName = locationInstance.constructor.name;
|
|
908
|
+
let message = `'withPlatformNavigation' provides a 'Location' implementation that ensures navigation APIs are consistently used.` + ` An instance of ${locationConstructorName} was found instead.`;
|
|
909
|
+
if (locationConstructorName === 'SpyLocation') {
|
|
910
|
+
message += ` One of 'RouterTestingModule' or 'provideLocationMocks' was likely used. 'withPlatformNavigation' does not work with these because they override the Location implementation.`;
|
|
911
|
+
}
|
|
912
|
+
throw new Error(message);
|
|
913
|
+
}
|
|
914
|
+
})] : [];
|
|
915
|
+
const providers = [{
|
|
916
|
+
provide: StateManager,
|
|
917
|
+
useExisting: NavigationStateManager
|
|
918
|
+
}, {
|
|
919
|
+
provide: Location,
|
|
920
|
+
useClass: _NavigationAdapterForLocation
|
|
921
|
+
}, devModeLocationCheck];
|
|
922
|
+
return routerFeature(4, providers);
|
|
923
|
+
}
|
|
924
|
+
function getBootstrapListener() {
|
|
925
|
+
const injector = inject(Injector);
|
|
926
|
+
return bootstrappedComponentRef => {
|
|
927
|
+
const ref = injector.get(ApplicationRef);
|
|
928
|
+
if (bootstrappedComponentRef !== ref.components[0]) {
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
const router = injector.get(Router);
|
|
932
|
+
const bootstrapDone = injector.get(BOOTSTRAP_DONE);
|
|
933
|
+
if (injector.get(INITIAL_NAVIGATION) === 1) {
|
|
934
|
+
router.initialNavigation();
|
|
935
|
+
}
|
|
936
|
+
injector.get(ROUTER_PRELOADER, null, {
|
|
937
|
+
optional: true
|
|
938
|
+
})?.setUpPreloading();
|
|
939
|
+
injector.get(ROUTER_SCROLLER, null, {
|
|
940
|
+
optional: true
|
|
941
|
+
})?.init();
|
|
942
|
+
router.resetRootComponentType(ref.componentTypes[0]);
|
|
943
|
+
if (!bootstrapDone.closed) {
|
|
944
|
+
bootstrapDone.next();
|
|
945
|
+
bootstrapDone.complete();
|
|
946
|
+
bootstrapDone.unsubscribe();
|
|
947
|
+
}
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
const BOOTSTRAP_DONE = new InjectionToken(typeof ngDevMode === 'undefined' || ngDevMode ? 'bootstrap done indicator' : '', {
|
|
951
|
+
factory: () => {
|
|
952
|
+
return new Subject();
|
|
953
|
+
}
|
|
954
|
+
});
|
|
955
|
+
const INITIAL_NAVIGATION = new InjectionToken(typeof ngDevMode === 'undefined' || ngDevMode ? 'initial navigation' : '', {
|
|
956
|
+
providedIn: 'root',
|
|
957
|
+
factory: () => 1
|
|
958
|
+
});
|
|
959
|
+
function withEnabledBlockingInitialNavigation() {
|
|
960
|
+
const providers = [{
|
|
961
|
+
provide: _IS_ENABLED_BLOCKING_INITIAL_NAVIGATION,
|
|
962
|
+
useValue: true
|
|
963
|
+
}, {
|
|
964
|
+
provide: INITIAL_NAVIGATION,
|
|
965
|
+
useValue: 0
|
|
966
|
+
}, provideAppInitializer(() => {
|
|
967
|
+
const injector = inject(Injector);
|
|
968
|
+
const locationInitialized = injector.get(LOCATION_INITIALIZED, Promise.resolve());
|
|
969
|
+
return locationInitialized.then(() => {
|
|
970
|
+
return new Promise(resolve => {
|
|
971
|
+
const router = injector.get(Router);
|
|
972
|
+
const bootstrapDone = injector.get(BOOTSTRAP_DONE);
|
|
973
|
+
afterNextNavigation(router, () => {
|
|
974
|
+
resolve(true);
|
|
975
|
+
});
|
|
976
|
+
injector.get(NavigationTransitions).afterPreactivation = () => {
|
|
977
|
+
resolve(true);
|
|
978
|
+
return bootstrapDone.closed ? of(void 0) : bootstrapDone;
|
|
979
|
+
};
|
|
980
|
+
router.initialNavigation();
|
|
981
|
+
});
|
|
982
|
+
});
|
|
983
|
+
})];
|
|
984
|
+
return routerFeature(2, providers);
|
|
985
|
+
}
|
|
986
|
+
function withDisabledInitialNavigation() {
|
|
987
|
+
const providers = [provideAppInitializer(() => {
|
|
988
|
+
inject(Router).setUpLocationChangeListener();
|
|
989
|
+
}), {
|
|
990
|
+
provide: INITIAL_NAVIGATION,
|
|
991
|
+
useValue: 2
|
|
992
|
+
}];
|
|
993
|
+
return routerFeature(3, providers);
|
|
994
|
+
}
|
|
995
|
+
function withDebugTracing() {
|
|
996
|
+
let providers = [];
|
|
997
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
998
|
+
providers = [{
|
|
999
|
+
provide: ENVIRONMENT_INITIALIZER,
|
|
1000
|
+
multi: true,
|
|
1001
|
+
useFactory: () => {
|
|
1002
|
+
const router = inject(Router);
|
|
1003
|
+
return () => router.events.subscribe(e => {
|
|
1004
|
+
console.group?.(`Router Event: ${e.constructor.name}`);
|
|
1005
|
+
console.log(stringifyEvent(e));
|
|
1006
|
+
console.log(e);
|
|
1007
|
+
console.groupEnd?.();
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
}];
|
|
1011
|
+
} else {
|
|
1012
|
+
providers = [];
|
|
1013
|
+
}
|
|
1014
|
+
return routerFeature(1, providers);
|
|
1015
|
+
}
|
|
1016
|
+
const ROUTER_PRELOADER = new InjectionToken(typeof ngDevMode === 'undefined' || ngDevMode ? 'router preloader' : '');
|
|
1017
|
+
function withPreloading(preloadingStrategy) {
|
|
1018
|
+
const providers = [{
|
|
1019
|
+
provide: ROUTER_PRELOADER,
|
|
1020
|
+
useExisting: RouterPreloader
|
|
1021
|
+
}, {
|
|
1022
|
+
provide: PreloadingStrategy,
|
|
1023
|
+
useExisting: preloadingStrategy
|
|
1024
|
+
}];
|
|
1025
|
+
return routerFeature(0, providers);
|
|
1026
|
+
}
|
|
1027
|
+
function withRouterConfig(options) {
|
|
1028
|
+
const providers = [{
|
|
1029
|
+
provide: ROUTER_CONFIGURATION,
|
|
1030
|
+
useValue: options
|
|
1031
|
+
}];
|
|
1032
|
+
return routerFeature(5, providers);
|
|
1033
|
+
}
|
|
1034
|
+
function withHashLocation() {
|
|
1035
|
+
const providers = [{
|
|
1036
|
+
provide: LocationStrategy,
|
|
1037
|
+
useClass: HashLocationStrategy
|
|
1038
|
+
}];
|
|
1039
|
+
return routerFeature(6, providers);
|
|
1040
|
+
}
|
|
1041
|
+
function withNavigationErrorHandler(handler) {
|
|
1042
|
+
const providers = [{
|
|
1043
|
+
provide: NAVIGATION_ERROR_HANDLER,
|
|
1044
|
+
useValue: handler
|
|
1045
|
+
}];
|
|
1046
|
+
return routerFeature(7, providers);
|
|
1047
|
+
}
|
|
1048
|
+
function withComponentInputBinding() {
|
|
1049
|
+
const providers = [RoutedComponentInputBinder, {
|
|
1050
|
+
provide: INPUT_BINDER,
|
|
1051
|
+
useExisting: RoutedComponentInputBinder
|
|
1052
|
+
}];
|
|
1053
|
+
return routerFeature(8, providers);
|
|
1054
|
+
}
|
|
1055
|
+
function withViewTransitions(options) {
|
|
1056
|
+
_performanceMarkFeature('NgRouterViewTransitions');
|
|
1057
|
+
const providers = [{
|
|
1058
|
+
provide: CREATE_VIEW_TRANSITION,
|
|
1059
|
+
useValue: createViewTransition
|
|
1060
|
+
}, {
|
|
1061
|
+
provide: VIEW_TRANSITION_OPTIONS,
|
|
1062
|
+
useValue: {
|
|
1063
|
+
skipNextTransition: !!options?.skipInitialTransition,
|
|
1064
|
+
...options
|
|
1065
|
+
}
|
|
1066
|
+
}];
|
|
1067
|
+
return routerFeature(9, providers);
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
const ROUTER_DIRECTIVES = [RouterOutlet, RouterLink, RouterLinkActive, _EmptyOutletComponent];
|
|
1071
|
+
const ROUTER_FORROOT_GUARD = new InjectionToken(typeof ngDevMode === 'undefined' || ngDevMode ? 'router duplicate forRoot guard' : '');
|
|
1072
|
+
const ROUTER_PROVIDERS = [Location, {
|
|
1073
|
+
provide: UrlSerializer,
|
|
1074
|
+
useClass: DefaultUrlSerializer
|
|
1075
|
+
}, Router, ChildrenOutletContexts, {
|
|
1076
|
+
provide: ActivatedRoute,
|
|
1077
|
+
useFactory: rootRoute
|
|
1078
|
+
}, RouterConfigLoader, typeof ngDevMode === 'undefined' || ngDevMode ? {
|
|
1079
|
+
provide: ROUTER_IS_PROVIDED,
|
|
1080
|
+
useValue: true
|
|
1081
|
+
} : []];
|
|
1082
|
+
class RouterModule {
|
|
1083
|
+
constructor() {
|
|
1084
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
1085
|
+
inject(ROUTER_FORROOT_GUARD, {
|
|
1086
|
+
optional: true
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
static forRoot(routes, config) {
|
|
1091
|
+
return {
|
|
1092
|
+
ngModule: RouterModule,
|
|
1093
|
+
providers: [ROUTER_PROVIDERS, typeof ngDevMode === 'undefined' || ngDevMode ? config?.enableTracing ? withDebugTracing().ɵproviders : [] : [], {
|
|
1094
|
+
provide: ROUTES,
|
|
1095
|
+
multi: true,
|
|
1096
|
+
useValue: routes
|
|
1097
|
+
}, typeof ngDevMode === 'undefined' || ngDevMode ? {
|
|
1098
|
+
provide: ROUTER_FORROOT_GUARD,
|
|
1099
|
+
useFactory: provideForRootGuard
|
|
1100
|
+
} : [], config?.errorHandler ? {
|
|
1101
|
+
provide: NAVIGATION_ERROR_HANDLER,
|
|
1102
|
+
useValue: config.errorHandler
|
|
1103
|
+
} : [], {
|
|
1104
|
+
provide: ROUTER_CONFIGURATION,
|
|
1105
|
+
useValue: config ? config : {}
|
|
1106
|
+
}, config?.useHash ? provideHashLocationStrategy() : providePathLocationStrategy(), provideRouterScroller(), config?.preloadingStrategy ? withPreloading(config.preloadingStrategy).ɵproviders : [], config?.initialNavigation ? provideInitialNavigation(config) : [], config?.bindToComponentInputs ? withComponentInputBinding().ɵproviders : [], config?.enableViewTransitions ? withViewTransitions().ɵproviders : [], provideRouterInitializer()]
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
static forChild(routes) {
|
|
1110
|
+
return {
|
|
1111
|
+
ngModule: RouterModule,
|
|
1112
|
+
providers: [{
|
|
1113
|
+
provide: ROUTES,
|
|
1114
|
+
multi: true,
|
|
1115
|
+
useValue: routes
|
|
1116
|
+
}]
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1120
|
+
minVersion: "12.0.0",
|
|
1121
|
+
version: "21.0.0-next.10",
|
|
1122
|
+
ngImport: i0,
|
|
1123
|
+
type: RouterModule,
|
|
1124
|
+
deps: [],
|
|
1125
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
1126
|
+
});
|
|
1127
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({
|
|
1128
|
+
minVersion: "14.0.0",
|
|
1129
|
+
version: "21.0.0-next.10",
|
|
1130
|
+
ngImport: i0,
|
|
1131
|
+
type: RouterModule,
|
|
1132
|
+
imports: [RouterOutlet, RouterLink, RouterLinkActive, _EmptyOutletComponent],
|
|
1133
|
+
exports: [RouterOutlet, RouterLink, RouterLinkActive, _EmptyOutletComponent]
|
|
1134
|
+
});
|
|
1135
|
+
static ɵinj = i0.ɵɵngDeclareInjector({
|
|
1136
|
+
minVersion: "12.0.0",
|
|
1137
|
+
version: "21.0.0-next.10",
|
|
1138
|
+
ngImport: i0,
|
|
1139
|
+
type: RouterModule
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1143
|
+
minVersion: "12.0.0",
|
|
1144
|
+
version: "21.0.0-next.10",
|
|
1145
|
+
ngImport: i0,
|
|
1146
|
+
type: RouterModule,
|
|
1147
|
+
decorators: [{
|
|
1148
|
+
type: NgModule,
|
|
1149
|
+
args: [{
|
|
1150
|
+
imports: ROUTER_DIRECTIVES,
|
|
1151
|
+
exports: ROUTER_DIRECTIVES
|
|
1152
|
+
}]
|
|
1153
|
+
}],
|
|
1154
|
+
ctorParameters: () => []
|
|
1155
|
+
});
|
|
1156
|
+
function provideRouterScroller() {
|
|
1157
|
+
return {
|
|
1158
|
+
provide: ROUTER_SCROLLER,
|
|
1159
|
+
useFactory: () => {
|
|
1160
|
+
const viewportScroller = inject(ViewportScroller);
|
|
1161
|
+
const zone = inject(NgZone);
|
|
1162
|
+
const config = inject(ROUTER_CONFIGURATION);
|
|
1163
|
+
const transitions = inject(NavigationTransitions);
|
|
1164
|
+
const urlSerializer = inject(UrlSerializer);
|
|
1165
|
+
if (config.scrollOffset) {
|
|
1166
|
+
viewportScroller.setOffset(config.scrollOffset);
|
|
1167
|
+
}
|
|
1168
|
+
return new RouterScroller(urlSerializer, transitions, viewportScroller, zone, config);
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
function provideHashLocationStrategy() {
|
|
1173
|
+
return {
|
|
1174
|
+
provide: LocationStrategy,
|
|
1175
|
+
useClass: HashLocationStrategy
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
function providePathLocationStrategy() {
|
|
1179
|
+
return {
|
|
1180
|
+
provide: LocationStrategy,
|
|
1181
|
+
useClass: PathLocationStrategy
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
function provideForRootGuard() {
|
|
1185
|
+
const router = inject(Router, {
|
|
1186
|
+
optional: true,
|
|
1187
|
+
skipSelf: true
|
|
1188
|
+
});
|
|
1189
|
+
if (router) {
|
|
1190
|
+
throw new _RuntimeError(4007, `The Router was provided more than once. This can happen if 'forRoot' is used outside of the root injector.` + ` Lazy loaded modules should use RouterModule.forChild() instead.`);
|
|
1191
|
+
}
|
|
1192
|
+
return 'guarded';
|
|
1193
|
+
}
|
|
1194
|
+
function provideInitialNavigation(config) {
|
|
1195
|
+
return [config.initialNavigation === 'disabled' ? withDisabledInitialNavigation().ɵproviders : [], config.initialNavigation === 'enabledBlocking' ? withEnabledBlockingInitialNavigation().ɵproviders : []];
|
|
1196
|
+
}
|
|
1197
|
+
const ROUTER_INITIALIZER = new InjectionToken(typeof ngDevMode === 'undefined' || ngDevMode ? 'Router Initializer' : '');
|
|
1198
|
+
function provideRouterInitializer() {
|
|
1199
|
+
return [{
|
|
1200
|
+
provide: ROUTER_INITIALIZER,
|
|
1201
|
+
useFactory: getBootstrapListener
|
|
1202
|
+
}, {
|
|
1203
|
+
provide: APP_BOOTSTRAP_LISTENER,
|
|
1204
|
+
multi: true,
|
|
1205
|
+
useExisting: ROUTER_INITIALIZER
|
|
1206
|
+
}];
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
export { NoPreloading, PreloadAllModules, PreloadingStrategy, ROUTER_INITIALIZER, ROUTER_PROVIDERS, RouterLink, RouterLinkActive, RouterModule, RouterPreloader, provideRouter, provideRoutes, withComponentInputBinding, withDebugTracing, withDisabledInitialNavigation, withEnabledBlockingInitialNavigation, withHashLocation, withInMemoryScrolling, withNavigationErrorHandler, withPlatformNavigation, withPreloading, withRouterConfig, withViewTransitions };
|
|
1210
|
+
//# sourceMappingURL=_router_module-chunk.mjs.map
|