Socket
Socket
Sign inDemoInstall

redux-devtools-instrument

Package Overview
Dependencies
2
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.9.0 to 1.9.1

105

lib/instrument.js

@@ -8,3 +8,3 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

@@ -55,3 +55,3 @@ exports.liftAction = liftAction;

var ActionCreators = exports.ActionCreators = {
performAction: function performAction(action) {
performAction: function performAction(action, shouldIncludeCallstack) {
if (!(0, _isPlainObject2.default)(action)) {

@@ -65,3 +65,6 @@ throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');

return { type: ActionTypes.PERFORM_ACTION, action: action, timestamp: Date.now() };
return {
type: ActionTypes.PERFORM_ACTION, action: action, timestamp: Date.now(),
stack: shouldIncludeCallstack ? Error().stack : undefined
};
},

@@ -84,3 +87,3 @@ reset: function reset() {

setActionsActive: function setActionsActive(start, end) {
var active = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var active = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2];

@@ -188,4 +191,4 @@ return { type: ActionTypes.SET_ACTIONS_ACTIVE, start: start, end: end, active: active };

*/
function liftAction(action) {
return ActionCreators.performAction(action);
function liftAction(action, shouldIncludeCallstack) {
return ActionCreators.performAction(action, shouldIncludeCallstack);
}

@@ -214,14 +217,16 @@

return function (liftedState, liftedAction) {
var _ref = liftedState || initialLiftedState,
monitorState = _ref.monitorState,
actionsById = _ref.actionsById,
nextActionId = _ref.nextActionId,
stagedActionIds = _ref.stagedActionIds,
skippedActionIds = _ref.skippedActionIds,
committedState = _ref.committedState,
currentStateIndex = _ref.currentStateIndex,
computedStates = _ref.computedStates,
isLocked = _ref.isLocked,
isPaused = _ref.isPaused;
var _ref = liftedState || initialLiftedState;
var monitorState = _ref.monitorState;
var actionsById = _ref.actionsById;
var nextActionId = _ref.nextActionId;
var stagedActionIds = _ref.stagedActionIds;
var skippedActionIds = _ref.skippedActionIds;
var committedState = _ref.committedState;
var currentStateIndex = _ref.currentStateIndex;
var computedStates = _ref.computedStates;
var isLocked = _ref.isLocked;
var isPaused = _ref.isPaused;
if (!liftedState) {

@@ -393,17 +398,21 @@ // Prevent mutating initialLiftedState

{
// Toggle whether an action with given ID is skipped.
// Being skipped means it is a no-op during the computation.
var _actionId = liftedAction.id;
var _ret = function () {
// Toggle whether an action with given ID is skipped.
// Being skipped means it is a no-op during the computation.
var actionId = liftedAction.id;
var index = skippedActionIds.indexOf(_actionId);
if (index === -1) {
skippedActionIds = [_actionId].concat(skippedActionIds);
} else {
skippedActionIds = skippedActionIds.filter(function (id) {
return id !== _actionId;
});
}
// Optimization: we know history before this action hasn't changed
minInvalidatedStateIndex = stagedActionIds.indexOf(_actionId);
break;
var index = skippedActionIds.indexOf(actionId);
if (index === -1) {
skippedActionIds = [actionId].concat(skippedActionIds);
} else {
skippedActionIds = skippedActionIds.filter(function (id) {
return id !== actionId;
});
}
// Optimization: we know history before this action hasn't changed
minInvalidatedStateIndex = stagedActionIds.indexOf(actionId);
return 'break';
}();
if (_ret === 'break') break;
}

@@ -414,5 +423,5 @@ case ActionTypes.SET_ACTIONS_ACTIVE:

// Being skipped means it is a no-op during the computation.
var start = liftedAction.start,
end = liftedAction.end,
active = liftedAction.active;
var start = liftedAction.start;
var end = liftedAction.end;
var active = liftedAction.active;

@@ -461,4 +470,4 @@ var actionIds = [];

// Recompute actions in a new order.
var _actionId2 = liftedAction.actionId;
var idx = stagedActionIds.indexOf(_actionId2);
var _actionId = liftedAction.actionId;
var idx = stagedActionIds.indexOf(_actionId);
// do nothing in case the action is already removed or trying to move the first action

@@ -477,7 +486,7 @@ if (idx < 1) break;

// move left
stagedActionIds = [].concat(stagedActionIds.slice(0, newIdx), [_actionId2], stagedActionIds.slice(newIdx, idx), stagedActionIds.slice(idx + 1));
stagedActionIds = [].concat(stagedActionIds.slice(0, newIdx), [_actionId], stagedActionIds.slice(newIdx, idx), stagedActionIds.slice(idx + 1));
minInvalidatedStateIndex = newIdx;
} else if (diff < 0) {
// move right
stagedActionIds = [].concat(stagedActionIds.slice(0, idx), stagedActionIds.slice(idx + 1, newIdx), [_actionId2], stagedActionIds.slice(newIdx));
stagedActionIds = [].concat(stagedActionIds.slice(0, idx), stagedActionIds.slice(idx + 1, newIdx), [_actionId], stagedActionIds.slice(newIdx));
minInvalidatedStateIndex = idx;

@@ -501,3 +510,3 @@ }

liftedAction.nextLiftedState.forEach(function (action) {
actionsById[nextActionId] = liftAction(action);
actionsById[nextActionId] = liftAction(action, options.shouldIncludeCallstack);
stagedActionIds.push(nextActionId);

@@ -580,4 +589,4 @@ nextActionId++;

function unliftState(liftedState) {
var computedStates = liftedState.computedStates,
currentStateIndex = liftedState.currentStateIndex;
var computedStates = liftedState.computedStates;
var currentStateIndex = liftedState.currentStateIndex;
var state = computedStates[currentStateIndex].state;

@@ -591,7 +600,9 @@

*/
function unliftStore(liftedStore, liftReducer) {
function unliftStore(liftedStore, liftReducer, options) {
var _extends3;
var lastDefinedState = void 0;
var shouldIncludeCallstack = options.shouldIncludeCallstack;
function getState() {

@@ -610,3 +621,3 @@ var state = unliftState(liftedStore.getState());

dispatch: function dispatch(action) {
liftedStore.dispatch(liftAction(action));
liftedStore.dispatch(liftAction(action, shouldIncludeCallstack));
return action;

@@ -646,6 +657,6 @@ },

function instrument() {
var monitorReducer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
var monitorReducer = arguments.length <= 0 || arguments[0] === undefined ? function () {
return null;
};
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
} : arguments[0];
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

@@ -676,5 +687,5 @@ /* eslint-disable no-eq-null */

return unliftStore(liftedStore, liftReducer);
return unliftStore(liftedStore, liftReducer, options);
};
};
}
{
"name": "redux-devtools-instrument",
"version": "1.9.0",
"version": "1.9.1",
"description": "Redux DevTools instrumentation",

@@ -5,0 +5,0 @@ "main": "lib/instrument.js",

@@ -53,2 +53,3 @@ Redux DevTools Instrumentation

- **shouldHotReload** *boolean* - if set to `false`, will not recompute the states on hot reloading (or on replacing the reducers). Default to `true`.
- **shouldIncludeCallstack** *boolean* - if set to `true`, will include callstack for every dispatched action. Default to `false`.

@@ -55,0 +56,0 @@ ### License

@@ -26,3 +26,3 @@ import difference from 'lodash/difference';

export const ActionCreators = {
performAction(action) {
performAction(action, shouldIncludeCallstack) {
if (!isPlainObject(action)) {

@@ -42,3 +42,6 @@ throw new Error(

return { type: ActionTypes.PERFORM_ACTION, action, timestamp: Date.now() };
return {
type: ActionTypes.PERFORM_ACTION, action, timestamp: Date.now(),
stack: shouldIncludeCallstack ? Error().stack : undefined
};
},

@@ -190,4 +193,4 @@

*/
export function liftAction(action) {
return ActionCreators.performAction(action);
export function liftAction(action, shouldIncludeCallstack) {
return ActionCreators.performAction(action, shouldIncludeCallstack);
}

@@ -501,3 +504,3 @@

liftedAction.nextLiftedState.forEach(action => {
actionsById[nextActionId] = liftAction(action);
actionsById[nextActionId] = liftAction(action, options.shouldIncludeCallstack);
stagedActionIds.push(nextActionId);

@@ -593,4 +596,5 @@ nextActionId++;

*/
export function unliftStore(liftedStore, liftReducer) {
export function unliftStore(liftedStore, liftReducer, options) {
let lastDefinedState;
const { shouldIncludeCallstack } = options;

@@ -611,3 +615,3 @@ function getState() {

dispatch(action) {
liftedStore.dispatch(liftAction(action));
liftedStore.dispatch(liftAction(action, shouldIncludeCallstack));
return action;

@@ -683,4 +687,4 @@ },

return unliftStore(liftedStore, liftReducer);
return unliftStore(liftedStore, liftReducer, options);
};
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc