@ngxs/router-plugin 3.7.3 → 3.7.4-dev.master-327646e
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/README.md +4 -4
- package/bundles/ngxs-router-plugin.umd.js +854 -826
- package/bundles/ngxs-router-plugin.umd.js.map +1 -1
- package/bundles/ngxs-router-plugin.umd.min.js +2 -2
- package/bundles/ngxs-router-plugin.umd.min.js.map +1 -1
- package/esm2015/index.js +9 -9
- package/esm2015/ngxs-router-plugin.js +8 -8
- package/esm2015/src/public_api.js +9 -9
- package/esm2015/src/router.actions.js +172 -172
- package/esm2015/src/router.module.js +25 -25
- package/esm2015/src/router.state.js +463 -437
- package/esm2015/src/serializer.js +72 -72
- package/esm5/index.js +9 -9
- package/esm5/ngxs-router-plugin.js +8 -8
- package/esm5/src/public_api.js +9 -9
- package/esm5/src/router.actions.js +227 -227
- package/esm5/src/router.module.js +32 -32
- package/esm5/src/router.state.js +552 -523
- package/esm5/src/serializer.js +98 -98
- package/fesm2015/ngxs-router-plugin.js +715 -689
- package/fesm2015/ngxs-router-plugin.js.map +1 -1
- package/fesm5/ngxs-router-plugin.js +860 -831
- package/fesm5/ngxs-router-plugin.js.map +1 -1
- package/index.d.ts +4 -4
- package/ngxs-router-plugin.d.ts +5 -5
- package/ngxs-router-plugin.metadata.json +1 -1
- package/package.json +5 -5
- package/src/public_api.d.ts +4 -4
- package/src/router.actions.d.ts +63 -63
- package/src/router.module.d.ts +4 -4
- package/src/router.state.d.ts +60 -58
- package/src/serializer.d.ts +12 -12
|
@@ -4,709 +4,735 @@ import { __decorate, __metadata } from 'tslib';
|
|
|
4
4
|
import { NavigationStart, RoutesRecognized, ResolveEnd, NavigationCancel, NavigationError, NavigationEnd, Router, UrlSerializer } from '@angular/router';
|
|
5
5
|
import { LocationStrategy, Location } from '@angular/common';
|
|
6
6
|
import { isAngularInTestMode } from '@ngxs/store/internals';
|
|
7
|
+
import { Subscription } from 'rxjs';
|
|
7
8
|
import { first } from 'rxjs/operators';
|
|
8
9
|
|
|
9
|
-
/**
|
|
10
|
-
* @fileoverview added by tsickle
|
|
11
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Public event api of the router
|
|
15
|
-
*/
|
|
16
|
-
class Navigate {
|
|
17
|
-
/**
|
|
18
|
-
* @param {?} path
|
|
19
|
-
* @param {?=} queryParams
|
|
20
|
-
* @param {?=} extras
|
|
21
|
-
*/
|
|
22
|
-
constructor(path, queryParams, extras) {
|
|
23
|
-
this.path = path;
|
|
24
|
-
this.queryParams = queryParams;
|
|
25
|
-
this.extras = extras;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @return {?}
|
|
29
|
-
*/
|
|
30
|
-
static get type() {
|
|
31
|
-
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
32
|
-
return '[Router] Navigate';
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (false) {
|
|
36
|
-
/** @type {?} */
|
|
37
|
-
Navigate.prototype.path;
|
|
38
|
-
/** @type {?} */
|
|
39
|
-
Navigate.prototype.queryParams;
|
|
40
|
-
/** @type {?} */
|
|
41
|
-
Navigate.prototype.extras;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* Angular Routers internal state events
|
|
46
|
-
*
|
|
47
|
-
*/
|
|
48
|
-
/**
|
|
49
|
-
* An action dispatched when the router navigates.
|
|
50
|
-
* @template T
|
|
51
|
-
*/
|
|
52
|
-
class RouterNavigation {
|
|
53
|
-
/**
|
|
54
|
-
* @param {?} routerState
|
|
55
|
-
* @param {?} event
|
|
56
|
-
* @param {?=} trigger
|
|
57
|
-
*/
|
|
58
|
-
constructor(routerState, event, trigger = 'none') {
|
|
59
|
-
this.routerState = routerState;
|
|
60
|
-
this.event = event;
|
|
61
|
-
this.trigger = trigger;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* @return {?}
|
|
65
|
-
*/
|
|
66
|
-
static get type() {
|
|
67
|
-
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
68
|
-
return '[Router] RouterNavigation';
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (false) {
|
|
72
|
-
/** @type {?} */
|
|
73
|
-
RouterNavigation.prototype.routerState;
|
|
74
|
-
/** @type {?} */
|
|
75
|
-
RouterNavigation.prototype.event;
|
|
76
|
-
/** @type {?} */
|
|
77
|
-
RouterNavigation.prototype.trigger;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* An action dispatched when the router cancel navigation.
|
|
81
|
-
* @template T, V
|
|
82
|
-
*/
|
|
83
|
-
class RouterCancel {
|
|
84
|
-
/**
|
|
85
|
-
* @param {?} routerState
|
|
86
|
-
* @param {?} storeState
|
|
87
|
-
* @param {?} event
|
|
88
|
-
* @param {?=} trigger
|
|
89
|
-
*/
|
|
90
|
-
constructor(routerState, storeState, event, trigger = 'none') {
|
|
91
|
-
this.routerState = routerState;
|
|
92
|
-
this.storeState = storeState;
|
|
93
|
-
this.event = event;
|
|
94
|
-
this.trigger = trigger;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* @return {?}
|
|
98
|
-
*/
|
|
99
|
-
static get type() {
|
|
100
|
-
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
101
|
-
return '[Router] RouterCancel';
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (false) {
|
|
105
|
-
/** @type {?} */
|
|
106
|
-
RouterCancel.prototype.routerState;
|
|
107
|
-
/** @type {?} */
|
|
108
|
-
RouterCancel.prototype.storeState;
|
|
109
|
-
/** @type {?} */
|
|
110
|
-
RouterCancel.prototype.event;
|
|
111
|
-
/** @type {?} */
|
|
112
|
-
RouterCancel.prototype.trigger;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* An action dispatched when the router errors.
|
|
116
|
-
* @template T, V
|
|
117
|
-
*/
|
|
118
|
-
class RouterError {
|
|
119
|
-
/**
|
|
120
|
-
* @param {?} routerState
|
|
121
|
-
* @param {?} storeState
|
|
122
|
-
* @param {?} event
|
|
123
|
-
* @param {?=} trigger
|
|
124
|
-
*/
|
|
125
|
-
constructor(routerState, storeState, event, trigger = 'none') {
|
|
126
|
-
this.routerState = routerState;
|
|
127
|
-
this.storeState = storeState;
|
|
128
|
-
this.event = event;
|
|
129
|
-
this.trigger = trigger;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* @return {?}
|
|
133
|
-
*/
|
|
134
|
-
static get type() {
|
|
135
|
-
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
136
|
-
return '[Router] RouterError';
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if (false) {
|
|
140
|
-
/** @type {?} */
|
|
141
|
-
RouterError.prototype.routerState;
|
|
142
|
-
/** @type {?} */
|
|
143
|
-
RouterError.prototype.storeState;
|
|
144
|
-
/** @type {?} */
|
|
145
|
-
RouterError.prototype.event;
|
|
146
|
-
/** @type {?} */
|
|
147
|
-
RouterError.prototype.trigger;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* An action dispatched when the `ResolveEnd` event is triggered.
|
|
151
|
-
* @template T
|
|
152
|
-
*/
|
|
153
|
-
class RouterDataResolved {
|
|
154
|
-
/**
|
|
155
|
-
* @param {?} routerState
|
|
156
|
-
* @param {?} event
|
|
157
|
-
* @param {?=} trigger
|
|
158
|
-
*/
|
|
159
|
-
constructor(routerState, event, trigger = 'none') {
|
|
160
|
-
this.routerState = routerState;
|
|
161
|
-
this.event = event;
|
|
162
|
-
this.trigger = trigger;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* @return {?}
|
|
166
|
-
*/
|
|
167
|
-
static get type() {
|
|
168
|
-
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
169
|
-
return '[Router] RouterDataResolved';
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (false) {
|
|
173
|
-
/** @type {?} */
|
|
174
|
-
RouterDataResolved.prototype.routerState;
|
|
175
|
-
/** @type {?} */
|
|
176
|
-
RouterDataResolved.prototype.event;
|
|
177
|
-
/** @type {?} */
|
|
178
|
-
RouterDataResolved.prototype.trigger;
|
|
10
|
+
/**
|
|
11
|
+
* @fileoverview added by tsickle
|
|
12
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Public event api of the router
|
|
16
|
+
*/
|
|
17
|
+
class Navigate {
|
|
18
|
+
/**
|
|
19
|
+
* @param {?} path
|
|
20
|
+
* @param {?=} queryParams
|
|
21
|
+
* @param {?=} extras
|
|
22
|
+
*/
|
|
23
|
+
constructor(path, queryParams, extras) {
|
|
24
|
+
this.path = path;
|
|
25
|
+
this.queryParams = queryParams;
|
|
26
|
+
this.extras = extras;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @return {?}
|
|
30
|
+
*/
|
|
31
|
+
static get type() {
|
|
32
|
+
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
33
|
+
return '[Router] Navigate';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (false) {
|
|
37
|
+
/** @type {?} */
|
|
38
|
+
Navigate.prototype.path;
|
|
39
|
+
/** @type {?} */
|
|
40
|
+
Navigate.prototype.queryParams;
|
|
41
|
+
/** @type {?} */
|
|
42
|
+
Navigate.prototype.extras;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* Angular Routers internal state events
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
/**
|
|
50
|
+
* An action dispatched when the router navigates.
|
|
51
|
+
* @template T
|
|
52
|
+
*/
|
|
53
|
+
class RouterNavigation {
|
|
54
|
+
/**
|
|
55
|
+
* @param {?} routerState
|
|
56
|
+
* @param {?} event
|
|
57
|
+
* @param {?=} trigger
|
|
58
|
+
*/
|
|
59
|
+
constructor(routerState, event, trigger = 'none') {
|
|
60
|
+
this.routerState = routerState;
|
|
61
|
+
this.event = event;
|
|
62
|
+
this.trigger = trigger;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @return {?}
|
|
66
|
+
*/
|
|
67
|
+
static get type() {
|
|
68
|
+
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
69
|
+
return '[Router] RouterNavigation';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (false) {
|
|
73
|
+
/** @type {?} */
|
|
74
|
+
RouterNavigation.prototype.routerState;
|
|
75
|
+
/** @type {?} */
|
|
76
|
+
RouterNavigation.prototype.event;
|
|
77
|
+
/** @type {?} */
|
|
78
|
+
RouterNavigation.prototype.trigger;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* An action dispatched when the router cancel navigation.
|
|
82
|
+
* @template T, V
|
|
83
|
+
*/
|
|
84
|
+
class RouterCancel {
|
|
85
|
+
/**
|
|
86
|
+
* @param {?} routerState
|
|
87
|
+
* @param {?} storeState
|
|
88
|
+
* @param {?} event
|
|
89
|
+
* @param {?=} trigger
|
|
90
|
+
*/
|
|
91
|
+
constructor(routerState, storeState, event, trigger = 'none') {
|
|
92
|
+
this.routerState = routerState;
|
|
93
|
+
this.storeState = storeState;
|
|
94
|
+
this.event = event;
|
|
95
|
+
this.trigger = trigger;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @return {?}
|
|
99
|
+
*/
|
|
100
|
+
static get type() {
|
|
101
|
+
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
102
|
+
return '[Router] RouterCancel';
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (false) {
|
|
106
|
+
/** @type {?} */
|
|
107
|
+
RouterCancel.prototype.routerState;
|
|
108
|
+
/** @type {?} */
|
|
109
|
+
RouterCancel.prototype.storeState;
|
|
110
|
+
/** @type {?} */
|
|
111
|
+
RouterCancel.prototype.event;
|
|
112
|
+
/** @type {?} */
|
|
113
|
+
RouterCancel.prototype.trigger;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* An action dispatched when the router errors.
|
|
117
|
+
* @template T, V
|
|
118
|
+
*/
|
|
119
|
+
class RouterError {
|
|
120
|
+
/**
|
|
121
|
+
* @param {?} routerState
|
|
122
|
+
* @param {?} storeState
|
|
123
|
+
* @param {?} event
|
|
124
|
+
* @param {?=} trigger
|
|
125
|
+
*/
|
|
126
|
+
constructor(routerState, storeState, event, trigger = 'none') {
|
|
127
|
+
this.routerState = routerState;
|
|
128
|
+
this.storeState = storeState;
|
|
129
|
+
this.event = event;
|
|
130
|
+
this.trigger = trigger;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* @return {?}
|
|
134
|
+
*/
|
|
135
|
+
static get type() {
|
|
136
|
+
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
137
|
+
return '[Router] RouterError';
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (false) {
|
|
141
|
+
/** @type {?} */
|
|
142
|
+
RouterError.prototype.routerState;
|
|
143
|
+
/** @type {?} */
|
|
144
|
+
RouterError.prototype.storeState;
|
|
145
|
+
/** @type {?} */
|
|
146
|
+
RouterError.prototype.event;
|
|
147
|
+
/** @type {?} */
|
|
148
|
+
RouterError.prototype.trigger;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* An action dispatched when the `ResolveEnd` event is triggered.
|
|
152
|
+
* @template T
|
|
153
|
+
*/
|
|
154
|
+
class RouterDataResolved {
|
|
155
|
+
/**
|
|
156
|
+
* @param {?} routerState
|
|
157
|
+
* @param {?} event
|
|
158
|
+
* @param {?=} trigger
|
|
159
|
+
*/
|
|
160
|
+
constructor(routerState, event, trigger = 'none') {
|
|
161
|
+
this.routerState = routerState;
|
|
162
|
+
this.event = event;
|
|
163
|
+
this.trigger = trigger;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* @return {?}
|
|
167
|
+
*/
|
|
168
|
+
static get type() {
|
|
169
|
+
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
170
|
+
return '[Router] RouterDataResolved';
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (false) {
|
|
174
|
+
/** @type {?} */
|
|
175
|
+
RouterDataResolved.prototype.routerState;
|
|
176
|
+
/** @type {?} */
|
|
177
|
+
RouterDataResolved.prototype.event;
|
|
178
|
+
/** @type {?} */
|
|
179
|
+
RouterDataResolved.prototype.trigger;
|
|
179
180
|
}
|
|
180
181
|
|
|
181
|
-
/**
|
|
182
|
-
* @fileoverview added by tsickle
|
|
183
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
184
|
-
*/
|
|
185
|
-
/**
|
|
186
|
-
* @abstract
|
|
187
|
-
* @template T
|
|
188
|
-
*/
|
|
189
|
-
class RouterStateSerializer {
|
|
190
|
-
}
|
|
191
|
-
if (false) {
|
|
192
|
-
/**
|
|
193
|
-
* @abstract
|
|
194
|
-
* @param {?} routerState
|
|
195
|
-
* @return {?}
|
|
196
|
-
*/
|
|
197
|
-
RouterStateSerializer.prototype.serialize = function (routerState) { };
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* @record
|
|
201
|
-
*/
|
|
202
|
-
function SerializedRouterStateSnapshot() { }
|
|
203
|
-
if (false) {
|
|
204
|
-
/** @type {?} */
|
|
205
|
-
SerializedRouterStateSnapshot.prototype.root;
|
|
206
|
-
/** @type {?} */
|
|
207
|
-
SerializedRouterStateSnapshot.prototype.url;
|
|
208
|
-
}
|
|
209
|
-
class DefaultRouterStateSerializer {
|
|
210
|
-
/**
|
|
211
|
-
* @param {?} routerState
|
|
212
|
-
* @return {?}
|
|
213
|
-
*/
|
|
214
|
-
serialize(routerState) {
|
|
215
|
-
return {
|
|
216
|
-
root: this.serializeRoute(routerState.root),
|
|
217
|
-
url: routerState.url
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* @private
|
|
222
|
-
* @param {?} route
|
|
223
|
-
* @return {?}
|
|
224
|
-
*/
|
|
225
|
-
serializeRoute(route) {
|
|
226
|
-
/** @type {?} */
|
|
227
|
-
const children = route.children.map((/**
|
|
228
|
-
* @param {?} c
|
|
229
|
-
* @return {?}
|
|
230
|
-
*/
|
|
231
|
-
c => this.serializeRoute(c)));
|
|
232
|
-
return {
|
|
233
|
-
url: route.url,
|
|
234
|
-
params: route.params,
|
|
235
|
-
queryParams: route.queryParams,
|
|
236
|
-
fragment: route.fragment,
|
|
237
|
-
data: route.data,
|
|
238
|
-
outlet: route.outlet,
|
|
239
|
-
component: null,
|
|
240
|
-
routeConfig: null,
|
|
241
|
-
root: (/** @type {?} */ (null)),
|
|
242
|
-
parent: null,
|
|
243
|
-
firstChild: children[0],
|
|
244
|
-
children: children,
|
|
245
|
-
pathFromRoot: (/** @type {?} */ (null)),
|
|
246
|
-
paramMap: route.paramMap,
|
|
247
|
-
queryParamMap: route.queryParamMap,
|
|
248
|
-
toString: route.toString
|
|
249
|
-
};
|
|
250
|
-
}
|
|
182
|
+
/**
|
|
183
|
+
* @fileoverview added by tsickle
|
|
184
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
185
|
+
*/
|
|
186
|
+
/**
|
|
187
|
+
* @abstract
|
|
188
|
+
* @template T
|
|
189
|
+
*/
|
|
190
|
+
class RouterStateSerializer {
|
|
191
|
+
}
|
|
192
|
+
if (false) {
|
|
193
|
+
/**
|
|
194
|
+
* @abstract
|
|
195
|
+
* @param {?} routerState
|
|
196
|
+
* @return {?}
|
|
197
|
+
*/
|
|
198
|
+
RouterStateSerializer.prototype.serialize = function (routerState) { };
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* @record
|
|
202
|
+
*/
|
|
203
|
+
function SerializedRouterStateSnapshot() { }
|
|
204
|
+
if (false) {
|
|
205
|
+
/** @type {?} */
|
|
206
|
+
SerializedRouterStateSnapshot.prototype.root;
|
|
207
|
+
/** @type {?} */
|
|
208
|
+
SerializedRouterStateSnapshot.prototype.url;
|
|
209
|
+
}
|
|
210
|
+
class DefaultRouterStateSerializer {
|
|
211
|
+
/**
|
|
212
|
+
* @param {?} routerState
|
|
213
|
+
* @return {?}
|
|
214
|
+
*/
|
|
215
|
+
serialize(routerState) {
|
|
216
|
+
return {
|
|
217
|
+
root: this.serializeRoute(routerState.root),
|
|
218
|
+
url: routerState.url
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* @private
|
|
223
|
+
* @param {?} route
|
|
224
|
+
* @return {?}
|
|
225
|
+
*/
|
|
226
|
+
serializeRoute(route) {
|
|
227
|
+
/** @type {?} */
|
|
228
|
+
const children = route.children.map((/**
|
|
229
|
+
* @param {?} c
|
|
230
|
+
* @return {?}
|
|
231
|
+
*/
|
|
232
|
+
c => this.serializeRoute(c)));
|
|
233
|
+
return {
|
|
234
|
+
url: route.url,
|
|
235
|
+
params: route.params,
|
|
236
|
+
queryParams: route.queryParams,
|
|
237
|
+
fragment: route.fragment,
|
|
238
|
+
data: route.data,
|
|
239
|
+
outlet: route.outlet,
|
|
240
|
+
component: null,
|
|
241
|
+
routeConfig: null,
|
|
242
|
+
root: (/** @type {?} */ (null)),
|
|
243
|
+
parent: null,
|
|
244
|
+
firstChild: children[0],
|
|
245
|
+
children: children,
|
|
246
|
+
pathFromRoot: (/** @type {?} */ (null)),
|
|
247
|
+
paramMap: route.paramMap,
|
|
248
|
+
queryParamMap: route.queryParamMap,
|
|
249
|
+
toString: route.toString
|
|
250
|
+
};
|
|
251
|
+
}
|
|
251
252
|
}
|
|
252
253
|
|
|
253
|
-
var RouterState_1;
|
|
254
|
-
/**
|
|
255
|
-
* @record
|
|
256
|
-
* @template T
|
|
257
|
-
*/
|
|
258
|
-
function RouterStateModel() { }
|
|
259
|
-
if (false) {
|
|
260
|
-
/** @type {?|undefined} */
|
|
261
|
-
RouterStateModel.prototype.state;
|
|
262
|
-
/** @type {?|undefined} */
|
|
263
|
-
RouterStateModel.prototype.navigationId;
|
|
264
|
-
/** @type {?} */
|
|
265
|
-
RouterStateModel.prototype.trigger;
|
|
266
|
-
}
|
|
267
|
-
let RouterState = RouterState_1 = class RouterState {
|
|
268
|
-
/**
|
|
269
|
-
* @param {?} _store
|
|
270
|
-
* @param {?} _router
|
|
271
|
-
* @param {?} _serializer
|
|
272
|
-
* @param {?} _ngZone
|
|
273
|
-
* @param {?} _urlSerializer
|
|
274
|
-
* @param {?} _locationStrategy
|
|
275
|
-
* @param {?} _location
|
|
276
|
-
*/
|
|
277
|
-
constructor(_store, _router, _serializer, _ngZone, _urlSerializer, _locationStrategy, _location) {
|
|
278
|
-
this._store = _store;
|
|
279
|
-
this._router = _router;
|
|
280
|
-
this._serializer = _serializer;
|
|
281
|
-
this._ngZone = _ngZone;
|
|
282
|
-
this._urlSerializer = _urlSerializer;
|
|
283
|
-
this._locationStrategy = _locationStrategy;
|
|
284
|
-
this._location = _location;
|
|
285
|
-
/**
|
|
286
|
-
* Determines how navigation was performed by the `RouterState` itself
|
|
287
|
-
* or outside via `new Navigate(...)`
|
|
288
|
-
*/
|
|
289
|
-
this._trigger = 'none';
|
|
290
|
-
/**
|
|
291
|
-
* That's the serialized state from the `Router` class
|
|
292
|
-
*/
|
|
293
|
-
this._routerState = null;
|
|
294
|
-
/**
|
|
295
|
-
* That's the value of the `RouterState` state
|
|
296
|
-
*/
|
|
297
|
-
this._storeState = null;
|
|
298
|
-
this._lastRoutesRecognized = (/** @type {?} */ (null));
|
|
299
|
-
this.
|
|
300
|
-
this.
|
|
301
|
-
this.
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
* @
|
|
306
|
-
* @
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
* @
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
* @
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
* @
|
|
339
|
-
* @return {?}
|
|
340
|
-
*/
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
this.
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
* @
|
|
476
|
-
* @
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
* @
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
this.
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
//
|
|
518
|
-
//
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
// We
|
|
539
|
-
//
|
|
540
|
-
//
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
//
|
|
544
|
-
//
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
__metadata("design:
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
*
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
* @
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
* @type {?}
|
|
651
|
-
* @private
|
|
652
|
-
*/
|
|
653
|
-
RouterState.prototype.
|
|
654
|
-
/**
|
|
655
|
-
* @type {?}
|
|
656
|
-
* @private
|
|
657
|
-
*/
|
|
658
|
-
RouterState.prototype.
|
|
659
|
-
/**
|
|
660
|
-
* @type {?}
|
|
661
|
-
* @private
|
|
662
|
-
*/
|
|
663
|
-
RouterState.prototype.
|
|
664
|
-
/**
|
|
665
|
-
* @type {?}
|
|
666
|
-
* @private
|
|
667
|
-
*/
|
|
668
|
-
RouterState.prototype.
|
|
669
|
-
/**
|
|
670
|
-
* @type {?}
|
|
671
|
-
* @private
|
|
672
|
-
*/
|
|
673
|
-
RouterState.prototype.
|
|
254
|
+
var RouterState_1;
|
|
255
|
+
/**
|
|
256
|
+
* @record
|
|
257
|
+
* @template T
|
|
258
|
+
*/
|
|
259
|
+
function RouterStateModel() { }
|
|
260
|
+
if (false) {
|
|
261
|
+
/** @type {?|undefined} */
|
|
262
|
+
RouterStateModel.prototype.state;
|
|
263
|
+
/** @type {?|undefined} */
|
|
264
|
+
RouterStateModel.prototype.navigationId;
|
|
265
|
+
/** @type {?} */
|
|
266
|
+
RouterStateModel.prototype.trigger;
|
|
267
|
+
}
|
|
268
|
+
let RouterState = RouterState_1 = class RouterState {
|
|
269
|
+
/**
|
|
270
|
+
* @param {?} _store
|
|
271
|
+
* @param {?} _router
|
|
272
|
+
* @param {?} _serializer
|
|
273
|
+
* @param {?} _ngZone
|
|
274
|
+
* @param {?} _urlSerializer
|
|
275
|
+
* @param {?} _locationStrategy
|
|
276
|
+
* @param {?} _location
|
|
277
|
+
*/
|
|
278
|
+
constructor(_store, _router, _serializer, _ngZone, _urlSerializer, _locationStrategy, _location) {
|
|
279
|
+
this._store = _store;
|
|
280
|
+
this._router = _router;
|
|
281
|
+
this._serializer = _serializer;
|
|
282
|
+
this._ngZone = _ngZone;
|
|
283
|
+
this._urlSerializer = _urlSerializer;
|
|
284
|
+
this._locationStrategy = _locationStrategy;
|
|
285
|
+
this._location = _location;
|
|
286
|
+
/**
|
|
287
|
+
* Determines how navigation was performed by the `RouterState` itself
|
|
288
|
+
* or outside via `new Navigate(...)`
|
|
289
|
+
*/
|
|
290
|
+
this._trigger = 'none';
|
|
291
|
+
/**
|
|
292
|
+
* That's the serialized state from the `Router` class
|
|
293
|
+
*/
|
|
294
|
+
this._routerState = null;
|
|
295
|
+
/**
|
|
296
|
+
* That's the value of the `RouterState` state
|
|
297
|
+
*/
|
|
298
|
+
this._storeState = null;
|
|
299
|
+
this._lastRoutesRecognized = (/** @type {?} */ (null));
|
|
300
|
+
this._subscription = new Subscription();
|
|
301
|
+
this.setUpStoreListener();
|
|
302
|
+
this.setUpRouterEventsListener();
|
|
303
|
+
this.checkInitialNavigationOnce();
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* @template T
|
|
307
|
+
* @param {?} state
|
|
308
|
+
* @return {?}
|
|
309
|
+
*/
|
|
310
|
+
static state(state) {
|
|
311
|
+
return state && state.state;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* @param {?} state
|
|
315
|
+
* @return {?}
|
|
316
|
+
*/
|
|
317
|
+
static url(state) {
|
|
318
|
+
return state && state.state && state.state.url;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* @return {?}
|
|
322
|
+
*/
|
|
323
|
+
ngOnDestroy() {
|
|
324
|
+
this._subscription.unsubscribe();
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* @param {?} _
|
|
328
|
+
* @param {?} action
|
|
329
|
+
* @return {?}
|
|
330
|
+
*/
|
|
331
|
+
navigate(_, action) {
|
|
332
|
+
return this._ngZone.run((/**
|
|
333
|
+
* @return {?}
|
|
334
|
+
*/
|
|
335
|
+
() => this._router.navigate(action.path, Object.assign({ queryParams: action.queryParams }, action.extras))));
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* @param {?} ctx
|
|
339
|
+
* @param {?} action
|
|
340
|
+
* @return {?}
|
|
341
|
+
*/
|
|
342
|
+
angularRouterAction(ctx, action) {
|
|
343
|
+
ctx.setState(Object.assign({}, ctx.getState(), { trigger: action.trigger, state: action.routerState, navigationId: action.event.id }));
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* @private
|
|
347
|
+
* @return {?}
|
|
348
|
+
*/
|
|
349
|
+
setUpStoreListener() {
|
|
350
|
+
/** @type {?} */
|
|
351
|
+
const subscription = this._store
|
|
352
|
+
.select(RouterState_1)
|
|
353
|
+
.subscribe((/**
|
|
354
|
+
* @param {?} state
|
|
355
|
+
* @return {?}
|
|
356
|
+
*/
|
|
357
|
+
(state) => {
|
|
358
|
+
this.navigateIfNeeded(state);
|
|
359
|
+
}));
|
|
360
|
+
this._subscription.add(subscription);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* @private
|
|
364
|
+
* @return {?}
|
|
365
|
+
*/
|
|
366
|
+
setUpRouterEventsListener() {
|
|
367
|
+
/** @type {?} */
|
|
368
|
+
const subscription = this._router.events.subscribe((/**
|
|
369
|
+
* @param {?} event
|
|
370
|
+
* @return {?}
|
|
371
|
+
*/
|
|
372
|
+
event => {
|
|
373
|
+
if (event instanceof NavigationStart) {
|
|
374
|
+
this.navigationStart();
|
|
375
|
+
}
|
|
376
|
+
else if (event instanceof RoutesRecognized) {
|
|
377
|
+
this._lastRoutesRecognized = event;
|
|
378
|
+
}
|
|
379
|
+
else if (event instanceof ResolveEnd) {
|
|
380
|
+
this.dispatchRouterDataResolved(event);
|
|
381
|
+
}
|
|
382
|
+
else if (event instanceof NavigationCancel) {
|
|
383
|
+
this.dispatchRouterCancel(event);
|
|
384
|
+
this.reset();
|
|
385
|
+
}
|
|
386
|
+
else if (event instanceof NavigationError) {
|
|
387
|
+
this.dispatchRouterError(event);
|
|
388
|
+
this.reset();
|
|
389
|
+
}
|
|
390
|
+
else if (event instanceof NavigationEnd) {
|
|
391
|
+
this.navigationEnd();
|
|
392
|
+
this.reset();
|
|
393
|
+
}
|
|
394
|
+
}));
|
|
395
|
+
this._subscription.add(subscription);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* @private
|
|
399
|
+
* @return {?}
|
|
400
|
+
*/
|
|
401
|
+
navigationStart() {
|
|
402
|
+
this._routerState = this._serializer.serialize(this._router.routerState.snapshot);
|
|
403
|
+
if (this._trigger !== 'none') {
|
|
404
|
+
this._storeState = this._store.selectSnapshot(RouterState_1);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* @private
|
|
409
|
+
* @return {?}
|
|
410
|
+
*/
|
|
411
|
+
navigationEnd() {
|
|
412
|
+
if (this.shouldDispatchRouterNavigation()) {
|
|
413
|
+
this.dispatchRouterNavigation();
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* @private
|
|
418
|
+
* @return {?}
|
|
419
|
+
*/
|
|
420
|
+
shouldDispatchRouterNavigation() {
|
|
421
|
+
if (!this._storeState)
|
|
422
|
+
return true;
|
|
423
|
+
return this._trigger !== 'store';
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* @private
|
|
427
|
+
* @param {?} state
|
|
428
|
+
* @return {?}
|
|
429
|
+
*/
|
|
430
|
+
navigateIfNeeded(state) {
|
|
431
|
+
/** @type {?} */
|
|
432
|
+
const canSkipNavigation = !this._storeState ||
|
|
433
|
+
!this._storeState.state ||
|
|
434
|
+
!state ||
|
|
435
|
+
state.trigger === 'router' ||
|
|
436
|
+
this._router.url === this._storeState.state.url;
|
|
437
|
+
if (canSkipNavigation) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
this._trigger = 'store';
|
|
441
|
+
this._ngZone.run((/**
|
|
442
|
+
* @return {?}
|
|
443
|
+
*/
|
|
444
|
+
() => {
|
|
445
|
+
this._router.navigateByUrl((/** @type {?} */ ((/** @type {?} */ (this._storeState)).state)).url);
|
|
446
|
+
}));
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* @private
|
|
450
|
+
* @return {?}
|
|
451
|
+
*/
|
|
452
|
+
dispatchRouterNavigation() {
|
|
453
|
+
/** @type {?} */
|
|
454
|
+
const nextRouterState = this._serializer.serialize(this._lastRoutesRecognized.state);
|
|
455
|
+
this.dispatchRouterAction(new RouterNavigation(nextRouterState, new RoutesRecognized(this._lastRoutesRecognized.id, this._lastRoutesRecognized.url, this._lastRoutesRecognized.urlAfterRedirects, nextRouterState), this._trigger));
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* @private
|
|
459
|
+
* @param {?} event
|
|
460
|
+
* @return {?}
|
|
461
|
+
*/
|
|
462
|
+
dispatchRouterCancel(event) {
|
|
463
|
+
this.dispatchRouterAction(new RouterCancel((/** @type {?} */ (this._routerState)), this._storeState, event, this._trigger));
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* @private
|
|
467
|
+
* @param {?} event
|
|
468
|
+
* @return {?}
|
|
469
|
+
*/
|
|
470
|
+
dispatchRouterError(event) {
|
|
471
|
+
this.dispatchRouterAction(new RouterError((/** @type {?} */ (this._routerState)), this._storeState, new NavigationError(event.id, event.url, `${event}`), this._trigger));
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* @private
|
|
475
|
+
* @template T
|
|
476
|
+
* @param {?} action
|
|
477
|
+
* @return {?}
|
|
478
|
+
*/
|
|
479
|
+
dispatchRouterAction(action) {
|
|
480
|
+
this._trigger = 'router';
|
|
481
|
+
try {
|
|
482
|
+
this._store.dispatch(action);
|
|
483
|
+
}
|
|
484
|
+
finally {
|
|
485
|
+
this._trigger = 'none';
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* @private
|
|
490
|
+
* @param {?} event
|
|
491
|
+
* @return {?}
|
|
492
|
+
*/
|
|
493
|
+
dispatchRouterDataResolved(event) {
|
|
494
|
+
/** @type {?} */
|
|
495
|
+
const routerState = this._serializer.serialize(event.state);
|
|
496
|
+
this.dispatchRouterAction(new RouterDataResolved(routerState, event, this._trigger));
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* @private
|
|
500
|
+
* @return {?}
|
|
501
|
+
*/
|
|
502
|
+
reset() {
|
|
503
|
+
this._trigger = 'none';
|
|
504
|
+
this._storeState = null;
|
|
505
|
+
this._routerState = null;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* No sense to mess up the `setUpRouterEventsListener` method as we have
|
|
509
|
+
* to perform this check only once and unsubscribe after the first event
|
|
510
|
+
* is triggered
|
|
511
|
+
* @private
|
|
512
|
+
* @return {?}
|
|
513
|
+
*/
|
|
514
|
+
checkInitialNavigationOnce() {
|
|
515
|
+
// Caretaker note: we have still left the `typeof` condition in order to avoid
|
|
516
|
+
// creating a breaking change for projects that still use the View Engine.
|
|
517
|
+
if ((typeof ngDevMode === 'undefined' || ngDevMode) &&
|
|
518
|
+
// Angular is running tests in development mode thus we can be sure that this method will be
|
|
519
|
+
// skipped in tests.
|
|
520
|
+
isAngularInTestMode()) {
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
/** @type {?} */
|
|
524
|
+
const subscription = this._router.events
|
|
525
|
+
.pipe(first((/**
|
|
526
|
+
* @param {?} event
|
|
527
|
+
* @return {?}
|
|
528
|
+
*/
|
|
529
|
+
(event) => event instanceof RoutesRecognized)))
|
|
530
|
+
.subscribe((/**
|
|
531
|
+
* @param {?} __0
|
|
532
|
+
* @return {?}
|
|
533
|
+
*/
|
|
534
|
+
({ url }) => {
|
|
535
|
+
// `location.pathname` always equals manually entered URL in the address bar
|
|
536
|
+
// e.g. `location.pathname === '/foo'`, but the `router` state has been initialized
|
|
537
|
+
// with another URL (e.g. used in combination with `NgxsStoragePlugin`), thus the
|
|
538
|
+
// `RouterNavigation` action will be dispatched and the user will be redirected to the
|
|
539
|
+
// previously saved URL. We want to prevent such behavior, so we perform this check
|
|
540
|
+
// `location.pathname` always equals manually entered URL in the address bar
|
|
541
|
+
// e.g. `location.pathname === '/foo'`, but the `router` state has been initialized
|
|
542
|
+
// with another URL (e.g. used in combination with `NgxsStoragePlugin`), thus the
|
|
543
|
+
// `RouterNavigation` action will be dispatched and the user will be redirected to the
|
|
544
|
+
// previously saved URL. We want to prevent such behavior, so we perform this check
|
|
545
|
+
// `url` is a recognized URL by the Angular's router, while `currentUrl` is an actual URL
|
|
546
|
+
// entered in the browser's address bar
|
|
547
|
+
// `PathLocationStrategy.prototype.path()` returns a concatenation of
|
|
548
|
+
// `PlatformLocation.pathname` and normalized `PlatformLocation.search`.
|
|
549
|
+
// `Location.prototype.normalize` strips base href from the URL,
|
|
550
|
+
// if `baseHref` (declared in angular.json) for example is `/en`
|
|
551
|
+
// and the URL is `/test#anchor` - then `_locationStrategy.path(true)` will return `/en/test#anchor`,
|
|
552
|
+
// but `/en/test#anchor` is not known to the Angular's router, so we have to strip `/en`
|
|
553
|
+
// from the URL
|
|
554
|
+
/** @type {?} */
|
|
555
|
+
const currentUrl = this._location.normalize(this._locationStrategy.path(true));
|
|
556
|
+
/** @type {?} */
|
|
557
|
+
const currentUrlTree = this._urlSerializer.parse(currentUrl);
|
|
558
|
+
// We need to serialize the URL because in that example `/test/?redirect=https://google.com/`
|
|
559
|
+
// Angular will recognize it as `/test?redirect=https:%2F%2Fwww.google.com%2F`
|
|
560
|
+
// so we have to run the `currentUrl` via the `UrlSerializer` that will encode characters
|
|
561
|
+
/** @type {?} */
|
|
562
|
+
const currentSerializedUrl = this._urlSerializer.serialize(currentUrlTree);
|
|
563
|
+
// If URLs differ from each other - we've got to perform a redirect to the manually entered URL
|
|
564
|
+
// in the address bar, as it must have a priority
|
|
565
|
+
if (currentSerializedUrl !== url) {
|
|
566
|
+
this._router.navigateByUrl(currentUrl);
|
|
567
|
+
}
|
|
568
|
+
}));
|
|
569
|
+
this._subscription.add(subscription);
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
RouterState.ctorParameters = () => [
|
|
573
|
+
{ type: Store },
|
|
574
|
+
{ type: Router },
|
|
575
|
+
{ type: RouterStateSerializer },
|
|
576
|
+
{ type: NgZone },
|
|
577
|
+
{ type: UrlSerializer },
|
|
578
|
+
{ type: LocationStrategy },
|
|
579
|
+
{ type: Location }
|
|
580
|
+
];
|
|
581
|
+
RouterState.decorators = [
|
|
582
|
+
{ type: Injectable }
|
|
583
|
+
];
|
|
584
|
+
/** @nocollapse */
|
|
585
|
+
RouterState.ctorParameters = () => [
|
|
586
|
+
{ type: Store },
|
|
587
|
+
{ type: Router },
|
|
588
|
+
{ type: RouterStateSerializer },
|
|
589
|
+
{ type: NgZone },
|
|
590
|
+
{ type: UrlSerializer },
|
|
591
|
+
{ type: LocationStrategy },
|
|
592
|
+
{ type: Location }
|
|
593
|
+
];
|
|
594
|
+
__decorate([
|
|
595
|
+
Action(Navigate),
|
|
596
|
+
__metadata("design:type", Function),
|
|
597
|
+
__metadata("design:paramtypes", [Object, Navigate]),
|
|
598
|
+
__metadata("design:returntype", void 0)
|
|
599
|
+
], RouterState.prototype, "navigate", null);
|
|
600
|
+
__decorate([
|
|
601
|
+
Action([RouterNavigation, RouterError, RouterCancel, RouterDataResolved]),
|
|
602
|
+
__metadata("design:type", Function),
|
|
603
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
604
|
+
__metadata("design:returntype", void 0)
|
|
605
|
+
], RouterState.prototype, "angularRouterAction", null);
|
|
606
|
+
__decorate([
|
|
607
|
+
Selector(),
|
|
608
|
+
__metadata("design:type", Function),
|
|
609
|
+
__metadata("design:paramtypes", [Object]),
|
|
610
|
+
__metadata("design:returntype", void 0)
|
|
611
|
+
], RouterState, "state", null);
|
|
612
|
+
__decorate([
|
|
613
|
+
Selector(),
|
|
614
|
+
__metadata("design:type", Function),
|
|
615
|
+
__metadata("design:paramtypes", [Object]),
|
|
616
|
+
__metadata("design:returntype", Object)
|
|
617
|
+
], RouterState, "url", null);
|
|
618
|
+
RouterState = RouterState_1 = __decorate([
|
|
619
|
+
State({
|
|
620
|
+
name: 'router',
|
|
621
|
+
defaults: {
|
|
622
|
+
state: undefined,
|
|
623
|
+
navigationId: undefined,
|
|
624
|
+
trigger: 'none'
|
|
625
|
+
}
|
|
626
|
+
}),
|
|
627
|
+
__metadata("design:paramtypes", [Store,
|
|
628
|
+
Router,
|
|
629
|
+
RouterStateSerializer,
|
|
630
|
+
NgZone,
|
|
631
|
+
UrlSerializer,
|
|
632
|
+
LocationStrategy,
|
|
633
|
+
Location])
|
|
634
|
+
], RouterState);
|
|
635
|
+
if (false) {
|
|
636
|
+
/**
|
|
637
|
+
* Determines how navigation was performed by the `RouterState` itself
|
|
638
|
+
* or outside via `new Navigate(...)`
|
|
639
|
+
* @type {?}
|
|
640
|
+
* @private
|
|
641
|
+
*/
|
|
642
|
+
RouterState.prototype._trigger;
|
|
643
|
+
/**
|
|
644
|
+
* That's the serialized state from the `Router` class
|
|
645
|
+
* @type {?}
|
|
646
|
+
* @private
|
|
647
|
+
*/
|
|
648
|
+
RouterState.prototype._routerState;
|
|
649
|
+
/**
|
|
650
|
+
* That's the value of the `RouterState` state
|
|
651
|
+
* @type {?}
|
|
652
|
+
* @private
|
|
653
|
+
*/
|
|
654
|
+
RouterState.prototype._storeState;
|
|
655
|
+
/**
|
|
656
|
+
* @type {?}
|
|
657
|
+
* @private
|
|
658
|
+
*/
|
|
659
|
+
RouterState.prototype._lastRoutesRecognized;
|
|
660
|
+
/**
|
|
661
|
+
* @type {?}
|
|
662
|
+
* @private
|
|
663
|
+
*/
|
|
664
|
+
RouterState.prototype._subscription;
|
|
665
|
+
/**
|
|
666
|
+
* @type {?}
|
|
667
|
+
* @private
|
|
668
|
+
*/
|
|
669
|
+
RouterState.prototype._store;
|
|
670
|
+
/**
|
|
671
|
+
* @type {?}
|
|
672
|
+
* @private
|
|
673
|
+
*/
|
|
674
|
+
RouterState.prototype._router;
|
|
675
|
+
/**
|
|
676
|
+
* @type {?}
|
|
677
|
+
* @private
|
|
678
|
+
*/
|
|
679
|
+
RouterState.prototype._serializer;
|
|
680
|
+
/**
|
|
681
|
+
* @type {?}
|
|
682
|
+
* @private
|
|
683
|
+
*/
|
|
684
|
+
RouterState.prototype._ngZone;
|
|
685
|
+
/**
|
|
686
|
+
* @type {?}
|
|
687
|
+
* @private
|
|
688
|
+
*/
|
|
689
|
+
RouterState.prototype._urlSerializer;
|
|
690
|
+
/**
|
|
691
|
+
* @type {?}
|
|
692
|
+
* @private
|
|
693
|
+
*/
|
|
694
|
+
RouterState.prototype._locationStrategy;
|
|
695
|
+
/**
|
|
696
|
+
* @type {?}
|
|
697
|
+
* @private
|
|
698
|
+
*/
|
|
699
|
+
RouterState.prototype._location;
|
|
674
700
|
}
|
|
675
701
|
|
|
676
|
-
/**
|
|
677
|
-
* @fileoverview added by tsickle
|
|
678
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
679
|
-
*/
|
|
680
|
-
class NgxsRouterPluginModule {
|
|
681
|
-
/**
|
|
682
|
-
* @return {?}
|
|
683
|
-
*/
|
|
684
|
-
static forRoot() {
|
|
685
|
-
return {
|
|
686
|
-
ngModule: NgxsRouterPluginModule,
|
|
687
|
-
providers: [{ provide: RouterStateSerializer, useClass: DefaultRouterStateSerializer }]
|
|
688
|
-
};
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
NgxsRouterPluginModule.decorators = [
|
|
692
|
-
{ type: NgModule, args: [{
|
|
693
|
-
imports: [NgxsModule.forFeature([RouterState])]
|
|
694
|
-
},] }
|
|
702
|
+
/**
|
|
703
|
+
* @fileoverview added by tsickle
|
|
704
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
705
|
+
*/
|
|
706
|
+
class NgxsRouterPluginModule {
|
|
707
|
+
/**
|
|
708
|
+
* @return {?}
|
|
709
|
+
*/
|
|
710
|
+
static forRoot() {
|
|
711
|
+
return {
|
|
712
|
+
ngModule: NgxsRouterPluginModule,
|
|
713
|
+
providers: [{ provide: RouterStateSerializer, useClass: DefaultRouterStateSerializer }]
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
NgxsRouterPluginModule.decorators = [
|
|
718
|
+
{ type: NgModule, args: [{
|
|
719
|
+
imports: [NgxsModule.forFeature([RouterState])]
|
|
720
|
+
},] }
|
|
695
721
|
];
|
|
696
722
|
|
|
697
|
-
/**
|
|
698
|
-
* @fileoverview added by tsickle
|
|
699
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
723
|
+
/**
|
|
724
|
+
* @fileoverview added by tsickle
|
|
725
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
700
726
|
*/
|
|
701
727
|
|
|
702
|
-
/**
|
|
703
|
-
* @fileoverview added by tsickle
|
|
704
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
728
|
+
/**
|
|
729
|
+
* @fileoverview added by tsickle
|
|
730
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
705
731
|
*/
|
|
706
732
|
|
|
707
|
-
/**
|
|
708
|
-
* @fileoverview added by tsickle
|
|
709
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
733
|
+
/**
|
|
734
|
+
* @fileoverview added by tsickle
|
|
735
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
710
736
|
*/
|
|
711
737
|
|
|
712
738
|
export { DefaultRouterStateSerializer, Navigate, NgxsRouterPluginModule, RouterCancel, RouterDataResolved, RouterError, RouterNavigation, RouterState, RouterStateSerializer };
|