storion 0.10.0 → 0.10.2

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.
Files changed (2) hide show
  1. package/README.md +82 -68
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  <h1 align="center">Storion</h1>
6
6
 
7
7
  <p align="center">
8
- <strong>Reactive state management with automatic dependency tracking</strong>
8
+ <strong>State management that gets out of your way</strong>
9
9
  </p>
10
10
 
11
11
  <p align="center">
@@ -24,94 +24,108 @@
24
24
 
25
25
  ---
26
26
 
27
- ## Why Storion?
27
+ ## The Simplest Counter You'll Ever Write
28
+
29
+ ```tsx
30
+ import { create } from "storion/react";
31
+
32
+ const [_, useCounter] = create({
33
+ state: { count: 0 },
34
+ setup: ({ state }) => ({
35
+ inc: () => state.count++,
36
+ dec: () => state.count--,
37
+ }),
38
+ });
39
+
40
+ function Counter() {
41
+ const { count, inc, dec } = useCounter((s, a) => ({ count: s.count, ...a }));
42
+ return <button onClick={inc}>{count}</button>;
43
+ }
44
+ ```
28
45
 
29
- **Simple at first. Powerful as you grow.**
46
+ **That's it.** No Provider. No boilerplate. No ceremony.
47
+
48
+ ---
30
49
 
31
- Start with basic stores and direct mutations. As your app grows, layer in async state, effects, dependency injection, and middleware — all without rewriting existing code.
50
+ ## Why Storion?
32
51
 
33
- ## Features
52
+ | Pain Point | Storion's Answer |
53
+ | ------------------------- | ----------------------------------------------- |
54
+ | 🤯 Too much boilerplate | One `create()` call. Done. |
55
+ | 🐌 Unnecessary re-renders | Auto-tracks what you read, updates only that |
56
+ | 😵 Complex async handling | Built-in loading states, cancellation, Suspense |
57
+ | 🔧 Provider hell | Optional. Use it when you need it |
58
+ | 📦 Bundle anxiety | ~4KB gzipped. Seriously. |
34
59
 
35
- | | |
36
- | -------------------- | ---------------------------------------- |
37
- | 🎯 **Auto-tracking** | Dependencies tracked when you read state |
38
- | ⚡ **Fine-grained** | Only re-render what changed |
39
- | 🔒 **Type-safe** | Full TypeScript with excellent inference |
40
- | 📦 **Tiny** | ~4KB minified + gzipped |
41
- | ⏳ **Async** | First-class loading states with Suspense |
42
- | 🛠️ **DevTools** | Built-in debugging panel |
60
+ ---
43
61
 
44
- ## Installation
62
+ ## Features at a Glance
45
63
 
46
- ```bash
47
- npm install storion
64
+ ```
65
+ Auto-tracking Read state → automatically subscribed
66
+ ✦ Fine-grained Change count? Only Counter re-renders
67
+ ✦ Type-safe Full inference, zero manual types
68
+ ✦ Async-first Loading, error, stale states built-in
69
+ ✦ DevTools Time-travel debugging included
70
+ ✦ Scalable From counter to enterprise, same API
48
71
  ```
49
72
 
50
- ## Quick Start
73
+ ---
51
74
 
52
- **Read state Storion tracks it. State changes → Only affected components re-render.**
75
+ ## Growing With You
53
76
 
54
- ```tsx
55
- import { store } from "storion";
56
- import { useStore } from "storion/react";
77
+ **Start simple:**
57
78
 
58
- // Define a store
59
- const counterStore = store({
60
- name: "counter",
61
- state: { count: 0 },
62
- setup({ state }) {
63
- return {
64
- inc: () => state.count++,
65
- dec: () => state.count--,
66
- };
67
- },
79
+ ```tsx
80
+ const [_, useAuth] = create({
81
+ state: { user: null },
82
+ setup: ({ state }) => ({
83
+ login: (user) => {
84
+ state.user = user;
85
+ },
86
+ logout: () => {
87
+ state.user = null;
88
+ },
89
+ }),
68
90
  });
69
-
70
- // Use in React
71
- function Counter() {
72
- const { count, inc, dec } = useStore(({ get }) => {
73
- const [state, actions] = get(counterStore);
74
- return { count: state.count, ...actions };
75
- });
76
-
77
- return (
78
- <div>
79
- <button onClick={dec}>-</button>
80
- <span>{count}</span>
81
- <button onClick={inc}>+</button>
82
- </div>
83
- );
84
- }
85
91
  ```
86
92
 
87
- ## Async State
93
+ **Add async when ready:**
88
94
 
89
95
  ```tsx
90
- import { async } from "storion/async";
91
-
92
- const userStore = store({
93
- name: "user",
94
- state: { user: async.fresh<User>() },
95
- setup({ focus }) {
96
- const userQuery = async.action(focus("user"), async (ctx, id: string) => {
97
- const res = await fetch(`/api/users/${id}`, { signal: ctx.signal });
98
- return res.json();
99
- });
100
-
101
- return { fetchUser: userQuery.dispatch };
96
+ const [_, useUsers] = create({
97
+ state: { users: async.stale([]) },
98
+ setup: ({ focus }) => {
99
+ const query = async(focus("users"), (ctx) =>
100
+ fetch("/api/users", { signal: ctx.signal }).then((r) => r.json())
101
+ );
102
+ return { fetch: query.dispatch, refresh: query.refresh };
102
103
  },
103
104
  });
104
105
  ```
105
106
 
106
- ## Learn More
107
+ **Scale to multi-store apps:**
107
108
 
108
- 📚 **[Full Documentation](https://linq2js.github.io/storion/)** — Guides, examples, and API reference
109
+ ```tsx
110
+ // When you need shared containers, dependency injection, middleware...
111
+ <StoreProvider>
112
+ <App />
113
+ </StoreProvider>
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Documentation
109
119
 
110
- - [Getting Started](https://linq2js.github.io/storion/guide/getting-started.html)
111
- - [Core Concepts](https://linq2js.github.io/storion/guide/core-concepts.html)
112
- - [Async State](https://linq2js.github.io/storion/guide/async.html)
113
- - [API Reference](https://linq2js.github.io/storion/api/store.html)
114
- - [Live Demos](https://linq2js.github.io/storion/demos.html)
120
+ 📚 **[Full Documentation](https://linq2js.github.io/storion/)** — Everything you need
121
+
122
+ - [Getting Started](https://linq2js.github.io/storion/guide/getting-started.html) — 5 min setup
123
+ - [Core Concepts](https://linq2js.github.io/storion/guide/core-concepts.html) — How it works
124
+ - [Async State](https://linq2js.github.io/storion/guide/async.html) — Loading states made easy
125
+ - [API Reference](https://linq2js.github.io/storion/api/store.html) — Every function documented
126
+ - [Live Demos](https://linq2js.github.io/storion/demos.html) — See it in action
127
+
128
+ ---
115
129
 
116
130
  ## License
117
131
 
@@ -120,5 +134,5 @@ MIT © [linq2js](https://github.com/linq2js)
120
134
  ---
121
135
 
122
136
  <p align="center">
123
- <sub>Built with ❤️ for the React community</sub>
137
+ <sub>Built with ❤️ for developers who value simplicity</sub>
124
138
  </p>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storion",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Reactive stores for modern apps. Type-safe. Auto-tracked. Effortlessly composable",
5
5
  "type": "module",
6
6
  "main": "./dist/storion.js",