1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators')) :
|
3 | typeof define === 'function' && define.amd ? define('@ngrx/store', ['exports', '@angular/core', 'rxjs', 'rxjs/operators'], factory) :
|
4 | (global = global || self, factory((global.ngrx = global.ngrx || {}, global.ngrx.store = {}), global.ng.core, global.rxjs, global.rxjs.operators));
|
5 | }(this, (function (exports, ngCore, rxjs, operators) { 'use strict';
|
6 |
|
7 | |
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | var extendStatics = function (d, b) {
|
23 | extendStatics = Object.setPrototypeOf ||
|
24 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
25 | function (d, b) { for (var p in b)
|
26 | if (b.hasOwnProperty(p))
|
27 | d[p] = b[p]; };
|
28 | return extendStatics(d, b);
|
29 | };
|
30 | function __extends(d, b) {
|
31 | extendStatics(d, b);
|
32 | function __() { this.constructor = d; }
|
33 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
34 | }
|
35 | var __assign = function () {
|
36 | __assign = Object.assign || function __assign(t) {
|
37 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
38 | s = arguments[i];
|
39 | for (var p in s)
|
40 | if (Object.prototype.hasOwnProperty.call(s, p))
|
41 | t[p] = s[p];
|
42 | }
|
43 | return t;
|
44 | };
|
45 | return __assign.apply(this, arguments);
|
46 | };
|
47 | function __rest(s, e) {
|
48 | var t = {};
|
49 | for (var p in s)
|
50 | if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
51 | t[p] = s[p];
|
52 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
53 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
54 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
55 | t[p[i]] = s[p[i]];
|
56 | }
|
57 | return t;
|
58 | }
|
59 | function __decorate(decorators, target, key, desc) {
|
60 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
61 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
62 | r = Reflect.decorate(decorators, target, key, desc);
|
63 | else
|
64 | for (var i = decorators.length - 1; i >= 0; i--)
|
65 | if (d = decorators[i])
|
66 | r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
67 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
68 | }
|
69 | function __param(paramIndex, decorator) {
|
70 | return function (target, key) { decorator(target, key, paramIndex); };
|
71 | }
|
72 | function __metadata(metadataKey, metadataValue) {
|
73 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
74 | return Reflect.metadata(metadataKey, metadataValue);
|
75 | }
|
76 | function __awaiter(thisArg, _arguments, P, generator) {
|
77 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
78 | return new (P || (P = Promise))(function (resolve, reject) {
|
79 | function fulfilled(value) { try {
|
80 | step(generator.next(value));
|
81 | }
|
82 | catch (e) {
|
83 | reject(e);
|
84 | } }
|
85 | function rejected(value) { try {
|
86 | step(generator["throw"](value));
|
87 | }
|
88 | catch (e) {
|
89 | reject(e);
|
90 | } }
|
91 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
92 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
93 | });
|
94 | }
|
95 | function __generator(thisArg, body) {
|
96 | var _ = { label: 0, sent: function () { if (t[0] & 1)
|
97 | throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
98 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
99 | function verb(n) { return function (v) { return step([n, v]); }; }
|
100 | function step(op) {
|
101 | if (f)
|
102 | throw new TypeError("Generator is already executing.");
|
103 | while (_)
|
104 | try {
|
105 | 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)
|
106 | return t;
|
107 | if (y = 0, t)
|
108 | op = [op[0] & 2, t.value];
|
109 | switch (op[0]) {
|
110 | case 0:
|
111 | case 1:
|
112 | t = op;
|
113 | break;
|
114 | case 4:
|
115 | _.label++;
|
116 | return { value: op[1], done: false };
|
117 | case 5:
|
118 | _.label++;
|
119 | y = op[1];
|
120 | op = [0];
|
121 | continue;
|
122 | case 7:
|
123 | op = _.ops.pop();
|
124 | _.trys.pop();
|
125 | continue;
|
126 | default:
|
127 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
128 | _ = 0;
|
129 | continue;
|
130 | }
|
131 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
132 | _.label = op[1];
|
133 | break;
|
134 | }
|
135 | if (op[0] === 6 && _.label < t[1]) {
|
136 | _.label = t[1];
|
137 | t = op;
|
138 | break;
|
139 | }
|
140 | if (t && _.label < t[2]) {
|
141 | _.label = t[2];
|
142 | _.ops.push(op);
|
143 | break;
|
144 | }
|
145 | if (t[2])
|
146 | _.ops.pop();
|
147 | _.trys.pop();
|
148 | continue;
|
149 | }
|
150 | op = body.call(thisArg, _);
|
151 | }
|
152 | catch (e) {
|
153 | op = [6, e];
|
154 | y = 0;
|
155 | }
|
156 | finally {
|
157 | f = t = 0;
|
158 | }
|
159 | if (op[0] & 5)
|
160 | throw op[1];
|
161 | return { value: op[0] ? op[1] : void 0, done: true };
|
162 | }
|
163 | }
|
164 | var __createBinding = Object.create ? (function (o, m, k, k2) {
|
165 | if (k2 === undefined)
|
166 | k2 = k;
|
167 | Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
168 | }) : (function (o, m, k, k2) {
|
169 | if (k2 === undefined)
|
170 | k2 = k;
|
171 | o[k2] = m[k];
|
172 | });
|
173 | function __exportStar(m, exports) {
|
174 | for (var p in m)
|
175 | if (p !== "default" && !exports.hasOwnProperty(p))
|
176 | __createBinding(exports, m, p);
|
177 | }
|
178 | function __values(o) {
|
179 | var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
180 | if (m)
|
181 | return m.call(o);
|
182 | if (o && typeof o.length === "number")
|
183 | return {
|
184 | next: function () {
|
185 | if (o && i >= o.length)
|
186 | o = void 0;
|
187 | return { value: o && o[i++], done: !o };
|
188 | }
|
189 | };
|
190 | throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
191 | }
|
192 | function __read(o, n) {
|
193 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
194 | if (!m)
|
195 | return o;
|
196 | var i = m.call(o), r, ar = [], e;
|
197 | try {
|
198 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
199 | ar.push(r.value);
|
200 | }
|
201 | catch (error) {
|
202 | e = { error: error };
|
203 | }
|
204 | finally {
|
205 | try {
|
206 | if (r && !r.done && (m = i["return"]))
|
207 | m.call(i);
|
208 | }
|
209 | finally {
|
210 | if (e)
|
211 | throw e.error;
|
212 | }
|
213 | }
|
214 | return ar;
|
215 | }
|
216 | function __spread() {
|
217 | for (var ar = [], i = 0; i < arguments.length; i++)
|
218 | ar = ar.concat(__read(arguments[i]));
|
219 | return ar;
|
220 | }
|
221 | function __spreadArrays() {
|
222 | for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
223 | s += arguments[i].length;
|
224 | for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
225 | for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
226 | r[k] = a[j];
|
227 | return r;
|
228 | }
|
229 | ;
|
230 | function __await(v) {
|
231 | return this instanceof __await ? (this.v = v, this) : new __await(v);
|
232 | }
|
233 | function __asyncGenerator(thisArg, _arguments, generator) {
|
234 | if (!Symbol.asyncIterator)
|
235 | throw new TypeError("Symbol.asyncIterator is not defined.");
|
236 | var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
237 | return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
238 | function verb(n) { if (g[n])
|
239 | i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
240 | function resume(n, v) { try {
|
241 | step(g[n](v));
|
242 | }
|
243 | catch (e) {
|
244 | settle(q[0][3], e);
|
245 | } }
|
246 | function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
247 | function fulfill(value) { resume("next", value); }
|
248 | function reject(value) { resume("throw", value); }
|
249 | function settle(f, v) { if (f(v), q.shift(), q.length)
|
250 | resume(q[0][0], q[0][1]); }
|
251 | }
|
252 | function __asyncDelegator(o) {
|
253 | var i, p;
|
254 | return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
255 | 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; }
|
256 | }
|
257 | function __asyncValues(o) {
|
258 | if (!Symbol.asyncIterator)
|
259 | throw new TypeError("Symbol.asyncIterator is not defined.");
|
260 | var m = o[Symbol.asyncIterator], i;
|
261 | 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);
|
262 | 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); }); }; }
|
263 | function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
264 | }
|
265 | function __makeTemplateObject(cooked, raw) {
|
266 | if (Object.defineProperty) {
|
267 | Object.defineProperty(cooked, "raw", { value: raw });
|
268 | }
|
269 | else {
|
270 | cooked.raw = raw;
|
271 | }
|
272 | return cooked;
|
273 | }
|
274 | ;
|
275 | var __setModuleDefault = Object.create ? (function (o, v) {
|
276 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
277 | }) : function (o, v) {
|
278 | o["default"] = v;
|
279 | };
|
280 | function __importStar(mod) {
|
281 | if (mod && mod.__esModule)
|
282 | return mod;
|
283 | var result = {};
|
284 | if (mod != null)
|
285 | for (var k in mod)
|
286 | if (Object.hasOwnProperty.call(mod, k))
|
287 | __createBinding(result, mod, k);
|
288 | __setModuleDefault(result, mod);
|
289 | return result;
|
290 | }
|
291 | function __importDefault(mod) {
|
292 | return (mod && mod.__esModule) ? mod : { default: mod };
|
293 | }
|
294 | function __classPrivateFieldGet(receiver, privateMap) {
|
295 | if (!privateMap.has(receiver)) {
|
296 | throw new TypeError("attempted to get private field on non-instance");
|
297 | }
|
298 | return privateMap.get(receiver);
|
299 | }
|
300 | function __classPrivateFieldSet(receiver, privateMap, value) {
|
301 | if (!privateMap.has(receiver)) {
|
302 | throw new TypeError("attempted to set private field on non-instance");
|
303 | }
|
304 | privateMap.set(receiver, value);
|
305 | return value;
|
306 | }
|
307 |
|
308 | |
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 | var REGISTERED_ACTION_TYPES = {};
|
315 | |
316 |
|
317 |
|
318 | function resetRegisteredActionTypes() {
|
319 | var e_1, _a;
|
320 | try {
|
321 | for (var _b = __values(Object.keys(REGISTERED_ACTION_TYPES)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
322 | var key = _c.value;
|
323 | delete REGISTERED_ACTION_TYPES[key];
|
324 | }
|
325 | }
|
326 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
327 | finally {
|
328 | try {
|
329 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
330 | }
|
331 | finally { if (e_1) throw e_1.error; }
|
332 | }
|
333 | }
|
334 |
|
335 | |
336 |
|
337 |
|
338 |
|
339 |
|
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 |
|
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 | function createAction(type, config) {
|
410 | REGISTERED_ACTION_TYPES[type] = (REGISTERED_ACTION_TYPES[type] || 0) + 1;
|
411 | if (typeof config === 'function') {
|
412 | return defineType(type, ( |
413 |
|
414 |
|
415 | function () {
|
416 | var args = [];
|
417 | for (var _i = 0; _i < arguments.length; _i++) {
|
418 | args[_i] = arguments[_i];
|
419 | }
|
420 | return (Object.assign(Object.assign({}, config.apply(void 0, __spread(args))), { type: type }));
|
421 | }));
|
422 | }
|
423 |
|
424 | var as = config ? config._as : 'empty';
|
425 | switch (as) {
|
426 | case 'empty':
|
427 | return defineType(type, ( |
428 |
|
429 | function () { return ({ type: type }); }));
|
430 | case 'props':
|
431 | return defineType(type, ( |
432 |
|
433 |
|
434 | function (props) { return (Object.assign(Object.assign({}, props), { type: type })); }));
|
435 | default:
|
436 | throw new Error('Unexpected config.');
|
437 | }
|
438 | }
|
439 | |
440 |
|
441 |
|
442 |
|
443 | function props() {
|
444 | return { _as: 'props', _p: ( (undefined)) };
|
445 | }
|
446 | |
447 |
|
448 |
|
449 |
|
450 |
|
451 | function union(creators) {
|
452 | return ( (undefined));
|
453 | }
|
454 | |
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 | function defineType(type, creator) {
|
461 | return Object.defineProperty(creator, 'type', {
|
462 | value: type,
|
463 | writable: false,
|
464 | });
|
465 | }
|
466 |
|
467 |
|
468 | var INIT = ( ('@ngrx/store/init'));
|
469 | var ActionsSubject = (function (_super) {
|
470 | __extends(ActionsSubject, _super);
|
471 | function ActionsSubject() {
|
472 | return _super.call(this, { type: INIT }) || this;
|
473 | }
|
474 | |
475 |
|
476 |
|
477 |
|
478 | ActionsSubject.prototype.next = function (action) {
|
479 | if (typeof action === 'function') {
|
480 | throw new TypeError("\n Dispatch expected an object, instead it received a function.\n If you're using the createAction function, make sure to invoke the function\n before dispatching the action. For example, someAction should be someAction().");
|
481 | }
|
482 | else if (typeof action === 'undefined') {
|
483 | throw new TypeError("Actions must be objects");
|
484 | }
|
485 | else if (typeof action.type === 'undefined') {
|
486 | throw new TypeError("Actions must have a type property");
|
487 | }
|
488 | _super.prototype.next.call(this, action);
|
489 | };
|
490 | |
491 |
|
492 |
|
493 | ActionsSubject.prototype.complete = function () {
|
494 |
|
495 | };
|
496 | |
497 |
|
498 |
|
499 | ActionsSubject.prototype.ngOnDestroy = function () {
|
500 | _super.prototype.complete.call(this);
|
501 | };
|
502 | return ActionsSubject;
|
503 | }(rxjs.BehaviorSubject));
|
504 | ActionsSubject.decorators = [
|
505 | { type: ngCore.Injectable }
|
506 | ];
|
507 |
|
508 | ActionsSubject.ctorParameters = function () { return []; };
|
509 |
|
510 | var ACTIONS_SUBJECT_PROVIDERS = [ActionsSubject];
|
511 |
|
512 | |
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 | var _ROOT_STORE_GUARD = new ngCore.InjectionToken('@ngrx/store Internal Root Guard');
|
519 |
|
520 | var _INITIAL_STATE = new ngCore.InjectionToken('@ngrx/store Internal Initial State');
|
521 |
|
522 | var INITIAL_STATE = new ngCore.InjectionToken('@ngrx/store Initial State');
|
523 |
|
524 | var REDUCER_FACTORY = new ngCore.InjectionToken('@ngrx/store Reducer Factory');
|
525 |
|
526 | var _REDUCER_FACTORY = new ngCore.InjectionToken('@ngrx/store Internal Reducer Factory Provider');
|
527 |
|
528 | var INITIAL_REDUCERS = new ngCore.InjectionToken('@ngrx/store Initial Reducers');
|
529 |
|
530 | var _INITIAL_REDUCERS = new ngCore.InjectionToken('@ngrx/store Internal Initial Reducers');
|
531 |
|
532 | var STORE_FEATURES = new ngCore.InjectionToken('@ngrx/store Store Features');
|
533 |
|
534 | var _STORE_REDUCERS = new ngCore.InjectionToken('@ngrx/store Internal Store Reducers');
|
535 |
|
536 | var _FEATURE_REDUCERS = new ngCore.InjectionToken('@ngrx/store Internal Feature Reducers');
|
537 |
|
538 | var _FEATURE_CONFIGS = new ngCore.InjectionToken('@ngrx/store Internal Feature Configs');
|
539 |
|
540 | var _STORE_FEATURES = new ngCore.InjectionToken('@ngrx/store Internal Store Features');
|
541 |
|
542 | var _FEATURE_REDUCERS_TOKEN = new ngCore.InjectionToken('@ngrx/store Internal Feature Reducers Token');
|
543 |
|
544 | var FEATURE_REDUCERS = new ngCore.InjectionToken('@ngrx/store Feature Reducers');
|
545 | |
546 |
|
547 |
|
548 |
|
549 | var USER_PROVIDED_META_REDUCERS = new ngCore.InjectionToken('@ngrx/store User Provided Meta Reducers');
|
550 | |
551 |
|
552 |
|
553 |
|
554 | var META_REDUCERS = new ngCore.InjectionToken('@ngrx/store Meta Reducers');
|
555 | |
556 |
|
557 |
|
558 |
|
559 |
|
560 | var _RESOLVED_META_REDUCERS = new ngCore.InjectionToken('@ngrx/store Internal Resolved Meta Reducers');
|
561 | |
562 |
|
563 |
|
564 |
|
565 |
|
566 | var USER_RUNTIME_CHECKS = new ngCore.InjectionToken('@ngrx/store User Runtime Checks Config');
|
567 | |
568 |
|
569 |
|
570 |
|
571 | var _USER_RUNTIME_CHECKS = new ngCore.InjectionToken('@ngrx/store Internal User Runtime Checks Config');
|
572 | |
573 |
|
574 |
|
575 |
|
576 | var _ACTIVE_RUNTIME_CHECKS = new ngCore.InjectionToken('@ngrx/store Internal Runtime Checks');
|
577 |
|
578 | var _ACTION_TYPE_UNIQUENESS_CHECK = new ngCore.InjectionToken('@ngrx/store Check if Action types are unique');
|
579 |
|
580 | |
581 |
|
582 |
|
583 |
|
584 |
|
585 | |
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 |
|
602 |
|
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 | function combineReducers(reducers, initialState) {
|
619 | if (initialState === void 0) { initialState = {}; }
|
620 |
|
621 | var reducerKeys = Object.keys(reducers);
|
622 |
|
623 | var finalReducers = {};
|
624 | for (var i = 0; i < reducerKeys.length; i++) {
|
625 |
|
626 | var key = reducerKeys[i];
|
627 | if (typeof reducers[key] === 'function') {
|
628 | finalReducers[key] = reducers[key];
|
629 | }
|
630 | }
|
631 |
|
632 | var finalReducerKeys = Object.keys(finalReducers);
|
633 | return ( |
634 |
|
635 |
|
636 |
|
637 | function combination(state, action) {
|
638 | state = state === undefined ? initialState : state;
|
639 |
|
640 | var hasChanged = false;
|
641 |
|
642 | var nextState = {};
|
643 | for (var i = 0; i < finalReducerKeys.length; i++) {
|
644 |
|
645 | var key = finalReducerKeys[i];
|
646 |
|
647 | var reducer = finalReducers[key];
|
648 |
|
649 | var previousStateForKey = state[key];
|
650 |
|
651 | var nextStateForKey = reducer(previousStateForKey, action);
|
652 | nextState[key] = nextStateForKey;
|
653 | hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
654 | }
|
655 | return hasChanged ? nextState : state;
|
656 | });
|
657 | }
|
658 | |
659 |
|
660 |
|
661 |
|
662 |
|
663 |
|
664 | function omit(object, keyToRemove) {
|
665 | return Object.keys(object)
|
666 | .filter(( |
667 |
|
668 |
|
669 | function (key) { return key !== keyToRemove; }))
|
670 | .reduce(( |
671 |
|
672 |
|
673 |
|
674 | function (result, key) {
|
675 | var _a;
|
676 | return Object.assign(result, (_a = {}, _a[key] = object[key], _a));
|
677 | }), {});
|
678 | }
|
679 | |
680 |
|
681 |
|
682 |
|
683 | function compose() {
|
684 | var functions = [];
|
685 | for (var _i = 0; _i < arguments.length; _i++) {
|
686 | functions[_i] = arguments[_i];
|
687 | }
|
688 | return ( |
689 |
|
690 |
|
691 | function (arg) {
|
692 | if (functions.length === 0) {
|
693 | return arg;
|
694 | }
|
695 |
|
696 | var last = functions[functions.length - 1];
|
697 |
|
698 | var rest = functions.slice(0, -1);
|
699 | return rest.reduceRight(( |
700 |
|
701 |
|
702 |
|
703 | function (composed, fn) { return fn(composed); }), last(arg));
|
704 | });
|
705 | }
|
706 | |
707 |
|
708 |
|
709 |
|
710 |
|
711 |
|
712 | function createReducerFactory(reducerFactory, metaReducers) {
|
713 | if (Array.isArray(metaReducers) && metaReducers.length > 0) {
|
714 | (( (reducerFactory))) = compose.apply(null, __spread(metaReducers, [
|
715 | reducerFactory,
|
716 | ]));
|
717 | }
|
718 | return ( |
719 |
|
720 |
|
721 |
|
722 | function (reducers, initialState) {
|
723 |
|
724 | var reducer = reducerFactory(reducers);
|
725 | return ( |
726 |
|
727 |
|
728 |
|
729 | function (state, action) {
|
730 | state = state === undefined ? (( (initialState))) : state;
|
731 | return reducer(state, action);
|
732 | });
|
733 | });
|
734 | }
|
735 | |
736 |
|
737 |
|
738 |
|
739 |
|
740 | function createFeatureReducerFactory(metaReducers) {
|
741 |
|
742 | var reducerFactory = Array.isArray(metaReducers) && metaReducers.length > 0
|
743 | ? compose.apply(void 0, __spread(metaReducers)) : ( |
744 |
|
745 |
|
746 | function (r) { return r; });
|
747 | return ( |
748 |
|
749 |
|
750 |
|
751 | function (reducer, initialState) {
|
752 | reducer = reducerFactory(reducer);
|
753 | return ( |
754 |
|
755 |
|
756 |
|
757 | function (state, action) {
|
758 | state = state === undefined ? initialState : state;
|
759 | return reducer(state, action);
|
760 | });
|
761 | });
|
762 | }
|
763 |
|
764 | |
765 |
|
766 |
|
767 | var ReducerObservable = (function (_super) {
|
768 | __extends(ReducerObservable, _super);
|
769 | function ReducerObservable() {
|
770 | return _super !== null && _super.apply(this, arguments) || this;
|
771 | }
|
772 | return ReducerObservable;
|
773 | }(rxjs.Observable));
|
774 | |
775 |
|
776 |
|
777 | var ReducerManagerDispatcher = (function (_super) {
|
778 | __extends(ReducerManagerDispatcher, _super);
|
779 | function ReducerManagerDispatcher() {
|
780 | return _super !== null && _super.apply(this, arguments) || this;
|
781 | }
|
782 | return ReducerManagerDispatcher;
|
783 | }(ActionsSubject));
|
784 |
|
785 | var UPDATE = ( ('@ngrx/store/update-reducers'));
|
786 | var ReducerManager = (function (_super) {
|
787 | __extends(ReducerManager, _super);
|
788 | |
789 |
|
790 |
|
791 |
|
792 |
|
793 |
|
794 | function ReducerManager(dispatcher, initialState, reducers, reducerFactory) {
|
795 | var _this = _super.call(this, reducerFactory(reducers, initialState)) || this;
|
796 | _this.dispatcher = dispatcher;
|
797 | _this.initialState = initialState;
|
798 | _this.reducers = reducers;
|
799 | _this.reducerFactory = reducerFactory;
|
800 | return _this;
|
801 | }
|
802 | |
803 |
|
804 |
|
805 |
|
806 | ReducerManager.prototype.addFeature = function (feature) {
|
807 | this.addFeatures([feature]);
|
808 | };
|
809 | |
810 |
|
811 |
|
812 |
|
813 | ReducerManager.prototype.addFeatures = function (features) {
|
814 |
|
815 | var reducers = features.reduce(( |
816 |
|
817 |
|
818 |
|
819 | function (reducerDict, _a) {
|
820 | var reducers = _a.reducers, reducerFactory = _a.reducerFactory, metaReducers = _a.metaReducers, initialState = _a.initialState, key = _a.key;
|
821 |
|
822 | var reducer = typeof reducers === 'function'
|
823 | ? createFeatureReducerFactory(metaReducers)(reducers, initialState)
|
824 | : createReducerFactory(reducerFactory, metaReducers)(reducers, initialState);
|
825 | reducerDict[key] = reducer;
|
826 | return reducerDict;
|
827 | }), ( ({})));
|
828 | this.addReducers(reducers);
|
829 | };
|
830 | |
831 |
|
832 |
|
833 |
|
834 | ReducerManager.prototype.removeFeature = function (feature) {
|
835 | this.removeFeatures([feature]);
|
836 | };
|
837 | |
838 |
|
839 |
|
840 |
|
841 | ReducerManager.prototype.removeFeatures = function (features) {
|
842 | this.removeReducers(features.map(( |
843 |
|
844 |
|
845 | function (p) { return p.key; })));
|
846 | };
|
847 | |
848 |
|
849 |
|
850 |
|
851 |
|
852 | ReducerManager.prototype.addReducer = function (key, reducer) {
|
853 | var _a;
|
854 | this.addReducers((_a = {}, _a[key] = reducer, _a));
|
855 | };
|
856 | |
857 |
|
858 |
|
859 |
|
860 | ReducerManager.prototype.addReducers = function (reducers) {
|
861 | this.reducers = Object.assign(Object.assign({}, this.reducers), reducers);
|
862 | this.updateReducers(Object.keys(reducers));
|
863 | };
|
864 | |
865 |
|
866 |
|
867 |
|
868 | ReducerManager.prototype.removeReducer = function (featureKey) {
|
869 | this.removeReducers([featureKey]);
|
870 | };
|
871 | |
872 |
|
873 |
|
874 |
|
875 | ReducerManager.prototype.removeReducers = function (featureKeys) {
|
876 | var _this = this;
|
877 | featureKeys.forEach(( |
878 |
|
879 |
|
880 | function (key) {
|
881 | _this.reducers = ( (omit(_this.reducers, key) ));
|
882 | }));
|
883 | this.updateReducers(featureKeys);
|
884 | };
|
885 | |
886 |
|
887 |
|
888 |
|
889 |
|
890 | ReducerManager.prototype.updateReducers = function (featureKeys) {
|
891 | this.next(this.reducerFactory(this.reducers, this.initialState));
|
892 | this.dispatcher.next(( ({
|
893 | type: UPDATE,
|
894 | features: featureKeys,
|
895 | })));
|
896 | };
|
897 | |
898 |
|
899 |
|
900 | ReducerManager.prototype.ngOnDestroy = function () {
|
901 | this.complete();
|
902 | };
|
903 | return ReducerManager;
|
904 | }(rxjs.BehaviorSubject));
|
905 | ReducerManager.decorators = [
|
906 | { type: ngCore.Injectable }
|
907 | ];
|
908 |
|
909 | ReducerManager.ctorParameters = function () { return [
|
910 | { type: ReducerManagerDispatcher },
|
911 | { type: undefined, decorators: [{ type: ngCore.Inject, args: [INITIAL_STATE,] }] },
|
912 | { type: undefined, decorators: [{ type: ngCore.Inject, args: [INITIAL_REDUCERS,] }] },
|
913 | { type: undefined, decorators: [{ type: ngCore.Inject, args: [REDUCER_FACTORY,] }] }
|
914 | ]; };
|
915 | if (false) {
|
916 | |
917 |
|
918 |
|
919 |
|
920 | ReducerManager.prototype.dispatcher;
|
921 | |
922 |
|
923 |
|
924 |
|
925 | ReducerManager.prototype.initialState;
|
926 | |
927 |
|
928 |
|
929 |
|
930 | ReducerManager.prototype.reducers;
|
931 | |
932 |
|
933 |
|
934 |
|
935 | ReducerManager.prototype.reducerFactory;
|
936 | }
|
937 |
|
938 | var REDUCER_MANAGER_PROVIDERS = [
|
939 | ReducerManager,
|
940 | { provide: ReducerObservable, useExisting: ReducerManager },
|
941 | { provide: ReducerManagerDispatcher, useExisting: ActionsSubject },
|
942 | ];
|
943 |
|
944 | var ScannedActionsSubject = (function (_super) {
|
945 | __extends(ScannedActionsSubject, _super);
|
946 | function ScannedActionsSubject() {
|
947 | return _super !== null && _super.apply(this, arguments) || this;
|
948 | }
|
949 | |
950 |
|
951 |
|
952 | ScannedActionsSubject.prototype.ngOnDestroy = function () {
|
953 | this.complete();
|
954 | };
|
955 | return ScannedActionsSubject;
|
956 | }(rxjs.Subject));
|
957 | ScannedActionsSubject.decorators = [
|
958 | { type: ngCore.Injectable }
|
959 | ];
|
960 |
|
961 | var SCANNED_ACTIONS_SUBJECT_PROVIDERS = [
|
962 | ScannedActionsSubject,
|
963 | ];
|
964 |
|
965 | |
966 |
|
967 |
|
968 | var StateObservable = (function (_super) {
|
969 | __extends(StateObservable, _super);
|
970 | function StateObservable() {
|
971 | return _super !== null && _super.apply(this, arguments) || this;
|
972 | }
|
973 | return StateObservable;
|
974 | }(rxjs.Observable));
|
975 | |
976 |
|
977 |
|
978 | var State = (function (_super) {
|
979 | __extends(State, _super);
|
980 | |
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 | function State(actions$, reducer$, scannedActions, initialState) {
|
987 | var _this = _super.call(this, initialState) || this;
|
988 |
|
989 | var actionsOnQueue$ = actions$.pipe(operators.observeOn(rxjs.queueScheduler));
|
990 |
|
991 | var withLatestReducer$ = actionsOnQueue$.pipe(operators.withLatestFrom(reducer$));
|
992 |
|
993 | var seed = { state: initialState };
|
994 |
|
995 | var stateAndAction$ = withLatestReducer$.pipe(operators.scan(reduceState, seed));
|
996 | _this.stateSubscription = stateAndAction$.subscribe(( |
997 |
|
998 |
|
999 | function (_a) {
|
1000 | var state = _a.state, action = _a.action;
|
1001 | _this.next(state);
|
1002 | scannedActions.next(( (action)));
|
1003 | }));
|
1004 | return _this;
|
1005 | }
|
1006 | |
1007 |
|
1008 |
|
1009 | State.prototype.ngOnDestroy = function () {
|
1010 | this.stateSubscription.unsubscribe();
|
1011 | this.complete();
|
1012 | };
|
1013 | return State;
|
1014 | }(rxjs.BehaviorSubject));
|
1015 | State.INIT = INIT;
|
1016 | State.decorators = [
|
1017 | { type: ngCore.Injectable }
|
1018 | ];
|
1019 |
|
1020 | State.ctorParameters = function () { return [
|
1021 | { type: ActionsSubject },
|
1022 | { type: ReducerObservable },
|
1023 | { type: ScannedActionsSubject },
|
1024 | { type: undefined, decorators: [{ type: ngCore.Inject, args: [INITIAL_STATE,] }] }
|
1025 | ]; };
|
1026 | if (false) {
|
1027 |
|
1028 | State.INIT;
|
1029 | |
1030 |
|
1031 |
|
1032 |
|
1033 | State.prototype.stateSubscription;
|
1034 | }
|
1035 | |
1036 |
|
1037 |
|
1038 |
|
1039 |
|
1040 |
|
1041 | function reduceState(stateActionPair, _a) {
|
1042 | if (stateActionPair === void 0) { stateActionPair = { state: undefined }; }
|
1043 | var _b = __read(_a, 2), action = _b[0], reducer = _b[1];
|
1044 | var state = stateActionPair.state;
|
1045 | return { state: reducer(state, action), action: action };
|
1046 | }
|
1047 |
|
1048 | var STATE_PROVIDERS = [
|
1049 | State,
|
1050 | { provide: StateObservable, useExisting: State },
|
1051 | ];
|
1052 |
|
1053 | |
1054 |
|
1055 |
|
1056 | var Store = (function (_super) {
|
1057 | __extends(Store, _super);
|
1058 | |
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 | function Store(state$, actionsObserver, reducerManager) {
|
1064 | var _this = _super.call(this) || this;
|
1065 | _this.actionsObserver = actionsObserver;
|
1066 | _this.reducerManager = reducerManager;
|
1067 | _this.source = state$;
|
1068 | return _this;
|
1069 | }
|
1070 | |
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 | Store.prototype.select = function (pathOrMapFn) {
|
1077 | var paths = [];
|
1078 | for (var _i = 1; _i < arguments.length; _i++) {
|
1079 | paths[_i - 1] = arguments[_i];
|
1080 | }
|
1081 | return (( (select))).call.apply((( (select))), __spread([null, pathOrMapFn], paths))(this);
|
1082 | };
|
1083 | |
1084 |
|
1085 |
|
1086 |
|
1087 |
|
1088 | Store.prototype.lift = function (operator) {
|
1089 |
|
1090 | var store = new Store(this, this.actionsObserver, this.reducerManager);
|
1091 | store.operator = operator;
|
1092 | return store;
|
1093 | };
|
1094 | |
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 | Store.prototype.dispatch = function (action) {
|
1100 | this.actionsObserver.next(action);
|
1101 | };
|
1102 | |
1103 |
|
1104 |
|
1105 |
|
1106 | Store.prototype.next = function (action) {
|
1107 | this.actionsObserver.next(action);
|
1108 | };
|
1109 | |
1110 |
|
1111 |
|
1112 |
|
1113 | Store.prototype.error = function (err) {
|
1114 | this.actionsObserver.error(err);
|
1115 | };
|
1116 | |
1117 |
|
1118 |
|
1119 | Store.prototype.complete = function () {
|
1120 | this.actionsObserver.complete();
|
1121 | };
|
1122 | |
1123 |
|
1124 |
|
1125 |
|
1126 |
|
1127 |
|
1128 | Store.prototype.addReducer = function (key, reducer) {
|
1129 | this.reducerManager.addReducer(key, reducer);
|
1130 | };
|
1131 | |
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 | Store.prototype.removeReducer = function (key) {
|
1137 | this.reducerManager.removeReducer(key);
|
1138 | };
|
1139 | return Store;
|
1140 | }(rxjs.Observable));
|
1141 | Store.decorators = [
|
1142 | { type: ngCore.Injectable }
|
1143 | ];
|
1144 |
|
1145 | Store.ctorParameters = function () { return [
|
1146 | { type: StateObservable },
|
1147 | { type: ActionsSubject },
|
1148 | { type: ReducerManager }
|
1149 | ]; };
|
1150 | if (false) {
|
1151 | |
1152 |
|
1153 |
|
1154 |
|
1155 | Store.prototype.actionsObserver;
|
1156 | |
1157 |
|
1158 |
|
1159 |
|
1160 | Store.prototype.reducerManager;
|
1161 | }
|
1162 |
|
1163 | var STORE_PROVIDERS = [Store];
|
1164 | |
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 | function select(pathOrMapFn, propsOrPath) {
|
1172 | var paths = [];
|
1173 | for (var _i = 2; _i < arguments.length; _i++) {
|
1174 | paths[_i - 2] = arguments[_i];
|
1175 | }
|
1176 | return ( |
1177 |
|
1178 |
|
1179 | function selectOperator(source$) {
|
1180 |
|
1181 | var mapped$;
|
1182 | if (typeof pathOrMapFn === 'string') {
|
1183 |
|
1184 | var pathSlices = __spread([( (propsOrPath))], paths).filter(Boolean);
|
1185 | mapped$ = source$.pipe(operators.pluck.apply(void 0, __spread([pathOrMapFn], pathSlices)));
|
1186 | }
|
1187 | else if (typeof pathOrMapFn === 'function') {
|
1188 | mapped$ = source$.pipe(operators.map(( |
1189 |
|
1190 |
|
1191 | function (source) { return pathOrMapFn(source, ( (propsOrPath))); })));
|
1192 | }
|
1193 | else {
|
1194 | throw new TypeError("Unexpected type '" + typeof pathOrMapFn + "' in select operator," +
|
1195 | " expected 'string' or 'function'");
|
1196 | }
|
1197 | return mapped$.pipe(operators.distinctUntilChanged());
|
1198 | });
|
1199 | }
|
1200 |
|
1201 | |
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 |
|
1207 | var _ngrxMockEnvironment = false;
|
1208 | |
1209 |
|
1210 |
|
1211 |
|
1212 | function setNgrxMockEnvironment(value) {
|
1213 | _ngrxMockEnvironment = value;
|
1214 | }
|
1215 | |
1216 |
|
1217 |
|
1218 | function isNgrxMockEnvironment() {
|
1219 | return _ngrxMockEnvironment;
|
1220 | }
|
1221 |
|
1222 | |
1223 |
|
1224 |
|
1225 |
|
1226 | function MemoizedSelector() { }
|
1227 | if (false) {
|
1228 |
|
1229 | MemoizedSelector.prototype.projector;
|
1230 |
|
1231 | MemoizedSelector.prototype.setResult;
|
1232 |
|
1233 | MemoizedSelector.prototype.clearResult;
|
1234 | |
1235 |
|
1236 |
|
1237 | MemoizedSelector.prototype.release = function () { };
|
1238 | }
|
1239 | |
1240 |
|
1241 |
|
1242 |
|
1243 | function MemoizedSelectorWithProps() { }
|
1244 | if (false) {
|
1245 |
|
1246 | MemoizedSelectorWithProps.prototype.projector;
|
1247 |
|
1248 | MemoizedSelectorWithProps.prototype.setResult;
|
1249 |
|
1250 | MemoizedSelectorWithProps.prototype.clearResult;
|
1251 | |
1252 |
|
1253 |
|
1254 | MemoizedSelectorWithProps.prototype.release = function () { };
|
1255 | }
|
1256 | |
1257 |
|
1258 |
|
1259 |
|
1260 |
|
1261 | function isEqualCheck(a, b) {
|
1262 | return a === b;
|
1263 | }
|
1264 | |
1265 |
|
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 | function isArgumentsChanged(args, lastArguments, comparator) {
|
1271 | for (var i = 0; i < args.length; i++) {
|
1272 | if (!comparator(args[i], lastArguments[i])) {
|
1273 | return true;
|
1274 | }
|
1275 | }
|
1276 | return false;
|
1277 | }
|
1278 | |
1279 |
|
1280 |
|
1281 |
|
1282 |
|
1283 | function resultMemoize(projectionFn, isResultEqual) {
|
1284 | return defaultMemoize(projectionFn, isEqualCheck, isResultEqual);
|
1285 | }
|
1286 | |
1287 |
|
1288 |
|
1289 |
|
1290 |
|
1291 |
|
1292 | function defaultMemoize(projectionFn, isArgumentsEqual, isResultEqual) {
|
1293 | if (isArgumentsEqual === void 0) { isArgumentsEqual = isEqualCheck; }
|
1294 | if (isResultEqual === void 0) { isResultEqual = isEqualCheck; }
|
1295 |
|
1296 | var lastArguments = null;
|
1297 |
|
1298 |
|
1299 | var lastResult = null;
|
1300 |
|
1301 | var overrideResult;
|
1302 | |
1303 |
|
1304 |
|
1305 | function reset() {
|
1306 | lastArguments = null;
|
1307 | lastResult = null;
|
1308 | }
|
1309 | |
1310 |
|
1311 |
|
1312 |
|
1313 | function setResult(result) {
|
1314 | if (result === void 0) { result = undefined; }
|
1315 | overrideResult = { result: result };
|
1316 | }
|
1317 | |
1318 |
|
1319 |
|
1320 | function clearResult() {
|
1321 | overrideResult = undefined;
|
1322 | }
|
1323 |
|
1324 | |
1325 |
|
1326 |
|
1327 | function memoized() {
|
1328 | if (overrideResult !== undefined) {
|
1329 | return overrideResult.result;
|
1330 | }
|
1331 | if (!lastArguments) {
|
1332 | lastResult = projectionFn.apply(null, ( (arguments)));
|
1333 | lastArguments = arguments;
|
1334 | return lastResult;
|
1335 | }
|
1336 | if (!isArgumentsChanged(arguments, lastArguments, isArgumentsEqual)) {
|
1337 | return lastResult;
|
1338 | }
|
1339 |
|
1340 | var newResult = projectionFn.apply(null, ( (arguments)));
|
1341 | lastArguments = arguments;
|
1342 | if (isResultEqual(lastResult, newResult)) {
|
1343 | return lastResult;
|
1344 | }
|
1345 | lastResult = newResult;
|
1346 | return newResult;
|
1347 | }
|
1348 | return { memoized: memoized, reset: reset, setResult: setResult, clearResult: clearResult };
|
1349 | }
|
1350 | |
1351 |
|
1352 |
|
1353 |
|
1354 | function createSelector() {
|
1355 | var input = [];
|
1356 | for (var _i = 0; _i < arguments.length; _i++) {
|
1357 | input[_i] = arguments[_i];
|
1358 | }
|
1359 | return createSelectorFactory(defaultMemoize).apply(void 0, __spread(input));
|
1360 | }
|
1361 | |
1362 |
|
1363 |
|
1364 |
|
1365 |
|
1366 |
|
1367 |
|
1368 | function defaultStateFn(state, selectors, props, memoizedProjector) {
|
1369 | if (props === undefined) {
|
1370 |
|
1371 | var args_1 = (( (selectors))).map(( |
1372 |
|
1373 |
|
1374 | function (fn) { return fn(state); }));
|
1375 | return memoizedProjector.memoized.apply(null, args_1);
|
1376 | }
|
1377 |
|
1378 | var args = (( (selectors))).map(( |
1379 |
|
1380 |
|
1381 | function (fn) { return fn(state, props); }));
|
1382 | return memoizedProjector.memoized.apply(null, __spread(args, [props]));
|
1383 | }
|
1384 | |
1385 |
|
1386 |
|
1387 |
|
1388 |
|
1389 |
|
1390 |
|
1391 |
|
1392 |
|
1393 |
|
1394 |
|
1395 |
|
1396 |
|
1397 |
|
1398 |
|
1399 |
|
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 |
|
1405 |
|
1406 |
|
1407 |
|
1408 |
|
1409 |
|
1410 |
|
1411 |
|
1412 |
|
1413 |
|
1414 |
|
1415 |
|
1416 |
|
1417 |
|
1418 |
|
1419 |
|
1420 |
|
1421 |
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 |
|
1432 |
|
1433 |
|
1434 |
|
1435 |
|
1436 |
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 |
|
1453 |
|
1454 |
|
1455 |
|
1456 |
|
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 | function createSelectorFactory(memoize, options) {
|
1464 | if (options === void 0) { options = {
|
1465 | stateFn: defaultStateFn,
|
1466 | }; }
|
1467 | return ( |
1468 |
|
1469 |
|
1470 | function () {
|
1471 | var input = [];
|
1472 | for (var _i = 0; _i < arguments.length; _i++) {
|
1473 | input[_i] = arguments[_i];
|
1474 | }
|
1475 |
|
1476 | var args = input;
|
1477 | if (Array.isArray(args[0])) {
|
1478 | var _a = __read(args), head = _a[0], tail = _a.slice(1);
|
1479 | args = __spread(head, tail);
|
1480 | }
|
1481 |
|
1482 | var selectors = args.slice(0, args.length - 1);
|
1483 |
|
1484 | var projector = args[args.length - 1];
|
1485 |
|
1486 | var memoizedSelectors = selectors.filter(( |
1487 |
|
1488 |
|
1489 | function (selector) { return selector.release && typeof selector.release === 'function'; }));
|
1490 |
|
1491 | var memoizedProjector = memoize(( |
1492 |
|
1493 |
|
1494 | function () {
|
1495 | var selectors = [];
|
1496 | for (var _i = 0; _i < arguments.length; _i++) {
|
1497 | selectors[_i] = arguments[_i];
|
1498 | }
|
1499 | return projector.apply(null, selectors);
|
1500 | }));
|
1501 |
|
1502 | var memoizedState = defaultMemoize(( |
1503 |
|
1504 |
|
1505 |
|
1506 | function (state, props) {
|
1507 | return options.stateFn.apply(null, [
|
1508 | state,
|
1509 | selectors,
|
1510 | props,
|
1511 | memoizedProjector,
|
1512 | ]);
|
1513 | }));
|
1514 | |
1515 |
|
1516 |
|
1517 | function release() {
|
1518 | memoizedState.reset();
|
1519 | memoizedProjector.reset();
|
1520 | memoizedSelectors.forEach(( |
1521 |
|
1522 |
|
1523 | function (selector) { return selector.release(); }));
|
1524 | }
|
1525 | return Object.assign(memoizedState.memoized, {
|
1526 | release: release,
|
1527 | projector: memoizedProjector.memoized,
|
1528 | setResult: memoizedState.setResult,
|
1529 | clearResult: memoizedState.clearResult,
|
1530 | });
|
1531 | });
|
1532 | }
|
1533 | |
1534 |
|
1535 |
|
1536 |
|
1537 | function createFeatureSelector(featureName) {
|
1538 | return createSelector(( |
1539 |
|
1540 |
|
1541 | function (state) {
|
1542 |
|
1543 | var featureState = state[featureName];
|
1544 | if (!isNgrxMockEnvironment() && ngCore.isDevMode() && !(featureName in state)) {
|
1545 | console.warn("@ngrx/store: The feature name \"" + featureName + "\" does " +
|
1546 | 'not exist in the state, therefore createFeatureSelector ' +
|
1547 | 'cannot access it. Be sure it is imported in a loaded module ' +
|
1548 | ("using StoreModule.forRoot('" + featureName + "', ...) or ") +
|
1549 | ("StoreModule.forFeature('" + featureName + "', ...). If the default ") +
|
1550 | 'state is intended to be undefined, as is the case with router ' +
|
1551 | 'state, this development-only warning message can be ignored.');
|
1552 | }
|
1553 | return featureState;
|
1554 | }), ( |
1555 |
|
1556 |
|
1557 | function (featureState) { return featureState; }));
|
1558 | }
|
1559 |
|
1560 | |
1561 |
|
1562 |
|
1563 |
|
1564 |
|
1565 |
|
1566 | var RUNTIME_CHECK_URL = 'https://ngrx.io/guide/store/configuration/runtime-checks';
|
1567 | |
1568 |
|
1569 |
|
1570 |
|
1571 | function isUndefined(target) {
|
1572 | return target === undefined;
|
1573 | }
|
1574 | |
1575 |
|
1576 |
|
1577 |
|
1578 | function isNull(target) {
|
1579 | return target === null;
|
1580 | }
|
1581 | |
1582 |
|
1583 |
|
1584 |
|
1585 | function isArray(target) {
|
1586 | return Array.isArray(target);
|
1587 | }
|
1588 | |
1589 |
|
1590 |
|
1591 |
|
1592 | function isString(target) {
|
1593 | return typeof target === 'string';
|
1594 | }
|
1595 | |
1596 |
|
1597 |
|
1598 |
|
1599 | function isBoolean(target) {
|
1600 | return typeof target === 'boolean';
|
1601 | }
|
1602 | |
1603 |
|
1604 |
|
1605 |
|
1606 | function isNumber(target) {
|
1607 | return typeof target === 'number';
|
1608 | }
|
1609 | |
1610 |
|
1611 |
|
1612 |
|
1613 | function isObjectLike(target) {
|
1614 | return typeof target === 'object' && target !== null;
|
1615 | }
|
1616 | |
1617 |
|
1618 |
|
1619 |
|
1620 | function isObject(target) {
|
1621 | return isObjectLike(target) && !isArray(target);
|
1622 | }
|
1623 | |
1624 |
|
1625 |
|
1626 |
|
1627 | function isPlainObject(target) {
|
1628 | if (!isObject(target)) {
|
1629 | return false;
|
1630 | }
|
1631 |
|
1632 | var targetPrototype = Object.getPrototypeOf(target);
|
1633 | return targetPrototype === Object.prototype || targetPrototype === null;
|
1634 | }
|
1635 | |
1636 |
|
1637 |
|
1638 |
|
1639 | function isFunction(target) {
|
1640 | return typeof target === 'function';
|
1641 | }
|
1642 | |
1643 |
|
1644 |
|
1645 |
|
1646 | function isComponent(target) {
|
1647 | return isFunction(target) && target.hasOwnProperty('ɵcmp');
|
1648 | }
|
1649 | |
1650 |
|
1651 |
|
1652 |
|
1653 |
|
1654 | function hasOwnProperty(target, propertyName) {
|
1655 | return Object.prototype.hasOwnProperty.call(target, propertyName);
|
1656 | }
|
1657 |
|
1658 | |
1659 |
|
1660 |
|
1661 |
|
1662 |
|
1663 | |
1664 |
|
1665 |
|
1666 |
|
1667 |
|
1668 | function immutabilityCheckMetaReducer(reducer, checks) {
|
1669 | return ( |
1670 |
|
1671 |
|
1672 |
|
1673 | function (state, action) {
|
1674 |
|
1675 | var act = checks.action(action) ? freeze(action) : action;
|
1676 |
|
1677 | var nextState = reducer(state, act);
|
1678 | return checks.state() ? freeze(nextState) : nextState;
|
1679 | });
|
1680 | }
|
1681 | |
1682 |
|
1683 |
|
1684 |
|
1685 | function freeze(target) {
|
1686 | Object.freeze(target);
|
1687 |
|
1688 | var targetIsFunction = isFunction(target);
|
1689 | Object.getOwnPropertyNames(target).forEach(( |
1690 |
|
1691 |
|
1692 | function (prop) {
|
1693 |
|
1694 | if (prop.startsWith('ɵ')) {
|
1695 | return;
|
1696 | }
|
1697 | if (hasOwnProperty(target, prop) &&
|
1698 | (targetIsFunction
|
1699 | ? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments'
|
1700 | : true)) {
|
1701 |
|
1702 | var propValue = target[prop];
|
1703 | if ((isObjectLike(propValue) || isFunction(propValue)) &&
|
1704 | !Object.isFrozen(propValue)) {
|
1705 | freeze(propValue);
|
1706 | }
|
1707 | }
|
1708 | }));
|
1709 | return target;
|
1710 | }
|
1711 |
|
1712 | |
1713 |
|
1714 |
|
1715 |
|
1716 |
|
1717 | function serializationCheckMetaReducer(reducer, checks) {
|
1718 | return ( |
1719 |
|
1720 |
|
1721 |
|
1722 | function (state, action) {
|
1723 | if (checks.action(action)) {
|
1724 |
|
1725 | var unserializableAction = getUnserializable(action);
|
1726 | throwIfUnserializable(unserializableAction, 'action');
|
1727 | }
|
1728 |
|
1729 | var nextState = reducer(state, action);
|
1730 | if (checks.state()) {
|
1731 |
|
1732 | var unserializableState = getUnserializable(nextState);
|
1733 | throwIfUnserializable(unserializableState, 'state');
|
1734 | }
|
1735 | return nextState;
|
1736 | });
|
1737 | }
|
1738 | |
1739 |
|
1740 |
|
1741 |
|
1742 |
|
1743 | function getUnserializable(target, path) {
|
1744 | if (path === void 0) { path = []; }
|
1745 |
|
1746 | if ((isUndefined(target) || isNull(target)) && path.length === 0) {
|
1747 | return {
|
1748 | path: ['root'],
|
1749 | value: target,
|
1750 | };
|
1751 | }
|
1752 |
|
1753 | var keys = Object.keys(target);
|
1754 | return keys.reduce(( |
1755 |
|
1756 |
|
1757 |
|
1758 | function (result, key) {
|
1759 | if (result) {
|
1760 | return result;
|
1761 | }
|
1762 |
|
1763 | var value = (( (target)))[key];
|
1764 |
|
1765 | if (isComponent(value)) {
|
1766 | return result;
|
1767 | }
|
1768 | if (isUndefined(value) ||
|
1769 | isNull(value) ||
|
1770 | isNumber(value) ||
|
1771 | isBoolean(value) ||
|
1772 | isString(value) ||
|
1773 | isArray(value)) {
|
1774 | return false;
|
1775 | }
|
1776 | if (isPlainObject(value)) {
|
1777 | return getUnserializable(value, __spread(path, [key]));
|
1778 | }
|
1779 | return {
|
1780 | path: __spread(path, [key]),
|
1781 | value: value,
|
1782 | };
|
1783 | }), false);
|
1784 | }
|
1785 | |
1786 |
|
1787 |
|
1788 |
|
1789 |
|
1790 | function throwIfUnserializable(unserializable, context) {
|
1791 | if (unserializable === false) {
|
1792 | return;
|
1793 | }
|
1794 |
|
1795 | var unserializablePath = unserializable.path.join('.');
|
1796 |
|
1797 | var error = new Error("Detected unserializable " + context + " at \"" + unserializablePath + "\". " + RUNTIME_CHECK_URL + "#strict" + context + "serializability");
|
1798 | error.value = unserializable.value;
|
1799 | error.unserializablePath = unserializablePath;
|
1800 | throw error;
|
1801 | }
|
1802 |
|
1803 | |
1804 |
|
1805 |
|
1806 |
|
1807 |
|
1808 | |
1809 |
|
1810 |
|
1811 |
|
1812 |
|
1813 | function inNgZoneAssertMetaReducer(reducer, checks) {
|
1814 | return ( |
1815 |
|
1816 |
|
1817 |
|
1818 | function (state, action) {
|
1819 | if (checks.action(action) && !ngCore.NgZone.isInAngularZone()) {
|
1820 | throw new Error("Action '" + action.type + "' running outside NgZone. " + RUNTIME_CHECK_URL + "#strictactionwithinngzone");
|
1821 | }
|
1822 | return reducer(state, action);
|
1823 | });
|
1824 | }
|
1825 |
|
1826 | |
1827 |
|
1828 |
|
1829 |
|
1830 |
|
1831 |
|
1832 | |
1833 |
|
1834 |
|
1835 |
|
1836 | function createActiveRuntimeChecks(runtimeChecks) {
|
1837 | if (ngCore.isDevMode()) {
|
1838 | return Object.assign({ strictStateSerializability: false, strictActionSerializability: false, strictStateImmutability: true, strictActionImmutability: true, strictActionWithinNgZone: false, strictActionTypeUniqueness: false }, runtimeChecks);
|
1839 | }
|
1840 | return {
|
1841 | strictStateSerializability: false,
|
1842 | strictActionSerializability: false,
|
1843 | strictStateImmutability: false,
|
1844 | strictActionImmutability: false,
|
1845 | strictActionWithinNgZone: false,
|
1846 | strictActionTypeUniqueness: false,
|
1847 | };
|
1848 | }
|
1849 | |
1850 |
|
1851 |
|
1852 |
|
1853 | function createSerializationCheckMetaReducer(_a) {
|
1854 | var strictActionSerializability = _a.strictActionSerializability, strictStateSerializability = _a.strictStateSerializability;
|
1855 | return ( |
1856 |
|
1857 |
|
1858 | function (reducer) { return strictActionSerializability || strictStateSerializability
|
1859 | ? serializationCheckMetaReducer(reducer, {
|
1860 | action: ( |
1861 |
|
1862 |
|
1863 | function (action) { return strictActionSerializability && !ignoreNgrxAction(action); }),
|
1864 | state: ( |
1865 |
|
1866 | function () { return strictStateSerializability; }),
|
1867 | })
|
1868 | : reducer; });
|
1869 | }
|
1870 | |
1871 |
|
1872 |
|
1873 |
|
1874 | function createImmutabilityCheckMetaReducer(_a) {
|
1875 | var strictActionImmutability = _a.strictActionImmutability, strictStateImmutability = _a.strictStateImmutability;
|
1876 | return ( |
1877 |
|
1878 |
|
1879 | function (reducer) { return strictActionImmutability || strictStateImmutability
|
1880 | ? immutabilityCheckMetaReducer(reducer, {
|
1881 | action: ( |
1882 |
|
1883 |
|
1884 | function (action) { return strictActionImmutability && !ignoreNgrxAction(action); }),
|
1885 | state: ( |
1886 |
|
1887 | function () { return strictStateImmutability; }),
|
1888 | })
|
1889 | : reducer; });
|
1890 | }
|
1891 | |
1892 |
|
1893 |
|
1894 |
|
1895 | function ignoreNgrxAction(action) {
|
1896 | return action.type.startsWith('@ngrx');
|
1897 | }
|
1898 | |
1899 |
|
1900 |
|
1901 |
|
1902 | function createInNgZoneCheckMetaReducer(_a) {
|
1903 | var strictActionWithinNgZone = _a.strictActionWithinNgZone;
|
1904 | return ( |
1905 |
|
1906 |
|
1907 | function (reducer) { return strictActionWithinNgZone
|
1908 | ? inNgZoneAssertMetaReducer(reducer, {
|
1909 | action: ( |
1910 |
|
1911 |
|
1912 | function (action) { return strictActionWithinNgZone && !ignoreNgrxAction(action); }),
|
1913 | })
|
1914 | : reducer; });
|
1915 | }
|
1916 | |
1917 |
|
1918 |
|
1919 |
|
1920 | function provideRuntimeChecks(runtimeChecks) {
|
1921 | return [
|
1922 | {
|
1923 | provide: _USER_RUNTIME_CHECKS,
|
1924 | useValue: runtimeChecks,
|
1925 | },
|
1926 | {
|
1927 | provide: USER_RUNTIME_CHECKS,
|
1928 | useFactory: _runtimeChecksFactory,
|
1929 | deps: [_USER_RUNTIME_CHECKS],
|
1930 | },
|
1931 | {
|
1932 | provide: _ACTIVE_RUNTIME_CHECKS,
|
1933 | deps: [USER_RUNTIME_CHECKS],
|
1934 | useFactory: createActiveRuntimeChecks,
|
1935 | },
|
1936 | {
|
1937 | provide: META_REDUCERS,
|
1938 | multi: true,
|
1939 | deps: [_ACTIVE_RUNTIME_CHECKS],
|
1940 | useFactory: createImmutabilityCheckMetaReducer,
|
1941 | },
|
1942 | {
|
1943 | provide: META_REDUCERS,
|
1944 | multi: true,
|
1945 | deps: [_ACTIVE_RUNTIME_CHECKS],
|
1946 | useFactory: createSerializationCheckMetaReducer,
|
1947 | },
|
1948 | {
|
1949 | provide: META_REDUCERS,
|
1950 | multi: true,
|
1951 | deps: [_ACTIVE_RUNTIME_CHECKS],
|
1952 | useFactory: createInNgZoneCheckMetaReducer,
|
1953 | },
|
1954 | ];
|
1955 | }
|
1956 | |
1957 |
|
1958 |
|
1959 | function checkForActionTypeUniqueness() {
|
1960 | return [
|
1961 | {
|
1962 | provide: _ACTION_TYPE_UNIQUENESS_CHECK,
|
1963 | multi: true,
|
1964 | deps: [_ACTIVE_RUNTIME_CHECKS],
|
1965 | useFactory: _actionTypeUniquenessCheck,
|
1966 | },
|
1967 | ];
|
1968 | }
|
1969 | |
1970 |
|
1971 |
|
1972 |
|
1973 | function _runtimeChecksFactory(runtimeChecks) {
|
1974 | return runtimeChecks;
|
1975 | }
|
1976 | |
1977 |
|
1978 |
|
1979 |
|
1980 | function _actionTypeUniquenessCheck(config) {
|
1981 | if (!config.strictActionTypeUniqueness) {
|
1982 | return;
|
1983 | }
|
1984 |
|
1985 | var duplicates = Object.entries(REGISTERED_ACTION_TYPES)
|
1986 | .filter(( |
1987 |
|
1988 |
|
1989 | function (_a) {
|
1990 | var _b = __read(_a, 2), registrations = _b[1];
|
1991 | return registrations > 1;
|
1992 | }))
|
1993 | .map(( |
1994 |
|
1995 |
|
1996 | function (_a) {
|
1997 | var _b = __read(_a, 1), type = _b[0];
|
1998 | return type;
|
1999 | }));
|
2000 | if (duplicates.length) {
|
2001 | throw new Error("Action types are registered more than once, " + duplicates
|
2002 | .map(( |
2003 |
|
2004 |
|
2005 | function (type) { return "\"" + type + "\""; }))
|
2006 | .join(', ') + ". " + RUNTIME_CHECK_URL + "#strictactiontypeuniqueness");
|
2007 | }
|
2008 | }
|
2009 |
|
2010 | |
2011 |
|
2012 |
|
2013 |
|
2014 |
|
2015 | var StoreRootModule = (function () {
|
2016 | |
2017 |
|
2018 |
|
2019 |
|
2020 |
|
2021 |
|
2022 |
|
2023 |
|
2024 | function StoreRootModule(actions$, reducer$, scannedActions$, store, guard, actionCheck) {
|
2025 | }
|
2026 | return StoreRootModule;
|
2027 | }());
|
2028 | StoreRootModule.decorators = [
|
2029 | { type: ngCore.NgModule, args: [{},] }
|
2030 | ];
|
2031 |
|
2032 | StoreRootModule.ctorParameters = function () { return [
|
2033 | { type: ActionsSubject },
|
2034 | { type: ReducerObservable },
|
2035 | { type: ScannedActionsSubject },
|
2036 | { type: Store },
|
2037 | { type: undefined, decorators: [{ type: ngCore.Optional }, { type: ngCore.Inject, args: [_ROOT_STORE_GUARD,] }] },
|
2038 | { type: undefined, decorators: [{ type: ngCore.Optional }, { type: ngCore.Inject, args: [_ACTION_TYPE_UNIQUENESS_CHECK,] }] }
|
2039 | ]; };
|
2040 | var StoreFeatureModule = (function () {
|
2041 | |
2042 |
|
2043 |
|
2044 |
|
2045 |
|
2046 |
|
2047 |
|
2048 | function StoreFeatureModule(features, featureReducers, reducerManager, root, actionCheck) {
|
2049 | this.features = features;
|
2050 | this.featureReducers = featureReducers;
|
2051 | this.reducerManager = reducerManager;
|
2052 |
|
2053 | var feats = features.map(( |
2054 |
|
2055 |
|
2056 |
|
2057 | function (feature, index) {
|
2058 |
|
2059 | var featureReducerCollection = featureReducers.shift();
|
2060 |
|
2061 | var reducers = ( (featureReducerCollection ))[index];
|
2062 | return Object.assign(Object.assign({}, feature), { reducers: reducers, initialState: _initialStateFactory(feature.initialState) });
|
2063 | }));
|
2064 | reducerManager.addFeatures(feats);
|
2065 | }
|
2066 | |
2067 |
|
2068 |
|
2069 | StoreFeatureModule.prototype.ngOnDestroy = function () {
|
2070 | this.reducerManager.removeFeatures(this.features);
|
2071 | };
|
2072 | return StoreFeatureModule;
|
2073 | }());
|
2074 | StoreFeatureModule.decorators = [
|
2075 | { type: ngCore.NgModule, args: [{},] }
|
2076 | ];
|
2077 |
|
2078 | StoreFeatureModule.ctorParameters = function () { return [
|
2079 | { type: Array, decorators: [{ type: ngCore.Inject, args: [_STORE_FEATURES,] }] },
|
2080 | { type: Array, decorators: [{ type: ngCore.Inject, args: [FEATURE_REDUCERS,] }] },
|
2081 | { type: ReducerManager },
|
2082 | { type: StoreRootModule },
|
2083 | { type: undefined, decorators: [{ type: ngCore.Optional }, { type: ngCore.Inject, args: [_ACTION_TYPE_UNIQUENESS_CHECK,] }] }
|
2084 | ]; };
|
2085 | if (false) {
|
2086 | |
2087 |
|
2088 |
|
2089 |
|
2090 | StoreFeatureModule.prototype.features;
|
2091 | |
2092 |
|
2093 |
|
2094 |
|
2095 | StoreFeatureModule.prototype.featureReducers;
|
2096 | |
2097 |
|
2098 |
|
2099 |
|
2100 | StoreFeatureModule.prototype.reducerManager;
|
2101 | }
|
2102 | |
2103 |
|
2104 |
|
2105 |
|
2106 | function StoreConfig() { }
|
2107 | if (false) {
|
2108 |
|
2109 | StoreConfig.prototype.initialState;
|
2110 |
|
2111 | StoreConfig.prototype.reducerFactory;
|
2112 |
|
2113 | StoreConfig.prototype.metaReducers;
|
2114 | }
|
2115 | |
2116 |
|
2117 |
|
2118 |
|
2119 | function RootStoreConfig() { }
|
2120 | if (false) {
|
2121 |
|
2122 | RootStoreConfig.prototype.runtimeChecks;
|
2123 | }
|
2124 | |
2125 |
|
2126 |
|
2127 |
|
2128 |
|
2129 | function FeatureSlice() { }
|
2130 | if (false) {
|
2131 |
|
2132 | FeatureSlice.prototype.name;
|
2133 |
|
2134 | FeatureSlice.prototype.reducer;
|
2135 | }
|
2136 | var StoreModule = (function () {
|
2137 | function StoreModule() {
|
2138 | }
|
2139 | |
2140 |
|
2141 |
|
2142 |
|
2143 |
|
2144 | StoreModule.forRoot = function (reducers, config) {
|
2145 | if (config === void 0) { config = {}; }
|
2146 | return {
|
2147 | ngModule: StoreRootModule,
|
2148 | providers: [
|
2149 | {
|
2150 | provide: _ROOT_STORE_GUARD,
|
2151 | useFactory: _provideForRootGuard,
|
2152 | deps: [[Store, new ngCore.Optional(), new ngCore.SkipSelf()]],
|
2153 | },
|
2154 | { provide: _INITIAL_STATE, useValue: config.initialState },
|
2155 | {
|
2156 | provide: INITIAL_STATE,
|
2157 | useFactory: _initialStateFactory,
|
2158 | deps: [_INITIAL_STATE],
|
2159 | },
|
2160 | { provide: _INITIAL_REDUCERS, useValue: reducers },
|
2161 | {
|
2162 | provide: _STORE_REDUCERS,
|
2163 | useExisting: reducers instanceof ngCore.InjectionToken ? reducers : _INITIAL_REDUCERS,
|
2164 | },
|
2165 | {
|
2166 | provide: INITIAL_REDUCERS,
|
2167 | deps: [ngCore.Injector, _INITIAL_REDUCERS, [new ngCore.Inject(_STORE_REDUCERS)]],
|
2168 | useFactory: _createStoreReducers,
|
2169 | },
|
2170 | {
|
2171 | provide: USER_PROVIDED_META_REDUCERS,
|
2172 | useValue: config.metaReducers ? config.metaReducers : [],
|
2173 | },
|
2174 | {
|
2175 | provide: _RESOLVED_META_REDUCERS,
|
2176 | deps: [META_REDUCERS, USER_PROVIDED_META_REDUCERS],
|
2177 | useFactory: _concatMetaReducers,
|
2178 | },
|
2179 | {
|
2180 | provide: _REDUCER_FACTORY,
|
2181 | useValue: config.reducerFactory
|
2182 | ? config.reducerFactory
|
2183 | : combineReducers,
|
2184 | },
|
2185 | {
|
2186 | provide: REDUCER_FACTORY,
|
2187 | deps: [_REDUCER_FACTORY, _RESOLVED_META_REDUCERS],
|
2188 | useFactory: createReducerFactory,
|
2189 | },
|
2190 | ACTIONS_SUBJECT_PROVIDERS,
|
2191 | REDUCER_MANAGER_PROVIDERS,
|
2192 | SCANNED_ACTIONS_SUBJECT_PROVIDERS,
|
2193 | STATE_PROVIDERS,
|
2194 | STORE_PROVIDERS,
|
2195 | provideRuntimeChecks(config.runtimeChecks),
|
2196 | checkForActionTypeUniqueness(),
|
2197 | ],
|
2198 | };
|
2199 | };
|
2200 | |
2201 |
|
2202 |
|
2203 |
|
2204 |
|
2205 |
|
2206 | StoreModule.forFeature = function (featureNameOrSlice, reducersOrConfig, config) {
|
2207 | if (config === void 0) { config = {}; }
|
2208 | return {
|
2209 | ngModule: StoreFeatureModule,
|
2210 | providers: [
|
2211 | {
|
2212 | provide: _FEATURE_CONFIGS,
|
2213 | multi: true,
|
2214 | useValue: typeof featureNameOrSlice === 'string' ? config : {},
|
2215 | },
|
2216 | {
|
2217 | provide: STORE_FEATURES,
|
2218 | multi: true,
|
2219 | useValue: {
|
2220 | key: typeof featureNameOrSlice === 'string'
|
2221 | ? featureNameOrSlice
|
2222 | : featureNameOrSlice.name,
|
2223 | reducerFactory: !(config instanceof ngCore.InjectionToken) && config.reducerFactory
|
2224 | ? config.reducerFactory
|
2225 | : combineReducers,
|
2226 | metaReducers: !(config instanceof ngCore.InjectionToken) && config.metaReducers
|
2227 | ? config.metaReducers
|
2228 | : [],
|
2229 | initialState: !(config instanceof ngCore.InjectionToken) && config.initialState
|
2230 | ? config.initialState
|
2231 | : undefined,
|
2232 | },
|
2233 | },
|
2234 | {
|
2235 | provide: _STORE_FEATURES,
|
2236 | deps: [ngCore.Injector, _FEATURE_CONFIGS, STORE_FEATURES],
|
2237 | useFactory: _createFeatureStore,
|
2238 | },
|
2239 | {
|
2240 | provide: _FEATURE_REDUCERS,
|
2241 | multi: true,
|
2242 | useValue: typeof featureNameOrSlice === 'string'
|
2243 | ? reducersOrConfig
|
2244 | : featureNameOrSlice.reducer,
|
2245 | },
|
2246 | {
|
2247 | provide: _FEATURE_REDUCERS_TOKEN,
|
2248 | multi: true,
|
2249 | useExisting: reducersOrConfig instanceof ngCore.InjectionToken
|
2250 | ? reducersOrConfig
|
2251 | : _FEATURE_REDUCERS,
|
2252 | },
|
2253 | {
|
2254 | provide: FEATURE_REDUCERS,
|
2255 | multi: true,
|
2256 | deps: [
|
2257 | ngCore.Injector,
|
2258 | _FEATURE_REDUCERS,
|
2259 | [new ngCore.Inject(_FEATURE_REDUCERS_TOKEN)],
|
2260 | ],
|
2261 | useFactory: _createFeatureReducers,
|
2262 | },
|
2263 | checkForActionTypeUniqueness(),
|
2264 | ],
|
2265 | };
|
2266 | };
|
2267 | return StoreModule;
|
2268 | }());
|
2269 | StoreModule.decorators = [
|
2270 | { type: ngCore.NgModule, args: [{},] }
|
2271 | ];
|
2272 | |
2273 |
|
2274 |
|
2275 |
|
2276 |
|
2277 | function _createStoreReducers(injector, reducers) {
|
2278 | return reducers instanceof ngCore.InjectionToken ? injector.get(reducers) : reducers;
|
2279 | }
|
2280 | |
2281 |
|
2282 |
|
2283 |
|
2284 |
|
2285 |
|
2286 | function _createFeatureStore(injector, configs, featureStores) {
|
2287 | return featureStores.map(( |
2288 |
|
2289 |
|
2290 |
|
2291 | function (feat, index) {
|
2292 | if (configs[index] instanceof ngCore.InjectionToken) {
|
2293 |
|
2294 | var conf = injector.get(configs[index]);
|
2295 | return {
|
2296 | key: feat.key,
|
2297 | reducerFactory: conf.reducerFactory
|
2298 | ? conf.reducerFactory
|
2299 | : combineReducers,
|
2300 | metaReducers: conf.metaReducers ? conf.metaReducers : [],
|
2301 | initialState: conf.initialState,
|
2302 | };
|
2303 | }
|
2304 | return feat;
|
2305 | }));
|
2306 | }
|
2307 | |
2308 |
|
2309 |
|
2310 |
|
2311 |
|
2312 | function _createFeatureReducers(injector, reducerCollection) {
|
2313 |
|
2314 | var reducers = reducerCollection.map(( |
2315 |
|
2316 |
|
2317 | function (reducer) {
|
2318 | return reducer instanceof ngCore.InjectionToken ? injector.get(reducer) : reducer;
|
2319 | }));
|
2320 | return reducers;
|
2321 | }
|
2322 | |
2323 |
|
2324 |
|
2325 |
|
2326 | function _initialStateFactory(initialState) {
|
2327 | if (typeof initialState === 'function') {
|
2328 | return initialState();
|
2329 | }
|
2330 | return initialState;
|
2331 | }
|
2332 | |
2333 |
|
2334 |
|
2335 |
|
2336 |
|
2337 | function _concatMetaReducers(metaReducers, userProvidedMetaReducers) {
|
2338 | return metaReducers.concat(userProvidedMetaReducers);
|
2339 | }
|
2340 | |
2341 |
|
2342 |
|
2343 |
|
2344 | function _provideForRootGuard(store) {
|
2345 | if (store) {
|
2346 | throw new TypeError("StoreModule.forRoot() called twice. Feature modules should use StoreModule.forFeature() instead.");
|
2347 | }
|
2348 | return 'guarded';
|
2349 | }
|
2350 |
|
2351 | |
2352 |
|
2353 |
|
2354 |
|
2355 |
|
2356 | |
2357 |
|
2358 |
|
2359 |
|
2360 |
|
2361 |
|
2362 | function ReducerTypes() { }
|
2363 | if (false) {
|
2364 |
|
2365 | ReducerTypes.prototype.reducer;
|
2366 |
|
2367 | ReducerTypes.prototype.types;
|
2368 | }
|
2369 | |
2370 |
|
2371 |
|
2372 |
|
2373 | function OnReducer() { }
|
2374 | |
2375 |
|
2376 |
|
2377 |
|
2378 |
|
2379 |
|
2380 |
|
2381 |
|
2382 |
|
2383 |
|
2384 |
|
2385 |
|
2386 |
|
2387 |
|
2388 |
|
2389 | function on() {
|
2390 | var args = [];
|
2391 | for (var _i = 0; _i < arguments.length; _i++) {
|
2392 | args[_i] = arguments[_i];
|
2393 | }
|
2394 |
|
2395 |
|
2396 |
|
2397 | var reducer = ( (args.pop()));
|
2398 |
|
2399 | var types = ( ((( ((( ((( (args)))))).map(( |
2400 |
|
2401 |
|
2402 | function (creator) { return creator.type; })))))));
|
2403 | return { reducer: reducer, types: types };
|
2404 | }
|
2405 | |
2406 |
|
2407 |
|
2408 |
|
2409 |
|
2410 |
|
2411 |
|
2412 |
|
2413 |
|
2414 |
|
2415 |
|
2416 |
|
2417 |
|
2418 |
|
2419 |
|
2420 |
|
2421 |
|
2422 |
|
2423 |
|
2424 |
|
2425 |
|
2426 |
|
2427 |
|
2428 |
|
2429 |
|
2430 |
|
2431 |
|
2432 |
|
2433 |
|
2434 |
|
2435 |
|
2436 |
|
2437 |
|
2438 |
|
2439 |
|
2440 |
|
2441 |
|
2442 |
|
2443 |
|
2444 |
|
2445 |
|
2446 |
|
2447 |
|
2448 |
|
2449 |
|
2450 |
|
2451 |
|
2452 |
|
2453 |
|
2454 | function createReducer(initialState) {
|
2455 | var e_1, _a;
|
2456 | var ons = [];
|
2457 | for (var _i = 1; _i < arguments.length; _i++) {
|
2458 | ons[_i - 1] = arguments[_i];
|
2459 | }
|
2460 |
|
2461 | var map = new Map();
|
2462 | var _loop_1 = function (on_1) {
|
2463 | var e_2, _a;
|
2464 | var _loop_2 = function (type) {
|
2465 |
|
2466 | var existingReducer = map.get(type);
|
2467 | if (existingReducer) {
|
2468 |
|
2469 | var newReducer = ( |
2470 |
|
2471 |
|
2472 |
|
2473 | function (state, action) { return on_1.reducer(existingReducer(state, action), action); });
|
2474 | map.set(type, newReducer);
|
2475 | }
|
2476 | else {
|
2477 | map.set(type, on_1.reducer);
|
2478 | }
|
2479 | };
|
2480 | try {
|
2481 | for (var _b = (e_2 = void 0, __values(on_1.types)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
2482 | var type = _c.value;
|
2483 | _loop_2(type);
|
2484 | }
|
2485 | }
|
2486 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
2487 | finally {
|
2488 | try {
|
2489 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
2490 | }
|
2491 | finally { if (e_2) throw e_2.error; }
|
2492 | }
|
2493 | };
|
2494 | try {
|
2495 | for (var ons_1 = __values(ons), ons_1_1 = ons_1.next(); !ons_1_1.done; ons_1_1 = ons_1.next()) {
|
2496 | var on_1 = ons_1_1.value;
|
2497 | _loop_1(on_1);
|
2498 | }
|
2499 | }
|
2500 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
2501 | finally {
|
2502 | try {
|
2503 | if (ons_1_1 && !ons_1_1.done && (_a = ons_1.return)) _a.call(ons_1);
|
2504 | }
|
2505 | finally { if (e_1) throw e_1.error; }
|
2506 | }
|
2507 | return ( |
2508 |
|
2509 |
|
2510 |
|
2511 | function (state, action) {
|
2512 | if (state === void 0) { state = initialState; }
|
2513 |
|
2514 | var reducer = map.get(action.type);
|
2515 | return reducer ? reducer(state, action) : state;
|
2516 | });
|
2517 | }
|
2518 |
|
2519 | |
2520 |
|
2521 |
|
2522 |
|
2523 |
|
2524 |
|
2525 | |
2526 |
|
2527 |
|
2528 |
|
2529 |
|
2530 |
|
2531 | |
2532 |
|
2533 |
|
2534 |
|
2535 |
|
2536 |
|
2537 | |
2538 |
|
2539 |
|
2540 |
|
2541 |
|
2542 |
|
2543 | exports.ActionsSubject = ActionsSubject;
|
2544 | exports.FEATURE_REDUCERS = FEATURE_REDUCERS;
|
2545 | exports.INIT = INIT;
|
2546 | exports.INITIAL_REDUCERS = INITIAL_REDUCERS;
|
2547 | exports.INITIAL_STATE = INITIAL_STATE;
|
2548 | exports.META_REDUCERS = META_REDUCERS;
|
2549 | exports.REDUCER_FACTORY = REDUCER_FACTORY;
|
2550 | exports.ReducerManager = ReducerManager;
|
2551 | exports.ReducerManagerDispatcher = ReducerManagerDispatcher;
|
2552 | exports.ReducerObservable = ReducerObservable;
|
2553 | exports.STORE_FEATURES = STORE_FEATURES;
|
2554 | exports.ScannedActionsSubject = ScannedActionsSubject;
|
2555 | exports.State = State;
|
2556 | exports.StateObservable = StateObservable;
|
2557 | exports.Store = Store;
|
2558 | exports.StoreFeatureModule = StoreFeatureModule;
|
2559 | exports.StoreModule = StoreModule;
|
2560 | exports.StoreRootModule = StoreRootModule;
|
2561 | exports.UPDATE = UPDATE;
|
2562 | exports.USER_PROVIDED_META_REDUCERS = USER_PROVIDED_META_REDUCERS;
|
2563 | exports.USER_RUNTIME_CHECKS = USER_RUNTIME_CHECKS;
|
2564 | exports.combineReducers = combineReducers;
|
2565 | exports.compose = compose;
|
2566 | exports.createAction = createAction;
|
2567 | exports.createFeatureSelector = createFeatureSelector;
|
2568 | exports.createReducer = createReducer;
|
2569 | exports.createReducerFactory = createReducerFactory;
|
2570 | exports.createSelector = createSelector;
|
2571 | exports.createSelectorFactory = createSelectorFactory;
|
2572 | exports.defaultMemoize = defaultMemoize;
|
2573 | exports.defaultStateFn = defaultStateFn;
|
2574 | exports.isNgrxMockEnvironment = isNgrxMockEnvironment;
|
2575 | exports.on = on;
|
2576 | exports.props = props;
|
2577 | exports.reduceState = reduceState;
|
2578 | exports.resultMemoize = resultMemoize;
|
2579 | exports.select = select;
|
2580 | exports.setNgrxMockEnvironment = setNgrxMockEnvironment;
|
2581 | exports.union = union;
|
2582 | exports.ɵb = STORE_PROVIDERS;
|
2583 | exports.ɵba = createActiveRuntimeChecks;
|
2584 | exports.ɵbb = createSerializationCheckMetaReducer;
|
2585 | exports.ɵbc = createImmutabilityCheckMetaReducer;
|
2586 | exports.ɵbd = createInNgZoneCheckMetaReducer;
|
2587 | exports.ɵbe = provideRuntimeChecks;
|
2588 | exports.ɵbf = checkForActionTypeUniqueness;
|
2589 | exports.ɵbg = _runtimeChecksFactory;
|
2590 | exports.ɵbh = _actionTypeUniquenessCheck;
|
2591 | exports.ɵc = ACTIONS_SUBJECT_PROVIDERS;
|
2592 | exports.ɵd = REDUCER_MANAGER_PROVIDERS;
|
2593 | exports.ɵe = SCANNED_ACTIONS_SUBJECT_PROVIDERS;
|
2594 | exports.ɵf = isEqualCheck;
|
2595 | exports.ɵg = STATE_PROVIDERS;
|
2596 | exports.ɵh = _ROOT_STORE_GUARD;
|
2597 | exports.ɵi = _INITIAL_STATE;
|
2598 | exports.ɵj = _REDUCER_FACTORY;
|
2599 | exports.ɵk = _INITIAL_REDUCERS;
|
2600 | exports.ɵl = _STORE_REDUCERS;
|
2601 | exports.ɵm = _FEATURE_REDUCERS;
|
2602 | exports.ɵn = _FEATURE_CONFIGS;
|
2603 | exports.ɵo = _STORE_FEATURES;
|
2604 | exports.ɵp = _FEATURE_REDUCERS_TOKEN;
|
2605 | exports.ɵq = _RESOLVED_META_REDUCERS;
|
2606 | exports.ɵr = _USER_RUNTIME_CHECKS;
|
2607 | exports.ɵs = _ACTIVE_RUNTIME_CHECKS;
|
2608 | exports.ɵt = _ACTION_TYPE_UNIQUENESS_CHECK;
|
2609 | exports.ɵu = _createStoreReducers;
|
2610 | exports.ɵv = _createFeatureStore;
|
2611 | exports.ɵw = _createFeatureReducers;
|
2612 | exports.ɵx = _initialStateFactory;
|
2613 | exports.ɵy = _concatMetaReducers;
|
2614 | exports.ɵz = _provideForRootGuard;
|
2615 |
|
2616 | Object.defineProperty(exports, '__esModule', { value: true });
|
2617 |
|
2618 | })));
|
2619 |
|