UNPKG

61.1 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@ngrx/store'), require('rxjs'), require('rxjs/operators')) :
3 typeof define === 'function' && define.amd ? define('@ngrx/store-devtools', ['exports', '@angular/core', '@ngrx/store', 'rxjs', 'rxjs/operators'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ngrx = global.ngrx || {}, global.ngrx['store-devtools'] = {}), global.ng.core, global.ngrx.store, global.rxjs, global.rxjs.operators));
5}(this, (function (exports, core, store, rxjs, operators) { 'use strict';
6
7 var StoreDevtoolsConfig = /** @class */ (function () {
8 function StoreDevtoolsConfig() {
9 this.maxAge = false;
10 }
11 return StoreDevtoolsConfig;
12 }());
13 var STORE_DEVTOOLS_CONFIG = new core.InjectionToken('@ngrx/store-devtools Options');
14 var INITIAL_OPTIONS = new core.InjectionToken('@ngrx/store-devtools Initial Config');
15 function noMonitor() {
16 return null;
17 }
18 var DEFAULT_NAME = 'NgRx Store DevTools';
19 function createConfig(optionsInput) {
20 var DEFAULT_OPTIONS = {
21 maxAge: false,
22 monitor: noMonitor,
23 actionSanitizer: undefined,
24 stateSanitizer: undefined,
25 name: DEFAULT_NAME,
26 serialize: false,
27 logOnly: false,
28 // Add all features explicitly. This prevent buggy behavior for
29 // options like "lock" which might otherwise not show up.
30 features: {
31 pause: true,
32 lock: true,
33 persist: true,
34 export: true,
35 import: 'custom',
36 jump: true,
37 skip: true,
38 reorder: true,
39 dispatch: true,
40 test: true, // generate tests for the selected actions
41 },
42 };
43 var options = typeof optionsInput === 'function' ? optionsInput() : optionsInput;
44 var logOnly = options.logOnly
45 ? { pause: true, export: true, test: true }
46 : false;
47 var features = options.features || logOnly || DEFAULT_OPTIONS.features;
48 var config = Object.assign({}, DEFAULT_OPTIONS, { features: features }, options);
49 if (config.maxAge && config.maxAge < 2) {
50 throw new Error("Devtools 'maxAge' cannot be less than 2, got " + config.maxAge);
51 }
52 return config;
53 }
54
55 /*! *****************************************************************************
56 Copyright (c) Microsoft Corporation.
57
58 Permission to use, copy, modify, and/or distribute this software for any
59 purpose with or without fee is hereby granted.
60
61 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
62 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
63 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
64 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
65 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
66 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
67 PERFORMANCE OF THIS SOFTWARE.
68 ***************************************************************************** */
69 /* global Reflect, Promise */
70 var extendStatics = function (d, b) {
71 extendStatics = Object.setPrototypeOf ||
72 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
73 function (d, b) { for (var p in b)
74 if (Object.prototype.hasOwnProperty.call(b, p))
75 d[p] = b[p]; };
76 return extendStatics(d, b);
77 };
78 function __extends(d, b) {
79 if (typeof b !== "function" && b !== null)
80 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
81 extendStatics(d, b);
82 function __() { this.constructor = d; }
83 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
84 }
85 var __assign = function () {
86 __assign = Object.assign || function __assign(t) {
87 for (var s, i = 1, n = arguments.length; i < n; i++) {
88 s = arguments[i];
89 for (var p in s)
90 if (Object.prototype.hasOwnProperty.call(s, p))
91 t[p] = s[p];
92 }
93 return t;
94 };
95 return __assign.apply(this, arguments);
96 };
97 function __rest(s, e) {
98 var t = {};
99 for (var p in s)
100 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
101 t[p] = s[p];
102 if (s != null && typeof Object.getOwnPropertySymbols === "function")
103 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
104 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
105 t[p[i]] = s[p[i]];
106 }
107 return t;
108 }
109 function __decorate(decorators, target, key, desc) {
110 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
111 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
112 r = Reflect.decorate(decorators, target, key, desc);
113 else
114 for (var i = decorators.length - 1; i >= 0; i--)
115 if (d = decorators[i])
116 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
117 return c > 3 && r && Object.defineProperty(target, key, r), r;
118 }
119 function __param(paramIndex, decorator) {
120 return function (target, key) { decorator(target, key, paramIndex); };
121 }
122 function __metadata(metadataKey, metadataValue) {
123 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
124 return Reflect.metadata(metadataKey, metadataValue);
125 }
126 function __awaiter(thisArg, _arguments, P, generator) {
127 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
128 return new (P || (P = Promise))(function (resolve, reject) {
129 function fulfilled(value) { try {
130 step(generator.next(value));
131 }
132 catch (e) {
133 reject(e);
134 } }
135 function rejected(value) { try {
136 step(generator["throw"](value));
137 }
138 catch (e) {
139 reject(e);
140 } }
141 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
142 step((generator = generator.apply(thisArg, _arguments || [])).next());
143 });
144 }
145 function __generator(thisArg, body) {
146 var _ = { label: 0, sent: function () { if (t[0] & 1)
147 throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
148 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
149 function verb(n) { return function (v) { return step([n, v]); }; }
150 function step(op) {
151 if (f)
152 throw new TypeError("Generator is already executing.");
153 while (_)
154 try {
155 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)
156 return t;
157 if (y = 0, t)
158 op = [op[0] & 2, t.value];
159 switch (op[0]) {
160 case 0:
161 case 1:
162 t = op;
163 break;
164 case 4:
165 _.label++;
166 return { value: op[1], done: false };
167 case 5:
168 _.label++;
169 y = op[1];
170 op = [0];
171 continue;
172 case 7:
173 op = _.ops.pop();
174 _.trys.pop();
175 continue;
176 default:
177 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
178 _ = 0;
179 continue;
180 }
181 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
182 _.label = op[1];
183 break;
184 }
185 if (op[0] === 6 && _.label < t[1]) {
186 _.label = t[1];
187 t = op;
188 break;
189 }
190 if (t && _.label < t[2]) {
191 _.label = t[2];
192 _.ops.push(op);
193 break;
194 }
195 if (t[2])
196 _.ops.pop();
197 _.trys.pop();
198 continue;
199 }
200 op = body.call(thisArg, _);
201 }
202 catch (e) {
203 op = [6, e];
204 y = 0;
205 }
206 finally {
207 f = t = 0;
208 }
209 if (op[0] & 5)
210 throw op[1];
211 return { value: op[0] ? op[1] : void 0, done: true };
212 }
213 }
214 var __createBinding = Object.create ? (function (o, m, k, k2) {
215 if (k2 === undefined)
216 k2 = k;
217 Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
218 }) : (function (o, m, k, k2) {
219 if (k2 === undefined)
220 k2 = k;
221 o[k2] = m[k];
222 });
223 function __exportStar(m, o) {
224 for (var p in m)
225 if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
226 __createBinding(o, m, p);
227 }
228 function __values(o) {
229 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
230 if (m)
231 return m.call(o);
232 if (o && typeof o.length === "number")
233 return {
234 next: function () {
235 if (o && i >= o.length)
236 o = void 0;
237 return { value: o && o[i++], done: !o };
238 }
239 };
240 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
241 }
242 function __read(o, n) {
243 var m = typeof Symbol === "function" && o[Symbol.iterator];
244 if (!m)
245 return o;
246 var i = m.call(o), r, ar = [], e;
247 try {
248 while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
249 ar.push(r.value);
250 }
251 catch (error) {
252 e = { error: error };
253 }
254 finally {
255 try {
256 if (r && !r.done && (m = i["return"]))
257 m.call(i);
258 }
259 finally {
260 if (e)
261 throw e.error;
262 }
263 }
264 return ar;
265 }
266 /** @deprecated */
267 function __spread() {
268 for (var ar = [], i = 0; i < arguments.length; i++)
269 ar = ar.concat(__read(arguments[i]));
270 return ar;
271 }
272 /** @deprecated */
273 function __spreadArrays() {
274 for (var s = 0, i = 0, il = arguments.length; i < il; i++)
275 s += arguments[i].length;
276 for (var r = Array(s), k = 0, i = 0; i < il; i++)
277 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
278 r[k] = a[j];
279 return r;
280 }
281 function __spreadArray(to, from) {
282 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
283 to[j] = from[i];
284 return to;
285 }
286 function __await(v) {
287 return this instanceof __await ? (this.v = v, this) : new __await(v);
288 }
289 function __asyncGenerator(thisArg, _arguments, generator) {
290 if (!Symbol.asyncIterator)
291 throw new TypeError("Symbol.asyncIterator is not defined.");
292 var g = generator.apply(thisArg, _arguments || []), i, q = [];
293 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
294 function verb(n) { if (g[n])
295 i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
296 function resume(n, v) { try {
297 step(g[n](v));
298 }
299 catch (e) {
300 settle(q[0][3], e);
301 } }
302 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
303 function fulfill(value) { resume("next", value); }
304 function reject(value) { resume("throw", value); }
305 function settle(f, v) { if (f(v), q.shift(), q.length)
306 resume(q[0][0], q[0][1]); }
307 }
308 function __asyncDelegator(o) {
309 var i, p;
310 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
311 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; }
312 }
313 function __asyncValues(o) {
314 if (!Symbol.asyncIterator)
315 throw new TypeError("Symbol.asyncIterator is not defined.");
316 var m = o[Symbol.asyncIterator], i;
317 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);
318 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); }); }; }
319 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
320 }
321 function __makeTemplateObject(cooked, raw) {
322 if (Object.defineProperty) {
323 Object.defineProperty(cooked, "raw", { value: raw });
324 }
325 else {
326 cooked.raw = raw;
327 }
328 return cooked;
329 }
330 ;
331 var __setModuleDefault = Object.create ? (function (o, v) {
332 Object.defineProperty(o, "default", { enumerable: true, value: v });
333 }) : function (o, v) {
334 o["default"] = v;
335 };
336 function __importStar(mod) {
337 if (mod && mod.__esModule)
338 return mod;
339 var result = {};
340 if (mod != null)
341 for (var k in mod)
342 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
343 __createBinding(result, mod, k);
344 __setModuleDefault(result, mod);
345 return result;
346 }
347 function __importDefault(mod) {
348 return (mod && mod.__esModule) ? mod : { default: mod };
349 }
350 function __classPrivateFieldGet(receiver, state, kind, f) {
351 if (kind === "a" && !f)
352 throw new TypeError("Private accessor was defined without a getter");
353 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
354 throw new TypeError("Cannot read private member from an object whose class did not declare it");
355 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
356 }
357 function __classPrivateFieldSet(receiver, state, value, kind, f) {
358 if (kind === "m")
359 throw new TypeError("Private method is not writable");
360 if (kind === "a" && !f)
361 throw new TypeError("Private accessor was defined without a setter");
362 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
363 throw new TypeError("Cannot write private member to an object whose class did not declare it");
364 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
365 }
366
367 var PERFORM_ACTION = 'PERFORM_ACTION';
368 var REFRESH = 'REFRESH';
369 var RESET = 'RESET';
370 var ROLLBACK = 'ROLLBACK';
371 var COMMIT = 'COMMIT';
372 var SWEEP = 'SWEEP';
373 var TOGGLE_ACTION = 'TOGGLE_ACTION';
374 var SET_ACTIONS_ACTIVE = 'SET_ACTIONS_ACTIVE';
375 var JUMP_TO_STATE = 'JUMP_TO_STATE';
376 var JUMP_TO_ACTION = 'JUMP_TO_ACTION';
377 var IMPORT_STATE = 'IMPORT_STATE';
378 var LOCK_CHANGES = 'LOCK_CHANGES';
379 var PAUSE_RECORDING = 'PAUSE_RECORDING';
380 var PerformAction = /** @class */ (function () {
381 function PerformAction(action, timestamp) {
382 this.action = action;
383 this.timestamp = timestamp;
384 this.type = PERFORM_ACTION;
385 if (typeof action.type === 'undefined') {
386 throw new Error('Actions may not have an undefined "type" property. ' +
387 'Have you misspelled a constant?');
388 }
389 }
390 return PerformAction;
391 }());
392 var Refresh = /** @class */ (function () {
393 function Refresh() {
394 this.type = REFRESH;
395 }
396 return Refresh;
397 }());
398 var Reset = /** @class */ (function () {
399 function Reset(timestamp) {
400 this.timestamp = timestamp;
401 this.type = RESET;
402 }
403 return Reset;
404 }());
405 var Rollback = /** @class */ (function () {
406 function Rollback(timestamp) {
407 this.timestamp = timestamp;
408 this.type = ROLLBACK;
409 }
410 return Rollback;
411 }());
412 var Commit = /** @class */ (function () {
413 function Commit(timestamp) {
414 this.timestamp = timestamp;
415 this.type = COMMIT;
416 }
417 return Commit;
418 }());
419 var Sweep = /** @class */ (function () {
420 function Sweep() {
421 this.type = SWEEP;
422 }
423 return Sweep;
424 }());
425 var ToggleAction = /** @class */ (function () {
426 function ToggleAction(id) {
427 this.id = id;
428 this.type = TOGGLE_ACTION;
429 }
430 return ToggleAction;
431 }());
432 var SetActionsActive = /** @class */ (function () {
433 function SetActionsActive(start, end, active) {
434 if (active === void 0) { active = true; }
435 this.start = start;
436 this.end = end;
437 this.active = active;
438 this.type = SET_ACTIONS_ACTIVE;
439 }
440 return SetActionsActive;
441 }());
442 var JumpToState = /** @class */ (function () {
443 function JumpToState(index) {
444 this.index = index;
445 this.type = JUMP_TO_STATE;
446 }
447 return JumpToState;
448 }());
449 var JumpToAction = /** @class */ (function () {
450 function JumpToAction(actionId) {
451 this.actionId = actionId;
452 this.type = JUMP_TO_ACTION;
453 }
454 return JumpToAction;
455 }());
456 var ImportState = /** @class */ (function () {
457 function ImportState(nextLiftedState) {
458 this.nextLiftedState = nextLiftedState;
459 this.type = IMPORT_STATE;
460 }
461 return ImportState;
462 }());
463 var LockChanges = /** @class */ (function () {
464 function LockChanges(status) {
465 this.status = status;
466 this.type = LOCK_CHANGES;
467 }
468 return LockChanges;
469 }());
470 var PauseRecording = /** @class */ (function () {
471 function PauseRecording(status) {
472 this.status = status;
473 this.type = PAUSE_RECORDING;
474 }
475 return PauseRecording;
476 }());
477
478 var DevtoolsDispatcher = /** @class */ (function (_super) {
479 __extends(DevtoolsDispatcher, _super);
480 function DevtoolsDispatcher() {
481 return _super !== null && _super.apply(this, arguments) || this;
482 }
483 return DevtoolsDispatcher;
484 }(store.ActionsSubject));
485 DevtoolsDispatcher.decorators = [
486 { type: core.Injectable }
487 ];
488
489 function difference(first, second) {
490 return first.filter(function (item) { return second.indexOf(item) < 0; });
491 }
492 /**
493 * Provides an app's view into the state of the lifted store.
494 */
495 function unliftState(liftedState) {
496 var computedStates = liftedState.computedStates, currentStateIndex = liftedState.currentStateIndex;
497 // At start up NgRx dispatches init actions,
498 // When these init actions are being filtered out by the predicate or safe/block list options
499 // we don't have a complete computed states yet.
500 // At this point it could happen that we're out of bounds, when this happens we fall back to the last known state
501 if (currentStateIndex >= computedStates.length) {
502 var state_1 = computedStates[computedStates.length - 1].state;
503 return state_1;
504 }
505 var state = computedStates[currentStateIndex].state;
506 return state;
507 }
508 function unliftAction(liftedState) {
509 return liftedState.actionsById[liftedState.nextActionId - 1];
510 }
511 /**
512 * Lifts an app's action into an action on the lifted store.
513 */
514 function liftAction(action) {
515 return new PerformAction(action, +Date.now());
516 }
517 /**
518 * Sanitizes given actions with given function.
519 */
520 function sanitizeActions(actionSanitizer, actions) {
521 return Object.keys(actions).reduce(function (sanitizedActions, actionIdx) {
522 var idx = Number(actionIdx);
523 sanitizedActions[idx] = sanitizeAction(actionSanitizer, actions[idx], idx);
524 return sanitizedActions;
525 }, {});
526 }
527 /**
528 * Sanitizes given action with given function.
529 */
530 function sanitizeAction(actionSanitizer, action, actionIdx) {
531 return Object.assign(Object.assign({}, action), { action: actionSanitizer(action.action, actionIdx) });
532 }
533 /**
534 * Sanitizes given states with given function.
535 */
536 function sanitizeStates(stateSanitizer, states) {
537 return states.map(function (computedState, idx) { return ({
538 state: sanitizeState(stateSanitizer, computedState.state, idx),
539 error: computedState.error,
540 }); });
541 }
542 /**
543 * Sanitizes given state with given function.
544 */
545 function sanitizeState(stateSanitizer, state, stateIdx) {
546 return stateSanitizer(state, stateIdx);
547 }
548 /**
549 * Read the config and tell if actions should be filtered
550 */
551 function shouldFilterActions(config) {
552 return config.predicate || config.actionsSafelist || config.actionsBlocklist;
553 }
554 /**
555 * Return a full filtered lifted state
556 */
557 function filterLiftedState(liftedState, predicate, safelist, blocklist) {
558 var filteredStagedActionIds = [];
559 var filteredActionsById = {};
560 var filteredComputedStates = [];
561 liftedState.stagedActionIds.forEach(function (id, idx) {
562 var liftedAction = liftedState.actionsById[id];
563 if (!liftedAction)
564 return;
565 if (idx &&
566 isActionFiltered(liftedState.computedStates[idx], liftedAction, predicate, safelist, blocklist)) {
567 return;
568 }
569 filteredActionsById[id] = liftedAction;
570 filteredStagedActionIds.push(id);
571 filteredComputedStates.push(liftedState.computedStates[idx]);
572 });
573 return Object.assign(Object.assign({}, liftedState), { stagedActionIds: filteredStagedActionIds, actionsById: filteredActionsById, computedStates: filteredComputedStates });
574 }
575 /**
576 * Return true is the action should be ignored
577 */
578 function isActionFiltered(state, action, predicate, safelist, blockedlist) {
579 var predicateMatch = predicate && !predicate(state, action.action);
580 var safelistMatch = safelist &&
581 !action.action.type.match(safelist.map(function (s) { return escapeRegExp(s); }).join('|'));
582 var blocklistMatch = blockedlist &&
583 action.action.type.match(blockedlist.map(function (s) { return escapeRegExp(s); }).join('|'));
584 return predicateMatch || safelistMatch || blocklistMatch;
585 }
586 /**
587 * Return string with escaped RegExp special characters
588 * https://stackoverflow.com/a/6969486/1337347
589 */
590 function escapeRegExp(s) {
591 return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
592 }
593
594 var ExtensionActionTypes = {
595 START: 'START',
596 DISPATCH: 'DISPATCH',
597 STOP: 'STOP',
598 ACTION: 'ACTION',
599 };
600 var REDUX_DEVTOOLS_EXTENSION = new core.InjectionToken('@ngrx/store-devtools Redux Devtools Extension');
601 var DevtoolsExtension = /** @class */ (function () {
602 function DevtoolsExtension(devtoolsExtension, config, dispatcher) {
603 this.config = config;
604 this.dispatcher = dispatcher;
605 this.devtoolsExtension = devtoolsExtension;
606 this.createActionStreams();
607 }
608 DevtoolsExtension.prototype.notify = function (action, state) {
609 var _this = this;
610 if (!this.devtoolsExtension) {
611 return;
612 }
613 // Check to see if the action requires a full update of the liftedState.
614 // If it is a simple action generated by the user's app and the recording
615 // is not locked/paused, only send the action and the current state (fast).
616 //
617 // A full liftedState update (slow: serializes the entire liftedState) is
618 // only required when:
619 // a) redux-devtools-extension fires the @@Init action (ignored by
620 // @ngrx/store-devtools)
621 // b) an action is generated by an @ngrx module (e.g. @ngrx/effects/init
622 // or @ngrx/store/update-reducers)
623 // c) the state has been recomputed due to time-traveling
624 // d) any action that is not a PerformAction to err on the side of
625 // caution.
626 if (action.type === PERFORM_ACTION) {
627 if (state.isLocked || state.isPaused) {
628 return;
629 }
630 var currentState = unliftState(state);
631 if (shouldFilterActions(this.config) &&
632 isActionFiltered(currentState, action, this.config.predicate, this.config.actionsSafelist, this.config.actionsBlocklist)) {
633 return;
634 }
635 var sanitizedState_1 = this.config.stateSanitizer
636 ? sanitizeState(this.config.stateSanitizer, currentState, state.currentStateIndex)
637 : currentState;
638 var sanitizedAction_1 = this.config.actionSanitizer
639 ? sanitizeAction(this.config.actionSanitizer, action, state.nextActionId)
640 : action;
641 this.sendToReduxDevtools(function () { return _this.extensionConnection.send(sanitizedAction_1, sanitizedState_1); });
642 }
643 else {
644 // Requires full state update
645 var sanitizedLiftedState_1 = Object.assign(Object.assign({}, state), { stagedActionIds: state.stagedActionIds, actionsById: this.config.actionSanitizer
646 ? sanitizeActions(this.config.actionSanitizer, state.actionsById)
647 : state.actionsById, computedStates: this.config.stateSanitizer
648 ? sanitizeStates(this.config.stateSanitizer, state.computedStates)
649 : state.computedStates });
650 this.sendToReduxDevtools(function () { return _this.devtoolsExtension.send(null, sanitizedLiftedState_1, _this.getExtensionConfig(_this.config)); });
651 }
652 };
653 DevtoolsExtension.prototype.createChangesObservable = function () {
654 var _this = this;
655 if (!this.devtoolsExtension) {
656 return rxjs.EMPTY;
657 }
658 return new rxjs.Observable(function (subscriber) {
659 var connection = _this.devtoolsExtension.connect(_this.getExtensionConfig(_this.config));
660 _this.extensionConnection = connection;
661 connection.init();
662 connection.subscribe(function (change) { return subscriber.next(change); });
663 return connection.unsubscribe;
664 });
665 };
666 DevtoolsExtension.prototype.createActionStreams = function () {
667 var _this = this;
668 // Listens to all changes
669 var changes$ = this.createChangesObservable().pipe(operators.share());
670 // Listen for the start action
671 var start$ = changes$.pipe(operators.filter(function (change) { return change.type === ExtensionActionTypes.START; }));
672 // Listen for the stop action
673 var stop$ = changes$.pipe(operators.filter(function (change) { return change.type === ExtensionActionTypes.STOP; }));
674 // Listen for lifted actions
675 var liftedActions$ = changes$.pipe(operators.filter(function (change) { return change.type === ExtensionActionTypes.DISPATCH; }), operators.map(function (change) { return _this.unwrapAction(change.payload); }), operators.concatMap(function (action) {
676 if (action.type === IMPORT_STATE) {
677 // State imports may happen in two situations:
678 // 1. Explicitly by user
679 // 2. User activated the "persist state accross reloads" option
680 // and now the state is imported during reload.
681 // Because of option 2, we need to give possible
682 // lazy loaded reducers time to instantiate.
683 // As soon as there is no UPDATE action within 1 second,
684 // it is assumed that all reducers are loaded.
685 return _this.dispatcher.pipe(operators.filter(function (action) { return action.type === store.UPDATE; }), operators.timeout(1000), operators.debounceTime(1000), operators.map(function () { return action; }), operators.catchError(function () { return rxjs.of(action); }), operators.take(1));
686 }
687 else {
688 return rxjs.of(action);
689 }
690 }));
691 // Listen for unlifted actions
692 var actions$ = changes$.pipe(operators.filter(function (change) { return change.type === ExtensionActionTypes.ACTION; }), operators.map(function (change) { return _this.unwrapAction(change.payload); }));
693 var actionsUntilStop$ = actions$.pipe(operators.takeUntil(stop$));
694 var liftedUntilStop$ = liftedActions$.pipe(operators.takeUntil(stop$));
695 this.start$ = start$.pipe(operators.takeUntil(stop$));
696 // Only take the action sources between the start/stop events
697 this.actions$ = this.start$.pipe(operators.switchMap(function () { return actionsUntilStop$; }));
698 this.liftedActions$ = this.start$.pipe(operators.switchMap(function () { return liftedUntilStop$; }));
699 };
700 DevtoolsExtension.prototype.unwrapAction = function (action) {
701 return typeof action === 'string' ? eval("(" + action + ")") : action;
702 };
703 DevtoolsExtension.prototype.getExtensionConfig = function (config) {
704 var extensionOptions = {
705 name: config.name,
706 features: config.features,
707 serialize: config.serialize,
708 // The action/state sanitizers are not added to the config
709 // because sanitation is done in this class already.
710 // It is done before sending it to the devtools extension for consistency:
711 // - If we call extensionConnection.send(...),
712 // the extension would call the sanitizers.
713 // - If we call devtoolsExtension.send(...) (aka full state update),
714 // the extension would NOT call the sanitizers, so we have to do it ourselves.
715 };
716 if (config.maxAge !== false /* support === 0 */) {
717 extensionOptions.maxAge = config.maxAge;
718 }
719 return extensionOptions;
720 };
721 DevtoolsExtension.prototype.sendToReduxDevtools = function (send) {
722 try {
723 send();
724 }
725 catch (err) {
726 console.warn('@ngrx/store-devtools: something went wrong inside the redux devtools', err);
727 }
728 };
729 return DevtoolsExtension;
730 }());
731 DevtoolsExtension.decorators = [
732 { type: core.Injectable }
733 ];
734 /** @nocollapse */
735 DevtoolsExtension.ctorParameters = function () { return [
736 { type: undefined, decorators: [{ type: core.Inject, args: [REDUX_DEVTOOLS_EXTENSION,] }] },
737 { type: StoreDevtoolsConfig, decorators: [{ type: core.Inject, args: [STORE_DEVTOOLS_CONFIG,] }] },
738 { type: DevtoolsDispatcher }
739 ]; };
740
741 var INIT_ACTION = { type: store.INIT };
742 var RECOMPUTE = '@ngrx/store-devtools/recompute';
743 var RECOMPUTE_ACTION = { type: RECOMPUTE };
744 /**
745 * Computes the next entry in the log by applying an action.
746 */
747 function computeNextEntry(reducer, action, state, error, errorHandler) {
748 if (error) {
749 return {
750 state: state,
751 error: 'Interrupted by an error up the chain',
752 };
753 }
754 var nextState = state;
755 var nextError;
756 try {
757 nextState = reducer(state, action);
758 }
759 catch (err) {
760 nextError = err.toString();
761 errorHandler.handleError(err);
762 }
763 return {
764 state: nextState,
765 error: nextError,
766 };
767 }
768 /**
769 * Runs the reducer on invalidated actions to get a fresh computation log.
770 */
771 function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused) {
772 // Optimization: exit early and return the same reference
773 // if we know nothing could have changed.
774 if (minInvalidatedStateIndex >= computedStates.length &&
775 computedStates.length === stagedActionIds.length) {
776 return computedStates;
777 }
778 var nextComputedStates = computedStates.slice(0, minInvalidatedStateIndex);
779 // If the recording is paused, recompute all states up until the pause state,
780 // else recompute all states.
781 var lastIncludedActionId = stagedActionIds.length - (isPaused ? 1 : 0);
782 for (var i = minInvalidatedStateIndex; i < lastIncludedActionId; i++) {
783 var actionId = stagedActionIds[i];
784 var action = actionsById[actionId].action;
785 var previousEntry = nextComputedStates[i - 1];
786 var previousState = previousEntry ? previousEntry.state : committedState;
787 var previousError = previousEntry ? previousEntry.error : undefined;
788 var shouldSkip = skippedActionIds.indexOf(actionId) > -1;
789 var entry = shouldSkip
790 ? previousEntry
791 : computeNextEntry(reducer, action, previousState, previousError, errorHandler);
792 nextComputedStates.push(entry);
793 }
794 // If the recording is paused, the last state will not be recomputed,
795 // because it's essentially not part of the state history.
796 if (isPaused) {
797 nextComputedStates.push(computedStates[computedStates.length - 1]);
798 }
799 return nextComputedStates;
800 }
801 function liftInitialState(initialCommittedState, monitorReducer) {
802 return {
803 monitorState: monitorReducer(undefined, {}),
804 nextActionId: 1,
805 actionsById: { 0: liftAction(INIT_ACTION) },
806 stagedActionIds: [0],
807 skippedActionIds: [],
808 committedState: initialCommittedState,
809 currentStateIndex: 0,
810 computedStates: [],
811 isLocked: false,
812 isPaused: false,
813 };
814 }
815 /**
816 * Creates a history state reducer from an app's reducer.
817 */
818 function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler, monitorReducer, options) {
819 if (options === void 0) { options = {}; }
820 /**
821 * Manages how the history actions modify the history state.
822 */
823 return function (reducer) { return function (liftedState, liftedAction) {
824 var _a;
825 var _b = liftedState || initialLiftedState, monitorState = _b.monitorState, actionsById = _b.actionsById, nextActionId = _b.nextActionId, stagedActionIds = _b.stagedActionIds, skippedActionIds = _b.skippedActionIds, committedState = _b.committedState, currentStateIndex = _b.currentStateIndex, computedStates = _b.computedStates, isLocked = _b.isLocked, isPaused = _b.isPaused;
826 if (!liftedState) {
827 // Prevent mutating initialLiftedState
828 actionsById = Object.create(actionsById);
829 }
830 function commitExcessActions(n) {
831 // Auto-commits n-number of excess actions.
832 var excess = n;
833 var idsToDelete = stagedActionIds.slice(1, excess + 1);
834 for (var i = 0; i < idsToDelete.length; i++) {
835 if (computedStates[i + 1].error) {
836 // Stop if error is found. Commit actions up to error.
837 excess = i;
838 idsToDelete = stagedActionIds.slice(1, excess + 1);
839 break;
840 }
841 else {
842 delete actionsById[idsToDelete[i]];
843 }
844 }
845 skippedActionIds = skippedActionIds.filter(function (id) { return idsToDelete.indexOf(id) === -1; });
846 stagedActionIds = __spreadArray([0], __read(stagedActionIds.slice(excess + 1)));
847 committedState = computedStates[excess].state;
848 computedStates = computedStates.slice(excess);
849 currentStateIndex =
850 currentStateIndex > excess ? currentStateIndex - excess : 0;
851 }
852 function commitChanges() {
853 // Consider the last committed state the new starting point.
854 // Squash any staged actions into a single committed state.
855 actionsById = { 0: liftAction(INIT_ACTION) };
856 nextActionId = 1;
857 stagedActionIds = [0];
858 skippedActionIds = [];
859 committedState = computedStates[currentStateIndex].state;
860 currentStateIndex = 0;
861 computedStates = [];
862 }
863 // By default, aggressively recompute every state whatever happens.
864 // This has O(n) performance, so we'll override this to a sensible
865 // value whenever we feel like we don't have to recompute the states.
866 var minInvalidatedStateIndex = 0;
867 switch (liftedAction.type) {
868 case LOCK_CHANGES: {
869 isLocked = liftedAction.status;
870 minInvalidatedStateIndex = Infinity;
871 break;
872 }
873 case PAUSE_RECORDING: {
874 isPaused = liftedAction.status;
875 if (isPaused) {
876 // Add a pause action to signal the devtools-user the recording is paused.
877 // The corresponding state will be overwritten on each update to always contain
878 // the latest state (see Actions.PERFORM_ACTION).
879 stagedActionIds = __spreadArray(__spreadArray([], __read(stagedActionIds)), [nextActionId]);
880 actionsById[nextActionId] = new PerformAction({
881 type: '@ngrx/devtools/pause',
882 }, +Date.now());
883 nextActionId++;
884 minInvalidatedStateIndex = stagedActionIds.length - 1;
885 computedStates = computedStates.concat(computedStates[computedStates.length - 1]);
886 if (currentStateIndex === stagedActionIds.length - 2) {
887 currentStateIndex++;
888 }
889 minInvalidatedStateIndex = Infinity;
890 }
891 else {
892 commitChanges();
893 }
894 break;
895 }
896 case RESET: {
897 // Get back to the state the store was created with.
898 actionsById = { 0: liftAction(INIT_ACTION) };
899 nextActionId = 1;
900 stagedActionIds = [0];
901 skippedActionIds = [];
902 committedState = initialCommittedState;
903 currentStateIndex = 0;
904 computedStates = [];
905 break;
906 }
907 case COMMIT: {
908 commitChanges();
909 break;
910 }
911 case ROLLBACK: {
912 // Forget about any staged actions.
913 // Start again from the last committed state.
914 actionsById = { 0: liftAction(INIT_ACTION) };
915 nextActionId = 1;
916 stagedActionIds = [0];
917 skippedActionIds = [];
918 currentStateIndex = 0;
919 computedStates = [];
920 break;
921 }
922 case TOGGLE_ACTION: {
923 // Toggle whether an action with given ID is skipped.
924 // Being skipped means it is a no-op during the computation.
925 var actionId_1 = liftedAction.id;
926 var index = skippedActionIds.indexOf(actionId_1);
927 if (index === -1) {
928 skippedActionIds = __spreadArray([actionId_1], __read(skippedActionIds));
929 }
930 else {
931 skippedActionIds = skippedActionIds.filter(function (id) { return id !== actionId_1; });
932 }
933 // Optimization: we know history before this action hasn't changed
934 minInvalidatedStateIndex = stagedActionIds.indexOf(actionId_1);
935 break;
936 }
937 case SET_ACTIONS_ACTIVE: {
938 // Toggle whether an action with given ID is skipped.
939 // Being skipped means it is a no-op during the computation.
940 var start = liftedAction.start, end = liftedAction.end, active = liftedAction.active;
941 var actionIds = [];
942 for (var i = start; i < end; i++)
943 actionIds.push(i);
944 if (active) {
945 skippedActionIds = difference(skippedActionIds, actionIds);
946 }
947 else {
948 skippedActionIds = __spreadArray(__spreadArray([], __read(skippedActionIds)), __read(actionIds));
949 }
950 // Optimization: we know history before this action hasn't changed
951 minInvalidatedStateIndex = stagedActionIds.indexOf(start);
952 break;
953 }
954 case JUMP_TO_STATE: {
955 // Without recomputing anything, move the pointer that tell us
956 // which state is considered the current one. Useful for sliders.
957 currentStateIndex = liftedAction.index;
958 // Optimization: we know the history has not changed.
959 minInvalidatedStateIndex = Infinity;
960 break;
961 }
962 case JUMP_TO_ACTION: {
963 // Jumps to a corresponding state to a specific action.
964 // Useful when filtering actions.
965 var index = stagedActionIds.indexOf(liftedAction.actionId);
966 if (index !== -1)
967 currentStateIndex = index;
968 minInvalidatedStateIndex = Infinity;
969 break;
970 }
971 case SWEEP: {
972 // Forget any actions that are currently being skipped.
973 stagedActionIds = difference(stagedActionIds, skippedActionIds);
974 skippedActionIds = [];
975 currentStateIndex = Math.min(currentStateIndex, stagedActionIds.length - 1);
976 break;
977 }
978 case PERFORM_ACTION: {
979 // Ignore action and return state as is if recording is locked
980 if (isLocked) {
981 return liftedState || initialLiftedState;
982 }
983 if (isPaused ||
984 (liftedState &&
985 isActionFiltered(liftedState.computedStates[currentStateIndex], liftedAction, options.predicate, options.actionsSafelist, options.actionsBlocklist))) {
986 // If recording is paused or if the action should be ignored, overwrite the last state
987 // (corresponds to the pause action) and keep everything else as is.
988 // This way, the app gets the new current state while the devtools
989 // do not record another action.
990 var lastState = computedStates[computedStates.length - 1];
991 computedStates = __spreadArray(__spreadArray([], __read(computedStates.slice(0, -1))), [
992 computeNextEntry(reducer, liftedAction.action, lastState.state, lastState.error, errorHandler),
993 ]);
994 minInvalidatedStateIndex = Infinity;
995 break;
996 }
997 // Auto-commit as new actions come in.
998 if (options.maxAge && stagedActionIds.length === options.maxAge) {
999 commitExcessActions(1);
1000 }
1001 if (currentStateIndex === stagedActionIds.length - 1) {
1002 currentStateIndex++;
1003 }
1004 var actionId = nextActionId++;
1005 // Mutation! This is the hottest path, and we optimize on purpose.
1006 // It is safe because we set a new key in a cache dictionary.
1007 actionsById[actionId] = liftedAction;
1008 stagedActionIds = __spreadArray(__spreadArray([], __read(stagedActionIds)), [actionId]);
1009 // Optimization: we know that only the new action needs computing.
1010 minInvalidatedStateIndex = stagedActionIds.length - 1;
1011 break;
1012 }
1013 case IMPORT_STATE: {
1014 // Completely replace everything.
1015 (_a = liftedAction.nextLiftedState, monitorState = _a.monitorState, actionsById = _a.actionsById, nextActionId = _a.nextActionId, stagedActionIds = _a.stagedActionIds, skippedActionIds = _a.skippedActionIds, committedState = _a.committedState, currentStateIndex = _a.currentStateIndex, computedStates = _a.computedStates, isLocked = _a.isLocked, isPaused = _a.isPaused);
1016 break;
1017 }
1018 case store.INIT: {
1019 // Always recompute states on hot reload and init.
1020 minInvalidatedStateIndex = 0;
1021 if (options.maxAge && stagedActionIds.length > options.maxAge) {
1022 // States must be recomputed before committing excess.
1023 computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
1024 commitExcessActions(stagedActionIds.length - options.maxAge);
1025 // Avoid double computation.
1026 minInvalidatedStateIndex = Infinity;
1027 }
1028 break;
1029 }
1030 case store.UPDATE: {
1031 var stateHasErrors = computedStates.filter(function (state) { return state.error; }).length > 0;
1032 if (stateHasErrors) {
1033 // Recompute all states
1034 minInvalidatedStateIndex = 0;
1035 if (options.maxAge && stagedActionIds.length > options.maxAge) {
1036 // States must be recomputed before committing excess.
1037 computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
1038 commitExcessActions(stagedActionIds.length - options.maxAge);
1039 // Avoid double computation.
1040 minInvalidatedStateIndex = Infinity;
1041 }
1042 }
1043 else {
1044 // If not paused/locked, add a new action to signal devtools-user
1045 // that there was a reducer update.
1046 if (!isPaused && !isLocked) {
1047 if (currentStateIndex === stagedActionIds.length - 1) {
1048 currentStateIndex++;
1049 }
1050 // Add a new action to only recompute state
1051 var actionId = nextActionId++;
1052 actionsById[actionId] = new PerformAction(liftedAction, +Date.now());
1053 stagedActionIds = __spreadArray(__spreadArray([], __read(stagedActionIds)), [actionId]);
1054 minInvalidatedStateIndex = stagedActionIds.length - 1;
1055 computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
1056 }
1057 // Recompute state history with latest reducer and update action
1058 computedStates = computedStates.map(function (cmp) { return (Object.assign(Object.assign({}, cmp), { state: reducer(cmp.state, RECOMPUTE_ACTION) })); });
1059 currentStateIndex = stagedActionIds.length - 1;
1060 if (options.maxAge && stagedActionIds.length > options.maxAge) {
1061 commitExcessActions(stagedActionIds.length - options.maxAge);
1062 }
1063 // Avoid double computation.
1064 minInvalidatedStateIndex = Infinity;
1065 }
1066 break;
1067 }
1068 default: {
1069 // If the action is not recognized, it's a monitor action.
1070 // Optimization: a monitor action can't change history.
1071 minInvalidatedStateIndex = Infinity;
1072 break;
1073 }
1074 }
1075 computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
1076 monitorState = monitorReducer(monitorState, liftedAction);
1077 return {
1078 monitorState: monitorState,
1079 actionsById: actionsById,
1080 nextActionId: nextActionId,
1081 stagedActionIds: stagedActionIds,
1082 skippedActionIds: skippedActionIds,
1083 committedState: committedState,
1084 currentStateIndex: currentStateIndex,
1085 computedStates: computedStates,
1086 isLocked: isLocked,
1087 isPaused: isPaused,
1088 };
1089 }; };
1090 }
1091
1092 var StoreDevtools = /** @class */ (function () {
1093 function StoreDevtools(dispatcher, actions$, reducers$, extension, scannedActions, errorHandler, initialState, config) {
1094 var _this = this;
1095 var liftedInitialState = liftInitialState(initialState, config.monitor);
1096 var liftReducer = liftReducerWith(initialState, liftedInitialState, errorHandler, config.monitor, config);
1097 var liftedAction$ = rxjs.merge(rxjs.merge(actions$.asObservable().pipe(operators.skip(1)), extension.actions$).pipe(operators.map(liftAction)), dispatcher, extension.liftedActions$).pipe(operators.observeOn(rxjs.queueScheduler));
1098 var liftedReducer$ = reducers$.pipe(operators.map(liftReducer));
1099 var liftedStateSubject = new rxjs.ReplaySubject(1);
1100 var liftedStateSubscription = liftedAction$
1101 .pipe(operators.withLatestFrom(liftedReducer$), operators.scan(function (_a, _b) {
1102 var liftedState = _a.state;
1103 var _c = __read(_b, 2), action = _c[0], reducer = _c[1];
1104 var reducedLiftedState = reducer(liftedState, action);
1105 // On full state update
1106 // If we have actions filters, we must filter completely our lifted state to be sync with the extension
1107 if (action.type !== PERFORM_ACTION && shouldFilterActions(config)) {
1108 reducedLiftedState = filterLiftedState(reducedLiftedState, config.predicate, config.actionsSafelist, config.actionsBlocklist);
1109 }
1110 // Extension should be sent the sanitized lifted state
1111 extension.notify(action, reducedLiftedState);
1112 return { state: reducedLiftedState, action: action };
1113 }, { state: liftedInitialState, action: null }))
1114 .subscribe(function (_a) {
1115 var state = _a.state, action = _a.action;
1116 liftedStateSubject.next(state);
1117 if (action.type === PERFORM_ACTION) {
1118 var unliftedAction = action.action;
1119 scannedActions.next(unliftedAction);
1120 }
1121 });
1122 var extensionStartSubscription = extension.start$.subscribe(function () {
1123 _this.refresh();
1124 });
1125 var liftedState$ = liftedStateSubject.asObservable();
1126 var state$ = liftedState$.pipe(operators.map(unliftState));
1127 this.extensionStartSubscription = extensionStartSubscription;
1128 this.stateSubscription = liftedStateSubscription;
1129 this.dispatcher = dispatcher;
1130 this.liftedState = liftedState$;
1131 this.state = state$;
1132 }
1133 StoreDevtools.prototype.dispatch = function (action) {
1134 this.dispatcher.next(action);
1135 };
1136 StoreDevtools.prototype.next = function (action) {
1137 this.dispatcher.next(action);
1138 };
1139 StoreDevtools.prototype.error = function (error) { };
1140 StoreDevtools.prototype.complete = function () { };
1141 StoreDevtools.prototype.performAction = function (action) {
1142 this.dispatch(new PerformAction(action, +Date.now()));
1143 };
1144 StoreDevtools.prototype.refresh = function () {
1145 this.dispatch(new Refresh());
1146 };
1147 StoreDevtools.prototype.reset = function () {
1148 this.dispatch(new Reset(+Date.now()));
1149 };
1150 StoreDevtools.prototype.rollback = function () {
1151 this.dispatch(new Rollback(+Date.now()));
1152 };
1153 StoreDevtools.prototype.commit = function () {
1154 this.dispatch(new Commit(+Date.now()));
1155 };
1156 StoreDevtools.prototype.sweep = function () {
1157 this.dispatch(new Sweep());
1158 };
1159 StoreDevtools.prototype.toggleAction = function (id) {
1160 this.dispatch(new ToggleAction(id));
1161 };
1162 StoreDevtools.prototype.jumpToAction = function (actionId) {
1163 this.dispatch(new JumpToAction(actionId));
1164 };
1165 StoreDevtools.prototype.jumpToState = function (index) {
1166 this.dispatch(new JumpToState(index));
1167 };
1168 StoreDevtools.prototype.importState = function (nextLiftedState) {
1169 this.dispatch(new ImportState(nextLiftedState));
1170 };
1171 StoreDevtools.prototype.lockChanges = function (status) {
1172 this.dispatch(new LockChanges(status));
1173 };
1174 StoreDevtools.prototype.pauseRecording = function (status) {
1175 this.dispatch(new PauseRecording(status));
1176 };
1177 return StoreDevtools;
1178 }());
1179 StoreDevtools.decorators = [
1180 { type: core.Injectable }
1181 ];
1182 /** @nocollapse */
1183 StoreDevtools.ctorParameters = function () { return [
1184 { type: DevtoolsDispatcher },
1185 { type: store.ActionsSubject },
1186 { type: store.ReducerObservable },
1187 { type: DevtoolsExtension },
1188 { type: store.ScannedActionsSubject },
1189 { type: core.ErrorHandler },
1190 { type: undefined, decorators: [{ type: core.Inject, args: [store.INITIAL_STATE,] }] },
1191 { type: StoreDevtoolsConfig, decorators: [{ type: core.Inject, args: [STORE_DEVTOOLS_CONFIG,] }] }
1192 ]; };
1193
1194 var IS_EXTENSION_OR_MONITOR_PRESENT = new core.InjectionToken('@ngrx/store-devtools Is Devtools Extension or Monitor Present');
1195 function createIsExtensionOrMonitorPresent(extension, config) {
1196 return Boolean(extension) || config.monitor !== noMonitor;
1197 }
1198 function createReduxDevtoolsExtension() {
1199 var extensionKey = '__REDUX_DEVTOOLS_EXTENSION__';
1200 if (typeof window === 'object' &&
1201 typeof window[extensionKey] !== 'undefined') {
1202 return window[extensionKey];
1203 }
1204 else {
1205 return null;
1206 }
1207 }
1208 function createStateObservable(devtools) {
1209 return devtools.state;
1210 }
1211 var StoreDevtoolsModule = /** @class */ (function () {
1212 function StoreDevtoolsModule() {
1213 }
1214 StoreDevtoolsModule.instrument = function (options) {
1215 if (options === void 0) { options = {}; }
1216 return {
1217 ngModule: StoreDevtoolsModule,
1218 providers: [
1219 DevtoolsExtension,
1220 DevtoolsDispatcher,
1221 StoreDevtools,
1222 {
1223 provide: INITIAL_OPTIONS,
1224 useValue: options,
1225 },
1226 {
1227 provide: IS_EXTENSION_OR_MONITOR_PRESENT,
1228 deps: [REDUX_DEVTOOLS_EXTENSION, STORE_DEVTOOLS_CONFIG],
1229 useFactory: createIsExtensionOrMonitorPresent,
1230 },
1231 {
1232 provide: REDUX_DEVTOOLS_EXTENSION,
1233 useFactory: createReduxDevtoolsExtension,
1234 },
1235 {
1236 provide: STORE_DEVTOOLS_CONFIG,
1237 deps: [INITIAL_OPTIONS],
1238 useFactory: createConfig,
1239 },
1240 {
1241 provide: store.StateObservable,
1242 deps: [StoreDevtools],
1243 useFactory: createStateObservable,
1244 },
1245 {
1246 provide: store.ReducerManagerDispatcher,
1247 useExisting: DevtoolsDispatcher,
1248 },
1249 ],
1250 };
1251 };
1252 return StoreDevtoolsModule;
1253 }());
1254 StoreDevtoolsModule.decorators = [
1255 { type: core.NgModule, args: [{},] }
1256 ];
1257
1258 /**
1259 * DO NOT EDIT
1260 *
1261 * This file is automatically generated at build
1262 */
1263
1264 /**
1265 * Generated bundle index. Do not edit.
1266 */
1267
1268 exports.INITIAL_OPTIONS = INITIAL_OPTIONS;
1269 exports.RECOMPUTE = RECOMPUTE;
1270 exports.StoreDevtools = StoreDevtools;
1271 exports.StoreDevtoolsConfig = StoreDevtoolsConfig;
1272 exports.StoreDevtoolsModule = StoreDevtoolsModule;
1273 exports.ɵa = IS_EXTENSION_OR_MONITOR_PRESENT;
1274 exports.ɵb = createIsExtensionOrMonitorPresent;
1275 exports.ɵc = createReduxDevtoolsExtension;
1276 exports.ɵd = createStateObservable;
1277 exports.ɵe = STORE_DEVTOOLS_CONFIG;
1278 exports.ɵf = noMonitor;
1279 exports.ɵg = createConfig;
1280 exports.ɵh = REDUX_DEVTOOLS_EXTENSION;
1281 exports.ɵi = DevtoolsExtension;
1282 exports.ɵj = DevtoolsDispatcher;
1283
1284 Object.defineProperty(exports, '__esModule', { value: true });
1285
1286})));
1287//# sourceMappingURL=ngrx-store-devtools.umd.js.map