react-state-basis 0.2.0 β†’ 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 CHANGED
@@ -24,7 +24,7 @@ Inspired by the work of **Sheldon Axler** (*"Linear Algebra Done Right"*), Basis
24
24
 
25
25
  ---
26
26
 
27
- ## πŸ“¦ Installation
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
- ## 🧠 The Philosophy: State as a Vector Space
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 $\{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:
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
- ## πŸš€ See It In Action
45
+ ## See It In Action
46
46
 
47
- > ### πŸ’‘ Detecting Causal Links & Double Renders
47
+ ### Detecting Causal Links & Double Renders
48
48
  ![alt text](./example/screenshots/causal.gif)
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
- > ### πŸ•ΈοΈ Identifying Boolean Entanglement
54
+ ### Identifying Boolean Entanglement
55
55
  ![alt text](./example/screenshots/booleanEntanglement.gif)
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
- > ### πŸ›‘ Circuit Breaker (Infinite Loop Protection)
63
+ ### Circuit Breaker (Infinite Loop Protection)
64
64
  ![Infinite Loop GIF](./example/screenshots/infiniteLoopTrap.gif)
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
- > ### 🌐 Cross-Context Dependency Audit
72
+ ### Cross-Context Dependency Audit
73
73
  ![Cross-Context Sync GIF](./example/screenshots/initiateGlobalSync.gif)
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
- > ### πŸ“Š System Health & Structural Audit
83
+ ### System Health & Structural Audit
84
84
  ![System Health Report](./example/screenshots/systemHealthReport.gif)
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 (e.g., `main.tsx` or `App.tsx`) with the `BasisProvider`. Setting `debug={true}` enables the real-time diagnostic dashboard and the visual system status monitor.
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.
@@ -178,6 +182,15 @@ function MyComponent() {
178
182
  }
179
183
  ```
180
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
+
181
194
  ### 3. The Babel plugin
182
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.
183
196
 
@@ -212,7 +225,7 @@ export default defineConfig({
212
225
 
213
226
  ---
214
227
 
215
- ## πŸ•΅οΈβ€β™‚οΈ Technical Architecture
228
+ ## Technical Architecture
216
229
 
217
230
  React-State-Basis utilizes a three-tier instrumentation pipeline to audit your system:
218
231
 
@@ -239,7 +252,7 @@ If $\cos(\theta) \approx 1.00$, the vectors are collinear (linearly dependent),
239
252
 
240
253
  ---
241
254
 
242
- ## πŸ“ Real-World Demonstration: The Auth Anti-Pattern
255
+ ## Real-World Demonstration: The Auth Anti-Pattern
243
256
 
244
257
  Developers often manually sync related states, creating a redundant dimension in the Basis:
245
258
 
@@ -250,7 +263,7 @@ const [isLogged, setIsLogged] = useState(false);
250
263
 
251
264
  const onLogin = (userData) => {
252
265
  setUser(userData);
253
- setIsLogged(true); // ⚠️ BASIS ALERT: Always updated in sync with 'user'
266
+ setIsLogged(true); // BASIS ALERT: Always updated in sync with 'user'
254
267
  };
255
268
  ```
256
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.
@@ -264,28 +277,28 @@ const isLogged = useMemo(() => !!user, [user]); // Mathematically clean
264
277
 
265
278
  ---
266
279
 
267
- ## πŸ–₯️ Diagnostic Dashboard
280
+ ## Diagnostic Dashboard
268
281
 
269
282
  Basis provides high-end diagnostic feedback directly in your browser console:
270
283
 
271
- * **πŸ“ Location Tracking:** Identifies exact files and variable names causing redundancy.
272
- * **πŸ› οΈ Refactor Snippets:** Provides dark-themed code blocks you can copy-paste to fix your state architecture.
273
- * **πŸ“Š Health Matrix:** Call `printBasisReport()` to see your **Efficiency Score** and the full **Correlation Matrix** of your application.
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.
274
287
 
275
288
  ---
276
289
 
277
- ## ✨ Key Features
290
+ ## Key Features
278
291
 
279
- * **πŸ•΅οΈβ€β™‚οΈ Content-Agnostic:** Identifies logical links through temporal synchronization, not data types.
280
- * **πŸ›‘οΈ Circuit Breaker:** Halts high-frequency state oscillations (Infinite Loops) to protect the browser thread.
281
- * **πŸ’‘ Causal Detective:** Tracks causality chains from `useEffect` to `useState` to identify cascading renders.
282
- * **πŸ”„ Zero Lock-in:** Simply point your imports back to `'react'` in production. Basis is a **Development-time verification infrastructure**.
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**.
283
296
 
284
297
  ---
285
298
 
286
- ## πŸŽ“ Mathematical Inspiration
299
+ ## Mathematical Inspiration
287
300
 
288
- ### πŸ“œ The Basis Theorem
301
+ ### The Basis Theorem
289
302
  According to Axler (*Linear Algebra Done Right, Definition 2.27*):
290
303
 
291
304
  > A **basis** of $V$ is a list of vectors in $V$ that is **linearly independent** and **spans** $V$.
@@ -304,7 +317,7 @@ React-State-Basis bridges the gap between abstract algebra and UI engineering.
304
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.
305
318
  ---
306
319
 
307
- ### πŸ“œ Implementation of the Linear Dependency Lemma
320
+ ### Implementation of the Linear Dependency Lemma
308
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}$).
309
322
 
310
323
  **React-State-Basis** implements this sequential logic to audit your state:
@@ -316,7 +329,7 @@ According to Axler (*Lemma 2.21*), in a linearly dependent **list** of vectors,
316
329
 
317
330
  ---
318
331
 
319
- ## ⚠️ Design Constraints & Heuristics
332
+ ## Design Constraints & Heuristics
320
333
 
321
334
  React-State-Basis uses probabilistic, time-windowed heuristics to approximate linear dependence.
322
335
  As with any runtime analysis:
@@ -342,8 +355,6 @@ It answers questions like:
342
355
  - *β€œWhich state is the true source of truth?”*
343
356
  - *β€œAm I manually synchronizing derived data?”*
344
357
 
345
- ---
346
-
347
358
  ### **Does this change React behavior or execution order?**
348
359
  No.
349
360
 
@@ -352,19 +363,12 @@ It observes state updates at runtime and logs diagnostics during development.
352
363
 
353
364
  Removing React-State-Basis restores your application to standard React behavior with no residual effects.
354
365
 
355
- ---
356
-
357
366
  ### **Is this safe to use in production?**
358
367
  React-State-Basis is designed for **development-time analysis**.
359
368
 
360
- While it is technically safe to run in production, it:
361
- - adds runtime overhead
362
- - logs diagnostic output
363
- - performs continuous analysis
369
+ Minimal in development, zero in production via Ghost Mode.
364
370
 
365
- For production builds, simply switch your imports back to `'react'`.
366
-
367
- ---
371
+ For production builds, simply switch your imports back to `'react'` or keep as is.
368
372
 
369
373
  ### **How accurate is the redundancy detection?**
370
374
  React-State-Basis uses **time-windowed behavioral analysis**, not formal proofs.
@@ -375,8 +379,6 @@ This means:
375
379
 
376
380
  All results are **advisory** and should be interpreted as architectural signals, not errors.
377
381
 
378
- ---
379
-
380
382
  ### **Can this detect all redundant state?**
381
383
  No-and that’s intentional.
382
384
 
@@ -385,8 +387,6 @@ Two states may contain the same *data* but update independently, which is archit
385
387
 
386
388
  React-State-Basis only flags redundancy when two states behave as a single information dimension over time.
387
389
 
388
- ---
389
-
390
390
  ### **Why not just use selectors or derived state manually?**
391
391
  You should-and React-State-Basis encourages that.
392
392
 
@@ -397,8 +397,6 @@ The challenge is *finding* where derived state should exist in large or evolving
397
397
 
398
398
  It surfaces opportunities for refactoring, not rules you must follow.
399
399
 
400
- ---
401
-
402
400
  ### **Does this work with Redux, Zustand, or other state managers?**
403
401
  React-State-Basis currently instruments **React hooks directly**.
404
402
 
@@ -409,8 +407,6 @@ However, the underlying model is store-agnostic. Any system with:
409
407
 
410
408
  could theoretically be analyzed using the same approach.
411
409
 
412
- ---
413
-
414
410
  ### **What about performance?**
415
411
  React-State-Basis is optimized for real-time use in development.
416
412
 
@@ -421,16 +417,12 @@ Key design choices:
421
417
 
422
418
  For typical applications, overhead is negligible. For extremely high-frequency updates (e.g., animations), React-State-Basis may emit conservative warnings.
423
419
 
424
- ---
425
-
426
420
  ### **Is this β€œformal verification”?**
427
421
  No.
428
422
 
429
423
  React-State-Basis performs **runtime architectural auditing**, not formal mathematical verification.
430
424
  It applies concepts from linear algebra to **observe and analyze behavior**, not to prove correctness.
431
425
 
432
- ---
433
-
434
426
  ### **Who is this tool for?**
435
427
  React-State-Basis is best suited for:
436
428
  - Medium to large React applications
@@ -440,15 +432,11 @@ React-State-Basis is best suited for:
440
432
 
441
433
  It may be unnecessary for small or short-lived projects.
442
434
 
443
- ---
444
-
445
435
  ### **Why linear algebra?**
446
436
  Because state redundancy *is* linear dependence.
447
437
 
448
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.
449
439
 
450
- ---
451
-
452
440
  ### **Will this ever produce false positives?**
453
441
  Yes.
454
442
 
@@ -459,30 +447,27 @@ Think of it as an architectural smoke detector-not a fire marshal.
459
447
 
460
448
  ---
461
449
 
462
- ## πŸ—ΊοΈ Roadmap: The Path to Architectural Rigor
450
+ ## Roadmap: The Path to Architectural Rigor
463
451
 
464
452
  React-State-Basis is evolving from a runtime auditor to a complete development infrastructure. Here is the planned trajectory:
465
453
 
466
- ### **v0.2.0 - Full Hook Parity (Upcoming)**
467
- The goal is to make Basis a complete drop-in replacement for the standard React API.
468
- * **Complete API Coverage:** Adding support for `useRef`, `useCallback`, `useLayoutEffect`, `useTransition`, `useDeferredValue`
469
- * **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.
470
457
  * **Signature Robustness:** Smart disambiguation between dependency arrays and manual labels.
471
458
 
472
- ### **v0.3.0 - Modernity & Production Strategy**
473
- Aligning with the future of React and ensuring zero production cost.
474
- * **React 19 Support:** Integration of `use()`, `useOptimistic()`, and `useActionState()` into the vector space model.
475
- * **Zero-Overhead Production:** Implementing **Conditional Exports**. When in production mode, Basis will pass through raw React hooks with zero logic, ensuring no performance penalty.
476
-
477
- ### **v0.4.0 - Developer Ecosystem & Visuals**
478
- Tools for better ergonomics and high-level insights.
479
- * **CLI Utilities (`rsb-init`, `rsb-clean`):** Automated codemods to instantly inject or remove Basis from large codebases. No more manual search-and-replace.
480
- * **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.
481
463
 
482
- ### **v1.0.0 - Formal Verification**
483
- * **Architectural Gatekeeping:** CI/CD integration to fail builds on infinite loops or critical dimension collapses.
484
- * **KPI Tracking:** Long-term monitoring of your application’s **System Efficiency Score**.
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.
485
468
 
469
+ #### **v1.0.0 β€” Formal Verification**
470
+ * **Architectural Gatekeeping:** CI/CD integration to fail builds on critical dimension collapses.
486
471
  ---
487
472
 
488
473
  ### πŸ“¬ Get Involved
@@ -490,4 +475,4 @@ If you have an idea for a mathematical heuristic or a DX improvement, feel free
490
475
 
491
476
  ---
492
477
  *Developed by LP*
