@ngrx/store-devtools 6.0.1 → 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 +807 -604
- 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 +96 -78
- package/esm2015/src/index.js +3 -2
- package/esm2015/src/instrument.js +9 -48
- package/esm2015/src/reducer.js +190 -106
- 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 +69 -32
- package/esm5/src/index.js +2 -1
- package/esm5/src/instrument.js +16 -33
- package/esm5/src/reducer.js +259 -194
- package/esm5/src/utils.js +50 -14
- package/esm5/store-devtools.js +5 -5
- package/fesm2015/store-devtools.js +425 -201
- package/fesm2015/store-devtools.js.map +1 -1
- package/fesm5/store-devtools.js +509 -307
- package/fesm5/store-devtools.js.map +1 -1
- package/migrations/6_0_0/index.js +3 -3
- package/package.json +4 -3
- package/schematics/collection.json +10 -0
- package/schematics/ng-add/index.d.ts +4 -0
- package/schematics/ng-add/index.js +119 -0
- package/schematics/ng-add/schema.d.ts +8 -0
- package/schematics/ng-add/schema.js +13 -0
- package/schematics/ng-add/schema.json +34 -0
- package/schematics-core/index.d.ts +6 -6
- package/schematics-core/index.js +5 -3
- package/schematics-core/utility/ast-utils.js +13 -11
- package/schematics-core/utility/change.js +1 -1
- package/schematics-core/utility/config.js +1 -1
- package/schematics-core/utility/find-module.js +2 -2
- package/schematics-core/utility/ngrx-utils.d.ts +1 -1
- package/schematics-core/utility/ngrx-utils.js +12 -12
- package/schematics-core/utility/package.js +1 -1
- package/schematics-core/utility/parse-name.js +1 -1
- package/schematics-core/utility/project.d.ts +12 -0
- package/schematics-core/utility/project.js +12 -3
- 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 +15 -1
- package/src/devtools-dispatcher.d.ts +3 -0
- package/src/devtools.d.ts +3 -2
- package/src/extension.d.ts +10 -10
- 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 {
|
|
7
|
-
import { ActionsSubject, INIT, INITIAL_STATE,
|
|
8
|
-
import {
|
|
9
|
-
import { filter, map,
|
|
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; });
|
|
@@ -120,7 +178,6 @@ function unliftState(liftedState) {
|
|
|
120
178
|
var state = computedStates[currentStateIndex].state;
|
|
121
179
|
return state;
|
|
122
180
|
}
|
|
123
|
-
|
|
124
181
|
/**
|
|
125
182
|
* Lifts an app's action into an action on the lifted store.
|
|
126
183
|
*/
|
|
@@ -141,18 +198,16 @@ function sanitizeActions(actionSanitizer, actions) {
|
|
|
141
198
|
* Sanitizes given action with given function.
|
|
142
199
|
*/
|
|
143
200
|
function sanitizeAction(actionSanitizer, action, actionIdx) {
|
|
144
|
-
return __assign
|
|
201
|
+
return __assign({}, action, { action: actionSanitizer(action.action, actionIdx) });
|
|
145
202
|
}
|
|
146
203
|
/**
|
|
147
204
|
* Sanitizes given states with given function.
|
|
148
205
|
*/
|
|
149
206
|
function sanitizeStates(stateSanitizer, states) {
|
|
150
|
-
return states.map(function (computedState, idx) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
});
|
|
155
|
-
});
|
|
207
|
+
return states.map(function (computedState, idx) { return ({
|
|
208
|
+
state: sanitizeState(stateSanitizer, computedState.state, idx),
|
|
209
|
+
error: computedState.error,
|
|
210
|
+
}); });
|
|
156
211
|
}
|
|
157
212
|
/**
|
|
158
213
|
* Sanitizes given state with given function.
|
|
@@ -160,14 +215,94 @@ function sanitizeStates(stateSanitizer, states) {
|
|
|
160
215
|
function sanitizeState(stateSanitizer, state, stateIdx) {
|
|
161
216
|
return stateSanitizer(state, stateIdx);
|
|
162
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
|
+
}
|
|
163
253
|
|
|
164
|
-
var
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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;
|
|
169
277
|
}
|
|
170
|
-
|
|
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); }
|
|
171
306
|
};
|
|
172
307
|
var ExtensionActionTypes = {
|
|
173
308
|
START: 'START',
|
|
@@ -177,9 +312,9 @@ var ExtensionActionTypes = {
|
|
|
177
312
|
};
|
|
178
313
|
var REDUX_DEVTOOLS_EXTENSION = new InjectionToken('Redux Devtools Extension');
|
|
179
314
|
var DevtoolsExtension = /** @class */ (function () {
|
|
180
|
-
function DevtoolsExtension(devtoolsExtension, config) {
|
|
315
|
+
function DevtoolsExtension(devtoolsExtension, config, dispatcher) {
|
|
181
316
|
this.config = config;
|
|
182
|
-
this.
|
|
317
|
+
this.dispatcher = dispatcher;
|
|
183
318
|
this.devtoolsExtension = devtoolsExtension;
|
|
184
319
|
this.createActionStreams();
|
|
185
320
|
}
|
|
@@ -188,8 +323,8 @@ var DevtoolsExtension = /** @class */ (function () {
|
|
|
188
323
|
return;
|
|
189
324
|
}
|
|
190
325
|
// Check to see if the action requires a full update of the liftedState.
|
|
191
|
-
// If it is a simple action generated by the user's app
|
|
192
|
-
// 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).
|
|
193
328
|
//
|
|
194
329
|
// A full liftedState update (slow: serializes the entire liftedState) is
|
|
195
330
|
// only required when:
|
|
@@ -201,7 +336,14 @@ var DevtoolsExtension = /** @class */ (function () {
|
|
|
201
336
|
// d) any action that is not a PerformAction to err on the side of
|
|
202
337
|
// caution.
|
|
203
338
|
if (action.type === PERFORM_ACTION) {
|
|
339
|
+
if (state.isLocked || state.isPaused) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
204
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
|
+
}
|
|
205
347
|
var sanitizedState = this.config.stateSanitizer
|
|
206
348
|
? sanitizeState(this.config.stateSanitizer, currentState, state.currentStateIndex)
|
|
207
349
|
: currentState;
|
|
@@ -212,12 +354,12 @@ var DevtoolsExtension = /** @class */ (function () {
|
|
|
212
354
|
}
|
|
213
355
|
else {
|
|
214
356
|
// Requires full state update
|
|
215
|
-
var sanitizedLiftedState = __assign({}, state, { actionsById: this.config.actionSanitizer
|
|
357
|
+
var sanitizedLiftedState = __assign$1({}, state, { stagedActionIds: state.stagedActionIds, actionsById: this.config.actionSanitizer
|
|
216
358
|
? sanitizeActions(this.config.actionSanitizer, state.actionsById)
|
|
217
359
|
: state.actionsById, computedStates: this.config.stateSanitizer
|
|
218
360
|
? sanitizeStates(this.config.stateSanitizer, state.computedStates)
|
|
219
361
|
: state.computedStates });
|
|
220
|
-
this.devtoolsExtension.send(null, sanitizedLiftedState, this.getExtensionConfig(this.
|
|
362
|
+
this.devtoolsExtension.send(null, sanitizedLiftedState, this.getExtensionConfig(this.config));
|
|
221
363
|
}
|
|
222
364
|
};
|
|
223
365
|
DevtoolsExtension.prototype.createChangesObservable = function () {
|
|
@@ -226,7 +368,7 @@ var DevtoolsExtension = /** @class */ (function () {
|
|
|
226
368
|
return empty();
|
|
227
369
|
}
|
|
228
370
|
return new Observable(function (subscriber) {
|
|
229
|
-
var connection = _this.devtoolsExtension.connect(_this.getExtensionConfig(_this.
|
|
371
|
+
var connection = _this.devtoolsExtension.connect(_this.getExtensionConfig(_this.config));
|
|
230
372
|
_this.extensionConnection = connection;
|
|
231
373
|
connection.init();
|
|
232
374
|
connection.subscribe(function (change) { return subscriber.next(change); });
|
|
@@ -235,14 +377,29 @@ var DevtoolsExtension = /** @class */ (function () {
|
|
|
235
377
|
};
|
|
236
378
|
DevtoolsExtension.prototype.createActionStreams = function () {
|
|
237
379
|
var _this = this;
|
|
238
|
-
// Listens to all changes
|
|
380
|
+
// Listens to all changes
|
|
239
381
|
var changes$ = this.createChangesObservable().pipe(share());
|
|
240
382
|
// Listen for the start action
|
|
241
383
|
var start$ = changes$.pipe(filter(function (change) { return change.type === ExtensionActionTypes.START; }));
|
|
242
384
|
// Listen for the stop action
|
|
243
385
|
var stop$ = changes$.pipe(filter(function (change) { return change.type === ExtensionActionTypes.STOP; }));
|
|
244
386
|
// Listen for lifted actions
|
|
245
|
-
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
|
+
}));
|
|
246
403
|
// Listen for unlifted actions
|
|
247
404
|
var actions$ = changes$.pipe(filter(function (change) { return change.type === ExtensionActionTypes.ACTION; }), map(function (change) { return _this.unwrapAction(change.payload); }));
|
|
248
405
|
var actionsUntilStop$ = actions$.pipe(takeUntil(stop$));
|
|
@@ -255,9 +412,8 @@ var DevtoolsExtension = /** @class */ (function () {
|
|
|
255
412
|
DevtoolsExtension.prototype.unwrapAction = function (action) {
|
|
256
413
|
return typeof action === 'string' ? eval("(" + action + ")") : action;
|
|
257
414
|
};
|
|
258
|
-
DevtoolsExtension.prototype.getExtensionConfig = function (
|
|
415
|
+
DevtoolsExtension.prototype.getExtensionConfig = function (config) {
|
|
259
416
|
var extensionOptions = {
|
|
260
|
-
instanceId: instanceId,
|
|
261
417
|
name: config.name,
|
|
262
418
|
features: config.features,
|
|
263
419
|
serialize: config.serialize,
|
|
@@ -267,26 +423,28 @@ var DevtoolsExtension = /** @class */ (function () {
|
|
|
267
423
|
}
|
|
268
424
|
return extensionOptions;
|
|
269
425
|
};
|
|
270
|
-
DevtoolsExtension
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
]; };
|
|
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);
|
|
278
433
|
return DevtoolsExtension;
|
|
279
434
|
}());
|
|
280
435
|
|
|
281
|
-
var __assign$2 = (undefined && undefined.__assign) ||
|
|
282
|
-
|
|
283
|
-
s = arguments
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
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);
|
|
288
446
|
};
|
|
289
|
-
var __read
|
|
447
|
+
var __read = (undefined && undefined.__read) || function (o, n) {
|
|
290
448
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
291
449
|
if (!m) return o;
|
|
292
450
|
var i = m.call(o), r, ar = [], e;
|
|
@@ -303,10 +461,12 @@ var __read$1 = (undefined && undefined.__read) || function (o, n) {
|
|
|
303
461
|
return ar;
|
|
304
462
|
};
|
|
305
463
|
var __spread = (undefined && undefined.__spread) || function () {
|
|
306
|
-
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read
|
|
464
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
307
465
|
return ar;
|
|
308
466
|
};
|
|
309
467
|
var INIT_ACTION = { type: INIT };
|
|
468
|
+
var RECOMPUTE = '@ngrx/store-devtools/recompute';
|
|
469
|
+
var RECOMPUTE_ACTION = { type: RECOMPUTE };
|
|
310
470
|
/**
|
|
311
471
|
* Computes the next entry in the log by applying an action.
|
|
312
472
|
*/
|
|
@@ -334,7 +494,7 @@ function computeNextEntry(reducer, action, state, error, errorHandler) {
|
|
|
334
494
|
/**
|
|
335
495
|
* Runs the reducer on invalidated actions to get a fresh computation log.
|
|
336
496
|
*/
|
|
337
|
-
function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler) {
|
|
497
|
+
function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused) {
|
|
338
498
|
// Optimization: exit early and return the same reference
|
|
339
499
|
// if we know nothing could have changed.
|
|
340
500
|
if (minInvalidatedStateIndex >= computedStates.length &&
|
|
@@ -342,7 +502,10 @@ function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, comm
|
|
|
342
502
|
return computedStates;
|
|
343
503
|
}
|
|
344
504
|
var nextComputedStates = computedStates.slice(0, minInvalidatedStateIndex);
|
|
345
|
-
|
|
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++) {
|
|
346
509
|
var actionId = stagedActionIds[i];
|
|
347
510
|
var action = actionsById[actionId].action;
|
|
348
511
|
var previousEntry = nextComputedStates[i - 1];
|
|
@@ -354,6 +517,11 @@ function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, comm
|
|
|
354
517
|
: computeNextEntry(reducer, action, previousState, previousError, errorHandler);
|
|
355
518
|
nextComputedStates.push(entry);
|
|
356
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
|
+
}
|
|
357
525
|
return nextComputedStates;
|
|
358
526
|
}
|
|
359
527
|
function liftInitialState(initialCommittedState, monitorReducer) {
|
|
@@ -366,6 +534,8 @@ function liftInitialState(initialCommittedState, monitorReducer) {
|
|
|
366
534
|
committedState: initialCommittedState,
|
|
367
535
|
currentStateIndex: 0,
|
|
368
536
|
computedStates: [],
|
|
537
|
+
isLocked: false,
|
|
538
|
+
isPaused: false,
|
|
369
539
|
};
|
|
370
540
|
}
|
|
371
541
|
/**
|
|
@@ -374,180 +544,232 @@ function liftInitialState(initialCommittedState, monitorReducer) {
|
|
|
374
544
|
function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler, monitorReducer, options) {
|
|
375
545
|
if (options === void 0) { options = {}; }
|
|
376
546
|
/**
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
return function (reducer) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
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
|
+
}
|
|
385
570
|
}
|
|
386
|
-
function
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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++;
|
|
399
614
|
}
|
|
615
|
+
minInvalidatedStateIndex = Infinity;
|
|
400
616
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
committedState = computedStates[excess].state;
|
|
404
|
-
computedStates = computedStates.slice(excess);
|
|
405
|
-
currentStateIndex =
|
|
406
|
-
currentStateIndex > excess ? currentStateIndex - excess : 0;
|
|
407
|
-
}
|
|
408
|
-
// By default, aggressively recompute every state whatever happens.
|
|
409
|
-
// This has O(n) performance, so we'll override this to a sensible
|
|
410
|
-
// value whenever we feel like we don't have to recompute the states.
|
|
411
|
-
var minInvalidatedStateIndex = 0;
|
|
412
|
-
switch (liftedAction.type) {
|
|
413
|
-
case RESET: {
|
|
414
|
-
// Get back to the state the store was created with.
|
|
415
|
-
actionsById = { 0: liftAction(INIT_ACTION) };
|
|
416
|
-
nextActionId = 1;
|
|
417
|
-
stagedActionIds = [0];
|
|
418
|
-
skippedActionIds = [];
|
|
419
|
-
committedState = initialCommittedState;
|
|
420
|
-
currentStateIndex = 0;
|
|
421
|
-
computedStates = [];
|
|
422
|
-
break;
|
|
617
|
+
else {
|
|
618
|
+
commitChanges();
|
|
423
619
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
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);
|
|
435
655
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
// Start again from the last committed state.
|
|
439
|
-
actionsById = { 0: liftAction(INIT_ACTION) };
|
|
440
|
-
nextActionId = 1;
|
|
441
|
-
stagedActionIds = [0];
|
|
442
|
-
skippedActionIds = [];
|
|
443
|
-
currentStateIndex = 0;
|
|
444
|
-
computedStates = [];
|
|
445
|
-
break;
|
|
656
|
+
else {
|
|
657
|
+
skippedActionIds = skippedActionIds.filter(function (id) { return id !== actionId_1; });
|
|
446
658
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
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);
|
|
461
672
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
// Being skipped means it is a no-op during the computation.
|
|
465
|
-
var start = liftedAction.start, end = liftedAction.end, active = liftedAction.active;
|
|
466
|
-
var actionIds = [];
|
|
467
|
-
for (var i = start; i < end; i++)
|
|
468
|
-
actionIds.push(i);
|
|
469
|
-
if (active) {
|
|
470
|
-
skippedActionIds = difference(skippedActionIds, actionIds);
|
|
471
|
-
}
|
|
472
|
-
else {
|
|
473
|
-
skippedActionIds = __spread(skippedActionIds, actionIds);
|
|
474
|
-
}
|
|
475
|
-
// Optimization: we know history before this action hasn't changed
|
|
476
|
-
minInvalidatedStateIndex = stagedActionIds.indexOf(start);
|
|
477
|
-
break;
|
|
673
|
+
else {
|
|
674
|
+
skippedActionIds = __spread(skippedActionIds, actionIds);
|
|
478
675
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
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;
|
|
486
708
|
}
|
|
487
|
-
|
|
488
|
-
//
|
|
489
|
-
//
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
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
|
+
]);
|
|
493
718
|
minInvalidatedStateIndex = Infinity;
|
|
494
719
|
break;
|
|
495
720
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
skippedActionIds = [];
|
|
500
|
-
currentStateIndex = Math.min(currentStateIndex, stagedActionIds.length - 1);
|
|
501
|
-
break;
|
|
721
|
+
// Auto-commit as new actions come in.
|
|
722
|
+
if (options.maxAge && stagedActionIds.length === options.maxAge) {
|
|
723
|
+
commitExcessActions(1);
|
|
502
724
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
if (options.maxAge && stagedActionIds.length === options.maxAge) {
|
|
506
|
-
commitExcessActions(1);
|
|
507
|
-
}
|
|
508
|
-
if (currentStateIndex === stagedActionIds.length - 1) {
|
|
509
|
-
currentStateIndex++;
|
|
510
|
-
}
|
|
511
|
-
var actionId = nextActionId++;
|
|
512
|
-
// Mutation! This is the hottest path, and we optimize on purpose.
|
|
513
|
-
// It is safe because we set a new key in a cache dictionary.
|
|
514
|
-
actionsById[actionId] = liftedAction;
|
|
515
|
-
stagedActionIds = __spread(stagedActionIds, [actionId]);
|
|
516
|
-
// Optimization: we know that only the new action needs computing.
|
|
517
|
-
minInvalidatedStateIndex = stagedActionIds.length - 1;
|
|
518
|
-
break;
|
|
725
|
+
if (currentStateIndex === stagedActionIds.length - 1) {
|
|
726
|
+
currentStateIndex++;
|
|
519
727
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
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;
|
|
524
753
|
}
|
|
525
|
-
|
|
526
|
-
|
|
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
|
|
527
760
|
minInvalidatedStateIndex = 0;
|
|
528
761
|
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
529
762
|
// States must be recomputed before committing excess.
|
|
530
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler);
|
|
763
|
+
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
531
764
|
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
532
765
|
// Avoid double computation.
|
|
533
766
|
minInvalidatedStateIndex = Infinity;
|
|
534
767
|
}
|
|
535
|
-
break;
|
|
536
768
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
minInvalidatedStateIndex = 0;
|
|
542
|
-
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
543
|
-
// States must be recomputed before committing excess.
|
|
544
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler);
|
|
545
|
-
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
546
|
-
// Avoid double computation.
|
|
547
|
-
minInvalidatedStateIndex = Infinity;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
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) {
|
|
551
773
|
if (currentStateIndex === stagedActionIds.length - 1) {
|
|
552
774
|
currentStateIndex++;
|
|
553
775
|
}
|
|
@@ -556,56 +778,56 @@ function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler
|
|
|
556
778
|
actionsById[actionId] = new PerformAction(liftedAction, +Date.now());
|
|
557
779
|
stagedActionIds = __spread(stagedActionIds, [actionId]);
|
|
558
780
|
minInvalidatedStateIndex = stagedActionIds.length - 1;
|
|
559
|
-
|
|
560
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler);
|
|
561
|
-
// Recompute state history with latest reducer and update action
|
|
562
|
-
computedStates = computedStates.map(function (cmp) {
|
|
563
|
-
return (__assign$2({}, cmp, { state: reducer(cmp.state, liftedAction) }));
|
|
564
|
-
});
|
|
565
|
-
currentStateIndex = minInvalidatedStateIndex;
|
|
566
|
-
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
567
|
-
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
568
|
-
}
|
|
569
|
-
// Avoid double computation.
|
|
570
|
-
minInvalidatedStateIndex = Infinity;
|
|
781
|
+
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
571
782
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
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.
|
|
577
790
|
minInvalidatedStateIndex = Infinity;
|
|
578
|
-
break;
|
|
579
791
|
}
|
|
792
|
+
break;
|
|
580
793
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
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;
|
|
799
|
+
}
|
|
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,
|
|
594
814
|
};
|
|
595
|
-
};
|
|
815
|
+
}; };
|
|
596
816
|
}
|
|
597
817
|
|
|
598
|
-
var
|
|
599
|
-
var
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
return
|
|
603
|
-
|
|
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
|
+
};
|
|
830
|
+
var __read$1 = (undefined && undefined.__read) || function (o, n) {
|
|
609
831
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
610
832
|
if (!m) return o;
|
|
611
833
|
var i = m.call(o), r, ar = [], e;
|
|
@@ -621,16 +843,6 @@ var __read = (undefined && undefined.__read) || function (o, n) {
|
|
|
621
843
|
}
|
|
622
844
|
return ar;
|
|
623
845
|
};
|
|
624
|
-
var DevtoolsDispatcher = /** @class */ (function (_super) {
|
|
625
|
-
__extends(DevtoolsDispatcher, _super);
|
|
626
|
-
function DevtoolsDispatcher() {
|
|
627
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
628
|
-
}
|
|
629
|
-
DevtoolsDispatcher.decorators = [
|
|
630
|
-
{ type: Injectable }
|
|
631
|
-
];
|
|
632
|
-
return DevtoolsDispatcher;
|
|
633
|
-
}(ActionsSubject));
|
|
634
846
|
var StoreDevtools = /** @class */ (function () {
|
|
635
847
|
function StoreDevtools(dispatcher, actions$, reducers$, extension, scannedActions, errorHandler, initialState, config) {
|
|
636
848
|
var _this = this;
|
|
@@ -642,9 +854,14 @@ var StoreDevtools = /** @class */ (function () {
|
|
|
642
854
|
var liftedStateSubscription = liftedAction$
|
|
643
855
|
.pipe(withLatestFrom(liftedReducer$), scan(function (_a, _b) {
|
|
644
856
|
var liftedState = _a.state;
|
|
645
|
-
var _c = __read(_b, 2), action = _c[0], reducer = _c[1];
|
|
857
|
+
var _c = __read$1(_b, 2), action = _c[0], reducer = _c[1];
|
|
646
858
|
var reducedLiftedState = reducer(liftedState, action);
|
|
647
|
-
//
|
|
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
|
|
648
865
|
extension.notify(action, reducedLiftedState);
|
|
649
866
|
return { state: reducedLiftedState, action: action };
|
|
650
867
|
}, { state: liftedInitialState, action: null }))
|
|
@@ -705,23 +922,32 @@ var StoreDevtools = /** @class */ (function () {
|
|
|
705
922
|
StoreDevtools.prototype.importState = function (nextLiftedState) {
|
|
706
923
|
this.dispatch(new ImportState(nextLiftedState));
|
|
707
924
|
};
|
|
708
|
-
StoreDevtools.
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
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);
|
|
722
942
|
return StoreDevtools;
|
|
723
943
|
}());
|
|
724
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
|
+
};
|
|
725
951
|
var IS_EXTENSION_OR_MONITOR_PRESENT = new InjectionToken('Is Devtools Extension or Monitor Present');
|
|
726
952
|
function createIsExtensionOrMonitorPresent(extension, config) {
|
|
727
953
|
return Boolean(extension) || config.monitor !== noMonitor;
|
|
@@ -739,39 +965,14 @@ function createReduxDevtoolsExtension() {
|
|
|
739
965
|
function createStateObservable(devtools) {
|
|
740
966
|
return devtools.state;
|
|
741
967
|
}
|
|
742
|
-
function noMonitor() {
|
|
743
|
-
return null;
|
|
744
|
-
}
|
|
745
|
-
var DEFAULT_NAME = 'NgRx Store DevTools';
|
|
746
|
-
function createConfig(_options) {
|
|
747
|
-
var DEFAULT_OPTIONS = {
|
|
748
|
-
maxAge: false,
|
|
749
|
-
monitor: noMonitor,
|
|
750
|
-
actionSanitizer: undefined,
|
|
751
|
-
stateSanitizer: undefined,
|
|
752
|
-
name: DEFAULT_NAME,
|
|
753
|
-
serialize: false,
|
|
754
|
-
logOnly: false,
|
|
755
|
-
features: false,
|
|
756
|
-
};
|
|
757
|
-
var options = typeof _options === 'function' ? _options() : _options;
|
|
758
|
-
var logOnly = options.logOnly
|
|
759
|
-
? { pause: true, export: true, test: true }
|
|
760
|
-
: false;
|
|
761
|
-
var features = options.features || logOnly;
|
|
762
|
-
var config = Object.assign({}, DEFAULT_OPTIONS, { features: features }, options);
|
|
763
|
-
if (config.maxAge && config.maxAge < 2) {
|
|
764
|
-
throw new Error("Devtools 'maxAge' cannot be less than 2, got " + config.maxAge);
|
|
765
|
-
}
|
|
766
|
-
return config;
|
|
767
|
-
}
|
|
768
968
|
var StoreDevtoolsModule = /** @class */ (function () {
|
|
769
969
|
function StoreDevtoolsModule() {
|
|
770
970
|
}
|
|
971
|
+
StoreDevtoolsModule_1 = StoreDevtoolsModule;
|
|
771
972
|
StoreDevtoolsModule.instrument = function (options) {
|
|
772
973
|
if (options === void 0) { options = {}; }
|
|
773
974
|
return {
|
|
774
|
-
ngModule:
|
|
975
|
+
ngModule: StoreDevtoolsModule_1,
|
|
775
976
|
providers: [
|
|
776
977
|
DevtoolsExtension,
|
|
777
978
|
DevtoolsDispatcher,
|
|
@@ -806,9 +1007,10 @@ var StoreDevtoolsModule = /** @class */ (function () {
|
|
|
806
1007
|
],
|
|
807
1008
|
};
|
|
808
1009
|
};
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
1010
|
+
var StoreDevtoolsModule_1;
|
|
1011
|
+
StoreDevtoolsModule = StoreDevtoolsModule_1 = __decorate$3([
|
|
1012
|
+
NgModule({})
|
|
1013
|
+
], StoreDevtoolsModule);
|
|
812
1014
|
return StoreDevtoolsModule;
|
|
813
1015
|
}());
|
|
814
1016
|
|
|
@@ -822,5 +1024,5 @@ var StoreDevtoolsModule = /** @class */ (function () {
|
|
|
822
1024
|
* Generated bundle index. Do not edit.
|
|
823
1025
|
*/
|
|
824
1026
|
|
|
825
|
-
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 };
|
|
826
1028
|
//# sourceMappingURL=store-devtools.js.map
|