react-state-basis 0.2.2 → 0.2.3
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 +17 -0
- package/dist/index.d.mts +60 -25
- package/dist/index.d.ts +60 -25
- package/dist/index.js +202 -132
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +162 -124
- package/dist/index.mjs.map +1 -1
- package/dist/jsx-dev-runtime.d.mts +2 -0
- package/dist/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx-dev-runtime.js +33 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-dev-runtime.mjs +7 -0
- package/dist/jsx-dev-runtime.mjs.map +1 -0
- package/dist/jsx-runtime.d.mts +1 -0
- package/dist/jsx-runtime.d.ts +1 -0
- package/dist/jsx-runtime.js +35 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/jsx-runtime.mjs +8 -0
- package/dist/jsx-runtime.mjs.map +1 -0
- package/dist/plugin.js +4 -1
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -206,6 +206,23 @@ Basis performs a global audit of your state space to calculate its **Mathematica
|
|
|
206
206
|
<br/>
|
|
207
207
|
<img src="./example/screenshots/systemHealthReport.gif" width="700" alt="System Health Report Demo" />
|
|
208
208
|
|
|
209
|
+
---
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 🔍 Case Study: Auditing a Production-Ready Admin Dashboard
|
|
213
|
+
|
|
214
|
+
I ran Basis on a complex `shadcn/ui` admin template to see how it handles professional-grade code. Here is what the mathematical engine discovered:
|
|
215
|
+
|
|
216
|
+
<p align="center">
|
|
217
|
+
<img src="./assets/real-world-audit.png" width="800" alt="Basis Real World Audit" />
|
|
218
|
+
</p>
|
|
219
|
+
|
|
220
|
+
### Key Insights from the Audit:
|
|
221
|
+
* **Double Render Detection:** Basis flagged a "Double Render Cycle" in the `use-mobile.tsx` hook. It detected that state was being manually synchronized within an effect, causing unnecessary UI churn.
|
|
222
|
+
* **Stability Verification:** The engine verified that the `Sidebar` callbacks were correctly memoized, providing a "Stable Callback" confirmation.
|
|
223
|
+
* **Valid Projections:** Complex table states (pagination, filters) were confirmed as valid mathematical projections, ensuring no redundant `useState` was used.
|
|
224
|
+
|
|
225
|
+
Math reveals exactly what standard code reviews often miss: the **temporal topology** of your application.
|
|
209
226
|
---
|
|
210
227
|
|
|
211
228
|
## Roadmap
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import * as React
|
|
2
|
-
import React__default, {
|
|
3
|
-
export {
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
3
|
+
export { React };
|
|
4
|
+
export { React as default };
|
|
5
|
+
export { AnchorHTMLAttributes, Attributes, ButtonHTMLAttributes, CSSProperties, ChangeEvent, ComponentProps, ComponentPropsWithRef, ComponentPropsWithoutRef, ComponentType, DependencyList, DetailedHTMLProps, Dispatch, DragEvent, EffectCallback, ElementType, FC, FocusEvent, FormEvent, HTMLAttributes, HTMLProps, InputHTMLAttributes, JSX, Key, KeyboardEvent, MouseEvent, MutableRefObject, PointerEvent, PropsWithChildren, ReactElement, ReactNode, ReactPortal, Reducer, Ref, RefObject, SVGProps, SetStateAction, TouchEvent } from 'react';
|
|
4
6
|
|
|
5
7
|
interface BasisConfig {
|
|
6
8
|
debug: boolean;
|
|
@@ -27,22 +29,38 @@ declare const __testEngine__: {
|
|
|
27
29
|
endEffectTracking: () => void;
|
|
28
30
|
};
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
declare
|
|
35
|
-
declare
|
|
36
|
-
|
|
32
|
+
interface BasisProviderProps {
|
|
33
|
+
children: ReactNode;
|
|
34
|
+
debug?: boolean;
|
|
35
|
+
}
|
|
36
|
+
declare const BasisProvider: React__default.FC<BasisProviderProps>;
|
|
37
|
+
declare const useBasisConfig: () => {
|
|
38
|
+
debug: boolean;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type GetReducerState<R extends React.Reducer<any, any>> = R extends React.Reducer<infer S, any> ? S : never;
|
|
42
|
+
type GetReducerAction<R extends React.Reducer<any, any>> = R extends React.Reducer<any, infer A> ? A : never;
|
|
43
|
+
declare function useState<S>(initialState: S | (() => S), label?: string): [S, React.Dispatch<React.SetStateAction<S>>];
|
|
44
|
+
declare function useRef<T>(initialValue: T): React.RefObject<T>;
|
|
45
|
+
declare function useRef<T>(initialValue: T | null): React.RefObject<T>;
|
|
46
|
+
declare function useRef<T = undefined>(): React.MutableRefObject<T | undefined>;
|
|
47
|
+
declare function useReducer<R extends React.Reducer<any, any>, I>(reducer: R, initialArg: I, init?: any, label?: string): [GetReducerState<R>, React.Dispatch<GetReducerAction<R>>];
|
|
48
|
+
declare function useMemo<T>(factory: () => T, deps: React.DependencyList | undefined, label?: string): T;
|
|
49
|
+
declare function useCallback<T extends (...args: any[]) => any>(callback: T, deps: React.DependencyList, label?: string): T;
|
|
50
|
+
declare function useEffect(effect: React.EffectCallback, deps?: React.DependencyList, label?: string): void;
|
|
51
|
+
declare function useLayoutEffect(effect: React.EffectCallback, deps?: React.DependencyList, label?: string): void;
|
|
37
52
|
declare function useTransition(_label?: string): [boolean, (callback: () => void) => void];
|
|
38
53
|
declare function useDeferredValue<T>(value: T, initialValueOrLabel?: T | string, label?: string): T;
|
|
39
|
-
declare function
|
|
40
|
-
declare
|
|
41
|
-
declare
|
|
42
|
-
declare
|
|
43
|
-
declare
|
|
44
|
-
declare
|
|
45
|
-
declare
|
|
54
|
+
declare function createContext<T>(defaultValue: T, label?: string): React.Context<T>;
|
|
55
|
+
declare const useContext: typeof React.useContext;
|
|
56
|
+
declare const useId: (label?: string) => string;
|
|
57
|
+
declare const useDebugValue: typeof React.useDebugValue;
|
|
58
|
+
declare const useImperativeHandle: typeof React.useImperativeHandle;
|
|
59
|
+
declare const useInsertionEffect: typeof React.useInsertionEffect;
|
|
60
|
+
declare const useSyncExternalStore: any;
|
|
61
|
+
declare function use<T>(usable: React.Usable<T>): T;
|
|
62
|
+
declare function useOptimistic<S, P>(passthrough: S, reducer?: (state: S, payload: P) => S, label?: string): [S, (payload: P) => void];
|
|
63
|
+
declare function useActionState<State, Payload>(action: (state: State, payload: Payload) => Promise<State> | State, initialState: State, permalink?: string, label?: string): [state: State, dispatch: (payload: Payload) => void, isPending: boolean];
|
|
46
64
|
declare const __test__: {
|
|
47
65
|
registerVariable: (label: string) => void;
|
|
48
66
|
unregisterVariable: (label: string) => void;
|
|
@@ -53,13 +71,30 @@ declare const __test__: {
|
|
|
53
71
|
currentTickBatch: any;
|
|
54
72
|
};
|
|
55
73
|
|
|
56
|
-
|
|
57
|
-
children:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
debug: boolean;
|
|
74
|
+
declare const Children: {
|
|
75
|
+
map<T, C>(children: C | readonly C[], fn: (child: C, index: number) => T): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
|
|
76
|
+
forEach<C>(children: C | readonly C[], fn: (child: C, index: number) => void): void;
|
|
77
|
+
count(children: any): number;
|
|
78
|
+
only<C>(children: C): C extends any[] ? never : C;
|
|
79
|
+
toArray(children: React.ReactNode | React.ReactNode[]): Array<Exclude<React.ReactNode, boolean | null | undefined>>;
|
|
63
80
|
};
|
|
81
|
+
declare const Component: typeof React.Component;
|
|
82
|
+
declare const Fragment: React.ExoticComponent<React.FragmentProps>;
|
|
83
|
+
declare const Profiler: React.ExoticComponent<React.ProfilerProps>;
|
|
84
|
+
declare const PureComponent: typeof React.PureComponent;
|
|
85
|
+
declare const StrictMode: React.ExoticComponent<{
|
|
86
|
+
children?: React.ReactNode | undefined;
|
|
87
|
+
}>;
|
|
88
|
+
declare const Suspense: React.ExoticComponent<React.SuspenseProps>;
|
|
89
|
+
declare const cloneElement: typeof React.cloneElement;
|
|
90
|
+
declare const createRef: typeof React.createRef;
|
|
91
|
+
declare const forwardRef: typeof React.forwardRef;
|
|
92
|
+
declare const isValidElement: typeof React.isValidElement;
|
|
93
|
+
declare const lazy: typeof React.lazy;
|
|
94
|
+
declare const memo: typeof React.memo;
|
|
95
|
+
declare const startTransition: typeof React.startTransition;
|
|
96
|
+
declare const version: string;
|
|
97
|
+
declare const createPortal: any;
|
|
98
|
+
declare const flushSync: any;
|
|
64
99
|
|
|
65
|
-
export {
|
|
100
|
+
export { BasisProvider, Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __testEngine__, __test__, beginEffectTracking, cloneElement, config, configureBasis, createContext, createPortal, createRef, currentTickBatch, endEffectTracking, flushSync, forwardRef, history, isValidElement, lazy, memo, printBasisHealthReport, recordUpdate, registerVariable, startTransition, unregisterVariable, use, useActionState, useBasisConfig, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useOptimistic, useReducer, useRef, useState, useSyncExternalStore, useTransition, version };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import * as React
|
|
2
|
-
import React__default, {
|
|
3
|
-
export {
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
3
|
+
export { React };
|
|
4
|
+
export { React as default };
|
|
5
|
+
export { AnchorHTMLAttributes, Attributes, ButtonHTMLAttributes, CSSProperties, ChangeEvent, ComponentProps, ComponentPropsWithRef, ComponentPropsWithoutRef, ComponentType, DependencyList, DetailedHTMLProps, Dispatch, DragEvent, EffectCallback, ElementType, FC, FocusEvent, FormEvent, HTMLAttributes, HTMLProps, InputHTMLAttributes, JSX, Key, KeyboardEvent, MouseEvent, MutableRefObject, PointerEvent, PropsWithChildren, ReactElement, ReactNode, ReactPortal, Reducer, Ref, RefObject, SVGProps, SetStateAction, TouchEvent } from 'react';
|
|
4
6
|
|
|
5
7
|
interface BasisConfig {
|
|
6
8
|
debug: boolean;
|
|
@@ -27,22 +29,38 @@ declare const __testEngine__: {
|
|
|
27
29
|
endEffectTracking: () => void;
|
|
28
30
|
};
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
declare
|
|
35
|
-
declare
|
|
36
|
-
|
|
32
|
+
interface BasisProviderProps {
|
|
33
|
+
children: ReactNode;
|
|
34
|
+
debug?: boolean;
|
|
35
|
+
}
|
|
36
|
+
declare const BasisProvider: React__default.FC<BasisProviderProps>;
|
|
37
|
+
declare const useBasisConfig: () => {
|
|
38
|
+
debug: boolean;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type GetReducerState<R extends React.Reducer<any, any>> = R extends React.Reducer<infer S, any> ? S : never;
|
|
42
|
+
type GetReducerAction<R extends React.Reducer<any, any>> = R extends React.Reducer<any, infer A> ? A : never;
|
|
43
|
+
declare function useState<S>(initialState: S | (() => S), label?: string): [S, React.Dispatch<React.SetStateAction<S>>];
|
|
44
|
+
declare function useRef<T>(initialValue: T): React.RefObject<T>;
|
|
45
|
+
declare function useRef<T>(initialValue: T | null): React.RefObject<T>;
|
|
46
|
+
declare function useRef<T = undefined>(): React.MutableRefObject<T | undefined>;
|
|
47
|
+
declare function useReducer<R extends React.Reducer<any, any>, I>(reducer: R, initialArg: I, init?: any, label?: string): [GetReducerState<R>, React.Dispatch<GetReducerAction<R>>];
|
|
48
|
+
declare function useMemo<T>(factory: () => T, deps: React.DependencyList | undefined, label?: string): T;
|
|
49
|
+
declare function useCallback<T extends (...args: any[]) => any>(callback: T, deps: React.DependencyList, label?: string): T;
|
|
50
|
+
declare function useEffect(effect: React.EffectCallback, deps?: React.DependencyList, label?: string): void;
|
|
51
|
+
declare function useLayoutEffect(effect: React.EffectCallback, deps?: React.DependencyList, label?: string): void;
|
|
37
52
|
declare function useTransition(_label?: string): [boolean, (callback: () => void) => void];
|
|
38
53
|
declare function useDeferredValue<T>(value: T, initialValueOrLabel?: T | string, label?: string): T;
|
|
39
|
-
declare function
|
|
40
|
-
declare
|
|
41
|
-
declare
|
|
42
|
-
declare
|
|
43
|
-
declare
|
|
44
|
-
declare
|
|
45
|
-
declare
|
|
54
|
+
declare function createContext<T>(defaultValue: T, label?: string): React.Context<T>;
|
|
55
|
+
declare const useContext: typeof React.useContext;
|
|
56
|
+
declare const useId: (label?: string) => string;
|
|
57
|
+
declare const useDebugValue: typeof React.useDebugValue;
|
|
58
|
+
declare const useImperativeHandle: typeof React.useImperativeHandle;
|
|
59
|
+
declare const useInsertionEffect: typeof React.useInsertionEffect;
|
|
60
|
+
declare const useSyncExternalStore: any;
|
|
61
|
+
declare function use<T>(usable: React.Usable<T>): T;
|
|
62
|
+
declare function useOptimistic<S, P>(passthrough: S, reducer?: (state: S, payload: P) => S, label?: string): [S, (payload: P) => void];
|
|
63
|
+
declare function useActionState<State, Payload>(action: (state: State, payload: Payload) => Promise<State> | State, initialState: State, permalink?: string, label?: string): [state: State, dispatch: (payload: Payload) => void, isPending: boolean];
|
|
46
64
|
declare const __test__: {
|
|
47
65
|
registerVariable: (label: string) => void;
|
|
48
66
|
unregisterVariable: (label: string) => void;
|
|
@@ -53,13 +71,30 @@ declare const __test__: {
|
|
|
53
71
|
currentTickBatch: any;
|
|
54
72
|
};
|
|
55
73
|
|
|
56
|
-
|
|
57
|
-
children:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
debug: boolean;
|
|
74
|
+
declare const Children: {
|
|
75
|
+
map<T, C>(children: C | readonly C[], fn: (child: C, index: number) => T): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
|
|
76
|
+
forEach<C>(children: C | readonly C[], fn: (child: C, index: number) => void): void;
|
|
77
|
+
count(children: any): number;
|
|
78
|
+
only<C>(children: C): C extends any[] ? never : C;
|
|
79
|
+
toArray(children: React.ReactNode | React.ReactNode[]): Array<Exclude<React.ReactNode, boolean | null | undefined>>;
|
|
63
80
|
};
|
|
81
|
+
declare const Component: typeof React.Component;
|
|
82
|
+
declare const Fragment: React.ExoticComponent<React.FragmentProps>;
|
|
83
|
+
declare const Profiler: React.ExoticComponent<React.ProfilerProps>;
|
|
84
|
+
declare const PureComponent: typeof React.PureComponent;
|
|
85
|
+
declare const StrictMode: React.ExoticComponent<{
|
|
86
|
+
children?: React.ReactNode | undefined;
|
|
87
|
+
}>;
|
|
88
|
+
declare const Suspense: React.ExoticComponent<React.SuspenseProps>;
|
|
89
|
+
declare const cloneElement: typeof React.cloneElement;
|
|
90
|
+
declare const createRef: typeof React.createRef;
|
|
91
|
+
declare const forwardRef: typeof React.forwardRef;
|
|
92
|
+
declare const isValidElement: typeof React.isValidElement;
|
|
93
|
+
declare const lazy: typeof React.lazy;
|
|
94
|
+
declare const memo: typeof React.memo;
|
|
95
|
+
declare const startTransition: typeof React.startTransition;
|
|
96
|
+
declare const version: string;
|
|
97
|
+
declare const createPortal: any;
|
|
98
|
+
declare const flushSync: any;
|
|
64
99
|
|
|
65
|
-
export {
|
|
100
|
+
export { BasisProvider, Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __testEngine__, __test__, beginEffectTracking, cloneElement, config, configureBasis, createContext, createPortal, createRef, currentTickBatch, endEffectTracking, flushSync, forwardRef, history, isValidElement, lazy, memo, printBasisHealthReport, recordUpdate, registerVariable, startTransition, unregisterVariable, use, useActionState, useBasisConfig, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useOptimistic, useReducer, useRef, useState, useSyncExternalStore, useTransition, version };
|