mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-27 00:19:55 +03:00
stash
This commit is contained in:
parent
1c5cc0604f
commit
4448ac51ce
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"root": true,
|
||||
"extends": "eslint-config-airbnb",
|
||||
"globals": {
|
||||
"chrome": true,
|
||||
|
|
|
@ -49,7 +49,7 @@ gulp.task('webpack:dev', (callback) => {
|
|||
callback();
|
||||
});
|
||||
|
||||
gulp.task('views:dev', () => {
|
||||
gulp.task('views:dev', (done) => {
|
||||
gulp
|
||||
.src('./src/browser/views/*.pug')
|
||||
.pipe(
|
||||
|
@ -58,14 +58,16 @@ gulp.task('views:dev', () => {
|
|||
})
|
||||
)
|
||||
.pipe(gulp.dest('./dev'));
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('copy:dev', () => {
|
||||
gulp.task('copy:dev', (done) => {
|
||||
gulp
|
||||
.src('./src/browser/extension/manifest.json')
|
||||
.pipe(rename('manifest.json'))
|
||||
.pipe(gulp.dest('./dev'));
|
||||
copy('./dev');
|
||||
done();
|
||||
});
|
||||
|
||||
/*
|
||||
|
@ -121,18 +123,20 @@ gulp.task('copy:build:extension', (done) => {
|
|||
* compress task
|
||||
*/
|
||||
|
||||
gulp.task('compress:extension', () => {
|
||||
gulp.task('compress:extension', (done) => {
|
||||
gulp
|
||||
.src('build/extension/**')
|
||||
.pipe(zip('extension.zip'))
|
||||
.pipe(gulp.dest('./build'));
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('compress:firefox', () => {
|
||||
gulp.task('compress:firefox', (done) => {
|
||||
gulp
|
||||
.src('build/firefox/**')
|
||||
.pipe(zip('firefox.zip'))
|
||||
.pipe(gulp.dest('./build'));
|
||||
done();
|
||||
});
|
||||
|
||||
/*
|
||||
|
@ -187,7 +191,7 @@ gulp.task('copy:build:firefox', gulp.series('build:extension', (done) => {
|
|||
'!./build/extension/js/redux-devtools-extension.js',
|
||||
])
|
||||
.pipe(gulp.dest('./build/firefox'))
|
||||
.on('finish', function () {
|
||||
.on('finish', function() {
|
||||
gulp
|
||||
.src('./src/browser/firefox/manifest.json')
|
||||
.pipe(gulp.dest('./build/firefox'));
|
||||
|
|
|
@ -31,8 +31,9 @@ export function isFiltered(action, localFilter) {
|
|||
if (
|
||||
noFiltersApplied(localFilter) ||
|
||||
(typeof action !== 'string' && typeof action.type.match !== 'function')
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const { whitelist, blacklist } = localFilter || window.devToolsOptions || {};
|
||||
const actionType = action.type || action;
|
||||
|
@ -67,8 +68,9 @@ export function filterState(
|
|||
nextActionId,
|
||||
predicate
|
||||
) {
|
||||
if (type === 'ACTION')
|
||||
if (type === 'ACTION') {
|
||||
return !stateSanitizer ? state : stateSanitizer(state, nextActionId - 1);
|
||||
}
|
||||
else if (type !== 'STATE') return state;
|
||||
|
||||
if (predicate || !noFiltersApplied(localFilter)) {
|
||||
|
@ -151,8 +153,9 @@ export function startingFrom(
|
|||
if (
|
||||
(predicate && !predicate(currState.state, currAction.action)) ||
|
||||
isFiltered(currAction.action, localFilter)
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
filteredStagedActionIds.push(key);
|
||||
if (i < index) continue;
|
||||
}
|
||||
|
|
|
@ -3,9 +3,10 @@ import jsan from 'jsan';
|
|||
import seralizeImmutable from 'remotedev-serialize/immutable/serialize';
|
||||
|
||||
function deprecate(param) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
`\`${param}\` parameter for Redux DevTools Extension is deprecated. Use \`serialize\` parameter instead: https://github.com/zalmoxisus/redux-devtools-extension/releases/tag/v2.12.1`
|
||||
); // eslint-disable-line
|
||||
);
|
||||
}
|
||||
|
||||
export default function importState(
|
||||
|
@ -34,8 +35,9 @@ export default function importState(
|
|||
let preloadedState;
|
||||
let nextLiftedState = parse(state);
|
||||
if (nextLiftedState.payload) {
|
||||
if (nextLiftedState.preloadedState)
|
||||
if (nextLiftedState.preloadedState) {
|
||||
preloadedState = parse(nextLiftedState.preloadedState);
|
||||
}
|
||||
nextLiftedState = parse(nextLiftedState.payload);
|
||||
}
|
||||
if (deserializeState) {
|
||||
|
|
|
@ -21,8 +21,9 @@ function tryCatchStringify(obj) {
|
|||
return JSON.stringify(obj);
|
||||
} catch (err) {
|
||||
/* eslint-disable no-console */
|
||||
if (process.env.NODE_ENV !== 'production')
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
console.log('Failed to stringify', err);
|
||||
}
|
||||
/* eslint-enable no-console */
|
||||
return jsan.stringify(obj, windowReplacer, null, {
|
||||
circular: '[CIRCULAR]',
|
||||
|
@ -71,8 +72,9 @@ export function getSeralizeParameter(config, param) {
|
|||
: immutableSerializer.options,
|
||||
};
|
||||
}
|
||||
if (!serialize.replacer && !serialize.reviver)
|
||||
if (!serialize.replacer && !serialize.reviver) {
|
||||
return { options: serialize.options };
|
||||
}
|
||||
return {
|
||||
replacer: serialize.replacer,
|
||||
reviver: serialize.reviver,
|
||||
|
@ -82,9 +84,10 @@ export function getSeralizeParameter(config, param) {
|
|||
|
||||
const value = config[param];
|
||||
if (typeof value === 'undefined') return undefined;
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
`\`${param}\` parameter for Redux DevTools Extension is deprecated. Use \`serialize\` parameter instead: https://github.com/zalmoxisus/redux-devtools-extension/releases/tag/v2.12.1`
|
||||
); // eslint-disable-line
|
||||
);
|
||||
|
||||
if (typeof serializeState === 'boolean') return { options: value };
|
||||
if (typeof serializeState === 'function') return { replacer: value };
|
||||
|
@ -133,8 +136,9 @@ function getStackTrace(config, toExcludeFromTrace) {
|
|||
function amendActionType(action, config, toExcludeFromTrace) {
|
||||
let timestamp = Date.now();
|
||||
let stack = getStackTrace(config, toExcludeFromTrace);
|
||||
if (typeof action === 'string')
|
||||
if (typeof action === 'string') {
|
||||
return { action: { type: action }, timestamp, stack };
|
||||
}
|
||||
if (!action.type) return { action: { type: 'update' }, timestamp, stack };
|
||||
if (action.action) return stack ? { stack, ...action } : action;
|
||||
return { action, timestamp, stack };
|
||||
|
@ -187,17 +191,19 @@ export function sendMessage(action, state, config, instanceId, name) {
|
|||
}
|
||||
|
||||
function handleMessages(event) {
|
||||
if (process.env.BABEL_ENV !== 'test' && (!event || event.source !== window))
|
||||
if (process.env.BABEL_ENV !== 'test' && (!event || event.source !== window)) {
|
||||
return;
|
||||
}
|
||||
const message = event.data;
|
||||
if (!message || message.source !== '@devtools-extension') return;
|
||||
Object.keys(listeners).forEach((id) => {
|
||||
if (message.id && id !== message.id) return;
|
||||
if (typeof listeners[id] === 'function') listeners[id](message);
|
||||
else
|
||||
else {
|
||||
listeners[id].forEach((fn) => {
|
||||
fn(message);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -229,9 +235,10 @@ export function connect(preConfig) {
|
|||
const config = preConfig || {};
|
||||
const id = generateId(config.instanceId);
|
||||
if (!config.instanceId) config.instanceId = id;
|
||||
if (!config.name)
|
||||
if (!config.name) {
|
||||
config.name =
|
||||
document.title && id === 1 ? document.title : `Instance ${id}`;
|
||||
}
|
||||
if (config.serialize) config.serialize = getSeralizeParameter(config);
|
||||
const actionCreators = config.actionCreators || {};
|
||||
const latency = config.latency;
|
||||
|
@ -306,8 +313,9 @@ export function connect(preConfig) {
|
|||
timestamp: Date.now(),
|
||||
};
|
||||
}
|
||||
} else if (config.actionSanitizer)
|
||||
} else if (config.actionSanitizer) {
|
||||
amendedAction = config.actionSanitizer(action);
|
||||
}
|
||||
amendedAction = amendActionType(amendedAction, config, send);
|
||||
if (latency) {
|
||||
delayedActions.push(amendedAction);
|
||||
|
@ -364,7 +372,7 @@ export function connect(preConfig) {
|
|||
}
|
||||
|
||||
export function updateStore(stores) {
|
||||
return function (newStore, instanceId) {
|
||||
return function(newStore, instanceId) {
|
||||
/* eslint-disable no-console */
|
||||
console.warn(
|
||||
'`__REDUX_DEVTOOLS_EXTENSION__.updateStore` is deprecated, remove it and just use ' +
|
||||
|
|
|
@ -3,7 +3,7 @@ let lastTime = 0;
|
|||
|
||||
function createExpBackoffTimer(step) {
|
||||
let count = 1;
|
||||
return function (reset) {
|
||||
return function(reset) {
|
||||
// Reset call
|
||||
if (reset) {
|
||||
count = 1;
|
||||
|
@ -34,8 +34,9 @@ function catchErrors(e) {
|
|||
if (
|
||||
(window.devToolsOptions && !window.devToolsOptions.shouldCatchErrors) ||
|
||||
e.timeStamp - lastTime < nextErrorTimeout()
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
lastTime = e.timeStamp;
|
||||
nextErrorTimeout(true);
|
||||
postError(e.message);
|
||||
|
|
|
@ -31,8 +31,9 @@ export default class Monitor {
|
|||
isPaused = () => {
|
||||
if (this.paused) {
|
||||
if (this.lastAction !== 'BLOCKED') {
|
||||
if (!window.__REDUX_DEVTOOLS_EXTENSION_LOCKED__)
|
||||
if (!window.__REDUX_DEVTOOLS_EXTENSION_LOCKED__) {
|
||||
this.lastAction = 'BLOCKED';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -28,7 +28,7 @@ export function getReport(reportId, tabId, instanceId) {
|
|||
instanceId: `${tabId}/${instanceId}`,
|
||||
});
|
||||
})
|
||||
.catch(function (err) {
|
||||
.catch(function(err) {
|
||||
/* eslint-disable no-console */
|
||||
console.warn(err);
|
||||
/* eslint-enable no-console */
|
||||
|
|
|
@ -9,8 +9,9 @@ export default function openDevToolsWindow(position) {
|
|||
lastPosition = position;
|
||||
} else {
|
||||
let params = { focused: true };
|
||||
if (lastPosition !== position && position !== 'devtools-panel')
|
||||
if (lastPosition !== position && position !== 'devtools-panel') {
|
||||
params = { ...params, ...customOptions };
|
||||
}
|
||||
chrome.windows.update(windows[position], params, () => {
|
||||
lastPosition = null;
|
||||
if (chrome.runtime.lastError) callback();
|
||||
|
|
|
@ -76,7 +76,7 @@ if (window.isElectron) {
|
|||
}
|
||||
// Avoid error: chrome.runtime.sendMessage is not supported responseCallback
|
||||
const originSendMessage = chrome.runtime.sendMessage;
|
||||
chrome.runtime.sendMessage = function () {
|
||||
chrome.runtime.sendMessage = function() {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
return originSendMessage(...arguments);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ function createPanel(url) {
|
|||
'Redux',
|
||||
'img/logo/scalable.png',
|
||||
url,
|
||||
function () {}
|
||||
function() {}
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -93,8 +93,9 @@ function tryCatch(fn, args) {
|
|||
}
|
||||
handleDisconnect();
|
||||
/* eslint-disable no-console */
|
||||
if (process.env.NODE_ENV !== 'production')
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
console.error('Failed to send message', err);
|
||||
}
|
||||
/* eslint-enable no-console */
|
||||
}
|
||||
}
|
||||
|
@ -112,8 +113,9 @@ function send(message) {
|
|||
// Resend messages from the page to the background script
|
||||
function handleMessages(event) {
|
||||
if (!isAllowed()) return;
|
||||
if (!event || event.source !== window || typeof event.data !== 'object')
|
||||
if (!event || event.source !== window || typeof event.data !== 'object') {
|
||||
return;
|
||||
}
|
||||
const message = event.data;
|
||||
if (message.source !== pageSource) return;
|
||||
if (message.type === 'DISCONNECT') {
|
||||
|
|
|
@ -8,7 +8,7 @@ require('./pageScript');
|
|||
chrome.runtime.sendMessage(
|
||||
window.devToolsExtensionID,
|
||||
{ type: 'GET_OPTIONS' },
|
||||
function (response) {
|
||||
function(response) {
|
||||
if (!response.options.inject) {
|
||||
const urls = response.options.urls.split('\n').filter(Boolean).join('|');
|
||||
if (!location.href.match(new RegExp(urls))) return;
|
||||
|
|
|
@ -38,7 +38,7 @@ function deprecateParam(oldParam, newParam) {
|
|||
/* eslint-enable no-console */
|
||||
}
|
||||
|
||||
const __REDUX_DEVTOOLS_EXTENSION__ = function (
|
||||
const __REDUX_DEVTOOLS_EXTENSION__ = function(
|
||||
reducer,
|
||||
preloadedState,
|
||||
config
|
||||
|
@ -164,8 +164,9 @@ const __REDUX_DEVTOOLS_EXTENSION__ = function (
|
|||
isFiltered(action, localFilter) ||
|
||||
(predicate &&
|
||||
!predicate(computedStates[computedStates.length - 1].state, action))
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const state =
|
||||
liftedState.computedStates[liftedState.computedStates.length - 1].state;
|
||||
relay(
|
||||
|
@ -233,8 +234,9 @@ const __REDUX_DEVTOOLS_EXTENSION__ = function (
|
|||
if (
|
||||
!features.jump &&
|
||||
(type === 'JUMP_TO_STATE' || type === 'JUMP_TO_ACTION')
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (!features.skip && type === 'TOGGLE_ACTION') return;
|
||||
if (!features.reorder && type === 'REORDER_ACTION') return;
|
||||
if (!features.import && type === 'IMPORT_STATE') return;
|
||||
|
@ -297,8 +299,9 @@ const __REDUX_DEVTOOLS_EXTENSION__ = function (
|
|||
const filteredActionIds = []; // simple circular buffer of non-excluded actions with fixed maxAge-1 length
|
||||
const getMaxAge = (liftedAction, liftedState) => {
|
||||
let m = (config && config.maxAge) || window.devToolsOptions.maxAge || 50;
|
||||
if (!liftedAction || noFiltersApplied(localFilter) || !liftedAction.action)
|
||||
if (!liftedAction || noFiltersApplied(localFilter) || !liftedAction.action) {
|
||||
return m;
|
||||
}
|
||||
if (!maxAge || maxAge < m) maxAge = m; // it can be modified in process on options page
|
||||
if (isFiltered(liftedAction.action, localFilter)) {
|
||||
// TODO: check also predicate && !predicate(state, action) with current state
|
||||
|
@ -347,8 +350,9 @@ const __REDUX_DEVTOOLS_EXTENSION__ = function (
|
|||
relayAction();
|
||||
return;
|
||||
}
|
||||
if (monitor.isPaused() || monitor.isLocked() || monitor.isTimeTraveling())
|
||||
if (monitor.isPaused() || monitor.isLocked() || monitor.isTimeTraveling()) {
|
||||
return;
|
||||
}
|
||||
const liftedState = store.liftedStore.getState();
|
||||
if (
|
||||
errorOccurred &&
|
||||
|
@ -361,8 +365,9 @@ const __REDUX_DEVTOOLS_EXTENSION__ = function (
|
|||
|
||||
const enhance = () => (next) => {
|
||||
return (reducer_, initialState_, enhancer_) => {
|
||||
if (!isAllowed(window.devToolsOptions))
|
||||
if (!isAllowed(window.devToolsOptions)) {
|
||||
return next(reducer_, initialState_, enhancer_);
|
||||
}
|
||||
|
||||
store = stores[instanceId] = configureStore(next, monitor.reducer, {
|
||||
...config,
|
||||
|
|
|
@ -8,7 +8,7 @@ if (process.env.NODE_ENV === 'production') {
|
|||
s.parentNode.removeChild(s);
|
||||
} else {
|
||||
s.src = chrome.extension.getURL('js/page.bundle.js');
|
||||
s.onload = function () {
|
||||
s.onload = function() {
|
||||
this.parentNode.removeChild(this);
|
||||
};
|
||||
(document.head || document.documentElement).appendChild(s);
|
||||
|
|
|
@ -47,7 +47,7 @@ const get = (callback) => {
|
|||
'^https?://localhost|0\\.0\\.0\\.0:\\d+\n^https?://.+\\.github\\.io',
|
||||
showContextMenus: true,
|
||||
},
|
||||
function (items) {
|
||||
function(items) {
|
||||
options = migrateOldOptions(items);
|
||||
callback(options);
|
||||
}
|
||||
|
|
|
@ -16,8 +16,9 @@ getPreloadedState(position, (state) => {
|
|||
chrome.runtime.getBackgroundPage(({ store }) => {
|
||||
const localStore = configureStore(store, position, preloadedState);
|
||||
let name = 'monitor';
|
||||
if (chrome && chrome.devtools && chrome.devtools.inspectedWindow)
|
||||
if (chrome && chrome.devtools && chrome.devtools.inspectedWindow) {
|
||||
name += chrome.devtools.inspectedWindow.tabId;
|
||||
}
|
||||
const bg = chrome.runtime.connect({ name });
|
||||
const update = (action) => {
|
||||
localStore.dispatch(action || { type: UPDATE_STATE });
|
||||
|
|
|
@ -22,10 +22,10 @@ chrome.storage.local.get(
|
|||
socketOptions={
|
||||
options['s:hostname'] && options['s:port']
|
||||
? {
|
||||
hostname: options['s:hostname'],
|
||||
port: options['s:port'],
|
||||
secure: options['s:secure'],
|
||||
}
|
||||
hostname: options['s:hostname'],
|
||||
port: options['s:port'],
|
||||
secure: options['s:secure'],
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>,
|
||||
|
|
|
@ -8,7 +8,7 @@ const path = resolve('build/extension');
|
|||
const extensionId = 'lmhkpmbekcpmknklioeibfkpmmfibljd';
|
||||
const actionsPattern = /^@@INIT(.|\n)+@@reduxReactRouter\/routerDidChange(.|\n)+@@reduxReactRouter\/initRoutes(.|\n)+$/;
|
||||
|
||||
describe('Chrome extension', function () {
|
||||
describe('Chrome extension', function() {
|
||||
this.timeout(20000);
|
||||
|
||||
before(async () => {
|
||||
|
|
|
@ -7,7 +7,7 @@ import { switchMonitorTests, delay } from '../utils/e2e';
|
|||
const port = 9515;
|
||||
const devPanelPath = 'chrome-extension://redux-devtools/devpanel.html';
|
||||
|
||||
describe('DevTools panel for Electron', function () {
|
||||
describe('DevTools panel for Electron', function() {
|
||||
this.timeout(10000);
|
||||
|
||||
before(async () => {
|
||||
|
@ -36,7 +36,7 @@ describe('DevTools panel for Electron', function () {
|
|||
|
||||
await this.driver.manage().timeouts().pageLoadTimeout(5000);
|
||||
|
||||
const id = await this.driver.executeAsyncScript(function (callback) {
|
||||
const id = await this.driver.executeAsyncScript(function(callback) {
|
||||
let attempts = 5;
|
||||
function showReduxPanel() {
|
||||
if (attempts === 0) {
|
||||
|
|
|
@ -4,7 +4,7 @@ export const delay = (time) =>
|
|||
new Promise((resolve) => setTimeout(resolve, time));
|
||||
|
||||
export const switchMonitorTests = {
|
||||
'should switch to Log Monitor': async function () {
|
||||
'should switch to Log Monitor': async function() {
|
||||
await this.driver
|
||||
.findElement(webdriver.By.xpath('//div[text()="Inspector"]'))
|
||||
.click();
|
||||
|
@ -19,7 +19,7 @@ export const switchMonitorTests = {
|
|||
await delay(500);
|
||||
},
|
||||
|
||||
'should switch to Chart Monitor': async function () {
|
||||
'should switch to Chart Monitor': async function() {
|
||||
await this.driver
|
||||
.findElement(webdriver.By.xpath('//div[text()="Log monitor"]'))
|
||||
.click();
|
||||
|
@ -34,7 +34,7 @@ export const switchMonitorTests = {
|
|||
await delay(500); // Wait till menu is closed
|
||||
},
|
||||
|
||||
'should switch back to Inspector Monitor': async function () {
|
||||
'should switch back to Inspector Monitor': async function() {
|
||||
await this.driver
|
||||
.findElement(webdriver.By.xpath('//div[text()="Chart"]'))
|
||||
.click();
|
||||
|
|
|
@ -34,9 +34,9 @@ const baseConfig = (params) => ({
|
|||
...(params.plugins
|
||||
? params.plugins
|
||||
: [
|
||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
||||
new webpack.optimize.OccurrenceOrderPlugin(),
|
||||
]),
|
||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
||||
new webpack.optimize.OccurrenceOrderPlugin(),
|
||||
]),
|
||||
],
|
||||
optimization: {
|
||||
minimizer: [
|
||||
|
@ -67,12 +67,12 @@ const baseConfig = (params) => ({
|
|||
...(params.loaders
|
||||
? params.loaders
|
||||
: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
use: 'babel-loader',
|
||||
exclude: /(node_modules|tmp\/page\.bundle)/,
|
||||
},
|
||||
]),
|
||||
{
|
||||
test: /\.js$/,
|
||||
use: 'babel-loader',
|
||||
exclude: /(node_modules|tmp\/page\.bundle)/,
|
||||
},
|
||||
]),
|
||||
{
|
||||
test: /\.css?$/,
|
||||
use: ['style-loader', 'raw-loader'],
|
||||
|
|
Loading…
Reference in New Issue
Block a user