Skip to content

Commit

Permalink
build(deps): upgrade dependencies to resolve some security alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
ArrayZoneYour committed May 15, 2022
1 parent f19e2c6 commit e7126ef
Show file tree
Hide file tree
Showing 4 changed files with 1,172 additions and 951 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# react-model · ![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg) [![npm version](https://img.shields.io/npm/v/react-model.svg?style=flat)](https://www.npmjs.com/package/react-model) [![minified size](https://badgen.net/bundlephobia/min/react)](https://bundlephobia.com/result?p=react-model) [![Build Status](https://travis-ci.org/byte-fe/react-model.svg?branch=master)](https://travis-ci.org/byte-fe/react-model) [![size](http://img.badgesize.io/https://cdn.jsdelivr.net/npm/react-model/dist/react-model.js?compression=gzip)](http://img.badgesize.io/https://cdn.jsdelivr.net/npm/react-model/dist/react-model.js) [![downloads](https://img.shields.io/npm/dt/react-model.svg)](https://www.npmjs.com/package/react-model) [![Coverage Status](https://codecov.io/gh/byte-fe/react-model/branch/master/graph/badge.svg)](https://codecov.io/gh/byte-fe/react-model) [![Greenkeeper badge](https://badges.greenkeeper.io/byte-fe/react-model.svg)](https://greenkeeper.io/) ![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)
# react-model · ![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg) [![npm version](https://img.shields.io/npm/v/react-model.svg?style=flat)](https://www.npmjs.com/package/react-model) [![minified size](https://badgen.net/bundlephobia/min/react)](https://bundlephobia.com/result?p=react-model) [![Node.js CI](https://github.com/byte-fe/react-model/actions/workflows/node.js.yml/badge.svg?branch=main)](https://github.com/byte-fe/react-model/actions/workflows/node.js.yml) [![size](http://img.badgesize.io/https://cdn.jsdelivr.net/npm/react-model/dist/react-model.js?compression=gzip)](http://img.badgesize.io/https://cdn.jsdelivr.net/npm/react-model/dist/react-model.js) [![downloads](https://img.shields.io/npm/dt/react-model.svg)](https://www.npmjs.com/package/react-model) [![Coverage Status](https://codecov.io/gh/byte-fe/react-model/branch/master/graph/badge.svg)](https://codecov.io/gh/byte-fe/react-model) [![Greenkeeper badge](https://badges.greenkeeper.io/byte-fe/react-model.svg)](https://greenkeeper.io/) ![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)

The State management library for React

Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"main": "./dist/react-model.js",
"module": "./dist/react-model.esm.js",
"umd:main": "./dist/react-model.umd.js",
"types": "./src/index",
"scripts": {
"build:prod": "microbundle --define process.env.NODE_ENV=production --sourcemap false --jsx React.createElement --output dist --tsconfig ./tsconfig.json",
"build:dev": "microbundle --define process.env.NODE_ENV=development --sourcemap true --jsx React.createElement --output dist --tsconfig ./tsconfig.json",
Expand All @@ -27,8 +26,8 @@
"typescript": ">=3.9.0"
},
"devDependencies": {
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"@commitlint/cli": "^16.3.0",
"@commitlint/config-conventional": "^16.2.4",
"@testing-library/react": "^10.0.1",
"@testing-library/react-hooks": "^2.0.1",
"@types/babel__core": "^7.1.1",
Expand All @@ -48,9 +47,9 @@
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-test-renderer": "^16.8.6",
"remark-cli": "^8.0.0",
"remark-lint": "^7.0.0",
"remark-preset-lint-recommended": "^4.0.0",
"remark-cli": "^10.0.1",
"remark-lint": "^9.1.1",
"remark-preset-lint-recommended": "^6.1.2",
"ts-jest": "^26.0.0",
"tslint": "^5.14.0",
"typescript": "^3.4.5"
Expand All @@ -64,6 +63,9 @@
"type": "git",
"url": "git+https://github.com/byte-fe/react-model"
},
"resolutions": {
"minimist": ">=1.2.6"
},
"bugs": {
"url": "https://github.com/byte-fe/react-model/issues"
},
Expand Down
75 changes: 40 additions & 35 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,11 @@ function Model<M extends Models, MT extends ModelType, E>(
}
if (models.actions) {
console.error('invalid model(s) schema: ', models)
const errorFn = (fakeReturnVal?: unknown) => (..._: unknown[]) => {
return fakeReturnVal
}
const errorFn =
(fakeReturnVal?: unknown) =>
(..._: unknown[]) => {
return fakeReturnVal
}
// Fallback Functions
return {
__ERROR__: true,
Expand Down Expand Up @@ -404,39 +406,42 @@ class Provider extends PureComponent<{}, Global['State']> {
}
}

const connect = (
modelName: string,
mapState?: Function | undefined,
mapActions?: Function | undefined
) => (Component: typeof React.Component | typeof PureComponent) =>
class P extends PureComponent<any> {
render() {
const { state: prevState = {}, actions: prevActions = {} } = this.props
return (
<Consumer>
{(models) => {
const { [`${modelName}`]: state } = models as any
const actions = Global.Actions[modelName]
return (
<Component
{...this.props}
state={{
...prevState,
...(mapState ? mapState(state) : state)
}}
actions={{
...prevActions,
...(mapActions
? mapActions(consumerActions(actions, { modelName }))
: consumerActions(actions, { modelName }))
}}
/>
)
}}
</Consumer>
)
const connect =
(
modelName: string,
mapState?: Function | undefined,
mapActions?: Function | undefined
) =>
(Component: typeof React.Component | typeof PureComponent) =>
class P extends PureComponent<any> {
render() {
const { state: prevState = {}, actions: prevActions = {} } = this.props
return (
<Consumer>
{(models) => {
const { [`${modelName}`]: state } = models as any
const actions = Global.Actions[modelName]
return (
// @ts-ignore
<Component
{...this.props}
state={{
...prevState,
...(mapState ? mapState(state) : state)
}}
actions={{
...prevActions,
...(mapActions
? mapActions(consumerActions(actions, { modelName }))
: consumerActions(actions, { modelName }))
}}
/>
)
}}
</Consumer>
)
}
}
}

export {
actionMiddlewares,
Expand Down
Loading

0 comments on commit e7126ef

Please sign in to comment.