@ngrx/store-devtools 15.3.0 → 16.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/esm2022/src/config.mjs +68 -0
- package/esm2022/src/devtools-dispatcher.mjs +12 -0
- package/esm2022/src/devtools.mjs +109 -0
- package/esm2022/src/extension.mjs +164 -0
- package/esm2022/src/instrument.mjs +23 -0
- package/{fesm2020 → fesm2022}/ngrx-store-devtools.mjs +19 -15
- package/fesm2022/ngrx-store-devtools.mjs.map +1 -0
- package/migrations/6_0_0/index.js +2 -2
- package/migrations/6_0_0/index.js.map +1 -1
- package/package.json +6 -12
- package/schematics/ng-add/index.js +4 -4
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.js +1 -1
- package/schematics-core/index.js +50 -61
- package/schematics-core/index.js.map +1 -1
- package/schematics-core/utility/ast-utils.js +3 -3
- package/schematics-core/utility/change.js +2 -2
- package/schematics-core/utility/config.js +1 -1
- package/schematics-core/utility/find-component.js +2 -2
- package/schematics-core/utility/find-module.js +2 -2
- package/schematics-core/utility/json-utilts.js +2 -2
- package/schematics-core/utility/libs-version.js +2 -2
- package/schematics-core/utility/libs-version.js.map +1 -1
- package/schematics-core/utility/ngrx-utils.js +3 -3
- package/schematics-core/utility/package.js +1 -1
- package/schematics-core/utility/parse-name.js +2 -2
- package/schematics-core/utility/project.js +1 -1
- package/schematics-core/utility/strings.js +1 -1
- package/schematics-core/utility/update.js +1 -1
- package/schematics-core/utility/visitors.js +7 -7
- package/src/actions.d.ts +1 -1
- package/src/config.d.ts +5 -5
- package/src/reducer.d.ts +4 -4
- package/esm2020/src/config.mjs +0 -63
- package/esm2020/src/devtools-dispatcher.mjs +0 -11
- package/esm2020/src/devtools.mjs +0 -108
- package/esm2020/src/extension.mjs +0 -163
- package/esm2020/src/instrument.mjs +0 -22
- package/fesm2015/ngrx-store-devtools.mjs +0 -984
- package/fesm2015/ngrx-store-devtools.mjs.map +0 -1
- package/fesm2020/ngrx-store-devtools.mjs.map +0 -1
- /package/{esm2020 → esm2022}/index.mjs +0 -0
- /package/{esm2020 → esm2022}/ngrx-store-devtools.mjs +0 -0
- /package/{esm2020 → esm2022}/public_api.mjs +0 -0
- /package/{esm2020 → esm2022}/src/actions.mjs +0 -0
- /package/{esm2020 → esm2022}/src/index.mjs +0 -0
- /package/{esm2020 → esm2022}/src/provide-store-devtools.mjs +0 -0
- /package/{esm2020 → esm2022}/src/reducer.mjs +0 -0
- /package/{esm2020 → esm2022}/src/utils.mjs +0 -0
|
@@ -1,984 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, Injectable, Inject, makeEnvironmentProviders, NgModule } from '@angular/core';
|
|
3
|
-
import * as i2 from '@ngrx/store';
|
|
4
|
-
import { ActionsSubject, UPDATE, INIT, INITIAL_STATE, StateObservable, ReducerManagerDispatcher } from '@ngrx/store';
|
|
5
|
-
import { EMPTY, Observable, of, merge, queueScheduler, ReplaySubject } from 'rxjs';
|
|
6
|
-
import { share, filter, map, concatMap, timeout, debounceTime, catchError, take, takeUntil, switchMap, skip, observeOn, withLatestFrom, scan } from 'rxjs/operators';
|
|
7
|
-
|
|
8
|
-
const PERFORM_ACTION = 'PERFORM_ACTION';
|
|
9
|
-
const REFRESH = 'REFRESH';
|
|
10
|
-
const RESET = 'RESET';
|
|
11
|
-
const ROLLBACK = 'ROLLBACK';
|
|
12
|
-
const COMMIT = 'COMMIT';
|
|
13
|
-
const SWEEP = 'SWEEP';
|
|
14
|
-
const TOGGLE_ACTION = 'TOGGLE_ACTION';
|
|
15
|
-
const SET_ACTIONS_ACTIVE = 'SET_ACTIONS_ACTIVE';
|
|
16
|
-
const JUMP_TO_STATE = 'JUMP_TO_STATE';
|
|
17
|
-
const JUMP_TO_ACTION = 'JUMP_TO_ACTION';
|
|
18
|
-
const IMPORT_STATE = 'IMPORT_STATE';
|
|
19
|
-
const LOCK_CHANGES = 'LOCK_CHANGES';
|
|
20
|
-
const PAUSE_RECORDING = 'PAUSE_RECORDING';
|
|
21
|
-
class PerformAction {
|
|
22
|
-
constructor(action, timestamp) {
|
|
23
|
-
this.action = action;
|
|
24
|
-
this.timestamp = timestamp;
|
|
25
|
-
this.type = PERFORM_ACTION;
|
|
26
|
-
if (typeof action.type === 'undefined') {
|
|
27
|
-
throw new Error('Actions may not have an undefined "type" property. ' +
|
|
28
|
-
'Have you misspelled a constant?');
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
class Refresh {
|
|
33
|
-
constructor() {
|
|
34
|
-
this.type = REFRESH;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
class Reset {
|
|
38
|
-
constructor(timestamp) {
|
|
39
|
-
this.timestamp = timestamp;
|
|
40
|
-
this.type = RESET;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
class Rollback {
|
|
44
|
-
constructor(timestamp) {
|
|
45
|
-
this.timestamp = timestamp;
|
|
46
|
-
this.type = ROLLBACK;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
class Commit {
|
|
50
|
-
constructor(timestamp) {
|
|
51
|
-
this.timestamp = timestamp;
|
|
52
|
-
this.type = COMMIT;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
class Sweep {
|
|
56
|
-
constructor() {
|
|
57
|
-
this.type = SWEEP;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
class ToggleAction {
|
|
61
|
-
constructor(id) {
|
|
62
|
-
this.id = id;
|
|
63
|
-
this.type = TOGGLE_ACTION;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
class SetActionsActive {
|
|
67
|
-
constructor(start, end, active = true) {
|
|
68
|
-
this.start = start;
|
|
69
|
-
this.end = end;
|
|
70
|
-
this.active = active;
|
|
71
|
-
this.type = SET_ACTIONS_ACTIVE;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
class JumpToState {
|
|
75
|
-
constructor(index) {
|
|
76
|
-
this.index = index;
|
|
77
|
-
this.type = JUMP_TO_STATE;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
class JumpToAction {
|
|
81
|
-
constructor(actionId) {
|
|
82
|
-
this.actionId = actionId;
|
|
83
|
-
this.type = JUMP_TO_ACTION;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
class ImportState {
|
|
87
|
-
constructor(nextLiftedState) {
|
|
88
|
-
this.nextLiftedState = nextLiftedState;
|
|
89
|
-
this.type = IMPORT_STATE;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
class LockChanges {
|
|
93
|
-
constructor(status) {
|
|
94
|
-
this.status = status;
|
|
95
|
-
this.type = LOCK_CHANGES;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
class PauseRecording {
|
|
99
|
-
constructor(status) {
|
|
100
|
-
this.status = status;
|
|
101
|
-
this.type = PAUSE_RECORDING;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Chrome extension documentation
|
|
107
|
-
* @see https://github.com/reduxjs/redux-devtools/blob/main/extension/docs/API/Arguments.md
|
|
108
|
-
* Firefox extension documentation
|
|
109
|
-
* @see https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md
|
|
110
|
-
*/
|
|
111
|
-
class StoreDevtoolsConfig {
|
|
112
|
-
constructor() {
|
|
113
|
-
/**
|
|
114
|
-
* Maximum allowed actions to be stored in the history tree (default: `false`)
|
|
115
|
-
*/
|
|
116
|
-
this.maxAge = false;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
const STORE_DEVTOOLS_CONFIG = new InjectionToken('@ngrx/store-devtools Options');
|
|
120
|
-
/**
|
|
121
|
-
* Used to provide a `StoreDevtoolsConfig` for the store-devtools.
|
|
122
|
-
*/
|
|
123
|
-
const INITIAL_OPTIONS = new InjectionToken('@ngrx/store-devtools Initial Config');
|
|
124
|
-
function noMonitor() {
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
const DEFAULT_NAME = 'NgRx Store DevTools';
|
|
128
|
-
function createConfig(optionsInput) {
|
|
129
|
-
const DEFAULT_OPTIONS = {
|
|
130
|
-
maxAge: false,
|
|
131
|
-
monitor: noMonitor,
|
|
132
|
-
actionSanitizer: undefined,
|
|
133
|
-
stateSanitizer: undefined,
|
|
134
|
-
name: DEFAULT_NAME,
|
|
135
|
-
serialize: false,
|
|
136
|
-
logOnly: false,
|
|
137
|
-
autoPause: false,
|
|
138
|
-
trace: false,
|
|
139
|
-
traceLimit: 75,
|
|
140
|
-
// Add all features explicitly. This prevent buggy behavior for
|
|
141
|
-
// options like "lock" which might otherwise not show up.
|
|
142
|
-
features: {
|
|
143
|
-
pause: true,
|
|
144
|
-
lock: true,
|
|
145
|
-
persist: true,
|
|
146
|
-
export: true,
|
|
147
|
-
import: 'custom',
|
|
148
|
-
jump: true,
|
|
149
|
-
skip: true,
|
|
150
|
-
reorder: true,
|
|
151
|
-
dispatch: true,
|
|
152
|
-
test: true, // Generate tests for the selected actions
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
const options = typeof optionsInput === 'function' ? optionsInput() : optionsInput;
|
|
156
|
-
const logOnly = options.logOnly
|
|
157
|
-
? { pause: true, export: true, test: true }
|
|
158
|
-
: false;
|
|
159
|
-
const features = options.features || logOnly || DEFAULT_OPTIONS.features;
|
|
160
|
-
const config = Object.assign({}, DEFAULT_OPTIONS, { features }, options);
|
|
161
|
-
if (config.maxAge && config.maxAge < 2) {
|
|
162
|
-
throw new Error(`Devtools 'maxAge' cannot be less than 2, got ${config.maxAge}`);
|
|
163
|
-
}
|
|
164
|
-
return config;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function difference(first, second) {
|
|
168
|
-
return first.filter((item) => second.indexOf(item) < 0);
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Provides an app's view into the state of the lifted store.
|
|
172
|
-
*/
|
|
173
|
-
function unliftState(liftedState) {
|
|
174
|
-
const { computedStates, currentStateIndex } = liftedState;
|
|
175
|
-
// At start up NgRx dispatches init actions,
|
|
176
|
-
// When these init actions are being filtered out by the predicate or safe/block list options
|
|
177
|
-
// we don't have a complete computed states yet.
|
|
178
|
-
// At this point it could happen that we're out of bounds, when this happens we fall back to the last known state
|
|
179
|
-
if (currentStateIndex >= computedStates.length) {
|
|
180
|
-
const { state } = computedStates[computedStates.length - 1];
|
|
181
|
-
return state;
|
|
182
|
-
}
|
|
183
|
-
const { state } = computedStates[currentStateIndex];
|
|
184
|
-
return state;
|
|
185
|
-
}
|
|
186
|
-
function unliftAction(liftedState) {
|
|
187
|
-
return liftedState.actionsById[liftedState.nextActionId - 1];
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Lifts an app's action into an action on the lifted store.
|
|
191
|
-
*/
|
|
192
|
-
function liftAction(action) {
|
|
193
|
-
return new PerformAction(action, +Date.now());
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Sanitizes given actions with given function.
|
|
197
|
-
*/
|
|
198
|
-
function sanitizeActions(actionSanitizer, actions) {
|
|
199
|
-
return Object.keys(actions).reduce((sanitizedActions, actionIdx) => {
|
|
200
|
-
const idx = Number(actionIdx);
|
|
201
|
-
sanitizedActions[idx] = sanitizeAction(actionSanitizer, actions[idx], idx);
|
|
202
|
-
return sanitizedActions;
|
|
203
|
-
}, {});
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Sanitizes given action with given function.
|
|
207
|
-
*/
|
|
208
|
-
function sanitizeAction(actionSanitizer, action, actionIdx) {
|
|
209
|
-
return Object.assign(Object.assign({}, action), { action: actionSanitizer(action.action, actionIdx) });
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Sanitizes given states with given function.
|
|
213
|
-
*/
|
|
214
|
-
function sanitizeStates(stateSanitizer, states) {
|
|
215
|
-
return states.map((computedState, idx) => ({
|
|
216
|
-
state: sanitizeState(stateSanitizer, computedState.state, idx),
|
|
217
|
-
error: computedState.error,
|
|
218
|
-
}));
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Sanitizes given state with given function.
|
|
222
|
-
*/
|
|
223
|
-
function sanitizeState(stateSanitizer, state, stateIdx) {
|
|
224
|
-
return stateSanitizer(state, stateIdx);
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Read the config and tell if actions should be filtered
|
|
228
|
-
*/
|
|
229
|
-
function shouldFilterActions(config) {
|
|
230
|
-
return config.predicate || config.actionsSafelist || config.actionsBlocklist;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Return a full filtered lifted state
|
|
234
|
-
*/
|
|
235
|
-
function filterLiftedState(liftedState, predicate, safelist, blocklist) {
|
|
236
|
-
const filteredStagedActionIds = [];
|
|
237
|
-
const filteredActionsById = {};
|
|
238
|
-
const filteredComputedStates = [];
|
|
239
|
-
liftedState.stagedActionIds.forEach((id, idx) => {
|
|
240
|
-
const liftedAction = liftedState.actionsById[id];
|
|
241
|
-
if (!liftedAction)
|
|
242
|
-
return;
|
|
243
|
-
if (idx &&
|
|
244
|
-
isActionFiltered(liftedState.computedStates[idx], liftedAction, predicate, safelist, blocklist)) {
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
filteredActionsById[id] = liftedAction;
|
|
248
|
-
filteredStagedActionIds.push(id);
|
|
249
|
-
filteredComputedStates.push(liftedState.computedStates[idx]);
|
|
250
|
-
});
|
|
251
|
-
return Object.assign(Object.assign({}, liftedState), { stagedActionIds: filteredStagedActionIds, actionsById: filteredActionsById, computedStates: filteredComputedStates });
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Return true is the action should be ignored
|
|
255
|
-
*/
|
|
256
|
-
function isActionFiltered(state, action, predicate, safelist, blockedlist) {
|
|
257
|
-
const predicateMatch = predicate && !predicate(state, action.action);
|
|
258
|
-
const safelistMatch = safelist &&
|
|
259
|
-
!action.action.type.match(safelist.map((s) => escapeRegExp(s)).join('|'));
|
|
260
|
-
const blocklistMatch = blockedlist &&
|
|
261
|
-
action.action.type.match(blockedlist.map((s) => escapeRegExp(s)).join('|'));
|
|
262
|
-
return predicateMatch || safelistMatch || blocklistMatch;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Return string with escaped RegExp special characters
|
|
266
|
-
* https://stackoverflow.com/a/6969486/1337347
|
|
267
|
-
*/
|
|
268
|
-
function escapeRegExp(s) {
|
|
269
|
-
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
class DevtoolsDispatcher extends ActionsSubject {
|
|
273
|
-
}
|
|
274
|
-
/** @nocollapse */ DevtoolsDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: DevtoolsDispatcher, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
275
|
-
/** @nocollapse */ DevtoolsDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: DevtoolsDispatcher });
|
|
276
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: DevtoolsDispatcher, decorators: [{
|
|
277
|
-
type: Injectable
|
|
278
|
-
}] });
|
|
279
|
-
|
|
280
|
-
const ExtensionActionTypes = {
|
|
281
|
-
START: 'START',
|
|
282
|
-
DISPATCH: 'DISPATCH',
|
|
283
|
-
STOP: 'STOP',
|
|
284
|
-
ACTION: 'ACTION',
|
|
285
|
-
};
|
|
286
|
-
const REDUX_DEVTOOLS_EXTENSION = new InjectionToken('@ngrx/store-devtools Redux Devtools Extension');
|
|
287
|
-
class DevtoolsExtension {
|
|
288
|
-
constructor(devtoolsExtension, config, dispatcher) {
|
|
289
|
-
this.config = config;
|
|
290
|
-
this.dispatcher = dispatcher;
|
|
291
|
-
this.devtoolsExtension = devtoolsExtension;
|
|
292
|
-
this.createActionStreams();
|
|
293
|
-
}
|
|
294
|
-
notify(action, state) {
|
|
295
|
-
if (!this.devtoolsExtension) {
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
// Check to see if the action requires a full update of the liftedState.
|
|
299
|
-
// If it is a simple action generated by the user's app and the recording
|
|
300
|
-
// is not locked/paused, only send the action and the current state (fast).
|
|
301
|
-
//
|
|
302
|
-
// A full liftedState update (slow: serializes the entire liftedState) is
|
|
303
|
-
// only required when:
|
|
304
|
-
// a) redux-devtools-extension fires the @@Init action (ignored by
|
|
305
|
-
// @ngrx/store-devtools)
|
|
306
|
-
// b) an action is generated by an @ngrx module (e.g. @ngrx/effects/init
|
|
307
|
-
// or @ngrx/store/update-reducers)
|
|
308
|
-
// c) the state has been recomputed due to time-traveling
|
|
309
|
-
// d) any action that is not a PerformAction to err on the side of
|
|
310
|
-
// caution.
|
|
311
|
-
if (action.type === PERFORM_ACTION) {
|
|
312
|
-
if (state.isLocked || state.isPaused) {
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
const currentState = unliftState(state);
|
|
316
|
-
if (shouldFilterActions(this.config) &&
|
|
317
|
-
isActionFiltered(currentState, action, this.config.predicate, this.config.actionsSafelist, this.config.actionsBlocklist)) {
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
const sanitizedState = this.config.stateSanitizer
|
|
321
|
-
? sanitizeState(this.config.stateSanitizer, currentState, state.currentStateIndex)
|
|
322
|
-
: currentState;
|
|
323
|
-
const sanitizedAction = this.config.actionSanitizer
|
|
324
|
-
? sanitizeAction(this.config.actionSanitizer, action, state.nextActionId)
|
|
325
|
-
: action;
|
|
326
|
-
this.sendToReduxDevtools(() => this.extensionConnection.send(sanitizedAction, sanitizedState));
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
// Requires full state update
|
|
330
|
-
const sanitizedLiftedState = Object.assign(Object.assign({}, state), { stagedActionIds: state.stagedActionIds, actionsById: this.config.actionSanitizer
|
|
331
|
-
? sanitizeActions(this.config.actionSanitizer, state.actionsById)
|
|
332
|
-
: state.actionsById, computedStates: this.config.stateSanitizer
|
|
333
|
-
? sanitizeStates(this.config.stateSanitizer, state.computedStates)
|
|
334
|
-
: state.computedStates });
|
|
335
|
-
this.sendToReduxDevtools(() => this.devtoolsExtension.send(null, sanitizedLiftedState, this.getExtensionConfig(this.config)));
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
createChangesObservable() {
|
|
339
|
-
if (!this.devtoolsExtension) {
|
|
340
|
-
return EMPTY;
|
|
341
|
-
}
|
|
342
|
-
return new Observable((subscriber) => {
|
|
343
|
-
const connection = this.devtoolsExtension.connect(this.getExtensionConfig(this.config));
|
|
344
|
-
this.extensionConnection = connection;
|
|
345
|
-
connection.init();
|
|
346
|
-
connection.subscribe((change) => subscriber.next(change));
|
|
347
|
-
return connection.unsubscribe;
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
createActionStreams() {
|
|
351
|
-
// Listens to all changes
|
|
352
|
-
const changes$ = this.createChangesObservable().pipe(share());
|
|
353
|
-
// Listen for the start action
|
|
354
|
-
const start$ = changes$.pipe(filter((change) => change.type === ExtensionActionTypes.START));
|
|
355
|
-
// Listen for the stop action
|
|
356
|
-
const stop$ = changes$.pipe(filter((change) => change.type === ExtensionActionTypes.STOP));
|
|
357
|
-
// Listen for lifted actions
|
|
358
|
-
const liftedActions$ = changes$.pipe(filter((change) => change.type === ExtensionActionTypes.DISPATCH), map((change) => this.unwrapAction(change.payload)), concatMap((action) => {
|
|
359
|
-
if (action.type === IMPORT_STATE) {
|
|
360
|
-
// State imports may happen in two situations:
|
|
361
|
-
// 1. Explicitly by user
|
|
362
|
-
// 2. User activated the "persist state accross reloads" option
|
|
363
|
-
// and now the state is imported during reload.
|
|
364
|
-
// Because of option 2, we need to give possible
|
|
365
|
-
// lazy loaded reducers time to instantiate.
|
|
366
|
-
// As soon as there is no UPDATE action within 1 second,
|
|
367
|
-
// it is assumed that all reducers are loaded.
|
|
368
|
-
return this.dispatcher.pipe(filter((action) => action.type === UPDATE), timeout(1000), debounceTime(1000), map(() => action), catchError(() => of(action)), take(1));
|
|
369
|
-
}
|
|
370
|
-
else {
|
|
371
|
-
return of(action);
|
|
372
|
-
}
|
|
373
|
-
}));
|
|
374
|
-
// Listen for unlifted actions
|
|
375
|
-
const actions$ = changes$.pipe(filter((change) => change.type === ExtensionActionTypes.ACTION), map((change) => this.unwrapAction(change.payload)));
|
|
376
|
-
const actionsUntilStop$ = actions$.pipe(takeUntil(stop$));
|
|
377
|
-
const liftedUntilStop$ = liftedActions$.pipe(takeUntil(stop$));
|
|
378
|
-
this.start$ = start$.pipe(takeUntil(stop$));
|
|
379
|
-
// Only take the action sources between the start/stop events
|
|
380
|
-
this.actions$ = this.start$.pipe(switchMap(() => actionsUntilStop$));
|
|
381
|
-
this.liftedActions$ = this.start$.pipe(switchMap(() => liftedUntilStop$));
|
|
382
|
-
}
|
|
383
|
-
unwrapAction(action) {
|
|
384
|
-
return typeof action === 'string' ? eval(`(${action})`) : action;
|
|
385
|
-
}
|
|
386
|
-
getExtensionConfig(config) {
|
|
387
|
-
var _a, _b, _c;
|
|
388
|
-
const extensionOptions = {
|
|
389
|
-
name: config.name,
|
|
390
|
-
features: config.features,
|
|
391
|
-
serialize: config.serialize,
|
|
392
|
-
autoPause: (_a = config.autoPause) !== null && _a !== void 0 ? _a : false,
|
|
393
|
-
trace: (_b = config.trace) !== null && _b !== void 0 ? _b : false,
|
|
394
|
-
traceLimit: (_c = config.traceLimit) !== null && _c !== void 0 ? _c : 75,
|
|
395
|
-
// The action/state sanitizers are not added to the config
|
|
396
|
-
// because sanitation is done in this class already.
|
|
397
|
-
// It is done before sending it to the devtools extension for consistency:
|
|
398
|
-
// - If we call extensionConnection.send(...),
|
|
399
|
-
// the extension would call the sanitizers.
|
|
400
|
-
// - If we call devtoolsExtension.send(...) (aka full state update),
|
|
401
|
-
// the extension would NOT call the sanitizers, so we have to do it ourselves.
|
|
402
|
-
};
|
|
403
|
-
if (config.maxAge !== false /* support === 0 */) {
|
|
404
|
-
extensionOptions.maxAge = config.maxAge;
|
|
405
|
-
}
|
|
406
|
-
return extensionOptions;
|
|
407
|
-
}
|
|
408
|
-
sendToReduxDevtools(send) {
|
|
409
|
-
try {
|
|
410
|
-
send();
|
|
411
|
-
}
|
|
412
|
-
catch (err) {
|
|
413
|
-
console.warn('@ngrx/store-devtools: something went wrong inside the redux devtools', err);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
/** @nocollapse */ DevtoolsExtension.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: DevtoolsExtension, deps: [{ token: REDUX_DEVTOOLS_EXTENSION }, { token: STORE_DEVTOOLS_CONFIG }, { token: DevtoolsDispatcher }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
418
|
-
/** @nocollapse */ DevtoolsExtension.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: DevtoolsExtension });
|
|
419
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: DevtoolsExtension, decorators: [{
|
|
420
|
-
type: Injectable
|
|
421
|
-
}], ctorParameters: function () {
|
|
422
|
-
return [{ type: undefined, decorators: [{
|
|
423
|
-
type: Inject,
|
|
424
|
-
args: [REDUX_DEVTOOLS_EXTENSION]
|
|
425
|
-
}] }, { type: StoreDevtoolsConfig, decorators: [{
|
|
426
|
-
type: Inject,
|
|
427
|
-
args: [STORE_DEVTOOLS_CONFIG]
|
|
428
|
-
}] }, { type: DevtoolsDispatcher }];
|
|
429
|
-
} });
|
|
430
|
-
|
|
431
|
-
const INIT_ACTION = { type: INIT };
|
|
432
|
-
const RECOMPUTE = '@ngrx/store-devtools/recompute';
|
|
433
|
-
const RECOMPUTE_ACTION = { type: RECOMPUTE };
|
|
434
|
-
/**
|
|
435
|
-
* Computes the next entry in the log by applying an action.
|
|
436
|
-
*/
|
|
437
|
-
function computeNextEntry(reducer, action, state, error, errorHandler) {
|
|
438
|
-
if (error) {
|
|
439
|
-
return {
|
|
440
|
-
state,
|
|
441
|
-
error: 'Interrupted by an error up the chain',
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
let nextState = state;
|
|
445
|
-
let nextError;
|
|
446
|
-
try {
|
|
447
|
-
nextState = reducer(state, action);
|
|
448
|
-
}
|
|
449
|
-
catch (err) {
|
|
450
|
-
nextError = err.toString();
|
|
451
|
-
errorHandler.handleError(err);
|
|
452
|
-
}
|
|
453
|
-
return {
|
|
454
|
-
state: nextState,
|
|
455
|
-
error: nextError,
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* Runs the reducer on invalidated actions to get a fresh computation log.
|
|
460
|
-
*/
|
|
461
|
-
function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused) {
|
|
462
|
-
// Optimization: exit early and return the same reference
|
|
463
|
-
// if we know nothing could have changed.
|
|
464
|
-
if (minInvalidatedStateIndex >= computedStates.length &&
|
|
465
|
-
computedStates.length === stagedActionIds.length) {
|
|
466
|
-
return computedStates;
|
|
467
|
-
}
|
|
468
|
-
const nextComputedStates = computedStates.slice(0, minInvalidatedStateIndex);
|
|
469
|
-
// If the recording is paused, recompute all states up until the pause state,
|
|
470
|
-
// else recompute all states.
|
|
471
|
-
const lastIncludedActionId = stagedActionIds.length - (isPaused ? 1 : 0);
|
|
472
|
-
for (let i = minInvalidatedStateIndex; i < lastIncludedActionId; i++) {
|
|
473
|
-
const actionId = stagedActionIds[i];
|
|
474
|
-
const action = actionsById[actionId].action;
|
|
475
|
-
const previousEntry = nextComputedStates[i - 1];
|
|
476
|
-
const previousState = previousEntry ? previousEntry.state : committedState;
|
|
477
|
-
const previousError = previousEntry ? previousEntry.error : undefined;
|
|
478
|
-
const shouldSkip = skippedActionIds.indexOf(actionId) > -1;
|
|
479
|
-
const entry = shouldSkip
|
|
480
|
-
? previousEntry
|
|
481
|
-
: computeNextEntry(reducer, action, previousState, previousError, errorHandler);
|
|
482
|
-
nextComputedStates.push(entry);
|
|
483
|
-
}
|
|
484
|
-
// If the recording is paused, the last state will not be recomputed,
|
|
485
|
-
// because it's essentially not part of the state history.
|
|
486
|
-
if (isPaused) {
|
|
487
|
-
nextComputedStates.push(computedStates[computedStates.length - 1]);
|
|
488
|
-
}
|
|
489
|
-
return nextComputedStates;
|
|
490
|
-
}
|
|
491
|
-
function liftInitialState(initialCommittedState, monitorReducer) {
|
|
492
|
-
return {
|
|
493
|
-
monitorState: monitorReducer(undefined, {}),
|
|
494
|
-
nextActionId: 1,
|
|
495
|
-
actionsById: { 0: liftAction(INIT_ACTION) },
|
|
496
|
-
stagedActionIds: [0],
|
|
497
|
-
skippedActionIds: [],
|
|
498
|
-
committedState: initialCommittedState,
|
|
499
|
-
currentStateIndex: 0,
|
|
500
|
-
computedStates: [],
|
|
501
|
-
isLocked: false,
|
|
502
|
-
isPaused: false,
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* Creates a history state reducer from an app's reducer.
|
|
507
|
-
*/
|
|
508
|
-
function liftReducerWith(initialCommittedState, initialLiftedState, errorHandler, monitorReducer, options = {}) {
|
|
509
|
-
/**
|
|
510
|
-
* Manages how the history actions modify the history state.
|
|
511
|
-
*/
|
|
512
|
-
return (reducer) => (liftedState, liftedAction) => {
|
|
513
|
-
let { monitorState, actionsById, nextActionId, stagedActionIds, skippedActionIds, committedState, currentStateIndex, computedStates, isLocked, isPaused, } = liftedState || initialLiftedState;
|
|
514
|
-
if (!liftedState) {
|
|
515
|
-
// Prevent mutating initialLiftedState
|
|
516
|
-
actionsById = Object.create(actionsById);
|
|
517
|
-
}
|
|
518
|
-
function commitExcessActions(n) {
|
|
519
|
-
// Auto-commits n-number of excess actions.
|
|
520
|
-
let excess = n;
|
|
521
|
-
let idsToDelete = stagedActionIds.slice(1, excess + 1);
|
|
522
|
-
for (let i = 0; i < idsToDelete.length; i++) {
|
|
523
|
-
if (computedStates[i + 1].error) {
|
|
524
|
-
// Stop if error is found. Commit actions up to error.
|
|
525
|
-
excess = i;
|
|
526
|
-
idsToDelete = stagedActionIds.slice(1, excess + 1);
|
|
527
|
-
break;
|
|
528
|
-
}
|
|
529
|
-
else {
|
|
530
|
-
delete actionsById[idsToDelete[i]];
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
skippedActionIds = skippedActionIds.filter((id) => idsToDelete.indexOf(id) === -1);
|
|
534
|
-
stagedActionIds = [0, ...stagedActionIds.slice(excess + 1)];
|
|
535
|
-
committedState = computedStates[excess].state;
|
|
536
|
-
computedStates = computedStates.slice(excess);
|
|
537
|
-
currentStateIndex =
|
|
538
|
-
currentStateIndex > excess ? currentStateIndex - excess : 0;
|
|
539
|
-
}
|
|
540
|
-
function commitChanges() {
|
|
541
|
-
// Consider the last committed state the new starting point.
|
|
542
|
-
// Squash any staged actions into a single committed state.
|
|
543
|
-
actionsById = { 0: liftAction(INIT_ACTION) };
|
|
544
|
-
nextActionId = 1;
|
|
545
|
-
stagedActionIds = [0];
|
|
546
|
-
skippedActionIds = [];
|
|
547
|
-
committedState = computedStates[currentStateIndex].state;
|
|
548
|
-
currentStateIndex = 0;
|
|
549
|
-
computedStates = [];
|
|
550
|
-
}
|
|
551
|
-
// By default, aggressively recompute every state whatever happens.
|
|
552
|
-
// This has O(n) performance, so we'll override this to a sensible
|
|
553
|
-
// value whenever we feel like we don't have to recompute the states.
|
|
554
|
-
let minInvalidatedStateIndex = 0;
|
|
555
|
-
switch (liftedAction.type) {
|
|
556
|
-
case LOCK_CHANGES: {
|
|
557
|
-
isLocked = liftedAction.status;
|
|
558
|
-
minInvalidatedStateIndex = Infinity;
|
|
559
|
-
break;
|
|
560
|
-
}
|
|
561
|
-
case PAUSE_RECORDING: {
|
|
562
|
-
isPaused = liftedAction.status;
|
|
563
|
-
if (isPaused) {
|
|
564
|
-
// Add a pause action to signal the devtools-user the recording is paused.
|
|
565
|
-
// The corresponding state will be overwritten on each update to always contain
|
|
566
|
-
// the latest state (see Actions.PERFORM_ACTION).
|
|
567
|
-
stagedActionIds = [...stagedActionIds, nextActionId];
|
|
568
|
-
actionsById[nextActionId] = new PerformAction({
|
|
569
|
-
type: '@ngrx/devtools/pause',
|
|
570
|
-
}, +Date.now());
|
|
571
|
-
nextActionId++;
|
|
572
|
-
minInvalidatedStateIndex = stagedActionIds.length - 1;
|
|
573
|
-
computedStates = computedStates.concat(computedStates[computedStates.length - 1]);
|
|
574
|
-
if (currentStateIndex === stagedActionIds.length - 2) {
|
|
575
|
-
currentStateIndex++;
|
|
576
|
-
}
|
|
577
|
-
minInvalidatedStateIndex = Infinity;
|
|
578
|
-
}
|
|
579
|
-
else {
|
|
580
|
-
commitChanges();
|
|
581
|
-
}
|
|
582
|
-
break;
|
|
583
|
-
}
|
|
584
|
-
case RESET: {
|
|
585
|
-
// Get back to the state the store was created with.
|
|
586
|
-
actionsById = { 0: liftAction(INIT_ACTION) };
|
|
587
|
-
nextActionId = 1;
|
|
588
|
-
stagedActionIds = [0];
|
|
589
|
-
skippedActionIds = [];
|
|
590
|
-
committedState = initialCommittedState;
|
|
591
|
-
currentStateIndex = 0;
|
|
592
|
-
computedStates = [];
|
|
593
|
-
break;
|
|
594
|
-
}
|
|
595
|
-
case COMMIT: {
|
|
596
|
-
commitChanges();
|
|
597
|
-
break;
|
|
598
|
-
}
|
|
599
|
-
case ROLLBACK: {
|
|
600
|
-
// Forget about any staged actions.
|
|
601
|
-
// Start again from the last committed state.
|
|
602
|
-
actionsById = { 0: liftAction(INIT_ACTION) };
|
|
603
|
-
nextActionId = 1;
|
|
604
|
-
stagedActionIds = [0];
|
|
605
|
-
skippedActionIds = [];
|
|
606
|
-
currentStateIndex = 0;
|
|
607
|
-
computedStates = [];
|
|
608
|
-
break;
|
|
609
|
-
}
|
|
610
|
-
case TOGGLE_ACTION: {
|
|
611
|
-
// Toggle whether an action with given ID is skipped.
|
|
612
|
-
// Being skipped means it is a no-op during the computation.
|
|
613
|
-
const { id: actionId } = liftedAction;
|
|
614
|
-
const index = skippedActionIds.indexOf(actionId);
|
|
615
|
-
if (index === -1) {
|
|
616
|
-
skippedActionIds = [actionId, ...skippedActionIds];
|
|
617
|
-
}
|
|
618
|
-
else {
|
|
619
|
-
skippedActionIds = skippedActionIds.filter((id) => id !== actionId);
|
|
620
|
-
}
|
|
621
|
-
// Optimization: we know history before this action hasn't changed
|
|
622
|
-
minInvalidatedStateIndex = stagedActionIds.indexOf(actionId);
|
|
623
|
-
break;
|
|
624
|
-
}
|
|
625
|
-
case SET_ACTIONS_ACTIVE: {
|
|
626
|
-
// Toggle whether an action with given ID is skipped.
|
|
627
|
-
// Being skipped means it is a no-op during the computation.
|
|
628
|
-
const { start, end, active } = liftedAction;
|
|
629
|
-
const actionIds = [];
|
|
630
|
-
for (let i = start; i < end; i++)
|
|
631
|
-
actionIds.push(i);
|
|
632
|
-
if (active) {
|
|
633
|
-
skippedActionIds = difference(skippedActionIds, actionIds);
|
|
634
|
-
}
|
|
635
|
-
else {
|
|
636
|
-
skippedActionIds = [...skippedActionIds, ...actionIds];
|
|
637
|
-
}
|
|
638
|
-
// Optimization: we know history before this action hasn't changed
|
|
639
|
-
minInvalidatedStateIndex = stagedActionIds.indexOf(start);
|
|
640
|
-
break;
|
|
641
|
-
}
|
|
642
|
-
case JUMP_TO_STATE: {
|
|
643
|
-
// Without recomputing anything, move the pointer that tell us
|
|
644
|
-
// which state is considered the current one. Useful for sliders.
|
|
645
|
-
currentStateIndex = liftedAction.index;
|
|
646
|
-
// Optimization: we know the history has not changed.
|
|
647
|
-
minInvalidatedStateIndex = Infinity;
|
|
648
|
-
break;
|
|
649
|
-
}
|
|
650
|
-
case JUMP_TO_ACTION: {
|
|
651
|
-
// Jumps to a corresponding state to a specific action.
|
|
652
|
-
// Useful when filtering actions.
|
|
653
|
-
const index = stagedActionIds.indexOf(liftedAction.actionId);
|
|
654
|
-
if (index !== -1)
|
|
655
|
-
currentStateIndex = index;
|
|
656
|
-
minInvalidatedStateIndex = Infinity;
|
|
657
|
-
break;
|
|
658
|
-
}
|
|
659
|
-
case SWEEP: {
|
|
660
|
-
// Forget any actions that are currently being skipped.
|
|
661
|
-
stagedActionIds = difference(stagedActionIds, skippedActionIds);
|
|
662
|
-
skippedActionIds = [];
|
|
663
|
-
currentStateIndex = Math.min(currentStateIndex, stagedActionIds.length - 1);
|
|
664
|
-
break;
|
|
665
|
-
}
|
|
666
|
-
case PERFORM_ACTION: {
|
|
667
|
-
// Ignore action and return state as is if recording is locked
|
|
668
|
-
if (isLocked) {
|
|
669
|
-
return liftedState || initialLiftedState;
|
|
670
|
-
}
|
|
671
|
-
if (isPaused ||
|
|
672
|
-
(liftedState &&
|
|
673
|
-
isActionFiltered(liftedState.computedStates[currentStateIndex], liftedAction, options.predicate, options.actionsSafelist, options.actionsBlocklist))) {
|
|
674
|
-
// If recording is paused or if the action should be ignored, overwrite the last state
|
|
675
|
-
// (corresponds to the pause action) and keep everything else as is.
|
|
676
|
-
// This way, the app gets the new current state while the devtools
|
|
677
|
-
// do not record another action.
|
|
678
|
-
const lastState = computedStates[computedStates.length - 1];
|
|
679
|
-
computedStates = [
|
|
680
|
-
...computedStates.slice(0, -1),
|
|
681
|
-
computeNextEntry(reducer, liftedAction.action, lastState.state, lastState.error, errorHandler),
|
|
682
|
-
];
|
|
683
|
-
minInvalidatedStateIndex = Infinity;
|
|
684
|
-
break;
|
|
685
|
-
}
|
|
686
|
-
// Auto-commit as new actions come in.
|
|
687
|
-
if (options.maxAge && stagedActionIds.length === options.maxAge) {
|
|
688
|
-
commitExcessActions(1);
|
|
689
|
-
}
|
|
690
|
-
if (currentStateIndex === stagedActionIds.length - 1) {
|
|
691
|
-
currentStateIndex++;
|
|
692
|
-
}
|
|
693
|
-
const actionId = nextActionId++;
|
|
694
|
-
// Mutation! This is the hottest path, and we optimize on purpose.
|
|
695
|
-
// It is safe because we set a new key in a cache dictionary.
|
|
696
|
-
actionsById[actionId] = liftedAction;
|
|
697
|
-
stagedActionIds = [...stagedActionIds, actionId];
|
|
698
|
-
// Optimization: we know that only the new action needs computing.
|
|
699
|
-
minInvalidatedStateIndex = stagedActionIds.length - 1;
|
|
700
|
-
break;
|
|
701
|
-
}
|
|
702
|
-
case IMPORT_STATE: {
|
|
703
|
-
// Completely replace everything.
|
|
704
|
-
({
|
|
705
|
-
monitorState,
|
|
706
|
-
actionsById,
|
|
707
|
-
nextActionId,
|
|
708
|
-
stagedActionIds,
|
|
709
|
-
skippedActionIds,
|
|
710
|
-
committedState,
|
|
711
|
-
currentStateIndex,
|
|
712
|
-
computedStates,
|
|
713
|
-
isLocked,
|
|
714
|
-
isPaused,
|
|
715
|
-
} = liftedAction.nextLiftedState);
|
|
716
|
-
break;
|
|
717
|
-
}
|
|
718
|
-
case INIT: {
|
|
719
|
-
// Always recompute states on hot reload and init.
|
|
720
|
-
minInvalidatedStateIndex = 0;
|
|
721
|
-
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
722
|
-
// States must be recomputed before committing excess.
|
|
723
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
724
|
-
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
725
|
-
// Avoid double computation.
|
|
726
|
-
minInvalidatedStateIndex = Infinity;
|
|
727
|
-
}
|
|
728
|
-
break;
|
|
729
|
-
}
|
|
730
|
-
case UPDATE: {
|
|
731
|
-
const stateHasErrors = computedStates.filter((state) => state.error).length > 0;
|
|
732
|
-
if (stateHasErrors) {
|
|
733
|
-
// Recompute all states
|
|
734
|
-
minInvalidatedStateIndex = 0;
|
|
735
|
-
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
736
|
-
// States must be recomputed before committing excess.
|
|
737
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
738
|
-
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
739
|
-
// Avoid double computation.
|
|
740
|
-
minInvalidatedStateIndex = Infinity;
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
else {
|
|
744
|
-
// If not paused/locked, add a new action to signal devtools-user
|
|
745
|
-
// that there was a reducer update.
|
|
746
|
-
if (!isPaused && !isLocked) {
|
|
747
|
-
if (currentStateIndex === stagedActionIds.length - 1) {
|
|
748
|
-
currentStateIndex++;
|
|
749
|
-
}
|
|
750
|
-
// Add a new action to only recompute state
|
|
751
|
-
const actionId = nextActionId++;
|
|
752
|
-
actionsById[actionId] = new PerformAction(liftedAction, +Date.now());
|
|
753
|
-
stagedActionIds = [...stagedActionIds, actionId];
|
|
754
|
-
minInvalidatedStateIndex = stagedActionIds.length - 1;
|
|
755
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
756
|
-
}
|
|
757
|
-
// Recompute state history with latest reducer and update action
|
|
758
|
-
computedStates = computedStates.map((cmp) => (Object.assign(Object.assign({}, cmp), { state: reducer(cmp.state, RECOMPUTE_ACTION) })));
|
|
759
|
-
currentStateIndex = stagedActionIds.length - 1;
|
|
760
|
-
if (options.maxAge && stagedActionIds.length > options.maxAge) {
|
|
761
|
-
commitExcessActions(stagedActionIds.length - options.maxAge);
|
|
762
|
-
}
|
|
763
|
-
// Avoid double computation.
|
|
764
|
-
minInvalidatedStateIndex = Infinity;
|
|
765
|
-
}
|
|
766
|
-
break;
|
|
767
|
-
}
|
|
768
|
-
default: {
|
|
769
|
-
// If the action is not recognized, it's a monitor action.
|
|
770
|
-
// Optimization: a monitor action can't change history.
|
|
771
|
-
minInvalidatedStateIndex = Infinity;
|
|
772
|
-
break;
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
computedStates = recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds, errorHandler, isPaused);
|
|
776
|
-
monitorState = monitorReducer(monitorState, liftedAction);
|
|
777
|
-
return {
|
|
778
|
-
monitorState,
|
|
779
|
-
actionsById,
|
|
780
|
-
nextActionId,
|
|
781
|
-
stagedActionIds,
|
|
782
|
-
skippedActionIds,
|
|
783
|
-
committedState,
|
|
784
|
-
currentStateIndex,
|
|
785
|
-
computedStates,
|
|
786
|
-
isLocked,
|
|
787
|
-
isPaused,
|
|
788
|
-
};
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
class StoreDevtools {
|
|
793
|
-
constructor(dispatcher, actions$, reducers$, extension, scannedActions, errorHandler, initialState, config) {
|
|
794
|
-
const liftedInitialState = liftInitialState(initialState, config.monitor);
|
|
795
|
-
const liftReducer = liftReducerWith(initialState, liftedInitialState, errorHandler, config.monitor, config);
|
|
796
|
-
const liftedAction$ = merge(merge(actions$.asObservable().pipe(skip(1)), extension.actions$).pipe(map(liftAction)), dispatcher, extension.liftedActions$).pipe(observeOn(queueScheduler));
|
|
797
|
-
const liftedReducer$ = reducers$.pipe(map(liftReducer));
|
|
798
|
-
const liftedStateSubject = new ReplaySubject(1);
|
|
799
|
-
const liftedStateSubscription = liftedAction$
|
|
800
|
-
.pipe(withLatestFrom(liftedReducer$), scan(({ state: liftedState }, [action, reducer]) => {
|
|
801
|
-
let reducedLiftedState = reducer(liftedState, action);
|
|
802
|
-
// On full state update
|
|
803
|
-
// If we have actions filters, we must filter completely our lifted state to be sync with the extension
|
|
804
|
-
if (action.type !== PERFORM_ACTION && shouldFilterActions(config)) {
|
|
805
|
-
reducedLiftedState = filterLiftedState(reducedLiftedState, config.predicate, config.actionsSafelist, config.actionsBlocklist);
|
|
806
|
-
}
|
|
807
|
-
// Extension should be sent the sanitized lifted state
|
|
808
|
-
extension.notify(action, reducedLiftedState);
|
|
809
|
-
return { state: reducedLiftedState, action };
|
|
810
|
-
}, { state: liftedInitialState, action: null }))
|
|
811
|
-
.subscribe(({ state, action }) => {
|
|
812
|
-
liftedStateSubject.next(state);
|
|
813
|
-
if (action.type === PERFORM_ACTION) {
|
|
814
|
-
const unliftedAction = action.action;
|
|
815
|
-
scannedActions.next(unliftedAction);
|
|
816
|
-
}
|
|
817
|
-
});
|
|
818
|
-
const extensionStartSubscription = extension.start$.subscribe(() => {
|
|
819
|
-
this.refresh();
|
|
820
|
-
});
|
|
821
|
-
const liftedState$ = liftedStateSubject.asObservable();
|
|
822
|
-
const state$ = liftedState$.pipe(map(unliftState));
|
|
823
|
-
this.extensionStartSubscription = extensionStartSubscription;
|
|
824
|
-
this.stateSubscription = liftedStateSubscription;
|
|
825
|
-
this.dispatcher = dispatcher;
|
|
826
|
-
this.liftedState = liftedState$;
|
|
827
|
-
this.state = state$;
|
|
828
|
-
}
|
|
829
|
-
dispatch(action) {
|
|
830
|
-
this.dispatcher.next(action);
|
|
831
|
-
}
|
|
832
|
-
next(action) {
|
|
833
|
-
this.dispatcher.next(action);
|
|
834
|
-
}
|
|
835
|
-
error(error) { }
|
|
836
|
-
complete() { }
|
|
837
|
-
performAction(action) {
|
|
838
|
-
this.dispatch(new PerformAction(action, +Date.now()));
|
|
839
|
-
}
|
|
840
|
-
refresh() {
|
|
841
|
-
this.dispatch(new Refresh());
|
|
842
|
-
}
|
|
843
|
-
reset() {
|
|
844
|
-
this.dispatch(new Reset(+Date.now()));
|
|
845
|
-
}
|
|
846
|
-
rollback() {
|
|
847
|
-
this.dispatch(new Rollback(+Date.now()));
|
|
848
|
-
}
|
|
849
|
-
commit() {
|
|
850
|
-
this.dispatch(new Commit(+Date.now()));
|
|
851
|
-
}
|
|
852
|
-
sweep() {
|
|
853
|
-
this.dispatch(new Sweep());
|
|
854
|
-
}
|
|
855
|
-
toggleAction(id) {
|
|
856
|
-
this.dispatch(new ToggleAction(id));
|
|
857
|
-
}
|
|
858
|
-
jumpToAction(actionId) {
|
|
859
|
-
this.dispatch(new JumpToAction(actionId));
|
|
860
|
-
}
|
|
861
|
-
jumpToState(index) {
|
|
862
|
-
this.dispatch(new JumpToState(index));
|
|
863
|
-
}
|
|
864
|
-
importState(nextLiftedState) {
|
|
865
|
-
this.dispatch(new ImportState(nextLiftedState));
|
|
866
|
-
}
|
|
867
|
-
lockChanges(status) {
|
|
868
|
-
this.dispatch(new LockChanges(status));
|
|
869
|
-
}
|
|
870
|
-
pauseRecording(status) {
|
|
871
|
-
this.dispatch(new PauseRecording(status));
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
/** @nocollapse */ StoreDevtools.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: StoreDevtools, deps: [{ token: DevtoolsDispatcher }, { token: i2.ActionsSubject }, { token: i2.ReducerObservable }, { token: DevtoolsExtension }, { token: i2.ScannedActionsSubject }, { token: i0.ErrorHandler }, { token: INITIAL_STATE }, { token: STORE_DEVTOOLS_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
875
|
-
/** @nocollapse */ StoreDevtools.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: StoreDevtools });
|
|
876
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: StoreDevtools, decorators: [{
|
|
877
|
-
type: Injectable
|
|
878
|
-
}], ctorParameters: function () {
|
|
879
|
-
return [{ type: DevtoolsDispatcher }, { type: i2.ActionsSubject }, { type: i2.ReducerObservable }, { type: DevtoolsExtension }, { type: i2.ScannedActionsSubject }, { type: i0.ErrorHandler }, { type: undefined, decorators: [{
|
|
880
|
-
type: Inject,
|
|
881
|
-
args: [INITIAL_STATE]
|
|
882
|
-
}] }, { type: StoreDevtoolsConfig, decorators: [{
|
|
883
|
-
type: Inject,
|
|
884
|
-
args: [STORE_DEVTOOLS_CONFIG]
|
|
885
|
-
}] }];
|
|
886
|
-
} });
|
|
887
|
-
|
|
888
|
-
const IS_EXTENSION_OR_MONITOR_PRESENT = new InjectionToken('@ngrx/store-devtools Is Devtools Extension or Monitor Present');
|
|
889
|
-
function createIsExtensionOrMonitorPresent(extension, config) {
|
|
890
|
-
return Boolean(extension) || config.monitor !== noMonitor;
|
|
891
|
-
}
|
|
892
|
-
function createReduxDevtoolsExtension() {
|
|
893
|
-
const extensionKey = '__REDUX_DEVTOOLS_EXTENSION__';
|
|
894
|
-
if (typeof window === 'object' &&
|
|
895
|
-
typeof window[extensionKey] !== 'undefined') {
|
|
896
|
-
return window[extensionKey];
|
|
897
|
-
}
|
|
898
|
-
else {
|
|
899
|
-
return null;
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
/**
|
|
903
|
-
* Provides developer tools and instrumentation for `Store`.
|
|
904
|
-
*
|
|
905
|
-
* @usageNotes
|
|
906
|
-
*
|
|
907
|
-
* ```ts
|
|
908
|
-
* bootstrapApplication(AppComponent, {
|
|
909
|
-
* providers: [
|
|
910
|
-
* provideStoreDevtools({
|
|
911
|
-
* maxAge: 25,
|
|
912
|
-
* logOnly: !isDevMode(),
|
|
913
|
-
* }),
|
|
914
|
-
* ],
|
|
915
|
-
* });
|
|
916
|
-
* ```
|
|
917
|
-
*/
|
|
918
|
-
function provideStoreDevtools(options = {}) {
|
|
919
|
-
return makeEnvironmentProviders([
|
|
920
|
-
DevtoolsExtension,
|
|
921
|
-
DevtoolsDispatcher,
|
|
922
|
-
StoreDevtools,
|
|
923
|
-
{
|
|
924
|
-
provide: INITIAL_OPTIONS,
|
|
925
|
-
useValue: options,
|
|
926
|
-
},
|
|
927
|
-
{
|
|
928
|
-
provide: IS_EXTENSION_OR_MONITOR_PRESENT,
|
|
929
|
-
deps: [REDUX_DEVTOOLS_EXTENSION, STORE_DEVTOOLS_CONFIG],
|
|
930
|
-
useFactory: createIsExtensionOrMonitorPresent,
|
|
931
|
-
},
|
|
932
|
-
{
|
|
933
|
-
provide: REDUX_DEVTOOLS_EXTENSION,
|
|
934
|
-
useFactory: createReduxDevtoolsExtension,
|
|
935
|
-
},
|
|
936
|
-
{
|
|
937
|
-
provide: STORE_DEVTOOLS_CONFIG,
|
|
938
|
-
deps: [INITIAL_OPTIONS],
|
|
939
|
-
useFactory: createConfig,
|
|
940
|
-
},
|
|
941
|
-
{
|
|
942
|
-
provide: StateObservable,
|
|
943
|
-
deps: [StoreDevtools],
|
|
944
|
-
useFactory: createStateObservable,
|
|
945
|
-
},
|
|
946
|
-
{
|
|
947
|
-
provide: ReducerManagerDispatcher,
|
|
948
|
-
useExisting: DevtoolsDispatcher,
|
|
949
|
-
},
|
|
950
|
-
]);
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
function createStateObservable(devtools) {
|
|
954
|
-
return devtools.state;
|
|
955
|
-
}
|
|
956
|
-
class StoreDevtoolsModule {
|
|
957
|
-
static instrument(options = {}) {
|
|
958
|
-
return {
|
|
959
|
-
ngModule: StoreDevtoolsModule,
|
|
960
|
-
providers: [provideStoreDevtools(options)],
|
|
961
|
-
};
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
/** @nocollapse */ StoreDevtoolsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: StoreDevtoolsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
965
|
-
/** @nocollapse */ StoreDevtoolsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.0.0", ngImport: i0, type: StoreDevtoolsModule });
|
|
966
|
-
/** @nocollapse */ StoreDevtoolsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: StoreDevtoolsModule });
|
|
967
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: StoreDevtoolsModule, decorators: [{
|
|
968
|
-
type: NgModule,
|
|
969
|
-
args: [{}]
|
|
970
|
-
}] });
|
|
971
|
-
|
|
972
|
-
/**
|
|
973
|
-
* DO NOT EDIT
|
|
974
|
-
*
|
|
975
|
-
* This file is automatically generated at build
|
|
976
|
-
*/
|
|
977
|
-
|
|
978
|
-
/**
|
|
979
|
-
* Generated bundle index. Do not edit.
|
|
980
|
-
*/
|
|
981
|
-
|
|
982
|
-
export { INITIAL_OPTIONS, RECOMPUTE, REDUX_DEVTOOLS_EXTENSION, StoreDevtools, StoreDevtoolsConfig, StoreDevtoolsModule, provideStoreDevtools };
|
|
983
|
-
//# sourceMappingURL=ngrx-store-devtools.mjs.map
|
|
984
|
-
//# sourceMappingURL=ngrx-store-devtools.mjs.map
|