react-state-basis 0.1.4 β 0.2.1
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.md +69 -72
- package/dist/index.d.mts +22 -4
- package/dist/index.d.ts +22 -4
- package/dist/index.js +130 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +129 -21
- package/dist/index.mjs.map +1 -1
- package/dist/plugin.js +23 -4
- package/dist/production.d.mts +32 -0
- package/dist/production.d.ts +32 -0
- package/dist/production.js +115 -0
- package/dist/production.js.map +1 -0
- package/dist/production.mjs +58 -0
- package/dist/production.mjs.map +1 -0
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Inspired by the work of **Sheldon Axler** (*"Linear Algebra Done Right"*), Basis
|
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
27
|
-
##
|
|
27
|
+
## Installation
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
30
|
npm i react-state-basis
|
|
@@ -32,26 +32,26 @@ npm i react-state-basis
|
|
|
32
32
|
|
|
33
33
|
---
|
|
34
34
|
|
|
35
|
-
##
|
|
35
|
+
## The Philosophy: State as a Vector Space
|
|
36
36
|
|
|
37
37
|
In a perfectly architected application, every state variable should represent a **unique dimension of information**.
|
|
38
38
|
|
|
39
|
-
Mathematically, your state variables
|
|
39
|
+
Mathematically, your state variables $(v_1, v_2, \dots, v_n)$ should form a **Basis** for your application's state space $V$. A Basis must be **linearly independent**. If two variables update in perfect synchronization, they are **collinear** (linearly dependent). This creates:
|
|
40
40
|
1. **Redundant Renders:** Multiple cycles for a single logical change.
|
|
41
41
|
2. **State Desynchronization:** High risk of "impossible states" (e.g., `user` exists but `isLoggedIn` is false).
|
|
42
42
|
3. **Architectural Entropy:** High cognitive load in tracing data causality.
|
|
43
43
|
|
|
44
44
|
---
|
|
45
|
-
##
|
|
45
|
+
## See It In Action
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
### Detecting Causal Links & Double Renders
|
|
48
48
|

|
|
49
49
|
|
|
50
50
|
**The Problem:** Manually syncing `fahrenheit` via `useEffect` creates a "Double Render Cycle" (React renders once for Celsius, then again for Fahrenheit).
|
|
51
51
|
|
|
52
52
|
**The Basis Solution:** Basis identifies this sequential dependency in real-time. It flags the `Causal Link` and provides a copy-paste refactor to move from expensive state synchronization to a pure **Mathematical Projection** (`useMemo`).
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
### Identifying Boolean Entanglement
|
|
55
55
|

|
|
56
56
|
|
|
57
57
|
**The Problem:** Using multiple boolean flags (`isLoading`, `isSuccess`, `hasData`) often leads to "impossible states" and redundant updates.
|
|
@@ -60,7 +60,7 @@ Mathematically, your state variables $\{v_1, v_2, \dots, v_n\}$ should form a **
|
|
|
60
60
|
|
|
61
61
|
**The Insight:** It flags a **Dimension Collapse**, alerting you that 3 independent state variables are actually spanning only 1 dimension of information. It suggests consolidating them into a single state machine or a status string.
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
### Circuit Breaker (Infinite Loop Protection)
|
|
64
64
|

|
|
65
65
|
|
|
66
66
|
**The Trap:** A recursive `useEffect` that triggers an infinite state oscillation, a common mistake that usually freezes the browser's main thread.
|
|
@@ -69,7 +69,7 @@ Mathematically, your state variables $\{v_1, v_2, \dots, v_n\}$ should form a **
|
|
|
69
69
|
|
|
70
70
|
**The Result:** The engine forcefully halts the update chain before the browser locks up. It provides a critical diagnostic report with the exact location of the loop, allowing you to fix the bug without having to kill the browser process.
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
### Cross-Context Dependency Audit
|
|
73
73
|

