@angular/router 20.3.11 → 20.3.12
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.mjs +2 -2
- package/fesm2022/router.mjs.map +1 -1
- package/fesm2022/router2.mjs +53 -49
- package/fesm2022/router2.mjs.map +1 -1
- package/fesm2022/router_module.mjs +31 -23
- package/fesm2022/router_module.mjs.map +1 -1
- package/fesm2022/testing.mjs +11 -11
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/upgrade.mjs +1 -1
- package/fesm2022/upgrade.mjs.map +1 -1
- package/index.d.ts +7 -1
- package/package.json +4 -4
- package/router_module.d.d.ts +48 -3
- package/testing/index.d.ts +1 -1
- package/upgrade/index.d.ts +1 -1
package/fesm2022/testing.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.mjs","sources":["../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/packages/router/testing/src/router_testing_module.ts","../../../../../k8-fastbuild-ST-199a4f3c4e20/bin/packages/router/testing/src/router_testing_harness.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {provideLocationMocks} from '@angular/common/testing';\nimport {ModuleWithProviders, NgModule} from '@angular/core';\nimport {\n ExtraOptions,\n NoPreloading,\n ROUTER_CONFIGURATION,\n RouterModule,\n ROUTES,\n Routes,\n withPreloading,\n ɵROUTER_PROVIDERS as ROUTER_PROVIDERS,\n} from '../../index';\n\n/**\n * @description\n *\n * Sets up the router to be used for testing.\n *\n * The modules sets up the router to be used for testing.\n * It provides spy implementations of `Location` and `LocationStrategy`.\n *\n * @usageNotes\n * ### Example\n *\n * ```ts\n * beforeEach(() => {\n * TestBed.configureTestingModule({\n * imports: [\n * RouterModule.forRoot(\n * [{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}]\n * )\n * ]\n * });\n * });\n * ```\n *\n * @publicApi\n * @deprecated Use `provideRouter` or `RouterModule`/`RouterModule.forRoot` instead.\n * This module was previously used to provide a helpful collection of test fakes,\n * most notably those for `Location` and `LocationStrategy`. These are generally not\n * required anymore, as `MockPlatformLocation` is provided in `TestBed` by default.\n * However, you can use them directly with `provideLocationMocks`.\n */\n@NgModule({\n exports: [RouterModule],\n providers: [\n ROUTER_PROVIDERS,\n provideLocationMocks(),\n withPreloading(NoPreloading).ɵproviders,\n {provide: ROUTES, multi: true, useValue: []},\n ],\n})\nexport class RouterTestingModule {\n static withRoutes(\n routes: Routes,\n config?: ExtraOptions,\n ): ModuleWithProviders<RouterTestingModule> {\n return {\n ngModule: RouterTestingModule,\n providers: [\n {provide: ROUTES, multi: true, useValue: routes},\n {provide: ROUTER_CONFIGURATION, useValue: config ? config : {}},\n ],\n };\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n Component,\n DebugElement,\n Injectable,\n Type,\n ViewChild,\n WritableSignal,\n signal,\n} from '@angular/core';\nimport {ComponentFixture, TestBed} from '@angular/core/testing';\nimport {Router, RouterOutlet, ɵafterNextNavigation as afterNextNavigation} from '../../index';\n\n@Injectable({providedIn: 'root'})\nexport class RootFixtureService {\n private fixture?: ComponentFixture<RootCmp>;\n private harness?: RouterTestingHarness;\n\n createHarness(): RouterTestingHarness {\n if (this.harness) {\n throw new Error('Only one harness should be created per test.');\n }\n this.harness = new RouterTestingHarness(this.getRootFixture());\n return this.harness;\n }\n\n private getRootFixture(): ComponentFixture<RootCmp> {\n if (this.fixture !== undefined) {\n return this.fixture;\n }\n this.fixture = TestBed.createComponent(RootCmp);\n this.fixture.detectChanges();\n return this.fixture;\n }\n}\n\n@Component({\n template: '<router-outlet [routerOutletData]=\"routerOutletData()\"></router-outlet>',\n imports: [RouterOutlet],\n})\nexport class RootCmp {\n @ViewChild(RouterOutlet) outlet?: RouterOutlet;\n readonly routerOutletData = signal<unknown>(undefined);\n}\n\n/**\n * A testing harness for the `Router` to reduce the boilerplate needed to test routes and routed\n * components.\n *\n * @publicApi\n */\nexport class RouterTestingHarness {\n /**\n * Creates a `RouterTestingHarness` instance.\n *\n * The `RouterTestingHarness` also creates its own root component with a `RouterOutlet` for the\n * purposes of rendering route components.\n *\n * Throws an error if an instance has already been created.\n * Use of this harness also requires `destroyAfterEach: true` in the `ModuleTeardownOptions`\n *\n * @param initialUrl The target of navigation to trigger before returning the harness.\n */\n static async create(initialUrl?: string): Promise<RouterTestingHarness> {\n const harness = TestBed.inject(RootFixtureService).createHarness();\n if (initialUrl !== undefined) {\n await harness.navigateByUrl(initialUrl);\n }\n return harness;\n }\n\n /**\n * Fixture of the root component of the RouterTestingHarness\n */\n public readonly fixture: ComponentFixture<{routerOutletData: WritableSignal<unknown>}>;\n\n /** @internal */\n constructor(fixture: ComponentFixture<{routerOutletData: WritableSignal<unknown>}>) {\n this.fixture = fixture;\n }\n\n /** Instructs the root fixture to run change detection. */\n detectChanges(): void {\n this.fixture.detectChanges();\n }\n /** The `DebugElement` of the `RouterOutlet` component. `null` if the outlet is not activated. */\n get routeDebugElement(): DebugElement | null {\n const outlet = (this.fixture.componentInstance as RootCmp).outlet;\n if (!outlet || !outlet.isActivated) {\n return null;\n }\n return this.fixture.debugElement.query((v) => v.componentInstance === outlet.component);\n }\n /** The native element of the `RouterOutlet` component. `null` if the outlet is not activated. */\n get routeNativeElement(): HTMLElement | null {\n return this.routeDebugElement?.nativeElement ?? null;\n }\n\n /**\n * Triggers a `Router` navigation and waits for it to complete.\n *\n * The root component with a `RouterOutlet` created for the harness is used to render `Route`\n * components. The root component is reused within the same test in subsequent calls to\n * `navigateForTest`.\n *\n * When testing `Routes` with a guards that reject the navigation, the `RouterOutlet` might not be\n * activated and the `activatedComponent` may be `null`.\n *\n * {@example router/testing/test/router_testing_harness_examples.spec.ts region='Guard'}\n *\n * @param url The target of the navigation. Passed to `Router.navigateByUrl`.\n * @returns The activated component instance of the `RouterOutlet` after navigation completes\n * (`null` if the outlet does not get activated).\n */\n async navigateByUrl(url: string): Promise<null | {}>;\n /**\n * Triggers a router navigation and waits for it to complete.\n *\n * The root component with a `RouterOutlet` created for the harness is used to render `Route`\n * components.\n *\n * {@example router/testing/test/router_testing_harness_examples.spec.ts region='RoutedComponent'}\n *\n * The root component is reused within the same test in subsequent calls to `navigateByUrl`.\n *\n * This function also makes it easier to test components that depend on `ActivatedRoute` data.\n *\n * {@example router/testing/test/router_testing_harness_examples.spec.ts region='ActivatedRoute'}\n *\n * @param url The target of the navigation. Passed to `Router.navigateByUrl`.\n * @param requiredRoutedComponentType After navigation completes, the required type for the\n * activated component of the `RouterOutlet`. If the outlet is not activated or a different\n * component is activated, this function will throw an error.\n * @returns The activated component instance of the `RouterOutlet` after navigation completes.\n */\n async navigateByUrl<T>(url: string, requiredRoutedComponentType: Type<T>): Promise<T>;\n async navigateByUrl<T>(url: string, requiredRoutedComponentType?: Type<T>): Promise<T | null> {\n const router = TestBed.inject(Router);\n let resolveFn!: () => void;\n const redirectTrackingPromise = new Promise<void>((resolve) => {\n resolveFn = resolve;\n });\n afterNextNavigation(TestBed.inject(Router), resolveFn);\n await router.navigateByUrl(url);\n await redirectTrackingPromise;\n this.fixture.detectChanges();\n const outlet = (this.fixture.componentInstance as RootCmp).outlet;\n // The outlet might not be activated if the user is testing a navigation for a guard that\n // rejects\n if (outlet && outlet.isActivated && outlet.activatedRoute.component) {\n const activatedComponent = outlet.component;\n if (\n requiredRoutedComponentType !== undefined &&\n !(activatedComponent instanceof requiredRoutedComponentType)\n ) {\n throw new Error(\n `Unexpected routed component type. Expected ${requiredRoutedComponentType.name} but got ${activatedComponent.constructor.name}`,\n );\n }\n return activatedComponent as T;\n } else {\n if (requiredRoutedComponentType !== undefined) {\n throw new Error(\n `Unexpected routed component type. Expected ${requiredRoutedComponentType.name} but the navigation did not activate any component.`,\n );\n }\n return null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M,CAAC,SAAS;YAC3C,IACE,2BAA2B,KAAK,SAAS;AACzC,gBAAA,EAAE,kBAAkB,YAAY,2BAA2B,CAAC,EAC5D;AACA,gBAAA,MAAM,IAAI,KAAK,CACb,CAAA,2CAAA,EAA8C,2BAA2B,CAAC,IAAI,CAAY,SAAA,EAAA,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAA,CAAE,CAChI;;AAEH,YAAA,OAAO,kBAAuB;;aACzB;AACL,YAAA,IAAI,2BAA2B,KAAK,SAAS,EAAE;gBAC7C,MAAM,IAAI,KAAK,CACb,CAAA,2CAAA,EAA8C,2BAA2B,CAAC,IAAI,CAAqD,mDAAA,CAAA,CACpI;;AAEH,YAAA,OAAO,IAAI;;;AAGhB;;;;"}
|
|
1
|
+
{"version":3,"file":"testing.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/packages/router/testing/src/router_testing_module.ts","../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/packages/router/testing/src/router_testing_harness.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {provideLocationMocks} from '@angular/common/testing';\nimport {ModuleWithProviders, NgModule} from '@angular/core';\nimport {\n ExtraOptions,\n NoPreloading,\n ROUTER_CONFIGURATION,\n RouterModule,\n ROUTES,\n Routes,\n withPreloading,\n ɵROUTER_PROVIDERS as ROUTER_PROVIDERS,\n} from '../../index';\n\n/**\n * @description\n *\n * Sets up the router to be used for testing.\n *\n * The modules sets up the router to be used for testing.\n * It provides spy implementations of `Location` and `LocationStrategy`.\n *\n * @usageNotes\n * ### Example\n *\n * ```ts\n * beforeEach(() => {\n * TestBed.configureTestingModule({\n * imports: [\n * RouterModule.forRoot(\n * [{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}]\n * )\n * ]\n * });\n * });\n * ```\n *\n * @publicApi\n * @deprecated Use `provideRouter` or `RouterModule`/`RouterModule.forRoot` instead.\n * This module was previously used to provide a helpful collection of test fakes,\n * most notably those for `Location` and `LocationStrategy`. These are generally not\n * required anymore, as `MockPlatformLocation` is provided in `TestBed` by default.\n * However, you can use them directly with `provideLocationMocks`.\n */\n@NgModule({\n exports: [RouterModule],\n providers: [\n ROUTER_PROVIDERS,\n provideLocationMocks(),\n withPreloading(NoPreloading).ɵproviders,\n {provide: ROUTES, multi: true, useValue: []},\n ],\n})\nexport class RouterTestingModule {\n static withRoutes(\n routes: Routes,\n config?: ExtraOptions,\n ): ModuleWithProviders<RouterTestingModule> {\n return {\n ngModule: RouterTestingModule,\n providers: [\n {provide: ROUTES, multi: true, useValue: routes},\n {provide: ROUTER_CONFIGURATION, useValue: config ? config : {}},\n ],\n };\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n Component,\n DebugElement,\n Injectable,\n Type,\n ViewChild,\n WritableSignal,\n signal,\n} from '@angular/core';\nimport {ComponentFixture, TestBed} from '@angular/core/testing';\nimport {Router, RouterOutlet, ɵafterNextNavigation as afterNextNavigation} from '../../index';\n\n@Injectable({providedIn: 'root'})\nexport class RootFixtureService {\n private fixture?: ComponentFixture<RootCmp>;\n private harness?: RouterTestingHarness;\n\n createHarness(): RouterTestingHarness {\n if (this.harness) {\n throw new Error('Only one harness should be created per test.');\n }\n this.harness = new RouterTestingHarness(this.getRootFixture());\n return this.harness;\n }\n\n private getRootFixture(): ComponentFixture<RootCmp> {\n if (this.fixture !== undefined) {\n return this.fixture;\n }\n this.fixture = TestBed.createComponent(RootCmp);\n this.fixture.detectChanges();\n return this.fixture;\n }\n}\n\n@Component({\n template: '<router-outlet [routerOutletData]=\"routerOutletData()\"></router-outlet>',\n imports: [RouterOutlet],\n})\nexport class RootCmp {\n @ViewChild(RouterOutlet) outlet?: RouterOutlet;\n readonly routerOutletData = signal<unknown>(undefined);\n}\n\n/**\n * A testing harness for the `Router` to reduce the boilerplate needed to test routes and routed\n * components.\n *\n * @publicApi\n */\nexport class RouterTestingHarness {\n /**\n * Creates a `RouterTestingHarness` instance.\n *\n * The `RouterTestingHarness` also creates its own root component with a `RouterOutlet` for the\n * purposes of rendering route components.\n *\n * Throws an error if an instance has already been created.\n * Use of this harness also requires `destroyAfterEach: true` in the `ModuleTeardownOptions`\n *\n * @param initialUrl The target of navigation to trigger before returning the harness.\n */\n static async create(initialUrl?: string): Promise<RouterTestingHarness> {\n const harness = TestBed.inject(RootFixtureService).createHarness();\n if (initialUrl !== undefined) {\n await harness.navigateByUrl(initialUrl);\n }\n return harness;\n }\n\n /**\n * Fixture of the root component of the RouterTestingHarness\n */\n public readonly fixture: ComponentFixture<{routerOutletData: WritableSignal<unknown>}>;\n\n /** @internal */\n constructor(fixture: ComponentFixture<{routerOutletData: WritableSignal<unknown>}>) {\n this.fixture = fixture;\n }\n\n /** Instructs the root fixture to run change detection. */\n detectChanges(): void {\n this.fixture.detectChanges();\n }\n /** The `DebugElement` of the `RouterOutlet` component. `null` if the outlet is not activated. */\n get routeDebugElement(): DebugElement | null {\n const outlet = (this.fixture.componentInstance as RootCmp).outlet;\n if (!outlet || !outlet.isActivated) {\n return null;\n }\n return this.fixture.debugElement.query((v) => v.componentInstance === outlet.component);\n }\n /** The native element of the `RouterOutlet` component. `null` if the outlet is not activated. */\n get routeNativeElement(): HTMLElement | null {\n return this.routeDebugElement?.nativeElement ?? null;\n }\n\n /**\n * Triggers a `Router` navigation and waits for it to complete.\n *\n * The root component with a `RouterOutlet` created for the harness is used to render `Route`\n * components. The root component is reused within the same test in subsequent calls to\n * `navigateForTest`.\n *\n * When testing `Routes` with a guards that reject the navigation, the `RouterOutlet` might not be\n * activated and the `activatedComponent` may be `null`.\n *\n * {@example router/testing/test/router_testing_harness_examples.spec.ts region='Guard'}\n *\n * @param url The target of the navigation. Passed to `Router.navigateByUrl`.\n * @returns The activated component instance of the `RouterOutlet` after navigation completes\n * (`null` if the outlet does not get activated).\n */\n async navigateByUrl(url: string): Promise<null | {}>;\n /**\n * Triggers a router navigation and waits for it to complete.\n *\n * The root component with a `RouterOutlet` created for the harness is used to render `Route`\n * components.\n *\n * {@example router/testing/test/router_testing_harness_examples.spec.ts region='RoutedComponent'}\n *\n * The root component is reused within the same test in subsequent calls to `navigateByUrl`.\n *\n * This function also makes it easier to test components that depend on `ActivatedRoute` data.\n *\n * {@example router/testing/test/router_testing_harness_examples.spec.ts region='ActivatedRoute'}\n *\n * @param url The target of the navigation. Passed to `Router.navigateByUrl`.\n * @param requiredRoutedComponentType After navigation completes, the required type for the\n * activated component of the `RouterOutlet`. If the outlet is not activated or a different\n * component is activated, this function will throw an error.\n * @returns The activated component instance of the `RouterOutlet` after navigation completes.\n */\n async navigateByUrl<T>(url: string, requiredRoutedComponentType: Type<T>): Promise<T>;\n async navigateByUrl<T>(url: string, requiredRoutedComponentType?: Type<T>): Promise<T | null> {\n const router = TestBed.inject(Router);\n let resolveFn!: () => void;\n const redirectTrackingPromise = new Promise<void>((resolve) => {\n resolveFn = resolve;\n });\n afterNextNavigation(TestBed.inject(Router), resolveFn);\n await router.navigateByUrl(url);\n await redirectTrackingPromise;\n this.fixture.detectChanges();\n const outlet = (this.fixture.componentInstance as RootCmp).outlet;\n // The outlet might not be activated if the user is testing a navigation for a guard that\n // rejects\n if (outlet && outlet.isActivated && outlet.activatedRoute.component) {\n const activatedComponent = outlet.component;\n if (\n requiredRoutedComponentType !== undefined &&\n !(activatedComponent instanceof requiredRoutedComponentType)\n ) {\n throw new Error(\n `Unexpected routed component type. Expected ${requiredRoutedComponentType.name} but got ${activatedComponent.constructor.name}`,\n );\n }\n return activatedComponent as T;\n } else {\n if (requiredRoutedComponentType !== undefined) {\n throw new Error(\n `Unexpected routed component type. Expected ${requiredRoutedComponentType.name} but the navigation did not activate any component.`,\n );\n }\n return null;\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;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AACzC,gBAAA,EAAE,kBAAkB,YAAY,2BAA2B,CAAC,EAC5D;AACA,gBAAA,MAAM,IAAI,KAAK,CACb,CAAA,2CAAA,EAA8C,2BAA2B,CAAC,IAAI,CAAY,SAAA,EAAA,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAA,CAAE,CAChI;;AAEH,YAAA,OAAO,kBAAuB;;aACzB;AACL,YAAA,IAAI,2BAA2B,KAAK,SAAS,EAAE;gBAC7C,MAAM,IAAI,KAAK,CACb,CAAA,2CAAA,EAA8C,2BAA2B,CAAC,IAAI,CAAqD,mDAAA,CAAA,CACpI;;AAEH,YAAA,OAAO,IAAI;;;AAGhB;;;;"}
|
package/fesm2022/upgrade.mjs
CHANGED
package/fesm2022/upgrade.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.mjs","sources":["../../../../../
|
|
1
|
+
{"version":3,"file":"upgrade.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/packages/router/upgrade/src/upgrade.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Location} from '@angular/common';\nimport {APP_BOOTSTRAP_LISTENER, ComponentRef, InjectionToken} from '@angular/core';\nimport {Router, ɵRestoredState as RestoredState} from '../../index';\nimport {UpgradeModule} from '@angular/upgrade/static';\n\n/**\n * Creates an initializer that sets up `ngRoute` integration\n * along with setting up the Angular router.\n *\n * @usageNotes\n *\n * For standalone applications:\n * ```ts\n * export const appConfig: ApplicationConfig = {\n * providers: [RouterUpgradeInitializer],\n * };\n * ```\n *\n * For NgModule based applications:\n * ```ts\n * @NgModule({\n * imports: [\n * RouterModule.forRoot(SOME_ROUTES),\n * UpgradeModule\n * ],\n * providers: [\n * RouterUpgradeInitializer\n * ]\n * })\n * export class AppModule {\n * ngDoBootstrap() {}\n * }\n * ```\n *\n * @publicApi\n */\nexport const RouterUpgradeInitializer = {\n provide: APP_BOOTSTRAP_LISTENER,\n multi: true,\n useFactory: locationSyncBootstrapListener as (ngUpgrade: UpgradeModule) => () => void,\n deps: [UpgradeModule],\n};\n\n/**\n * @internal\n */\nexport function locationSyncBootstrapListener(ngUpgrade: UpgradeModule) {\n return () => {\n setUpLocationSync(ngUpgrade);\n };\n}\n\n/**\n * Sets up a location change listener to trigger `history.pushState`.\n * Works around the problem that `onPopState` does not trigger `history.pushState`.\n * Must be called *after* calling `UpgradeModule.bootstrap`.\n *\n * @param ngUpgrade The upgrade NgModule.\n * @param urlType The location strategy.\n * @see {@link /api/common/HashLocationStrategy HashLocationStrategy}\n * @see {@link /api/common/PathLocationStrategy PathLocationStrategy}\n *\n * @publicApi\n */\nexport function setUpLocationSync(\n ngUpgrade: UpgradeModule,\n urlType: 'path' | 'hash' = 'path',\n): void {\n if (!ngUpgrade.$injector) {\n throw new Error(`\n RouterUpgradeInitializer can be used only after UpgradeModule.bootstrap has been called.\n Remove RouterUpgradeInitializer and call setUpLocationSync after UpgradeModule.bootstrap.\n `);\n }\n\n const router: Router = ngUpgrade.injector.get(Router);\n const location: Location = ngUpgrade.injector.get(Location);\n\n ngUpgrade.$injector\n .get('$rootScope')\n .$on(\n '$locationChangeStart',\n (\n event: any,\n newUrl: string,\n oldUrl: string,\n newState?: {[k: string]: unknown} | RestoredState,\n oldState?: {[k: string]: unknown} | RestoredState,\n ) => {\n // Navigations coming from Angular router have a navigationId state\n // property. Don't trigger Angular router navigation again if it is\n // caused by a URL change from the current Angular router\n // navigation.\n const currentNavigationId = router.getCurrentNavigation()?.id;\n const newStateNavigationId = newState?.navigationId;\n if (newStateNavigationId !== undefined && newStateNavigationId === currentNavigationId) {\n return;\n }\n\n let url;\n if (urlType === 'path') {\n url = resolveUrl(newUrl);\n } else if (urlType === 'hash') {\n // Remove the first hash from the URL\n const hashIdx = newUrl.indexOf('#');\n url = resolveUrl(newUrl.substring(0, hashIdx) + newUrl.substring(hashIdx + 1));\n } else {\n throw 'Invalid URLType passed to setUpLocationSync: ' + urlType;\n }\n const path = location.normalize(url.pathname);\n router.navigateByUrl(path + url.search + url.hash);\n },\n );\n}\n\n/**\n * Normalizes and parses a URL.\n *\n * - Normalizing means that a relative URL will be resolved into an absolute URL in the context of\n * the application document.\n * - Parsing means that the anchor's `protocol`, `hostname`, `port`, `pathname` and related\n * properties are all populated to reflect the normalized URL.\n *\n * While this approach has wide compatibility, it doesn't work as expected on IE. On IE, normalizing\n * happens similar to other browsers, but the parsed components will not be set. (E.g. if you assign\n * `a.href = 'foo'`, then `a.protocol`, `a.host`, etc. will not be correctly updated.)\n * We work around that by performing the parsing in a 2nd step by taking a previously normalized URL\n * and assigning it again. This correctly populates all properties.\n *\n * See\n * https://github.com/angular/angular.js/blob/2c7400e7d07b0f6cec1817dab40b9250ce8ebce6/src/ng/urlUtils.js#L26-L33\n * for more info.\n */\nlet anchor: HTMLAnchorElement | undefined;\nfunction resolveUrl(url: string): {pathname: string; search: string; hash: string} {\n anchor ??= document.createElement('a');\n\n anchor.setAttribute('href', url);\n anchor.setAttribute('href', anchor.href);\n\n return {\n // IE does not start `pathname` with `/` like other browsers.\n pathname: `/${anchor.pathname.replace(/^\\//, '')}`,\n search: anchor.search,\n hash: anchor.hash,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;AACU,MAAA,wBAAwB,GAAG;AACtC,IAAA,OAAO,EAAE,sBAAsB;AAC/B,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,UAAU,EAAE,6BAAyE;IACrF,IAAI,EAAE,CAAC,aAAa,CAAC;;AAGvB;;AAEG;AACG,SAAU,6BAA6B,CAAC,SAAwB,EAAA;AACpE,IAAA,OAAO,MAAK;QACV,iBAAiB,CAAC,SAAS,CAAC;AAC9B,KAAC;AACH;AAEA;;;;;;;;;;;AAWG;SACa,iBAAiB,CAC/B,SAAwB,EACxB,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;;;;;;;AAiBG;AACH,IAAI,MAAqC;AACzC,SAAS,UAAU,CAAC,GAAW,EAAA;AAC7B,IAAA,MAAM,KAAK,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC;AAEtC,IAAA,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC;IAChC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC;IAExC,OAAO;;AAEL,QAAA,QAAQ,EAAE,CAAA,CAAA,EAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAE,CAAA;QAClD,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,IAAI,EAAE,MAAM,CAAC,IAAI;KAClB;AACH;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v20.3.
|
|
2
|
+
* @license Angular v20.3.12
|
|
3
3
|
* (c) 2010-2025 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -558,6 +558,8 @@ type PreloadingFeature = RouterFeature<RouterFeatureKind.PreloadingFeature>;
|
|
|
558
558
|
* should be used.
|
|
559
559
|
* @returns A set of providers for use with `provideRouter`.
|
|
560
560
|
*
|
|
561
|
+
* @see [Preloading strategy](guide/routing/customizing-route-behavior#preloading-strategy)
|
|
562
|
+
*
|
|
561
563
|
* @publicApi
|
|
562
564
|
*/
|
|
563
565
|
declare function withPreloading(preloadingStrategy: Type<PreloadingStrategy>): PreloadingFeature;
|
|
@@ -595,6 +597,8 @@ type RouterConfigurationFeature = RouterFeature<RouterFeatureKind.RouterConfigur
|
|
|
595
597
|
* additional information.
|
|
596
598
|
* @returns A set of providers for use with `provideRouter`.
|
|
597
599
|
*
|
|
600
|
+
* @see [Router configuration options](guide/routing/customizing-route-behavior#router-configuration-options)
|
|
601
|
+
*
|
|
598
602
|
* @publicApi
|
|
599
603
|
*/
|
|
600
604
|
declare function withRouterConfig(options: RouterConfigOptions): RouterConfigurationFeature;
|
|
@@ -671,6 +675,7 @@ type NavigationErrorHandlerFeature = RouterFeature<RouterFeatureKind.NavigationE
|
|
|
671
675
|
* @see {@link NavigationError}
|
|
672
676
|
* @see {@link /api/core/inject inject}
|
|
673
677
|
* @see {@link runInInjectionContext}
|
|
678
|
+
* @see [Centralize error handling in withNavigationErrorHandler](guide/routing/data-resolvers#centralize-error-handling-in-withnavigationerrorhandler)
|
|
674
679
|
*
|
|
675
680
|
* @returns A set of providers for use with `provideRouter`.
|
|
676
681
|
*
|
|
@@ -759,6 +764,7 @@ declare function withComponentInputBinding(): ComponentInputBindingFeature;
|
|
|
759
764
|
* @returns A set of providers for use with `provideRouter`.
|
|
760
765
|
* @see https://developer.chrome.com/docs/web-platform/view-transitions/
|
|
761
766
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API
|
|
767
|
+
* @see [Route transition animations](guide/routing/route-transition-animations)
|
|
762
768
|
* @developerPreview 19.0
|
|
763
769
|
*/
|
|
764
770
|
declare function withViewTransitions(options?: ViewTransitionsFeatureOptions): ViewTransitionsFeature;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/router",
|
|
3
|
-
"version": "20.3.
|
|
3
|
+
"version": "20.3.12",
|
|
4
4
|
"description": "Angular - the routing library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"tslib": "^2.3.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@angular/core": "20.3.
|
|
28
|
-
"@angular/common": "20.3.
|
|
29
|
-
"@angular/platform-browser": "20.3.
|
|
27
|
+
"@angular/core": "20.3.12",
|
|
28
|
+
"@angular/common": "20.3.12",
|
|
29
|
+
"@angular/platform-browser": "20.3.12",
|
|
30
30
|
"rxjs": "^6.5.3 || ^7.4.0"
|
|
31
31
|
},
|
|
32
32
|
"ng-update": {
|
package/router_module.d.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v20.3.
|
|
2
|
+
* @license Angular v20.3.12
|
|
3
3
|
* (c) 2010-2025 Google LLC. https://angular.dev/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -451,6 +451,7 @@ type UrlMatchResult = {
|
|
|
451
451
|
* export const routes = [{ matcher: htmlFiles, component: AnyComponent }];
|
|
452
452
|
* ```
|
|
453
453
|
*
|
|
454
|
+
* @see [Creating custom route matches](guide/routing/routing-with-urlmatcher)
|
|
454
455
|
* @publicApi
|
|
455
456
|
*/
|
|
456
457
|
type UrlMatcher = (segments: UrlSegment[], group: UrlSegmentGroup, route: Route) => UrlMatchResult | null;
|
|
@@ -586,6 +587,7 @@ type RedirectFunction = (redirectData: Pick<ActivatedRouteSnapshot, 'routeConfig
|
|
|
586
587
|
* change or query params have changed. This does not include matrix parameters.
|
|
587
588
|
*
|
|
588
589
|
* @see {@link Route#runGuardsAndResolvers}
|
|
590
|
+
* @see [Control when guards and resolvers execute](guide/routing/customizing-route-behavior#control-when-guards-and-resolvers-execute)
|
|
589
591
|
* @publicApi
|
|
590
592
|
*/
|
|
591
593
|
type RunGuardsAndResolvers = 'pathParamsChange' | 'pathParamsOrQueryParamsChange' | 'paramsChange' | 'paramsOrQueryParamsChange' | 'always' | ((from: ActivatedRouteSnapshot, to: ActivatedRouteSnapshot) => boolean);
|
|
@@ -820,6 +822,7 @@ interface Route {
|
|
|
820
822
|
* implements `Resolve`.
|
|
821
823
|
*
|
|
822
824
|
* @see {@link TitleStrategy}
|
|
825
|
+
* @see [Page titles](guide/routing/define-routes#page-titles)
|
|
823
826
|
*/
|
|
824
827
|
title?: string | Type<Resolve<string>> | ResolveFn<string>;
|
|
825
828
|
/**
|
|
@@ -848,10 +851,15 @@ interface Route {
|
|
|
848
851
|
* the router would apply the redirect even when navigating
|
|
849
852
|
* to the redirect destination, creating an endless loop.
|
|
850
853
|
*
|
|
854
|
+
* @see [Redirecting Routes](guide/routing/redirecting-routes)
|
|
855
|
+
*
|
|
851
856
|
*/
|
|
852
857
|
pathMatch?: 'prefix' | 'full';
|
|
853
858
|
/**
|
|
854
859
|
* A custom URL-matching function. Cannot be used together with `path`.
|
|
860
|
+
*
|
|
861
|
+
* @see [Creating custom route matches](guide/routing/routing-with-urlmatcher)
|
|
862
|
+
*
|
|
855
863
|
*/
|
|
856
864
|
matcher?: UrlMatcher;
|
|
857
865
|
/**
|
|
@@ -876,11 +884,16 @@ interface Route {
|
|
|
876
884
|
* required dependencies.
|
|
877
885
|
*
|
|
878
886
|
* When not present, router does not redirect.
|
|
887
|
+
*
|
|
888
|
+
* @see [Conditional redirects](guide/routing/redirecting-routes#conditional-redirects)
|
|
879
889
|
*/
|
|
880
890
|
redirectTo?: string | RedirectFunction;
|
|
881
891
|
/**
|
|
882
892
|
* Name of a `RouterOutlet` object where the component can be placed
|
|
883
893
|
* when the path matches.
|
|
894
|
+
*
|
|
895
|
+
* @see [Show routes with outlets](guide/routing/show-routes-with-outlets)
|
|
896
|
+
*
|
|
884
897
|
*/
|
|
885
898
|
outlet?: string;
|
|
886
899
|
/**
|
|
@@ -890,6 +903,9 @@ interface Route {
|
|
|
890
903
|
*
|
|
891
904
|
* When using a function rather than DI tokens, the function can call `inject` to get any required
|
|
892
905
|
* dependencies. This `inject` call must be done in a synchronous context.
|
|
906
|
+
*
|
|
907
|
+
* @see [CanActivate](guide/routing/route-guards#canactivate)
|
|
908
|
+
*
|
|
893
909
|
*/
|
|
894
910
|
canActivate?: Array<CanActivateFn | DeprecatedGuard>;
|
|
895
911
|
/**
|
|
@@ -899,6 +915,9 @@ interface Route {
|
|
|
899
915
|
*
|
|
900
916
|
* When using a function rather than DI tokens, the function can call `inject` to get any required
|
|
901
917
|
* dependencies. This `inject` call must be done in a synchronous context.
|
|
918
|
+
*
|
|
919
|
+
* @see [CanMatch](guide/routing/route-guards#canmatch)
|
|
920
|
+
*
|
|
902
921
|
*/
|
|
903
922
|
canMatch?: Array<CanMatchFn | DeprecatedGuard>;
|
|
904
923
|
/**
|
|
@@ -908,6 +927,9 @@ interface Route {
|
|
|
908
927
|
*
|
|
909
928
|
* When using a function rather than DI tokens, the function can call `inject` to get any required
|
|
910
929
|
* dependencies. This `inject` call must be done in a synchronous context.
|
|
930
|
+
*
|
|
931
|
+
* @see [CanActivateChild](guide/routing/route-guards#canactivatechild)
|
|
932
|
+
*
|
|
911
933
|
*/
|
|
912
934
|
canActivateChild?: Array<CanActivateChildFn | DeprecatedGuard>;
|
|
913
935
|
/**
|
|
@@ -917,6 +939,9 @@ interface Route {
|
|
|
917
939
|
*
|
|
918
940
|
* When using a function rather than DI tokens, the function can call `inject` to get any required
|
|
919
941
|
* dependencies. This `inject` call must be done in a synchronous context.
|
|
942
|
+
*
|
|
943
|
+
* @see [CanDeactivate](guide/routing/route-guards#candeactivate)
|
|
944
|
+
*
|
|
920
945
|
*/
|
|
921
946
|
canDeactivate?: Array<CanDeactivateFn<any> | DeprecatedGuard>;
|
|
922
947
|
/**
|
|
@@ -936,6 +961,8 @@ interface Route {
|
|
|
936
961
|
data?: Data;
|
|
937
962
|
/**
|
|
938
963
|
* A map of DI tokens used to look up data resolvers. See `Resolve`.
|
|
964
|
+
*
|
|
965
|
+
* @see [Resolve](guide/routing/data-resolvers#what-are-data-resolvers)
|
|
939
966
|
*/
|
|
940
967
|
resolve?: ResolveData;
|
|
941
968
|
/**
|
|
@@ -966,6 +993,7 @@ interface Route {
|
|
|
966
993
|
* change or query params have changed. This does not include matrix parameters.
|
|
967
994
|
*
|
|
968
995
|
* @see {@link RunGuardsAndResolvers}
|
|
996
|
+
* @see [Control when guards and resolvers execute](guide/routing/customizing-route-behavior#control-when-guards-and-resolvers-execute)
|
|
969
997
|
*/
|
|
970
998
|
runGuardsAndResolvers?: RunGuardsAndResolvers;
|
|
971
999
|
/**
|
|
@@ -975,6 +1003,7 @@ interface Route {
|
|
|
975
1003
|
* `Route` and use it for this `Route` and its `children`. If this
|
|
976
1004
|
* route also has a `loadChildren` function which returns an `NgModuleRef`, this injector will be
|
|
977
1005
|
* used as the parent of the lazy loaded module.
|
|
1006
|
+
* @see [Route providers](guide/di/defining-dependency-providers#route-providers)
|
|
978
1007
|
*/
|
|
979
1008
|
providers?: Array<Provider | EnvironmentProviders>;
|
|
980
1009
|
}
|
|
@@ -1033,6 +1062,9 @@ interface LoadedRouterConfig {
|
|
|
1033
1062
|
* class AppModule {}
|
|
1034
1063
|
* ```
|
|
1035
1064
|
*
|
|
1065
|
+
* @see [CanActivate](guide/routing/route-guards#canactivate)
|
|
1066
|
+
*
|
|
1067
|
+
*
|
|
1036
1068
|
* @publicApi
|
|
1037
1069
|
*/
|
|
1038
1070
|
interface CanActivate {
|
|
@@ -1089,6 +1121,7 @@ interface CanActivate {
|
|
|
1089
1121
|
*
|
|
1090
1122
|
* @publicApi
|
|
1091
1123
|
* @see {@link Route}
|
|
1124
|
+
* @see [CanActivate](guide/routing/route-guards#canactivate)
|
|
1092
1125
|
*/
|
|
1093
1126
|
type CanActivateFn = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => MaybeAsync<GuardResult>;
|
|
1094
1127
|
/**
|
|
@@ -1146,7 +1179,7 @@ type CanActivateFn = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot)
|
|
|
1146
1179
|
* })
|
|
1147
1180
|
* class AppModule {}
|
|
1148
1181
|
* ```
|
|
1149
|
-
*
|
|
1182
|
+
* @see [CanActivateChild](guide/routing/route-guards#canactivatechild)
|
|
1150
1183
|
* @publicApi
|
|
1151
1184
|
*/
|
|
1152
1185
|
interface CanActivateChild {
|
|
@@ -1166,6 +1199,7 @@ interface CanActivateChild {
|
|
|
1166
1199
|
*
|
|
1167
1200
|
* @publicApi
|
|
1168
1201
|
* @see {@link Route}
|
|
1202
|
+
* @see [CanActivateChild](guide/routing/route-guards#canactivatechild)
|
|
1169
1203
|
*/
|
|
1170
1204
|
type CanActivateChildFn = (childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot) => MaybeAsync<GuardResult>;
|
|
1171
1205
|
/**
|
|
@@ -1220,7 +1254,7 @@ type CanActivateChildFn = (childRoute: ActivatedRouteSnapshot, state: RouterStat
|
|
|
1220
1254
|
* })
|
|
1221
1255
|
* class AppModule {}
|
|
1222
1256
|
* ```
|
|
1223
|
-
*
|
|
1257
|
+
* @see [CanDeactivate](guide/routing/route-guards#candeactivate)
|
|
1224
1258
|
* @publicApi
|
|
1225
1259
|
*/
|
|
1226
1260
|
interface CanDeactivate<T> {
|
|
@@ -1240,6 +1274,7 @@ interface CanDeactivate<T> {
|
|
|
1240
1274
|
*
|
|
1241
1275
|
* @publicApi
|
|
1242
1276
|
* @see {@link Route}
|
|
1277
|
+
* @see [CanDeactivate](guide/routing/route-guards#candeactivate)
|
|
1243
1278
|
*/
|
|
1244
1279
|
type CanDeactivateFn<T> = (component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState: RouterStateSnapshot) => MaybeAsync<GuardResult>;
|
|
1245
1280
|
/**
|
|
@@ -1301,6 +1336,7 @@ type CanDeactivateFn<T> = (component: T, currentRoute: ActivatedRouteSnapshot, c
|
|
|
1301
1336
|
* could not be used for a URL match but the catch-all `**` `Route` did instead.
|
|
1302
1337
|
*
|
|
1303
1338
|
* @publicApi
|
|
1339
|
+
* @see [CanMatch](guide/routing/route-guards#canmatch)
|
|
1304
1340
|
*/
|
|
1305
1341
|
interface CanMatch {
|
|
1306
1342
|
canMatch(route: Route, segments: UrlSegment[]): MaybeAsync<GuardResult>;
|
|
@@ -1322,6 +1358,7 @@ interface CanMatch {
|
|
|
1322
1358
|
*
|
|
1323
1359
|
* @publicApi
|
|
1324
1360
|
* @see {@link Route}
|
|
1361
|
+
* @see [CanMatch](guide/routing/route-guards#canmatch)
|
|
1325
1362
|
*/
|
|
1326
1363
|
type CanMatchFn = (route: Route, segments: UrlSegment[]) => MaybeAsync<GuardResult>;
|
|
1327
1364
|
/**
|
|
@@ -1415,6 +1452,7 @@ type CanMatchFn = (route: Route, segments: UrlSegment[]) => MaybeAsync<GuardResu
|
|
|
1415
1452
|
*
|
|
1416
1453
|
* @publicApi
|
|
1417
1454
|
* @see {@link ResolveFn}
|
|
1455
|
+
* @see [Data resolvers](guide/routing/data-resolvers)
|
|
1418
1456
|
*/
|
|
1419
1457
|
interface Resolve<T> {
|
|
1420
1458
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): MaybeAsync<T | RedirectCommand>;
|
|
@@ -1520,6 +1558,7 @@ interface Resolve<T> {
|
|
|
1520
1558
|
*
|
|
1521
1559
|
* @publicApi
|
|
1522
1560
|
* @see {@link Route}
|
|
1561
|
+
* @see [Data resolvers](guide/routing/data-resolvers)
|
|
1523
1562
|
*/
|
|
1524
1563
|
type ResolveFn<T> = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => MaybeAsync<T | RedirectCommand>;
|
|
1525
1564
|
/**
|
|
@@ -1839,6 +1878,8 @@ declare class ActivatedRoute {
|
|
|
1839
1878
|
* }
|
|
1840
1879
|
* ```
|
|
1841
1880
|
*
|
|
1881
|
+
* @see [Understanding route snapshots](guide/routing/read-route-state#understanding-route-snapshots)
|
|
1882
|
+
*
|
|
1842
1883
|
* @publicApi
|
|
1843
1884
|
*/
|
|
1844
1885
|
declare class ActivatedRouteSnapshot {
|
|
@@ -1938,6 +1979,8 @@ type NavigationTrigger = 'imperative' | 'popstate' | 'hashchange';
|
|
|
1938
1979
|
/**
|
|
1939
1980
|
* Identifies the type of a router event.
|
|
1940
1981
|
*
|
|
1982
|
+
* @see [Router Lifecycle and Events](guide/routing/lifecycle-and-events)
|
|
1983
|
+
*
|
|
1941
1984
|
* @publicApi
|
|
1942
1985
|
*/
|
|
1943
1986
|
declare enum EventType {
|
|
@@ -3569,6 +3612,8 @@ declare class RouterLink implements OnChanges, OnDestroy {
|
|
|
3569
3612
|
*
|
|
3570
3613
|
* @ngModule RouterModule
|
|
3571
3614
|
*
|
|
3615
|
+
* @see [Detect active current route with RouterLinkActive](guide/routing/read-route-state#detect-active-current-route-with-routerlinkactive)
|
|
3616
|
+
*
|
|
3572
3617
|
* @publicApi
|
|
3573
3618
|
*/
|
|
3574
3619
|
declare class RouterLinkActive implements OnChanges, OnDestroy, AfterContentInit {
|
package/testing/index.d.ts
CHANGED
package/upgrade/index.d.ts
CHANGED