493
- *For engineers who treat software as applied mathematics.* πŸš€πŸ“
478
+ *For engineers who treat software as applied mathematics.* πŸ“
package/dist/index.d.mts CHANGED
@@ -1,7 +1,12 @@
1
- import * as react from 'react';
2
- import react__default, { Dispatch, SetStateAction, DependencyList, EffectCallback, Reducer, Context, ReactNode } from 'react';
1
+ import * as React$1 from 'react';
2
+ import React__default, { Dispatch, SetStateAction, Reducer, DependencyList, EffectCallback, Context, ReactNode } from 'react';
3
3
  export { CSSProperties, Context, DependencyList, Dispatch, EffectCallback, FC, PropsWithChildren, ReactElement, ReactNode, Reducer, SetStateAction } from 'react';
4
4
 
5
+ interface BasisConfig {
6
+ debug: boolean;
7
+ }
8
+ declare let config: BasisConfig;
9
+ declare const configureBasis: (newConfig: Partial<BasisConfig>) => void;
5
10
  declare const history: Map<string, number[]>;
6
11
  declare const currentTickBatch: Set<string>;
7
12
  declare const printBasisHealthReport: (threshold?: number) => void;
@@ -11,6 +16,8 @@ declare const registerVariable: (label: string) => void;
11
16
  declare const unregisterVariable: (label: string) => void;
12
17
  declare const recordUpdate: (label: string) => boolean;
13
18
  declare const __testEngine__: {
19
+ config: BasisConfig;
20
+ configureBasis: (newConfig: Partial<BasisConfig>) => void;
14
21
  history: Map<string, number[]>;
15
22
  currentTickBatch: Set<string>;
16
23
  registerVariable: (label: string) => void;
@@ -21,20 +28,20 @@ declare const __testEngine__: {
21
28
  };
22
29
 
23
30
  declare function useState<T>(initialValue: T, label?: string): [T, Dispatch<SetStateAction<T>>];
24
- declare function useMemo<T>(factory: () => T, depsOrLabel?: DependencyList | string, label?: string): T;
25
- declare function useEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string): void;
26
31
  declare function useReducer<S, A, I>(reducer: Reducer<S, A>, initialArg: I & S, init?: any, label?: string): [S, Dispatch<A>];
27
- declare function createContext<T>(defaultValue: T, label?: string): Context<T>;
32
+ declare function useMemo<T>(factory: () => T, depsOrLabel?: DependencyList | string, label?: string): T;
28
33
  declare function useCallback<T extends (...args: any[]) => any>(callback: T, depsOrLabel?: DependencyList | string, label?: string): T;
29
- declare function useRef<T>(initialValue: T, _label?: string): react.RefObject<T>;
34
+ declare function useEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string): void;
30
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>;
40
+ declare function createContext<T>(defaultValue: T, label?: string): Context<T>;
31
41
  declare function useContext<T>(context: Context<T>): T;
32
42
  declare function useId(_label?: string): string;
33
43
  declare function useDebugValue<T>(value: T, formatter?: (value: T) => any, _label?: string): void;
34
44
  declare function useImperativeHandle<T, R extends T>(ref: React.Ref<T> | undefined, init: () => R, deps?: DependencyList, _label?: string): void;
35
- declare function useInsertionEffect(effect: EffectCallback, deps?: DependencyList, _label?: string): void;
36
- declare function useTransition(_label?: string): [boolean, (callback: () => void) => void];
37
- declare function useDeferredValue<T>(value: T, initialValueOrLabel?: T | string, label?: string): T;
38
45
  declare function useSyncExternalStore<Snapshot>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => Snapshot, getServerSnapshot?: () => Snapshot, _label?: string): Snapshot;
