Skip to content

Commit a19d258

Browse files
imsobearluhc228
andauthored
release: @ice/store 2.0.0 (#133)
* chore: bump version * feat: no longer support actions&effects: {} * chore: lint * feat: remove actions APIs * chore: add coverage report * chore(test): remove warning expect * fix(test): variable naming (#134) * chore: 撤回多包架构 * feat: support output es * feat: support output es * fix: ts-node error * chore: add es to pkg files * chore: default es&remove cjs * chore: bump version * chore: add ts-node config * chore: modify pkg * chore: lib -> esm&remove utils/warning * chore: remove english docs * docs: optimie v2 docs Co-authored-by: Hengchang Lu <44047106+luhc228@users.noreply.github.com>
1 parent de76ab8 commit a19d258

34 files changed

+515
-3400
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
lib
2+
esm
23
node_modules

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ jobs:
1515
- name: Output branch name
1616
run: echo ${BRANCH_NAME}
1717
- run: npm install
18-
- run: npm run lint:nofix
18+
- run: npm run lint
1919
- run: npm run build
2020
- run: npm run test
2121
- name: Generate coverage
2222
run: npm run coverage
23+
- name: Upload coverage to Codecov
24+
uses: codecov/codecov-action@v1
2325
- name: Publish And Notify
2426
run: npm run publish
2527
env:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ jspm_packages/
5959

6060
# Compile directory
6161
lib
62+
esm
6263

6364
package-lock.json
6465

6566
yarn.lock
6667

6768
.ice
69+
.DS_Store

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
3+
See https://github.com/ice-lab/icestore/releases

README.en.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
English | [简体中文](./README.md)
2+
3+
# icestore
4+
5+
> Simple and friendly state for React.
6+
7+
[![NPM version](https://img.shields.io/npm/v/@ice/store.svg?style=flat)](https://npmjs.org/package/@ice/store)
8+
[![build status](https://github.com/ice-lab/icestore/actions/workflows/ci.yml/badge.svg)](https://github.com/ice-lab/icestore/actions/workflows/ci.yml)
9+
[![NPM downloads](http://img.shields.io/npm/dm/@ice/store.svg?style=flat)](https://npmjs.org/package/@ice/store)
10+
[![codecov](https://codecov.io/gh/ice-lab/icestore/branch/master/graph/badge.svg)](https://codecov.io/gh/ice-lab/icestore)
11+
12+
## Versions
13+
14+
| Version | Branch | Docs |
15+
| --- | --- | --- |
16+
| V2 | master | [Docs](https://github.com/ice-lab/icestore#documents)
17+
| V1 | stable/1.x | [Docs](https://github.com/ice-lab/icestore/tree/stable/1.x#documents)
18+
19+
## Introduction
20+
21+
icestore is a simple and friendly state management library for React. It has the following core features:
22+
23+
- **Minimal & Familiar API**: No additional learning costs, easy to get started with the knowledge of Redux && React Hooks.
24+
- **Built in Async Status**: Records loading and error status of effects, simplifying the rendering logic in the view layer.
25+
- **Class Component Support**: Make old projects enjoying the fun of lightweight state management with friendly compatibility strategy.
26+
- **TypeScript Support**: Provide complete type definitions to support intelliSense in VS Code.
27+
28+
See the [comparison table](docs/recipes.md#能力对比表) for more details.
29+
30+
## Examples
31+
32+
- [Counter](https://codesandbox.io/s/github/ice-lab/icestore/tree/master/examples/counter)
33+
- [Todos](https://codesandbox.io/s/github/ice-lab/icestore/tree/master/examples/todos)
34+
- [Class Component Support](https://codesandbox.io/s/github/ice-lab/icestore/tree/master/examples/classComponent)
35+
- [withModel](https://codesandbox.io/s/github/ice-lab/icestore/tree/master/examples/withModel)
36+
37+
## Basic example
38+
39+
```jsx
40+
import React from 'react';
41+
import ReactDOM from 'react-dom';
42+
import { createStore } from '@ice/store';
43+
44+
const delay = (time) =>
45+
new Promise((resolve) => setTimeout(() => resolve(), time));
46+
47+
// 1️⃣ Use a model to define your store
48+
const counter = {
49+
state: 0,
50+
reducers: {
51+
increment: (prevState) => prevState + 1,
52+
decrement: (prevState) => prevState - 1,
53+
},
54+
effects: () => ({
55+
async asyncDecrement() {
56+
await delay(1000);
57+
this.decrement();
58+
},
59+
}),
60+
};
61+
62+
const models = {
63+
counter,
64+
};
65+
66+
// 2️⃣ Create the store
67+
const store = createStore(models);
68+
69+
// 3️⃣ Consume model
70+
const { useModel } = store;
71+
function Counter() {
72+
const [count, dispatchers] = useModel('counter');
73+
const { increment, asyncDecrement } = dispatchers;
74+
return (
75+
<div>
76+
<span>{count}</span>
77+
<button type="button" onClick={increment}>
78+
+
79+
</button>
80+
<button type="button" onClick={asyncDecrement}>
81+
-
82+
</button>
83+
</div>
84+
);
85+
}
86+
87+
// 4️⃣ Wrap your components with Provider
88+
const { Provider } = store;
89+
function App() {
90+
return (
91+
<Provider>
92+
<Counter />
93+
</Provider>
94+
);
95+
}
96+
97+
const rootElement = document.getElementById('root');
98+
ReactDOM.render(<App />, rootElement);
99+
```
100+
101+
## Installation
102+
103+
icestore requires React 16.8.0 or later.
104+
105+
```bash
106+
npm install @ice/store --save
107+
```
108+
109+
## Documents
110+
111+
- [API](./docs/api.md)
112+
- [Recipes](./docs/recipes.md)
113+
- [Upgrade from V1](./docs/upgrade-guidelines.md)
114+
- [Q & A](./docs/qna.md)
115+
116+
## Inspiration
117+
118+
icestore refines and builds upon the ideas of [rematch](https://github.com/rematch/rematch) & [constate](https://github.com/diegohaz/constate).
119+
120+
## Contributors
121+
122+
Feel free to report any questions as an [issue](https://github.com/ice-lab/icestore/issues/new), we'd love to have your helping hand on icestore.
123+
124+
Develop:
125+
126+
```bash
127+
$ cd icestore/
128+
$ npm install
129+
$ npm run test
130+
$ npm run watch
131+
132+
$ cd examples/counter
133+
$ npm install
134+
$ npm link ../../ # link icestore
135+
$ npm link ../../node_modules/react # link react
136+
$ npm start
137+
```
138+
139+
## License
140+
141+
[MIT](LICENSE)

README.md

Lines changed: 48 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,85 @@
1-
English | [简体中文](./README.zh-CN.md)
1+
简体中文 | [English](./README.cn.md)
22

33
# icestore
44

5-
> Simple and friendly state for React.
5+
> 简单友好的状态管理方案。
66
77
[![NPM version](https://img.shields.io/npm/v/@ice/store.svg?style=flat)](https://npmjs.org/package/@ice/store)
8-
[![Package Quality](https://npm.packagequality.com/shield/@ice%2Fstore.svg)](https://packagequality.com/#?package=@ice/store)
9-
[![build status](https://img.shields.io/travis/ice-lab/icestore.svg?style=flat-square)](https://travis-ci.org/ice-lab/icestore)
8+
[![build status](https://github.com/ice-lab/icestore/actions/workflows/ci.yml/badge.svg)](https://github.com/ice-lab/icestore/actions/workflows/ci.yml)
109
[![NPM downloads](http://img.shields.io/npm/dm/@ice/store.svg?style=flat)](https://npmjs.org/package/@ice/store)
11-
[![Known Vulnerabilities](https://snyk.io/test/npm/@ice/store/badge.svg)](https://snyk.io/test/npm/@ice/store)
12-
[![David deps](https://img.shields.io/david/ice-lab/icestore.svg?style=flat-square)](https://david-dm.org/ice-lab/icestore)
1310
[![codecov](https://codecov.io/gh/ice-lab/icestore/branch/master/graph/badge.svg)](https://codecov.io/gh/ice-lab/icestore)
1411

15-
<table>
16-
<thead>
17-
<tr>
18-
<th colspan="5"><center>🕹 CodeSandbox demos 🕹</center></th>
19-
</tr>
20-
</thead>
21-
<tbody>
22-
<tr>
23-
<td><a href="https://codesandbox.io/s/github/ice-lab/icestore/tree/master/examples/counter?module=/src/index.tsx">Counter</a></td>
24-
<td><a href="https://codesandbox.io/s/github/ice-lab/icestore/tree/master/examples/todos?module=/src/index.tsx">Todos</a></td>
25-
</tr>
26-
</tbody>
27-
</table>
12+
## 版本
2813

29-
## Introduction
14+
| 版本 | 代码分支 | 文档 |
15+
| --- | --- | --- |
16+
| V2 | master | [Docs](https://github.com/ice-lab/icestore#documents)
17+
| V1 | stable/1.x | [Docs](https://github.com/ice-lab/icestore/tree/stable/1.x#documents)
3018

31-
icestore is a simple and friendly state management library for React. It has the following core features:
19+
## 安装
3220

33-
- **Minimal & Familiar API**: No additional learning costs, easy to get started with the knowledge of Redux && React Hooks.
34-
- **Built in Async Status**: Records loading and error status of effects, simplifying the rendering logic in the view layer.
35-
- **Class Component Support**: Make old projects enjoying the fun of lightweight state management with friendly compatibility strategy.
36-
- **TypeScript Support**: Provide complete type definitions to support intelliSense in VS Code.
21+
icestore 是面向 React 应用的、简单友好的状态管理方案。它包含以下核心特征:
3722

38-
See the [comparison table](docs/recipes.md#Comparison) for more details.
23+
* **简单、熟悉的 API**:不需要额外的学习成本,只需要了解 React Hooks,对 Redux 用户友好。
24+
* **集成异步处理**:记录异步操作时的执行状态,简化视图中对于等待或错误的处理逻辑。
25+
* **支持组件 Class 写法**:友好的兼容策略可以让老项目享受轻量状态管理的乐趣。
26+
* **良好的 TypeScript 支持**:提供完整的 TypeScript 类型定义,在 VS Code 中能获得完整的类型检查和推断。
3927

40-
## Basic example
28+
查看[《能力对比表》](docs/recipes.md#Comparison)了解更多细节。
29+
30+
## 示例
31+
32+
- [Counter](https://codesandbox.io/s/github/ice-lab/icestore/tree/master/examples/counter)
33+
- [Todos](https://codesandbox.io/s/github/ice-lab/icestore/tree/master/examples/todos)
34+
- [Class Component Support](https://codesandbox.io/s/github/ice-lab/icestore/tree/master/examples/classComponent)
35+
- [withModel](https://codesandbox.io/s/github/ice-lab/icestore/tree/master/examples/withModel)
36+
37+
## 快速开始
4138

4239
```jsx
4340
import React from 'react';
4441
import ReactDOM from 'react-dom';
4542
import { createStore } from '@ice/store';
4643

47-
const delay = (time) =>
48-
new Promise((resolve) => setTimeout(() => resolve(), time));
44+
const delay = (time) => new Promise((resolve) => setTimeout(() => resolve(), time));
4945

50-
// 1️⃣ Use a model to define your store
46+
// 1️⃣ 使用模型定义你的状态
5147
const counter = {
5248
state: 0,
5349
reducers: {
54-
increment: (prevState) => prevState + 1,
55-
decrement: (prevState) => prevState - 1,
50+
increment:(prevState) => prevState + 1,
51+
decrement:(prevState) => prevState - 1,
5652
},
5753
effects: () => ({
5854
async asyncDecrement() {
5955
await delay(1000);
6056
this.decrement();
6157
},
62-
}),
58+
})
6359
};
6460

6561
const models = {
6662
counter,
6763
};
6864

69-
// 2️⃣ Create the store
65+
// 2️⃣ 创建 Store
7066
const store = createStore(models);
7167

72-
// 3️⃣ Consume model
68+
// 3️⃣ 消费模型
7369
const { useModel } = store;
7470
function Counter() {
75-
const [count, dispatchers] = useModel('counter');
71+
const [ count, dispatchers ] = useModel('counter');
7672
const { increment, asyncDecrement } = dispatchers;
7773
return (
7874
<div>
7975
<span>{count}</span>
80-
<button type="button" onClick={increment}>
81-
+
82-
</button>
83-
<button type="button" onClick={asyncDecrement}>
84-
-
85-
</button>
76+
<button type="button" onClick={increment}>+</button>
77+
<button type="button" onClick={asyncDecrement}>-</button>
8678
</div>
8779
);
8880
}
8981

90-
// 4️⃣ Wrap your components with Provider
82+
// 4️⃣ 绑定视图
9183
const { Provider } = store;
9284
function App() {
9385
return (
@@ -101,50 +93,35 @@ const rootElement = document.getElementById('root');
10193
ReactDOM.render(<App />, rootElement);
10294
```
10395

104-
## Installation
96+
## 安装
10597

106-
icestore requires React 16.8.0 or later.
98+
使用 icestore 需要 React 16.8.0 版本以上。
10799

108100
```bash
109-
npm install @ice/store --save
101+
$ npm install @ice/store --save
110102
```
111103

112-
## Documents
104+
## 文档
113105

114106
- [API](./docs/api.md)
115-
- [Recipes](./docs/recipes.md)
116-
- [Upgrade Guidelines](./docs/upgrade-guidelines.md)
117-
- [Migration](./docs/migration.md)
118-
- [Q & A](./docs/qna.md)
119-
120-
## Examples
121-
122-
- [Counter](https://codesandbox.io/s/github/ice-lab/icestore/tree/master/examples/counter)
123-
- [Todos](https://codesandbox.io/s/github/ice-lab/icestore/tree/master/examples/todos)
124-
- [Class Component Support](https://codesandbox.io/s/github/ice-lab/icestore/tree/master/examples/classComponent)
125-
- [withModel](https://codesandbox.io/s/github/ice-lab/icestore/tree/master/examples/withModel)
126-
127-
## Browser Compatibility
128-
129-
| ![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![UC](https://raw.github.com/alrra/browser-logos/master/src/uc/uc_48x48.png) |
130-
| :--------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------: | :--------------------------------------------------------------------------: |
131-
|||| 9+ ✔ ||||
132-
133-
## Inspiration
107+
- [更多技巧](./docs/recipes.md)
108+
- [从 V1 版本升级](./docs/upgrade-guidelines.md)
109+
- [常见问题](./docs/qna.md)
134110

135-
icestore refines and builds upon the ideas of [rematch](https://github.com/rematch/rematch) & [constate](https://github.com/diegohaz/constate).
111+
## 灵感
136112

137-
## Contributors
113+
创造 icestore 的灵感来自于 [rematch](https://github.com/rematch/rematch)[constate](https://github.com/diegohaz/constate)
138114

139-
Feel free to report any questions as an [issue](https://github.com/ice-lab/icestore/issues/new), we'd love to have your helping hand on icestore.
115+
## 参与贡献
140116

141-
If you're interested in icestore, see [CONTRIBUTING.md](https://github.com/alibaba/ice/blob/master/.github/CONTRIBUTING.md) for more information to learn how to get started.
117+
欢迎通过 [issue](https://github.com/ice-lab/icestore/issues/new) 反馈问题。
142118

143-
Develop:
119+
开发:
144120

145121
```bash
146122
$ cd icestore/
147123
$ npm install
124+
$ npm run test
148125
$ npm run watch
149126

150127
$ cd examples/counter

0 commit comments

Comments
 (0)