@ngxs/router-plugin 3.8.1 → 3.8.2-dev.master-a75608e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/esm2020/internals/index.mjs +2 -0
  2. package/esm2020/internals/ngxs-router-plugin-internals.mjs +5 -0
  3. package/esm2020/internals/symbols.mjs +10 -0
  4. package/esm2020/src/public_api.mjs +5 -0
  5. package/esm2020/src/router.actions.mjs +85 -0
  6. package/esm2020/src/router.module.mjs +45 -0
  7. package/esm2020/src/router.state.mjs +224 -0
  8. package/esm2020/src/serializer.mjs +33 -0
  9. package/fesm2015/ngxs-router-plugin-internals.mjs +17 -0
  10. package/fesm2015/ngxs-router-plugin-internals.mjs.map +1 -0
  11. package/fesm2015/{ngxs-router-plugin.js → ngxs-router-plugin.mjs} +46 -62
  12. package/fesm2015/ngxs-router-plugin.mjs.map +1 -0
  13. package/fesm2020/ngxs-router-plugin-internals.mjs +17 -0
  14. package/fesm2020/ngxs-router-plugin-internals.mjs.map +1 -0
  15. package/fesm2020/ngxs-router-plugin.mjs +387 -0
  16. package/fesm2020/ngxs-router-plugin.mjs.map +1 -0
  17. package/internals/index.d.ts +1 -0
  18. package/internals/symbols.d.ts +11 -0
  19. package/package.json +34 -14
  20. package/src/public_api.d.ts +2 -2
  21. package/src/router.actions.d.ts +7 -7
  22. package/src/router.module.d.ts +3 -2
  23. package/src/router.state.d.ts +1 -1
  24. package/bundles/ngxs-router-plugin.umd.js +0 -815
  25. package/bundles/ngxs-router-plugin.umd.js.map +0 -1
  26. package/esm2015/src/public_api.js +0 -5
  27. package/esm2015/src/router.actions.js +0 -106
  28. package/esm2015/src/router.module.js +0 -33
  29. package/esm2015/src/router.state.js +0 -222
  30. package/esm2015/src/serializer.js +0 -32
  31. package/esm2015/src/symbols.js +0 -9
  32. package/fesm2015/ngxs-router-plugin.js.map +0 -1
  33. package/ngxs-router-plugin.d.ts +0 -5
  34. package/src/symbols.d.ts +0 -11
  35. /package/{esm2015/index.js → esm2020/index.mjs} +0 -0
  36. /package/{esm2015/ngxs-router-plugin.js → esm2020/ngxs-router-plugin.mjs} +0 -0