|
|
74
74
|
|
|
75
75
|
**The Scenario:** Modern apps often split state into multiple providers (e.g., `AuthContext` and `ThemeContext`). While architecturally decoupled, they are often **manually synchronized** in logic (e.g., switching to "dark theme" every time a user logs in).
|
|
@@ -80,7 +80,7 @@ Mathematically, your state variables $\{v_1, v_2, \dots, v_n\}$ should form a **
|
|
|
80
80
|
|
|
81
81
|
**The Benefit:** This helps architects identify states that should potentially be merged or derived from a single source of truth, even when they are physically separated across different providers.
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
### System Health & Structural Audit
|
|
84
84
|

|
|
85
85
|
|
|
86
86
|
**System Rank & Efficiency:** Basis performs a global audit of your state space to calculate its **Mathematical Rank**βthe actual number of independent information dimensions. An efficiency of **40% (Rank: 4/10)** warns you that 60% of your state is mathematically redundant.
|
|
@@ -126,7 +126,7 @@ It is a specialized diagnostic tool for one very common anti-pattern - and it tr
|
|
|
126
126
|
To enable the mathematical monitoring of your application, follow these two steps:
|
|
127
127
|
|
|
128
128
|
### 1. Initialize the Basis Monitor
|
|
129
|
-
Wrap your application root
|
|
129
|
+
Wrap your application root with the `BasisProvider`.
|
|
130
130
|
|
|
131
131
|
```tsx
|
|
132
132
|
import { BasisProvider } from 'react-state-basis';
|
|
@@ -139,6 +139,10 @@ export default function Root() {
|
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
141
|
```
|
|
142
|
+
**Props:**
|
|
143
|
+
* `debug (boolean)`:
|
|
144
|
+
* `true` (Default): Enables the real-time diagnostic dashboard, visual system status badge (Web only), and detailed console auditing (including the Circuit Breaker).
|
|
145
|
+
* `false`: Completely deactivates the Basis engine. No background analysis, no memory consumption, and no logging. The "Circuit Breaker" is also disabled in this mode to allow for a zero-overhead, raw React experience in development.
|
|
142
146
|
|
|
143
147
|
### 2. Use Drop-in Replacement Imports
|
|
144
148
|
Replace your standard React hook imports with `react-state-basis`. This allows the engine to instrument your state updates without changing your component logic.
|
|
@@ -149,7 +153,19 @@ Replace your standard React hook imports with `react-state-basis`. This allows t
|
|
|
149
153
|
// import { useState, useEffect } from 'react';
|
|
150
154
|
|
|
151
155
|
// β
To this:
|
|
152
|
-
import {
|
|
156
|
+
import {
|
|
157
|
+
useState,
|
|
158
|
+
useEffect,
|
|
159
|
+
useMemo,
|
|
160
|
+
useCallback,
|
|
161
|
+
useContext,
|
|
162
|
+
useRef,
|
|
163
|
+
useLayoutEffect,
|
|
164
|
+
useId,
|
|
165
|
+
useSyncExternalStore,
|
|
166
|
+
useDeferredValue,
|
|
167
|
+
useTransition
|
|
168
|
+
} from 'react-state-basis';
|
|
153
169
|
|
|
154
170
|
function MyComponent() {
|
|
155
171
|
const [data, setData] = useState([]); // Automatically vectorized and tracked
|
|
@@ -166,6 +182,15 @@ function MyComponent() {
|
|
|
166
182
|
}
|
|
167
183
|
```
|
|
168
184
|
|
|
185
|
+
## Ghost Mode: Zero-Overhead Production
|
|
186
|
+
Basis is a **development-only** infrastructure.
|
|
187
|
+
|
|
188
|
+
Using **Conditional Exports**, Basis automatically detects your environment:
|
|
189
|
+
* **Development:** The full Linear Algebra engine and auditor are active.
|
|
190
|
+
* **Production:** Basis swaps itself for a **Zero-Op version**. It exports raw React hooks directly with no additional logic, ensuring **zero bundle bloat** and **zero performance penalty** for your end users.
|
|
191
|
+
|
|
192
|
+
You can safely keep `react-state-basis` in your code without manual removal before deployment.
|
|
193
|
+
|
|
169
194
|
### 3. The Babel plugin
|
|
170
195
|
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.
|
|
171
196
|
|
|
@@ -200,7 +225,7 @@ export default defineConfig({
|
|
|
200
225
|
|
|
201
226
|
---
|
|
202
227
|
|
|
203
|
-
##
|
|
228
|
+
## Technical Architecture
|
|
204
229
|
|
|
205
230
|
React-State-Basis utilizes a three-tier instrumentation pipeline to audit your system:
|
|
206
231
|
|
|
@@ -227,7 +252,7 @@ If $\cos(\theta) \approx 1.00$, the vectors are collinear (linearly dependent),
|
|
|
227
252
|
|
|
228
253
|
---
|
|
229
254
|
|
|
230
|
-
##
|
|
255
|
+
## Real-World Demonstration: The Auth Anti-Pattern
|
|
231
256
|
|
|
232
257
|
Developers often manually sync related states, creating a redundant dimension in the Basis:
|
|
233
258
|
|
|
@@ -238,7 +263,7 @@ const [isLogged, setIsLogged] = useState(false);
|
|
|
238
263
|
|
|
239
264
|
const onLogin = (userData) => {
|
|
240
265
|
setUser(userData);
|
|
241
|
-
setIsLogged(true); //
|
|
266
|
+
setIsLogged(true); // BASIS ALERT: Always updated in sync with 'user'
|
|
242
267
|
};
|
|
243
268
|
```
|
|
244
269
|
**Engine Analysis:** The Engine calculates that `user` and `isLogged` are perfectly synchronized. It warns you that you are using two dimensions to describe a 1D problem.
|
|
@@ -252,28 +277,28 @@ const isLogged = useMemo(() => !!user, [user]); // Mathematically clean
|
|
|
252
277
|
|
|
253
278
|
---
|
|
254
279
|
|
|
255
|
-
##
|
|
280
|
+
## Diagnostic Dashboard
|
|
256
281
|
|
|
257
282
|
Basis provides high-end diagnostic feedback directly in your browser console:
|
|
258
283
|
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
284
|
+
* **Location Tracking:** Identifies exact files and variable names causing redundancy.
|
|
285
|
+
* **Refactor Snippets:** Provides dark-themed code blocks you can copy-paste to fix your state architecture.
|
|
286
|
+
* **Health Matrix:** Call `printBasisReport()` to see your **Efficiency Score** and the full **Correlation Matrix** of your application.
|
|
262
287
|
|
|
263
288
|
---
|
|
264
289
|
|
|
265
|
-
##
|
|
290
|
+
## Key Features
|
|
266
291
|
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
292
|
+
* **Content-Agnostic:** Identifies logical links through temporal synchronization, not data types.
|
|
293
|
+
* **Circuit Breaker:** Halts high-frequency state oscillations (Infinite Loops) to protect the browser thread.
|
|
294
|
+
* **Causal Detective:** Tracks causality chains from `useEffect` to `useState` to identify cascading renders.
|
|
295
|
+
* **Zero Lock-in:** Simply point your imports back to `'react'` in production. Basis is a **Development-time verification infrastructure**.
|
|
271
296
|
|
|
272
297
|
---
|
|
273
298
|
|
|
274
|
-
##
|
|
299
|
+
## Mathematical Inspiration
|
|
275
300
|
|
|
276
|
-
###
|
|
301
|
+
### The Basis Theorem
|
|
277
302
|
According to Axler (*Linear Algebra Done Right, Definition 2.27*):
|
|
278
303
|
|
|
279
304
|
> A **basis** of $V$ is a list of vectors in $V$ that is **linearly independent** and **spans** $V$.
|
|
@@ -292,7 +317,7 @@ React-State-Basis bridges the gap between abstract algebra and UI engineering.
|
|
|
292
317
|
By ensuring your application state forms an independent, non-redundant basis, it helps you build software that is inherently more stable, efficient, and easier to reason about.
|
|
293
318
|
---
|
|
294
319
|
|
|
295
|
-
###
|
|
320
|
+
### Implementation of the Linear Dependency Lemma
|
|
296
321
|
According to Axler (*Lemma 2.21*), in a linearly dependent **list** of vectors, there exists an index $j$ such that $v_j$ is in the span of the **preceding** vectors ($v_1, \dots, v_{j-1}$).
|
|
297
322
|
|
|
298
323
|
**React-State-Basis** implements this sequential logic to audit your state:
|
|
@@ -304,7 +329,7 @@ According to Axler (*Lemma 2.21*), in a linearly dependent **list** of vectors,
|
|
|
304
329
|
|
|
305
330
|
---
|
|
306
331
|
|
|
307
|
-
##
|
|
332
|
+
## Design Constraints & Heuristics
|
|
308
333
|
|
|
309
334
|
React-State-Basis uses probabilistic, time-windowed heuristics to approximate linear dependence.
|
|
310
335
|
As with any runtime analysis:
|
|
@@ -330,8 +355,6 @@ It answers questions like:
|
|
|
330
355
|
- *βWhich state is the true source of truth?β*
|
|
331
356
|
- *βAm I manually synchronizing derived data?β*
|
|
332
357
|
|
|
333
|
-
---
|
|
334
|
-
|
|
335
358
|
### **Does this change React behavior or execution order?**
|
|
336
359
|
No.
|
|
337
360
|
|
|
@@ -340,19 +363,12 @@ It observes state updates at runtime and logs diagnostics during development.
|
|
|
340
363
|
|
|
341
364
|
Removing React-State-Basis restores your application to standard React behavior with no residual effects.
|
|
342
365
|
|
|
343
|
-
---
|
|
344
|
-
|
|
345
366
|
### **Is this safe to use in production?**
|
|
346
367
|
React-State-Basis is designed for **development-time analysis**.
|
|
347
368
|
|
|
348
|
-
|
|
349
|
-
- adds runtime overhead
|
|
350
|
-
- logs diagnostic output
|
|
351
|
-
- performs continuous analysis
|
|
369
|
+
Minimal in development, zero in production via Ghost Mode.
|
|
352
370
|
|
|
353
|
-
For production builds, simply switch your imports back to `'react'
|
|
354
|
-
|
|
355
|
-
---
|
|
371
|
+
For production builds, simply switch your imports back to `'react'` or keep as is.
|
|
356
372
|
|
|
357
373
|
### **How accurate is the redundancy detection?**
|
|
358
374
|
React-State-Basis uses **time-windowed behavioral analysis**, not formal proofs.
|
|
@@ -363,8 +379,6 @@ This means:
|
|
|
363
379
|
|
|
364
380
|
All results are **advisory** and should be interpreted as architectural signals, not errors.
|
|
365
381
|
|
|
366
|
-
---
|
|
367
|
-
|
|
368
382
|
### **Can this detect all redundant state?**
|
|
369
383
|
No-and thatβs intentional.
|
|
370
384
|
|
|
@@ -373,8 +387,6 @@ Two states may contain the same *data* but update independently, which is archit
|
|
|
373
387
|
|
|
374
388
|
React-State-Basis only flags redundancy when two states behave as a single information dimension over time.
|
|
375
389
|
|
|
376
|
-
---
|
|
377
|
-
|
|
378
390
|
### **Why not just use selectors or derived state manually?**
|
|
379
391
|
You should-and React-State-Basis encourages that.
|
|
380
392
|
|
|
@@ -385,8 +397,6 @@ The challenge is *finding* where derived state should exist in large or evolving
|
|
|
385
397
|
|
|
386
398
|
It surfaces opportunities for refactoring, not rules you must follow.
|
|
387
399
|
|
|
388
|
-
---
|
|
389
|
-
|
|
390
400
|
### **Does this work with Redux, Zustand, or other state managers?**
|
|
391
401
|
React-State-Basis currently instruments **React hooks directly**.
|
|
392
402
|
|
|
@@ -397,8 +407,6 @@ However, the underlying model is store-agnostic. Any system with:
|
|
|
397
407
|
|
|
398
408
|
could theoretically be analyzed using the same approach.
|
|
399
409
|
|
|
400
|
-
---
|
|
401
|
-
|
|
402
410
|
### **What about performance?**
|
|
403
411
|
React-State-Basis is optimized for real-time use in development.
|
|
404
412
|
|
|
@@ -409,16 +417,12 @@ Key design choices:
|
|
|
409
417
|
|
|
410
418
|
For typical applications, overhead is negligible. For extremely high-frequency updates (e.g., animations), React-State-Basis may emit conservative warnings.
|
|
411
419
|
|
|
412
|
-
---
|
|
413
|
-
|
|
414
420
|
### **Is this βformal verificationβ?**
|
|
415
421
|
No.
|
|
416
422
|
|
|
417
423
|
React-State-Basis performs **runtime architectural auditing**, not formal mathematical verification.
|
|
418
424
|
It applies concepts from linear algebra to **observe and analyze behavior**, not to prove correctness.
|
|
419
425
|
|
|
420
|
-
---
|
|
421
|
-
|
|
422
426
|
### **Who is this tool for?**
|
|
423
427
|
React-State-Basis is best suited for:
|
|
424
428
|
- Medium to large React applications
|
|
@@ -428,15 +432,11 @@ React-State-Basis is best suited for:
|
|
|
428
432
|
|
|
429
433
|
It may be unnecessary for small or short-lived projects.
|
|
430
434
|
|
|
431
|
-
---
|
|
432
|
-
|
|
433
435
|
### **Why linear algebra?**
|
|
434
436
|
Because state redundancy *is* linear dependence.
|
|
435
437
|
|
|
436
438
|
If two state variables always change together, they span the same dimension of information. Linear algebra provides a precise language-and useful tools-for detecting and reasoning about that relationship.
|
|
437
439
|
|
|
438
|
-
---
|
|
439
|
-
|
|
440
440
|
### **Will this ever produce false positives?**
|
|
441
441
|
Yes.
|
|
442
442
|
|
|
@@ -447,30 +447,27 @@ Think of it as an architectural smoke detector-not a fire marshal.
|
|
|
447
447
|
|
|
448
448
|
---
|
|
449
449
|
|
|
450
|
-
##
|
|
450
|
+
## Roadmap: The Path to Architectural Rigor
|
|
451
451
|
|
|
452
452
|
React-State-Basis is evolving from a runtime auditor to a complete development infrastructure. Here is the planned trajectory:
|
|
453
453
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
* **
|
|
457
|
-
* **Babel Enhancements:** Automated labeling for the entire hook suite to ensure zero-manual-config diagnostics.
|
|
454
|
+
#### **v0.2.0 β Full Hook Parity (DONE)** β
|
|
455
|
+
* **Complete API Coverage:** Added support for the entire React hook suite.
|
|
456
|
+
* **Babel Enhancements:** Automated labeling for all hooks via AST transformation.
|
|
458
457
|
* **Signature Robustness:** Smart disambiguation between dependency arrays and manual labels.
|
|
459
458
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
* **
|
|
463
|
-
* **
|
|
464
|
-
|
|
465
|
-
### **v0.4.0 - Developer Ecosystem & Visuals**
|
|
466
|
-
Tools for better ergonomics and high-level insights.
|
|
467
|
-
* **CLI Utilities (`rsb-init`, `rsb-clean`):** Automated codemods to instantly inject or remove Basis from large codebases. No more manual search-and-replace.
|
|
468
|
-
* **State-Space Visualizer:** A 2D topology map showing "Redundancy Clusters." Visualize your state vectors as physical nodes to identify where the architecture is collapsing.
|
|
459
|
+
#### **v0.2.1 β Performance & Safety (DONE)** β
|
|
460
|
+
* **Universal Support:** Environment detection (`isWeb`) to prevent crashes in **React Native** and **Expo**.
|
|
461
|
+
* **Memory Optimization:** "Ghost registration" logic to ensure zero memory footprint when `debug={false}`.
|
|
462
|
+
* **Centralized Config:** Unified engine state to prevent logging "leaks" during initialization.
|
|
469
463
|
|
|
470
|
-
|
|
471
|
-
* **
|
|
472
|
-
* **
|
|
464
|
+
#### **v0.3.0 β Modernity & Visual Ecosystem (Upcoming)**
|
|
465
|
+
* **React 19 Support:** Native integration for `use()`, `useOptimistic()`, and `useActionState()`.
|
|
466
|
+
* **CLI Utilities (`rsb-init`, `rsb-clean`):** Automated codemods to instantly inject or remove Basis from large codebases.
|
|
467
|
+
* **State-Space Visualizer:** A 2D topology map showing "Redundancy Clusters" to visualize your architecture's geometry.
|
|
473
468
|
|
|
469
|
+
#### **v1.0.0 β Formal Verification**
|
|
470
|
+
* **Architectural Gatekeeping:** CI/CD integration to fail builds on critical dimension collapses.
|
|
474
471
|
---
|
|
475
472
|
|
|
476
473
|
### π¬ Get Involved
|
|
@@ -478,4 +475,4 @@ If you have an idea for a mathematical heuristic or a DX improvement, feel free
|
|
|
478
475
|
|
|
479
476
|
---
|
|
480
477
|
*Developed by LP*
|
|
481
|
-
*For engineers who treat software as applied mathematics.*
|
|
478
|
+
*For engineers who treat software as applied mathematics.* π
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import React__default, { Dispatch, SetStateAction, Reducer, DependencyList, EffectCallback, Context, ReactNode } from 'react';
|
|
2
3
|
export { CSSProperties, Context, DependencyList, Dispatch, EffectCallback, FC, PropsWithChildren, ReactElement, ReactNode, Reducer, SetStateAction } from 'react';
|
|
3
4
|
|
|
5
|
+
interface BasisConfig {
|
|
6
|
+
debug: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare let config: BasisConfig;
|
|
9
|
+
declare const configureBasis: (newConfig: Partial<BasisConfig>) => void;
|
|
4
10
|
declare const history: Map<string, number[]>;
|
|
5
11
|
declare const currentTickBatch: Set<string>;
|
|
6
12
|
declare const printBasisHealthReport: (threshold?: number) => void;
|
|
@@ -10,6 +16,8 @@ declare const registerVariable: (label: string) => void;
|
|
|
10
16
|
declare const unregisterVariable: (label: string) => void;
|
|
11
17
|
declare const recordUpdate: (label: string) => boolean;
|
|
12
18
|
declare const __testEngine__: {
|
|
19
|
+
config: BasisConfig;
|
|
20
|
+
configureBasis: (newConfig: Partial<BasisConfig>) => void;
|
|
13
21
|
history: Map<string, number[]>;
|
|
14
22
|
currentTickBatch: Set<string>;
|
|
15
23
|
registerVariable: (label: string) => void;
|
|
@@ -20,11 +28,21 @@ declare const __testEngine__: {
|
|
|
20
28
|
};
|
|
21
29
|
|
|
22
30
|
declare function useState<T>(initialValue: T, label?: string): [T, Dispatch<SetStateAction<T>>];
|
|
31
|
+
declare function useReducer<S, A, I>(reducer: Reducer<S, A>, initialArg: I & S, init?: any, label?: string): [S, Dispatch<A>];
|
|
23
32
|
declare function useMemo<T>(factory: () => T, depsOrLabel?: DependencyList | string, label?: string): T;
|
|
33
|
+
declare function useCallback<T extends (...args: any[]) => any>(callback: T, depsOrLabel?: DependencyList | string, label?: string): T;
|
|
24
34
|
declare function useEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string): void;
|
|
25
|
-
declare function
|
|
35
|
+
declare function useLayoutEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string): void;
|
|
36
|
+
declare function useInsertionEffect(effect: EffectCallback, deps?: DependencyList, _label?: string): void;
|
|
37
|
+
declare function useTransition(_label?: string): [boolean, (callback: () => void) => void];
|
|
38
|
+
declare function useDeferredValue<T>(value: T, initialValueOrLabel?: T | string, label?: string): T;
|
|
39
|
+
declare function useRef<T>(initialValue: T, _label?: string): React$1.RefObject<T>;
|
|
26
40
|
declare function createContext<T>(defaultValue: T, label?: string): Context<T>;
|
|
27
41
|
declare function useContext<T>(context: Context<T>): T;
|
|
42
|
+
declare function useId(_label?: string): string;
|
|
43
|
+
declare function useDebugValue<T>(value: T, formatter?: (value: T) => any, _label?: string): void;
|
|
44
|
+
declare function useImperativeHandle<T, R extends T>(ref: React.Ref<T> | undefined, init: () => R, deps?: DependencyList, _label?: string): void;
|
|
45
|
+
declare function useSyncExternalStore<Snapshot>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => Snapshot, getServerSnapshot?: () => Snapshot, _label?: string): Snapshot;
|
|
28
46
|
declare const __test__: {
|
|
29
47
|
registerVariable: (label: string) => void;
|
|
30
48
|
unregisterVariable: (label: string) => void;
|
|
@@ -39,9 +57,9 @@ interface BasisProviderProps {
|
|
|
39
57
|
children: ReactNode;
|
|
40
58
|
debug?: boolean;
|
|
41
59
|
}
|
|
42
|
-
declare const BasisProvider:
|
|
60
|
+
declare const BasisProvider: React__default.FC<BasisProviderProps>;
|
|
43
61
|
declare const useBasisConfig: () => {
|
|
44
62
|
debug: boolean;
|
|
45
63
|
};
|
|
46
64
|
|
|
47
|
-
export { BasisProvider, __testEngine__, __test__, beginEffectTracking, createContext, currentTickBatch, endEffectTracking, history, printBasisHealthReport, recordUpdate, registerVariable, unregisterVariable, useBasisConfig, useContext, useEffect, useMemo, useReducer, useState };
|
|
65
|
+
export { type BasisConfig, BasisProvider, __testEngine__, __test__, beginEffectTracking, config, configureBasis, createContext, currentTickBatch, endEffectTracking, history, printBasisHealthReport, recordUpdate, registerVariable, unregisterVariable, useBasisConfig, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import React__default, { Dispatch, SetStateAction, Reducer, DependencyList, EffectCallback, Context, ReactNode } from 'react';
|
|
2
3
|
export { CSSProperties, Context, DependencyList, Dispatch, EffectCallback, FC, PropsWithChildren, ReactElement, ReactNode, Reducer, SetStateAction } from 'react';
|
|
3
4
|
|
|
5
|
+
interface BasisConfig {
|
|
6
|
+
debug: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare let config: BasisConfig;
|
|
9
|
+
declare const configureBasis: (newConfig: Partial<BasisConfig>) => void;
|
|
4
10
|
declare const history: Map<string, number[]>;
|
|
5
11
|
declare const currentTickBatch: Set<string>;
|
|
6
12
|
declare const printBasisHealthReport: (threshold?: number) => void;
|
|
@@ -10,6 +16,8 @@ declare const registerVariable: (label: string) => void;
|
|
|
10
16
|
declare const unregisterVariable: (label: string) => void;
|
|
11
17
|
declare const recordUpdate: (label: string) => boolean;
|
|
12
18
|
declare const __testEngine__: {
|
|
19
|
+
config: BasisConfig;
|
|
20
|
+
configureBasis: (newConfig: Partial<BasisConfig>) => void;
|
|
13
21
|
history: Map<string, number[]>;
|
|
14
22
|
currentTickBatch: Set<string>;
|
|
15
23
|
registerVariable: (label: string) => void;
|
|
@@ -20,11 +28,21 @@ declare const __testEngine__: {
|
|
|
20
28
|
};
|
|
21
29
|
|
|
22
30
|
declare function useState<T>(initialValue: T, label?: string): [T, Dispatch<SetStateAction<T>>];
|
|
31
|
+
declare function useReducer<S, A, I>(reducer: Reducer<S, A>, initialArg: I & S, init?: any, label?: string): [S, Dispatch<A>];
|
|
23
32
|
declare function useMemo<T>(factory: () => T, depsOrLabel?: DependencyList | string, label?: string): T;
|
|
33
|
+
declare function useCallback<T extends (...args: any[]) => any>(callback: T, depsOrLabel?: DependencyList | string, label?: string): T;
|
|
24
34
|
declare function useEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string): void;
|
|
25
|
-
declare function
|
|
35
|
+
declare function useLayoutEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string): void;
|
|
36
|
+
declare function useInsertionEffect(effect: EffectCallback, deps?: DependencyList, _label?: string): void;
|
|
37
|
+
declare function useTransition(_label?: string): [boolean, (callback: () => void) => void];
|
|
38
|
+
declare function useDeferredValue<T>(value: T, initialValueOrLabel?: T | string, label?: string): T;
|
|
39
|
+
declare function useRef<T>(initialValue: T, _label?: string): React$1.RefObject<T>;
|
|
26
40
|
declare function createContext<T>(defaultValue: T, label?: string): Context<T>;
|
|
27
41
|
declare function useContext<T>(context: Context<T>): T;
|
|
42
|
+
declare function useId(_label?: string): string;
|
|
43
|
+
declare function useDebugValue<T>(value: T, formatter?: (value: T) => any, _label?: string): void;
|
|
44
|
+
declare function useImperativeHandle<T, R extends T>(ref: React.Ref<T> | undefined, init: () => R, deps?: DependencyList, _label?: string): void;
|
|
45
|
+
declare function useSyncExternalStore<Snapshot>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => Snapshot, getServerSnapshot?: () => Snapshot, _label?: string): Snapshot;
|
|
28
46
|
declare const __test__: {
|
|
29
47
|
registerVariable: (label: string) => void;
|
|
30
48
|
unregisterVariable: (label: string) => void;
|
|
@@ -39,9 +57,9 @@ interface BasisProviderProps {
|
|
|
39
57
|
children: ReactNode;
|
|
40
58
|
debug?: boolean;
|
|
41
59
|
}
|
|
42
|
-
declare const BasisProvider:
|
|
60
|
+
declare const BasisProvider: React__default.FC<BasisProviderProps>;
|
|
43
61
|
declare const useBasisConfig: () => {
|
|
44
62
|
debug: boolean;
|
|
45
63
|
};
|
|
46
64
|
|
|
47
|
-
export { BasisProvider, __testEngine__, __test__, beginEffectTracking, createContext, currentTickBatch, endEffectTracking, history, printBasisHealthReport, recordUpdate, registerVariable, unregisterVariable, useBasisConfig, useContext, useEffect, useMemo, useReducer, useState };
|
|
65
|
+
export { type BasisConfig, BasisProvider, __testEngine__, __test__, beginEffectTracking, config, configureBasis, createContext, currentTickBatch, endEffectTracking, history, printBasisHealthReport, recordUpdate, registerVariable, unregisterVariable, useBasisConfig, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition };
|