@angular/common 19.2.0-rc.0 → 20.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,707 +1,15 @@
1
1
  /**
2
- * @license Angular v19.2.0-rc.0
2
+ * @license Angular v20.0.0-next.0
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import { ɵPlatformNavigation, DOCUMENT, PlatformLocation, ɵnormalizeQueryParams, LocationStrategy, Location } from '@angular/common';
8
8
  import * as i0 from '@angular/core';
9
- import { Injectable, InjectionToken, Inject, Optional, inject } from '@angular/core';
9
+ import { InjectionToken, Injectable, Inject, Optional, inject } from '@angular/core';
10
10
  import { Subject } from 'rxjs';
11
-
12
- /**
13
- * This class wraps the platform Navigation API which allows server-specific and test
14
- * implementations.
15
- */
16
- class PlatformNavigation {
17
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: PlatformNavigation, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
18
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: PlatformNavigation, providedIn: 'platform', useFactory: () => window.navigation });
19
- }
20
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: PlatformNavigation, decorators: [{
21
- type: Injectable,
22
- args: [{ providedIn: 'platform', useFactory: () => window.navigation }]
23
- }] });
24
-
25
- /**
26
- * Fake implementation of user agent history and navigation behavior. This is a
27
- * high-fidelity implementation of browser behavior that attempts to emulate
28
- * things like traversal delay.
29
- */
30
- class FakeNavigation {
31
- window;
32
- /**
33
- * The fake implementation of an entries array. Only same-document entries
34
- * allowed.
35
- */
36
- entriesArr = [];
37
- /**
38
- * The current active entry index into `entriesArr`.
39
- */
40
- currentEntryIndex = 0;
41
- /**
42
- * The current navigate event.
43
- */
44
- navigateEvent = undefined;
45
- /**
46
- * A Map of pending traversals, so that traversals to the same entry can be
47
- * re-used.
48
- */
49
- traversalQueue = new Map();
50
- /**
51
- * A Promise that resolves when the previous traversals have finished. Used to
52
- * simulate the cross-process communication necessary for traversals.
53
- */
54
- nextTraversal = Promise.resolve();
55
- /**
56
- * A prospective current active entry index, which includes unresolved
57
- * traversals. Used by `go` to determine where navigations are intended to go.
58
- */
59
- prospectiveEntryIndex = 0;
60
- /**
61
- * A test-only option to make traversals synchronous, rather than emulate
62
- * cross-process communication.
63
- */
64
- synchronousTraversals = false;
65
- /** Whether to allow a call to setInitialEntryForTesting. */
66
- canSetInitialEntry = true;
67
- /** `EventTarget` to dispatch events. */
68
- eventTarget;
69
- /** The next unique id for created entries. Replace recreates this id. */
70
- nextId = 0;
71
- /** The next unique key for created entries. Replace inherits this id. */
72
- nextKey = 0;
73
- /** Whether this fake is disposed. */
74
- disposed = false;
75
- /** Equivalent to `navigation.currentEntry`. */
76
- get currentEntry() {
77
- return this.entriesArr[this.currentEntryIndex];
78
- }
79
- get canGoBack() {
80
- return this.currentEntryIndex > 0;
81
- }
82
- get canGoForward() {
83
- return this.currentEntryIndex < this.entriesArr.length - 1;
84
- }
85
- constructor(window, startURL) {
86
- this.window = window;
87
- this.eventTarget = this.window.document.createElement('div');
88
- // First entry.
89
- this.setInitialEntryForTesting(startURL);
90
- }
91
- /**
92
- * Sets the initial entry.
93
- */
94
- setInitialEntryForTesting(url, options = { historyState: null }) {
95
- if (!this.canSetInitialEntry) {
96
- throw new Error('setInitialEntryForTesting can only be called before any ' + 'navigation has occurred');
97
- }
98
- const currentInitialEntry = this.entriesArr[0];
99
- this.entriesArr[0] = new FakeNavigationHistoryEntry(new URL(url).toString(), {
100
- index: 0,
101
- key: currentInitialEntry?.key ?? String(this.nextKey++),
102
- id: currentInitialEntry?.id ?? String(this.nextId++),
103
- sameDocument: true,
104
- historyState: options?.historyState,
105
- state: options.state,
106
- });
107
- }
108
- /** Returns whether the initial entry is still eligible to be set. */
109
- canSetInitialEntryForTesting() {
110
- return this.canSetInitialEntry;
111
- }
112
- /**
113
- * Sets whether to emulate traversals as synchronous rather than
114
- * asynchronous.
115
- */
116
- setSynchronousTraversalsForTesting(synchronousTraversals) {
117
- this.synchronousTraversals = synchronousTraversals;
118
- }
119
- /** Equivalent to `navigation.entries()`. */
120
- entries() {
121
- return this.entriesArr.slice();
122
- }
123
- /** Equivalent to `navigation.navigate()`. */
124
- navigate(url, options) {
125
- const fromUrl = new URL(this.currentEntry.url);
126
- const toUrl = new URL(url, this.currentEntry.url);
127
- let navigationType;
128
- if (!options?.history || options.history === 'auto') {
129
- // Auto defaults to push, but if the URLs are the same, is a replace.
130
- if (fromUrl.toString() === toUrl.toString()) {
131
- navigationType = 'replace';
132
- }
133
- else {
134
- navigationType = 'push';
135
- }
136
- }
137
- else {
138
- navigationType = options.history;
139
- }
140
- const hashChange = isHashChange(fromUrl, toUrl);
141
- const destination = new FakeNavigationDestination({
142
- url: toUrl.toString(),
143
- state: options?.state,
144
- sameDocument: hashChange,
145
- historyState: null,
146
- });
147
- const result = new InternalNavigationResult();
148
- this.userAgentNavigate(destination, result, {
149
- navigationType,
150
- cancelable: true,
151
- canIntercept: true,
152
- // Always false for navigate().
153
- userInitiated: false,
154
- hashChange,
155
- info: options?.info,
156
- });
157
- return {
158
- committed: result.committed,
159
- finished: result.finished,
160
- };
161
- }
162
- /** Equivalent to `history.pushState()`. */
163
- pushState(data, title, url) {
164
- this.pushOrReplaceState('push', data, title, url);
165
- }
166
- /** Equivalent to `history.replaceState()`. */
167
- replaceState(data, title, url) {
168
- this.pushOrReplaceState('replace', data, title, url);
169
- }
170
- pushOrReplaceState(navigationType, data, _title, url) {
171
- const fromUrl = new URL(this.currentEntry.url);
172
- const toUrl = url ? new URL(url, this.currentEntry.url) : fromUrl;
173
- const hashChange = isHashChange(fromUrl, toUrl);
174
- const destination = new FakeNavigationDestination({
175
- url: toUrl.toString(),
176
- sameDocument: true,
177
- historyState: data,
178
- });
179
- const result = new InternalNavigationResult();
180
- this.userAgentNavigate(destination, result, {
181
- navigationType,
182
- cancelable: true,
183
- canIntercept: true,
184
- // Always false for pushState() or replaceState().
185
- userInitiated: false,
186
- hashChange,
187
- skipPopState: true,
188
- });
189
- }
190
- /** Equivalent to `navigation.traverseTo()`. */
191
- traverseTo(key, options) {
192
- const fromUrl = new URL(this.currentEntry.url);
193
- const entry = this.findEntry(key);
194
- if (!entry) {
195
- const domException = new DOMException('Invalid key', 'InvalidStateError');
196
- const committed = Promise.reject(domException);
197
- const finished = Promise.reject(domException);
198
- committed.catch(() => { });
199
- finished.catch(() => { });
200
- return {
201
- committed,
202
- finished,
203
- };
204
- }
205
- if (entry === this.currentEntry) {
206
- return {
207
- committed: Promise.resolve(this.currentEntry),
208
- finished: Promise.resolve(this.currentEntry),
209
- };
210
- }
211
- if (this.traversalQueue.has(entry.key)) {
212
- const existingResult = this.traversalQueue.get(entry.key);
213
- return {
214
- committed: existingResult.committed,
215
- finished: existingResult.finished,
216
- };
217
- }
218
- const hashChange = isHashChange(fromUrl, new URL(entry.url, this.currentEntry.url));
219
- const destination = new FakeNavigationDestination({
220
- url: entry.url,
221
- state: entry.getState(),
222
- historyState: entry.getHistoryState(),
223
- key: entry.key,
224
- id: entry.id,
225
- index: entry.index,
226
- sameDocument: entry.sameDocument,
227
- });
228
- this.prospectiveEntryIndex = entry.index;
229
- const result = new InternalNavigationResult();
230
- this.traversalQueue.set(entry.key, result);
231
- this.runTraversal(() => {
232
- this.traversalQueue.delete(entry.key);
233
- this.userAgentNavigate(destination, result, {
234
- navigationType: 'traverse',
235
- cancelable: true,
236
- canIntercept: true,
237
- // Always false for traverseTo().
238
- userInitiated: false,
239
- hashChange,
240
- info: options?.info,
241
- });
242
- });
243
- return {
244
- committed: result.committed,
245
- finished: result.finished,
246
- };
247
- }
248
- /** Equivalent to `navigation.back()`. */
249
- back(options) {
250
- if (this.currentEntryIndex === 0) {
251
- const domException = new DOMException('Cannot go back', 'InvalidStateError');
252
- const committed = Promise.reject(domException);
253
- const finished = Promise.reject(domException);
254
- committed.catch(() => { });
255
- finished.catch(() => { });
256
- return {
257
- committed,
258
- finished,
259
- };
260
- }
261
- const entry = this.entriesArr[this.currentEntryIndex - 1];
262
- return this.traverseTo(entry.key, options);
263
- }
264
- /** Equivalent to `navigation.forward()`. */
265
- forward(options) {
266
- if (this.currentEntryIndex === this.entriesArr.length - 1) {
267
- const domException = new DOMException('Cannot go forward', 'InvalidStateError');
268
- const committed = Promise.reject(domException);
269
- const finished = Promise.reject(domException);
270
- committed.catch(() => { });
271
- finished.catch(() => { });
272
- return {
273
- committed,
274
- finished,
275
- };
276
- }
277
- const entry = this.entriesArr[this.currentEntryIndex + 1];
278
- return this.traverseTo(entry.key, options);
279
- }
280
- /**
281
- * Equivalent to `history.go()`.
282
- * Note that this method does not actually work precisely to how Chrome
283
- * does, instead choosing a simpler model with less unexpected behavior.
284
- * Chrome has a few edge case optimizations, for instance with repeated
285
- * `back(); forward()` chains it collapses certain traversals.
286
- */
287
- go(direction) {
288
- const targetIndex = this.prospectiveEntryIndex + direction;
289
- if (targetIndex >= this.entriesArr.length || targetIndex < 0) {
290
- return;
291
- }
292
- this.prospectiveEntryIndex = targetIndex;
293
- this.runTraversal(() => {
294
- // Check again that destination is in the entries array.
295
- if (targetIndex >= this.entriesArr.length || targetIndex < 0) {
296
- return;
297
- }
298
- const fromUrl = new URL(this.currentEntry.url);
299
- const entry = this.entriesArr[targetIndex];
300
- const hashChange = isHashChange(fromUrl, new URL(entry.url, this.currentEntry.url));
301
- const destination = new FakeNavigationDestination({
302
- url: entry.url,
303
- state: entry.getState(),
304
- historyState: entry.getHistoryState(),
305
- key: entry.key,
306
- id: entry.id,
307
- index: entry.index,
308
- sameDocument: entry.sameDocument,
309
- });
310
- const result = new InternalNavigationResult();
311
- this.userAgentNavigate(destination, result, {
312
- navigationType: 'traverse',
313
- cancelable: true,
314
- canIntercept: true,
315
- // Always false for go().
316
- userInitiated: false,
317
- hashChange,
318
- });
319
- });
320
- }
321
- /** Runs a traversal synchronously or asynchronously */
322
- runTraversal(traversal) {
323
- if (this.synchronousTraversals) {
324
- traversal();
325
- return;
326
- }
327
- // Each traversal occupies a single timeout resolution.
328
- // This means that Promises added to commit and finish should resolve
329
- // before the next traversal.
330
- this.nextTraversal = this.nextTraversal.then(() => {
331
- return new Promise((resolve) => {
332
- setTimeout(() => {
333
- resolve();
334
- traversal();
335
- });
336
- });
337
- });
338
- }
339
- /** Equivalent to `navigation.addEventListener()`. */
340
- addEventListener(type, callback, options) {
341
- this.eventTarget.addEventListener(type, callback, options);
342
- }
343
- /** Equivalent to `navigation.removeEventListener()`. */
344
- removeEventListener(type, callback, options) {
345
- this.eventTarget.removeEventListener(type, callback, options);
346
- }
347
- /** Equivalent to `navigation.dispatchEvent()` */
348
- dispatchEvent(event) {
349
- return this.eventTarget.dispatchEvent(event);
350
- }
351
- /** Cleans up resources. */
352
- dispose() {
353
- // Recreate eventTarget to release current listeners.
354
- // `document.createElement` because NodeJS `EventTarget` is incompatible with Domino's `Event`.
355
- this.eventTarget = this.window.document.createElement('div');
356
- this.disposed = true;
357
- }
358
- /** Returns whether this fake is disposed. */
359
- isDisposed() {
360
- return this.disposed;
361
- }
362
- /** Implementation for all navigations and traversals. */
363
- userAgentNavigate(destination, result, options) {
364
- // The first navigation should disallow any future calls to set the initial
365
- // entry.
366
- this.canSetInitialEntry = false;
367
- if (this.navigateEvent) {
368
- this.navigateEvent.cancel(new DOMException('Navigation was aborted', 'AbortError'));
369
- this.navigateEvent = undefined;
370
- }
371
- const navigateEvent = createFakeNavigateEvent({
372
- navigationType: options.navigationType,
373
- cancelable: options.cancelable,
374
- canIntercept: options.canIntercept,
375
- userInitiated: options.userInitiated,
376
- hashChange: options.hashChange,
377
- signal: result.signal,
378
- destination,
379
- info: options.info,
380
- sameDocument: destination.sameDocument,
381
- skipPopState: options.skipPopState,
382
- result,
383
- userAgentCommit: () => {
384
- this.userAgentCommit();
385
- },
386
- });
387
- this.navigateEvent = navigateEvent;
388
- this.eventTarget.dispatchEvent(navigateEvent);
389
- navigateEvent.dispatchedNavigateEvent();
390
- if (navigateEvent.commitOption === 'immediate') {
391
- navigateEvent.commit(/* internal= */ true);
392
- }
393
- }
394
- /** Implementation to commit a navigation. */
395
- userAgentCommit() {
396
- if (!this.navigateEvent) {
397
- return;
398
- }
399
- const from = this.currentEntry;
400
- if (!this.navigateEvent.sameDocument) {
401
- const error = new Error('Cannot navigate to a non-same-document URL.');
402
- this.navigateEvent.cancel(error);
403
- throw error;
404
- }
405
- if (this.navigateEvent.navigationType === 'push' ||
406
- this.navigateEvent.navigationType === 'replace') {
407
- this.userAgentPushOrReplace(this.navigateEvent.destination, {
408
- navigationType: this.navigateEvent.navigationType,
409
- });
410
- }
411
- else if (this.navigateEvent.navigationType === 'traverse') {
412
- this.userAgentTraverse(this.navigateEvent.destination);
413
- }
414
- this.navigateEvent.userAgentNavigated(this.currentEntry);
415
- const currentEntryChangeEvent = createFakeNavigationCurrentEntryChangeEvent({
416
- from,
417
- navigationType: this.navigateEvent.navigationType,
418
- });
419
- this.eventTarget.dispatchEvent(currentEntryChangeEvent);
420
- if (!this.navigateEvent.skipPopState) {
421
- const popStateEvent = createPopStateEvent({
422
- state: this.navigateEvent.destination.getHistoryState(),
423
- });
424
- this.window.dispatchEvent(popStateEvent);
425
- }
426
- }
427
- /** Implementation for a push or replace navigation. */
428
- userAgentPushOrReplace(destination, { navigationType }) {
429
- if (navigationType === 'push') {
430
- this.currentEntryIndex++;
431
- this.prospectiveEntryIndex = this.currentEntryIndex;
432
- }
433
- const index = this.currentEntryIndex;
434
- const key = navigationType === 'push' ? String(this.nextKey++) : this.currentEntry.key;
435
- const entry = new FakeNavigationHistoryEntry(destination.url, {
436
- id: String(this.nextId++),
437
- key,
438
- index,
439
- sameDocument: true,
440
- state: destination.getState(),
441
- historyState: destination.getHistoryState(),
442
- });
443
- if (navigationType === 'push') {
444
- this.entriesArr.splice(index, Infinity, entry);
445
- }
446
- else {
447
- this.entriesArr[index] = entry;
448
- }
449
- }
450
- /** Implementation for a traverse navigation. */
451
- userAgentTraverse(destination) {
452
- this.currentEntryIndex = destination.index;
453
- }
454
- /** Utility method for finding entries with the given `key`. */
455
- findEntry(key) {
456
- for (const entry of this.entriesArr) {
457
- if (entry.key === key)
458
- return entry;
459
- }
460
- return undefined;
461
- }
462
- set onnavigate(_handler) {
463
- throw new Error('unimplemented');
464
- }
465
- get onnavigate() {
466
- throw new Error('unimplemented');
467
- }
468
- set oncurrententrychange(_handler) {
469
- throw new Error('unimplemented');
470
- }
471
- get oncurrententrychange() {
472
- throw new Error('unimplemented');
473
- }
474
- set onnavigatesuccess(_handler) {
475
- throw new Error('unimplemented');
476
- }
477
- get onnavigatesuccess() {
478
- throw new Error('unimplemented');
479
- }
480
- set onnavigateerror(_handler) {
481
- throw new Error('unimplemented');
482
- }
483
- get onnavigateerror() {
484
- throw new Error('unimplemented');
485
- }
486
- get transition() {
487
- throw new Error('unimplemented');
488
- }
489
- updateCurrentEntry(_options) {
490
- throw new Error('unimplemented');
491
- }
492
- reload(_options) {
493
- throw new Error('unimplemented');
494
- }
495
- }
496
- /**
497
- * Fake equivalent of `NavigationHistoryEntry`.
498
- */
499
- class FakeNavigationHistoryEntry {
500
- url;
501
- sameDocument;
502
- id;
503
- key;
504
- index;
505
- state;
506
- historyState;
507
- ondispose = null;
508
- constructor(url, { id, key, index, sameDocument, state, historyState, }) {
509
- this.url = url;
510
- this.id = id;
511
- this.key = key;
512
- this.index = index;
513
- this.sameDocument = sameDocument;
514
- this.state = state;
515
- this.historyState = historyState;
516
- }
517
- getState() {
518
- // Budget copy.
519
- return this.state ? JSON.parse(JSON.stringify(this.state)) : this.state;
520
- }
521
- getHistoryState() {
522
- // Budget copy.
523
- return this.historyState ? JSON.parse(JSON.stringify(this.historyState)) : this.historyState;
524
- }
525
- addEventListener(type, callback, options) {
526
- throw new Error('unimplemented');
527
- }
528
- removeEventListener(type, callback, options) {
529
- throw new Error('unimplemented');
530
- }
531
- dispatchEvent(event) {
532
- throw new Error('unimplemented');
533
- }
534
- }
535
- /**
536
- * Create a fake equivalent of `NavigateEvent`. This is not a class because ES5
537
- * transpiled JavaScript cannot extend native Event.
538
- */
539
- function createFakeNavigateEvent({ cancelable, canIntercept, userInitiated, hashChange, navigationType, signal, destination, info, sameDocument, skipPopState, result, userAgentCommit, }) {
540
- const event = new Event('navigate', { bubbles: false, cancelable });
541
- event.canIntercept = canIntercept;
542
- event.userInitiated = userInitiated;
543
- event.hashChange = hashChange;
544
- event.navigationType = navigationType;
545
- event.signal = signal;
546
- event.destination = destination;
547
- event.info = info;
548
- event.downloadRequest = null;
549
- event.formData = null;
550
- event.sameDocument = sameDocument;
551
- event.skipPopState = skipPopState;
552
- event.commitOption = 'immediate';
553
- let handlerFinished = undefined;
554
- let interceptCalled = false;
555
- let dispatchedNavigateEvent = false;
556
- let commitCalled = false;
557
- event.intercept = function (options) {
558
- interceptCalled = true;
559
- event.sameDocument = true;
560
- const handler = options?.handler;
561
- if (handler) {
562
- handlerFinished = handler();
563
- }
564
- if (options?.commit) {
565
- event.commitOption = options.commit;
566
- }
567
- if (options?.focusReset !== undefined || options?.scroll !== undefined) {
568
- throw new Error('unimplemented');
569
- }
570
- };
571
- event.scroll = function () {
572
- throw new Error('unimplemented');
573
- };
574
- event.commit = function (internal = false) {
575
- if (!internal && !interceptCalled) {
576
- throw new DOMException(`Failed to execute 'commit' on 'NavigateEvent': intercept() must be ` +
577
- `called before commit().`, 'InvalidStateError');
578
- }
579
- if (!dispatchedNavigateEvent) {
580
- throw new DOMException(`Failed to execute 'commit' on 'NavigateEvent': commit() may not be ` +
581
- `called during event dispatch.`, 'InvalidStateError');
582
- }
583
- if (commitCalled) {
584
- throw new DOMException(`Failed to execute 'commit' on 'NavigateEvent': commit() already ` + `called.`, 'InvalidStateError');
585
- }
586
- commitCalled = true;
587
- userAgentCommit();
588
- };
589
- // Internal only.
590
- event.cancel = function (reason) {
591
- result.committedReject(reason);
592
- result.finishedReject(reason);
593
- };
594
- // Internal only.
595
- event.dispatchedNavigateEvent = function () {
596
- dispatchedNavigateEvent = true;
597
- if (event.commitOption === 'after-transition') {
598
- // If handler finishes before commit, call commit.
599
- handlerFinished?.then(() => {
600
- if (!commitCalled) {
601
- event.commit(/* internal */ true);
602
- }
603
- }, () => { });
604
- }
605
- Promise.all([result.committed, handlerFinished]).then(([entry]) => {
606
- result.finishedResolve(entry);
607
- }, (reason) => {
608
- result.finishedReject(reason);
609
- });
610
- };
611
- // Internal only.
612
- event.userAgentNavigated = function (entry) {
613
- result.committedResolve(entry);
614
- };
615
- return event;
616
- }
617
- /**
618
- * Create a fake equivalent of `NavigationCurrentEntryChange`. This does not use
619
- * a class because ES5 transpiled JavaScript cannot extend native Event.
620
- */
621
- function createFakeNavigationCurrentEntryChangeEvent({ from, navigationType, }) {
622
- const event = new Event('currententrychange', {
623
- bubbles: false,
624
- cancelable: false,
625
- });
626
- event.from = from;
627
- event.navigationType = navigationType;
628
- return event;
629
- }
630
- /**
631
- * Create a fake equivalent of `PopStateEvent`. This does not use a class
632
- * because ES5 transpiled JavaScript cannot extend native Event.
633
- */
634
- function createPopStateEvent({ state }) {
635
- const event = new Event('popstate', {
636
- bubbles: false,
637
- cancelable: false,
638
- });
639
- event.state = state;
640
- return event;
641
- }
642
- /**
643
- * Fake equivalent of `NavigationDestination`.
644
- */
645
- class FakeNavigationDestination {
646
- url;
647
- sameDocument;
648
- key;
649
- id;
650
- index;
651
- state;
652
- historyState;
653
- constructor({ url, sameDocument, historyState, state, key = null, id = null, index = -1, }) {
654
- this.url = url;
655
- this.sameDocument = sameDocument;
656
- this.state = state;
657
- this.historyState = historyState;
658
- this.key = key;
659
- this.id = id;
660
- this.index = index;
661
- }
662
- getState() {
663
- return this.state;
664
- }
665
- getHistoryState() {
666
- return this.historyState;
667
- }
668
- }
669
- /** Utility function to determine whether two UrlLike have the same hash. */
670
- function isHashChange(from, to) {
671
- return (to.hash !== from.hash &&
672
- to.hostname === from.hostname &&
673
- to.pathname === from.pathname &&
674
- to.search === from.search);
675
- }
676
- /** Internal utility class for representing the result of a navigation. */
677
- class InternalNavigationResult {
678
- committedResolve;
679
- committedReject;
680
- finishedResolve;
681
- finishedReject;
682
- committed;
683
- finished;
684
- get signal() {
685
- return this.abortController.signal;
686
- }
687
- abortController = new AbortController();
688
- constructor() {
689
- this.committed = new Promise((resolve, reject) => {
690
- this.committedResolve = resolve;
691
- this.committedReject = reject;
692
- });
693
- this.finished = new Promise(async (resolve, reject) => {
694
- this.finishedResolve = resolve;
695
- this.finishedReject = (reason) => {
696
- reject(reason);
697
- this.abortController.abort(reason);
698
- };
699
- });
700
- // All rejections are handled.
701
- this.committed.catch(() => { });
702
- this.finished.catch(() => { });
703
- }
704
- }
11
+ import { ɵFakeNavigation } from '@angular/core/testing';
12
+ export { ɵFakeNavigation } from '@angular/core/testing';
705
13
 
