@ngxs/router-plugin 3.7.6 → 3.8.0-dev.master-c341c15
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/bundles/ngxs-router-plugin.umd.js +590 -769
- package/bundles/ngxs-router-plugin.umd.js.map +1 -1
- package/esm2015/index.js +2 -6
- package/esm2015/ngxs-router-plugin.js +2 -6
- package/esm2015/src/public_api.js +2 -6
- package/esm2015/src/router.actions.js +28 -94
- package/esm2015/src/router.module.js +23 -15
- package/esm2015/src/router.state.js +126 -272
- package/esm2015/src/serializer.js +4 -44
- package/esm2015/src/symbols.js +9 -0
- package/fesm2015/ngxs-router-plugin.js +168 -412
- package/fesm2015/ngxs-router-plugin.js.map +1 -1
- package/ngxs-router-plugin.d.ts +1 -1
- package/package.json +5 -8
- package/src/public_api.d.ts +1 -0
- package/src/router.actions.d.ts +27 -7
- package/src/router.module.d.ts +7 -1
- package/src/router.state.d.ts +24 -15
- package/src/symbols.d.ts +11 -0
- package/bundles/ngxs-router-plugin.umd.min.js +0 -16
- package/bundles/ngxs-router-plugin.umd.min.js.map +0 -1
- package/esm5/index.js +0 -9
- package/esm5/ngxs-router-plugin.js +0 -9
- package/esm5/src/public_api.js +0 -9
- package/esm5/src/router.actions.js +0 -227
- package/esm5/src/router.module.js +0 -32
- package/esm5/src/router.state.js +0 -446
- package/esm5/src/serializer.js +0 -98
- package/fesm5/ngxs-router-plugin.js +0 -778
- package/fesm5/ngxs-router-plugin.js.map +0 -1
- package/ngxs-router-plugin.metadata.json +0 -1
|
@@ -1,232 +1,129 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, NgZone, Injector, Injectable, NgModule } from '@angular/core';
|
|
3
|
+
import * as i1 from '@ngxs/store';
|
|
4
|
+
import { Action, Selector, State, Store, NgxsModule } from '@ngxs/store';
|
|
3
5
|
import { __decorate, __metadata } from 'tslib';
|
|
6
|
+
import * as i2 from '@angular/router';
|
|
4
7
|
import { NavigationStart, RoutesRecognized, ResolveEnd, NavigationCancel, NavigationError, NavigationEnd, Router } from '@angular/router';
|
|
5
8
|
import { Subscription } from 'rxjs';
|
|
6
9
|
|
|
7
|
-
/**
|
|
8
|
-
* @fileoverview added by tsickle
|
|
9
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
10
|
-
*/
|
|
11
10
|
/**
|
|
12
11
|
* Public event api of the router
|
|
13
12
|
*/
|
|
14
13
|
class Navigate {
|
|
15
|
-
/**
|
|
16
|
-
* @param {?} path
|
|
17
|
-
* @param {?=} queryParams
|
|
18
|
-
* @param {?=} extras
|
|
19
|
-
*/
|
|
20
14
|
constructor(path, queryParams, extras) {
|
|
21
15
|
this.path = path;
|
|
22
16
|
this.queryParams = queryParams;
|
|
23
17
|
this.extras = extras;
|
|
24
18
|
}
|
|
25
|
-
/**
|
|
26
|
-
* @return {?}
|
|
27
|
-
*/
|
|
28
19
|
static get type() {
|
|
29
20
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
30
21
|
return '[Router] Navigate';
|
|
31
22
|
}
|
|
32
23
|
}
|
|
33
|
-
if (false) {
|
|
34
|
-
/** @type {?} */
|
|
35
|
-
Navigate.prototype.path;
|
|
36
|
-
/** @type {?} */
|
|
37
|
-
Navigate.prototype.queryParams;
|
|
38
|
-
/** @type {?} */
|
|
39
|
-
Navigate.prototype.extras;
|
|
40
|
-
}
|
|
41
24
|
/**
|
|
42
25
|
*
|
|
43
26
|
* Angular Routers internal state events
|
|
44
27
|
*
|
|
45
28
|
*/
|
|
29
|
+
/**
|
|
30
|
+
* An action dispatched when the router starts the navigation.
|
|
31
|
+
*/
|
|
32
|
+
class RouterRequest {
|
|
33
|
+
constructor(routerState, event, trigger = 'none') {
|
|
34
|
+
this.routerState = routerState;
|
|
35
|
+
this.event = event;
|
|
36
|
+
this.trigger = trigger;
|
|
37
|
+
}
|
|
38
|
+
static get type() {
|
|
39
|
+
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
40
|
+
return '[Router] RouterRequest';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
46
43
|
/**
|
|
47
44
|
* An action dispatched when the router navigates.
|
|
48
|
-
* @template T
|
|
49
45
|
*/
|
|
50
46
|
class RouterNavigation {
|
|
51
|
-
/**
|
|
52
|
-
* @param {?} routerState
|
|
53
|
-
* @param {?} event
|
|
54
|
-
* @param {?=} trigger
|
|
55
|
-
*/
|
|
56
47
|
constructor(routerState, event, trigger = 'none') {
|
|
57
48
|
this.routerState = routerState;
|
|
58
49
|
this.event = event;
|
|
59
50
|
this.trigger = trigger;
|
|
60
51
|
}
|
|
61
|
-
/**
|
|
62
|
-
* @return {?}
|
|
63
|
-
*/
|
|
64
52
|
static get type() {
|
|
65
53
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
66
54
|
return '[Router] RouterNavigation';
|
|
67
55
|
}
|
|
68
56
|
}
|
|
69
|
-
if (false) {
|
|
70
|
-
/** @type {?} */
|
|
71
|
-
RouterNavigation.prototype.routerState;
|
|
72
|
-
/** @type {?} */
|
|
73
|
-
RouterNavigation.prototype.event;
|
|
74
|
-
/** @type {?} */
|
|
75
|
-
RouterNavigation.prototype.trigger;
|
|
76
|
-
}
|
|
77
57
|
/**
|
|
78
58
|
* An action dispatched when the router cancel navigation.
|
|
79
|
-
* @template T, V
|
|
80
59
|
*/
|
|
81
60
|
class RouterCancel {
|
|
82
|
-
/**
|
|
83
|
-
* @param {?} routerState
|
|
84
|
-
* @param {?} storeState
|
|
85
|
-
* @param {?} event
|
|
86
|
-
* @param {?=} trigger
|
|
87
|
-
*/
|
|
88
61
|
constructor(routerState, storeState, event, trigger = 'none') {
|
|
89
62
|
this.routerState = routerState;
|
|
90
63
|
this.storeState = storeState;
|
|
91
64
|
this.event = event;
|
|
92
65
|
this.trigger = trigger;
|
|
93
66
|
}
|
|
94
|
-
/**
|
|
95
|
-
* @return {?}
|
|
96
|
-
*/
|
|
97
67
|
static get type() {
|
|
98
68
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
99
69
|
return '[Router] RouterCancel';
|
|
100
70
|
}
|
|
101
71
|
}
|
|
102
|
-
if (false) {
|
|
103
|
-
/** @type {?} */
|
|
104
|
-
RouterCancel.prototype.routerState;
|
|
105
|
-
/** @type {?} */
|
|
106
|
-
RouterCancel.prototype.storeState;
|
|
107
|
-
/** @type {?} */
|
|
108
|
-
RouterCancel.prototype.event;
|
|
109
|
-
/** @type {?} */
|
|
110
|
-
RouterCancel.prototype.trigger;
|
|
111
|
-
}
|
|
112
72
|
/**
|
|
113
73
|
* An action dispatched when the router errors.
|
|
114
|
-
* @template T, V
|
|
115
74
|
*/
|
|
116
75
|
class RouterError {
|
|
117
|
-
/**
|
|
118
|
-
* @param {?} routerState
|
|
119
|
-
* @param {?} storeState
|
|
120
|
-
* @param {?} event
|
|
121
|
-
* @param {?=} trigger
|
|
122
|
-
*/
|
|
123
76
|
constructor(routerState, storeState, event, trigger = 'none') {
|
|
124
77
|
this.routerState = routerState;
|
|
125
78
|
this.storeState = storeState;
|
|
126
79
|
this.event = event;
|
|
127
80
|
this.trigger = trigger;
|
|
128
81
|
}
|
|
129
|
-
/**
|
|
130
|
-
* @return {?}
|
|
131
|
-
*/
|
|
132
82
|
static get type() {
|
|
133
83
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
134
84
|
return '[Router] RouterError';
|
|
135
85
|
}
|
|
136
86
|
}
|
|
137
|
-
if (false) {
|
|
138
|
-
/** @type {?} */
|
|
139
|
-
RouterError.prototype.routerState;
|
|
140
|
-
/** @type {?} */
|
|
141
|
-
RouterError.prototype.storeState;
|
|
142
|
-
/** @type {?} */
|
|
143
|
-
RouterError.prototype.event;
|
|
144
|
-
/** @type {?} */
|
|
145
|
-
RouterError.prototype.trigger;
|
|
146
|
-
}
|
|
147
87
|
/**
|
|
148
88
|
* An action dispatched when the `ResolveEnd` event is triggered.
|
|
149
|
-
* @template T
|
|
150
89
|
*/
|
|
151
90
|
class RouterDataResolved {
|
|
152
|
-
/**
|
|
153
|
-
* @param {?} routerState
|
|
154
|
-
* @param {?} event
|
|
155
|
-
* @param {?=} trigger
|
|
156
|
-
*/
|
|
157
91
|
constructor(routerState, event, trigger = 'none') {
|
|
158
92
|
this.routerState = routerState;
|
|
159
93
|
this.event = event;
|
|
160
94
|
this.trigger = trigger;
|
|
161
95
|
}
|
|
162
|
-
/**
|
|
163
|
-
* @return {?}
|
|
164
|
-
*/
|
|
165
96
|
static get type() {
|
|
166
97
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
167
98
|
return '[Router] RouterDataResolved';
|
|
168
99
|
}
|
|
169
100
|
}
|
|
170
|
-
if (false) {
|
|
171
|
-
/** @type {?} */
|
|
172
|
-
RouterDataResolved.prototype.routerState;
|
|
173
|
-
/** @type {?} */
|
|
174
|
-
RouterDataResolved.prototype.event;
|
|
175
|
-
/** @type {?} */
|
|
176
|
-
RouterDataResolved.prototype.trigger;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
101
|
/**
|
|
180
|
-
*
|
|
181
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
102
|
+
* An action dispatched when the router navigation has been finished successfully.
|
|
182
103
|
*/
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
* @return {?}
|
|
194
|
-
*/
|
|
195
|
-
RouterStateSerializer.prototype.serialize = function (routerState) { };
|
|
104
|
+
class RouterNavigated {
|
|
105
|
+
constructor(routerState, event, trigger = 'none') {
|
|
106
|
+
this.routerState = routerState;
|
|
107
|
+
this.event = event;
|
|
108
|
+
this.trigger = trigger;
|
|
109
|
+
}
|
|
110
|
+
static get type() {
|
|
111
|
+
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
112
|
+
return '[Router] RouterNavigated';
|
|
113
|
+
}
|
|
196
114
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
*/
|
|
200
|
-
function SerializedRouterStateSnapshot() { }
|
|
201
|
-
if (false) {
|
|
202
|
-
/** @type {?} */
|
|
203
|
-
SerializedRouterStateSnapshot.prototype.root;
|
|
204
|
-
/** @type {?} */
|
|
205
|
-
SerializedRouterStateSnapshot.prototype.url;
|
|
115
|
+
|
|
116
|
+
class RouterStateSerializer {
|
|
206
117
|
}
|
|
207
118
|
class DefaultRouterStateSerializer {
|
|
208
|
-
/**
|
|
209
|
-
* @param {?} routerState
|
|
210
|
-
* @return {?}
|
|
211
|
-
*/
|
|
212
119
|
serialize(routerState) {
|
|
213
120
|
return {
|
|
214
121
|
root: this.serializeRoute(routerState.root),
|
|
215
122
|
url: routerState.url
|
|
216
123
|
};
|
|
217
124
|
}
|
|
218
|
-
/**
|
|
219
|
-
* @private
|
|
220
|
-
* @param {?} route
|
|
221
|
-
* @return {?}
|
|
222
|
-
*/
|
|
223
125
|
serializeRoute(route) {
|
|
224
|
-
|
|
225
|
-
const children = route.children.map((/**
|
|
226
|
-
* @param {?} c
|
|
227
|
-
* @return {?}
|
|
228
|
-
*/
|
|
229
|
-
c => this.serializeRoute(c)));
|
|
126
|
+
const children = route.children.map(c => this.serializeRoute(c));
|
|
230
127
|
return {
|
|
231
128
|
url: route.url,
|
|
232
129
|
params: route.params,
|
|
@@ -236,11 +133,11 @@ class DefaultRouterStateSerializer {
|
|
|
236
133
|
outlet: route.outlet,
|
|
237
134
|
component: null,
|
|
238
135
|
routeConfig: null,
|
|
239
|
-
root:
|
|
136
|
+
root: null,
|
|
240
137
|
parent: null,
|
|
241
138
|
firstChild: children[0],
|
|
242
139
|
children: children,
|
|
243
|
-
pathFromRoot:
|
|
140
|
+
pathFromRoot: null,
|
|
244
141
|
paramMap: route.paramMap,
|
|
245
142
|
queryParamMap: route.queryParamMap,
|
|
246
143
|
toString: route.toString
|
|
@@ -248,28 +145,17 @@ class DefaultRouterStateSerializer {
|
|
|
248
145
|
}
|
|
249
146
|
}
|
|
250
147
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
*/
|
|
256
|
-
|
|
257
|
-
if (false) {
|
|
258
|
-
/** @type {?|undefined} */
|
|
259
|
-
RouterStateModel.prototype.state;
|
|
260
|
-
/** @type {?|undefined} */
|
|
261
|
-
RouterStateModel.prototype.navigationId;
|
|
262
|
-
/** @type {?} */
|
|
263
|
-
RouterStateModel.prototype.trigger;
|
|
148
|
+
const USER_OPTIONS = new InjectionToken('USER_OPTIONS', { providedIn: 'root', factory: () => undefined });
|
|
149
|
+
const NGXS_ROUTER_PLUGIN_OPTIONS = new InjectionToken('NGXS_ROUTER_PLUGIN_OPTIONS', { providedIn: 'root', factory: () => ({}) });
|
|
150
|
+
function createRouterPluginOptions(options) {
|
|
151
|
+
return {
|
|
152
|
+
navigationActionTiming: (options && options.navigationActionTiming) || 1 /* PreActivation */
|
|
153
|
+
};
|
|
264
154
|
}
|
|
155
|
+
|
|
156
|
+
var RouterState_1;
|
|
265
157
|
let RouterState = RouterState_1 = class RouterState {
|
|
266
|
-
|
|
267
|
-
* @param {?} _store
|
|
268
|
-
* @param {?} _router
|
|
269
|
-
* @param {?} _serializer
|
|
270
|
-
* @param {?} _ngZone
|
|
271
|
-
*/
|
|
272
|
-
constructor(_store, _router, _serializer, _ngZone) {
|
|
158
|
+
constructor(_store, _router, _serializer, _ngZone, injector) {
|
|
273
159
|
this._store = _store;
|
|
274
160
|
this._router = _router;
|
|
275
161
|
this._serializer = _serializer;
|
|
@@ -287,189 +173,129 @@ let RouterState = RouterState_1 = class RouterState {
|
|
|
287
173
|
* That's the value of the `RouterState` state
|
|
288
174
|
*/
|
|
289
175
|
this._storeState = null;
|
|
290
|
-
this.
|
|
176
|
+
this._lastEvent = null;
|
|
291
177
|
this._subscription = new Subscription();
|
|
292
|
-
this.
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
*/
|
|
178
|
+
this._options = null;
|
|
179
|
+
// Note: do not use `@Inject` since it fails on lower versions of Angular with Jest
|
|
180
|
+
// integration, it cannot resolve the token provider.
|
|
181
|
+
this._options = injector.get(NGXS_ROUTER_PLUGIN_OPTIONS, null);
|
|
182
|
+
this._setUpStoreListener();
|
|
183
|
+
this._setUpRouterEventsListener();
|
|
184
|
+
}
|
|
300
185
|
static state(state) {
|
|
301
186
|
return state && state.state;
|
|
302
187
|
}
|
|
303
|
-
/**
|
|
304
|
-
* @param {?} state
|
|
305
|
-
* @return {?}
|
|
306
|
-
*/
|
|
307
188
|
static url(state) {
|
|
308
189
|
return state && state.state && state.state.url;
|
|
309
190
|
}
|
|
310
|
-
/**
|
|
311
|
-
* @return {?}
|
|
312
|
-
*/
|
|
313
191
|
ngOnDestroy() {
|
|
314
192
|
this._subscription.unsubscribe();
|
|
315
193
|
}
|
|
316
|
-
/**
|
|
317
|
-
* @param {?} _
|
|
318
|
-
* @param {?} action
|
|
319
|
-
* @return {?}
|
|
320
|
-
*/
|
|
321
194
|
navigate(_, action) {
|
|
322
|
-
return this._ngZone.run((
|
|
323
|
-
* @return {?}
|
|
324
|
-
*/
|
|
325
|
-
() => this._router.navigate(action.path, Object.assign({ queryParams: action.queryParams }, action.extras))));
|
|
195
|
+
return this._ngZone.run(() => this._router.navigate(action.path, Object.assign({ queryParams: action.queryParams }, action.extras)));
|
|
326
196
|
}
|
|
327
|
-
/**
|
|
328
|
-
* @param {?} ctx
|
|
329
|
-
* @param {?} action
|
|
330
|
-
* @return {?}
|
|
331
|
-
*/
|
|
332
197
|
angularRouterAction(ctx, action) {
|
|
333
|
-
ctx.setState(
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
/** @type {?} */
|
|
198
|
+
ctx.setState({
|
|
199
|
+
trigger: action.trigger,
|
|
200
|
+
state: action.routerState,
|
|
201
|
+
navigationId: action.event.id
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
_setUpStoreListener() {
|
|
341
205
|
const subscription = this._store
|
|
342
206
|
.select(RouterState_1)
|
|
343
|
-
.subscribe((
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
*/
|
|
347
|
-
(state) => {
|
|
348
|
-
this.navigateIfNeeded(state);
|
|
349
|
-
}));
|
|
207
|
+
.subscribe((state) => {
|
|
208
|
+
this._navigateIfNeeded(state);
|
|
209
|
+
});
|
|
350
210
|
this._subscription.add(subscription);
|
|
351
211
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
212
|
+
_navigateIfNeeded(routerState) {
|
|
213
|
+
if (routerState && routerState.trigger === 'devtools') {
|
|
214
|
+
this._storeState = this._store.selectSnapshot(RouterState_1);
|
|
215
|
+
}
|
|
216
|
+
const canSkipNavigation = !this._storeState ||
|
|
217
|
+
!this._storeState.state ||
|
|
218
|
+
!routerState ||
|
|
219
|
+
routerState.trigger === 'router' ||
|
|
220
|
+
this._router.url === this._storeState.state.url ||
|
|
221
|
+
this._lastEvent instanceof NavigationStart;
|
|
222
|
+
if (canSkipNavigation) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
this._storeState = this._store.selectSnapshot(RouterState_1);
|
|
226
|
+
this._trigger = 'store';
|
|
227
|
+
this._ngZone.run(() => this._router.navigateByUrl(this._storeState.state.url));
|
|
228
|
+
}
|
|
229
|
+
_setUpRouterEventsListener() {
|
|
230
|
+
const dispatchRouterNavigationLate = this._options != null &&
|
|
231
|
+
this._options.navigationActionTiming === 2 /* PostActivation */;
|
|
232
|
+
let lastRoutesRecognized;
|
|
233
|
+
const subscription = this._router.events.subscribe(event => {
|
|
234
|
+
this._lastEvent = event;
|
|
363
235
|
if (event instanceof NavigationStart) {
|
|
364
|
-
this.
|
|
236
|
+
this._navigationStart(event);
|
|
365
237
|
}
|
|
366
238
|
else if (event instanceof RoutesRecognized) {
|
|
367
|
-
|
|
239
|
+
lastRoutesRecognized = event;
|
|
240
|
+
if (!dispatchRouterNavigationLate && this._trigger !== 'store') {
|
|
241
|
+
this._dispatchRouterNavigation(lastRoutesRecognized);
|
|
242
|
+
}
|
|
368
243
|
}
|
|
369
244
|
else if (event instanceof ResolveEnd) {
|
|
370
|
-
this.
|
|
245
|
+
this._dispatchRouterDataResolved(event);
|
|
371
246
|
}
|
|
372
247
|
else if (event instanceof NavigationCancel) {
|
|
373
|
-
this.
|
|
374
|
-
this.
|
|
248
|
+
this._dispatchRouterCancel(event);
|
|
249
|
+
this._reset();
|
|
375
250
|
}
|
|
376
251
|
else if (event instanceof NavigationError) {
|
|
377
|
-
this.
|
|
378
|
-
this.
|
|
252
|
+
this._dispatchRouterError(event);
|
|
253
|
+
this._reset();
|
|
379
254
|
}
|
|
380
255
|
else if (event instanceof NavigationEnd) {
|
|
381
|
-
this.
|
|
382
|
-
|
|
256
|
+
if (this._trigger !== 'store') {
|
|
257
|
+
if (dispatchRouterNavigationLate) {
|
|
258
|
+
this._dispatchRouterNavigation(lastRoutesRecognized);
|
|
259
|
+
}
|
|
260
|
+
this._dispatchRouterNavigated(event);
|
|
261
|
+
}
|
|
262
|
+
this._reset();
|
|
383
263
|
}
|
|
384
|
-
})
|
|
264
|
+
});
|
|
385
265
|
this._subscription.add(subscription);
|
|
386
266
|
}
|
|
387
|
-
/**
|
|
388
|
-
|
|
389
|
-
* @return {?}
|
|
390
|
-
*/
|
|
391
|
-
navigationStart() {
|
|
267
|
+
/** Reacts to `NavigationStart`. */
|
|
268
|
+
_navigationStart(event) {
|
|
392
269
|
this._routerState = this._serializer.serialize(this._router.routerState.snapshot);
|
|
393
270
|
if (this._trigger !== 'none') {
|
|
394
271
|
this._storeState = this._store.selectSnapshot(RouterState_1);
|
|
272
|
+
this._dispatchRouterAction(new RouterRequest(this._routerState, event, this._trigger));
|
|
395
273
|
}
|
|
396
274
|
}
|
|
397
|
-
/**
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
navigationEnd() {
|
|
402
|
-
if (this.shouldDispatchRouterNavigation()) {
|
|
403
|
-
this.dispatchRouterNavigation();
|
|
404
|
-
}
|
|
275
|
+
/** Reacts to `ResolveEnd`. */
|
|
276
|
+
_dispatchRouterDataResolved(event) {
|
|
277
|
+
const routerState = this._serializer.serialize(event.state);
|
|
278
|
+
this._dispatchRouterAction(new RouterDataResolved(routerState, event, this._trigger));
|
|
405
279
|
}
|
|
406
|
-
/**
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
const canSkipNavigation = !this._storeState ||
|
|
426
|
-
!this._storeState.state ||
|
|
427
|
-
!state ||
|
|
428
|
-
state.trigger === 'router' ||
|
|
429
|
-
this._router.url === this._storeState.state.url;
|
|
430
|
-
if (canSkipNavigation) {
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
this._trigger = 'store';
|
|
434
|
-
this._ngZone.run((/**
|
|
435
|
-
* @return {?}
|
|
436
|
-
*/
|
|
437
|
-
() => {
|
|
438
|
-
this._router.navigateByUrl((/** @type {?} */ ((/** @type {?} */ (this._storeState)).state)).url);
|
|
439
|
-
}));
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* @private
|
|
443
|
-
* @return {?}
|
|
444
|
-
*/
|
|
445
|
-
dispatchRouterNavigation() {
|
|
446
|
-
/** @type {?} */
|
|
447
|
-
const nextRouterState = this._serializer.serialize(this._lastRoutesRecognized.state);
|
|
448
|
-
this.dispatchRouterAction(new RouterNavigation(nextRouterState, new RoutesRecognized(this._lastRoutesRecognized.id, this._lastRoutesRecognized.url, this._lastRoutesRecognized.urlAfterRedirects, nextRouterState), this._trigger));
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* @private
|
|
452
|
-
* @param {?} event
|
|
453
|
-
* @return {?}
|
|
454
|
-
*/
|
|
455
|
-
dispatchRouterCancel(event) {
|
|
456
|
-
this.dispatchRouterAction(new RouterCancel((/** @type {?} */ (this._routerState)), this._storeState, event, this._trigger));
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* @private
|
|
460
|
-
* @param {?} event
|
|
461
|
-
* @return {?}
|
|
462
|
-
*/
|
|
463
|
-
dispatchRouterError(event) {
|
|
464
|
-
this.dispatchRouterAction(new RouterError((/** @type {?} */ (this._routerState)), this._storeState, new NavigationError(event.id, event.url, `${event}`), this._trigger));
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* @private
|
|
468
|
-
* @template T
|
|
469
|
-
* @param {?} action
|
|
470
|
-
* @return {?}
|
|
471
|
-
*/
|
|
472
|
-
dispatchRouterAction(action) {
|
|
280
|
+
/** Reacts to `RoutesRecognized` or `NavigationEnd`, depends on the `navigationActionTiming`. */
|
|
281
|
+
_dispatchRouterNavigation(lastRoutesRecognized) {
|
|
282
|
+
const nextRouterState = this._serializer.serialize(lastRoutesRecognized.state);
|
|
283
|
+
this._dispatchRouterAction(new RouterNavigation(nextRouterState, new RoutesRecognized(lastRoutesRecognized.id, lastRoutesRecognized.url, lastRoutesRecognized.urlAfterRedirects, nextRouterState), this._trigger));
|
|
284
|
+
}
|
|
285
|
+
/** Reacts to `NavigationCancel`. */
|
|
286
|
+
_dispatchRouterCancel(event) {
|
|
287
|
+
this._dispatchRouterAction(new RouterCancel(this._routerState, this._storeState, event, this._trigger));
|
|
288
|
+
}
|
|
289
|
+
/** Reacts to `NavigationEnd`. */
|
|
290
|
+
_dispatchRouterError(event) {
|
|
291
|
+
this._dispatchRouterAction(new RouterError(this._routerState, this._storeState, new NavigationError(event.id, event.url, `${event}`), this._trigger));
|
|
292
|
+
}
|
|
293
|
+
/** Reacts to `NavigationEnd`. */
|
|
294
|
+
_dispatchRouterNavigated(event) {
|
|
295
|
+
const routerState = this._serializer.serialize(this._router.routerState.snapshot);
|
|
296
|
+
this._dispatchRouterAction(new RouterNavigated(routerState, event, this._trigger));
|
|
297
|
+
}
|
|
298
|
+
_dispatchRouterAction(action) {
|
|
473
299
|
this._trigger = 'router';
|
|
474
300
|
try {
|
|
475
301
|
this._store.dispatch(action);
|
|
@@ -478,42 +304,14 @@ let RouterState = RouterState_1 = class RouterState {
|
|
|
478
304
|
this._trigger = 'none';
|
|
479
305
|
}
|
|
480
306
|
}
|
|
481
|
-
|
|
482
|
-
* @private
|
|
483
|
-
* @param {?} event
|
|
484
|
-
* @return {?}
|
|
485
|
-
*/
|
|
486
|
-
dispatchRouterDataResolved(event) {
|
|
487
|
-
/** @type {?} */
|
|
488
|
-
const routerState = this._serializer.serialize(event.state);
|
|
489
|
-
this.dispatchRouterAction(new RouterDataResolved(routerState, event, this._trigger));
|
|
490
|
-
}
|
|
491
|
-
/**
|
|
492
|
-
* @private
|
|
493
|
-
* @return {?}
|
|
494
|
-
*/
|
|
495
|
-
reset() {
|
|
307
|
+
_reset() {
|
|
496
308
|
this._trigger = 'none';
|
|
497
309
|
this._storeState = null;
|
|
498
310
|
this._routerState = null;
|
|
499
311
|
}
|
|
500
312
|
};
|
|
501
|
-
RouterState
|
|
502
|
-
|
|
503
|
-
{ type: Router },
|
|
504
|
-
{ type: RouterStateSerializer },
|
|
505
|
-
{ type: NgZone }
|
|
506
|
-
];
|
|
507
|
-
RouterState.decorators = [
|
|
508
|
-
{ type: Injectable }
|
|
509
|
-
];
|
|
510
|
-
/** @nocollapse */
|
|
511
|
-
RouterState.ctorParameters = () => [
|
|
512
|
-
{ type: Store },
|
|
513
|
-
{ type: Router },
|
|
514
|
-
{ type: RouterStateSerializer },
|
|
515
|
-
{ type: NgZone }
|
|
516
|
-
];
|
|
313
|
+
/** @nocollapse */ RouterState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RouterState, deps: [{ token: i1.Store }, { token: i2.Router }, { token: RouterStateSerializer }, { token: i0.NgZone }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
314
|
+
/** @nocollapse */ RouterState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RouterState });
|
|
517
315
|
__decorate([
|
|
518
316
|
Action(Navigate),
|
|
519
317
|
__metadata("design:type", Function),
|
|
@@ -521,7 +319,14 @@ __decorate([
|
|
|
521
319
|
__metadata("design:returntype", void 0)
|
|
522
320
|
], RouterState.prototype, "navigate", null);
|
|
523
321
|
__decorate([
|
|
524
|
-
Action([
|
|
322
|
+
Action([
|
|
323
|
+
RouterRequest,
|
|
324
|
+
RouterNavigation,
|
|
325
|
+
RouterError,
|
|
326
|
+
RouterCancel,
|
|
327
|
+
RouterDataResolved,
|
|
328
|
+
RouterNavigated
|
|
329
|
+
]),
|
|
525
330
|
__metadata("design:type", Function),
|
|
526
331
|
__metadata("design:paramtypes", [Object, Object]),
|
|
527
332
|
__metadata("design:returntype", void 0)
|
|
@@ -550,95 +355,46 @@ RouterState = RouterState_1 = __decorate([
|
|
|
550
355
|
__metadata("design:paramtypes", [Store,
|
|
551
356
|
Router,
|
|
552
357
|
RouterStateSerializer,
|
|
553
|
-
NgZone
|
|
358
|
+
NgZone,
|
|
359
|
+
Injector])
|
|
554
360
|
], RouterState);
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
* or outside via `new Navigate(...)`
|
|
559
|
-
* @type {?}
|
|
560
|
-
* @private
|
|
561
|
-
*/
|
|
562
|
-
RouterState.prototype._trigger;
|
|
563
|
-
/**
|
|
564
|
-
* That's the serialized state from the `Router` class
|
|
565
|
-
* @type {?}
|
|
566
|
-
* @private
|
|
567
|
-
*/
|
|
568
|
-
RouterState.prototype._routerState;
|
|
569
|
-
/**
|
|
570
|
-
* That's the value of the `RouterState` state
|
|
571
|
-
* @type {?}
|
|
572
|
-
* @private
|
|
573
|
-
*/
|
|
574
|
-
RouterState.prototype._storeState;
|
|
575
|
-
/**
|
|
576
|
-
* @type {?}
|
|
577
|
-
* @private
|
|
578
|
-
*/
|
|
579
|
-
RouterState.prototype._lastRoutesRecognized;
|
|
580
|
-
/**
|
|
581
|
-
* @type {?}
|
|
582
|
-
* @private
|
|
583
|
-
*/
|
|
584
|
-
RouterState.prototype._subscription;
|
|
585
|
-
/**
|
|
586
|
-
* @type {?}
|
|
587
|
-
* @private
|
|
588
|
-
*/
|
|
589
|
-
RouterState.prototype._store;
|
|
590
|
-
/**
|
|
591
|
-
* @type {?}
|
|
592
|
-
* @private
|
|
593
|
-
*/
|
|
594
|
-
RouterState.prototype._router;
|
|
595
|
-
/**
|
|
596
|
-
* @type {?}
|
|
597
|
-
* @private
|
|
598
|
-
*/
|
|
599
|
-
RouterState.prototype._serializer;
|
|
600
|
-
/**
|
|
601
|
-
* @type {?}
|
|
602
|
-
* @private
|
|
603
|
-
*/
|
|
604
|
-
RouterState.prototype._ngZone;
|
|
605
|
-
}
|
|
361
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RouterState, decorators: [{
|
|
362
|
+
type: Injectable
|
|
363
|
+
}], ctorParameters: function () { return [{ type: i1.Store }, { type: i2.Router }, { type: RouterStateSerializer }, { type: i0.NgZone }, { type: i0.Injector }]; }, propDecorators: { navigate: [], angularRouterAction: [] } });
|
|
606
364
|
|
|
607
|
-
/**
|
|
608
|
-
* @fileoverview added by tsickle
|
|
609
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
610
|
-
*/
|
|
611
365
|
class NgxsRouterPluginModule {
|
|
612
|
-
|
|
613
|
-
* @return {?}
|
|
614
|
-
*/
|
|
615
|
-
static forRoot() {
|
|
366
|
+
static forRoot(options) {
|
|
616
367
|
return {
|
|
617
368
|
ngModule: NgxsRouterPluginModule,
|
|
618
|
-
providers: [
|
|
369
|
+
providers: [
|
|
370
|
+
{ provide: USER_OPTIONS, useValue: options },
|
|
371
|
+
{
|
|
372
|
+
provide: NGXS_ROUTER_PLUGIN_OPTIONS,
|
|
373
|
+
useFactory: createRouterPluginOptions,
|
|
374
|
+
deps: [USER_OPTIONS]
|
|
375
|
+
},
|
|
376
|
+
{ provide: RouterStateSerializer, useClass: DefaultRouterStateSerializer }
|
|
377
|
+
]
|
|
619
378
|
};
|
|
620
379
|
}
|
|
621
380
|
}
|
|
622
|
-
NgxsRouterPluginModule
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
*/
|
|
381
|
+
/** @nocollapse */ NgxsRouterPluginModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRouterPluginModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
382
|
+
/** @nocollapse */ NgxsRouterPluginModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRouterPluginModule, imports: [i1.ɵNgxsFeatureModule] });
|
|
383
|
+
/** @nocollapse */ NgxsRouterPluginModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRouterPluginModule, imports: [[NgxsModule.forFeature([RouterState])]] });
|
|
384
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsRouterPluginModule, decorators: [{
|
|
385
|
+
type: NgModule,
|
|
386
|
+
args: [{
|
|
387
|
+
imports: [NgxsModule.forFeature([RouterState])]
|
|
388
|
+
}]
|
|
389
|
+
}] });
|
|
632
390
|
|
|
633
391
|
/**
|
|
634
|
-
*
|
|
635
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
392
|
+
* The public api for consumers of @ngxs/router-plugin
|
|
636
393
|
*/
|
|
637
394
|
|
|
638
395
|
/**
|
|
639
|
-
*
|
|
640
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
396
|
+
* Generated bundle index. Do not edit.
|
|
641
397
|
*/
|
|
642
398
|
|
|
643
|
-
export { DefaultRouterStateSerializer, Navigate, NgxsRouterPluginModule, RouterCancel, RouterDataResolved, RouterError, RouterNavigation, RouterState, RouterStateSerializer };
|
|
399
|
+
export { DefaultRouterStateSerializer, Navigate, NgxsRouterPluginModule, RouterCancel, RouterDataResolved, RouterError, RouterNavigated, RouterNavigation, RouterRequest, RouterState, RouterStateSerializer };
|
|
644
400
|
//# sourceMappingURL=ngxs-router-plugin.js.map
|