mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-28 20:43:56 +03:00
Go back to CommonJS modules for now until https://phabricator.babeljs.io/T2817 is resolved.
This commit is contained in:
parent
a1e3d9ec3e
commit
384a9118af
|
@ -1,8 +1,9 @@
|
||||||
import React, { Children, Component, PropTypes } from 'react';
|
const React = require('react');
|
||||||
import { connect } from 'react-redux';
|
const { Children, Component, PropTypes } = require('react');
|
||||||
import instrument from './instrument';
|
const { connect } = require('react-redux');
|
||||||
|
const instrument = require('./instrument');
|
||||||
|
|
||||||
export default function createDevTools(children) {
|
module.exports = function createDevTools(children) {
|
||||||
const monitorElement = Children.only(children);
|
const monitorElement = Children.only(children);
|
||||||
const monitorProps = monitorElement.props;
|
const monitorProps = monitorElement.props;
|
||||||
const Monitor = monitorElement.type;
|
const Monitor = monitorElement.type;
|
||||||
|
@ -60,4 +61,4 @@ export default function createDevTools(children) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
14
src/index.js
14
src/index.js
|
@ -1,3 +1,11 @@
|
||||||
export { default as instrument, ActionCreators, ActionTypes } from './instrument';
|
const instrument = require('./instrument');
|
||||||
export { default as persistState } from './persistState';
|
const persistState = require('./persistState');
|
||||||
export { default as createDevTools } from './createDevTools';
|
const createDevTools = require('./createDevTools');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
instrument,
|
||||||
|
ActionCreators: instrument.ActionCreators,
|
||||||
|
ActionTypes: instrument.ActionTypes,
|
||||||
|
persistState,
|
||||||
|
createDevTools
|
||||||
|
};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import difference from 'lodash/array/difference';
|
const difference = require('lodash/array/difference');
|
||||||
|
|
||||||
export const ActionTypes = {
|
|
||||||
|
const ActionTypes = {
|
||||||
PERFORM_ACTION: 'PERFORM_ACTION',
|
PERFORM_ACTION: 'PERFORM_ACTION',
|
||||||
RESET: 'RESET',
|
RESET: 'RESET',
|
||||||
ROLLBACK: 'ROLLBACK',
|
ROLLBACK: 'ROLLBACK',
|
||||||
|
@ -14,7 +15,7 @@ export const ActionTypes = {
|
||||||
/**
|
/**
|
||||||
* Action creators to change the History state.
|
* Action creators to change the History state.
|
||||||
*/
|
*/
|
||||||
export const ActionCreators = {
|
const ActionCreators = {
|
||||||
performAction(action) {
|
performAction(action) {
|
||||||
return { type: ActionTypes.PERFORM_ACTION, action, timestamp: Date.now() };
|
return { type: ActionTypes.PERFORM_ACTION, action, timestamp: Date.now() };
|
||||||
},
|
},
|
||||||
|
@ -333,7 +334,7 @@ function unliftStore(liftedStore, liftReducer) {
|
||||||
/**
|
/**
|
||||||
* Redux instrumentation store enhancer.
|
* Redux instrumentation store enhancer.
|
||||||
*/
|
*/
|
||||||
export default function instrument(monitorReducer = () => null) {
|
module.exports = function instrument(monitorReducer = () => null) {
|
||||||
return createStore => (reducer, initialState) => {
|
return createStore => (reducer, initialState) => {
|
||||||
function liftReducer(r) {
|
function liftReducer(r) {
|
||||||
return liftReducerWith(r, initialState, monitorReducer);
|
return liftReducerWith(r, initialState, monitorReducer);
|
||||||
|
@ -342,4 +343,7 @@ export default function instrument(monitorReducer = () => null) {
|
||||||
const liftedStore = createStore(liftReducer(reducer));
|
const liftedStore = createStore(liftReducer(reducer));
|
||||||
return unliftStore(liftedStore, liftReducer);
|
return unliftStore(liftedStore, liftReducer);
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
|
module.exports.ActionTypes = ActionTypes;
|
||||||
|
module.exports.ActionCreators = ActionCreators;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import mapValues from 'lodash/object/mapValues';
|
const mapValues = require('lodash/object/mapValues');
|
||||||
import identity from 'lodash/utility/identity';
|
const identity = require('lodash/utility/identity');
|
||||||
|
|
||||||
export default function persistState(sessionId, deserializeState = identity, deserializeAction = identity) {
|
module.exports = function persistState(sessionId, deserializeState = identity, deserializeAction = identity) {
|
||||||
if (!sessionId) {
|
if (!sessionId) {
|
||||||
return next => (...args) => next(...args);
|
return next => (...args) => next(...args);
|
||||||
}
|
}
|
||||||
|
@ -57,4 +57,4 @@ export default function persistState(sessionId, deserializeState = identity, des
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
21
test/exports.spec.js
Normal file
21
test/exports.spec.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
const expect = require('expect');
|
||||||
|
|
||||||
|
const { instrument, ActionCreators, ActionTypes, persistState, createDevTools} = require('../src');
|
||||||
|
|
||||||
|
describe('exports are the correct types', () => {
|
||||||
|
it('instrument', () => {
|
||||||
|
expect(instrument).toBeA('function');
|
||||||
|
});
|
||||||
|
it('ActionCreators', () => {
|
||||||
|
expect(ActionCreators).toBeA('object');
|
||||||
|
});
|
||||||
|
it('ActionTypes', () => {
|
||||||
|
expect(ActionTypes).toBeA('object');
|
||||||
|
});
|
||||||
|
it('persistState', () => {
|
||||||
|
expect(persistState).toBeA('function');
|
||||||
|
});
|
||||||
|
it('createDevTools', () => {
|
||||||
|
expect(createDevTools).toBeA('function');
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,6 +1,8 @@
|
||||||
import expect, { spyOn } from 'expect';
|
const expect = require('expect');
|
||||||
import { createStore } from 'redux';
|
const { spyOn } = expect;
|
||||||
import instrument, { ActionCreators } from '../src/instrument';
|
const {createStore } = require('redux');
|
||||||
|
const instrument = require('../src/instrument');
|
||||||
|
const { ActionCreators } = instrument;
|
||||||
|
|
||||||
function counter(state = 0, action) {
|
function counter(state = 0, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import expect from 'expect';
|
const expect = require('expect');
|
||||||
import { instrument, persistState } from '../src';
|
const { instrument, persistState } = require('../src');
|
||||||
import { compose, createStore } from 'redux';
|
const { compose, createStore } = require('redux');
|
||||||
|
|
||||||
describe('persistState', () => {
|
describe('persistState', () => {
|
||||||
let savedLocalStorage = global.localStorage;
|
let savedLocalStorage = global.localStorage;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user