Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-starter-kit

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-starter-kit - npm Package Compare versions

Comparing version 0.4.3 to 0.5.0

dist/configureStore.d.ts

68

dist/redux-starter-kit.cjs.js

@@ -8,6 +8,5 @@ 'use strict';

var redux = require('redux');
var createNextState = _interopDefault(require('immer'));
var selectorator = _interopDefault(require('selectorator'));
var reduxDevtoolsExtension = require('redux-devtools-extension');
var thunk = _interopDefault(require('redux-thunk'));
var createNextState = _interopDefault(require('immer'));

@@ -43,2 +42,21 @@ function _typeof(obj) {

function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function _toConsumableArray(arr) {

@@ -111,6 +129,4 @@ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();

var _arr = Object.keys(value);
for (var _i = 0; _i < _arr.length; _i++) {
var property = _arr[_i];
for (var _i = 0, _Object$keys = Object.keys(value); _i < _Object$keys.length; _i++) {
var property = _Object$keys[_i];
var nestedPath = path.concat(property);

@@ -158,5 +174,5 @@ var nestedValue = value[property];

if (foundActionNonSerializableValue) {
var _keyPath = foundActionNonSerializableValue.keyPath,
var keyPath = foundActionNonSerializableValue.keyPath,
_value = foundActionNonSerializableValue.value;
console.error(NON_SERIALIZABLE_ACTION_MESSAGE, _keyPath, _value, action);
console.error(NON_SERIALIZABLE_ACTION_MESSAGE, keyPath, _value, action);
}

@@ -169,5 +185,5 @@

if (foundStateNonSerializableValue) {
var _keyPath2 = foundStateNonSerializableValue.keyPath,
var _keyPath = foundStateNonSerializableValue.keyPath,
_value2 = foundStateNonSerializableValue.value;
console.error(NON_SERIALIZABLE_STATE_MESSAGE, _keyPath2, _value2, action.type);
console.error(NON_SERIALIZABLE_STATE_MESSAGE, _keyPath, _value2, action.type);
}

@@ -194,3 +210,3 @@

if (process.env.NODE_ENV !== 'production') {
var createImmutableStateInvariantMiddleware = require('redux-immutable-state-invariant').default;
var createImmutableStateInvariantMiddleware = require('redux-immutable-state-invariant')["default"];

@@ -239,10 +255,6 @@ middlewareArray = [createImmutableStateInvariantMiddleware(), thunk, createSerializableStateInvariantMiddleware()];

if (devTools) {
finalCompose = reduxDevtoolsExtension.composeWithDevTools({
finalCompose = reduxDevtoolsExtension.composeWithDevTools(_objectSpread({
// Enable capture of stack traces for dispatched Redux actions
// @ts-ignore redux-devtools-extension doesn't have `trace` defined in
// its type definition file yet:
//
// https://github.com/zalmoxisus/redux-devtools-extension/pull/624
trace: !IS_PRODUCTION
});
}, _typeof(devTools) === 'object' && devTools));
}

@@ -404,24 +416,10 @@

// types using the `export { ... } from` syntax. Because it compiles
// modules, independently, it has no way of knowing whether an identifier
// refers to a type or value, and thus cannot strip the type re-exports
// out of the generated JS.
//
// https://github.com/babel/babel/issues/8361
//
// As a workaround, the root of this repository contains an `index.d.ts`
// that contains all type re-exports. Whenever adding a new public function
// or type, remember to export it in `index.d.ts` as well.
exports.combineReducers = redux.combineReducers;
exports.compose = redux.compose;
exports.createNextState = createNextState;
exports.createSelector = selectorator;
exports.configureStore = configureStore;
exports.getDefaultMiddleware = getDefaultMiddleware;
exports.createAction = createAction;
exports.getType = getType;
exports.createReducer = createReducer;
exports.createSerializableStateInvariantMiddleware = createSerializableStateInvariantMiddleware;
exports.createSlice = createSlice;
exports.createSerializableStateInvariantMiddleware = createSerializableStateInvariantMiddleware;
exports.findNonSerializableValue = findNonSerializableValue;
exports.getDefaultMiddleware = getDefaultMiddleware;
exports.getType = getType;
exports.isPlain = isPlain;
import { combineReducers, applyMiddleware, createStore, compose } from 'redux';
export { combineReducers, compose } from 'redux';
import createNextState from 'immer';
export { default as createNextState } from 'immer';
export { default as createSelector } from 'selectorator';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunk from 'redux-thunk';
import createNextState from 'immer';

@@ -38,2 +35,21 @@ function _typeof(obj) {

function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function _toConsumableArray(arr) {

@@ -106,6 +122,4 @@ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();

var _arr = Object.keys(value);
for (var _i = 0; _i < _arr.length; _i++) {
var property = _arr[_i];
for (var _i = 0, _Object$keys = Object.keys(value); _i < _Object$keys.length; _i++) {
var property = _Object$keys[_i];
var nestedPath = path.concat(property);

@@ -153,5 +167,5 @@ var nestedValue = value[property];

if (foundActionNonSerializableValue) {
var _keyPath = foundActionNonSerializableValue.keyPath,
var keyPath = foundActionNonSerializableValue.keyPath,
_value = foundActionNonSerializableValue.value;
console.error(NON_SERIALIZABLE_ACTION_MESSAGE, _keyPath, _value, action);
console.error(NON_SERIALIZABLE_ACTION_MESSAGE, keyPath, _value, action);
}

@@ -164,5 +178,5 @@

if (foundStateNonSerializableValue) {
var _keyPath2 = foundStateNonSerializableValue.keyPath,
var _keyPath = foundStateNonSerializableValue.keyPath,
_value2 = foundStateNonSerializableValue.value;
console.error(NON_SERIALIZABLE_STATE_MESSAGE, _keyPath2, _value2, action.type);
console.error(NON_SERIALIZABLE_STATE_MESSAGE, _keyPath, _value2, action.type);
}

@@ -189,3 +203,3 @@

if (process.env.NODE_ENV !== 'production') {
var createImmutableStateInvariantMiddleware = require('redux-immutable-state-invariant').default;
var createImmutableStateInvariantMiddleware = require('redux-immutable-state-invariant')["default"];

@@ -234,10 +248,6 @@ middlewareArray = [createImmutableStateInvariantMiddleware(), thunk, createSerializableStateInvariantMiddleware()];

if (devTools) {
finalCompose = composeWithDevTools({
finalCompose = composeWithDevTools(_objectSpread({
// Enable capture of stack traces for dispatched Redux actions
// @ts-ignore redux-devtools-extension doesn't have `trace` defined in
// its type definition file yet:
//
// https://github.com/zalmoxisus/redux-devtools-extension/pull/624
trace: !IS_PRODUCTION
});
}, _typeof(devTools) === 'object' && devTools));
}

@@ -399,13 +409,2 @@

// types using the `export { ... } from` syntax. Because it compiles
// modules, independently, it has no way of knowing whether an identifier
// refers to a type or value, and thus cannot strip the type re-exports
// out of the generated JS.
//
// https://github.com/babel/babel/issues/8361
//
// As a workaround, the root of this repository contains an `index.d.ts`
// that contains all type re-exports. Whenever adding a new public function
// or type, remember to export it in `index.d.ts` as well.
export { configureStore, getDefaultMiddleware, createAction, getType, createReducer, createSlice, createSerializableStateInvariantMiddleware, isPlain };
export { configureStore, createAction, createReducer, createSerializableStateInvariantMiddleware, createSlice, findNonSerializableValue, getDefaultMiddleware, getType, isPlain };
{
"name": "redux-starter-kit",
"version": "0.4.3",
"version": "0.5.0",
"description": "A simple set of tools to make using Redux easier",

@@ -9,27 +9,28 @@ "repository": "https://github.com/markerikson/redux-starter-kit",

"unpkg": "dist/redux-starter-kit.umd.js",
"types": "dist/typings.d.ts",
"author": "Mark Erikson <mark@isquaredsoftware.com>",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-typescript": "^7.1.0",
"@types/jest": "^23.3.12",
"@types/node": "^10.12.18",
"@babel/core": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"@babel/preset-typescript": "^7.3.3",
"@types/jest": "^24.0.11",
"@types/node": "^10.14.4",
"@types/redux-immutable-state-invariant": "^2.1.0",
"babel-core": "7.0.0-bridge.0",
"@typescript-eslint/parser": "^1.6.0",
"babel-eslint": "^10.0.1",
"eslint": "^4.17.0",
"eslint-config-react-app": "^2.1.0",
"eslint-plugin-flowtype": "^2.44.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.6.1",
"jest": "^22.4.2",
"prettier": "^1.10.2",
"rollup": "^1.0.2",
"rollup-plugin-babel": "^4.2.0",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^4.0.0",
"typescript": "^3.2.2",
"typescript-eslint-parser": "eslint/typescript-eslint-parser",
"eslint": "^5.16.0",
"eslint-config-react-app": "^3.0.8",
"eslint-plugin-flowtype": "^3.5.1",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.12.4",
"jest": "^24.7.1",
"prettier": "^1.17.0",
"react": "^16.8.6",
"rollup": "^1.9.0",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-node-resolve": "^4.2.0",
"typescript": "^3.4.3",
"typings-tester": "^0.3.2"

@@ -42,3 +43,3 @@ },

"format:check": "prettier --list-different \"src/*.ts\" \"**/*.md\"",
"lint": "eslint 'src/**/*.ts'",
"lint": "eslint \"src/**/*.ts\"",
"prepare": "npm run tsc && npm run lint && npm test && npm run build",

@@ -50,12 +51,11 @@ "test": "jest",

"dist",
"index.d.ts",
"src"
],
"dependencies": {
"immer": "^1.10.5",
"immer": "^2.1.5",
"redux": "^4.0.0",
"redux-devtools-extension": "^2.13.7",
"redux-devtools-extension": "^2.13.8",
"redux-immutable-state-invariant": "^2.1.0",
"redux-thunk": "^2.2.0",
"selectorator": "^4.0.1"
"selectorator": "^4.0.3"
},

@@ -62,0 +62,0 @@ "jest": {

@@ -17,3 +17,3 @@ # Redux Starter Kit

The `redux-starter-kit` package is intended to help address three common concerns about Redux:
The Redux Starter Kit package is intended to help address three common concerns about Redux:

@@ -30,3 +30,3 @@ - "Configuring a Redux store is too complicated"

`redux-starter-kit` includes:
Redux Starter Kit includes:

@@ -41,4 +41,4 @@ - A `configureStore()` function with simplified configuration options. It can automatically combine your slice reducers, adds whatever Redux middleware you supply, includes `redux-thunk` by default, and enables use of the Redux DevTools Extension.

The `redux-starter-kit` docs are now published at **https://redux-starter-kit.js.org**.
The Redux Starter Kit docs are now published at **https://redux-starter-kit.js.org**.
We're currently expanding and rewriting our docs content - check back soon for more updates!

@@ -123,2 +123,21 @@ import { configureStore, getDefaultMiddleware } from './configureStore'

describe('with devTools options', () => {
it('calls createStore with devTools enhancer and option', () => {
const options = {
name: 'myApp',
trace: true
}
expect(configureStore({ devTools: options, reducer })).toBeInstanceOf(
Object
)
expect(redux.applyMiddleware).toHaveBeenCalled()
expect(devtools.composeWithDevTools).toHaveBeenCalledWith(options)
expect(redux.createStore).toHaveBeenCalledWith(
reducer,
undefined,
expect.any(Function)
)
})
})
describe('given preloadedState', () => {

@@ -125,0 +144,0 @@ it('calls createStore with preloadedState', () => {

@@ -15,5 +15,5 @@ import {

} from 'redux'
import { composeWithDevTools } from 'redux-devtools-extension'
import { composeWithDevTools, EnhancerOptions } from 'redux-devtools-extension'
import thunk, { ThunkDispatch, ThunkMiddleware } from 'redux-thunk'
import createSerializableStateInvariantMiddleware from './serializableStateInvariantMiddleware'
import { createSerializableStateInvariantMiddleware } from './serializableStateInvariantMiddleware'

@@ -69,4 +69,6 @@ import isPlainObject from './isPlainObject'

* Whether to enable Redux DevTools integration. Defaults to `true`.
*
* Additional configuration can be done by passing enhancer options
*/
devTools?: boolean
devTools?: boolean | EnhancerOptions

@@ -138,8 +140,4 @@ /**

// Enable capture of stack traces for dispatched Redux actions
// @ts-ignore redux-devtools-extension doesn't have `trace` defined in
// its type definition file yet:
//
// https://github.com/zalmoxisus/redux-devtools-extension/pull/624
trace: !IS_PRODUCTION
trace: !IS_PRODUCTION,
...(typeof devTools === 'object' && devTools)
})

@@ -146,0 +144,0 @@ }

@@ -5,2 +5,7 @@ import createNextState, { Draft } from 'immer'

/**
* Defines a mapping from action types to corresponding action object shapes.
*/
export type Actions<T extends keyof any = string> = Record<T, Action>
/**
* An *case reducer* is a reducer function for a speficic action type. Case

@@ -27,4 +32,4 @@ * reducers can be composed to full reducers using `createReducer()`.

*/
export interface CaseReducersMapObject<S = any, A extends Action = AnyAction> {
[actionType: string]: CaseReducer<S, A>
export type CaseReducers<S, AS extends Actions> = {
[T in keyof AS]: AS[T] extends Action ? CaseReducer<S, AS[T]> : void
}

@@ -48,6 +53,6 @@

*/
export function createReducer<S = any, A extends Action = AnyAction>(
initialState: S,
actionsMap: CaseReducersMapObject<S, A>
): Reducer<S> {
export function createReducer<
S,
CR extends CaseReducers<S, any> = CaseReducers<S, any>
>(initialState: S, actionsMap: CR): Reducer<S> {
return function(state = initialState, action): S {

@@ -59,5 +64,5 @@ // @ts-ignore createNextState() produces an Immutable<Draft<S>> rather

const caseReducer = actionsMap[action.type]
return caseReducer ? caseReducer(draft, action as A) : undefined
return caseReducer ? caseReducer(draft, action) : undefined
})
}
}
import { createSlice } from './createSlice'
import { createAction } from './createAction'
import { createAction, PayloadAction } from './createAction'

@@ -9,3 +9,4 @@ describe('createSlice', () => {

increment: state => state + 1,
multiply: (state, action) => state * action.payload
multiply: (state, action: PayloadAction<number>) =>
state * action.payload
},

@@ -12,0 +13,0 @@ initialState: 0

@@ -1,4 +0,4 @@

import { Action, AnyAction, Reducer } from 'redux'
import { Reducer } from 'redux'
import { createAction, PayloadAction } from './createAction'
import { createReducer, CaseReducersMapObject } from './createReducer'
import { createReducer, CaseReducers } from './createReducer'
import { createSliceSelector, createSelectorName } from './sliceSelector'

@@ -9,7 +9,8 @@

*/
export type SliceActionCreator<P> = (payload: P) => PayloadAction<P>
export type SliceActionCreator<P> = P extends void
? () => PayloadAction<void>
: (payload: P) => PayloadAction<P>
export interface Slice<
S = any,
A extends Action = AnyAction,
AP extends { [key: string]: any } = { [key: string]: any }

@@ -25,3 +26,3 @@ > {

*/
reducer: Reducer<S, A>
reducer: Reducer<S>

@@ -48,5 +49,3 @@ /**

S = any,
A extends Action = AnyAction,
CR extends CaseReducersMapObject<S, A> = CaseReducersMapObject<S, A>,
CR2 extends CaseReducersMapObject<S, A> = CaseReducersMapObject<S, A>
CR extends CaseReducers<S, any> = CaseReducers<S, any>
> {

@@ -76,15 +75,11 @@ /**

*/
extraReducers?: CR2
extraReducers?: CaseReducers<S, any>
}
type ExtractPayloads<
S,
A extends PayloadAction,
CR extends CaseReducersMapObject<S, A>
> = {
[type in keyof CR]: CR[type] extends (state: S) => any
type CaseReducerActionPayloads<CR extends CaseReducers<any, any>> = {
[T in keyof CR]: CR[T] extends (state: any) => any
? void
: (CR[type] extends (state: S, action: PayloadAction<infer P>) => any
: (CR[T] extends (state: any, action: PayloadAction<infer P>) => any
? P
: never)
: void)
}

@@ -104,9 +99,5 @@

*/
export function createSlice<
S = any,
A extends PayloadAction = PayloadAction<any>,
CR extends CaseReducersMapObject<S, A> = CaseReducersMapObject<S, A>
>(
options: CreateSliceOptions<S, A, CR>
): Slice<S, A, ExtractPayloads<S, A, CR>> {
export function createSlice<S, CR extends CaseReducers<S, any>>(
options: CreateSliceOptions<S, CR>
): Slice<S, CaseReducerActionPayloads<CR>> {
const { slice = '', initialState } = options

@@ -113,0 +104,0 @@ const reducers = options.reducers || {}

@@ -1,24 +0,5 @@

export { combineReducers, compose } from 'redux'
export { default as createNextState } from 'immer'
export { default as createSelector } from 'selectorator'
export { configureStore, getDefaultMiddleware } from './configureStore'
export { createAction, getType } from './createAction'
export { createReducer } from './createReducer'
export { createSlice } from './createSlice'
export {
default as createSerializableStateInvariantMiddleware,
isPlain
} from './serializableStateInvariantMiddleware'
// Unfortunately, Babel's TypeScript plugin doesn't let us re-export
// types using the `export { ... } from` syntax. Because it compiles
// modules, independently, it has no way of knowing whether an identifier
// refers to a type or value, and thus cannot strip the type re-exports
// out of the generated JS.
//
// https://github.com/babel/babel/issues/8361
//
// As a workaround, the root of this repository contains an `index.d.ts`
// that contains all type re-exports. Whenever adding a new public function
// or type, remember to export it in `index.d.ts` as well.
export * from './configureStore'
export * from './createAction'
export * from './createReducer'
export * from './createSlice'
export * from './serializableStateInvariantMiddleware'
import { Reducer } from 'redux'
import { configureStore } from './configureStore'
import createSerializableStateInvariantMiddleware, {
import {
createSerializableStateInvariantMiddleware,
findNonSerializableValue

@@ -6,0 +7,0 @@ } from './serializableStateInvariantMiddleware'

@@ -104,3 +104,3 @@ import isPlainObject from './isPlainObject'

*/
export default function createSerializableStateInvariantMiddleware(
export function createSerializableStateInvariantMiddleware(
options: SerializableStateInvariantMiddlewareOptions = {}

@@ -107,0 +107,0 @@ ): Middleware {

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc