@ngrx/store-devtools 6.1.2 → 7.0.0-beta.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.
- package/bundles/store-devtools.umd.js +511 -309
- package/bundles/store-devtools.umd.js.map +1 -1
- package/bundles/store-devtools.umd.min.js +2 -2
- package/bundles/store-devtools.umd.min.js.map +1 -1
- package/esm2015/index.js +3 -3
- package/esm2015/public_api.js +3 -3
- package/esm2015/src/actions.js +72 -24
- package/esm2015/src/config.js +89 -5
- package/esm2015/src/devtools-dispatcher.js +13 -0
- package/esm2015/src/devtools.js +56 -45
- package/esm2015/src/extension.js +95 -77
- package/esm2015/src/index.js +3 -2
- package/esm2015/src/instrument.js +9 -48
- package/esm2015/src/reducer.js +190 -107
- package/esm2015/src/utils.js +56 -3
- package/esm2015/store-devtools.js +5 -5
- package/esm5/index.js +1 -1
- package/esm5/src/actions.js +19 -1
- package/esm5/src/config.js +40 -1
- package/esm5/src/devtools-dispatcher.js +34 -0
- package/esm5/src/devtools.js +39 -38
- package/esm5/src/extension.js +68 -31
- package/esm5/src/index.js +2 -1
- package/esm5/src/instrument.js +16 -33
- package/esm5/src/reducer.js +259 -196
- package/esm5/src/utils.js +50 -14
- package/esm5/store-devtools.js +5 -5
- package/fesm2015/store-devtools.js +443 -181
- package/fesm2015/store-devtools.js.map +1 -1
- package/fesm5/store-devtools.js +504 -303
- package/fesm5/store-devtools.js.map +1 -1
- package/migrations/6_0_0/index.js +1 -1
- package/package.json +3 -3
- package/schematics/ng-add/index.js +4 -4
- package/schematics-core/index.d.ts +4 -4
- package/schematics-core/utility/ast-utils.js +12 -10
- package/schematics-core/utility/change.js +1 -1
- package/schematics-core/utility/config.js +1 -1
- package/schematics-core/utility/find-module.js +1 -1
- package/schematics-core/utility/ngrx-utils.js +6 -6
- package/schematics-core/utility/package.js +1 -1
- package/schematics-core/utility/parse-name.js +1 -1
- package/schematics-core/utility/project.js +1 -1
- package/schematics-core/utility/route-utils.js +1 -1
- package/schematics-core/utility/strings.js +1 -1
- package/schematics-core/utility/update.js +1 -1
- package/src/actions.d.ts +24 -12
- package/src/config.d.ts +7 -0
- package/src/devtools-dispatcher.d.ts +3 -0
- package/src/devtools.d.ts +3 -2
- package/src/extension.d.ts +8 -8
- package/src/index.d.ts +1 -1
- package/src/instrument.d.ts +1 -4
- package/src/reducer.d.ts +8 -2
- package/src/utils.d.ts +13 -1
- package/store-devtools.d.ts +4 -4
- package/store-devtools.metadata.json +1 -1
package/fesm5/store-devtools.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license NgRx
|
|
2
|
+
* @license NgRx 7.0.0-beta.0
|
|
3
3
|
* (c) 2015-2018 Brandon Roberts, Mike Ryan, Rob Wormald, Victor Savkin
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
|
-
import { InjectionToken,
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { InjectionToken, Injectable, Inject, ErrorHandler, NgModule } from '@angular/core';
|
|
7
|
+
import { ActionsSubject, UPDATE, INIT, INITIAL_STATE, ReducerObservable, ScannedActionsSubject, ReducerManagerDispatcher, StateObservable } from '@ngrx/store';
|
|
8
|
+
import { empty, of, Observable, merge, queueScheduler, ReplaySubject } from 'rxjs';
|
|
9
|
+
import { filter, map, share, switchMap, takeUntil, concatMap, debounceTime, timeout, catchError, take, observeOn, scan, skip, withLatestFrom } from 'rxjs/operators';
|
|
10
10
|
|
|
11
11
|
var StoreDevtoolsConfig = /** @class */ (function () {
|
|
12
12
|
function StoreDevtoolsConfig() {
|
|
@@ -15,6 +15,45 @@ var StoreDevtoolsConfig = /** @class */ (function () {
|
|
|
15
15
|
}());
|
|
16
16
|
var STORE_DEVTOOLS_CONFIG = new InjectionToken('@ngrx/devtools Options');
|
|
17
17
|
var INITIAL_OPTIONS = new InjectionToken('@ngrx/devtools Initial Config');
|
|
18
|
+
function noMonitor() {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
var DEFAULT_NAME = 'NgRx Store DevTools';
|
|
22
|
+
function createConfig(_options) {
|
|
23
|
+
var DEFAULT_OPTIONS = {
|
|
24
|
+
maxAge: false,
|
|
25
|
+
monitor: noMonitor,
|
|
26
|
+
actionSanitizer: undefined,
|
|
27
|
+
stateSanitizer: undefined,
|
|
28
|
+
name: DEFAULT_NAME,
|
|
29
|
+
serialize: false,
|
|
30
|
+
logOnly: false,
|
|
31
|
+
// Add all features explicitely. This prevent buggy behavior for
|
|
32
|
+
// options like "lock" which might otherwise not show up.
|
|
33
|
+
features: {
|
|
34
|
+
pause: true,
|
|
35
|
+
lock: true,
|
|
36
|
+
persist: true,
|
|
37
|
+
export: true,
|
|
38
|
+
import: 'custom',
|
|
39
|
+
jump: true,
|
|
40
|
+
skip: true,
|
|
41
|
+
reorder: true,
|
|
42
|
+
dispatch: true,
|
|
43
|
+
test: true,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
var options = typeof _options === 'function' ? _options() : _options;
|
|
47
|
+
var logOnly = options.logOnly
|
|
48
|
+
? { pause: true, export: true, test: true }
|
|
49
|
+
: false;
|
|
50
|
+
var features = options.features || logOnly || DEFAULT_OPTIONS.features;
|
|
51
|
+
var config = Object.assign({}, DEFAULT_OPTIONS, { features: features }, options);
|
|
52
|
+
if (config.maxAge && config.maxAge < 2) {
|
|
53
|
+
throw new Error("Devtools 'maxAge' cannot be less than 2, got " + config.maxAge);
|
|
54
|
+
}
|
|
55
|
+
return config;
|
|
56
|
+
}
|
|
18
57
|
|
|
19
58
|
var PERFORM_ACTION = 'PERFORM_ACTION';
|
|
20
59
|
var REFRESH = 'REFRESH';
|
|
@@ -27,6 +66,8 @@ var SET_ACTIONS_ACTIVE = 'SET_ACTIONS_ACTIVE';
|
|
|
27
66
|
var JUMP_TO_STATE = 'JUMP_TO_STATE';
|
|
28
67
|
var JUMP_TO_ACTION = 'JUMP_TO_ACTION';
|
|
29
68
|
var IMPORT_STATE = 'IMPORT_STATE';
|
|
69
|
+
var LOCK_CHANGES = 'LOCK_CHANGES';
|
|
70
|
+
var PAUSE_RECORDING = 'PAUSE_RECORDING';
|
|
30
71
|
var PerformAction = /** @class */ (function () {
|
|
31
72
|
function PerformAction(action, timestamp) {
|
|
32
73
|
this.action = action;
|
|
@@ -100,14 +141,31 @@ var ImportState = /** @class */ (function () {
|
|
|
100
141
|
}
|
|
101
142
|
return ImportState;
|
|
102
143
|
}());
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
144
|
+
var LockChanges = /** @class */ (function () {
|
|
145
|
+
function LockChanges(status) {
|
|
146
|
+
this.status = status;
|
|
147
|
+
this.type = LOCK_CHANGES;
|
|
148
|
+
}
|
|
149
|
+
return LockChanges;
|
|
150
|
+
}());
|
|
151
|
+
var PauseRecording = /** @class */ (function () {
|
|
152
|
+
function PauseRecording(status) {
|
|
153
|
+
this.status = status;
|
|
154
|
+
this.type = PAUSE_RECORDING;
|
|
109
155
|
}
|
|
110
|
-
return
|
|
156
|
+
return PauseRecording;
|
|
157
|
+
}());
|
|
158
|
+
|
|
159
|
+
var __assign = (undefined && undefined.__assign) || function () {
|
|
160
|
+
__assign = Object.assign || function(t) {
|
|
161
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
162
|
+
s = arguments[i];
|
|
163
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
164
|
+
t[p] = s[p];
|
|
165
|
+
}
|
|
166
|
+
return t;
|
|
167
|
+
};
|
|
168
|
+
return __assign.apply(this, arguments);
|
|
111
169
|
};
|
|
112
170
|
function difference(first, second) {
|
|
113
171
|
return first.filter(function (item) { return second.indexOf(item) < 0; });
|
|
@@ -146,12 +204,10 @@ function sanitizeAction(actionSanitizer, action, actionIdx) {
|
|
|
146
204
|
* Sanitizes given states with given function.
|
|
147
205
|
*/
|
|
148
206
|
function sanitizeStates(stateSanitizer, states) {
|
|
149
|
-
return states.map(function (computedState, idx) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
});
|
|
154
|
-
});
|
|
207
|
+
return states.map(function (computedState, idx) { return ({
|
|
208
|
+
state: sanitizeState(stateSanitizer, computedState.state, idx),
|
|
209
|
+
error: computedState.error,
|
|
210
|
+
}); });
|
|
155
211
|
}
|
|
156
212
|
/**
|
|
157
213
|
* Sanitizes given state with given function.
|
|
@@ -159,14 +215,94 @@ function sanitizeStates(stateSanitizer, states) {
|
|
|
159
215
|
function sanitizeState(stateSanitizer, state, stateIdx) {
|
|
160
216
|
return stateSanitizer(state, stateIdx);
|
|
161
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Read the config and tell if actions should be filtered
|
|
220
|
+
*/
|
|
221
|
+
function shouldFilterActions(config) {
|
|
222
|
+
return config.predicate || config.actionsWhitelist || config.actionsBlacklist;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Return a full filtered lifted state
|
|
226
|
+
*/
|
|
227
|
+
function filterLiftedState(liftedState, predicate, whitelist, blacklist) {
|
|
228
|
+
var filteredStagedActionIds = [];
|
|
229
|
+
var filteredActionsById = {};
|
|
230
|
+
var filteredComputedStates = [];
|
|
231
|
+
liftedState.stagedActionIds.forEach(function (id, idx) {
|
|
232
|
+
var liftedAction = liftedState.actionsById[id];
|
|
233
|
+
if (!liftedAction)
|
|
234
|
+
return;
|
|
235
|
+
if (idx &&
|
|
236
|
+
isActionFiltered(liftedState.computedStates[idx], liftedAction, predicate, whitelist, blacklist)) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
filteredActionsById[id] = liftedAction;
|
|
240
|
+
filteredStagedActionIds.push(id);
|
|
241
|
+
filteredComputedStates.push(liftedState.computedStates[idx]);
|
|
242
|
+
});
|
|
243
|
+
return __assign({}, liftedState, { stagedActionIds: filteredStagedActionIds, actionsById: filteredActionsById, computedStates: filteredComputedStates });
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Return true is the action should be ignored
|
|
247
|
+
*/
|
|
248
|
+
function isActionFiltered(state, action, predicate, whitelist, blacklist) {
|
|
249
|
+
return ((predicate && !predicate(state, action.action)) ||
|
|
250
|
+
(whitelist && !action.action.type.match(whitelist.join('|'))) ||
|
|
251
|
+
(blacklist && action.action.type.match(blacklist.join('|'))));
|
|
252
|
+
}
|
|
162
253
|
|
|
163
|
-
var
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
254
|
+
var __extends = (undefined && undefined.__extends) || (function () {
|
|
255
|
+
var extendStatics = function (d, b) {
|
|
256
|
+
extendStatics = Object.setPrototypeOf ||
|
|
257
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
258
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
259
|
+
return extendStatics(d, b);
|
|
260
|
+
};
|
|
261
|
+
return function (d, b) {
|
|
262
|
+
extendStatics(d, b);
|
|
263
|
+
function __() { this.constructor = d; }
|
|
264
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
265
|
+
};
|
|
266
|
+
})();
|
|
267
|
+
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
268
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
269
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
270
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
271
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
272
|
+
};
|
|
273
|
+
var DevtoolsDispatcher = /** @class */ (function (_super) {
|
|
274
|
+
__extends(DevtoolsDispatcher, _super);
|
|
275
|
+
function DevtoolsDispatcher() {
|
|
276
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
168
277
|
}
|
|
169
|
-
|
|
278
|
+
DevtoolsDispatcher = __decorate([
|
|
279
|
+
Injectable()
|
|
280
|
+
], DevtoolsDispatcher);
|
|
281
|
+
return DevtoolsDispatcher;
|
|
282
|
+
}(ActionsSubject));
|
|
283
|
+
|
|
284
|
+
var __assign$1 = (undefined && undefined.__assign) || function () {
|
|
285
|
+
__assign$1 = Object.assign || function(t) {
|
|
286
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
287
|
+
s = arguments[i];
|
|
288
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
289
|
+
t[p] = s[p];
|
|
290
|
+
}
|
|
291
|
+
return t;
|
|
292
|
+
};
|
|
293
|
+
return __assign$1.apply(this, arguments);
|
|
294
|
+
};
|
|
295
|
+
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
296
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
297
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
298
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
299
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
300
|
+
};
|
|
301
|
+
var __metadata = (undefined && undefined.__metadata) || function (k, v) {
|
|
302
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
303
|
+
};
|
|
304
|
+
var __param = (undefined && undefined.__param) || function (paramIndex, decorator) {
|
|
305
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
170
306
|
};
|
|
171
307
|
var ExtensionActionTypes = {
|
|
172
308
|
START: 'START',
|
|
@@ -176,9 +312,9 @@ var ExtensionActionTypes = {
|
|
|
176
312
|
};
|
|
177
313
|
var REDUX_DEVTOOLS_EXTENSION = new InjectionToken('Redux Devtools Extension');
|
|
178
314
|
var DevtoolsExtension = /** @class */ (function () {
|
|
179
|
-
function DevtoolsExtension(devtoolsExtension, config) {
|
|
315
|
+
function DevtoolsExtension(devtoolsExtension, config, dispatcher) {
|
|
180
316
|
this.config = config;
|
|
181
|
-
this.
|
|
317
|
+
this.dispatcher = dispatcher;
|
|
182
318
|
this.devtoolsExtension = devtoolsExtension;
|
|
183
319
|
this.createActionStreams();
|
|
184
320
|
}
|
|
@@ -187,8 +323,8 @@ var DevtoolsExtension = /** @class */ (function () {
|
|
|
187
323
|
return;
|
|
188
324
|
}
|
|
189
325
|
// Check to see if the action requires a full update of the liftedState.
|
|
190
|
-
// If it is a simple action generated by the user's app
|
|
191
|
-
// action and the current state (fast).
|
|
326
|
+
// If it is a simple action generated by the user's app and the recording
|
|
327
|
+
// is not locked/paused, only send the action and the current state (fast).
|
|
192
328
|
//
|
|
193
329
|
// A full liftedState update (slow: serializes the entire liftedState) is
|
|
194
330
|
// only required when:
|
|
@@ -200,7 +336,14 @@ var DevtoolsExtension = /** @class */ (function () {
|
|
|
200
336
|
// d) any action that is not a PerformAction to err on the side of
|
|
201
337
|
// caution.
|
|
202
338
|
if (action.type === PERFORM_ACTION) {
|
|
339
|
+
if (state.isLocked || state.isPaused) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
203
342
|
var currentState = unliftState(state);
|
|
343
|
+
if (shouldFilterActions(this.config) &&
|
|
344
|
+
isActionFiltered(currentState, action, this.config.predicate, this.config.actionsWhitelist, this.config.actionsBlacklist)) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
204
347
|
var sanitizedState = this.config.stateSanitizer
|
|
205
348
|
? sanitizeState(this.config.stateSanitizer, currentState, state.currentStateIndex)
|
|
206
349
|
: currentState;
|
|
@@ -211,12 +354,12 @@ var DevtoolsExtension = /** @class */ (function () {
|
|
|
211
354
|
}
|
|
212
355
|
else {
|
|
213
356
|
// Requires full state update
|
|
214
|
-
var sanitizedLiftedState = __assign$1({}, state, { actionsById: this.config.actionSanitizer
|
|
357
|
+
var sanitizedLiftedState = __assign$1({}, state, { stagedActionIds: state.stagedActionIds, actionsById: this.config.actionSanitizer
|
|
215
358
|
? sanitizeActions(this.config.actionSanitizer, state.actionsById)
|
|
216
359
|
: state.actionsById, computedStates: this.config.stateSanitizer
|
|
217
360
|
? sanitizeStates(this.config.stateSanitizer, state.computedStates)
|
|
218
361
|
: state.computedStates });
|
|
219
|
-
this.devtoolsExtension.send(null, sanitizedLiftedState, this.getExtensionConfig(this.
|
|
362
|
+
this.devtoolsExtension.send(null, sanitizedLiftedState, this.getExtensionConfig(this.config));
|
|
220
363
|
}
|
|
221
364
|
};
|
|
222
365
|
DevtoolsExtension.prototype.createChangesObservable = function () {
|
|
@@ -225,7 +368,7 @@ var DevtoolsExtension = /** @class */ (function () {
|
|
|
225
368
|
return empty();
|
|
226
369
|
}
|
|
227
370
|
return new Observable(function (subscriber) {
|
|
228
|
-
var connection = _this.devtoolsExtension.connect(_this.getExtensionConfig(_this.
|
|
371
|
+
var connection = _this.devtoolsExtension.connect(_this.getExtensionConfig(_this.config));
|
|
229
372
|
_this.extensionConnection = connection;
|
|
230
373
|
connection.init();
|
|
231
374
|
connection.subscribe(function (change) { return subscriber.next(change); });
|
|
@@ -234,14 +377,29 @@ var DevtoolsExtension = /** @class */ (function () {
|
|
|
234
377
|
};
|
|
235
378
|
DevtoolsExtension.prototype.createActionStreams = function () {
|
|
236
379
|
var _this = this;
|
|
237
|
-
// Listens to all changes
|
|
380
|
+
// Listens to all changes
|
|
238
381
|
var changes$ = this.createChangesObservable().pipe(share());
|
|
239
382
|
// Listen for the start action
|
|
240
383
|
var start$ = changes$.pipe(filter(function (change) { return change.type === ExtensionActionTypes.START; }));
|
|
241
384
|
// Listen for the stop action
|
|
242
385
|
var stop$ = changes$.pipe(filter(function (change) { return change.type === ExtensionActionTypes.STOP; }));
|
|
243
386
|
// Listen for lifted actions
|
|
244
|
-
var liftedActions$ = changes$.pipe(filter(function (change) { return change.type === ExtensionActionTypes.DISPATCH; }), map(function (change) { return _this.unwrapAction(change.payload); }))
|
|
387
|
+
var liftedActions$ = changes$.pipe(filter(function (change) { return change.type === ExtensionActionTypes.DISPATCH; }), map(function (change) { return _this.unwrapAction(change.payload); }), concatMap(function (action) {
|
|
388
|
+
if (action.type === IMPORT_STATE) {
|
|
389
|
+
// State imports may happen in two situations:
|
|
390
|
+
// 1. Explicitly by user
|
|
391
|
+
// 2. User activated the "persist state accross reloads" option
|
|
392
|
+
// and now the state is imported during reload.
|
|
393
|
+
// Because of option 2, we need to give possible
|
|
394
|
+
// lazy loaded reducers time to instantiate.
|
|
395
|
+
// As soon as there is no UPDATE action within 1 second,
|
|
396
|
+
// it is assumed that all reducers are loaded.
|
|
397
|
+
return _this.dispatcher.pipe(filter(function (action) { return action.type === UPDATE; }), timeout(1000), debounceTime(1000), map(function () { return action; }), catchError(function () { return of(action); }), take(1));
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
return of(action);
|
|
401
|
+
}
|
|
402
|
+
}));
|
|
245
403
|
// Listen for unlifted actions
|
|
246
404
|
var actions$ = changes$.pipe(filter(function (change) { return change.type === ExtensionActionTypes.ACTION; }), map(function (change) { return _this.unwrapAction(change.payload); }));
|
|
247
405
|
var actionsUntilStop$ = actions$.pipe(takeUntil(stop$));
|
|
@@ -254,9 +412,8 @@ var DevtoolsExtension = /** @class */ (function () {
|
|
|
254
412
|
DevtoolsExtension.prototype.unwrapAction = function (action) {
|
|
255
413
|
return typeof action === 'string' ? eval("(" + action + ")") : action;
|
|
256
414
|
};
|
|
257
|
-
DevtoolsExtension.prototype.getExtensionConfig = function (
|
|
415
|
+
DevtoolsExtension.prototype.getExtensionConfig = function (config) {
|
|
258
416
|
var extensionOptions = {
|
|
259
|
-
instanceId: instanceId,
|
|
260
417
|
name: config.name,
|
|
261
418
|
features: config.features,
|
|
262
419
|
serialize: config.serialize,
|
|
@@ -266,24 +423,26 @@ var DevtoolsExtension = /** @class */ (function () {
|
|
|
266
423
|
}
|
|
267
424
|
return extensionOptions;
|
|
268
425
|
};
|
|
269
|
-
DevtoolsExtension
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
]; };
|
|
426
|
+
DevtoolsExtension = __decorate$1([
|
|
427
|
+
Injectable(),
|
|
428
|
+
__param(0, Inject(REDUX_DEVTOOLS_EXTENSION)),
|
|
429
|
+
__param(1, Inject(STORE_DEVTOOLS_CONFIG)),
|
|
430
|
+
__metadata("design:paramtypes", [Object, StoreDevtoolsConfig,
|
|
431
|
+
DevtoolsDispatcher])
|
|
432
|
+
], DevtoolsExtension);
|
|
277
433
|
return DevtoolsExtension;
|
|
278
434
|
}());
|
|
279
435
|
|
|
280
|
-
var __assign$2 = (undefined && undefined.__assign) ||
|
|
281
|
-
|
|
282
|
-
s = arguments
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
436
|
+
var __assign$2 = (undefined && undefined.__assign) || function () {
|
|
437
|
+
__assign$2 = Object.assign || function(t) {
|
|
438
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
439
|
+
s = arguments[i];
|
|
440
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
441
|
+
t[p] = s[p];
|
|
442
|
+
}
|
|
443
|
+
return t;
|
|
444
|
+
};
|
|
445
|
+
return __assign$2.apply(this, arguments);
|
|
287
446
|
};
|
|
288
447
|
var __read = (undefined && undefined.__read) || function (o, n) {
|
|
289
448
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
@@ -306,6 +465,8 @@ var __spread = (undefined && undefined.__spread) || function () {
|
|
|
306
465
|
return ar;
|
|
307
466
|
};
|
|
308
467
|
var INIT_ACTION = { type: INIT };
|
|
468
|
+
var RECOMPUTE = '@ngrx/store-devtools/recompute';
|
|
469
|
+
var RECOMPUTE_ACTION = { type: RECOMPUTE };
|
|
309
470
|
/**
|
|
310
471
|
* Computes the next entry in the log by applying an action.
|
|
311
472
|
*/
|
|
@@ -333,7 +494,7 @@ function computeNextEntry(reducer, action, state, error, errorHandler) {
|
|
|
333
494
|
/**
|
|
334
495
|
* Runs the reducer on invalidated actions to get a fresh computation log.
|
|
335
496
|
*/
|
|
336
|
-
function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler) {
|
|
497
|
+
function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused) {
|
|
337
498
|
// Optimization: exit early and return the same reference
|
|
338
499
|
// if we know nothing could have changed.
|
|
339
500
|
if (minInvalidatedStateIndex >= computedStates.length &&
|
|
@@ -341,7 +502,10 @@ function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, comm
|
|
|
341
502
|
return computedStates;
|
|
342
503
|
}
|
|
343
504
|
var nextComputedStates = computedStates.slice(0, minInvalidatedStateIndex);
|
|
344
|
-
|
|
505
|
+
// If the recording is paused, recompute all states up until the pause state,
|
|
506
|
+
// else recompute all states.
|
|
507
|
+
var lastIncludedActionId = stagedActionIds.length - (isPaused ? 1 : 0);
|
|
508
|
+
for (var i = minInvalidatedStateIndex; i < lastIncludedActionId; i++) {
|
|
345
509
|
var actionId = stagedActionIds[i];
|
|
346
510
|
var action = actionsById[actionId].action;
|
|
347
511
|
var previousEntry = nextComputedStates[i - 1];
|
|
@@ -353,6 +517,11 @@ function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, comm
|
|
|
353
517
|
: computeNextEntry(reducer, action, previousState, previousError, errorHandler);
|
|
354
518
|
nextComputedStates.push(entry);
|
|
355
519
|
}
|
|
520
|
+
// If the recording is paused, the last state will not be recomputed,
|
|
521
|
+
// because it's essentially not part of the state history.
|
|
522
|
+
if (isPaused) {
|
|
523
|
+
nextComputedStates.push(computedStates[computedStates.length - 1]);
|
|
524
|
+
}
|
|
356
525
|
return nextComputedStates;
|
|
357
526
|
}
|
|
358
527
|
function liftInitialState(initialCommittedState, monitorReducer) {
|
|
@@ -365,6 +534,8 @@ function liftInitialState(initialCommittedState, monitorReducer) {
|
|
|
365
534
|
committedState: initialCommittedState,
|
|
366
535
|
currentStateIndex: 0,
|
|
367
536
|
computedStates: [],
|
|
537
|
+
isLocked: false,
|
|
538
|
+
isPaused: false,
|
|
368
539
|
};
|
|
369
540
|
}
|
|
370
541
|
/**
|
|
@@ -373,182 +544,232 @@ function liftInitialState(initialCommittedState, monitorReducer) {
|
|
|
373
544
|
function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler, monitorReducer, options) {
|
|
374
545
|
if (options === void 0) { options = {}; }
|
|
375
546
|
/**
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
return function (reducer) {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
547
|
+
* Manages how the history actions modify the history state.
|
|
548
|
+
*/
|
|
549
|
+
return function (reducer) { return function (liftedState, liftedAction) {
|
|
550
|
+
var _a;
|
|
551
|
+
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;
|
|
552
|
+
if (!liftedState) {
|
|
553
|
+
// Prevent mutating initialLiftedState
|
|
554
|
+
actionsById = Object.create(actionsById);
|
|
555
|
+
}
|
|
556
|
+
function commitExcessActions(n) {
|
|
557
|
+
// Auto-commits n-number of excess actions.
|
|
558
|
+
var excess = n;
|
|
559
|
+
var idsToDelete = stagedActionIds.slice(1, excess + 1);
|
|
560
|
+
for (var i = 0; i < idsToDelete.length; i++) {
|
|
561
|
+
if (computedStates[i + 1].error) {
|
|
562
|
+
// Stop if error is found. Commit actions up to error.
|
|
563
|
+
excess = i;
|
|
564
|
+
idsToDelete = stagedActionIds.slice(1, excess + 1);
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
delete actionsById[idsToDelete[i]];
|
|
569
|
+
}
|
|
384
570
|
}
|
|
385
|
-
function
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
571
|
+
skippedActionIds = skippedActionIds.filter(function (id) { return idsToDelete.indexOf(id) === -1; });
|
|
572
|
+
stagedActionIds = __spread([0], stagedActionIds.slice(excess + 1));
|
|
573
|
+
committedState = computedStates[excess].state;
|
|
574
|
+
computedStates = computedStates.slice(excess);
|
|
575
|
+
currentStateIndex =
|
|
576
|
+
currentStateIndex > excess ? currentStateIndex - excess : 0;
|
|
577
|
+
}
|
|
578
|
+
function commitChanges() {
|
|
579
|
+
// Consider the last committed state the new starting point.
|
|
580
|
+
// Squash any staged actions into a single committed state.
|
|
581
|
+
actionsById = { 0: liftAction(INIT_ACTION) };
|
|
582
|
+
nextActionId = 1;
|
|
583
|
+
stagedActionIds = [0];
|
|
584
|
+
skippedActionIds = [];
|
|
585
|
+
committedState = computedStates[currentStateIndex].state;
|
|
586
|
+
currentStateIndex = 0;
|
|
587
|
+
computedStates = [];
|
|
588
|
+
}
|
|
589
|
+
// By default, aggressively recompute every state whatever happens.
|
|
590
|
+
// This has O(n) performance, so we'll override this to a sensible
|
|
591
|
+
// value whenever we feel like we don't have to recompute the states.
|
|
592
|
+
var minInvalidatedStateIndex = 0;
|
|
593
|
+
switch (liftedAction.type) {
|
|
594
|
+
case LOCK_CHANGES: {
|
|
595
|
+
isLocked = liftedAction.status;
|
|
596
|
+
minInvalidatedStateIndex = Infinity;
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
case PAUSE_RECORDING: {
|
|
600
|
+
isPaused = liftedAction.status;
|
|
601
|
+
if (isPaused) {
|
|
602
|
+
// Add a pause action to signal the devtools-user the recording is paused.
|
|
603
|
+
// The corresponding state will be overwritten on each update to always contain
|
|
604
|
+
// the latest state (see Actions.PERFORM_ACTION).
|
|
605
|
+
stagedActionIds = __spread(stagedActionIds, [nextActionId]);
|
|
606
|
+
actionsById[nextActionId] = new PerformAction({
|
|
607
|
+
type: '@ngrx/devtools/pause',
|
|
608
|
+
}, +Date.now());
|
|
609
|
+
nextActionId++;
|
|
610
|
+
minInvalidatedStateIndex = stagedActionIds.length - 1;
|
|
611
|
+
computedStates = computedStates.concat(computedStates[computedStates.length - 1]);
|
|
612
|
+
if (currentStateIndex === stagedActionIds.length - 2) {
|
|
613
|
+
currentStateIndex++;
|
|
398
614
|
}
|
|
615
|
+
minInvalidatedStateIndex = Infinity;
|
|
399
616
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
committedState = computedStates[excess].state;
|
|
403
|
-
computedStates = computedStates.slice(excess);
|
|
404
|
-
currentStateIndex =
|
|
405
|
-
currentStateIndex > excess ? currentStateIndex - excess : 0;
|
|
406
|
-
}
|
|
407
|
-
// By default, aggressively recompute every state whatever happens.
|
|
408
|
-
// This has O(n) performance, so we'll override this to a sensible
|
|
409
|
-
// value whenever we feel like we don't have to recompute the states.
|
|
410
|
-
var minInvalidatedStateIndex = 0;
|
|
411
|
-
switch (liftedAction.type) {
|
|
412
|
-
case RESET: {
|
|
413
|
-
// Get back to the state the store was created with.
|
|
414
|
-
actionsById = { 0: liftAction(INIT_ACTION) };
|
|
415
|
-
nextActionId = 1;
|
|
416
|
-
stagedActionIds = [0];
|
|
417
|
-
skippedActionIds = [];
|
|
418
|
-
committedState = initialCommittedState;
|
|
419
|
-
currentStateIndex = 0;
|
|
420
|
-
computedStates = [];
|
|
421
|
-
break;
|
|
617
|
+
else {
|
|
618
|
+
commitChanges();
|
|
422
619
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
case RESET: {
|
|
623
|
+
// Get back to the state the store was created with.
|
|
624
|
+
actionsById = { 0: liftAction(INIT_ACTION) };
|
|
625
|
+
nextActionId = 1;
|
|
626
|
+
stagedActionIds = [0];
|
|
627
|
+
skippedActionIds = [];
|
|
628
|
+
committedState = initialCommittedState;
|
|
629
|
+
currentStateIndex = 0;
|
|
630
|
+
computedStates = [];
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
633
|
+
case COMMIT: {
|
|
634
|
+
commitChanges();
|
|
635
|
+
break;
|
|
636
|
+
}
|
|
637
|
+
case ROLLBACK: {
|
|
638
|
+
// Forget about any staged actions.
|
|
639
|
+
// Start again from the last committed state.
|
|
640
|
+
actionsById = { 0: liftAction(INIT_ACTION) };
|
|
641
|
+
nextActionId = 1;
|
|
642
|
+
stagedActionIds = [0];
|
|
643
|
+
skippedActionIds = [];
|
|
644
|
+
currentStateIndex = 0;
|
|
645
|
+
computedStates = [];
|
|
646
|
+
break;
|
|
647
|
+
}
|
|
648
|
+
case TOGGLE_ACTION: {
|
|
649
|
+
// Toggle whether an action with given ID is skipped.
|
|
650
|
+
// Being skipped means it is a no-op during the computation.
|
|
651
|
+
var actionId_1 = liftedAction.id;
|
|
652
|
+
var index = skippedActionIds.indexOf(actionId_1);
|
|
653
|
+
if (index === -1) {
|
|
654
|
+
skippedActionIds = __spread([actionId_1], skippedActionIds);
|
|
434
655
|
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
// Start again from the last committed state.
|
|
438
|
-
actionsById = { 0: liftAction(INIT_ACTION) };
|
|
439
|
-
nextActionId = 1;
|
|
440
|
-
stagedActionIds = [0];
|
|
441
|
-
skippedActionIds = [];
|
|
442
|
-
currentStateIndex = 0;
|
|
443
|
-
computedStates = [];
|
|
444
|
-
break;
|
|
656
|
+
else {
|
|
657
|
+
skippedActionIds = skippedActionIds.filter(function (id) { return id !== actionId_1; });
|
|
445
658
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
break;
|
|
659
|
+
// Optimization: we know history before this action hasn't changed
|
|
660
|
+
minInvalidatedStateIndex = stagedActionIds.indexOf(actionId_1);
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
case SET_ACTIONS_ACTIVE: {
|
|
664
|
+
// Toggle whether an action with given ID is skipped.
|
|
665
|
+
// Being skipped means it is a no-op during the computation.
|
|
666
|
+
var start = liftedAction.start, end = liftedAction.end, active = liftedAction.active;
|
|
667
|
+
var actionIds = [];
|
|
668
|
+
for (var i = start; i < end; i++)
|
|
669
|
+
actionIds.push(i);
|
|
670
|
+
if (active) {
|
|
671
|
+
skippedActionIds = difference(skippedActionIds, actionIds);
|
|
460
672
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
// Being skipped means it is a no-op during the computation.
|
|
464
|
-
var start = liftedAction.start, end = liftedAction.end, active = liftedAction.active;
|
|
465
|
-
var actionIds = [];
|
|
466
|
-
for (var i = start; i < end; i++)
|
|
467
|
-
actionIds.push(i);
|
|
468
|
-
if (active) {
|
|
469
|
-
skippedActionIds = difference(skippedActionIds, actionIds);
|
|
470
|
-
}
|
|
471
|
-
else {
|
|
472
|
-
skippedActionIds = __spread(skippedActionIds, actionIds);
|
|
473
|
-
}
|
|
474
|
-
// Optimization: we know history before this action hasn't changed
|
|
475
|
-
minInvalidatedStateIndex = stagedActionIds.indexOf(start);
|
|
476
|
-
break;
|
|
673
|
+
else {
|
|
674
|
+
skippedActionIds = __spread(skippedActionIds, actionIds);
|
|
477
675
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
676
|
+
// Optimization: we know history before this action hasn't changed
|
|
677
|
+
minInvalidatedStateIndex = stagedActionIds.indexOf(start);
|
|
678
|
+
break;
|
|
679
|
+
}
|
|
680
|
+
case JUMP_TO_STATE: {
|
|
681
|
+
// Without recomputing anything, move the pointer that tell us
|
|
682
|
+
// which state is considered the current one. Useful for sliders.
|
|
683
|
+
currentStateIndex = liftedAction.index;
|
|
684
|
+
// Optimization: we know the history has not changed.
|
|
685
|
+
minInvalidatedStateIndex = Infinity;
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
case JUMP_TO_ACTION: {
|
|
689
|
+
// Jumps to a corresponding state to a specific action.
|
|
690
|
+
// Useful when filtering actions.
|
|
691
|
+
var index = stagedActionIds.indexOf(liftedAction.actionId);
|
|
692
|
+
if (index !== -1)
|
|
693
|
+
currentStateIndex = index;
|
|
694
|
+
minInvalidatedStateIndex = Infinity;
|
|
695
|
+
break;
|
|
696
|
+
}
|
|
697
|
+
case SWEEP: {
|
|
698
|
+
// Forget any actions that are currently being skipped.
|
|
699
|
+
stagedActionIds = difference(stagedActionIds, skippedActionIds);
|
|
700
|
+
skippedActionIds = [];
|
|
701
|
+
currentStateIndex = Math.min(currentStateIndex, stagedActionIds.length - 1);
|
|
702
|
+
break;
|
|
703
|
+
}
|
|
704
|
+
case PERFORM_ACTION: {
|
|
705
|
+
// Ignore action and return state as is if recording is locked
|
|
706
|
+
if (isLocked) {
|
|
707
|
+
return liftedState || initialLiftedState;
|
|
485
708
|
}
|
|
486
|
-
|
|
487
|
-
//
|
|
488
|
-
//
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
709
|
+
if (isPaused) {
|
|
710
|
+
// If recording is paused, overwrite the last state
|
|
711
|
+
// (corresponds to the pause action) and keep everything else as is.
|
|
712
|
+
// This way, the app gets the new current state while the devtools
|
|
713
|
+
// do not record another action.
|
|
714
|
+
var lastState = computedStates[computedStates.length - 1];
|
|
715
|
+
computedStates = __spread(computedStates.slice(0, -1), [
|
|
716
|
+
computeNextEntry(reducer, liftedAction.action, lastState.state, lastState.error, errorHandler),
|
|
717
|
+
]);
|
|
492
718
|
minInvalidatedStateIndex = Infinity;
|
|
493
719
|
break;
|
|
494
720
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
skippedActionIds = [];
|
|
499
|
-
currentStateIndex = Math.min(currentStateIndex, stagedActionIds.length - 1);
|
|
500
|
-
break;
|
|
721
|
+
// Auto-commit as new actions come in.
|
|
722
|
+
if (options.maxAge && stagedActionIds.length === options.maxAge) {
|
|
723
|
+
commitExcessActions(1);
|
|
501
724
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
if (options.maxAge && stagedActionIds.length === options.maxAge) {
|
|
505
|
-
commitExcessActions(1);
|
|
506
|
-
}
|
|
507
|
-
if (currentStateIndex === stagedActionIds.length - 1) {
|
|
508
|
-
currentStateIndex++;
|
|
509
|
-
}
|
|
510
|
-
var actionId = nextActionId++;
|
|
511
|
-
// Mutation! This is the hottest path, and we optimize on purpose.
|
|
512
|
-
// It is safe because we set a new key in a cache dictionary.
|
|
513
|
-
actionsById[actionId] = liftedAction;
|
|
514
|
-
stagedActionIds = __spread(stagedActionIds, [actionId]);
|
|
515
|
-
// Optimization: we know that only the new action needs computing.
|
|
516
|
-
minInvalidatedStateIndex = stagedActionIds.length - 1;
|
|
517
|
-
break;
|
|
725
|
+
if (currentStateIndex === stagedActionIds.length - 1) {
|
|
726
|
+
currentStateIndex++;
|
|
518
727
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
728
|
+
var actionId = nextActionId++;
|
|
729
|
+
// Mutation! This is the hottest path, and we optimize on purpose.
|
|
730
|
+
// It is safe because we set a new key in a cache dictionary.
|
|
731
|
+
actionsById[actionId] = liftedAction;
|
|
732
|
+
stagedActionIds = __spread(stagedActionIds, [actionId]);
|
|
733
|
+
// Optimization: we know that only the new action needs computing.
|
|
734
|
+
minInvalidatedStateIndex = stagedActionIds.length - 1;
|
|
735
|
+
break;
|
|
736
|
+
}
|
|
737
|
+
case IMPORT_STATE: {
|
|
738
|
+
// Completely replace everything.
|
|
739
|
+
(_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,
|
|
740
|
+
// prettier-ignore
|
|
741
|
+
isPaused = _a.isPaused);
|
|
742
|
+
break;
|
|
743
|
+
}
|
|
744
|
+
case INIT: {
|
|
745
|
+
// Always recompute states on hot reload and init.
|
|
746
|
+
minInvalidatedStateIndex = 0;
|
|
747
|
+
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
748
|
+
// States must be recomputed before committing excess.
|
|
749
|
+
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
750
|
+
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
751
|
+
// Avoid double computation.
|
|
752
|
+
minInvalidatedStateIndex = Infinity;
|
|
525
753
|
}
|
|
526
|
-
|
|
527
|
-
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
case UPDATE: {
|
|
757
|
+
var stateHasErrors = computedStates.filter(function (state) { return state.error; }).length > 0;
|
|
758
|
+
if (stateHasErrors) {
|
|
759
|
+
// Recompute all states
|
|
528
760
|
minInvalidatedStateIndex = 0;
|
|
529
761
|
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
530
762
|
// States must be recomputed before committing excess.
|
|
531
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler);
|
|
763
|
+
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
532
764
|
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
533
765
|
// Avoid double computation.
|
|
534
766
|
minInvalidatedStateIndex = Infinity;
|
|
535
767
|
}
|
|
536
|
-
break;
|
|
537
768
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
minInvalidatedStateIndex = 0;
|
|
543
|
-
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
544
|
-
// States must be recomputed before committing excess.
|
|
545
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler);
|
|
546
|
-
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
547
|
-
// Avoid double computation.
|
|
548
|
-
minInvalidatedStateIndex = Infinity;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
else {
|
|
769
|
+
else {
|
|
770
|
+
// If not paused/locked, add a new action to signal devtools-user
|
|
771
|
+
// that there was a reducer update.
|
|
772
|
+
if (!isPaused && !isLocked) {
|
|
552
773
|
if (currentStateIndex === stagedActionIds.length - 1) {
|
|
553
774
|
currentStateIndex++;
|
|
554
775
|
}
|
|
@@ -557,55 +778,55 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
557
778
|
actionsById[actionId] = new PerformAction(liftedAction, +Date.now());
|
|
558
779
|
stagedActionIds = __spread(stagedActionIds, [actionId]);
|
|
559
780
|
minInvalidatedStateIndex = stagedActionIds.length - 1;
|
|
560
|
-
|
|
561
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler);
|
|
562
|
-
// Recompute state history with latest reducer and update action
|
|
563
|
-
computedStates = computedStates.map(function (cmp) {
|
|
564
|
-
return (__assign$2({}, cmp, { state: reducer(cmp.state, liftedAction) }));
|
|
565
|
-
});
|
|
566
|
-
currentStateIndex = minInvalidatedStateIndex;
|
|
567
|
-
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
568
|
-
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
569
|
-
}
|
|
570
|
-
// Avoid double computation.
|
|
571
|
-
minInvalidatedStateIndex = Infinity;
|
|
781
|
+
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
572
782
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
783
|
+
// Recompute state history with latest reducer and update action
|
|
784
|
+
computedStates = computedStates.map(function (cmp) { return (__assign$2({}, cmp, { state: reducer(cmp.state, RECOMPUTE_ACTION) })); });
|
|
785
|
+
currentStateIndex = stagedActionIds.length - 1;
|
|
786
|
+
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
787
|
+
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
788
|
+
}
|
|
789
|
+
// Avoid double computation.
|
|
578
790
|
minInvalidatedStateIndex = Infinity;
|
|
579
|
-
break;
|
|
580
791
|
}
|
|
792
|
+
break;
|
|
793
|
+
}
|
|
794
|
+
default: {
|
|
795
|
+
// If the action is not recognized, it's a monitor action.
|
|
796
|
+
// Optimization: a monitor action can't change history.
|
|
797
|
+
minInvalidatedStateIndex = Infinity;
|
|
798
|
+
break;
|
|
581
799
|
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
800
|
+
}
|
|
801
|
+
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
802
|
+
monitorState = monitorReducer(monitorState, liftedAction);
|
|
803
|
+
return {
|
|
804
|
+
monitorState: monitorState,
|
|
805
|
+
actionsById: actionsById,
|
|
806
|
+
nextActionId: nextActionId,
|
|
807
|
+
stagedActionIds: stagedActionIds,
|
|
808
|
+
skippedActionIds: skippedActionIds,
|
|
809
|
+
committedState: committedState,
|
|
810
|
+
currentStateIndex: currentStateIndex,
|
|
811
|
+
computedStates: computedStates,
|
|
812
|
+
isLocked: isLocked,
|
|
813
|
+
isPaused: isPaused,
|
|
595
814
|
};
|
|
596
|
-
};
|
|
815
|
+
}; };
|
|
597
816
|
}
|
|
598
817
|
|
|
599
|
-
var
|
|
600
|
-
var
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
return
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
818
|
+
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
819
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
820
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
821
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
822
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
823
|
+
};
|
|
824
|
+
var __metadata$1 = (undefined && undefined.__metadata) || function (k, v) {
|
|
825
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
826
|
+
};
|
|
827
|
+
var __param$1 = (undefined && undefined.__param) || function (paramIndex, decorator) {
|
|
828
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
829
|
+
};
|
|
609
830
|
var __read$1 = (undefined && undefined.__read) || function (o, n) {
|
|
610
831
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
611
832
|
if (!m) return o;
|
|
@@ -622,16 +843,6 @@ var __read$1 = (undefined && undefined.__read) || function (o, n) {
|
|
|
622
843
|
}
|
|
623
844
|
return ar;
|
|
624
845
|
};
|
|
625
|
-
var DevtoolsDispatcher = /** @class */ (function (_super) {
|
|
626
|
-
__extends(DevtoolsDispatcher, _super);
|
|
627
|
-
function DevtoolsDispatcher() {
|
|
628
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
629
|
-
}
|
|
630
|
-
DevtoolsDispatcher.decorators = [
|
|
631
|
-
{ type: Injectable }
|
|
632
|
-
];
|
|
633
|
-
return DevtoolsDispatcher;
|
|
634
|
-
}(ActionsSubject));
|
|
635
846
|
var StoreDevtools = /** @class */ (function () {
|
|
636
847
|
function StoreDevtools(dispatcher, actions$, reducers$, extension, scannedActions, errorHandler, initialState, config) {
|
|
637
848
|
var _this = this;
|
|
@@ -645,7 +856,12 @@ var StoreDevtools = /** @class */ (function () {
|
|
|
645
856
|
var liftedState = _a.state;
|
|
646
857
|
var _c = __read$1(_b, 2), action = _c[0], reducer = _c[1];
|
|
647
858
|
var reducedLiftedState = reducer(liftedState, action);
|
|
648
|
-
//
|
|
859
|
+
// On full state update
|
|
860
|
+
// If we have actions filters, we must filter completly our lifted state to be sync with the extension
|
|
861
|
+
if (action.type !== PERFORM_ACTION && shouldFilterActions(config)) {
|
|
862
|
+
reducedLiftedState = filterLiftedState(reducedLiftedState, config.predicate, config.actionsWhitelist, config.actionsBlacklist);
|
|
863
|
+
}
|
|
864
|
+
// Extension should be sent the sanitized lifted state
|
|
649
865
|
extension.notify(action, reducedLiftedState);
|
|
650
866
|
return { state: reducedLiftedState, action: action };
|
|
651
867
|
}, { state: liftedInitialState, action: null }))
|
|
@@ -706,23 +922,32 @@ var StoreDevtools = /** @class */ (function () {
|
|
|
706
922
|
StoreDevtools.prototype.importState = function (nextLiftedState) {
|
|
707
923
|
this.dispatch(new ImportState(nextLiftedState));
|
|
708
924
|
};
|
|
709
|
-
StoreDevtools.
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
925
|
+
StoreDevtools.prototype.lockChanges = function (status) {
|
|
926
|
+
this.dispatch(new LockChanges(status));
|
|
927
|
+
};
|
|
928
|
+
StoreDevtools.prototype.pauseRecording = function (status) {
|
|
929
|
+
this.dispatch(new PauseRecording(status));
|
|
930
|
+
};
|
|
931
|
+
StoreDevtools = __decorate$2([
|
|
932
|
+
Injectable(),
|
|
933
|
+
__param$1(6, Inject(INITIAL_STATE)),
|
|
934
|
+
__param$1(7, Inject(STORE_DEVTOOLS_CONFIG)),
|
|
935
|
+
__metadata$1("design:paramtypes", [DevtoolsDispatcher,
|
|
936
|
+
ActionsSubject,
|
|
937
|
+
ReducerObservable,
|
|
938
|
+
DevtoolsExtension,
|
|
939
|
+
ScannedActionsSubject,
|
|
940
|
+
ErrorHandler, Object, StoreDevtoolsConfig])
|
|
941
|
+
], StoreDevtools);
|
|
723
942
|
return StoreDevtools;
|
|
724
943
|
}());
|
|
725
944
|
|
|
945
|
+
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
946
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
947
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
948
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
949
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
950
|
+
};
|
|
726
951
|
var IS_EXTENSION_OR_MONITOR_PRESENT = new InjectionToken('Is Devtools Extension or Monitor Present');
|
|
727
952
|
function createIsExtensionOrMonitorPresent(extension, config) {
|
|
728
953
|
return Boolean(extension) || config.monitor !== noMonitor;
|
|
@@ -740,39 +965,14 @@ function createReduxDevtoolsExtension() {
|
|
|
740
965
|
function createStateObservable(devtools) {
|
|
741
966
|
return devtools.state;
|
|
742
967
|
}
|
|
743
|
-
function noMonitor() {
|
|
744
|
-
return null;
|
|
745
|
-
}
|
|
746
|
-
var DEFAULT_NAME = 'NgRx Store DevTools';
|
|
747
|
-
function createConfig(_options) {
|
|
748
|
-
var DEFAULT_OPTIONS = {
|
|
749
|
-
maxAge: false,
|
|
750
|
-
monitor: noMonitor,
|
|
751
|
-
actionSanitizer: undefined,
|
|
752
|
-
stateSanitizer: undefined,
|
|
753
|
-
name: DEFAULT_NAME,
|
|
754
|
-
serialize: false,
|
|
755
|
-
logOnly: false,
|
|
756
|
-
features: false,
|
|
757
|
-
};
|
|
758
|
-
var options = typeof _options === 'function' ? _options() : _options;
|
|
759
|
-
var logOnly = options.logOnly
|
|
760
|
-
? { pause: true, export: true, test: true }
|
|
761
|
-
: false;
|
|
762
|
-
var features = options.features || logOnly;
|
|
763
|
-
var config = Object.assign({}, DEFAULT_OPTIONS, { features: features }, options);
|
|
764
|
-
if (config.maxAge && config.maxAge < 2) {
|
|
765
|
-
throw new Error("Devtools 'maxAge' cannot be less than 2, got " + config.maxAge);
|
|
766
|
-
}
|
|
767
|
-
return config;
|
|
768
|
-
}
|
|
769
968
|
var StoreDevtoolsModule = /** @class */ (function () {
|
|
770
969
|
function StoreDevtoolsModule() {
|
|
771
970
|
}
|
|
971
|
+
StoreDevtoolsModule_1 = StoreDevtoolsModule;
|
|
772
972
|
StoreDevtoolsModule.instrument = function (options) {
|
|
773
973
|
if (options === void 0) { options = {}; }
|
|
774
974
|
return {
|
|
775
|
-
ngModule:
|
|
975
|
+
ngModule: StoreDevtoolsModule_1,
|
|
776
976
|
providers: [
|
|
777
977
|
DevtoolsExtension,
|
|
778
978
|
DevtoolsDispatcher,
|
|
@@ -807,9 +1007,10 @@ var StoreDevtoolsModule = /** @class */ (function () {
|
|
|
807
1007
|
],
|
|
808
1008
|
};
|
|
809
1009
|
};
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
1010
|
+
var StoreDevtoolsModule_1;
|
|
1011
|
+
StoreDevtoolsModule = StoreDevtoolsModule_1 = __decorate$3([
|
|
1012
|
+
NgModule({})
|
|
1013
|
+
], StoreDevtoolsModule);
|
|
813
1014
|
return StoreDevtoolsModule;
|
|
814
1015
|
}());
|
|
815
1016
|
|
|
@@ -823,5 +1024,5 @@ var StoreDevtoolsModule = /** @class */ (function () {
|
|
|
823
1024
|
* Generated bundle index. Do not edit.
|
|
824
1025
|
*/
|
|
825
1026
|
|
|
826
|
-
export { INITIAL_OPTIONS as ɵ
|
|
1027
|
+
export { INITIAL_OPTIONS as ɵngrx_modules_store_devtools_store_devtools_f, STORE_DEVTOOLS_CONFIG as ɵngrx_modules_store_devtools_store_devtools_e, createConfig as ɵngrx_modules_store_devtools_store_devtools_h, noMonitor as ɵngrx_modules_store_devtools_store_devtools_g, DevtoolsDispatcher as ɵngrx_modules_store_devtools_store_devtools_k, DevtoolsExtension as ɵngrx_modules_store_devtools_store_devtools_j, REDUX_DEVTOOLS_EXTENSION as ɵngrx_modules_store_devtools_store_devtools_i, IS_EXTENSION_OR_MONITOR_PRESENT as ɵngrx_modules_store_devtools_store_devtools_a, createIsExtensionOrMonitorPresent as ɵngrx_modules_store_devtools_store_devtools_b, createReduxDevtoolsExtension as ɵngrx_modules_store_devtools_store_devtools_c, createStateObservable as ɵngrx_modules_store_devtools_store_devtools_d, StoreDevtoolsModule, RECOMPUTE, StoreDevtools, StoreDevtoolsConfig };
|
|
827
1028
|
//# sourceMappingURL=store-devtools.js.map
|