706
14
  /**
707
15
  * Parser from https://tools.ietf.org/html/rfc3986#appendix-B
@@ -909,10 +217,10 @@ class MockPlatformLocation {
909
217
  });
910
218
  }
911
219
  }
912
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: MockPlatformLocation, deps: [{ token: MOCK_PLATFORM_LOCATION_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
913
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: MockPlatformLocation });
220
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.0", ngImport: i0, type: MockPlatformLocation, deps: [{ token: MOCK_PLATFORM_LOCATION_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
221
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0-next.0", ngImport: i0, type: MockPlatformLocation });
914
222
  }
915
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: MockPlatformLocation, decorators: [{
223
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.0", ngImport: i0, type: MockPlatformLocation, decorators: [{
916
224
  type: Injectable
917
225
  }], ctorParameters: () => [{ type: undefined, decorators: [{
918
226
  type: Inject,
@@ -927,7 +235,7 @@ class FakeNavigationPlatformLocation {
927
235
  _platformNavigation = inject(ɵPlatformNavigation);
928
236
  window = inject(DOCUMENT).defaultView;
929
237
  constructor() {
930
- if (!(this._platformNavigation instanceof FakeNavigation)) {
238
+ if (!(this._platformNavigation instanceof ɵFakeNavigation)) {
931
239
  throw new Error('FakePlatformNavigation cannot be used without FakeNavigation. Use ' +
932
240
  '`provideFakeNavigation` to have all these services provided together.');
933
241
  }
@@ -983,10 +291,10 @@ class FakeNavigationPlatformLocation {
983
291
  getState() {
984
292
  return this._platformNavigation.currentEntry.getHistoryState();
985
293
  }
986
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: FakeNavigationPlatformLocation, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
987
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: FakeNavigationPlatformLocation });
294
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.0", ngImport: i0, type: FakeNavigationPlatformLocation, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
295
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0-next.0", ngImport: i0, type: FakeNavigationPlatformLocation });
988
296
  }
989
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: FakeNavigationPlatformLocation, decorators: [{
297
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.0", ngImport: i0, type: FakeNavigationPlatformLocation, decorators: [{
990
298
  type: Injectable
991
299
  }], ctorParameters: () => [] });
992
300
 
@@ -996,10 +304,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0-rc.0", ng
996
304
  function provideFakePlatformNavigation() {
997
305
  return [
998
306
  {
999
- provide: PlatformNavigation,
307
+ provide: ɵPlatformNavigation,
1000
308
  useFactory: () => {
1001
309
  const config = inject(MOCK_PLATFORM_LOCATION_CONFIG, { optional: true });
1002
- return new FakeNavigation(inject(DOCUMENT).defaultView, config?.startUrl ?? 'http://_empty_/');
310
+ return new ɵFakeNavigation(inject(DOCUMENT).defaultView, config?.startUrl ?? 'http://_empty_/');
1003
311
  },
1004
312
  },
1005
313
  { provide: PlatformLocation, useClass: FakeNavigationPlatformLocation },
@@ -1160,10 +468,10 @@ class SpyLocation {
1160
468
  this._history.push(new LocationState(path, query, state));
1161
469
  this._historyIndex = this._history.length - 1;
1162
470
  }
1163
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: SpyLocation, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1164
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: SpyLocation });
471
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.0", ngImport: i0, type: SpyLocation, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
472
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0-next.0", ngImport: i0, type: SpyLocation });
1165
473
  }
1166
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: SpyLocation, decorators: [{
474
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.0", ngImport: i0, type: SpyLocation, decorators: [{
1167
475
  type: Injectable
1168
476
  }] });
1169
477
  class LocationState {
@@ -1245,10 +553,10 @@ class MockLocationStrategy extends LocationStrategy {
1245
553
  getState() {
1246
554
  return this.stateChanges[(this.stateChanges.length || 1) - 1];
1247
555
  }
1248
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: MockLocationStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1249
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: MockLocationStrategy });
556
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.0", ngImport: i0, type: MockLocationStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
557
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0-next.0", ngImport: i0, type: MockLocationStrategy });
1250
558
  }
1251
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0-rc.0", ngImport: i0, type: MockLocationStrategy, decorators: [{
559
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.0", ngImport: i0, type: MockLocationStrategy, decorators: [{
1252
560
  type: Injectable
1253
561
  }], ctorParameters: () => [] });
1254
562
  class _MockPopStateEvent {