UNPKG

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