@ngrx/store-devtools 13.0.0-beta.0 → 13.0.0-rc.0

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