@@ -1,815 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@ngxs/store'), require('@angular/router'), require('rxjs')) :
3
- typeof define === 'function' && define.amd ? define('@ngxs/router-plugin', ['exports', '@angular/core', '@ngxs/store', '@angular/router', 'rxjs'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ngxs = global.ngxs || {}, global.ngxs["router-plugin"] = {}), global.ng.core, global["ngxs-store"], global.ng.router, global.rxjs));
5
- })(this, (function (exports, i0, i1, i2, rxjs) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () { return e[k]; }
17
- });
18
- }
19
- });
20
- }
21
- n["default"] = e;
22
- return Object.freeze(n);
23
- }
24
-
25
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
26
- var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
27
- var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
28
-
29
- /******************************************************************************
30
- Copyright (c) Microsoft Corporation.
31
-
32
- Permission to use, copy, modify, and/or distribute this software for any
33
- purpose with or without fee is hereby granted.
34
-
35
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
36
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
37
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
38
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
39
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
40
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
41
- PERFORMANCE OF THIS SOFTWARE.
42
- ***************************************************************************** */
43
- /* global Reflect, Promise */
44
- var extendStatics = function (d, b) {
45
- extendStatics = Object.setPrototypeOf ||
46
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
47
- function (d, b) { for (var p in b)
48
- if (Object.prototype.hasOwnProperty.call(b, p))
49
- d[p] = b[p]; };
50
- return extendStatics(d, b);
51
- };
52
- function __extends(d, b) {
53
- if (typeof b !== "function" && b !== null)
54
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
55
- extendStatics(d, b);
56
- function __() { this.constructor = d; }
57
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
58
- }
59
- var __assign = function () {
60
- __assign = Object.assign || function __assign(t) {
61
- for (var s, i = 1, n = arguments.length; i < n; i++) {
62
- s = arguments[i];
63
- for (var p in s)
64
- if (Object.prototype.hasOwnProperty.call(s, p))
65
- t[p] = s[p];
66
- }
67
- return t;
68
- };
69
- return __assign.apply(this, arguments);
70
- };
71
- function __rest(s, e) {
72
- var t = {};
73
- for (var p in s)
74
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
75
- t[p] = s[p];
76
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
77
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
78
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
79
- t[p[i]] = s[p[i]];
80
- }
81
- return t;
82
- }
83
- function __decorate(decorators, target, key, desc) {
84
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
85
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
86
- r = Reflect.decorate(decorators, target, key, desc);
87
- else
88
- for (var i = decorators.length - 1; i >= 0; i--)
89
- if (d = decorators[i])
90
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
91
- return c > 3 && r && Object.defineProperty(target, key, r), r;
92
- }
93
- function __param(paramIndex, decorator) {
94
- return function (target, key) { decorator(target, key, paramIndex); };
95
- }
96
- function __metadata(metadataKey, metadataValue) {
97
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
98
- return Reflect.metadata(metadataKey, metadataValue);
99
- }
100
- function __awaiter(thisArg, _arguments, P, generator) {
101
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
102
- return new (P || (P = Promise))(function (resolve, reject) {
103
- function fulfilled(value) { try {
104
- step(generator.next(value));
105
- }
106
- catch (e) {
107
- reject(e);
108
- } }
109
- function rejected(value) { try {
110
- step(generator["throw"](value));
111
- }
112
- catch (e) {
113
- reject(e);
114
- } }
115
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
116
- step((generator = generator.apply(thisArg, _arguments || [])).next());
117
- });
118
- }
119
- function __generator(thisArg, body) {
120
- var _ = { label: 0, sent: function () { if (t[0] & 1)
121
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
122
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
123
- function verb(n) { return function (v) { return step([n, v]); }; }
124
- function step(op) {
125
- if (f)
126
- throw new TypeError("Generator is already executing.");
127
- while (g && (g = 0, op[0] && (_ = 0)), _)
128
- try {
129
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
130
- return t;
131
- if (y = 0, t)
132
- op = [op[0] & 2, t.value];
133
- switch (op[0]) {
134
- case 0:
135
- case 1:
136
- t = op;
137
- break;
138
- case 4:
139
- _.label++;
140
- return { value: op[1], done: false };
141
- case 5:
142
- _.label++;
143
- y = op[1];
144
- op = [0];
145
- continue;
146
- case 7:
147
- op = _.ops.pop();
148
- _.trys.pop();
149
- continue;
150
- default:
151
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
152
- _ = 0;
153
- continue;
154
- }
155
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
156
- _.label = op[1];
157
- break;
158
- }
159
- if (op[0] === 6 && _.label < t[1]) {
160
- _.label = t[1];
161
- t = op;
162
- break;
163
- }
164
- if (t && _.label < t[2]) {
165
- _.label = t[2];
166
- _.ops.push(op);
167
- break;
168
- }
169
- if (t[2])
170
- _.ops.pop();
171
- _.trys.pop();
172
- continue;
173
- }
174
- op = body.call(thisArg, _);
175
- }
176
- catch (e) {
177
- op = [6, e];
178
- y = 0;
179
- }
180
- finally {
181
- f = t = 0;
182
- }
183
- if (op[0] & 5)
184
- throw op[1];
185
- return { value: op[0] ? op[1] : void 0, done: true };
186
- }
187
- }
188
- var __createBinding = Object.create ? (function (o, m, k, k2) {
189
- if (k2 === undefined)
190
- k2 = k;
191
- var desc = Object.getOwnPropertyDescriptor(m, k);
192
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
193
- desc = { enumerable: true, get: function () { return m[k]; } };
194
- }
195
- Object.defineProperty(o, k2, desc);
196
- }) : (function (o, m, k, k2) {
197
- if (k2 === undefined)
198
- k2 = k;
199
- o[k2] = m[k];
200
- });
201
- function __exportStar(m, o) {
202
- for (var p in m)
203
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
204
- __createBinding(o, m, p);
205
- }
206
- function __values(o) {
207
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
208
- if (m)
209
- return m.call(o);
210
- if (o && typeof o.length === "number")
211
- return {
212
- next: function () {
213
- if (o && i >= o.length)
214
- o = void 0;
215
- return { value: o && o[i++], done: !o };
216
- }
217
- };
218
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
219
- }
220
- function __read(o, n) {
221
- var m = typeof Symbol === "function" && o[Symbol.iterator];
222
- if (!m)
223
- return o;
224
- var i = m.call(o), r, ar = [], e;
225
- try {
226
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
227
- ar.push(r.value);
228
- }
229
- catch (error) {
230
- e = { error: error };
231
- }
232
- finally {
233
- try {
234
- if (r && !r.done && (m = i["return"]))
235
- m.call(i);
236
- }
237
- finally {
238
- if (e)
239
- throw e.error;
240
- }
241
- }
242
- return ar;
243
- }
244
- /** @deprecated */
245
- function __spread() {
246
- for (var ar = [], i = 0; i < arguments.length; i++)
247
- ar = ar.concat(__read(arguments[i]));
248
- return ar;
249
- }
250
- /** @deprecated */
251
- function __spreadArrays() {
252
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
253
- s += arguments[i].length;
254
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
255
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
256
- r[k] = a[j];
257
- return r;
258
- }
259
- function __spreadArray(to, from, pack) {
260
- if (pack || arguments.length === 2)
261
- for (var i = 0, l = from.length, ar; i < l; i++) {
262
- if (ar || !(i in from)) {
263
- if (!ar)
264
- ar = Array.prototype.slice.call(from, 0, i);
265
- ar[i] = from[i];
266
- }
267
- }
268
- return to.concat(ar || Array.prototype.slice.call(from));
269
- }
270
- function __await(v) {
271
- return this instanceof __await ? (this.v = v, this) : new __await(v);
272
- }
273
- function __asyncGenerator(thisArg, _arguments, generator) {
274
- if (!Symbol.asyncIterator)
275
- throw new TypeError("Symbol.asyncIterator is not defined.");
276
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
277
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
278
- function verb(n) { if (g[n])
279
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
280
- function resume(n, v) { try {
281
- step(g[n](v));
282
- }
283
- catch (e) {
284
- settle(q[0][3], e);
285
- } }
286
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
287
- function fulfill(value) { resume("next", value); }
288
- function reject(value) { resume("throw", value); }
289
- function settle(f, v) { if (f(v), q.shift(), q.length)
290
- resume(q[0][0], q[0][1]); }
291
- }
292
- function __asyncDelegator(o) {
293
- var i, p;
294
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
295
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
296
- }
297
- function __asyncValues(o) {
298
- if (!Symbol.asyncIterator)
299
- throw new TypeError("Symbol.asyncIterator is not defined.");
300
- var m = o[Symbol.asyncIterator], i;
301
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
302
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
303
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
304
- }
305
- function __makeTemplateObject(cooked, raw) {
306
- if (Object.defineProperty) {
307
- Object.defineProperty(cooked, "raw", { value: raw });
308
- }
309
- else {
310
- cooked.raw = raw;
311
- }
312
- return cooked;
313
- }
314
- ;
315
- var __setModuleDefault = Object.create ? (function (o, v) {
316
- Object.defineProperty(o, "default", { enumerable: true, value: v });
317
- }) : function (o, v) {
318
- o["default"] = v;
319
- };
320
- function __importStar(mod) {
321
- if (mod && mod.__esModule)
322
- return mod;
323
- var result = {};
324
- if (mod != null)
325
- for (var k in mod)
326
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
327
- __createBinding(result, mod, k);
328
- __setModuleDefault(result, mod);
329
- return result;
330
- }
331
- function __importDefault(mod) {
332
- return (mod && mod.__esModule) ? mod : { default: mod };
333
- }
334
- function __classPrivateFieldGet(receiver, state, kind, f) {
335
- if (kind === "a" && !f)
336
- throw new TypeError("Private accessor was defined without a getter");
337
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
338
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
339
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
340
- }
341
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
342
- if (kind === "m")
343
- throw new TypeError("Private method is not writable");
344
- if (kind === "a" && !f)
345
- throw new TypeError("Private accessor was defined without a setter");
346
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
347
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
348
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
349
- }
350
- function __classPrivateFieldIn(state, receiver) {
351
- if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
352
- throw new TypeError("Cannot use 'in' operator on non-object");
353
- return typeof state === "function" ? receiver === state : state.has(receiver);
354
- }
355
-
356
- /**
357
- * Public event api of the router
358
- */
359
- var Navigate = /** @class */ (function () {
360
- function Navigate(path, queryParams, extras) {
361
- this.path = path;
362
- this.queryParams = queryParams;
363
- this.extras = extras;
364
- }
365
- Object.defineProperty(Navigate, "type", {
366
- get: function () {
367
- // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
368
- return '[Router] Navigate';
369
- },
370
- enumerable: false,
371
- configurable: true
372
- });
373
- return Navigate;
374
- }());
375
- /**
376
- *
377
- * Angular Routers internal state events
378
- *
379
- */
380
- /**
381
- * An action dispatched when the router starts the navigation.
382
- */
383
- var RouterRequest = /** @class */ (function () {
384
- function RouterRequest(routerState, event, trigger) {
385
- if (trigger === void 0) { trigger = 'none'; }
386
- this.routerState = routerState;
387
- this.event = event;
388
- this.trigger = trigger;
389
- }
390
- Object.defineProperty(RouterRequest, "type", {
391
- get: function () {
392
- // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
393
- return '[Router] RouterRequest';
394
- },
395
- enumerable: false,
396
- configurable: true
397
- });
398
- return RouterRequest;
399
- }());
400
- /**
401
- * An action dispatched when the router navigates.
402
- */
403
- var RouterNavigation = /** @class */ (function () {
404
- function RouterNavigation(routerState, event, trigger) {
405
- if (trigger === void 0) { trigger = 'none'; }
406
- this.routerState = routerState;
407
- this.event = event;
408
- this.trigger = trigger;
409
- }
410
- Object.defineProperty(RouterNavigation, "type", {
411
- get: function () {
412
- // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
413
- return '[Router] RouterNavigation';
414
- },
415
- enumerable: false,
416
- configurable: true
417
- });
418
- return RouterNavigation;
419
- }());
420
- /**
421
- * An action dispatched when the router cancel navigation.
422
- */
423
- var RouterCancel = /** @class */ (function () {
424
- function RouterCancel(routerState, storeState, event, trigger) {
425
- if (trigger === void 0) { trigger = 'none'; }
426
- this.routerState = routerState;
427
- this.storeState = storeState;
428
- this.event = event;
429
- this.trigger = trigger;
430
- }
431
- Object.defineProperty(RouterCancel, "type", {
432
- get: function () {
433
- // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
434
- return '[Router] RouterCancel';
435
- },
436
- enumerable: false,
437
- configurable: true
438
- });
439
- return RouterCancel;
440
- }());
441
- /**
442
- * An action dispatched when the router errors.
443
- */
444
- var RouterError = /** @class */ (function () {
445
- function RouterError(routerState, storeState, event, trigger) {
446
- if (trigger === void 0) { trigger = 'none'; }
447
- this.routerState = routerState;
448
- this.storeState = storeState;
449
- this.event = event;
450
- this.trigger = trigger;
451
- }
452
- Object.defineProperty(RouterError, "type", {
453
- get: function () {
454
- // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
455
- return '[Router] RouterError';
456
- },
457
- enumerable: false,
458
- configurable: true
459
- });
460
- return RouterError;
461
- }());
462
- /**
463
- * An action dispatched when the `ResolveEnd` event is triggered.
464
- */
465
- var RouterDataResolved = /** @class */ (function () {
466
- function RouterDataResolved(routerState, event, trigger) {
467
- if (trigger === void 0) { trigger = 'none'; }
468
- this.routerState = routerState;
469
- this.event = event;
470
- this.trigger = trigger;
471
- }
472
- Object.defineProperty(RouterDataResolved, "type", {
473
- get: function () {
474
- // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
475
- return '[Router] RouterDataResolved';
476
- },
477
- enumerable: false,
478
- configurable: true
479
- });
480
- return RouterDataResolved;
481
- }());
482
- /**
483
- * An action dispatched when the router navigation has been finished successfully.
484
- */
485
- var RouterNavigated = /** @class */ (function () {
486
- function RouterNavigated(routerState, event, trigger) {
487
- if (trigger === void 0) { trigger = 'none'; }
488
- this.routerState = routerState;
489
- this.event = event;
490
- this.trigger = trigger;
491
- }
492
- Object.defineProperty(RouterNavigated, "type", {
493
- get: function () {
494
- // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
495
- return '[Router] RouterNavigated';
496
- },
497
- enumerable: false,
498
- configurable: true
499
- });
500
- return RouterNavigated;
501
- }());
502
-
503
- var RouterStateSerializer = /** @class */ (function () {
504
- function RouterStateSerializer() {
505
- }
506
- return RouterStateSerializer;
507
- }());
508
- var DefaultRouterStateSerializer = /** @class */ (function () {
509
- function DefaultRouterStateSerializer() {
510
- }
511
- DefaultRouterStateSerializer.prototype.serialize = function (routerState) {
512
- return {
513
- root: this.serializeRoute(routerState.root),
514
- url: routerState.url
515
- };
516
- };
517
- DefaultRouterStateSerializer.prototype.serializeRoute = function (route) {
518
- var _this = this;
519
- var children = route.children.map(function (c) { return _this.serializeRoute(c); });
520
- return {
521
- url: route.url,
522
- params: route.params,
523
- queryParams: route.queryParams,
524
- fragment: route.fragment,
525
- data: route.data,
526
- outlet: route.outlet,
527
- component: null,
528
- routeConfig: null,
529
- root: null,
530
- parent: null,
531
- firstChild: children[0],
532
- children: children,
533
- pathFromRoot: null,
534
- paramMap: route.paramMap,
535
- queryParamMap: route.queryParamMap,
536
- toString: route.toString
537
- };
538
- };
539
- return DefaultRouterStateSerializer;
540
- }());
541
-
542
- var USER_OPTIONS = new i0.InjectionToken('USER_OPTIONS', { providedIn: 'root', factory: function () { return undefined; } });
543
- var NGXS_ROUTER_PLUGIN_OPTIONS = new i0.InjectionToken('NGXS_ROUTER_PLUGIN_OPTIONS', { providedIn: 'root', factory: function () { return ({}); } });
544
- function createRouterPluginOptions(options) {
545
- return {
546
- navigationActionTiming: (options && options.navigationActionTiming) || 1 /* PreActivation */
547
- };
548
- }
549
-
550
- var RouterState_1;
551
- exports.RouterState = RouterState_1 = /** @class */ (function () {
552
- function RouterState(_store, _router, _serializer, _ngZone, injector) {
553
- this._store = _store;
554
- this._router = _router;
555
- this._serializer = _serializer;
556
- this._ngZone = _ngZone;
557
- /**
558
- * Determines how navigation was performed by the `RouterState` itself
559
- * or outside via `new Navigate(...)`
560
- */
561
- this._trigger = 'none';
562
- /**
563
- * That's the serialized state from the `Router` class
564
- */
565
- this._routerState = null;
566
- /**
567
- * That's the value of the `RouterState` state
568
- */
569
- this._storeState = null;
570
- this._lastEvent = null;
571
- this._subscription = new rxjs.Subscription();
572
- this._options = null;
573
- // Note: do not use `@Inject` since it fails on lower versions of Angular with Jest
574
- // integration, it cannot resolve the token provider.
575
- this._options = injector.get(NGXS_ROUTER_PLUGIN_OPTIONS, null);
576
- this._setUpStoreListener();
577
- this._setUpRouterEventsListener();
578
- }
579
- RouterState.state = function (state) {
580
- return state && state.state;
581
- };
582
- RouterState.url = function (state) {
583
- return state && state.state && state.state.url;
584
- };
585
- RouterState.prototype.ngOnDestroy = function () {
586
- this._subscription.unsubscribe();
587
- };
588
- RouterState.prototype.navigate = function (_, action) {
589
- var _this = this;
590
- return this._ngZone.run(function () { return _this._router.navigate(action.path, Object.assign({ queryParams: action.queryParams }, action.extras)); });
591
- };
592
- RouterState.prototype.angularRouterAction = function (ctx, action) {
593
- ctx.setState({
594
- trigger: action.trigger,
595
- state: action.routerState,
596
- navigationId: action.event.id
597
- });
598
- };
599
- RouterState.prototype._setUpStoreListener = function () {
600
- var _this = this;
601
- var subscription = this._store
602
- .select(RouterState_1)
603
- .subscribe(function (state) {
604
- _this._navigateIfNeeded(state);
605
- });
606
- this._subscription.add(subscription);
607
- };
608
- RouterState.prototype._navigateIfNeeded = function (routerState) {
609
- var _this = this;
610
- if (routerState && routerState.trigger === 'devtools') {
611
- this._storeState = this._store.selectSnapshot(RouterState_1);
612
- }
613
- var canSkipNavigation = !this._storeState ||
614
- !this._storeState.state ||
615
- !routerState ||
616
- routerState.trigger === 'router' ||
617
- this._router.url === this._storeState.state.url ||
618
- this._lastEvent instanceof i2.NavigationStart;
619
- if (canSkipNavigation) {
620
- return;
621
- }
622
- this._storeState = this._store.selectSnapshot(RouterState_1);
623
- this._trigger = 'store';
624
- this._ngZone.run(function () { return _this._router.navigateByUrl(_this._storeState.state.url); });
625
- };
626
- RouterState.prototype._setUpRouterEventsListener = function () {
627
- var _this = this;
628
- var dispatchRouterNavigationLate = this._options != null &&
629
- this._options.navigationActionTiming === 2 /* PostActivation */;
630
- var lastRoutesRecognized;
631
- var subscription = this._router.events.subscribe(function (event) {
632
- _this._lastEvent = event;
633
- if (event instanceof i2.NavigationStart) {
634
- _this._navigationStart(event);
635
- }
636
- else if (event instanceof i2.RoutesRecognized) {
637
- lastRoutesRecognized = event;
638
- if (!dispatchRouterNavigationLate && _this._trigger !== 'store') {
639
- _this._dispatchRouterNavigation(lastRoutesRecognized);
640
- }
641
- }
642
- else if (event instanceof i2.ResolveEnd) {
643
- _this._dispatchRouterDataResolved(event);
644
- }
645
- else if (event instanceof i2.NavigationCancel) {
646
- _this._dispatchRouterCancel(event);
647
- _this._reset();
648
- }
649
- else if (event instanceof i2.NavigationError) {
650
- _this._dispatchRouterError(event);
651
- _this._reset();
652
- }
653
- else if (event instanceof i2.NavigationEnd) {
654
- if (_this._trigger !== 'store') {
655
- if (dispatchRouterNavigationLate) {
656
- _this._dispatchRouterNavigation(lastRoutesRecognized);
657
- }
658
- _this._dispatchRouterNavigated(event);
659
- }
660
- _this._reset();
661
- }
662
- });
663
- this._subscription.add(subscription);
664
- };
665
- /** Reacts to `NavigationStart`. */
666
- RouterState.prototype._navigationStart = function (event) {
667
- this._routerState = this._serializer.serialize(this._router.routerState.snapshot);
668
- if (this._trigger !== 'none') {
669
- this._storeState = this._store.selectSnapshot(RouterState_1);
670
- this._dispatchRouterAction(new RouterRequest(this._routerState, event, this._trigger));
671
- }
672
- };
673
- /** Reacts to `ResolveEnd`. */
674
- RouterState.prototype._dispatchRouterDataResolved = function (event) {
675
- var routerState = this._serializer.serialize(event.state);
676
- this._dispatchRouterAction(new RouterDataResolved(routerState, event, this._trigger));
677
- };
678
- /** Reacts to `RoutesRecognized` or `NavigationEnd`, depends on the `navigationActionTiming`. */
679
- RouterState.prototype._dispatchRouterNavigation = function (lastRoutesRecognized) {
680
- var nextRouterState = this._serializer.serialize(lastRoutesRecognized.state);
681
- this._dispatchRouterAction(new RouterNavigation(nextRouterState, new i2.RoutesRecognized(lastRoutesRecognized.id, lastRoutesRecognized.url, lastRoutesRecognized.urlAfterRedirects, nextRouterState), this._trigger));
682
- };
683
- /** Reacts to `NavigationCancel`. */
684
- RouterState.prototype._dispatchRouterCancel = function (event) {
685
- this._dispatchRouterAction(new RouterCancel(this._routerState, this._storeState, event, this._trigger));
686
- };
687
- /** Reacts to `NavigationEnd`. */
688
- RouterState.prototype._dispatchRouterError = function (event) {
689
- this._dispatchRouterAction(new RouterError(this._routerState, this._storeState, new i2.NavigationError(event.id, event.url, "" + event), this._trigger));
690
- };
691
- /** Reacts to `NavigationEnd`. */
692
- RouterState.prototype._dispatchRouterNavigated = function (event) {
693
- var routerState = this._serializer.serialize(this._router.routerState.snapshot);
694
- this._dispatchRouterAction(new RouterNavigated(routerState, event, this._trigger));
695
- };
696
- RouterState.prototype._dispatchRouterAction = function (action) {
697
- this._trigger = 'router';
698
- try {
699
- this._store.dispatch(action);
700
- }
701
- finally {
702
- this._trigger = 'none';
703
- }
704
- };
705
- RouterState.prototype._reset = function () {
706
- this._trigger = 'none';
707
- this._storeState = null;
708
- this._routerState = null;
709
- };
710
- return RouterState;
711
- }());
712
- /** @nocollapse */ exports.RouterState.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: exports.RouterState, deps: [{ token: i1__namespace.Store }, { token: i2__namespace.Router }, { token: RouterStateSerializer }, { token: i0__namespace.NgZone }, { token: i0__namespace.Injector }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
713
- /** @nocollapse */ exports.RouterState.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: exports.RouterState });
714
- __decorate([
715
- i1.Action(Navigate),
716
- __metadata("design:type", Function),
717
- __metadata("design:paramtypes", [Object, Navigate]),
718
- __metadata("design:returntype", void 0)
719
- ], exports.RouterState.prototype, "navigate", null);
720
- __decorate([
721
- i1.Action([
722
- RouterRequest,
723
- RouterNavigation,
724
- RouterError,
725
- RouterCancel,
726
- RouterDataResolved,
727
- RouterNavigated
728
- ]),
729
- __metadata("design:type", Function),
730
- __metadata("design:paramtypes", [Object, Object]),
731
- __metadata("design:returntype", void 0)
732
- ], exports.RouterState.prototype, "angularRouterAction", null);
733
- __decorate([
734
- i1.Selector(),
735
- __metadata("design:type", Function),
736
- __metadata("design:paramtypes", [Object]),
737
- __metadata("design:returntype", void 0)
738
- ], exports.RouterState, "state", null);
739
- __decorate([
740
- i1.Selector(),
741
- __metadata("design:type", Function),
742
- __metadata("design:paramtypes", [Object]),
743
- __metadata("design:returntype", Object)
744
- ], exports.RouterState, "url", null);
745
- exports.RouterState = RouterState_1 = __decorate([
746
- i1.State({
747
- name: 'router',
748
- defaults: {
749
- state: undefined,
750
- navigationId: undefined,
751
- trigger: 'none'
752
- }
753
- }),
754
- __metadata("design:paramtypes", [i1.Store,
755
- i2.Router,
756
- RouterStateSerializer,
757
- i0.NgZone,
758
- i0.Injector])
759
- ], exports.RouterState);
760
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: exports.RouterState, decorators: [{
761
- type: i0.Injectable
762
- }], ctorParameters: function () { return [{ type: i1__namespace.Store }, { type: i2__namespace.Router }, { type: RouterStateSerializer }, { type: i0__namespace.NgZone }, { type: i0__namespace.Injector }]; }, propDecorators: { navigate: [], angularRouterAction: [] } });
763
-
764
- var NgxsRouterPluginModule = /** @class */ (function () {
765
- function NgxsRouterPluginModule() {
766
- }
767
- NgxsRouterPluginModule.forRoot = function (options) {
768
- return {
769
- ngModule: NgxsRouterPluginModule,
770
- providers: [
771
- { provide: USER_OPTIONS, useValue: options },
772
- {
773
- provide: NGXS_ROUTER_PLUGIN_OPTIONS,
774
- useFactory: createRouterPluginOptions,
775
- deps: [USER_OPTIONS]
776
- },
777
- { provide: RouterStateSerializer, useClass: DefaultRouterStateSerializer }
778
- ]
779
- };
780
- };
781
- return NgxsRouterPluginModule;
782
- }());
783
- /** @nocollapse */ NgxsRouterPluginModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsRouterPluginModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
784
- /** @nocollapse */ NgxsRouterPluginModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsRouterPluginModule, imports: [i1__namespace.ɵNgxsFeatureModule] });
785
- /** @nocollapse */ NgxsRouterPluginModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsRouterPluginModule, imports: [[i1.NgxsModule.forFeature([exports.RouterState])]] });
786
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsRouterPluginModule, decorators: [{
787
- type: i0.NgModule,
788
- args: [{
789
- imports: [i1.NgxsModule.forFeature([exports.RouterState])]
790
- }]
791
- }] });
792
-
793
- /**
794
- * The public api for consumers of @ngxs/router-plugin
795
- */
796
-
797
- /**
798
- * Generated bundle index. Do not edit.
799
- */
800
-
801
- exports.DefaultRouterStateSerializer = DefaultRouterStateSerializer;
802
- exports.Navigate = Navigate;
803
- exports.NgxsRouterPluginModule = NgxsRouterPluginModule;
804
- exports.RouterCancel = RouterCancel;
805
- exports.RouterDataResolved = RouterDataResolved;
806
- exports.RouterError = RouterError;
807
- exports.RouterNavigated = RouterNavigated;
808
- exports.RouterNavigation = RouterNavigation;
809
- exports.RouterRequest = RouterRequest;
810
- exports.RouterStateSerializer = RouterStateSerializer;
811
-
812
- Object.defineProperty(exports, '__esModule', { value: true });
813
-
814
- }));
815
- //# sourceMappingURL=ngxs-router-plugin.umd.js.map