@angular/router 16.0.0-next.3 → 16.0.0-next.5

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.
Files changed (96) hide show
  1. package/esm2022/src/apply_redirects.mjs +112 -0
  2. package/{esm2020 → esm2022}/src/components/empty_outlet.mjs +4 -4
  3. package/esm2022/src/create_url_tree.mjs +418 -0
  4. package/{esm2020 → esm2022}/src/directives/router_link.mjs +4 -4
  5. package/{esm2020 → esm2022}/src/directives/router_link_active.mjs +4 -4
  6. package/esm2022/src/directives/router_outlet.mjs +259 -0
  7. package/esm2022/src/index.mjs +30 -0
  8. package/esm2022/src/models_deprecated.mjs +9 -0
  9. package/esm2022/src/navigation_transition.mjs +391 -0
  10. package/esm2022/src/operators/activate_routes.mjs +180 -0
  11. package/esm2022/src/operators/recognize.mjs +16 -0
  12. package/{esm2020 → esm2022}/src/page_title_strategy.mjs +7 -7
  13. package/esm2022/src/provide_router.mjs +478 -0
  14. package/esm2022/src/recognize.mjs +360 -0
  15. package/{esm2020 → esm2022}/src/route_reuse_strategy.mjs +7 -7
  16. package/esm2022/src/router.mjs +719 -0
  17. package/esm2022/src/router_config.mjs +18 -0
  18. package/esm2022/src/router_config_loader.mjs +132 -0
  19. package/esm2022/src/router_module.mjs +219 -0
  20. package/{esm2020 → esm2022}/src/router_outlet_context.mjs +4 -4
  21. package/esm2022/src/router_preloader.mjs +167 -0
  22. package/{esm2020 → esm2022}/src/router_scroller.mjs +4 -4
  23. package/esm2022/src/router_state.mjs +408 -0
  24. package/{esm2020 → esm2022}/src/url_handling_strategy.mjs +7 -7
  25. package/esm2022/src/url_tree.mjs +642 -0
  26. package/esm2022/src/utils/config_matching.mjs +141 -0
  27. package/esm2022/src/utils/navigations.mjs +42 -0
  28. package/{esm2020 → esm2022}/src/version.mjs +1 -1
  29. package/{esm2020 → esm2022}/testing/src/router_testing_harness.mjs +7 -7
  30. package/{esm2020 → esm2022}/testing/src/router_testing_module.mjs +10 -10
  31. package/{fesm2020 → fesm2022}/router.mjs +481 -726
  32. package/fesm2022/router.mjs.map +1 -0
  33. package/{fesm2020 → fesm2022}/testing.mjs +16 -16
  34. package/{fesm2020 → fesm2022}/testing.mjs.map +1 -1
  35. package/{fesm2020 → fesm2022}/upgrade.mjs +1 -1
  36. package/index.d.ts +9 -10
  37. package/package.json +14 -24
  38. package/testing/index.d.ts +1 -1
  39. package/upgrade/index.d.ts +1 -1
  40. package/esm2020/src/apply_redirects.mjs +0 -331
  41. package/esm2020/src/create_url_tree.mjs +0 -454
  42. package/esm2020/src/create_url_tree_strategy.mjs +0 -78
  43. package/esm2020/src/deprecated_load_children.mjs +0 -13
  44. package/esm2020/src/directives/router_outlet.mjs +0 -259
  45. package/esm2020/src/index.mjs +0 -29
  46. package/esm2020/src/navigation_transition.mjs +0 -399
  47. package/esm2020/src/operators/activate_routes.mjs +0 -177
  48. package/esm2020/src/operators/apply_redirects.mjs +0 -14
  49. package/esm2020/src/operators/recognize.mjs +0 -14
  50. package/esm2020/src/provide_router.mjs +0 -477
  51. package/esm2020/src/recognize.mjs +0 -297
  52. package/esm2020/src/router.mjs +0 -689
  53. package/esm2020/src/router_config.mjs +0 -19
  54. package/esm2020/src/router_config_loader.mjs +0 -137
  55. package/esm2020/src/router_module.mjs +0 -216
  56. package/esm2020/src/router_preloader.mjs +0 -167
  57. package/esm2020/src/router_state.mjs +0 -411
  58. package/esm2020/src/url_tree.mjs +0 -631
  59. package/esm2020/src/utils/config_matching.mjs +0 -153
  60. package/esm2020/src/utils/navigations.mjs +0 -42
  61. package/fesm2015/router.mjs +0 -7138
  62. package/fesm2015/router.mjs.map +0 -1
  63. package/fesm2015/testing.mjs +0 -270
  64. package/fesm2015/testing.mjs.map +0 -1
  65. package/fesm2015/upgrade.mjs +0 -146
  66. package/fesm2015/upgrade.mjs.map +0 -1
  67. package/fesm2020/router.mjs.map +0 -1
  68. /package/{esm2020 → esm2022}/index.mjs +0 -0
  69. /package/{esm2020 → esm2022}/public_api.mjs +0 -0
  70. /package/{esm2020 → esm2022}/router.mjs +0 -0
  71. /package/{esm2020 → esm2022}/src/create_router_state.mjs +0 -0
  72. /package/{esm2020 → esm2022}/src/errors.mjs +0 -0
  73. /package/{esm2020 → esm2022}/src/events.mjs +0 -0
  74. /package/{esm2020 → esm2022}/src/models.mjs +0 -0
  75. /package/{esm2020 → esm2022}/src/navigation_canceling_error.mjs +0 -0
  76. /package/{esm2020 → esm2022}/src/operators/check_guards.mjs +0 -0
  77. /package/{esm2020 → esm2022}/src/operators/prioritized_guard_value.mjs +0 -0
  78. /package/{esm2020 → esm2022}/src/operators/resolve_data.mjs +0 -0
  79. /package/{esm2020 → esm2022}/src/operators/switch_tap.mjs +0 -0
  80. /package/{esm2020 → esm2022}/src/private_export.mjs +0 -0
  81. /package/{esm2020 → esm2022}/src/shared.mjs +0 -0
  82. /package/{esm2020 → esm2022}/src/utils/collection.mjs +0 -0
  83. /package/{esm2020 → esm2022}/src/utils/config.mjs +0 -0
  84. /package/{esm2020 → esm2022}/src/utils/functional_guards.mjs +0 -0
  85. /package/{esm2020 → esm2022}/src/utils/preactivation.mjs +0 -0
  86. /package/{esm2020 → esm2022}/src/utils/tree.mjs +0 -0
  87. /package/{esm2020 → esm2022}/src/utils/type_guards.mjs +0 -0
  88. /package/{esm2020 → esm2022}/testing/index.mjs +0 -0
  89. /package/{esm2020 → esm2022}/testing/public_api.mjs +0 -0
  90. /package/{esm2020 → esm2022}/testing/src/testing.mjs +0 -0
  91. /package/{esm2020 → esm2022}/testing/testing.mjs +0 -0
  92. /package/{esm2020 → esm2022}/upgrade/index.mjs +0 -0
  93. /package/{esm2020 → esm2022}/upgrade/public_api.mjs +0 -0
  94. /package/{esm2020 → esm2022}/upgrade/src/upgrade.mjs +0 -0
  95. /package/{esm2020 → esm2022}/upgrade/upgrade.mjs +0 -0
  96. /package/{fesm2020 → fesm2022}/upgrade.mjs.map +0 -0
