@violetflux/kerros 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.de.md +9 -9
- package/README.es.md +9 -9
- package/README.fr.md +9 -9
- package/README.ja.md +9 -9
- package/README.ko.md +9 -9
- package/README.md +32 -29
- package/README.zh-CN.md +32 -29
- package/package.json +1 -1
package/README.de.md
CHANGED
|
@@ -21,15 +21,6 @@ Kerros lässt React-State dort, wo er natürlich hingehört: in Hooks und unter
|
|
|
21
21
|
- Stores lassen sich über einseitige Abhängigkeiten komponieren
|
|
22
22
|
- Unterstützt React 17, 18 und 19
|
|
23
23
|
|
|
24
|
-
## Installation
|
|
25
|
-
|
|
26
|
-
| Paketmanager | Befehl |
|
|
27
|
-
| --- | --- |
|
|
28
|
-
| npm | `npm install @violetflux/kerros` |
|
|
29
|
-
| pnpm | `pnpm add @violetflux/kerros` |
|
|
30
|
-
| Yarn | `yarn add @violetflux/kerros` |
|
|
31
|
-
| Bun | `bun add @violetflux/kerros` |
|
|
32
|
-
|
|
33
24
|
## Store erstellen
|
|
34
25
|
|
|
35
26
|
```tsx
|
|
@@ -62,6 +53,15 @@ function App() {
|
|
|
62
53
|
|
|
63
54
|
Der Selektor darf inline stehen. Änderungen an nicht ausgewählten Feldern rendern `Counter` nicht neu.
|
|
64
55
|
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
| Paketmanager | Befehl |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| npm | `npm install @violetflux/kerros` |
|
|
61
|
+
| pnpm | `pnpm add @violetflux/kerros` |
|
|
62
|
+
| Yarn | `yarn add @violetflux/kerros` |
|
|
63
|
+
| Bun | `bun add @violetflux/kerros` |
|
|
64
|
+
|
|
65
65
|
## Funktionsweise
|
|
66
66
|
|
|
67
67
|
Der Provider führt den Store Hook aus und gibt über Context nur einen stabilen Abonnement-Container weiter. Bestätigte Snapshots werden mit `subscribe/getSnapshot` veröffentlicht. Eine Komponente rendert nur neu, wenn sich ihre Auswahl ändert.
|
package/README.es.md
CHANGED
|
@@ -21,15 +21,6 @@ Kerros mantiene el estado de React donde pertenece de forma natural: dentro de H
|
|
|
21
21
|
- Los Stores se componen mediante dependencias unidireccionales
|
|
22
22
|
- Compatible con React 17, 18 y 19
|
|
23
23
|
|
|
24
|
-
## Instalación
|
|
25
|
-
|
|
26
|
-
| Gestor | Comando |
|
|
27
|
-
| --- | --- |
|
|
28
|
-
| npm | `npm install @violetflux/kerros` |
|
|
29
|
-
| pnpm | `pnpm add @violetflux/kerros` |
|
|
30
|
-
| Yarn | `yarn add @violetflux/kerros` |
|
|
31
|
-
| Bun | `bun add @violetflux/kerros` |
|
|
32
|
-
|
|
33
24
|
## Crear un Store
|
|
34
25
|
|
|
35
26
|
```tsx
|
|
@@ -62,6 +53,15 @@ function App() {
|
|
|
62
53
|
|
|
63
54
|
El selector puede escribirse en línea. Cambiar un campo no seleccionado no vuelve a renderizar `Counter`.
|
|
64
55
|
|
|
56
|
+
## Instalación
|
|
57
|
+
|
|
58
|
+
| Gestor | Comando |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| npm | `npm install @violetflux/kerros` |
|
|
61
|
+
| pnpm | `pnpm add @violetflux/kerros` |
|
|
62
|
+
| Yarn | `yarn add @violetflux/kerros` |
|
|
63
|
+
| Bun | `bun add @violetflux/kerros` |
|
|
64
|
+
|
|
65
65
|
## Cómo funciona
|
|
66
66
|
|
|
67
67
|
El Provider ejecuta el Hook del Store y Context solo transporta un contenedor de suscripción estable. Los snapshots confirmados se publican mediante `subscribe/getSnapshot`. Cada componente se renderiza de nuevo únicamente cuando cambia su selección.
|
package/README.fr.md
CHANGED
|
@@ -21,15 +21,6 @@ Kerros conserve l'état React là où il se trouve naturellement : dans les Hook
|
|
|
21
21
|
- Les Stores se composent grâce à des dépendances unidirectionnelles
|
|
22
22
|
- Compatible avec React 17, 18 et 19
|
|
23
23
|
|
|
24
|
-
## Installation
|
|
25
|
-
|
|
26
|
-
| Gestionnaire | Commande |
|
|
27
|
-
| --- | --- |
|
|
28
|
-
| npm | `npm install @violetflux/kerros` |
|
|
29
|
-
| pnpm | `pnpm add @violetflux/kerros` |
|
|
30
|
-
| Yarn | `yarn add @violetflux/kerros` |
|
|
31
|
-
| Bun | `bun add @violetflux/kerros` |
|
|
32
|
-
|
|
33
24
|
## Créer un Store
|
|
34
25
|
|
|
35
26
|
```tsx
|
|
@@ -62,6 +53,15 @@ function App() {
|
|
|
62
53
|
|
|
63
54
|
Le sélecteur peut rester en ligne. La modification d'un champ non sélectionné ne provoque pas un nouveau rendu de `Counter`.
|
|
64
55
|
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
| Gestionnaire | Commande |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| npm | `npm install @violetflux/kerros` |
|
|
61
|
+
| pnpm | `pnpm add @violetflux/kerros` |
|
|
62
|
+
| Yarn | `yarn add @violetflux/kerros` |
|
|
63
|
+
| Bun | `bun add @violetflux/kerros` |
|
|
64
|
+
|
|
65
65
|
## Fonctionnement
|
|
66
66
|
|
|
67
67
|
Le Provider exécute le Hook du Store et Context ne transporte qu'un conteneur d'abonnement stable. Les snapshots validés sont publiés via `subscribe/getSnapshot`. Un composant n'est rendu à nouveau que lorsque sa sélection change.
|
package/README.ja.md
CHANGED
|
@@ -21,15 +21,6 @@ Kerros は React の状態を Hook の中、Provider の下という自然な場
|
|
|
21
21
|
- 一方向の依存関係で Store を合成可能
|
|
22
22
|
- React 17、18、19 をサポート
|
|
23
23
|
|
|
24
|
-
## インストール
|
|
25
|
-
|
|
26
|
-
| パッケージマネージャー | コマンド |
|
|
27
|
-
| --- | --- |
|
|
28
|
-
| npm | `npm install @violetflux/kerros` |
|
|
29
|
-
| pnpm | `pnpm add @violetflux/kerros` |
|
|
30
|
-
| Yarn | `yarn add @violetflux/kerros` |
|
|
31
|
-
| Bun | `bun add @violetflux/kerros` |
|
|
32
|
-
|
|
33
24
|
## Store を作成する
|
|
34
25
|
|
|
35
26
|
```tsx
|
|
@@ -63,6 +54,15 @@ function App() {
|
|
|
63
54
|
|
|
64
55
|
selector はインラインで記述できます。選択していないフィールドの変更では `Counter` は再レンダーされません。
|
|
65
56
|
|
|
57
|
+
## インストール
|
|
58
|
+
|
|
59
|
+
| パッケージマネージャー | コマンド |
|
|
60
|
+
| --- | --- |
|
|
61
|
+
| npm | `npm install @violetflux/kerros` |
|
|
62
|
+
| pnpm | `pnpm add @violetflux/kerros` |
|
|
63
|
+
| Yarn | `yarn add @violetflux/kerros` |
|
|
64
|
+
| Bun | `bun add @violetflux/kerros` |
|
|
65
|
+
|
|
66
66
|
## 仕組み
|
|
67
67
|
|
|
68
68
|
Provider は Store Hook を実行し、Context には安定した購読コンテナだけを渡します。コミット済みスナップショットは `subscribe/getSnapshot` で公開され、各コンポーネントは選択結果が変わったときだけ再レンダーされます。
|
package/README.ko.md
CHANGED
|
@@ -21,15 +21,6 @@ Kerros는 React 상태를 Hook 안과 Provider 아래라는 자연스러운 위
|
|
|
21
21
|
- 단방향 의존성을 통한 Store 조합
|
|
22
22
|
- React 17, 18, 19 지원
|
|
23
23
|
|
|
24
|
-
## 설치
|
|
25
|
-
|
|
26
|
-
| 패키지 매니저 | 명령 |
|
|
27
|
-
| --- | --- |
|
|
28
|
-
| npm | `npm install @violetflux/kerros` |
|
|
29
|
-
| pnpm | `pnpm add @violetflux/kerros` |
|
|
30
|
-
| Yarn | `yarn add @violetflux/kerros` |
|
|
31
|
-
| Bun | `bun add @violetflux/kerros` |
|
|
32
|
-
|
|
33
24
|
## Store 만들기
|
|
34
25
|
|
|
35
26
|
```tsx
|
|
@@ -63,6 +54,15 @@ function App() {
|
|
|
63
54
|
|
|
64
55
|
selector는 인라인으로 작성할 수 있습니다. 선택하지 않은 필드가 바뀌어도 `Counter`는 다시 렌더링되지 않습니다.
|
|
65
56
|
|
|
57
|
+
## 설치
|
|
58
|
+
|
|
59
|
+
| 패키지 매니저 | 명령 |
|
|
60
|
+
| --- | --- |
|
|
61
|
+
| npm | `npm install @violetflux/kerros` |
|
|
62
|
+
| pnpm | `pnpm add @violetflux/kerros` |
|
|
63
|
+
| Yarn | `yarn add @violetflux/kerros` |
|
|
64
|
+
| Bun | `bun add @violetflux/kerros` |
|
|
65
|
+
|
|
66
66
|
## 작동 방식
|
|
67
67
|
|
|
68
68
|
Provider는 Store Hook을 실행하고 Context에는 안정적인 구독 컨테이너만 전달합니다. 커밋된 스냅샷은 `subscribe/getSnapshot`으로 게시되며 컴포넌트는 선택 결과가 바뀔 때만 다시 렌더링됩니다.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://violetflux.github.io/kerros/">
|
|
3
|
-
<img src="https://raw.githubusercontent.com/violetflux/kerros/main/docs/public/banner.svg" alt="Kerros —
|
|
3
|
+
<img src="https://raw.githubusercontent.com/violetflux/kerros/main/docs/public/banner.svg" alt="Kerros — share state between React components" width="100%" />
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
@@ -25,34 +25,6 @@ Kerros is a lightweight way to share state between React components.
|
|
|
25
25
|
|
|
26
26
|
Write a Store the same way you write a custom Hook. When local state needs to be shared, pass it to `createStore`, mount its Provider, and let each component select what it needs.
|
|
27
27
|
|
|
28
|
-
## Install
|
|
29
|
-
|
|
30
|
-
| Package manager | Command |
|
|
31
|
-
| --- | --- |
|
|
32
|
-
| npm | `npm install @violetflux/kerros` |
|
|
33
|
-
| pnpm | `pnpm add @violetflux/kerros` |
|
|
34
|
-
| Yarn | `yarn add @violetflux/kerros` |
|
|
35
|
-
| Bun | `bun add @violetflux/kerros` |
|
|
36
|
-
|
|
37
|
-
React 17, React 18, and React 19 are supported.
|
|
38
|
-
|
|
39
|
-
## Why Kerros?
|
|
40
|
-
|
|
41
|
-
- **Almost nothing new to learn** — reuse the React knowledge you already have; if you can write a custom Hook, you can write a Store
|
|
42
|
-
- **Designed for flexible refactoring** — Stores and components use the same Hook API, so local state can become shared state with very little work
|
|
43
|
-
- **Local and application-wide state** — Provider placement determines the Store scope, balancing flexibility with simplicity
|
|
44
|
-
- **Performance and TypeScript support** — focused selector subscriptions avoid unrelated rerenders and Store types are inferred automatically
|
|
45
|
-
|
|
46
|
-
## From state management to state sharing
|
|
47
|
-
|
|
48
|
-
Libraries such as Redux, Zustand, and Recoil can all share data, but their central job is still to organize state, update it, and define how data flows. “State management” is the right name for them.
|
|
49
|
-
|
|
50
|
-
Kerros focuses on a smaller and more direct problem. It does not invent a new data model or prescribe how async logic should work. It answers one question: **how can a piece of Hook state be shared between React components?**
|
|
51
|
-
|
|
52
|
-
Passing `value` and `onChange` through layer after layer damages component boundaries. Moving everything into one global Store does not automatically make an application scalable or maintainable either.
|
|
53
|
-
|
|
54
|
-
Kerros stays simple, lightweight, and reliable. Write local state as an ordinary Hook, share it only when necessary, use a Provider to set its scope, and use selectors to choose what each component observes.
|
|
55
|
-
|
|
56
28
|
## Quick start
|
|
57
29
|
|
|
58
30
|
### Create a Store
|
|
@@ -128,6 +100,37 @@ function TaskList() {
|
|
|
128
100
|
|
|
129
101
|
Kerros shallowly compares the selector object's top-level fields. When those selected fields stay equal, other Store updates do not rerender `TaskList`. The selector can stay inline and does not need `useCallback`.
|
|
130
102
|
|
|
103
|
+
## Install
|
|
104
|
+
|
|
105
|
+
| Package manager | Command |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| npm | `npm install @violetflux/kerros` |
|
|
108
|
+
| pnpm | `pnpm add @violetflux/kerros` |
|
|
109
|
+
| Yarn | `yarn add @violetflux/kerros` |
|
|
110
|
+
| Bun | `bun add @violetflux/kerros` |
|
|
111
|
+
|
|
112
|
+
React 17, React 18, and React 19 are supported.
|
|
113
|
+
|
|
114
|
+
## Why Kerros?
|
|
115
|
+
|
|
116
|
+
- **Almost nothing new to learn** — reuse the React knowledge you already have; if you can write a custom Hook, you can write a Store
|
|
117
|
+
- **Designed for flexible refactoring** — Stores and components use the same Hook API, so local state can become shared state with very little work
|
|
118
|
+
- **Local and application-wide state** — Provider placement determines the Store scope, balancing flexibility with simplicity
|
|
119
|
+
- **Avoid Context-wide rerenders** — Context carries a stable container and components rerender only when their selector result changes
|
|
120
|
+
- **TypeScript support** — Store and selector types are inferred without duplicate declarations
|
|
121
|
+
|
|
122
|
+
## From state management to state sharing
|
|
123
|
+
|
|
124
|
+
Libraries such as Redux, Zustand, and Recoil can all share data, but their central job is still to organize state, update it, and define how data flows. “State management” is the right name for them.
|
|
125
|
+
|
|
126
|
+
Kerros focuses on a smaller and more direct problem. It does not invent a new data model or prescribe how async logic should work. It answers one question: **how can a piece of Hook state be shared between React components?**
|
|
127
|
+
|
|
128
|
+
Passing `value` and `onChange` through layer after layer damages component boundaries. Moving everything into one global Store does not automatically make an application scalable or maintainable either.
|
|
129
|
+
|
|
130
|
+
Sharing frequently changing state through React Context directly also causes repeated work: every Context value change rerenders all consumers. Kerros keeps Provider scoping and multiple instances, but Context carries only a stable container. Components subscribe through selectors and rerender only when their selected result changes.
|
|
131
|
+
|
|
132
|
+
Kerros stays simple, lightweight, and reliable. Write local state as an ordinary Hook, share it only when necessary, use a Provider to set its scope, and use selectors to choose what each component observes.
|
|
133
|
+
|
|
131
134
|
## Multiple instances
|
|
132
135
|
|
|
133
136
|
Each `TaskProvider` owns independent state:
|
package/README.zh-CN.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://violetflux.github.io/kerros/zh/">
|
|
3
|
-
<img src="https://raw.githubusercontent.com/violetflux/kerros/main/docs/public/banner.svg" alt="Kerros —
|
|
3
|
+
<img src="https://raw.githubusercontent.com/violetflux/kerros/main/docs/public/banner.svg" alt="Kerros — 在 React 组件间共享状态" width="100%" />
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
@@ -18,34 +18,6 @@ Kerros 是一个在 React 组件间共享状态的轻量方案。
|
|
|
18
18
|
|
|
19
19
|
你怎么写 custom Hook,就可以怎么写 Store。只有当局部状态需要被多个组件使用时,再交给 `createStore`,用 Provider 决定共享范围,用 selector 选择组件真正需要的数据。
|
|
20
20
|
|
|
21
|
-
## 安装
|
|
22
|
-
|
|
23
|
-
| 包管理器 | 命令 |
|
|
24
|
-
| --- | --- |
|
|
25
|
-
| npm | `npm install @violetflux/kerros` |
|
|
26
|
-
| pnpm | `pnpm add @violetflux/kerros` |
|
|
27
|
-
| Yarn | `yarn add @violetflux/kerros` |
|
|
28
|
-
| Bun | `bun add @violetflux/kerros` |
|
|
29
|
-
|
|
30
|
-
支持 React 17、React 18 和 React 19。
|
|
31
|
-
|
|
32
|
-
## 为什么要用 Kerros?
|
|
33
|
-
|
|
34
|
-
- **几乎没有学习成本**:直接复用已有的 React 知识,你怎么写 custom Hook,就可以怎么写 Store
|
|
35
|
-
- **为灵活重构而设计**:Store 和组件使用同一套 Hook API,可以近乎零成本地把组件局部状态转换成组件间共享状态
|
|
36
|
-
- **同时支持局部状态和全局状态**:Provider 决定 Store 的作用域,在灵活和简单之间取得平衡
|
|
37
|
-
- **优秀的性能和 TypeScript 支持**:selector 精确订阅,选择结果不变的组件不会重渲染,Store 类型可以自动推断
|
|
38
|
-
|
|
39
|
-
## 从状态管理到状态共享
|
|
40
|
-
|
|
41
|
-
Redux、Zustand、Recoil 这些状态管理库当然也能解决数据共享问题,但它们最核心的能力仍然是组织数据、操作数据和约束数据流,因此它们应该被称为“状态管理”工具。
|
|
42
|
-
|
|
43
|
-
Kerros 想解决的问题更小,也更直接。它不发明新的数据结构,不规定异步和数据流应该怎么写,只聚焦一个痛点:**如何在多个 React 组件间共享一段 Hook 状态。**
|
|
44
|
-
|
|
45
|
-
层层传递 `value`、`onChange` 会逐渐破坏组件边界;粗暴地把数据全部塞进一个全局 Store,也不会自动让应用获得更好的扩展性和可维护性。
|
|
46
|
-
|
|
47
|
-
Kerros 简单、轻量、可靠。先把状态写成普通 Hook,需要共享时再交给 `createStore`;Provider 决定状态共享到哪里,selector 决定每个组件订阅什么。
|
|
48
|
-
|
|
49
21
|
## 快速上手
|
|
50
22
|
|
|
51
23
|
### 创建 Store
|
|
@@ -121,6 +93,37 @@ function TaskList() {
|
|
|
121
93
|
|
|
122
94
|
Kerros 会浅比较 selector 返回对象的顶层字段。只要这些选中字段保持不变,Store 的其他更新就不会让 `TaskList` 重渲染。selector 可以直接写在调用位置,不需要 `useCallback`。
|
|
123
95
|
|
|
96
|
+
## 安装
|
|
97
|
+
|
|
98
|
+
| 包管理器 | 命令 |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| npm | `npm install @violetflux/kerros` |
|
|
101
|
+
| pnpm | `pnpm add @violetflux/kerros` |
|
|
102
|
+
| Yarn | `yarn add @violetflux/kerros` |
|
|
103
|
+
| Bun | `bun add @violetflux/kerros` |
|
|
104
|
+
|
|
105
|
+
支持 React 17、React 18 和 React 19。
|
|
106
|
+
|
|
107
|
+
## 为什么要用 Kerros?
|
|
108
|
+
|
|
109
|
+
- **几乎没有学习成本**:直接复用已有的 React 知识,你怎么写 custom Hook,就可以怎么写 Store
|
|
110
|
+
- **为灵活重构而设计**:Store 和组件使用同一套 Hook API,可以近乎零成本地把组件局部状态转换成组件间共享状态
|
|
111
|
+
- **同时支持局部状态和全局状态**:Provider 决定 Store 的作用域,在灵活和简单之间取得平衡
|
|
112
|
+
- **解决 Context 的重复渲染问题**:Context 只传递稳定容器,selector 选择结果不变的组件不会重渲染
|
|
113
|
+
- **优秀的 TypeScript 支持**:Store 和 selector 类型自动推断,不需要重复声明
|
|
114
|
+
|
|
115
|
+
## 从状态管理到状态共享
|
|
116
|
+
|
|
117
|
+
Redux、Zustand、Recoil 这些状态管理库当然也能解决数据共享问题,但它们最核心的能力仍然是组织数据、操作数据和约束数据流,因此它们应该被称为“状态管理”工具。
|
|
118
|
+
|
|
119
|
+
Kerros 想解决的问题更小,也更直接。它不发明新的数据结构,不规定异步和数据流应该怎么写,只聚焦一个痛点:**如何在多个 React 组件间共享一段 Hook 状态。**
|
|
120
|
+
|
|
121
|
+
层层传递 `value`、`onChange` 会逐渐破坏组件边界;粗暴地把数据全部塞进一个全局 Store,也不会自动让应用获得更好的扩展性和可维护性。
|
|
122
|
+
|
|
123
|
+
直接用 React Context 共享变化频繁的状态也会带来重复渲染:Context value 每次变化,所有消费者都会更新。Kerros 保留 Provider 的作用域和多实例能力,但 Context 只传递稳定容器;组件通过 selector 订阅数据,只有选择结果变化时才重渲染。
|
|
124
|
+
|
|
125
|
+
Kerros 简单、轻量、可靠。先把状态写成普通 Hook,需要共享时再交给 `createStore`;Provider 决定状态共享到哪里,selector 决定每个组件订阅什么。
|
|
126
|
+
|
|
124
127
|
## 多个实例
|
|
125
128
|
|
|
126
129
|
每个 `TaskProvider` 都拥有独立状态:
|