@angular/common 19.0.0-next.9 → 19.0.0-rc.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.
- package/fesm2022/common.mjs +382 -272
- package/fesm2022/common.mjs.map +1 -1
- package/fesm2022/http/testing.mjs +18 -18
- package/fesm2022/http/testing.mjs.map +1 -1
- package/fesm2022/http.mjs +194 -108
- package/fesm2022/http.mjs.map +1 -1
- package/fesm2022/testing.mjs +117 -93
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/upgrade.mjs +33 -20
- package/fesm2022/upgrade.mjs.map +1 -1
- package/http/index.d.ts +2 -2
- package/http/testing/index.d.ts +1 -1
- package/index.d.ts +42 -8
- package/package.json +2 -2
- package/testing/index.d.ts +1 -1
- package/upgrade/index.d.ts +1 -1
package/fesm2022/testing.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v19.0.0-
|
|
2
|
+
* @license Angular v19.0.0-rc.0
|
|
3
3
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -14,10 +14,10 @@ import { Subject } from 'rxjs';
|
|
|
14
14
|
* implementations.
|
|
15
15
|
*/
|
|
16
16
|
class PlatformNavigation {
|
|
17
|
-
static
|
|
18
|
-
static
|
|
17
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: PlatformNavigation, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
18
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: PlatformNavigation, providedIn: 'platform', useFactory: () => window.navigation });
|
|
19
19
|
}
|
|
20
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-
|
|
20
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: PlatformNavigation, decorators: [{
|
|
21
21
|
type: Injectable,
|
|
22
22
|
args: [{ providedIn: 'platform', useFactory: () => window.navigation }]
|
|
23
23
|
}] });
|
|
@@ -28,6 +28,50 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-next.9",
|
|
|
28
28
|
* things like traversal delay.
|
|
29
29
|
*/
|
|
30
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;
|
|
31
75
|
/** Equivalent to `navigation.currentEntry`. */
|
|
32
76
|
get currentEntry() {
|
|
33
77
|
return this.entriesArr[this.currentEntryIndex];
|
|
@@ -40,49 +84,7 @@ class FakeNavigation {
|
|
|
40
84
|
}
|
|
41
85
|
constructor(window, startURL) {
|
|
42
86
|
this.window = window;
|
|
43
|
-
/**
|
|
44
|
-
* The fake implementation of an entries array. Only same-document entries
|
|
45
|
-
* allowed.
|
|
46
|
-
*/
|
|
47
|
-
this.entriesArr = [];
|
|
48
|
-
/**
|
|
49
|
-
* The current active entry index into `entriesArr`.
|
|
50
|
-
*/
|
|
51
|
-
this.currentEntryIndex = 0;
|
|
52
|
-
/**
|
|
53
|
-
* The current navigate event.
|
|
54
|
-
*/
|
|
55
|
-
this.navigateEvent = undefined;
|
|
56
|
-
/**
|
|
57
|
-
* A Map of pending traversals, so that traversals to the same entry can be
|
|
58
|
-
* re-used.
|
|
59
|
-
*/
|
|
60
|
-
this.traversalQueue = new Map();
|
|
61
|
-
/**
|
|
62
|
-
* A Promise that resolves when the previous traversals have finished. Used to
|
|
63
|
-
* simulate the cross-process communication necessary for traversals.
|
|
64
|
-
*/
|
|
65
|
-
this.nextTraversal = Promise.resolve();
|
|
66
|
-
/**
|
|
67
|
-
* A prospective current active entry index, which includes unresolved
|
|
68
|
-
* traversals. Used by `go` to determine where navigations are intended to go.
|
|
69
|
-
*/
|
|
70
|
-
this.prospectiveEntryIndex = 0;
|
|
71
|
-
/**
|
|
72
|
-
* A test-only option to make traversals synchronous, rather than emulate
|
|
73
|
-
* cross-process communication.
|
|
74
|
-
*/
|
|
75
|
-
this.synchronousTraversals = false;
|
|
76
|
-
/** Whether to allow a call to setInitialEntryForTesting. */
|
|
77
|
-
this.canSetInitialEntry = true;
|
|
78
|
-
/** `EventTarget` to dispatch events. */
|
|
79
87
|
this.eventTarget = this.window.document.createElement('div');
|
|
80
|
-
/** The next unique id for created entries. Replace recreates this id. */
|
|
81
|
-
this.nextId = 0;
|
|
82
|
-
/** The next unique key for created entries. Replace inherits this id. */
|
|
83
|
-
this.nextKey = 0;
|
|
84
|
-
/** Whether this fake is disposed. */
|
|
85
|
-
this.disposed = false;
|
|
86
88
|
// First entry.
|
|
87
89
|
this.setInitialEntryForTesting(startURL);
|
|
88
90
|
}
|
|
@@ -495,10 +497,17 @@ class FakeNavigation {
|
|
|
495
497
|
* Fake equivalent of `NavigationHistoryEntry`.
|
|
496
498
|
*/
|
|
497
499
|
class FakeNavigationHistoryEntry {
|
|
500
|
+
url;
|
|
501
|
+
sameDocument;
|
|
502
|
+
id;
|
|
503
|
+
key;
|
|
504
|
+
index;
|
|
505
|
+
state;
|
|
506
|
+
historyState;
|
|
507
|
+
// tslint:disable-next-line:no-any
|
|
508
|
+
ondispose = null;
|
|
498
509
|
constructor(url, { id, key, index, sameDocument, state, historyState, }) {
|
|
499
510
|
this.url = url;
|
|
500
|
-
// tslint:disable-next-line:no-any
|
|
501
|
-
this.ondispose = null;
|
|
502
511
|
this.id = id;
|
|
503
512
|
this.key = key;
|
|
504
513
|
this.index = index;
|
|
@@ -635,6 +644,13 @@ function createPopStateEvent({ state }) {
|
|
|
635
644
|
* Fake equivalent of `NavigationDestination`.
|
|
636
645
|
*/
|
|
637
646
|
class FakeNavigationDestination {
|
|
647
|
+
url;
|
|
648
|
+
sameDocument;
|
|
649
|
+
key;
|
|
650
|
+
id;
|
|
651
|
+
index;
|
|
652
|
+
state;
|
|
653
|
+
historyState;
|
|
638
654
|
constructor({ url, sameDocument, historyState, state, key = null, id = null, index = -1, }) {
|
|
639
655
|
this.url = url;
|
|
640
656
|
this.sameDocument = sameDocument;
|
|
@@ -660,11 +676,17 @@ function isHashChange(from, to) {
|
|
|
660
676
|
}
|
|
661
677
|
/** Internal utility class for representing the result of a navigation. */
|
|
662
678
|
class InternalNavigationResult {
|
|
679
|
+
committedResolve;
|
|
680
|
+
committedReject;
|
|
681
|
+
finishedResolve;
|
|
682
|
+
finishedReject;
|
|
683
|
+
committed;
|
|
684
|
+
finished;
|
|
663
685
|
get signal() {
|
|
664
686
|
return this.abortController.signal;
|
|
665
687
|
}
|
|
688
|
+
abortController = new AbortController();
|
|
666
689
|
constructor() {
|
|
667
|
-
this.abortController = new AbortController();
|
|
668
690
|
this.committed = new Promise((resolve, reject) => {
|
|
669
691
|
this.committedResolve = resolve;
|
|
670
692
|
this.committedReject = reject;
|
|
@@ -753,12 +775,12 @@ const MOCK_PLATFORM_LOCATION_CONFIG = new InjectionToken('MOCK_PLATFORM_LOCATION
|
|
|
753
775
|
* @publicApi
|
|
754
776
|
*/
|
|
755
777
|
class MockPlatformLocation {
|
|
778
|
+
baseHref = '';
|
|
779
|
+
hashUpdate = new Subject();
|
|
780
|
+
popStateSubject = new Subject();
|
|
781
|
+
urlChangeIndex = 0;
|
|
782
|
+
urlChanges = [{ hostname: '', protocol: '', port: '', pathname: '/', search: '', hash: '', state: null }];
|
|
756
783
|
constructor(config) {
|
|
757
|
-
this.baseHref = '';
|
|
758
|
-
this.hashUpdate = new Subject();
|
|
759
|
-
this.popStateSubject = new Subject();
|
|
760
|
-
this.urlChangeIndex = 0;
|
|
761
|
-
this.urlChanges = [{ hostname: '', protocol: '', port: '', pathname: '/', search: '', hash: '', state: null }];
|
|
762
784
|
if (config) {
|
|
763
785
|
this.baseHref = config.appBaseHref || '';
|
|
764
786
|
const parsedChanges = this.parseChanges(null, config.startUrl || 'http://_empty_/', this.baseHref);
|
|
@@ -888,10 +910,10 @@ class MockPlatformLocation {
|
|
|
888
910
|
});
|
|
889
911
|
}
|
|
890
912
|
}
|
|
891
|
-
static
|
|
892
|
-
static
|
|
913
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: MockPlatformLocation, deps: [{ token: MOCK_PLATFORM_LOCATION_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
914
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: MockPlatformLocation });
|
|
893
915
|
}
|
|
894
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-
|
|
916
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: MockPlatformLocation, decorators: [{
|
|
895
917
|
type: Injectable
|
|
896
918
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
897
919
|
type: Inject,
|
|
@@ -903,15 +925,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-next.9",
|
|
|
903
925
|
* Mock implementation of URL state.
|
|
904
926
|
*/
|
|
905
927
|
class FakeNavigationPlatformLocation {
|
|
928
|
+
_platformNavigation = inject(ɵPlatformNavigation);
|
|
929
|
+
window = inject(DOCUMENT).defaultView;
|
|
906
930
|
constructor() {
|
|
907
|
-
this._platformNavigation = inject(ɵPlatformNavigation);
|
|
908
|
-
this.window = inject(DOCUMENT).defaultView;
|
|
909
|
-
this.config = inject(MOCK_PLATFORM_LOCATION_CONFIG, { optional: true });
|
|
910
931
|
if (!(this._platformNavigation instanceof FakeNavigation)) {
|
|
911
932
|
throw new Error('FakePlatformNavigation cannot be used without FakeNavigation. Use ' +
|
|
912
933
|
'`provideFakeNavigation` to have all these services provided together.');
|
|
913
934
|
}
|
|
914
935
|
}
|
|
936
|
+
config = inject(MOCK_PLATFORM_LOCATION_CONFIG, { optional: true });
|
|
915
937
|
getBaseHrefFromDOM() {
|
|
916
938
|
return this.config?.appBaseHref ?? '';
|
|
917
939
|
}
|
|
@@ -962,10 +984,10 @@ class FakeNavigationPlatformLocation {
|
|
|
962
984
|
getState() {
|
|
963
985
|
return this._platformNavigation.currentEntry.getHistoryState();
|
|
964
986
|
}
|
|
965
|
-
static
|
|
966
|
-
static
|
|
987
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: FakeNavigationPlatformLocation, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
988
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: FakeNavigationPlatformLocation });
|
|
967
989
|
}
|
|
968
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-
|
|
990
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: FakeNavigationPlatformLocation, decorators: [{
|
|
969
991
|
type: Injectable
|
|
970
992
|
}], ctorParameters: () => [] });
|
|
971
993
|
|
|
@@ -991,21 +1013,19 @@ function provideFakePlatformNavigation() {
|
|
|
991
1013
|
* @publicApi
|
|
992
1014
|
*/
|
|
993
1015
|
class SpyLocation {
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
this._urlChangeSubscription = null;
|
|
1008
|
-
}
|
|
1016
|
+
urlChanges = [];
|
|
1017
|
+
_history = [new LocationState('', '', null)];
|
|
1018
|
+
_historyIndex = 0;
|
|
1019
|
+
/** @internal */
|
|
1020
|
+
_subject = new Subject();
|
|
1021
|
+
/** @internal */
|
|
1022
|
+
_basePath = '';
|
|
1023
|
+
/** @internal */
|
|
1024
|
+
_locationStrategy = null;
|
|
1025
|
+
/** @internal */
|
|
1026
|
+
_urlChangeListeners = [];
|
|
1027
|
+
/** @internal */
|
|
1028
|
+
_urlChangeSubscription = null;
|
|
1009
1029
|
/** @nodoc */
|
|
1010
1030
|
ngOnDestroy() {
|
|
1011
1031
|
this._urlChangeSubscription?.unsubscribe();
|
|
@@ -1141,13 +1161,16 @@ class SpyLocation {
|
|
|
1141
1161
|
this._history.push(new LocationState(path, query, state));
|
|
1142
1162
|
this._historyIndex = this._history.length - 1;
|
|
1143
1163
|
}
|
|
1144
|
-
static
|
|
1145
|
-
static
|
|
1164
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: SpyLocation, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1165
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: SpyLocation });
|
|
1146
1166
|
}
|
|
1147
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-
|
|
1167
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: SpyLocation, decorators: [{
|
|
1148
1168
|
type: Injectable
|
|
1149
1169
|
}] });
|
|
1150
1170
|
class LocationState {
|
|
1171
|
+
path;
|
|
1172
|
+
query;
|
|
1173
|
+
state;
|
|
1151
1174
|
constructor(path, query, state) {
|
|
1152
1175
|
this.path = path;
|
|
1153
1176
|
this.query = query;
|
|
@@ -1162,15 +1185,15 @@ class LocationState {
|
|
|
1162
1185
|
* @publicApi
|
|
1163
1186
|
*/
|
|
1164
1187
|
class MockLocationStrategy extends LocationStrategy {
|
|
1188
|
+
internalBaseHref = '/';
|
|
1189
|
+
internalPath = '/';
|
|
1190
|
+
internalTitle = '';
|
|
1191
|
+
urlChanges = [];
|
|
1192
|
+
/** @internal */
|
|
1193
|
+
_subject = new Subject();
|
|
1194
|
+
stateChanges = [];
|
|
1165
1195
|
constructor() {
|
|
1166
1196
|
super();
|
|
1167
|
-
this.internalBaseHref = '/';
|
|
1168
|
-
this.internalPath = '/';
|
|
1169
|
-
this.internalTitle = '';
|
|
1170
|
-
this.urlChanges = [];
|
|
1171
|
-
/** @internal */
|
|
1172
|
-
this._subject = new Subject();
|
|
1173
|
-
this.stateChanges = [];
|
|
1174
1197
|
}
|
|
1175
1198
|
simulatePopState(url) {
|
|
1176
1199
|
this.internalPath = url;
|
|
@@ -1223,17 +1246,18 @@ class MockLocationStrategy extends LocationStrategy {
|
|
|
1223
1246
|
getState() {
|
|
1224
1247
|
return this.stateChanges[(this.stateChanges.length || 1) - 1];
|
|
1225
1248
|
}
|
|
1226
|
-
static
|
|
1227
|
-
static
|
|
1249
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: MockLocationStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1250
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: MockLocationStrategy });
|
|
1228
1251
|
}
|
|
1229
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-
|
|
1252
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: MockLocationStrategy, decorators: [{
|
|
1230
1253
|
type: Injectable
|
|
1231
1254
|
}], ctorParameters: () => [] });
|
|
1232
1255
|
class _MockPopStateEvent {
|
|
1256
|
+
newUrl;
|
|
1257
|
+
pop = true;
|
|
1258
|
+
type = 'popstate';
|
|
1233
1259
|
constructor(newUrl) {
|
|
1234
1260
|
this.newUrl = newUrl;
|
|
1235
|
-
this.pop = true;
|
|
1236
|
-
this.type = 'popstate';
|
|
1237
1261
|
}
|
|
1238
1262
|
}
|
|
1239
1263
|
|