@@ -1,270 +0,0 @@
1
- /**
2
- * @license Angular v16.0.0-next.3
3
- * (c) 2010-2022 Google LLC. https://angular.io/
4
- * License: MIT
5
- */
6
-
7
- import { Location } from '@angular/common';
8
- import { provideLocationMocks } from '@angular/common/testing';
9
- import * as i0 from '@angular/core';
10
- import { inject, Compiler, Injector, NgModule, Injectable, Component, ViewChild } from '@angular/core';
11
- import { UrlSerializer, ChildrenOutletContexts, ROUTES, UrlHandlingStrategy, ROUTER_CONFIGURATION, RouteReuseStrategy, TitleStrategy, Router, RouterModule, ɵROUTER_PROVIDERS, ɵwithPreloading, NoPreloading, RouterOutlet, ɵafterNextNavigation } from '@angular/router';
12
- import { __awaiter } from 'tslib';
13
- import { TestBed } from '@angular/core/testing';
14
-
15
- function isUrlHandlingStrategy(opts) {
16
- // This property check is needed because UrlHandlingStrategy is an interface and doesn't exist at
17
- // runtime.
18
- return 'shouldProcessUrl' in opts;
19
- }
20
- function throwInvalidConfigError(parameter) {
21
- throw new Error(`Parameter ${parameter} does not match the one available in the injector. ` +
22
- '`setupTestingRouter` is meant to be used as a factory function with dependencies coming from DI.');
23
- }
24
- /**
25
- * Router setup factory function used for testing.
26
- *
27
- * @publicApi
28
- * @deprecated Use `provideRouter` or `RouterTestingModule` instead.
29
- */
30
- function setupTestingRouter(urlSerializer, contexts, location, compiler, injector, routes, opts, urlHandlingStrategy, routeReuseStrategy, titleStrategy) {
31
- // Note: The checks below are to detect misconfigured providers and invalid uses of
32
- // `setupTestingRouter`. This function is not used internally (neither in router code or anywhere
33
- // in g3). It appears this function was exposed as publicApi by mistake and should not be used
34
- // externally either. However, if it is, the documented intent is to be used as a factory function
35
- // and parameter values should always match what's available in DI.
36
- if (urlSerializer !== inject(UrlSerializer)) {
37
- throwInvalidConfigError('urlSerializer');
38
- }
39
- if (contexts !== inject(ChildrenOutletContexts)) {
40
- throwInvalidConfigError('contexts');
41
- }
42
- if (location !== inject(Location)) {
43
- throwInvalidConfigError('location');
44
- }
45
- if (compiler !== inject(Compiler)) {
46
- throwInvalidConfigError('compiler');
47
- }
48
- if (injector !== inject(Injector)) {
49
- throwInvalidConfigError('injector');
50
- }
51
- if (routes !== inject(ROUTES)) {
52
- throwInvalidConfigError('routes');
53
- }
54
- if (opts) {
55
- // Handle deprecated argument ordering.
56
- if (isUrlHandlingStrategy(opts)) {
57
- if (opts !== inject(UrlHandlingStrategy)) {
58
- throwInvalidConfigError('opts (UrlHandlingStrategy)');
59
- }
60
- }
61
- else {
62
- if (opts !== inject(ROUTER_CONFIGURATION)) {
63
- throwInvalidConfigError('opts (ROUTER_CONFIGURATION)');
64
- }
65
- }
66
- }
67
- if (urlHandlingStrategy !== inject(UrlHandlingStrategy)) {
68
- throwInvalidConfigError('urlHandlingStrategy');
69
- }
70
- if (routeReuseStrategy !== inject(RouteReuseStrategy)) {
71
- throwInvalidConfigError('routeReuseStrategy');
72
- }
73
- if (titleStrategy !== inject(TitleStrategy)) {
74
- throwInvalidConfigError('titleStrategy');
75
- }
76
- return new Router();
77
- }
78
- /**
79
- * @description
80
- *
81
- * Sets up the router to be used for testing.
82
- *
83
- * The modules sets up the router to be used for testing.
84
- * It provides spy implementations of `Location` and `LocationStrategy`.
85
- *
86
- * @usageNotes
87
- * ### Example
88
- *
89
- * ```
90
- * beforeEach(() => {
91
- * TestBed.configureTestingModule({
92
- * imports: [
93
- * RouterTestingModule.withRoutes(
94
- * [{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}]
95
- * )
96
- * ]
97
- * });
98
- * });
99
- * ```
100
- *
101
- * @publicApi
102
- */
103
- class RouterTestingModule {
104
- static withRoutes(routes, config) {
105
- return {
106
- ngModule: RouterTestingModule,
107
- providers: [
108
- { provide: ROUTES, multi: true, useValue: routes },
109
- { provide: ROUTER_CONFIGURATION, useValue: config ? config : {} },
110
- ]
111
- };
112
- }
113
- }
114
- RouterTestingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.3", ngImport: i0, type: RouterTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
115
- RouterTestingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-next.3", ngImport: i0, type: RouterTestingModule, exports: [RouterModule] });
116
- RouterTestingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-next.3", ngImport: i0, type: RouterTestingModule, providers: [
117
- ɵROUTER_PROVIDERS,
118
- provideLocationMocks(),
119
- ɵwithPreloading(NoPreloading).ɵproviders,
120
- { provide: ROUTES, multi: true, useValue: [] },
121
- ], imports: [RouterModule] });
122
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.3", ngImport: i0, type: RouterTestingModule, decorators: [{
123
- type: NgModule,
124
- args: [{
125
- exports: [RouterModule],
126
- providers: [
127
- ɵROUTER_PROVIDERS,
128
- provideLocationMocks(),
129
- ɵwithPreloading(NoPreloading).ɵproviders,
130
- { provide: ROUTES, multi: true, useValue: [] },
131
- ]
132
- }]
133
- }] });
134
-
135
- class RootFixtureService {
136
- createHarness() {
137
- if (this.harness) {
138
- throw new Error('Only one harness should be created per test.');
139
- }
140
- this.harness = new RouterTestingHarness(this.getRootFixture());
141
- return this.harness;
142
- }
143
- getRootFixture() {
144
- if (this.fixture !== undefined) {
145
- return this.fixture;
146
- }
147
- this.fixture = TestBed.createComponent(RootCmp);
148
- this.fixture.detectChanges();
149
- return this.fixture;
150
- }
151
- }
152
- RootFixtureService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.3", ngImport: i0, type: RootFixtureService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
153
- RootFixtureService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.3", ngImport: i0, type: RootFixtureService, providedIn: 'root' });
154
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.3", ngImport: i0, type: RootFixtureService, decorators: [{
155
- type: Injectable,
156
- args: [{ providedIn: 'root' }]
157
- }] });
158
- class RootCmp {
159
- }
160
- RootCmp.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.3", ngImport: i0, type: RootCmp, deps: [], target: i0.ɵɵFactoryTarget.Component });
161
- RootCmp.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0-next.3", type: RootCmp, isStandalone: true, selector: "ng-component", viewQueries: [{ propertyName: "outlet", first: true, predicate: RouterOutlet, descendants: true }], ngImport: i0, template: '<router-outlet></router-outlet>', isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] });
162
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.3", ngImport: i0, type: RootCmp, decorators: [{
163
- type: Component,
164
- args: [{
165
- standalone: true,
166
- template: '<router-outlet></router-outlet>',
167
- imports: [RouterOutlet],
168
- }]
169
- }], propDecorators: { outlet: [{
170
- type: ViewChild,
171
- args: [RouterOutlet]
172
- }] } });
173
- /**
174
- * A testing harness for the `Router` to reduce the boilerplate needed to test routes and routed
175
- * components.
176
- *
177
- * @publicApi
178
- */
179
- class RouterTestingHarness {
180
- /**
181
- * Creates a `RouterTestingHarness` instance.
182
- *
183
- * The `RouterTestingHarness` also creates its own root component with a `RouterOutlet` for the
184
- * purposes of rendering route components.
185
- *
186
- * Throws an error if an instance has already been created.
187
- * Use of this harness also requires `destroyAfterEach: true` in the `ModuleTeardownOptions`
188
- *
189
- * @param initialUrl The target of navigation to trigger before returning the harness.
190
- */
191
- static create(initialUrl) {
192
- return __awaiter(this, void 0, void 0, function* () {
193
- const harness = TestBed.inject(RootFixtureService).createHarness();
194
- if (initialUrl !== undefined) {
195
- yield harness.navigateByUrl(initialUrl);
196
- }
197
- return harness;
198
- });
199
- }
200
- /** @internal */
201
- constructor(fixture) {
202
- this.fixture = fixture;
203
- }
204
- /** Instructs the root fixture to run change detection. */
205
- detectChanges() {
206
- this.fixture.detectChanges();
207
- }
208
- /** The `DebugElement` of the `RouterOutlet` component. `null` if the outlet is not activated. */
209
- get routeDebugElement() {
210
- const outlet = this.fixture.componentInstance.outlet;
211
- if (!outlet || !outlet.isActivated) {
212
- return null;
213
- }
214
- return this.fixture.debugElement.query(v => v.componentInstance === outlet.component);
215
- }
216
- /** The native element of the `RouterOutlet` component. `null` if the outlet is not activated. */
217
- get routeNativeElement() {
218
- var _a, _b;
219
- return (_b = (_a = this.routeDebugElement) === null || _a === void 0 ? void 0 : _a.nativeElement) !== null && _b !== void 0 ? _b : null;
220
- }
221
- navigateByUrl(url, requiredRoutedComponentType) {
222
- return __awaiter(this, void 0, void 0, function* () {
223
- const router = TestBed.inject(Router);
224
- let resolveFn;
225
- const redirectTrackingPromise = new Promise(resolve => {
226
- resolveFn = resolve;
227
- });
228
- ɵafterNextNavigation(TestBed.inject(Router), resolveFn);
229
- yield router.navigateByUrl(url);
230
- yield redirectTrackingPromise;
231
- this.fixture.detectChanges();
232
- const outlet = this.fixture.componentInstance.outlet;
233
- // The outlet might not be activated if the user is testing a navigation for a guard that
234
- // rejects
235
- if (outlet && outlet.isActivated && outlet.activatedRoute.component) {
236
- const activatedComponent = outlet.component;
237
- if (requiredRoutedComponentType !== undefined &&
238
- !(activatedComponent instanceof requiredRoutedComponentType)) {
239
- throw new Error(`Unexpected routed component type. Expected ${requiredRoutedComponentType.name} but got ${activatedComponent.constructor.name}`);
240
- }
241
- return activatedComponent;
242
- }
243
- else {
244
- return null;
245
- }
246
- });
247
- }
248
- }
249
-
250
- /**
251
- * @module
252
- * @description
253
- * Entry point for all public APIs of the router/testing package.
254
- */
255
-
256
- /**
257
- * @module
258
- * @description
259
- * Entry point for all public APIs of this package.
260
- */
261
- // This file only reexports content of the `src` folder. Keep it that way.
262
-
263
- // This file is not used to build this module. It is only used during editing
264
-
265
- /**
266
- * Generated bundle index. Do not edit.
267
- */
268
-
269
- export { RouterTestingHarness, RouterTestingModule, setupTestingRouter };
270
- //# sourceMappingURL=testing.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"testing.mjs","sources":["../../../../../../packages/router/testing/src/router_testing_module.ts","../../../../../../packages/router/testing/src/router_testing_harness.ts","../../../../../../packages/router/testing/src/testing.ts","../../../../../../packages/router/testing/public_api.ts","../../../../../../packages/router/testing/index.ts","../../../../../../packages/router/testing/testing.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.io/license\n */\n\nimport {Location} from '@angular/common';\nimport {provideLocationMocks} from '@angular/common/testing';\nimport {Compiler, inject, Injector, ModuleWithProviders, NgModule} from '@angular/core';\nimport {ChildrenOutletContexts, ExtraOptions, NoPreloading, Route, Router, ROUTER_CONFIGURATION, RouteReuseStrategy, RouterModule, ROUTES, Routes, TitleStrategy, UrlHandlingStrategy, UrlSerializer, ɵROUTER_PROVIDERS as ROUTER_PROVIDERS, ɵwithPreloading as withPreloading} from '@angular/router';\n\nfunction isUrlHandlingStrategy(opts: ExtraOptions|\n UrlHandlingStrategy): opts is UrlHandlingStrategy {\n // This property check is needed because UrlHandlingStrategy is an interface and doesn't exist at\n // runtime.\n return 'shouldProcessUrl' in opts;\n}\n\nfunction throwInvalidConfigError(parameter: string): never {\n throw new Error(\n `Parameter ${parameter} does not match the one available in the injector. ` +\n '`setupTestingRouter` is meant to be used as a factory function with dependencies coming from DI.');\n}\n\n/**\n * Router setup factory function used for testing.\n *\n * @publicApi\n * @deprecated Use `provideRouter` or `RouterTestingModule` instead.\n */\nexport function setupTestingRouter(\n urlSerializer: UrlSerializer, contexts: ChildrenOutletContexts, location: Location,\n compiler: Compiler, injector: Injector, routes: Route[][],\n opts?: ExtraOptions|UrlHandlingStrategy|null, urlHandlingStrategy?: UrlHandlingStrategy,\n routeReuseStrategy?: RouteReuseStrategy, titleStrategy?: TitleStrategy) {\n // Note: The checks below are to detect misconfigured providers and invalid uses of\n // `setupTestingRouter`. This function is not used internally (neither in router code or anywhere\n // in g3). It appears this function was exposed as publicApi by mistake and should not be used\n // externally either. However, if it is, the documented intent is to be used as a factory function\n // and parameter values should always match what's available in DI.\n if (urlSerializer !== inject(UrlSerializer)) {\n throwInvalidConfigError('urlSerializer');\n }\n if (contexts !== inject(ChildrenOutletContexts)) {\n throwInvalidConfigError('contexts');\n }\n if (location !== inject(Location)) {\n throwInvalidConfigError('location');\n }\n if (compiler !== inject(Compiler)) {\n throwInvalidConfigError('compiler');\n }\n if (injector !== inject(Injector)) {\n throwInvalidConfigError('injector');\n }\n if (routes !== inject(ROUTES)) {\n throwInvalidConfigError('routes');\n }\n if (opts) {\n // Handle deprecated argument ordering.\n if (isUrlHandlingStrategy(opts)) {\n if (opts !== inject(UrlHandlingStrategy)) {\n throwInvalidConfigError('opts (UrlHandlingStrategy)');\n }\n } else {\n if (opts !== inject(ROUTER_CONFIGURATION)) {\n throwInvalidConfigError('opts (ROUTER_CONFIGURATION)');\n }\n }\n }\n\n if (urlHandlingStrategy !== inject(UrlHandlingStrategy)) {\n throwInvalidConfigError('urlHandlingStrategy');\n }\n\n if (routeReuseStrategy !== inject(RouteReuseStrategy)) {\n throwInvalidConfigError('routeReuseStrategy');\n }\n\n if (titleStrategy !== inject(TitleStrategy)) {\n throwInvalidConfigError('titleStrategy');\n }\n\n return new Router();\n}\n\n/**\n * @description\n *\n * Sets up the router to be used for testing.\n *\n * The modules sets up the router to be used for testing.\n * It provides spy implementations of `Location` and `LocationStrategy`.\n *\n * @usageNotes\n * ### Example\n *\n * ```\n * beforeEach(() => {\n * TestBed.configureTestingModule({\n * imports: [\n * RouterTestingModule.withRoutes(\n * [{path: '', component: BlankCmp}, {path: 'simple', component: SimpleCmp}]\n * )\n * ]\n * });\n * });\n * ```\n *\n * @publicApi\n */\n@NgModule({\n exports: [RouterModule],\n providers: [\n ROUTER_PROVIDERS,\n provideLocationMocks(),\n withPreloading(NoPreloading).ɵproviders,\n {provide: ROUTES, multi: true, useValue: []},\n ]\n})\nexport class RouterTestingModule {\n static withRoutes(routes: Routes, 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.io/license\n */\n\nimport {Component, DebugElement, Injectable, Type, ViewChild} from '@angular/core';\nimport {ComponentFixture, TestBed} from '@angular/core/testing';\nimport {Router, RouterOutlet, ɵafterNextNavigation as afterNextNavigation} from '@angular/router';\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 standalone: true,\n template: '<router-outlet></router-outlet>',\n imports: [RouterOutlet],\n})\nexport class RootCmp {\n @ViewChild(RouterOutlet) outlet?: RouterOutlet;\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 /** @internal */\n constructor(private readonly fixture: ComponentFixture<RootCmp>) {}\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.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.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 (requiredRoutedComponentType !== undefined &&\n !(activatedComponent instanceof requiredRoutedComponentType)) {\n throw new Error(`Unexpected routed component type. Expected ${\n requiredRoutedComponentType.name} but got ${activatedComponent.constructor.name}`);\n }\n return activatedComponent as T;\n } else {\n return null;\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.io/license\n */\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of the router/testing package.\n */\nexport * from './router_testing_module';\nexport {RouterTestingHarness} from './router_testing_harness';\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.io/license\n */\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of this package.\n */\nexport * from './src/testing';\n\n// This file only reexports content of the `src` folder. Keep it that way.\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.io/license\n */\n\n// This file is not used to build this module. It is only used during editing\n// by the TypeScript language service and during build for verification. `ngc`\n// replaces this file with production index.ts when it rewrites private symbol\n// names.\n\nexport * from './public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\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AAC,IAAI,CAAA,CAAE,CAAC,CAAC;AACxF,iBAAA;AACD,gBAAA,OAAO,kBAAuB,CAAC;AAChC,aAAA;AAAM,iBAAA;AACL,gBAAA,OAAO,IAAI,CAAC;AACb,aAAA;SACF,CAAA,CAAA;AAAA,KAAA;AACF;;ACjJD;;;;AAIG;;ACJH;;;;AAIG;AAGH;;ACPA;;ACRA;;AAEG;;;;"}
@@ -1,146 +0,0 @@
1
- /**
2
- * @license Angular v16.0.0-next.3
3
- * (c) 2010-2022 Google LLC. https://angular.io/
4
- * License: MIT
5
- */
6
-
7
- import { Location } from '@angular/common';
8
- import { APP_BOOTSTRAP_LISTENER } from '@angular/core';
9
- import { Router } from '@angular/router';
10
- import { UpgradeModule } from '@angular/upgrade/static';
11
-
12
- /**
13
- * Creates an initializer that sets up `ngRoute` integration
14
- * along with setting up the Angular router.
15
- *
16
- * @usageNotes
17
- *
18
- * <code-example language="typescript">
19
- * @NgModule({
20
- * imports: [
21
- * RouterModule.forRoot(SOME_ROUTES),
22
- * UpgradeModule
23
- * ],
24
- * providers: [
25
- * RouterUpgradeInitializer
26
- * ]
27
- * })
28
- * export class AppModule {
29
- * ngDoBootstrap() {}
30
- * }
31
- * </code-example>
32
- *
33
- * @publicApi
34
- */
35
- const RouterUpgradeInitializer = {
36
- provide: APP_BOOTSTRAP_LISTENER,
37
- multi: true,
38
- useFactory: locationSyncBootstrapListener,
39
- deps: [UpgradeModule]
40
- };
41
- /**
42
- * @internal
43
- */
44
- function locationSyncBootstrapListener(ngUpgrade) {
45
- return () => {
46
- setUpLocationSync(ngUpgrade);
47
- };
48
- }
49
- /**
50
- * Sets up a location change listener to trigger `history.pushState`.
51
- * Works around the problem that `onPopState` does not trigger `history.pushState`.
52
- * Must be called *after* calling `UpgradeModule.bootstrap`.
53
- *
54
- * @param ngUpgrade The upgrade NgModule.
55
- * @param urlType The location strategy.
56
- * @see `HashLocationStrategy`
57
- * @see `PathLocationStrategy`
58
- *
59
- * @publicApi
60
- */
61
- function setUpLocationSync(ngUpgrade, urlType = 'path') {
62
- if (!ngUpgrade.$injector) {
63
- throw new Error(`
64
- RouterUpgradeInitializer can be used only after UpgradeModule.bootstrap has been called.
65
- Remove RouterUpgradeInitializer and call setUpLocationSync after UpgradeModule.bootstrap.
66
- `);
67
- }
68
- const router = ngUpgrade.injector.get(Router);
69
- const location = ngUpgrade.injector.get(Location);
70
- ngUpgrade.$injector.get('$rootScope')
71
- .$on('$locationChangeStart', (event, newUrl, oldUrl, newState, oldState) => {
72
- var _a;
73
- // Navigations coming from Angular router have a navigationId state
74
- // property. Don't trigger Angular router navigation again if it is
75
- // caused by a URL change from the current Angular router
76
- // navigation.
77
- const currentNavigationId = (_a = router.getCurrentNavigation()) === null || _a === void 0 ? void 0 : _a.id;
78
- const newStateNavigationId = newState === null || newState === void 0 ? void 0 : newState.navigationId;
79
- if (newStateNavigationId !== undefined &&
80
- newStateNavigationId === currentNavigationId) {
81
- return;
82
- }
83
- let url;
84
- if (urlType === 'path') {
85
- url = resolveUrl(newUrl);
86
- }
87
- else if (urlType === 'hash') {
88
- // Remove the first hash from the URL
89
- const hashIdx = newUrl.indexOf('#');
90
- url = resolveUrl(newUrl.substring(0, hashIdx) + newUrl.substring(hashIdx + 1));
91
- }
92
- else {
93
- throw 'Invalid URLType passed to setUpLocationSync: ' + urlType;
94
- }
95
- const path = location.normalize(url.pathname);
96
- router.navigateByUrl(path + url.search + url.hash);
97
- });
98
- }
99
- /**
100
- * Normalizes and parses a URL.
101
- *
102
- * - Normalizing means that a relative URL will be resolved into an absolute URL in the context of
103
- * the application document.
104
- * - Parsing means that the anchor's `protocol`, `hostname`, `port`, `pathname` and related
105
- * properties are all populated to reflect the normalized URL.
106
- *
107
- * While this approach has wide compatibility, it doesn't work as expected on IE. On IE, normalizing
108
- * happens similar to other browsers, but the parsed components will not be set. (E.g. if you assign
109
- * `a.href = 'foo'`, then `a.protocol`, `a.host`, etc. will not be correctly updated.)
110
- * We work around that by performing the parsing in a 2nd step by taking a previously normalized URL
111
- * and assigning it again. This correctly populates all properties.
112
- *
113
- * See
114
- * https://github.com/angular/angular.js/blob/2c7400e7d07b0f6cec1817dab40b9250ce8ebce6/src/ng/urlUtils.js#L26-L33
115
- * for more info.
116
- */
117
- let anchor;
118
- function resolveUrl(url) {
119
- if (!anchor) {
120
- anchor = document.createElement('a');
121
- }
122
- anchor.setAttribute('href', url);
123
- anchor.setAttribute('href', anchor.href);
124
- return {
125
- // IE does not start `pathname` with `/` like other browsers.
126
- pathname: `/${anchor.pathname.replace(/^\//, '')}`,
127
- search: anchor.search,
128
- hash: anchor.hash
129
- };
130
- }
131
-
132
- /**
133
- * @module
134
- * @description
135
- * Entry point for all public APIs of this package.
136
- */
137
- // This file only reexports content of the `src` folder. Keep it that way.
138
-
139
- // This file is not used to build this module. It is only used during editing
140
-
141
- /**
142
- * Generated bundle index. Do not edit.
143
- */
144
-
145
- export { RouterUpgradeInitializer, locationSyncBootstrapListener, setUpLocationSync };
146
- //# sourceMappingURL=upgrade.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upgrade.mjs","sources":["../../../../../../packages/router/upgrade/src/upgrade.ts","../../../../../../packages/router/upgrade/public_api.ts","../../../../../../packages/router/upgrade/index.ts","../../../../../../packages/router/upgrade/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.io/license\n */\n\nimport {Location} from '@angular/common';\nimport {APP_BOOTSTRAP_LISTENER, ComponentRef, InjectionToken} from '@angular/core';\nimport {Router, ɵRestoredState as RestoredState} from '@angular/router';\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 * <code-example language=\"typescript\">\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 * </code-example>\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 `HashLocationStrategy`\n * @see `PathLocationStrategy`\n *\n * @publicApi\n */\nexport function setUpLocationSync(ngUpgrade: UpgradeModule, urlType: 'path'|'hash' = 'path') {\n if (!ngUpgrade.$injector) {\n throw new Error(`\n RouterUpgradeInitializer can be used only after UpgradeModule.bootstrap has been called.\n Remove RouterUpgradeInitializer and call setUpLocationSync after UpgradeModule.bootstrap.\n `);\n }\n\n const router: Router = ngUpgrade.injector.get(Router);\n const location: Location = ngUpgrade.injector.get(Location);\n\n ngUpgrade.$injector.get('$rootScope')\n .$on(\n '$locationChangeStart',\n (event: any, newUrl: string, oldUrl: string,\n newState?: {[k: string]: unknown}|RestoredState,\n oldState?: {[k: string]: unknown}|RestoredState) => {\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 &&\n 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 * 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 if (!anchor) {\n anchor = document.createElement('a');\n }\n\n anchor.setAttribute('href', url);\n anchor.setAttribute('href', anchor.href);\n\n return {\n // IE does not start `pathname` with `/` like other browsers.\n pathname: `/${anchor.pathname.replace(/^\\//, '')}`,\n search: anchor.search,\n hash: anchor.hash\n };\n}\n","/**\n * @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.io/license\n */\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of this package.\n */\nexport * from './src/upgrade';\n\n// This file only reexports content of the `src` folder. Keep it that way.\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.io/license\n */\n\n// This file is not used to build this module. It is only used during editing\n// by the TypeScript language service and during build for verification. `ngc`\n// replaces this file with production index.ts when it rewrites private symbol\n// names.\n\nexport * from './public_api';\n","/**\n * Generated bundle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