react-state-basis 0.1.0 → 0.1.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 +50 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  [![npm version](https://badge.fury.io/js/react-state-basis.svg)](https://www.npmjs.com/package/react-state-basis)
2
+ [![View on GitHub](https://img.shields.io/badge/View_Documentation-GitHub-black?logo=github)](https://github.com/liovic/react-state-basis#readme)
2
3
 
3
4
  # 📐 REACT-STATE-BASIS
4
5
  ### **Behavioral State Analysis for React**
@@ -18,6 +19,14 @@ Inspired by the work of **Sheldon Axler** (*"Linear Algebra Done Right"*), Basis
18
19
 
19
20
  ---
20
21
 
22
+ ## 📦 Installation
23
+
24
+ ```bash
25
+ npm i react-state-basis
26
+ ```
27
+
28
+ ---
29
+
21
30
  ## 🧠 The Philosophy: State as a Vector Space
22
31
 
23
32
  In a perfectly architected application, every state variable should represent a **unique dimension of information**.
@@ -129,6 +138,7 @@ export default function Root() {
129
138
  ### 2. Use Drop-in Replacement Imports
130
139
  Replace your standard React hook imports with `react-state-basis`. This allows the engine to instrument your state updates without changing your component logic.
131
140
 
141
+ **Standard Named Imports (Recommended):**
132
142
  ```tsx
133
143
  // ❌ Change this:
134
144
  // import { useState, useEffect } from 'react';
@@ -141,7 +151,46 @@ function MyComponent() {
141
151
  }
142
152
  ```
143
153
 
144
- > Note: React-State-Basis includes an optional Babel plugin that automatically labels state variables for richer diagnostics.
154
+ **Namespace Imports:**
155
+ Basis also supports namespace imports if you prefer to keep your hooks grouped:
156
+ ```tsx
157
+ import * as Basis from 'react-state-basis';
158
+
159
+ function MyComponent() {
160
+ const [count, setCount] = Basis.useState(0); // Also tracked automatically
161
+ }
162
+ ```
163
+
164
+ ### 3. The Babel plugin
165
+ The Babel plugin is optional but highly recommended. Without it, state variables will be tracked as anonymous_state, making it difficult to identify specific redundancies in large applications. You can also manually provide a label as the last argument to any hook if you prefer not to use Babel.
166
+
167
+ > If you choose not to use the Babel plugin, you can still get specific labels by passing a string as the last argument:
168
+
169
+ ```tsx
170
+ const [count, setCount] = useState(0, "MyComponent -> count");
171
+ ```
172
+
173
+ To get the most out of Basis, you should enable the Babel plugin. This automatically injects the **filename** and **variable name** into your hooks so you don't have to label them manually.
174
+
175
+ If you are using **Vite**, add the following to your `vite.config.ts`:
176
+
177
+ ```typescript
178
+ // vite.config.ts
179
+ import { defineConfig } from 'vite'
180
+ import react from '@vitejs/plugin-react'
181
+
182
+ export default defineConfig({
183
+ plugins: [
184
+ react({
185
+ babel: {
186
+ // Automatically labels useState, useMemo, etc.
187
+ // for richer diagnostics in the console.
188
+ plugins: [['react-state-basis/plugin']]
189
+ }
190
+ })
191
+ ]
192
+ })
193
+ ```
145
194
 
146
195
 
147
196
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-state-basis",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A linear algebra-powered React architectural tool that detects redundant state and synchronization anti-patterns by modeling state transitions as vectors in a basis.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",