39
46
  declare const __test__: {
40
47
  registerVariable: (label: string) => void;
@@ -50,9 +57,9 @@ interface BasisProviderProps {
50
57
  children: ReactNode;
51
58
  debug?: boolean;
52
59
  }
53
- declare const BasisProvider: react__default.FC<BasisProviderProps>;
60
+ declare const BasisProvider: React__default.FC<BasisProviderProps>;
54
61
  declare const useBasisConfig: () => {
55
62
  debug: boolean;
56
63
  };
57
64
 
58
- export { BasisProvider, __testEngine__, __test__, beginEffectTracking, createContext, currentTickBatch, endEffectTracking, history, printBasisHealthReport, recordUpdate, registerVariable, unregisterVariable, useBasisConfig, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition };
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,7 +1,12 @@
1
- import * as react from 'react';
2
- import react__default, { Dispatch, SetStateAction, DependencyList, EffectCallback, Reducer, Context, ReactNode } from 'react';
1
+ import * as React$1 from 'react';
2
+ import React__default, { Dispatch, SetStateAction, Reducer, DependencyList, EffectCallback, Context, ReactNode } from 'react';
3
3
  export { CSSProperties, Context, DependencyList, Dispatch, EffectCallback, FC, PropsWithChildren, ReactElement, ReactNode, Reducer, SetStateAction } from 'react';
4
4
 
5
+ interface BasisConfig {
6
+ debug: boolean;
7
+ }
8
+ declare let config: BasisConfig;
9
+ declare const configureBasis: (newConfig: Partial<BasisConfig>) => void;
5
10
  declare const history: Map<string, number[]>;
6
11
  declare const currentTickBatch: Set<string>;
7
12
  declare const printBasisHealthReport: (threshold?: number) => void;
@@ -11,6 +16,8 @@ declare const registerVariable: (label: string) => void;
11
16
  declare const unregisterVariable: (label: string) => void;
12
17
  declare const recordUpdate: (label: string) => boolean;
13
18
  declare const __testEngine__: {
19
+ config: BasisConfig;
20
+ configureBasis: (newConfig: Partial<BasisConfig>) => void;
14
21
  history: Map<string, number[]>;
15
22
  currentTickBatch: Set<string>;
16
23
  registerVariable: (label: string) => void;
@@ -21,20 +28,20 @@ declare const __testEngine__: {
21
28
  };
22
29
 
23
30
  declare function useState<T>(initialValue: T, label?: string): [T, Dispatch<SetStateAction<T>>];
24
- declare function useMemo<T>(factory: () => T, depsOrLabel?: DependencyList | string, label?: string): T;
25
- declare function useEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string): void;
26
31
  declare function useReducer<S, A, I>(reducer: Reducer<S, A>, initialArg: I & S, init?: any, label?: string): [S, Dispatch<A>];
27
- declare function createContext<T>(defaultValue: T, label?: string): Context<T>;
32
+ declare function useMemo<T>(factory: () => T, depsOrLabel?: DependencyList | string, label?: string): T;
28
33
  declare function useCallback<T extends (...args: any[]) => any>(callback: T, depsOrLabel?: DependencyList | string, label?: string): T;
29
- declare function useRef<T>(initialValue: T, _label?: string): react.RefObject<T>;
34
+ declare function useEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string): void;
30
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>;
40
+ declare function createContext<T>(defaultValue: T, label?: string): Context<T>;
31
41
  declare function useContext<T>(context: Context<T>): T;
32
42
  declare function useId(_label?: string): string;
33
43
  declare function useDebugValue<T>(value: T, formatter?: (value: T) => any, _label?: string): void;
34
44
  declare function useImperativeHandle<T, R extends T>(ref: React.Ref<T> | undefined, init: () => R, deps?: DependencyList, _label?: string): void;
35
- declare function useInsertionEffect(effect: EffectCallback, deps?: DependencyList, _label?: string): void;
36
- declare function useTransition(_label?: string): [boolean, (callback: () => void) => void];
37
- declare function useDeferredValue<T>(value: T, initialValueOrLabel?: T | string, label?: string): T;
38
45
  declare function useSyncExternalStore<Snapshot>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => Snapshot, getServerSnapshot?: () => Snapshot, _label?: string): Snapshot;
39
46
  declare const __test__: {
40
47
  registerVariable: (label: string) => void;
@@ -50,9 +57,9 @@ interface BasisProviderProps {
50
57
  children: ReactNode;
51
58
  debug?: boolean;
52
59
  }
53
- declare const BasisProvider: react__default.FC<BasisProviderProps>;
60
+ declare const BasisProvider: React__default.FC<BasisProviderProps>;
54
61
  declare const useBasisConfig: () => {
55
62
  debug: boolean;
56
63
  };
57
64
 
58
- export { BasisProvider, __testEngine__, __test__, beginEffectTracking, createContext, currentTickBatch, endEffectTracking, history, printBasisHealthReport, recordUpdate, registerVariable, unregisterVariable, useBasisConfig, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition };
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 };