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