@ngrx/store-devtools
Advanced tools
Comparing version 3.2.4 to 4.0.0
@@ -7,18 +7,30 @@ (function (global, factory) { | ||
var ActionTypes = { | ||
PERFORM_ACTION: 'PERFORM_ACTION', | ||
RESET: 'RESET', | ||
ROLLBACK: 'ROLLBACK', | ||
COMMIT: 'COMMIT', | ||
SWEEP: 'SWEEP', | ||
TOGGLE_ACTION: 'TOGGLE_ACTION', | ||
SET_ACTIONS_ACTIVE: 'SET_ACTIONS_ACTIVE', | ||
JUMP_TO_STATE: 'JUMP_TO_STATE', | ||
IMPORT_STATE: 'IMPORT_STATE' | ||
}; | ||
/** | ||
* Action creators to change the History state. | ||
*/ | ||
var StoreDevtoolActions = { | ||
performAction: function (action) { | ||
var __extends = (undefined && undefined.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var PERFORM_ACTION = 'PERFORM_ACTION'; | ||
var RESET = 'RESET'; | ||
var ROLLBACK = 'ROLLBACK'; | ||
var COMMIT = 'COMMIT'; | ||
var SWEEP = 'SWEEP'; | ||
var TOGGLE_ACTION = 'TOGGLE_ACTION'; | ||
var SET_ACTIONS_ACTIVE = 'SET_ACTIONS_ACTIVE'; | ||
var JUMP_TO_STATE = 'JUMP_TO_STATE'; | ||
var IMPORT_STATE = 'IMPORT_STATE'; | ||
var PerformAction = (function () { | ||
/** | ||
* @param {?} action | ||
* @param {?=} timestamp | ||
*/ | ||
function PerformAction(action, timestamp) { | ||
this.action = action; | ||
this.timestamp = timestamp; | ||
this.type = PERFORM_ACTION; | ||
if (typeof action.type === 'undefined') { | ||
@@ -28,31 +40,76 @@ throw new Error('Actions may not have an undefined "type" property. ' + | ||
} | ||
return { type: ActionTypes.PERFORM_ACTION, action: action, timestamp: Date.now() }; | ||
}, | ||
reset: function () { | ||
return { type: ActionTypes.RESET, timestamp: Date.now() }; | ||
}, | ||
rollback: function () { | ||
return { type: ActionTypes.ROLLBACK, timestamp: Date.now() }; | ||
}, | ||
commit: function () { | ||
return { type: ActionTypes.COMMIT, timestamp: Date.now() }; | ||
}, | ||
sweep: function () { | ||
return { type: ActionTypes.SWEEP }; | ||
}, | ||
toggleAction: function (id) { | ||
return { type: ActionTypes.TOGGLE_ACTION, id: id }; | ||
}, | ||
setActionsActive: function (start, end, active) { | ||
if (active === void 0) { active = true; } | ||
return { type: ActionTypes.SET_ACTIONS_ACTIVE, start: start, end: end, active: active }; | ||
}, | ||
jumpToState: function (index) { | ||
return { type: ActionTypes.JUMP_TO_STATE, index: index }; | ||
}, | ||
importState: function (nextLiftedState) { | ||
return { type: ActionTypes.IMPORT_STATE, nextLiftedState: nextLiftedState }; | ||
} | ||
}; | ||
return PerformAction; | ||
}()); | ||
var Reset = (function () { | ||
/** | ||
* @param {?=} timestamp | ||
*/ | ||
function Reset(timestamp) { | ||
this.timestamp = timestamp; | ||
this.type = RESET; | ||
} | ||
return Reset; | ||
}()); | ||
var Rollback = (function () { | ||
/** | ||
* @param {?=} timestamp | ||
*/ | ||
function Rollback(timestamp) { | ||
this.timestamp = timestamp; | ||
this.type = ROLLBACK; | ||
} | ||
return Rollback; | ||
}()); | ||
var Commit = (function () { | ||
/** | ||
* @param {?=} timestamp | ||
*/ | ||
function Commit(timestamp) { | ||
this.timestamp = timestamp; | ||
this.type = COMMIT; | ||
} | ||
return Commit; | ||
}()); | ||
var Sweep = (function () { | ||
function Sweep() { | ||
this.type = SWEEP; | ||
} | ||
return Sweep; | ||
}()); | ||
var ToggleAction = (function () { | ||
/** | ||
* @param {?} id | ||
*/ | ||
function ToggleAction(id) { | ||
this.id = id; | ||
this.type = TOGGLE_ACTION; | ||
} | ||
return ToggleAction; | ||
}()); | ||
var JumpToState = (function () { | ||
/** | ||
* @param {?} index | ||
*/ | ||
function JumpToState(index) { | ||
this.index = index; | ||
this.type = JUMP_TO_STATE; | ||
} | ||
return JumpToState; | ||
}()); | ||
var ImportState = (function () { | ||
/** | ||
* @param {?} nextLiftedState | ||
*/ | ||
function ImportState(nextLiftedState) { | ||
this.nextLiftedState = nextLiftedState; | ||
this.type = IMPORT_STATE; | ||
} | ||
return ImportState; | ||
}()); | ||
/** | ||
* @param {?} first | ||
* @param {?} second | ||
* @return {?} | ||
*/ | ||
function difference(first, second) { | ||
@@ -63,2 +120,4 @@ return first.filter(function (item) { return second.indexOf(item) < 0; }); | ||
* Provides an app's view into the state of the lifted store. | ||
* @param {?} liftedState | ||
* @return {?} | ||
*/ | ||
@@ -70,9 +129,19 @@ function unliftState(liftedState) { | ||
} | ||
/** | ||
* Lifts an app's action into an action on the lifted store. | ||
*/ | ||
* @param {?} liftedState | ||
* @return {?} | ||
*/ | ||
/** | ||
* Lifts an app's action into an action on the lifted store. | ||
* @param {?} action | ||
* @return {?} | ||
*/ | ||
function liftAction(action) { | ||
return StoreDevtoolActions.performAction(action); | ||
return new PerformAction(action); | ||
} | ||
/** | ||
* @param {?} input$ | ||
* @param {?} operators | ||
* @return {?} | ||
*/ | ||
function applyOperators(input$, operators) { | ||
@@ -84,3 +153,2 @@ return operators.reduce(function (source$, _a) { | ||
} | ||
var ExtensionActionTypes = { | ||
@@ -90,6 +158,9 @@ START: 'START', | ||
STOP: 'STOP', | ||
ACTION: 'ACTION' | ||
ACTION: 'ACTION', | ||
}; | ||
var REDUX_DEVTOOLS_EXTENSION = new _angular_core.OpaqueToken('Redux Devtools Extension'); | ||
var REDUX_DEVTOOLS_EXTENSION = new _angular_core.InjectionToken('Redux Devtools Extension'); | ||
var DevtoolsExtension = (function () { | ||
/** | ||
* @param {?} devtoolsExtension | ||
*/ | ||
function DevtoolsExtension(devtoolsExtension) { | ||
@@ -100,2 +171,7 @@ this.instanceId = "ngrx-store-" + Date.now(); | ||
} | ||
/** | ||
* @param {?} action | ||
* @param {?} state | ||
* @return {?} | ||
*/ | ||
DevtoolsExtension.prototype.notify = function (action, state) { | ||
@@ -105,4 +181,7 @@ if (!this.devtoolsExtension) { | ||
} | ||
this.devtoolsExtension.send(null, state, false, this.instanceId); | ||
this.devtoolsExtension.send(null, state, { serialize: false }, this.instanceId); | ||
}; | ||
/** | ||
* @return {?} | ||
*/ | ||
DevtoolsExtension.prototype.createChangesObservable = function () { | ||
@@ -114,3 +193,5 @@ var _this = this; | ||
return new rxjs_Observable.Observable(function (subscriber) { | ||
var connection = _this.devtoolsExtension.connect({ instanceId: _this.instanceId }); | ||
var /** @type {?} */ connection = _this.devtoolsExtension.connect({ | ||
instanceId: _this.instanceId, | ||
}); | ||
connection.subscribe(function (change) { return subscriber.next(change); }); | ||
@@ -120,22 +201,25 @@ return connection.unsubscribe; | ||
}; | ||
/** | ||
* @return {?} | ||
*/ | ||
DevtoolsExtension.prototype.createActionStreams = function () { | ||
var _this = this; | ||
// Listens to all changes based on our instanceId | ||
var changes$ = rxjs_operator_share.share.call(this.createChangesObservable()); | ||
var /** @type {?} */ changes$ = rxjs_operator_share.share.call(this.createChangesObservable()); | ||
// Listen for the start action | ||
var start$ = rxjs_operator_filter.filter.call(changes$, function (change) { return change.type === ExtensionActionTypes.START; }); | ||
var /** @type {?} */ start$ = rxjs_operator_filter.filter.call(changes$, function (change) { return change.type === ExtensionActionTypes.START; }); | ||
// Listen for the stop action | ||
var stop$ = rxjs_operator_filter.filter.call(changes$, function (change) { return change.type === ExtensionActionTypes.STOP; }); | ||
var /** @type {?} */ stop$ = rxjs_operator_filter.filter.call(changes$, function (change) { return change.type === ExtensionActionTypes.STOP; }); | ||
// Listen for lifted actions | ||
var liftedActions$ = applyOperators(changes$, [ | ||
var /** @type {?} */ liftedActions$ = applyOperators(changes$, [ | ||
[rxjs_operator_filter.filter, function (change) { return change.type === ExtensionActionTypes.DISPATCH; }], | ||
[rxjs_operator_map.map, function (change) { return _this.unwrapAction(change.payload); }] | ||
[rxjs_operator_map.map, function (change) { return _this.unwrapAction(change.payload); }], | ||
]); | ||
// Listen for unlifted actions | ||
var actions$ = applyOperators(changes$, [ | ||
var /** @type {?} */ actions$ = applyOperators(changes$, [ | ||
[rxjs_operator_filter.filter, function (change) { return change.type === ExtensionActionTypes.ACTION; }], | ||
[rxjs_operator_map.map, function (change) { return _this.unwrapAction(change.payload); }] | ||
[rxjs_operator_map.map, function (change) { return _this.unwrapAction(change.payload); }], | ||
]); | ||
var actionsUntilStop$ = rxjs_operator_takeUntil.takeUntil.call(actions$, stop$); | ||
var liftedUntilStop$ = rxjs_operator_takeUntil.takeUntil.call(liftedActions$, stop$); | ||
var /** @type {?} */ actionsUntilStop$ = rxjs_operator_takeUntil.takeUntil.call(actions$, stop$); | ||
var /** @type {?} */ liftedUntilStop$ = rxjs_operator_takeUntil.takeUntil.call(liftedActions$, stop$); | ||
// Only take the action sources between the start/stop events | ||
@@ -145,2 +229,6 @@ this.actions$ = rxjs_operator_switchMap.switchMap.call(start$, function () { return actionsUntilStop$; }); | ||
}; | ||
/** | ||
* @param {?} action | ||
* @return {?} | ||
*/ | ||
DevtoolsExtension.prototype.unwrapAction = function (action) { | ||
@@ -154,11 +242,17 @@ return typeof action === 'string' ? eval("(" + action + ")") : action; | ||
]; | ||
/** @nocollapse */ | ||
/** | ||
* @nocollapse | ||
*/ | ||
DevtoolsExtension.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [REDUX_DEVTOOLS_EXTENSION,] },] }, | ||
]; }; | ||
var INIT_ACTION = { type: _ngrx_store.Dispatcher.INIT }; | ||
var INIT_ACTION = { type: _ngrx_store.INIT }; | ||
/** | ||
* Computes the next entry in the log by applying an action. | ||
*/ | ||
* Computes the next entry in the log by applying an action. | ||
* @param {?} reducer | ||
* @param {?} action | ||
* @param {?} state | ||
* @param {?} error | ||
* @return {?} | ||
*/ | ||
function computeNextEntry(reducer, action, state, error) { | ||
@@ -168,7 +262,7 @@ if (error) { | ||
state: state, | ||
error: 'Interrupted by an error up the chain' | ||
error: 'Interrupted by an error up the chain', | ||
}; | ||
} | ||
var nextState = state; | ||
var nextError; | ||
var /** @type {?} */ nextState = state; | ||
var /** @type {?} */ nextError; | ||
try { | ||
@@ -183,8 +277,16 @@ nextState = reducer(state, action); | ||
state: nextState, | ||
error: nextError | ||
error: nextError, | ||
}; | ||
} | ||
/** | ||
* Runs the reducer on invalidated actions to get a fresh computation log. | ||
*/ | ||
* Runs the reducer on invalidated actions to get a fresh computation log. | ||
* @param {?} computedStates | ||
* @param {?} minInvalidatedStateIndex | ||
* @param {?} reducer | ||
* @param {?} committedState | ||
* @param {?} actionsById | ||
* @param {?} stagedActionIds | ||
* @param {?} skippedActionIds | ||
* @return {?} | ||
*/ | ||
function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds) { | ||
@@ -197,13 +299,13 @@ // Optimization: exit early and return the same reference | ||
} | ||
var nextComputedStates = computedStates.slice(0, minInvalidatedStateIndex); | ||
for (var i = minInvalidatedStateIndex; i < stagedActionIds.length; i++) { | ||
var actionId = stagedActionIds[i]; | ||
var action = actionsById[actionId].action; | ||
var previousEntry = nextComputedStates[i - 1]; | ||
var previousState = previousEntry ? previousEntry.state : committedState; | ||
var previousError = previousEntry ? previousEntry.error : undefined; | ||
var shouldSkip = skippedActionIds.indexOf(actionId) > -1; | ||
var entry = shouldSkip ? | ||
previousEntry : | ||
computeNextEntry(reducer, action, previousState, previousError); | ||
var /** @type {?} */ nextComputedStates = computedStates.slice(0, minInvalidatedStateIndex); | ||
for (var /** @type {?} */ i = minInvalidatedStateIndex; i < stagedActionIds.length; i++) { | ||
var /** @type {?} */ actionId = stagedActionIds[i]; | ||
var /** @type {?} */ action = actionsById[actionId].action; | ||
var /** @type {?} */ previousEntry = nextComputedStates[i - 1]; | ||
var /** @type {?} */ previousState = previousEntry ? previousEntry.state : committedState; | ||
var /** @type {?} */ previousError = previousEntry ? previousEntry.error : undefined; | ||
var /** @type {?} */ shouldSkip = skippedActionIds.indexOf(actionId) > -1; | ||
var /** @type {?} */ entry = shouldSkip | ||
? previousEntry | ||
: computeNextEntry(reducer, action, previousState, previousError); | ||
nextComputedStates.push(entry); | ||
@@ -213,2 +315,7 @@ } | ||
} | ||
/** | ||
* @param {?=} initialCommittedState | ||
* @param {?=} monitorReducer | ||
* @return {?} | ||
*/ | ||
function liftInitialState(initialCommittedState, monitorReducer) { | ||
@@ -223,8 +330,13 @@ return { | ||
currentStateIndex: 0, | ||
computedStates: [] | ||
computedStates: [], | ||
}; | ||
} | ||
/** | ||
* Creates a history state reducer from an app's reducer. | ||
*/ | ||
* Creates a history state reducer from an app's reducer. | ||
* @param {?} initialCommittedState | ||
* @param {?} initialLiftedState | ||
* @param {?=} monitorReducer | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
function liftReducerWith(initialCommittedState, initialLiftedState, monitorReducer, options) { | ||
@@ -241,7 +353,11 @@ if (options === void 0) { options = {}; } | ||
} | ||
/** | ||
* @param {?} n | ||
* @return {?} | ||
*/ | ||
function commitExcessActions(n) { | ||
// Auto-commits n-number of excess actions. | ||
var excess = n; | ||
var idsToDelete = stagedActionIds.slice(1, excess + 1); | ||
for (var i = 0; i < idsToDelete.length; i++) { | ||
var /** @type {?} */ excess = n; | ||
var /** @type {?} */ idsToDelete = stagedActionIds.slice(1, excess + 1); | ||
for (var /** @type {?} */ i = 0; i < idsToDelete.length; i++) { | ||
if (computedStates[i + 1].error) { | ||
@@ -261,5 +377,4 @@ // Stop if error is found. Commit actions up to error. | ||
computedStates = computedStates.slice(excess); | ||
currentStateIndex = currentStateIndex > excess | ||
? currentStateIndex - excess | ||
: 0; | ||
currentStateIndex = | ||
currentStateIndex > excess ? currentStateIndex - excess : 0; | ||
} | ||
@@ -269,5 +384,5 @@ // By default, agressively recompute every state whatever happens. | ||
// value whenever we feel like we don't have to recompute the states. | ||
var minInvalidatedStateIndex = 0; | ||
var /** @type {?} */ minInvalidatedStateIndex = 0; | ||
switch (liftedAction.type) { | ||
case ActionTypes.RESET: { | ||
case RESET: { | ||
// Get back to the state the store was created with. | ||
@@ -283,3 +398,3 @@ actionsById = { 0: liftAction(INIT_ACTION) }; | ||
} | ||
case ActionTypes.COMMIT: { | ||
case COMMIT: { | ||
// Consider the last committed state the new starting point. | ||
@@ -296,3 +411,3 @@ // Squash any staged actions into a single committed state. | ||
} | ||
case ActionTypes.ROLLBACK: { | ||
case ROLLBACK: { | ||
// Forget about any staged actions. | ||
@@ -308,7 +423,7 @@ // Start again from the last committed state. | ||
} | ||
case ActionTypes.TOGGLE_ACTION: { | ||
case TOGGLE_ACTION: { | ||
// Toggle whether an action with given ID is skipped. | ||
// Being skipped means it is a no-op during the computation. | ||
var actionId_1 = liftedAction.id; | ||
var index = skippedActionIds.indexOf(actionId_1); | ||
var /** @type {?} */ index = skippedActionIds.indexOf(actionId_1); | ||
if (index === -1) { | ||
@@ -324,8 +439,8 @@ skippedActionIds = [actionId_1].concat(skippedActionIds); | ||
} | ||
case ActionTypes.SET_ACTIONS_ACTIVE: { | ||
case SET_ACTIONS_ACTIVE: { | ||
// Toggle whether an action with given ID is skipped. | ||
// Being skipped means it is a no-op during the computation. | ||
var start = liftedAction.start, end = liftedAction.end, active = liftedAction.active; | ||
var actionIds = []; | ||
for (var i = start; i < end; i++) | ||
var /** @type {?} */ actionIds = []; | ||
for (var /** @type {?} */ i = start; i < end; i++) | ||
actionIds.push(i); | ||
@@ -342,3 +457,3 @@ if (active) { | ||
} | ||
case ActionTypes.JUMP_TO_STATE: { | ||
case JUMP_TO_STATE: { | ||
// Without recomputing anything, move the pointer that tell us | ||
@@ -351,3 +466,3 @@ // which state is considered the current one. Useful for sliders. | ||
} | ||
case ActionTypes.SWEEP: { | ||
case SWEEP: { | ||
// Forget any actions that are currently being skipped. | ||
@@ -359,3 +474,3 @@ stagedActionIds = difference(stagedActionIds, skippedActionIds); | ||
} | ||
case ActionTypes.PERFORM_ACTION: { | ||
case PERFORM_ACTION: { | ||
// Auto-commit as new actions come in. | ||
@@ -368,3 +483,3 @@ if (options.maxAge && stagedActionIds.length === options.maxAge) { | ||
} | ||
var actionId = nextActionId++; | ||
var /** @type {?} */ actionId = nextActionId++; | ||
// Mutation! This is the hottest path, and we optimize on purpose. | ||
@@ -378,3 +493,3 @@ // It is safe because we set a new key in a cache dictionary. | ||
} | ||
case ActionTypes.IMPORT_STATE: { | ||
case IMPORT_STATE: { | ||
// Completely replace everything. | ||
@@ -384,4 +499,4 @@ (_b = liftedAction.nextLiftedState, monitorState = _b.monitorState, actionsById = _b.actionsById, nextActionId = _b.nextActionId, stagedActionIds = _b.stagedActionIds, skippedActionIds = _b.skippedActionIds, committedState = _b.committedState, currentStateIndex = _b.currentStateIndex, computedStates = _b.computedStates); | ||
} | ||
case _ngrx_store.Reducer.REPLACE: | ||
case _ngrx_store.Dispatcher.INIT: { | ||
case _ngrx_store.UPDATE: | ||
case _ngrx_store.INIT: { | ||
// Always recompute states on hot reload and init. | ||
@@ -415,3 +530,3 @@ minInvalidatedStateIndex = 0; | ||
currentStateIndex: currentStateIndex, | ||
computedStates: computedStates | ||
computedStates: computedStates, | ||
}; | ||
@@ -421,16 +536,9 @@ var _b; | ||
} | ||
var STORE_DEVTOOLS_CONFIG = new _angular_core.OpaqueToken('@ngrx/devtools Options'); | ||
var INITIAL_OPTIONS = new _angular_core.OpaqueToken('@ngrx/devtools Initial Config'); | ||
var __extends = (undefined && undefined.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var StoreDevtoolsConfig = (function () { | ||
function StoreDevtoolsConfig() { | ||
} | ||
return StoreDevtoolsConfig; | ||
}()); | ||
var STORE_DEVTOOLS_CONFIG = new _angular_core.InjectionToken('@ngrx/devtools Options'); | ||
var INITIAL_OPTIONS = new _angular_core.InjectionToken('@ngrx/devtools Initial Config'); | ||
var DevtoolsDispatcher = (function (_super) { | ||
@@ -442,15 +550,24 @@ __extends(DevtoolsDispatcher, _super); | ||
return DevtoolsDispatcher; | ||
}(_ngrx_store.Dispatcher)); | ||
}(_ngrx_store.ActionsSubject)); | ||
DevtoolsDispatcher.decorators = [ | ||
{ type: _angular_core.Injectable }, | ||
]; | ||
/** @nocollapse */ | ||
/** | ||
* @nocollapse | ||
*/ | ||
DevtoolsDispatcher.ctorParameters = function () { return []; }; | ||
var StoreDevtools = (function () { | ||
function StoreDevtools(dispatcher, actions$, reducers$, extension, initialState, config) { | ||
/** | ||
* @param {?} dispatcher | ||
* @param {?} actions$ | ||
* @param {?} reducers$ | ||
* @param {?} extension | ||
* @param {?} scannedActions | ||
* @param {?} initialState | ||
* @param {?} config | ||
*/ | ||
function StoreDevtools(dispatcher, actions$, reducers$, extension, scannedActions, initialState, config) { | ||
var liftedInitialState = liftInitialState(initialState, config.monitor); | ||
var liftReducer = liftReducerWith(initialState, liftedInitialState, config.monitor, { | ||
maxAge: config.maxAge | ||
}); | ||
var liftedAction$ = applyOperators(actions$, [ | ||
var liftReducer = liftReducerWith(initialState, liftedInitialState, config.monitor, config.maxAge ? { maxAge: config.maxAge } : {}); | ||
var liftedAction$ = applyOperators(actions$.asObservable(), [ | ||
[rxjs_operator_skip.skip, 1], | ||
@@ -460,3 +577,3 @@ [rxjs_operator_merge.merge, extension.actions$], | ||
[rxjs_operator_merge.merge, dispatcher, extension.liftedActions$], | ||
[rxjs_operator_observeOn.observeOn, rxjs_scheduler_queue.queue] | ||
[rxjs_operator_observeOn.observeOn, rxjs_scheduler_queue.queue], | ||
]); | ||
@@ -467,9 +584,21 @@ var liftedReducer$ = rxjs_operator_map.map.call(reducers$, liftReducer); | ||
[rxjs_operator_withLatestFrom.withLatestFrom, liftedReducer$], | ||
[rxjs_operator_scan.scan, function (liftedState, _a) { | ||
var action = _a[0], reducer = _a[1]; | ||
var nextState = reducer(liftedState, action); | ||
extension.notify(action, nextState); | ||
return nextState; | ||
}, liftedInitialState] | ||
]).subscribe(liftedStateSubject); | ||
[ | ||
rxjs_operator_scan.scan, | ||
function (_a, _b) { | ||
var liftedState = _a.state; | ||
var action = _b[0], reducer = _b[1]; | ||
var state = reducer(liftedState, action); | ||
extension.notify(action, state); | ||
return { state: state, action: action }; | ||
}, | ||
{ state: liftedInitialState, action: null }, | ||
], | ||
]).subscribe(function (_a) { | ||
var state = _a.state, action = _a.action; | ||
liftedStateSubject.next(state); | ||
if (action.type === PERFORM_ACTION) { | ||
var unlifedAction = action.action; | ||
scannedActions.next(unlifedAction); | ||
} | ||
}); | ||
var liftedState$ = liftedStateSubject.asObservable(); | ||
@@ -482,33 +611,76 @@ var state$ = rxjs_operator_map.map.call(liftedState$, unliftState); | ||
} | ||
/** | ||
* @param {?} action | ||
* @return {?} | ||
*/ | ||
StoreDevtools.prototype.dispatch = function (action) { | ||
this.dispatcher.dispatch(action); | ||
this.dispatcher.next(action); | ||
}; | ||
/** | ||
* @param {?} action | ||
* @return {?} | ||
*/ | ||
StoreDevtools.prototype.next = function (action) { | ||
this.dispatcher.dispatch(action); | ||
this.dispatcher.next(action); | ||
}; | ||
/** | ||
* @param {?} error | ||
* @return {?} | ||
*/ | ||
StoreDevtools.prototype.error = function (error) { }; | ||
/** | ||
* @return {?} | ||
*/ | ||
StoreDevtools.prototype.complete = function () { }; | ||
/** | ||
* @param {?} action | ||
* @return {?} | ||
*/ | ||
StoreDevtools.prototype.performAction = function (action) { | ||
this.dispatch(StoreDevtoolActions.performAction(action)); | ||
this.dispatch(new PerformAction(action)); | ||
}; | ||
/** | ||
* @return {?} | ||
*/ | ||
StoreDevtools.prototype.reset = function () { | ||
this.dispatch(StoreDevtoolActions.reset()); | ||
this.dispatch(new Reset()); | ||
}; | ||
/** | ||
* @return {?} | ||
*/ | ||
StoreDevtools.prototype.rollback = function () { | ||
this.dispatch(StoreDevtoolActions.rollback()); | ||
this.dispatch(new Rollback()); | ||
}; | ||
/** | ||
* @return {?} | ||
*/ | ||
StoreDevtools.prototype.commit = function () { | ||
this.dispatch(StoreDevtoolActions.commit()); | ||
this.dispatch(new Commit()); | ||
}; | ||
/** | ||
* @return {?} | ||
*/ | ||
StoreDevtools.prototype.sweep = function () { | ||
this.dispatch(StoreDevtoolActions.sweep()); | ||
this.dispatch(new Sweep()); | ||
}; | ||
/** | ||
* @param {?} id | ||
* @return {?} | ||
*/ | ||
StoreDevtools.prototype.toggleAction = function (id) { | ||
this.dispatch(StoreDevtoolActions.toggleAction(id)); | ||
this.dispatch(new ToggleAction(id)); | ||
}; | ||
/** | ||
* @param {?} index | ||
* @return {?} | ||
*/ | ||
StoreDevtools.prototype.jumpToState = function (index) { | ||
this.dispatch(StoreDevtoolActions.jumpToState(index)); | ||
this.dispatch(new JumpToState(index)); | ||
}; | ||
/** | ||
* @param {?} nextLiftedState | ||
* @return {?} | ||
*/ | ||
StoreDevtools.prototype.importState = function (nextLiftedState) { | ||
this.dispatch(StoreDevtoolActions.importState(nextLiftedState)); | ||
this.dispatch(new ImportState(nextLiftedState)); | ||
}; | ||
@@ -520,21 +692,32 @@ return StoreDevtools; | ||
]; | ||
/** @nocollapse */ | ||
/** | ||
* @nocollapse | ||
*/ | ||
StoreDevtools.ctorParameters = function () { return [ | ||
{ type: DevtoolsDispatcher, }, | ||
{ type: _ngrx_store.Dispatcher, }, | ||
{ type: _ngrx_store.Reducer, }, | ||
{ type: _ngrx_store.ActionsSubject, }, | ||
{ type: _ngrx_store.ReducerObservable, }, | ||
{ type: DevtoolsExtension, }, | ||
{ type: _ngrx_store.ScannedActionsSubject, }, | ||
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_ngrx_store.INITIAL_STATE,] },] }, | ||
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [STORE_DEVTOOLS_CONFIG,] },] }, | ||
{ type: StoreDevtoolsConfig, decorators: [{ type: _angular_core.Inject, args: [STORE_DEVTOOLS_CONFIG,] },] }, | ||
]; }; | ||
function _createReduxDevtoolsExtension() { | ||
var legacyExtensionKey = 'devToolsExtension'; | ||
var extensionKey = '__REDUX_DEVTOOLS_EXTENSION__'; | ||
if (typeof window === 'object' && typeof window[legacyExtensionKey] !== 'undefined') { | ||
return window[legacyExtensionKey]; | ||
var IS_EXTENSION_OR_MONITOR_PRESENT = new _angular_core.InjectionToken('Is Devtools Extension or Monitor Present'); | ||
/** | ||
* @param {?} extension | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
function createIsExtensionOrMonitorPresent(extension, config) { | ||
return Boolean(extension) || config.monitor !== noMonitor; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
function createReduxDevtoolsExtension() { | ||
var /** @type {?} */ extensionKey = '__REDUX_DEVTOOLS_EXTENSION__'; | ||
if (typeof window === 'object' && | ||
typeof ((window))[extensionKey] !== 'undefined') { | ||
return ((window))[extensionKey]; | ||
} | ||
else if (typeof window === 'object' && typeof window[extensionKey] !== 'undefined') { | ||
return window[extensionKey]; | ||
} | ||
else { | ||
@@ -544,40 +727,30 @@ return null; | ||
} | ||
function _createState(devtools) { | ||
/** | ||
* @param {?} devtools | ||
* @return {?} | ||
*/ | ||
function createStateObservable(devtools) { | ||
return devtools.state; | ||
} | ||
function _createReducer(dispatcher, reducer) { | ||
return new _ngrx_store.Reducer(dispatcher, reducer); | ||
} | ||
function _createStateIfExtension(extension, injector, initialState) { | ||
if (!!extension) { | ||
var devtools = injector.get(StoreDevtools); | ||
return _createState(devtools); | ||
} | ||
else { | ||
var dispatcher = injector.get(_ngrx_store.Dispatcher); | ||
var reducer = injector.get(_ngrx_store.Reducer); | ||
return new _ngrx_store.State(initialState, dispatcher, reducer); | ||
} | ||
} | ||
function _createReducerIfExtension(extension, injector, reducer) { | ||
if (!!extension) { | ||
var devtoolsDispatcher = injector.get(DevtoolsDispatcher); | ||
return _createReducer(devtoolsDispatcher, reducer); | ||
} | ||
else { | ||
var dispatcher = injector.get(_ngrx_store.Dispatcher); | ||
return new _ngrx_store.Reducer(dispatcher, reducer); | ||
} | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
function noMonitor() { | ||
return null; | ||
} | ||
function _createOptions(_options) { | ||
var DEFAULT_OPTIONS = { monitor: noMonitor }; | ||
var options = typeof _options === 'function' ? _options() : _options; | ||
options = Object.assign({}, DEFAULT_OPTIONS, options); | ||
if (options.maxAge && options.maxAge < 2) { | ||
throw new Error("Devtools 'maxAge' cannot be less than 2, got " + options.maxAge); | ||
/** | ||
* @param {?} _options | ||
* @return {?} | ||
*/ | ||
function createConfig(_options) { | ||
var /** @type {?} */ DEFAULT_OPTIONS = { | ||
maxAge: false, | ||
monitor: noMonitor, | ||
}; | ||
var /** @type {?} */ options = typeof _options === 'function' ? _options() : _options; | ||
var /** @type {?} */ config = Object.assign({}, DEFAULT_OPTIONS, options); | ||
if (config.maxAge && config.maxAge < 2) { | ||
throw new Error("Devtools 'maxAge' cannot be less than 2, got " + config.maxAge); | ||
} | ||
return options; | ||
return config; | ||
} | ||
@@ -587,20 +760,26 @@ var StoreDevtoolsModule = (function () { | ||
} | ||
StoreDevtoolsModule.instrumentStore = function (_options) { | ||
if (_options === void 0) { _options = {}; } | ||
/** | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
StoreDevtoolsModule.instrument = function (options) { | ||
if (options === void 0) { options = {}; } | ||
return { | ||
ngModule: StoreDevtoolsModule, | ||
providers: [ | ||
DevtoolsExtension, | ||
DevtoolsDispatcher, | ||
StoreDevtools, | ||
{ | ||
provide: _ngrx_store.State, | ||
deps: [StoreDevtools], | ||
useFactory: _createState | ||
provide: INITIAL_OPTIONS, | ||
useValue: options, | ||
}, | ||
{ | ||
provide: INITIAL_OPTIONS, | ||
useValue: _options | ||
provide: IS_EXTENSION_OR_MONITOR_PRESENT, | ||
deps: [REDUX_DEVTOOLS_EXTENSION, STORE_DEVTOOLS_CONFIG], | ||
useFactory: createIsExtensionOrMonitorPresent, | ||
}, | ||
{ | ||
provide: _ngrx_store.Reducer, | ||
deps: [DevtoolsDispatcher, _ngrx_store.INITIAL_REDUCER], | ||
useFactory: _createReducer | ||
provide: REDUX_DEVTOOLS_EXTENSION, | ||
useFactory: createReduxDevtoolsExtension, | ||
}, | ||
@@ -610,32 +789,14 @@ { | ||
deps: [INITIAL_OPTIONS], | ||
useFactory: _createOptions | ||
} | ||
] | ||
}; | ||
}; | ||
StoreDevtoolsModule.instrumentOnlyWithExtension = function (_options) { | ||
if (_options === void 0) { _options = {}; } | ||
return { | ||
ngModule: StoreDevtoolsModule, | ||
providers: [ | ||
{ | ||
provide: _ngrx_store.State, | ||
deps: [REDUX_DEVTOOLS_EXTENSION, _angular_core.Injector, _ngrx_store.INITIAL_STATE], | ||
useFactory: _createStateIfExtension | ||
useFactory: createConfig, | ||
}, | ||
{ | ||
provide: _ngrx_store.Reducer, | ||
deps: [REDUX_DEVTOOLS_EXTENSION, _angular_core.Injector, _ngrx_store.INITIAL_REDUCER], | ||
useFactory: _createReducerIfExtension | ||
provide: _ngrx_store.StateObservable, | ||
deps: [StoreDevtools], | ||
useFactory: createStateObservable, | ||
}, | ||
{ | ||
provide: INITIAL_OPTIONS, | ||
useValue: _options | ||
provide: _ngrx_store.ReducerManagerDispatcher, | ||
useExisting: DevtoolsDispatcher, | ||
}, | ||
{ | ||
provide: STORE_DEVTOOLS_CONFIG, | ||
deps: [INITIAL_OPTIONS], | ||
useFactory: _createOptions | ||
} | ||
] | ||
], | ||
}; | ||
@@ -646,18 +807,7 @@ }; | ||
StoreDevtoolsModule.decorators = [ | ||
{ type: _angular_core.NgModule, args: [{ | ||
imports: [ | ||
_ngrx_store.StoreModule | ||
], | ||
providers: [ | ||
DevtoolsExtension, | ||
DevtoolsDispatcher, | ||
StoreDevtools, | ||
{ | ||
provide: REDUX_DEVTOOLS_EXTENSION, | ||
useFactory: _createReduxDevtoolsExtension | ||
} | ||
] | ||
},] }, | ||
{ type: _angular_core.NgModule, args: [{},] }, | ||
]; | ||
/** @nocollapse */ | ||
/** | ||
* @nocollapse | ||
*/ | ||
StoreDevtoolsModule.ctorParameters = function () { return []; }; | ||
@@ -667,2 +817,14 @@ | ||
exports.StoreDevtools = StoreDevtools; | ||
exports.StoreDevtoolsConfig = StoreDevtoolsConfig; | ||
exports.ɵi = INITIAL_OPTIONS; | ||
exports.ɵh = STORE_DEVTOOLS_CONFIG; | ||
exports.ɵg = DevtoolsDispatcher; | ||
exports.ɵk = DevtoolsExtension; | ||
exports.ɵj = REDUX_DEVTOOLS_EXTENSION; | ||
exports.ɵa = IS_EXTENSION_OR_MONITOR_PRESENT; | ||
exports.ɵf = createConfig; | ||
exports.ɵb = createIsExtensionOrMonitorPresent; | ||
exports.ɵc = createReduxDevtoolsExtension; | ||
exports.ɵd = createStateObservable; | ||
exports.ɵe = noMonitor; | ||
@@ -672,1 +834,2 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=store-devtools.umd.js.map |
{ | ||
"name": "@ngrx/store-devtools", | ||
"version": "3.2.4", | ||
"version": "4.0.0", | ||
"description": "Developer tools for @ngrx/store", | ||
"main": "./bundles/store-devtools.umd.js", | ||
"module": "./index.js", | ||
"scripts": { | ||
"karma": "karma start --single-run", | ||
"test:raw": "node tests.js", | ||
"test": "nyc node tests.js", | ||
"clean:pre": "rimraf release", | ||
"clean:post": "rimraf src/**/*.ngfactory.ts", | ||
"copy": "cpy LICENSE package.json README.md release", | ||
"build:js": "ngc -p tsconfig.dist.json", | ||
"build:umd": "rollup -c rollup.config.js", | ||
"build:uglify": "uglifyjs -c --screw-ie8 --comments -o ./release/bundles/store-devtools.min.umd.js ./release/bundles/store-devtools.umd.js", | ||
"prebuild": "npm run test && npm run clean:pre", | ||
"postbuild": "npm run clean:post && npm run copy", | ||
"build": "npm run build:js && npm run build:umd && npm run build:uglify" | ||
}, | ||
"module": "@ngrx/store-devtools.es5.js", | ||
"es2015": "@ngrx/store-devtools.js", | ||
"main": "bundles/store-devtools.umd.js", | ||
"typings": "store-devtools.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ngrx/devtools.git" | ||
"url": "git+https://github.com/ngrx/platform.git" | ||
}, | ||
"keywords": [ | ||
"RxJS", | ||
"Angular2", | ||
"Angular", | ||
"Redux", | ||
@@ -44,49 +32,9 @@ "Store", | ||
"bugs": { | ||
"url": "https://github.com/ngrx/devtools/issues" | ||
"url": "https://github.com/ngrx/platform/issues" | ||
}, | ||
"homepage": "https://github.com/ngrx/devtools#readme", | ||
"homepage": "https://github.com/ngrx/platform#readme", | ||
"peerDependencies": { | ||
"@ngrx/store": "^2.0.0", | ||
"rxjs": "^5.0.0-beta.12" | ||
}, | ||
"devDependencies": { | ||
"@angular/animations": "^4.0.0", | ||
"@angular/common": "^4.0.0", | ||
"@angular/compiler": "^4.0.0", | ||
"@angular/compiler-cli": "^4.0.0", | ||
"@angular/core": "^4.0.0", | ||
"@angular/http": "^4.0.0", | ||
"@angular/platform-browser": "^4.0.0", | ||
"@angular/platform-browser-dynamic": "^4.0.0", | ||
"@angular/platform-server": "^4.0.0", | ||
"@ngrx/core": "^1.0.0", | ||
"@ngrx/store": "^2.1.2", | ||
"@types/jasmine": "^2.5.46", | ||
"@types/node": "^7.0.10", | ||
"core-js": "^2.4.1", | ||
"cpy-cli": "^1.0.1", | ||
"jasmine": "^2.5.3", | ||
"nyc": "^10.1.2", | ||
"rimraf": "^2.6.1", | ||
"rollup": "^0.41.6", | ||
"rxjs": "^5.2.0", | ||
"ts-loader": "^2.0.3", | ||
"ts-node": "^3.0.2", | ||
"tslint": "^4.5.1", | ||
"tslint-loader": "^3.4.3", | ||
"typescript": "^2.2.1", | ||
"uglifyjs": "^2.4.10", | ||
"zone.js": "^0.8.5" | ||
}, | ||
"nyc": { | ||
"extension": [ | ||
".ts" | ||
], | ||
"exclude": [ | ||
"spec/**/*.spec" | ||
], | ||
"include": [ | ||
"src/**/*.ts" | ||
] | ||
"@ngrx/store": "^4.0.0", | ||
"rxjs": "^5.0.0" | ||
} | ||
} |
@@ -1,57 +0,6 @@ | ||
# @ngrx/store-devtools | ||
@ngrx/store-devtools | ||
======= | ||
[![Join the chat at https://gitter.im/ngrx/store](https://badges.gitter.im/ngrx/store.svg)](https://gitter.im/ngrx/store?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
The sources for this package are in the main [ngrx/platform](https://github.com/ngrx/platform) repo. Please file issues and pull requests against that repo. | ||
Devtools for [@ngrx/store](https://github.com/ngrx/store). | ||
## Installation | ||
`npm install @ngrx/store-devtools --save` | ||
## Instrumentation | ||
### Instrumentation with the Chrome / Firefox Extension (Preferred) | ||
1. Download the [Redux Devtools Extension](http://zalmoxisus.github.io/redux-devtools-extension/) | ||
2. In your root Angular module import `StoreDevtoolsModule.instrumentOnlyWithExtension()`: | ||
```ts | ||
import { StoreDevtoolsModule } from '@ngrx/store-devtools'; | ||
@NgModule({ | ||
imports: [ | ||
StoreModule.provideStore(rootReducer), | ||
// Note that you must instrument after importing StoreModule | ||
StoreDevtoolsModule.instrumentOnlyWithExtension({ | ||
maxAge: 5 | ||
}) | ||
] | ||
}) | ||
export class AppModule { } | ||
``` | ||
### Instrumentation with a Custom Monitor | ||
To instrument @ngrx/store and use the devtools with a custom monitor you will need to setup the | ||
instrumentation providers using `instrumentStore()`: | ||
```ts | ||
import {StoreDevtoolsModule} from '@ngrx/store-devtools'; | ||
@NgModule({ | ||
imports: [ | ||
StoreModule.provideStore(rootReducer), | ||
// Note that you must instrument after importing StoreModule | ||
StoreDevtoolsModule.instrumentStore({ | ||
maxAge: 5, | ||
monitor: monitorReducer | ||
}) | ||
] | ||
}) | ||
export class AppModule { } | ||
``` | ||
See [@ngrx/store-log-monitor](https://github.com/ngrx/store-log-monitor) for an example monitor built for Angular 2 | ||
## Contributing | ||
Please read [contributing guidelines here](https://github.com/ngrx/store-devtools/blob/master/CONTRIBUTING.md). | ||
License: MIT |
@@ -1,54 +0,57 @@ | ||
export declare const ActionTypes: { | ||
PERFORM_ACTION: string; | ||
RESET: string; | ||
ROLLBACK: string; | ||
COMMIT: string; | ||
SWEEP: string; | ||
TOGGLE_ACTION: string; | ||
SET_ACTIONS_ACTIVE: string; | ||
JUMP_TO_STATE: string; | ||
IMPORT_STATE: string; | ||
}; | ||
/** | ||
* Action creators to change the History state. | ||
*/ | ||
export declare const StoreDevtoolActions: { | ||
performAction(action: any): { | ||
type: string; | ||
action: any; | ||
timestamp: number; | ||
}; | ||
reset(): { | ||
type: string; | ||
timestamp: number; | ||
}; | ||
rollback(): { | ||
type: string; | ||
timestamp: number; | ||
}; | ||
commit(): { | ||
type: string; | ||
timestamp: number; | ||
}; | ||
sweep(): { | ||
type: string; | ||
}; | ||
toggleAction(id: any): { | ||
type: string; | ||
id: any; | ||
}; | ||
setActionsActive(start: any, end: any, active?: boolean): { | ||
type: string; | ||
start: any; | ||
end: any; | ||
active: boolean; | ||
}; | ||
jumpToState(index: any): { | ||
type: string; | ||
index: any; | ||
}; | ||
importState(nextLiftedState: any): { | ||
type: string; | ||
nextLiftedState: any; | ||
}; | ||
}; | ||
import { Action } from '@ngrx/store'; | ||
export declare const PERFORM_ACTION = "PERFORM_ACTION"; | ||
export declare const RESET = "RESET"; | ||
export declare const ROLLBACK = "ROLLBACK"; | ||
export declare const COMMIT = "COMMIT"; | ||
export declare const SWEEP = "SWEEP"; | ||
export declare const TOGGLE_ACTION = "TOGGLE_ACTION"; | ||
export declare const SET_ACTIONS_ACTIVE = "SET_ACTIONS_ACTIVE"; | ||
export declare const JUMP_TO_STATE = "JUMP_TO_STATE"; | ||
export declare const IMPORT_STATE = "IMPORT_STATE"; | ||
export declare class PerformAction implements Action { | ||
action: Action; | ||
timestamp: number; | ||
readonly type: string; | ||
constructor(action: Action, timestamp?: number); | ||
} | ||
export declare class Reset implements Action { | ||
timestamp: number; | ||
readonly type: string; | ||
constructor(timestamp?: number); | ||
} | ||
export declare class Rollback implements Action { | ||
timestamp: number; | ||
readonly type: string; | ||
constructor(timestamp?: number); | ||
} | ||
export declare class Commit implements Action { | ||
timestamp: number; | ||
readonly type: string; | ||
constructor(timestamp?: number); | ||
} | ||
export declare class Sweep implements Action { | ||
readonly type: string; | ||
} | ||
export declare class ToggleAction implements Action { | ||
id: number; | ||
readonly type: string; | ||
constructor(id: number); | ||
} | ||
export declare class SetActionsActive implements Action { | ||
start: number; | ||
end: number; | ||
active: boolean; | ||
readonly type: string; | ||
constructor(start: number, end: number, active?: boolean); | ||
} | ||
export declare class JumpToState implements Action { | ||
index: number; | ||
readonly type: string; | ||
constructor(index: number); | ||
} | ||
export declare class ImportState implements Action { | ||
nextLiftedState: any; | ||
readonly type: string; | ||
constructor(nextLiftedState: any); | ||
} | ||
export declare type All = PerformAction | Reset | Rollback | Commit | Sweep | ToggleAction | SetActionsActive | JumpToState | ImportState; |
@@ -1,17 +0,19 @@ | ||
export var ActionTypes = { | ||
PERFORM_ACTION: 'PERFORM_ACTION', | ||
RESET: 'RESET', | ||
ROLLBACK: 'ROLLBACK', | ||
COMMIT: 'COMMIT', | ||
SWEEP: 'SWEEP', | ||
TOGGLE_ACTION: 'TOGGLE_ACTION', | ||
SET_ACTIONS_ACTIVE: 'SET_ACTIONS_ACTIVE', | ||
JUMP_TO_STATE: 'JUMP_TO_STATE', | ||
IMPORT_STATE: 'IMPORT_STATE' | ||
}; | ||
/** | ||
* Action creators to change the History state. | ||
*/ | ||
export var StoreDevtoolActions = { | ||
performAction: function (action) { | ||
export const /** @type {?} */ PERFORM_ACTION = 'PERFORM_ACTION'; | ||
export const /** @type {?} */ RESET = 'RESET'; | ||
export const /** @type {?} */ ROLLBACK = 'ROLLBACK'; | ||
export const /** @type {?} */ COMMIT = 'COMMIT'; | ||
export const /** @type {?} */ SWEEP = 'SWEEP'; | ||
export const /** @type {?} */ TOGGLE_ACTION = 'TOGGLE_ACTION'; | ||
export const /** @type {?} */ SET_ACTIONS_ACTIVE = 'SET_ACTIONS_ACTIVE'; | ||
export const /** @type {?} */ JUMP_TO_STATE = 'JUMP_TO_STATE'; | ||
export const /** @type {?} */ IMPORT_STATE = 'IMPORT_STATE'; | ||
export class PerformAction { | ||
/** | ||
* @param {?} action | ||
* @param {?=} timestamp | ||
*/ | ||
constructor(action, timestamp) { | ||
this.action = action; | ||
this.timestamp = timestamp; | ||
this.type = PERFORM_ACTION; | ||
if (typeof action.type === 'undefined') { | ||
@@ -21,30 +23,134 @@ throw new Error('Actions may not have an undefined "type" property. ' + | ||
} | ||
return { type: ActionTypes.PERFORM_ACTION, action: action, timestamp: Date.now() }; | ||
}, | ||
reset: function () { | ||
return { type: ActionTypes.RESET, timestamp: Date.now() }; | ||
}, | ||
rollback: function () { | ||
return { type: ActionTypes.ROLLBACK, timestamp: Date.now() }; | ||
}, | ||
commit: function () { | ||
return { type: ActionTypes.COMMIT, timestamp: Date.now() }; | ||
}, | ||
sweep: function () { | ||
return { type: ActionTypes.SWEEP }; | ||
}, | ||
toggleAction: function (id) { | ||
return { type: ActionTypes.TOGGLE_ACTION, id: id }; | ||
}, | ||
setActionsActive: function (start, end, active) { | ||
if (active === void 0) { active = true; } | ||
return { type: ActionTypes.SET_ACTIONS_ACTIVE, start: start, end: end, active: active }; | ||
}, | ||
jumpToState: function (index) { | ||
return { type: ActionTypes.JUMP_TO_STATE, index: index }; | ||
}, | ||
importState: function (nextLiftedState) { | ||
return { type: ActionTypes.IMPORT_STATE, nextLiftedState: nextLiftedState }; | ||
} | ||
}; | ||
} | ||
function PerformAction_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
PerformAction.prototype.type; | ||
/** @type {?} */ | ||
PerformAction.prototype.action; | ||
/** @type {?} */ | ||
PerformAction.prototype.timestamp; | ||
} | ||
export class Reset { | ||
/** | ||
* @param {?=} timestamp | ||
*/ | ||
constructor(timestamp) { | ||
this.timestamp = timestamp; | ||
this.type = RESET; | ||
} | ||
} | ||
function Reset_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
Reset.prototype.type; | ||
/** @type {?} */ | ||
Reset.prototype.timestamp; | ||
} | ||
export class Rollback { | ||
/** | ||
* @param {?=} timestamp | ||
*/ | ||
constructor(timestamp) { | ||
this.timestamp = timestamp; | ||
this.type = ROLLBACK; | ||
} | ||
} | ||
function Rollback_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
Rollback.prototype.type; | ||
/** @type {?} */ | ||
Rollback.prototype.timestamp; | ||
} | ||
export class Commit { | ||
/** | ||
* @param {?=} timestamp | ||
*/ | ||
constructor(timestamp) { | ||
this.timestamp = timestamp; | ||
this.type = COMMIT; | ||
} | ||
} | ||
function Commit_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
Commit.prototype.type; | ||
/** @type {?} */ | ||
Commit.prototype.timestamp; | ||
} | ||
export class Sweep { | ||
constructor() { | ||
this.type = SWEEP; | ||
} | ||
} | ||
function Sweep_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
Sweep.prototype.type; | ||
} | ||
export class ToggleAction { | ||
/** | ||
* @param {?} id | ||
*/ | ||
constructor(id) { | ||
this.id = id; | ||
this.type = TOGGLE_ACTION; | ||
} | ||
} | ||
function ToggleAction_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
ToggleAction.prototype.type; | ||
/** @type {?} */ | ||
ToggleAction.prototype.id; | ||
} | ||
export class SetActionsActive { | ||
/** | ||
* @param {?} start | ||
* @param {?} end | ||
* @param {?=} active | ||
*/ | ||
constructor(start, end, active = true) { | ||
this.start = start; | ||
this.end = end; | ||
this.active = active; | ||
this.type = SET_ACTIONS_ACTIVE; | ||
} | ||
} | ||
function SetActionsActive_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
SetActionsActive.prototype.type; | ||
/** @type {?} */ | ||
SetActionsActive.prototype.start; | ||
/** @type {?} */ | ||
SetActionsActive.prototype.end; | ||
/** @type {?} */ | ||
SetActionsActive.prototype.active; | ||
} | ||
export class JumpToState { | ||
/** | ||
* @param {?} index | ||
*/ | ||
constructor(index) { | ||
this.index = index; | ||
this.type = JUMP_TO_STATE; | ||
} | ||
} | ||
function JumpToState_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
JumpToState.prototype.type; | ||
/** @type {?} */ | ||
JumpToState.prototype.index; | ||
} | ||
export class ImportState { | ||
/** | ||
* @param {?} nextLiftedState | ||
*/ | ||
constructor(nextLiftedState) { | ||
this.nextLiftedState = nextLiftedState; | ||
this.type = IMPORT_STATE; | ||
} | ||
} | ||
function ImportState_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
ImportState.prototype.type; | ||
/** @type {?} */ | ||
ImportState.prototype.nextLiftedState; | ||
} | ||
//# sourceMappingURL=actions.js.map |
import { ActionReducer } from '@ngrx/store'; | ||
import { OpaqueToken } from '@angular/core'; | ||
export interface StoreDevtoolsConfig { | ||
maxAge?: number; | ||
monitor?: ActionReducer<any>; | ||
import { InjectionToken } from '@angular/core'; | ||
export declare class StoreDevtoolsConfig { | ||
maxAge: number | false; | ||
monitor: ActionReducer<any, any>; | ||
} | ||
export declare const STORE_DEVTOOLS_CONFIG: OpaqueToken; | ||
export declare const INITIAL_OPTIONS: OpaqueToken; | ||
export declare const STORE_DEVTOOLS_CONFIG: InjectionToken<StoreDevtoolsConfig>; | ||
export declare const INITIAL_OPTIONS: InjectionToken<StoreDevtoolsConfig>; | ||
export declare type StoreDevtoolsOptions = Partial<StoreDevtoolsConfig> | (() => Partial<StoreDevtoolsConfig>); |
@@ -1,4 +0,12 @@ | ||
import { OpaqueToken } from '@angular/core'; | ||
export var STORE_DEVTOOLS_CONFIG = new OpaqueToken('@ngrx/devtools Options'); | ||
export var INITIAL_OPTIONS = new OpaqueToken('@ngrx/devtools Initial Config'); | ||
import { InjectionToken } from '@angular/core'; | ||
export class StoreDevtoolsConfig { | ||
} | ||
function StoreDevtoolsConfig_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
StoreDevtoolsConfig.prototype.maxAge; | ||
/** @type {?} */ | ||
StoreDevtoolsConfig.prototype.monitor; | ||
} | ||
export const /** @type {?} */ STORE_DEVTOOLS_CONFIG = new InjectionToken('@ngrx/devtools Options'); | ||
export const /** @type {?} */ INITIAL_OPTIONS = new InjectionToken('@ngrx/devtools Initial Config'); | ||
//# sourceMappingURL=config.js.map |
@@ -1,2 +0,2 @@ | ||
import { Dispatcher, Reducer } from '@ngrx/store'; | ||
import { Action, ReducerObservable, ActionsSubject, ScannedActionsSubject } from '@ngrx/store'; | ||
import { Observable } from 'rxjs/Observable'; | ||
@@ -7,11 +7,11 @@ import { Observer } from 'rxjs/Observer'; | ||
import { StoreDevtoolsConfig } from './config'; | ||
export declare class DevtoolsDispatcher extends Dispatcher { | ||
export declare class DevtoolsDispatcher extends ActionsSubject { | ||
} | ||
export declare class StoreDevtools implements Observer<any> { | ||
private stateSubscription; | ||
dispatcher: Dispatcher; | ||
dispatcher: ActionsSubject; | ||
liftedState: Observable<LiftedState>; | ||
state: Observable<any>; | ||
constructor(dispatcher: DevtoolsDispatcher, actions$: Dispatcher, reducers$: Reducer, extension: DevtoolsExtension, initialState: any, config: StoreDevtoolsConfig); | ||
dispatch(action: any): void; | ||
constructor(dispatcher: DevtoolsDispatcher, actions$: ActionsSubject, reducers$: ReducerObservable, extension: DevtoolsExtension, scannedActions: ScannedActionsSubject, initialState: any, config: StoreDevtoolsConfig); | ||
dispatch(action: Action): void; | ||
next(action: any): void; | ||
@@ -18,0 +18,0 @@ error(error: any): void; |
@@ -1,13 +0,3 @@ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
import { Injectable, Inject } from '@angular/core'; | ||
import { INITIAL_STATE, Dispatcher, Reducer } from '@ngrx/store'; | ||
import { INITIAL_STATE, ReducerObservable, ActionsSubject, ScannedActionsSubject, } from '@ngrx/store'; | ||
import { ReplaySubject } from 'rxjs/ReplaySubject'; | ||
@@ -24,24 +14,36 @@ import { map } from 'rxjs/operator/map'; | ||
import { liftReducerWith, liftInitialState } from './reducer'; | ||
import { StoreDevtoolActions as actions } from './actions'; | ||
import { STORE_DEVTOOLS_CONFIG } from './config'; | ||
var DevtoolsDispatcher = (function (_super) { | ||
__extends(DevtoolsDispatcher, _super); | ||
function DevtoolsDispatcher() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return DevtoolsDispatcher; | ||
}(Dispatcher)); | ||
export { DevtoolsDispatcher }; | ||
import * as Actions from './actions'; | ||
import { StoreDevtoolsConfig, STORE_DEVTOOLS_CONFIG } from './config'; | ||
export class DevtoolsDispatcher extends ActionsSubject { | ||
} | ||
DevtoolsDispatcher.decorators = [ | ||
{ type: Injectable }, | ||
]; | ||
/** @nocollapse */ | ||
DevtoolsDispatcher.ctorParameters = function () { return []; }; | ||
var StoreDevtools = (function () { | ||
function StoreDevtools(dispatcher, actions$, reducers$, extension, initialState, config) { | ||
var liftedInitialState = liftInitialState(initialState, config.monitor); | ||
var liftReducer = liftReducerWith(initialState, liftedInitialState, config.monitor, { | ||
maxAge: config.maxAge | ||
}); | ||
var liftedAction$ = applyOperators(actions$, [ | ||
/** | ||
* @nocollapse | ||
*/ | ||
DevtoolsDispatcher.ctorParameters = () => []; | ||
function DevtoolsDispatcher_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
DevtoolsDispatcher.decorators; | ||
/** | ||
* @nocollapse | ||
* @type {?} | ||
*/ | ||
DevtoolsDispatcher.ctorParameters; | ||
} | ||
export class StoreDevtools { | ||
/** | ||
* @param {?} dispatcher | ||
* @param {?} actions$ | ||
* @param {?} reducers$ | ||
* @param {?} extension | ||
* @param {?} scannedActions | ||
* @param {?} initialState | ||
* @param {?} config | ||
*/ | ||
constructor(dispatcher, actions$, reducers$, extension, scannedActions, initialState, config) { | ||
const liftedInitialState = liftInitialState(initialState, config.monitor); | ||
const liftReducer = liftReducerWith(initialState, liftedInitialState, config.monitor, config.maxAge ? { maxAge: config.maxAge } : {}); | ||
const liftedAction$ = applyOperators(actions$.asObservable(), [ | ||
[skip, 1], | ||
@@ -51,17 +53,26 @@ [merge, extension.actions$], | ||
[merge, dispatcher, extension.liftedActions$], | ||
[observeOn, queue] | ||
[observeOn, queue], | ||
]); | ||
var liftedReducer$ = map.call(reducers$, liftReducer); | ||
var liftedStateSubject = new ReplaySubject(1); | ||
var liftedStateSubscription = applyOperators(liftedAction$, [ | ||
const liftedReducer$ = map.call(reducers$, liftReducer); | ||
const liftedStateSubject = new ReplaySubject(1); | ||
const liftedStateSubscription = applyOperators(liftedAction$, [ | ||
[withLatestFrom, liftedReducer$], | ||
[scan, function (liftedState, _a) { | ||
var action = _a[0], reducer = _a[1]; | ||
var nextState = reducer(liftedState, action); | ||
extension.notify(action, nextState); | ||
return nextState; | ||
}, liftedInitialState] | ||
]).subscribe(liftedStateSubject); | ||
var liftedState$ = liftedStateSubject.asObservable(); | ||
var state$ = map.call(liftedState$, unliftState); | ||
[ | ||
scan, | ||
({ state: liftedState }, [action, reducer]) => { | ||
const state = reducer(liftedState, action); | ||
extension.notify(action, state); | ||
return { state, action }; | ||
}, | ||
{ state: liftedInitialState, action: null }, | ||
], | ||
]).subscribe(({ state, action }) => { | ||
liftedStateSubject.next(state); | ||
if (action.type === Actions.PERFORM_ACTION) { | ||
const unlifedAction = action.action; | ||
scannedActions.next(unlifedAction); | ||
} | ||
}); | ||
const liftedState$ = liftedStateSubject.asObservable(); | ||
const state$ = map.call(liftedState$, unliftState); | ||
this.stateSubscription = liftedStateSubscription; | ||
@@ -72,49 +83,110 @@ this.dispatcher = dispatcher; | ||
} | ||
StoreDevtools.prototype.dispatch = function (action) { | ||
this.dispatcher.dispatch(action); | ||
}; | ||
StoreDevtools.prototype.next = function (action) { | ||
this.dispatcher.dispatch(action); | ||
}; | ||
StoreDevtools.prototype.error = function (error) { }; | ||
StoreDevtools.prototype.complete = function () { }; | ||
StoreDevtools.prototype.performAction = function (action) { | ||
this.dispatch(actions.performAction(action)); | ||
}; | ||
StoreDevtools.prototype.reset = function () { | ||
this.dispatch(actions.reset()); | ||
}; | ||
StoreDevtools.prototype.rollback = function () { | ||
this.dispatch(actions.rollback()); | ||
}; | ||
StoreDevtools.prototype.commit = function () { | ||
this.dispatch(actions.commit()); | ||
}; | ||
StoreDevtools.prototype.sweep = function () { | ||
this.dispatch(actions.sweep()); | ||
}; | ||
StoreDevtools.prototype.toggleAction = function (id) { | ||
this.dispatch(actions.toggleAction(id)); | ||
}; | ||
StoreDevtools.prototype.jumpToState = function (index) { | ||
this.dispatch(actions.jumpToState(index)); | ||
}; | ||
StoreDevtools.prototype.importState = function (nextLiftedState) { | ||
this.dispatch(actions.importState(nextLiftedState)); | ||
}; | ||
return StoreDevtools; | ||
}()); | ||
export { StoreDevtools }; | ||
/** | ||
* @param {?} action | ||
* @return {?} | ||
*/ | ||
dispatch(action) { | ||
this.dispatcher.next(action); | ||
} | ||
/** | ||
* @param {?} action | ||
* @return {?} | ||
*/ | ||
next(action) { | ||
this.dispatcher.next(action); | ||
} | ||
/** | ||
* @param {?} error | ||
* @return {?} | ||
*/ | ||
error(error) { } | ||
/** | ||
* @return {?} | ||
*/ | ||
complete() { } | ||
/** | ||
* @param {?} action | ||
* @return {?} | ||
*/ | ||
performAction(action) { | ||
this.dispatch(new Actions.PerformAction(action)); | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
reset() { | ||
this.dispatch(new Actions.Reset()); | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
rollback() { | ||
this.dispatch(new Actions.Rollback()); | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
commit() { | ||
this.dispatch(new Actions.Commit()); | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
sweep() { | ||
this.dispatch(new Actions.Sweep()); | ||
} | ||
/** | ||
* @param {?} id | ||
* @return {?} | ||
*/ | ||
toggleAction(id) { | ||
this.dispatch(new Actions.ToggleAction(id)); | ||
} | ||
/** | ||
* @param {?} index | ||
* @return {?} | ||
*/ | ||
jumpToState(index) { | ||
this.dispatch(new Actions.JumpToState(index)); | ||
} | ||
/** | ||
* @param {?} nextLiftedState | ||
* @return {?} | ||
*/ | ||
importState(nextLiftedState) { | ||
this.dispatch(new Actions.ImportState(nextLiftedState)); | ||
} | ||
} | ||
StoreDevtools.decorators = [ | ||
{ type: Injectable }, | ||
]; | ||
/** @nocollapse */ | ||
StoreDevtools.ctorParameters = function () { return [ | ||
/** | ||
* @nocollapse | ||
*/ | ||
StoreDevtools.ctorParameters = () => [ | ||
{ type: DevtoolsDispatcher, }, | ||
{ type: Dispatcher, }, | ||
{ type: Reducer, }, | ||
{ type: ActionsSubject, }, | ||
{ type: ReducerObservable, }, | ||
{ type: DevtoolsExtension, }, | ||
{ type: ScannedActionsSubject, }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [INITIAL_STATE,] },] }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [STORE_DEVTOOLS_CONFIG,] },] }, | ||
]; }; | ||
{ type: StoreDevtoolsConfig, decorators: [{ type: Inject, args: [STORE_DEVTOOLS_CONFIG,] },] }, | ||
]; | ||
function StoreDevtools_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
StoreDevtools.decorators; | ||
/** | ||
* @nocollapse | ||
* @type {?} | ||
*/ | ||
StoreDevtools.ctorParameters; | ||
/** @type {?} */ | ||
StoreDevtools.prototype.stateSubscription; | ||
/** @type {?} */ | ||
StoreDevtools.prototype.dispatcher; | ||
/** @type {?} */ | ||
StoreDevtools.prototype.liftedState; | ||
/** @type {?} */ | ||
StoreDevtools.prototype.state; | ||
} | ||
//# sourceMappingURL=devtools.js.map |
@@ -1,3 +0,4 @@ | ||
import { OpaqueToken } from '@angular/core'; | ||
import { InjectionToken } from '@angular/core'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import { Action } from '@ngrx/store'; | ||
import { LiftedState } from './reducer'; | ||
@@ -10,7 +11,7 @@ export declare const ExtensionActionTypes: { | ||
}; | ||
export declare const REDUX_DEVTOOLS_EXTENSION: OpaqueToken; | ||
export declare const REDUX_DEVTOOLS_EXTENSION: InjectionToken<ReduxDevtoolsExtension>; | ||
export interface ReduxDevtoolsExtensionConnection { | ||
subscribe(listener: (change: any) => void): any; | ||
unsubscribe(): any; | ||
send(action: any, state: any): any; | ||
subscribe(listener: (change: any) => void): void; | ||
unsubscribe(): void; | ||
send(action: any, state: any): void; | ||
} | ||
@@ -22,3 +23,5 @@ export interface ReduxDevtoolsExtension { | ||
}): ReduxDevtoolsExtensionConnection; | ||
send(action: any, state: any, shouldStringify?: boolean, instanceId?: string): any; | ||
send(action: any, state: any, options?: boolean | { | ||
serialize: boolean | object; | ||
}, instanceId?: string): void; | ||
} | ||
@@ -30,4 +33,4 @@ export declare class DevtoolsExtension { | ||
actions$: Observable<any>; | ||
constructor(devtoolsExtension: any); | ||
notify(action: any, state: LiftedState): void; | ||
constructor(devtoolsExtension: ReduxDevtoolsExtension); | ||
notify(action: Action, state: LiftedState): void; | ||
private createChangesObservable(); | ||
@@ -34,0 +37,0 @@ private createActionStreams(); |
@@ -1,2 +0,2 @@ | ||
import { OpaqueToken, Inject, Injectable } from '@angular/core'; | ||
import { InjectionToken, Inject, Injectable } from '@angular/core'; | ||
import { Observable } from 'rxjs/Observable'; | ||
@@ -10,69 +10,104 @@ import { empty } from 'rxjs/observable/empty'; | ||
import { applyOperators } from './utils'; | ||
export var ExtensionActionTypes = { | ||
export const /** @type {?} */ ExtensionActionTypes = { | ||
START: 'START', | ||
DISPATCH: 'DISPATCH', | ||
STOP: 'STOP', | ||
ACTION: 'ACTION' | ||
ACTION: 'ACTION', | ||
}; | ||
export var REDUX_DEVTOOLS_EXTENSION = new OpaqueToken('Redux Devtools Extension'); | ||
var DevtoolsExtension = (function () { | ||
function DevtoolsExtension(devtoolsExtension) { | ||
this.instanceId = "ngrx-store-" + Date.now(); | ||
export const /** @type {?} */ REDUX_DEVTOOLS_EXTENSION = new InjectionToken('Redux Devtools Extension'); | ||
export class DevtoolsExtension { | ||
/** | ||
* @param {?} devtoolsExtension | ||
*/ | ||
constructor(devtoolsExtension) { | ||
this.instanceId = `ngrx-store-${Date.now()}`; | ||
this.devtoolsExtension = devtoolsExtension; | ||
this.createActionStreams(); | ||
} | ||
DevtoolsExtension.prototype.notify = function (action, state) { | ||
/** | ||
* @param {?} action | ||
* @param {?} state | ||
* @return {?} | ||
*/ | ||
notify(action, state) { | ||
if (!this.devtoolsExtension) { | ||
return; | ||
} | ||
this.devtoolsExtension.send(null, state, false, this.instanceId); | ||
}; | ||
DevtoolsExtension.prototype.createChangesObservable = function () { | ||
var _this = this; | ||
this.devtoolsExtension.send(null, state, { serialize: false }, this.instanceId); | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
createChangesObservable() { | ||
if (!this.devtoolsExtension) { | ||
return empty(); | ||
} | ||
return new Observable(function (subscriber) { | ||
var connection = _this.devtoolsExtension.connect({ instanceId: _this.instanceId }); | ||
connection.subscribe(function (change) { return subscriber.next(change); }); | ||
return new Observable(subscriber => { | ||
const /** @type {?} */ connection = this.devtoolsExtension.connect({ | ||
instanceId: this.instanceId, | ||
}); | ||
connection.subscribe((change) => subscriber.next(change)); | ||
return connection.unsubscribe; | ||
}); | ||
}; | ||
DevtoolsExtension.prototype.createActionStreams = function () { | ||
var _this = this; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
createActionStreams() { | ||
// Listens to all changes based on our instanceId | ||
var changes$ = share.call(this.createChangesObservable()); | ||
const /** @type {?} */ changes$ = share.call(this.createChangesObservable()); | ||
// Listen for the start action | ||
var start$ = filter.call(changes$, function (change) { return change.type === ExtensionActionTypes.START; }); | ||
const /** @type {?} */ start$ = filter.call(changes$, (change) => change.type === ExtensionActionTypes.START); | ||
// Listen for the stop action | ||
var stop$ = filter.call(changes$, function (change) { return change.type === ExtensionActionTypes.STOP; }); | ||
const /** @type {?} */ stop$ = filter.call(changes$, (change) => change.type === ExtensionActionTypes.STOP); | ||
// Listen for lifted actions | ||
var liftedActions$ = applyOperators(changes$, [ | ||
[filter, function (change) { return change.type === ExtensionActionTypes.DISPATCH; }], | ||
[map, function (change) { return _this.unwrapAction(change.payload); }] | ||
const /** @type {?} */ liftedActions$ = applyOperators(changes$, [ | ||
[filter, (change) => change.type === ExtensionActionTypes.DISPATCH], | ||
[map, (change) => this.unwrapAction(change.payload)], | ||
]); | ||
// Listen for unlifted actions | ||
var actions$ = applyOperators(changes$, [ | ||
[filter, function (change) { return change.type === ExtensionActionTypes.ACTION; }], | ||
[map, function (change) { return _this.unwrapAction(change.payload); }] | ||
const /** @type {?} */ actions$ = applyOperators(changes$, [ | ||
[filter, (change) => change.type === ExtensionActionTypes.ACTION], | ||
[map, (change) => this.unwrapAction(change.payload)], | ||
]); | ||
var actionsUntilStop$ = takeUntil.call(actions$, stop$); | ||
var liftedUntilStop$ = takeUntil.call(liftedActions$, stop$); | ||
const /** @type {?} */ actionsUntilStop$ = takeUntil.call(actions$, stop$); | ||
const /** @type {?} */ liftedUntilStop$ = takeUntil.call(liftedActions$, stop$); | ||
// Only take the action sources between the start/stop events | ||
this.actions$ = switchMap.call(start$, function () { return actionsUntilStop$; }); | ||
this.liftedActions$ = switchMap.call(start$, function () { return liftedUntilStop$; }); | ||
}; | ||
DevtoolsExtension.prototype.unwrapAction = function (action) { | ||
return typeof action === 'string' ? eval("(" + action + ")") : action; | ||
}; | ||
return DevtoolsExtension; | ||
}()); | ||
export { DevtoolsExtension }; | ||
this.actions$ = switchMap.call(start$, () => actionsUntilStop$); | ||
this.liftedActions$ = switchMap.call(start$, () => liftedUntilStop$); | ||
} | ||
/** | ||
* @param {?} action | ||
* @return {?} | ||
*/ | ||
unwrapAction(action) { | ||
return typeof action === 'string' ? eval(`(${action})`) : action; | ||
} | ||
} | ||
DevtoolsExtension.decorators = [ | ||
{ type: Injectable }, | ||
]; | ||
/** @nocollapse */ | ||
DevtoolsExtension.ctorParameters = function () { return [ | ||
/** | ||
* @nocollapse | ||
*/ | ||
DevtoolsExtension.ctorParameters = () => [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [REDUX_DEVTOOLS_EXTENSION,] },] }, | ||
]; }; | ||
]; | ||
function DevtoolsExtension_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
DevtoolsExtension.decorators; | ||
/** | ||
* @nocollapse | ||
* @type {?} | ||
*/ | ||
DevtoolsExtension.ctorParameters; | ||
/** @type {?} */ | ||
DevtoolsExtension.prototype.instanceId; | ||
/** @type {?} */ | ||
DevtoolsExtension.prototype.devtoolsExtension; | ||
/** @type {?} */ | ||
DevtoolsExtension.prototype.liftedActions$; | ||
/** @type {?} */ | ||
DevtoolsExtension.prototype.actions$; | ||
} | ||
//# sourceMappingURL=extension.js.map |
@@ -1,16 +0,14 @@ | ||
import { Injector, ModuleWithProviders } from '@angular/core'; | ||
import { Reducer } from '@ngrx/store'; | ||
import { InjectionToken, ModuleWithProviders } from '@angular/core'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import { StoreDevtools, DevtoolsDispatcher } from './devtools'; | ||
import { StoreDevtoolsConfig } from './config'; | ||
export declare function _createReduxDevtoolsExtension(): any; | ||
export declare function _createState(devtools: StoreDevtools): Observable<any>; | ||
export declare function _createReducer(dispatcher: DevtoolsDispatcher, reducer: any): Reducer; | ||
export declare function _createStateIfExtension(extension: any, injector: Injector, initialState: any): Observable<any>; | ||
export declare function _createReducerIfExtension(extension: any, injector: Injector, reducer: any): Reducer; | ||
export declare function noMonitor(): any; | ||
export declare function _createOptions(_options: any): StoreDevtoolsConfig; | ||
import { StoreDevtools } from './devtools'; | ||
import { StoreDevtoolsConfig, StoreDevtoolsOptions } from './config'; | ||
import { ReduxDevtoolsExtension } from './extension'; | ||
export declare const IS_EXTENSION_OR_MONITOR_PRESENT: InjectionToken<boolean>; | ||
export declare function createIsExtensionOrMonitorPresent(extension: ReduxDevtoolsExtension | null, config: StoreDevtoolsConfig): boolean; | ||
export declare function createReduxDevtoolsExtension(): any; | ||
export declare function createStateObservable(devtools: StoreDevtools): Observable<any>; | ||
export declare function noMonitor(): null; | ||
export declare function createConfig(_options: StoreDevtoolsOptions): StoreDevtoolsConfig; | ||
export declare class StoreDevtoolsModule { | ||
static instrumentStore(_options?: StoreDevtoolsConfig | (() => StoreDevtoolsConfig)): ModuleWithProviders; | ||
static instrumentOnlyWithExtension(_options?: StoreDevtoolsConfig | (() => StoreDevtoolsConfig)): ModuleWithProviders; | ||
static instrument(options?: StoreDevtoolsOptions): ModuleWithProviders; | ||
} |
@@ -1,15 +0,24 @@ | ||
import { NgModule, Injector } from '@angular/core'; | ||
import { StoreModule, State, INITIAL_STATE, INITIAL_REDUCER, Dispatcher, Reducer } from '@ngrx/store'; | ||
import { NgModule, InjectionToken, } from '@angular/core'; | ||
import { StateObservable, ReducerManagerDispatcher, } from '@ngrx/store'; | ||
import { StoreDevtools, DevtoolsDispatcher } from './devtools'; | ||
import { STORE_DEVTOOLS_CONFIG, INITIAL_OPTIONS } from './config'; | ||
import { DevtoolsExtension, REDUX_DEVTOOLS_EXTENSION } from './extension'; | ||
export function _createReduxDevtoolsExtension() { | ||
var legacyExtensionKey = 'devToolsExtension'; | ||
var extensionKey = '__REDUX_DEVTOOLS_EXTENSION__'; | ||
if (typeof window === 'object' && typeof window[legacyExtensionKey] !== 'undefined') { | ||
return window[legacyExtensionKey]; | ||
import { STORE_DEVTOOLS_CONFIG, INITIAL_OPTIONS, } from './config'; | ||
import { DevtoolsExtension, REDUX_DEVTOOLS_EXTENSION, } from './extension'; | ||
export const /** @type {?} */ IS_EXTENSION_OR_MONITOR_PRESENT = new InjectionToken('Is Devtools Extension or Monitor Present'); | ||
/** | ||
* @param {?} extension | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
export function createIsExtensionOrMonitorPresent(extension, config) { | ||
return Boolean(extension) || config.monitor !== noMonitor; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
export function createReduxDevtoolsExtension() { | ||
const /** @type {?} */ extensionKey = '__REDUX_DEVTOOLS_EXTENSION__'; | ||
if (typeof window === 'object' && | ||
typeof ((window))[extensionKey] !== 'undefined') { | ||
return ((window))[extensionKey]; | ||
} | ||
else if (typeof window === 'object' && typeof window[extensionKey] !== 'undefined') { | ||
return window[extensionKey]; | ||
} | ||
else { | ||
@@ -19,62 +28,55 @@ return null; | ||
} | ||
export function _createState(devtools) { | ||
/** | ||
* @param {?} devtools | ||
* @return {?} | ||
*/ | ||
export function createStateObservable(devtools) { | ||
return devtools.state; | ||
} | ||
export function _createReducer(dispatcher, reducer) { | ||
return new Reducer(dispatcher, reducer); | ||
} | ||
export function _createStateIfExtension(extension, injector, initialState) { | ||
if (!!extension) { | ||
var devtools = injector.get(StoreDevtools); | ||
return _createState(devtools); | ||
} | ||
else { | ||
var dispatcher = injector.get(Dispatcher); | ||
var reducer = injector.get(Reducer); | ||
return new State(initialState, dispatcher, reducer); | ||
} | ||
} | ||
export function _createReducerIfExtension(extension, injector, reducer) { | ||
if (!!extension) { | ||
var devtoolsDispatcher = injector.get(DevtoolsDispatcher); | ||
return _createReducer(devtoolsDispatcher, reducer); | ||
} | ||
else { | ||
var dispatcher = injector.get(Dispatcher); | ||
return new Reducer(dispatcher, reducer); | ||
} | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
export function noMonitor() { | ||
return null; | ||
} | ||
export function _createOptions(_options) { | ||
var DEFAULT_OPTIONS = { monitor: noMonitor }; | ||
var options = typeof _options === 'function' ? _options() : _options; | ||
options = Object.assign({}, DEFAULT_OPTIONS, options); | ||
if (options.maxAge && options.maxAge < 2) { | ||
throw new Error("Devtools 'maxAge' cannot be less than 2, got " + options.maxAge); | ||
/** | ||
* @param {?} _options | ||
* @return {?} | ||
*/ | ||
export function createConfig(_options) { | ||
const /** @type {?} */ DEFAULT_OPTIONS = { | ||
maxAge: false, | ||
monitor: noMonitor, | ||
}; | ||
let /** @type {?} */ options = typeof _options === 'function' ? _options() : _options; | ||
const /** @type {?} */ config = Object.assign({}, DEFAULT_OPTIONS, options); | ||
if (config.maxAge && config.maxAge < 2) { | ||
throw new Error(`Devtools 'maxAge' cannot be less than 2, got ${config.maxAge}`); | ||
} | ||
return options; | ||
return config; | ||
} | ||
var StoreDevtoolsModule = (function () { | ||
function StoreDevtoolsModule() { | ||
} | ||
StoreDevtoolsModule.instrumentStore = function (_options) { | ||
if (_options === void 0) { _options = {}; } | ||
export class StoreDevtoolsModule { | ||
/** | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
static instrument(options = {}) { | ||
return { | ||
ngModule: StoreDevtoolsModule, | ||
providers: [ | ||
DevtoolsExtension, | ||
DevtoolsDispatcher, | ||
StoreDevtools, | ||
{ | ||
provide: State, | ||
deps: [StoreDevtools], | ||
useFactory: _createState | ||
provide: INITIAL_OPTIONS, | ||
useValue: options, | ||
}, | ||
{ | ||
provide: INITIAL_OPTIONS, | ||
useValue: _options | ||
provide: IS_EXTENSION_OR_MONITOR_PRESENT, | ||
deps: [REDUX_DEVTOOLS_EXTENSION, STORE_DEVTOOLS_CONFIG], | ||
useFactory: createIsExtensionOrMonitorPresent, | ||
}, | ||
{ | ||
provide: Reducer, | ||
deps: [DevtoolsDispatcher, INITIAL_REDUCER], | ||
useFactory: _createReducer | ||
provide: REDUX_DEVTOOLS_EXTENSION, | ||
useFactory: createReduxDevtoolsExtension, | ||
}, | ||
@@ -84,55 +86,33 @@ { | ||
deps: [INITIAL_OPTIONS], | ||
useFactory: _createOptions | ||
} | ||
] | ||
}; | ||
}; | ||
StoreDevtoolsModule.instrumentOnlyWithExtension = function (_options) { | ||
if (_options === void 0) { _options = {}; } | ||
return { | ||
ngModule: StoreDevtoolsModule, | ||
providers: [ | ||
{ | ||
provide: State, | ||
deps: [REDUX_DEVTOOLS_EXTENSION, Injector, INITIAL_STATE], | ||
useFactory: _createStateIfExtension | ||
useFactory: createConfig, | ||
}, | ||
{ | ||
provide: Reducer, | ||
deps: [REDUX_DEVTOOLS_EXTENSION, Injector, INITIAL_REDUCER], | ||
useFactory: _createReducerIfExtension | ||
provide: StateObservable, | ||
deps: [StoreDevtools], | ||
useFactory: createStateObservable, | ||
}, | ||
{ | ||
provide: INITIAL_OPTIONS, | ||
useValue: _options | ||
provide: ReducerManagerDispatcher, | ||
useExisting: DevtoolsDispatcher, | ||
}, | ||
{ | ||
provide: STORE_DEVTOOLS_CONFIG, | ||
deps: [INITIAL_OPTIONS], | ||
useFactory: _createOptions | ||
} | ||
] | ||
], | ||
}; | ||
}; | ||
return StoreDevtoolsModule; | ||
}()); | ||
export { StoreDevtoolsModule }; | ||
} | ||
} | ||
StoreDevtoolsModule.decorators = [ | ||
{ type: NgModule, args: [{ | ||
imports: [ | ||
StoreModule | ||
], | ||
providers: [ | ||
DevtoolsExtension, | ||
DevtoolsDispatcher, | ||
StoreDevtools, | ||
{ | ||
provide: REDUX_DEVTOOLS_EXTENSION, | ||
useFactory: _createReduxDevtoolsExtension | ||
} | ||
] | ||
},] }, | ||
{ type: NgModule, args: [{},] }, | ||
]; | ||
/** @nocollapse */ | ||
StoreDevtoolsModule.ctorParameters = function () { return []; }; | ||
/** | ||
* @nocollapse | ||
*/ | ||
StoreDevtoolsModule.ctorParameters = () => []; | ||
function StoreDevtoolsModule_tsickle_Closure_declarations() { | ||
/** @type {?} */ | ||
StoreDevtoolsModule.decorators; | ||
/** | ||
* @nocollapse | ||
* @type {?} | ||
*/ | ||
StoreDevtoolsModule.ctorParameters; | ||
} | ||
//# sourceMappingURL=instrument.js.map |
@@ -1,2 +0,11 @@ | ||
import { Action } from '@ngrx/store'; | ||
import { Action, ActionReducer, UPDATE, INIT } from '@ngrx/store'; | ||
import * as Actions from './actions'; | ||
export declare type InitAction = { | ||
readonly type: typeof INIT; | ||
}; | ||
export declare type UpdateReducerAction = { | ||
readonly type: typeof UPDATE; | ||
}; | ||
export declare type CoreActions = InitAction | UpdateReducerAction; | ||
export declare type Actions = Actions.All | CoreActions; | ||
export declare const INIT_ACTION: { | ||
@@ -28,11 +37,2 @@ type: string; | ||
maxAge?: number; | ||
}): (reducer: any) => (liftedState: any, liftedAction: any) => { | ||
monitorState: any; | ||
actionsById: any; | ||
nextActionId: any; | ||
stagedActionIds: any; | ||
skippedActionIds: any; | ||
committedState: any; | ||
currentStateIndex: any; | ||
computedStates: any; | ||
}; | ||
}): (reducer: ActionReducer<any, any>) => ActionReducer<LiftedState, Actions>; |
@@ -1,17 +0,22 @@ | ||
import { Dispatcher, Reducer } from '@ngrx/store'; | ||
import { UPDATE, INIT, } from '@ngrx/store'; | ||
import { difference, liftAction } from './utils'; | ||
import { ActionTypes } from './actions'; | ||
export var INIT_ACTION = { type: Dispatcher.INIT }; | ||
import * as Actions from './actions'; | ||
export const /** @type {?} */ INIT_ACTION = { type: INIT }; | ||
/** | ||
* Computes the next entry in the log by applying an action. | ||
*/ | ||
* Computes the next entry in the log by applying an action. | ||
* @param {?} reducer | ||
* @param {?} action | ||
* @param {?} state | ||
* @param {?} error | ||
* @return {?} | ||
*/ | ||
function computeNextEntry(reducer, action, state, error) { | ||
if (error) { | ||
return { | ||
state: state, | ||
error: 'Interrupted by an error up the chain' | ||
state, | ||
error: 'Interrupted by an error up the chain', | ||
}; | ||
} | ||
var nextState = state; | ||
var nextError; | ||
let /** @type {?} */ nextState = state; | ||
let /** @type {?} */ nextError; | ||
try { | ||
@@ -26,8 +31,16 @@ nextState = reducer(state, action); | ||
state: nextState, | ||
error: nextError | ||
error: nextError, | ||
}; | ||
} | ||
/** | ||
* Runs the reducer on invalidated actions to get a fresh computation log. | ||
*/ | ||
* Runs the reducer on invalidated actions to get a fresh computation log. | ||
* @param {?} computedStates | ||
* @param {?} minInvalidatedStateIndex | ||
* @param {?} reducer | ||
* @param {?} committedState | ||
* @param {?} actionsById | ||
* @param {?} stagedActionIds | ||
* @param {?} skippedActionIds | ||
* @return {?} | ||
*/ | ||
function recomputeStates(computedStates, minInvalidatedStateIndex, reducer, committedState, actionsById, stagedActionIds, skippedActionIds) { | ||
@@ -40,13 +53,13 @@ // Optimization: exit early and return the same reference | ||
} | ||
var nextComputedStates = computedStates.slice(0, minInvalidatedStateIndex); | ||
for (var i = minInvalidatedStateIndex; i < stagedActionIds.length; i++) { | ||
var actionId = stagedActionIds[i]; | ||
var action = actionsById[actionId].action; | ||
var previousEntry = nextComputedStates[i - 1]; | ||
var previousState = previousEntry ? previousEntry.state : committedState; | ||
var previousError = previousEntry ? previousEntry.error : undefined; | ||
var shouldSkip = skippedActionIds.indexOf(actionId) > -1; | ||
var entry = shouldSkip ? | ||
previousEntry : | ||
computeNextEntry(reducer, action, previousState, previousError); | ||
const /** @type {?} */ nextComputedStates = computedStates.slice(0, minInvalidatedStateIndex); | ||
for (let /** @type {?} */ i = minInvalidatedStateIndex; i < stagedActionIds.length; i++) { | ||
const /** @type {?} */ actionId = stagedActionIds[i]; | ||
const /** @type {?} */ action = actionsById[actionId].action; | ||
const /** @type {?} */ previousEntry = nextComputedStates[i - 1]; | ||
const /** @type {?} */ previousState = previousEntry ? previousEntry.state : committedState; | ||
const /** @type {?} */ previousError = previousEntry ? previousEntry.error : undefined; | ||
const /** @type {?} */ shouldSkip = skippedActionIds.indexOf(actionId) > -1; | ||
const /** @type {?} */ entry = shouldSkip | ||
? previousEntry | ||
: computeNextEntry(reducer, action, previousState, previousError); | ||
nextComputedStates.push(entry); | ||
@@ -56,2 +69,7 @@ } | ||
} | ||
/** | ||
* @param {?=} initialCommittedState | ||
* @param {?=} monitorReducer | ||
* @return {?} | ||
*/ | ||
export function liftInitialState(initialCommittedState, monitorReducer) { | ||
@@ -66,15 +84,19 @@ return { | ||
currentStateIndex: 0, | ||
computedStates: [] | ||
computedStates: [], | ||
}; | ||
} | ||
/** | ||
* Creates a history state reducer from an app's reducer. | ||
*/ | ||
export function liftReducerWith(initialCommittedState, initialLiftedState, monitorReducer, options) { | ||
if (options === void 0) { options = {}; } | ||
* Creates a history state reducer from an app's reducer. | ||
* @param {?} initialCommittedState | ||
* @param {?} initialLiftedState | ||
* @param {?=} monitorReducer | ||
* @param {?=} options | ||
* @return {?} | ||
*/ | ||
export function liftReducerWith(initialCommittedState, initialLiftedState, monitorReducer, options = {}) { | ||
/** | ||
* Manages how the history actions modify the history state. | ||
*/ | ||
return function (reducer) { return function (liftedState, liftedAction) { | ||
var _a = liftedState || initialLiftedState, monitorState = _a.monitorState, actionsById = _a.actionsById, nextActionId = _a.nextActionId, stagedActionIds = _a.stagedActionIds, skippedActionIds = _a.skippedActionIds, committedState = _a.committedState, currentStateIndex = _a.currentStateIndex, computedStates = _a.computedStates; | ||
return (reducer) => (liftedState, liftedAction) => { | ||
let { monitorState, actionsById, nextActionId, stagedActionIds, skippedActionIds, committedState, currentStateIndex, computedStates, } = liftedState || initialLiftedState; | ||
if (!liftedState) { | ||
@@ -84,7 +106,11 @@ // Prevent mutating initialLiftedState | ||
} | ||
/** | ||
* @param {?} n | ||
* @return {?} | ||
*/ | ||
function commitExcessActions(n) { | ||
// Auto-commits n-number of excess actions. | ||
var excess = n; | ||
var idsToDelete = stagedActionIds.slice(1, excess + 1); | ||
for (var i = 0; i < idsToDelete.length; i++) { | ||
let /** @type {?} */ excess = n; | ||
let /** @type {?} */ idsToDelete = stagedActionIds.slice(1, excess + 1); | ||
for (let /** @type {?} */ i = 0; i < idsToDelete.length; i++) { | ||
if (computedStates[i + 1].error) { | ||
@@ -100,9 +126,8 @@ // Stop if error is found. Commit actions up to error. | ||
} | ||
skippedActionIds = skippedActionIds.filter(function (id) { return idsToDelete.indexOf(id) === -1; }); | ||
stagedActionIds = [0].concat(stagedActionIds.slice(excess + 1)); | ||
skippedActionIds = skippedActionIds.filter(id => idsToDelete.indexOf(id) === -1); | ||
stagedActionIds = [0, ...stagedActionIds.slice(excess + 1)]; | ||
committedState = computedStates[excess].state; | ||
computedStates = computedStates.slice(excess); | ||
currentStateIndex = currentStateIndex > excess | ||
? currentStateIndex - excess | ||
: 0; | ||
currentStateIndex = | ||
currentStateIndex > excess ? currentStateIndex - excess : 0; | ||
} | ||
@@ -112,5 +137,5 @@ // By default, agressively recompute every state whatever happens. | ||
// value whenever we feel like we don't have to recompute the states. | ||
var minInvalidatedStateIndex = 0; | ||
let /** @type {?} */ minInvalidatedStateIndex = 0; | ||
switch (liftedAction.type) { | ||
case ActionTypes.RESET: { | ||
case Actions.RESET: { | ||
// Get back to the state the store was created with. | ||
@@ -126,3 +151,3 @@ actionsById = { 0: liftAction(INIT_ACTION) }; | ||
} | ||
case ActionTypes.COMMIT: { | ||
case Actions.COMMIT: { | ||
// Consider the last committed state the new starting point. | ||
@@ -139,3 +164,3 @@ // Squash any staged actions into a single committed state. | ||
} | ||
case ActionTypes.ROLLBACK: { | ||
case Actions.ROLLBACK: { | ||
// Forget about any staged actions. | ||
@@ -151,23 +176,23 @@ // Start again from the last committed state. | ||
} | ||
case ActionTypes.TOGGLE_ACTION: { | ||
case Actions.TOGGLE_ACTION: { | ||
// Toggle whether an action with given ID is skipped. | ||
// Being skipped means it is a no-op during the computation. | ||
var actionId_1 = liftedAction.id; | ||
var index = skippedActionIds.indexOf(actionId_1); | ||
const { id: actionId } = liftedAction; | ||
const /** @type {?} */ index = skippedActionIds.indexOf(actionId); | ||
if (index === -1) { | ||
skippedActionIds = [actionId_1].concat(skippedActionIds); | ||
skippedActionIds = [actionId, ...skippedActionIds]; | ||
} | ||
else { | ||
skippedActionIds = skippedActionIds.filter(function (id) { return id !== actionId_1; }); | ||
skippedActionIds = skippedActionIds.filter(id => id !== actionId); | ||
} | ||
// Optimization: we know history before this action hasn't changed | ||
minInvalidatedStateIndex = stagedActionIds.indexOf(actionId_1); | ||
minInvalidatedStateIndex = stagedActionIds.indexOf(actionId); | ||
break; | ||
} | ||
case ActionTypes.SET_ACTIONS_ACTIVE: { | ||
case Actions.SET_ACTIONS_ACTIVE: { | ||
// Toggle whether an action with given ID is skipped. | ||
// Being skipped means it is a no-op during the computation. | ||
var start = liftedAction.start, end = liftedAction.end, active = liftedAction.active; | ||
var actionIds = []; | ||
for (var i = start; i < end; i++) | ||
const { start, end, active } = liftedAction; | ||
const /** @type {?} */ actionIds = []; | ||
for (let /** @type {?} */ i = start; i < end; i++) | ||
actionIds.push(i); | ||
@@ -178,3 +203,3 @@ if (active) { | ||
else { | ||
skippedActionIds = skippedActionIds.concat(actionIds); | ||
skippedActionIds = [...skippedActionIds, ...actionIds]; | ||
} | ||
@@ -185,3 +210,3 @@ // Optimization: we know history before this action hasn't changed | ||
} | ||
case ActionTypes.JUMP_TO_STATE: { | ||
case Actions.JUMP_TO_STATE: { | ||
// Without recomputing anything, move the pointer that tell us | ||
@@ -194,3 +219,3 @@ // which state is considered the current one. Useful for sliders. | ||
} | ||
case ActionTypes.SWEEP: { | ||
case Actions.SWEEP: { | ||
// Forget any actions that are currently being skipped. | ||
@@ -202,3 +227,3 @@ stagedActionIds = difference(stagedActionIds, skippedActionIds); | ||
} | ||
case ActionTypes.PERFORM_ACTION: { | ||
case Actions.PERFORM_ACTION: { | ||
// Auto-commit as new actions come in. | ||
@@ -211,7 +236,7 @@ if (options.maxAge && stagedActionIds.length === options.maxAge) { | ||
} | ||
var actionId = nextActionId++; | ||
const /** @type {?} */ actionId = nextActionId++; | ||
// Mutation! This is the hottest path, and we optimize on purpose. | ||
// It is safe because we set a new key in a cache dictionary. | ||
actionsById[actionId] = liftedAction; | ||
stagedActionIds = stagedActionIds.concat([actionId]); | ||
stagedActionIds = [...stagedActionIds, actionId]; | ||
// Optimization: we know that only the new action needs computing. | ||
@@ -221,9 +246,18 @@ minInvalidatedStateIndex = stagedActionIds.length - 1; | ||
} | ||
case ActionTypes.IMPORT_STATE: { | ||
case Actions.IMPORT_STATE: { | ||
// Completely replace everything. | ||
(_b = liftedAction.nextLiftedState, monitorState = _b.monitorState, actionsById = _b.actionsById, nextActionId = _b.nextActionId, stagedActionIds = _b.stagedActionIds, skippedActionIds = _b.skippedActionIds, committedState = _b.committedState, currentStateIndex = _b.currentStateIndex, computedStates = _b.computedStates); | ||
({ | ||
monitorState, | ||
actionsById, | ||
nextActionId, | ||
stagedActionIds, | ||
skippedActionIds, | ||
committedState, | ||
currentStateIndex, | ||
computedStates, | ||
} = liftedAction.nextLiftedState); | ||
break; | ||
} | ||
case Reducer.REPLACE: | ||
case Dispatcher.INIT: { | ||
case UPDATE: | ||
case INIT: { | ||
// Always recompute states on hot reload and init. | ||
@@ -250,14 +284,13 @@ minInvalidatedStateIndex = 0; | ||
return { | ||
monitorState: monitorState, | ||
actionsById: actionsById, | ||
nextActionId: nextActionId, | ||
stagedActionIds: stagedActionIds, | ||
skippedActionIds: skippedActionIds, | ||
committedState: committedState, | ||
currentStateIndex: currentStateIndex, | ||
computedStates: computedStates | ||
monitorState, | ||
actionsById, | ||
nextActionId, | ||
stagedActionIds, | ||
skippedActionIds, | ||
committedState, | ||
currentStateIndex, | ||
computedStates, | ||
}; | ||
var _b; | ||
}; }; | ||
}; | ||
} | ||
//# sourceMappingURL=reducer.js.map |
import { Action } from '@ngrx/store'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import { LiftedState } from './reducer'; | ||
import * as Actions from './actions'; | ||
export declare function difference(first: any[], second: any[]): any[]; | ||
@@ -15,7 +16,3 @@ /** | ||
*/ | ||
export declare function liftAction(action: any): { | ||
type: string; | ||
action: any; | ||
timestamp: number; | ||
}; | ||
export declare function liftAction(action: Action): Actions.PerformAction; | ||
export declare function applyOperators(input$: Observable<any>, operators: any[][]): Observable<any>; |
@@ -1,13 +0,24 @@ | ||
import { StoreDevtoolActions } from './actions'; | ||
import * as Actions from './actions'; | ||
/** | ||
* @param {?} first | ||
* @param {?} second | ||
* @return {?} | ||
*/ | ||
export function difference(first, second) { | ||
return first.filter(function (item) { return second.indexOf(item) < 0; }); | ||
return first.filter(item => second.indexOf(item) < 0); | ||
} | ||
/** | ||
* Provides an app's view into the state of the lifted store. | ||
* @param {?} liftedState | ||
* @return {?} | ||
*/ | ||
export function unliftState(liftedState) { | ||
var computedStates = liftedState.computedStates, currentStateIndex = liftedState.currentStateIndex; | ||
var state = computedStates[currentStateIndex].state; | ||
const { computedStates, currentStateIndex } = liftedState; | ||
const { state } = computedStates[currentStateIndex]; | ||
return state; | ||
} | ||
/** | ||
* @param {?} liftedState | ||
* @return {?} | ||
*/ | ||
export function unliftAction(liftedState) { | ||
@@ -17,10 +28,16 @@ return liftedState.actionsById[liftedState.nextActionId - 1]; | ||
/** | ||
* Lifts an app's action into an action on the lifted store. | ||
*/ | ||
* Lifts an app's action into an action on the lifted store. | ||
* @param {?} action | ||
* @return {?} | ||
*/ | ||
export function liftAction(action) { | ||
return StoreDevtoolActions.performAction(action); | ||
return new Actions.PerformAction(action); | ||
} | ||
/** | ||
* @param {?} input$ | ||
* @param {?} operators | ||
* @return {?} | ||
*/ | ||
export function applyOperators(input$, operators) { | ||
return operators.reduce(function (source$, _a) { | ||
var operator = _a[0], args = _a.slice(1); | ||
return operators.reduce((source$, [operator, ...args]) => { | ||
return operator.apply(source$, args); | ||
@@ -27,0 +44,0 @@ }, input$); |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
349170
0
3514
32
7
6